[U-Boot] [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash
Yann Vernier
yann.vernier at orsoc.se
Thu Aug 9 15:33:06 CEST 2012
Previously code to do this was in the Ethernet driver itself.
Since it is board specific, moved it here, and altered it to
support preset MAC from environment.
Signed-off-by: Yann Vernier <yann.vernier at orsoc.se>
---
board/cm4008/cm4008.c | 12 ++++++++++++
board/cm41xx/cm41xx.c | 12 ++++++++++++
2 files changed, 24 insertions(+)
diff --git a/board/cm4008/cm4008.c b/board/cm4008/cm4008.c
index 6c0da9a..e14f8f4 100644
--- a/board/cm4008/cm4008.c
+++ b/board/cm4008/cm4008.c
@@ -75,10 +75,22 @@ int board_late_init (void)
return 0;
}
+#ifdef CONFIG_DRIVER_KS8695ETH
int board_eth_init(bd_t *bis)
{
+ uchar enetaddr[6];
+ const uchar * const fp=CONFIG_SYS_FLASH_BASE+0x1c000;
+
+ /* read MAC address from flash */
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+ memcpy(&enetaddr[0], fp, 6);
+ if (is_valid_ether_addr(enetaddr))
+ eth_setenv_enetaddr("ethaddr", enetaddr);
+ }
+
return ks8695_eth_initialize();
}
+#endif
int board_init (void)
{
diff --git a/board/cm41xx/cm41xx.c b/board/cm41xx/cm41xx.c
index 6aef617..771701d 100644
--- a/board/cm41xx/cm41xx.c
+++ b/board/cm41xx/cm41xx.c
@@ -75,10 +75,22 @@ int board_late_init (void)
return 0;
}
+#ifdef CONFIG_DRIVER_KS8695ETH
int board_eth_init(bd_t *bis)
{
+ uchar enetaddr[6];
+ const uchar * const fp=CONFIG_SYS_FLASH_BASE+0x1c000;
+
+ /* read MAC address from flash */
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+ memcpy(&enetaddr[0], fp, 6);
+ if (is_valid_ether_addr(enetaddr))
+ eth_setenv_enetaddr("ethaddr", enetaddr);
+ }
+
return ks8695_eth_initialize();
}
+#endif
int board_init (void)
{
--
1.7.10.4
More information about the U-Boot
mailing list