summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-02-11 19:36:20 -0500
committerWolfgang Denk <wd@denx.de>2009-03-20 22:39:11 +0100
commit0107cf66f7346e8c7d6cf0fe99d2f265134afd59 (patch)
treec1e55d8bda28e709db5522892d26d683f9acc9dd
parent19b5b533ccd522abeb501d510750693c35e20456 (diff)
nx823: get mac address from environment
The environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly. For the nx823, the serial number is moved out of load_sernum_ethaddr() and into misc_init_r() as is the env setup. This lets us kill off the former function in the process. Signed-off-by: Mike Frysinger <vapier@gentoo.org> CC: Ben Warren <biggerbadderben@gmail.com>
-rw-r--r--board/nx823/flash.c5
-rw-r--r--board/nx823/nx823.c41
-rw-r--r--lib_ppc/board.c4
3 files changed, 19 insertions, 31 deletions
diff --git a/board/nx823/flash.c b/board/nx823/flash.c
index 194d841e4..336e70412 100644
--- a/board/nx823/flash.c
+++ b/board/nx823/flash.c
@@ -27,8 +27,9 @@
#include <common.h>
#include <mpc8xx.h>
+DECLARE_GLOBAL_DATA_PTR;
+
flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */
-extern u_long *my_sernum; /* from nx823.c */
/*-----------------------------------------------------------------------
* Protection Flags:
@@ -346,7 +347,7 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
if (addr >= CONFIG_SYS_FLASH_SN_SECTOR && addr < CONFIG_SYS_FLASH_SN_BASE)
{
u_long dest = CONFIG_SYS_FLASH_SN_BASE;
- u_short *sn = (u_short *)my_sernum;
+ u_short *sn = (u_short *)gd->bd->bi_sernum;
printf("(saving sernum)");
for (i=0; i<4; i++)
diff --git a/board/nx823/nx823.c b/board/nx823/nx823.c
index df9aaab7a..6ec29dc85 100644
--- a/board/nx823/nx823.c
+++ b/board/nx823/nx823.c
@@ -360,39 +360,30 @@ static long int dram_size (long int mamr_value, long int *base,
return (get_ram_size (base, maxsize));
}
-u_long *my_sernum;
-
int misc_init_r (void)
{
+ int i;
char tmp[50];
- u_char *e = gd->bd->bi_enetaddr;
+ uchar ethaddr[6];
+ bd_t *bd = gd->bd;
+ ulong my_sernum = bd->bi_sernum;
- /* save serial numbre from flash (uniquely programmed) */
- my_sernum = malloc (8);
- memcpy (my_sernum, gd->bd->bi_sernum, 8);
+ /* load unique serial number */
+ for (i = 0; i < 8; ++i)
+ bd->bi_sernum[i] = *(u_char *) (CONFIG_SYS_FLASH_SN_BASE + i);
/* save env variables according to sernum */
sprintf (tmp, "%08lx%08lx", my_sernum[0], my_sernum[1]);
setenv ("serial#", tmp);
- sprintf (tmp, "%02x:%02x:%02x:%02x:%02x:%02x", e[0], e[1], e[2], e[3],
- e[4], e[5]);
- setenv ("ethaddr", tmp);
- return (0);
-}
-
-void load_sernum_ethaddr (void)
-{
- int i;
- bd_t *bd = gd->bd;
-
- for (i = 0; i < 8; i++) {
- bd->bi_sernum[i] = *(u_char *) (CONFIG_SYS_FLASH_SN_BASE + i);
+ if (!eth_getenv_enetaddr("ethaddr", ethaddr)) {
+ ethaddr[0] = 0x10;
+ ethaddr[1] = 0x20;
+ ethaddr[2] = 0x30;
+ ethaddr[3] = bd->bi_sernum[1] << 4 | bd->bi_sernum[2];
+ ethaddr[4] = bd->bi_sernum[5];
+ ethaddr[5] = bd->bi_sernum[6];
}
- bd->bi_enetaddr[0] = 0x10;
- bd->bi_enetaddr[1] = 0x20;
- bd->bi_enetaddr[2] = 0x30;
- bd->bi_enetaddr[3] = bd->bi_sernum[1] << 4 | bd->bi_sernum[2];
- bd->bi_enetaddr[4] = bd->bi_sernum[5];
- bd->bi_enetaddr[5] = bd->bi_sernum[6];
+
+ return 0;
}
diff --git a/lib_ppc/board.c b/lib_ppc/board.c
index f69c5f4f1..b1612ff01 100644
--- a/lib_ppc/board.c
+++ b/lib_ppc/board.c
@@ -899,10 +899,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
bd->bi_ethspeed = 0xFFFF;
#endif
-#ifdef CONFIG_NX823
- load_sernum_ethaddr ();
-#endif
-
#ifdef CONFIG_HAS_ETH1
/* handle the 2nd ethernet address */