diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-02-11 19:01:26 -0500 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2009-03-20 22:39:10 +0100 |
commit | d3f871482f06f6a4eaf4a3fafde84846bad87b4f (patch) | |
tree | 992dd06b484d20eabb22d2a3d549b661f85dc9ea /drivers/net/dm9000x.c | |
parent | b6b4625d175019e387e5b0f65a17322a78f6bb90 (diff) |
drivers/net/: 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.
The drivers that get converted here:
3c589
4xx_enet
dc2114x
dm9000x
enc28j60
fsl_mcdmafec
ks8695eth
mcffec
rtl8019
rtl8169
s3c4510b_eth
xilinx_emac
xilinx_emaclite
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
CC: Rolf Offermanns <rof@sysgo.de>
CC: Stefan Roese <sr@denx.de>
CC: Sascha Hauer <saschahauer@web.de>
CC: TsiChung Liew <Tsi-Chung.Liew@freescale.com>
CC: Greg Ungerer <greg.ungerer@opengear.com>
CC: Xue Ligong <lgxue@hotmail.com>
CC: Masami Komiya <mkomiya@sonare.it>
CC: Curt Brune <curt@cucy.com>
CC: Michal SIMEK <monstr@monstr.eu>
Diffstat (limited to 'drivers/net/dm9000x.c')
-rw-r--r-- | drivers/net/dm9000x.c | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c index ffb739de9f..c52d30790d 100644 --- a/drivers/net/dm9000x.c +++ b/drivers/net/dm9000x.c @@ -287,6 +287,7 @@ eth_init(bd_t * bd) int i, oft, lnk; u8 io_mode; struct board_info *db = &dm9000_info; + uchar enetaddr[6]; DM9000_DBG("eth_init()\n"); @@ -345,32 +346,19 @@ eth_init(bd_t * bd) DM9000_iow(DM9000_ISR, ISR_ROOS | ISR_ROS | ISR_PTS | ISR_PRS); /* Set Node address */ + if (!eth_getenv_enetaddr("ethaddr", enetaddr)) { #if !defined(CONFIG_AT91SAM9261EK) - for (i = 0; i < 6; i++) - ((u16 *) bd->bi_enetaddr)[i] = read_srom_word(i); + for (i = 0; i < 6; i++) + enetaddr[i] = read_srom_word(i); + eth_setenv_enetaddr("ethaddr", enetaddr); #endif - - if (is_zero_ether_addr(bd->bi_enetaddr) || - is_multicast_ether_addr(bd->bi_enetaddr)) { - /* try reading from environment */ - u8 i; - char *s, *e; - s = getenv ("ethaddr"); - for (i = 0; i < 6; ++i) { - bd->bi_enetaddr[i] = s ? - simple_strtoul (s, &e, 16) : 0; - if (s) - s = (*e) ? e + 1 : e; - } } - printf("MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", bd->bi_enetaddr[0], - bd->bi_enetaddr[1], bd->bi_enetaddr[2], bd->bi_enetaddr[3], - bd->bi_enetaddr[4], bd->bi_enetaddr[5]); + printf("MAC: %pM\n", enetaddr); /* fill device MAC address registers */ for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++) - DM9000_iow(oft, bd->bi_enetaddr[i]); + DM9000_iow(oft, enetaddr[i]); for (i = 0, oft = 0x16; i < 8; i++, oft++) DM9000_iow(oft, 0xff); |