[U-Boot] [PATCH 01/27] Blackfin: bfin_mac: force board_get_enetaddr() usage

Mike Frysinger vapier at gentoo.org
Thu Jan 29 01:03:10 CET 2009


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 <vapier at gentoo.org>
CC: Ben Warren <biggerbadderben at gmail.com>
---
 drivers/net/bfin_mac.c |   24 +++++++++++++++++++++++-
 include/common.h       |    2 +-
 lib_blackfin/board.c   |   31 ++-----------------------------
 3 files changed, 26 insertions(+), 31 deletions(-)

diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index dddbb78..f074f17 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,27 @@ int bfin_EMAC_initialize(bd_t *bis)
 
 	eth_register(dev);
 
+	ethaddr = getenv("ethaddr");
+#ifndef CONFIG_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
+#endif
+	{
+		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"))
-- 
1.6.1.1



More information about the U-Boot mailing list