Commit 17b8bb3e authored by Joachim Eastwood's avatar Joachim Eastwood Committed by David S. Miller

net/macb: check all address registers sets

The macb driver in u-boot uses the first register set while
the at91_ether driver in u-boot uses the second register set.

By checking all register set, like at91_ether does, this code
can be shared between the drivers.

This only changes behavior on macb if no vaild address
is found in the first register set.
Signed-off-by: default avatarJoachim Eastwood <manabian@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 01cbc1a7
...@@ -114,23 +114,28 @@ static void __init macb_get_hwaddr(struct macb *bp) ...@@ -114,23 +114,28 @@ static void __init macb_get_hwaddr(struct macb *bp)
u32 bottom; u32 bottom;
u16 top; u16 top;
u8 addr[6]; u8 addr[6];
int i;
bottom = macb_or_gem_readl(bp, SA1B); /* Check all 4 address register for vaild address */
top = macb_or_gem_readl(bp, SA1T); for (i = 0; i < 4; i++) {
bottom = macb_or_gem_readl(bp, SA1B + i * 8);
addr[0] = bottom & 0xff; top = macb_or_gem_readl(bp, SA1T + i * 8);
addr[1] = (bottom >> 8) & 0xff;
addr[2] = (bottom >> 16) & 0xff; addr[0] = bottom & 0xff;
addr[3] = (bottom >> 24) & 0xff; addr[1] = (bottom >> 8) & 0xff;
addr[4] = top & 0xff; addr[2] = (bottom >> 16) & 0xff;
addr[5] = (top >> 8) & 0xff; addr[3] = (bottom >> 24) & 0xff;
addr[4] = top & 0xff;
if (is_valid_ether_addr(addr)) { addr[5] = (top >> 8) & 0xff;
memcpy(bp->dev->dev_addr, addr, sizeof(addr));
} else { if (is_valid_ether_addr(addr)) {
netdev_info(bp->dev, "invalid hw address, using random\n"); memcpy(bp->dev->dev_addr, addr, sizeof(addr));
eth_hw_addr_random(bp->dev); return;
}
} }
netdev_info(bp->dev, "invalid hw address, using random\n");
eth_hw_addr_random(bp->dev);
} }
static int macb_mdio_read(struct mii_bus *bus, int mii_id, int regnum) static int macb_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment