aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/cadence
diff options
context:
space:
mode:
authorJoachim Eastwood <manabian@gmail.com>2012-11-07 03:14:51 -0500
committerDavid S. Miller <davem@davemloft.net>2012-11-07 17:44:37 -0500
commitd25e78aaf963ae400a245fc2ae5af0e3208b7187 (patch)
tree1e77ef60dfcab0d9c16b4636491d929e0dc030d8 /drivers/net/ethernet/cadence
parent17b8bb3e209d3681e9c94786de845f0d5118eebb (diff)
net/macb: support reversed hw addr
This is used on one AT91RM9200 board where a bootloader stores the Ethernet address in the wrong order. Support this on macb so address setting functions can be shared with the at91_ether driver. Signed-off-by: Joachim Eastwood <manabian@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/cadence')
-rw-r--r--drivers/net/ethernet/cadence/macb.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 3b609bed70bc..a9e5a50ffc35 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -111,22 +111,34 @@ static void __macb_set_hwaddr(struct macb *bp)
111 111
112static void __init macb_get_hwaddr(struct macb *bp) 112static void __init macb_get_hwaddr(struct macb *bp)
113{ 113{
114 struct macb_platform_data *pdata;
114 u32 bottom; 115 u32 bottom;
115 u16 top; 116 u16 top;
116 u8 addr[6]; 117 u8 addr[6];
117 int i; 118 int i;
118 119
120 pdata = bp->pdev->dev.platform_data;
121
119 /* Check all 4 address register for vaild address */ 122 /* Check all 4 address register for vaild address */
120 for (i = 0; i < 4; i++) { 123 for (i = 0; i < 4; i++) {
121 bottom = macb_or_gem_readl(bp, SA1B + i * 8); 124 bottom = macb_or_gem_readl(bp, SA1B + i * 8);
122 top = macb_or_gem_readl(bp, SA1T + i * 8); 125 top = macb_or_gem_readl(bp, SA1T + i * 8);
123 126
124 addr[0] = bottom & 0xff; 127 if (pdata && pdata->rev_eth_addr) {
125 addr[1] = (bottom >> 8) & 0xff; 128 addr[5] = bottom & 0xff;
126 addr[2] = (bottom >> 16) & 0xff; 129 addr[4] = (bottom >> 8) & 0xff;
127 addr[3] = (bottom >> 24) & 0xff; 130 addr[3] = (bottom >> 16) & 0xff;
128 addr[4] = top & 0xff; 131 addr[2] = (bottom >> 24) & 0xff;
129 addr[5] = (top >> 8) & 0xff; 132 addr[1] = top & 0xff;
133 addr[0] = (top & 0xff00) >> 8;
134 } else {
135 addr[0] = bottom & 0xff;
136 addr[1] = (bottom >> 8) & 0xff;
137 addr[2] = (bottom >> 16) & 0xff;
138 addr[3] = (bottom >> 24) & 0xff;
139 addr[4] = top & 0xff;
140 addr[5] = (top >> 8) & 0xff;
141 }
130 142
131 if (is_valid_ether_addr(addr)) { 143 if (is_valid_ether_addr(addr)) {
132 memcpy(bp->dev->dev_addr, addr, sizeof(addr)); 144 memcpy(bp->dev->dev_addr, addr, sizeof(addr));