[U-Boot] [PATCH 5/8] mvgbe: Support preserving the existing MAC address
Michael Spang
mspang at csclub.uwaterloo.ca
Sat Jan 29 02:00:38 CET 2011
The MVGBE driver either gets the MAC from the environment, or invents
one. This allows the driver to leave the existing address alone in
case it is initialized before U-Boot starts.
Signed-off-by: Michael Spang <mspang at csclub.uwaterloo.ca>
---
drivers/net/mvgbe.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/drivers/net/mvgbe.c b/drivers/net/mvgbe.c
index c701f43..0e0dae1 100644
--- a/drivers/net/mvgbe.c
+++ b/drivers/net/mvgbe.c
@@ -380,6 +380,22 @@ static void port_uc_addr_set(struct mvgbe_registers *regs, u8 * p_addr)
}
/*
+ * port_uc_addr_get - This function gets the port unicast address.
+ */
+static void port_uc_addr_get(struct mvgbe_registers *regs, u8 * p_addr)
+{
+ u32 mac_l = MVGBE_REG_RD(regs->macal);
+ u32 mac_h = MVGBE_REG_RD(regs->macah);
+
+ p_addr[0] = (mac_h >> 24);
+ p_addr[1] = (mac_h >> 16);
+ p_addr[2] = (mac_h >> 8);
+ p_addr[3] = (mac_h >> 0);
+ p_addr[4] = (mac_l >> 8);
+ p_addr[5] = (mac_l >> 0);
+}
+
+/*
* mvgbe_init_rx_desc_ring - Curve a Rx chain desc list and buffer in memory.
*/
static void mvgbe_init_rx_desc_ring(struct mvgbe_device *dmvgbe)
@@ -718,6 +734,9 @@ error1:
return -1;
}
+#if defined(CONFIG_PRESERVE_LOCAL_MAC)
+ port_uc_addr_get(dmvgbe->regs, dmvgbe->dev.enetaddr);
+#else
while (!eth_getenv_enetaddr(s, dev->enetaddr)) {
/* Generate Private MAC addr if not set */
dev->enetaddr[0] = 0x02;
@@ -736,6 +755,7 @@ error1:
#endif
eth_setenv_enetaddr(s, dev->enetaddr);
}
+#endif
dev->init = (void *)mvgbe_init;
dev->halt = (void *)mvgbe_halt;
--
1.7.2.3
More information about the U-Boot
mailing list