From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Warren Date: Wed, 28 Jan 2009 23:53:43 -0800 Subject: [U-Boot] [PATCH 01/27 v2] Blackfin: bfin_mac: force board_get_enetaddr() usage In-Reply-To: <1233212358-27956-1-git-send-email-vapier@gentoo.org> References: <49814203.7020604@gmail.com> <1233212358-27956-1-git-send-email-vapier@gentoo.org> Message-ID: <49816087.6050507@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Mike Frysinger wrote: > Since the on-chip MAC does not have an eeprom or similar interface, force > all Blackfin boards that use this to define their own board_get_enetaddr() > function. > > Signed-off-by: Mike Frysinger > CC: Ben Warren > Acked-by: Ben Warren > --- > v2 > - drop CONFIG_ETHADDR handling > > drivers/net/bfin_mac.c | 21 ++++++++++++++++++++- > include/common.h | 2 +- > lib_blackfin/board.c | 31 ++----------------------------- > 3 files changed, 23 insertions(+), 31 deletions(-) > > diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c > index dddbb78..ac65d3e 100644 > --- a/drivers/net/bfin_mac.c > +++ b/drivers/net/bfin_mac.c > @@ -70,8 +70,9 @@ const ADI_DMA_CONFIG_REG txdmacfg = { > .b_FLOW = 7 /* large desc flow */ > }; > > -int bfin_EMAC_initialize(bd_t *bis) > +int bfin_EMAC_initialize(bd_t *bd) > { > + const char *ethaddr; > struct eth_device *dev; > dev = (struct eth_device *)malloc(sizeof(*dev)); > if (dev == NULL) > @@ -89,6 +90,24 @@ int bfin_EMAC_initialize(bd_t *bis) > > eth_register(dev); > > + ethaddr = getenv("ethaddr"); > + if (ethaddr == NULL) { > + char nid[20]; > + board_get_enetaddr(bd->bi_enetaddr); > + sprintf(nid, "%02X:%02X:%02X:%02X:%02X:%02X", > + bd->bi_enetaddr[0], bd->bi_enetaddr[1], > + bd->bi_enetaddr[2], bd->bi_enetaddr[3], > + bd->bi_enetaddr[4], bd->bi_enetaddr[5]); > + setenv("ethaddr", nid); > + } else { > + int i; > + char *e; > + for (i = 0; i < 6; ++i) { > + bd->bi_enetaddr[i] = simple_strtoul(ethaddr, &e, 16); > + ethaddr = (*e) ? e + 1 : e; > + } > + } > + > return 0; > } > > diff --git a/include/common.h b/include/common.h > index afee188..d4c361a 100644 > --- a/include/common.h > +++ b/include/common.h > @@ -354,7 +354,7 @@ void board_ether_init (void); > #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_MBX) || \ > defined(CONFIG_IAD210) || defined(CONFIG_XPEDITE1K) || \ > defined(CONFIG_METROBOX) || defined(CONFIG_KAREF) || \ > - defined(CONFIG_V38B) > + defined(CONFIG_V38B) || defined(CONFIG_BFIN_MAC) > void board_get_enetaddr (uchar *addr); > #endif > > diff --git a/lib_blackfin/board.c b/lib_blackfin/board.c > index 01b71d4..c1fa61b 100644 > --- a/lib_blackfin/board.c > +++ b/lib_blackfin/board.c > @@ -378,35 +378,6 @@ void board_init_r(gd_t * id, ulong dest_addr) > /* relocate environment function pointers etc. */ > env_relocate(); > > -#ifdef CONFIG_CMD_NET > - /* board MAC address */ > - s = getenv("ethaddr"); > - if (s == NULL) { > -# ifndef CONFIG_ETHADDR > -# if 0 > - if (!board_get_enetaddr(bd->bi_enetaddr)) { > - char nid[20]; > - sprintf(nid, "%02X:%02X:%02X:%02X:%02X:%02X", > - bd->bi_enetaddr[0], bd->bi_enetaddr[1], > - bd->bi_enetaddr[2], bd->bi_enetaddr[3], > - bd->bi_enetaddr[4], bd->bi_enetaddr[5]); > - setenv("ethaddr", nid); > - } > -# endif > -# endif > - } else { > - int i; > - char *e; > - for (i = 0; i < 6; ++i) { > - bd->bi_enetaddr[i] = simple_strtoul(s, &e, 16); > - s = (*e) ? e + 1 : e; > - } > - } > - > - /* IP Address */ > - bd->bi_ip_addr = getenv_IPaddr("ipaddr"); > -#endif > - > /* Initialize devices */ > devices_init(); > jumptable_init(); > @@ -433,6 +404,8 @@ void board_init_r(gd_t * id, ulong dest_addr) > #endif > > #ifdef CONFIG_CMD_NET > + /* IP Address */ > + bd->bi_ip_addr = getenv_IPaddr("ipaddr"); > printf("Net: "); > eth_initialize(gd->bd); > if (getenv("ethaddr")) > thanks, Ben