summaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2013-10-03 11:45:29 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-10-06 13:36:14 +0200
commit7ccaaf71fe84f090b359d8d21e76aaff84d295f0 (patch)
tree3ab8fa5a916b56571769a2967f4f2204e6353c4b /drivers/net
parenta99a74f87faf6ae2cb7922095b1e24a39c74c166 (diff)
downloadbarebox-7ccaaf71fe84f090b359d8d21e76aaff84d295f0.tar.gz
barebox-7ccaaf71fe84f090b359d8d21e76aaff84d295f0.tar.xz
macb: add support to read the mac address from register
check the 4 mac address register and return at the first valid Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/macb.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index b1f544b5ab..d8523cee3a 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -458,9 +458,31 @@ static int macb_phy_write(struct mii_bus *bus, int addr, int reg, u16 value)
static int macb_get_ethaddr(struct eth_device *edev, unsigned char *adr)
{
struct macb_device *macb = edev->priv;
+ u32 bottom;
+ u16 top;
+ u8 addr[6];
+ int i;
dev_dbg(macb->dev, "%s\n", __func__);
+ /* Check all 4 address register for vaild address */
+ for (i = 0; i < 4; i++) {
+ bottom = macb_or_gem_readl(macb, SA1B + i * 8);
+ top = macb_or_gem_readl(macb, SA1T + i * 8);
+
+ addr[0] = bottom & 0xff;
+ addr[1] = (bottom >> 8) & 0xff;
+ addr[2] = (bottom >> 16) & 0xff;
+ addr[3] = (bottom >> 24) & 0xff;
+ addr[4] = top & 0xff;
+ addr[5] = (top >> 8) & 0xff;
+
+ if (is_valid_ether_addr(addr)) {
+ memcpy(adr, addr, sizeof(addr));
+ return 0;
+ }
+ }
+
return -1;
}