aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/atl1
diff options
context:
space:
mode:
authorJay Cliburn <jacliburn@bellsouth.net>2007-02-14 21:14:55 -0500
committerJeff Garzik <jeff@garzik.org>2007-02-17 15:16:08 -0500
commitfd8c5a7da3c48e53c7859d9f0c1d82ba02ca0a20 (patch)
tree930be7e89650a4b82ca589f60c2a34391d8e09b6 /drivers/net/atl1
parenta62daa4c7544a0f0ca94d61458e3f78f630e0c05 (diff)
atl1: read MAC address from register
On some Asus motherboards containing the L1 NIC, the MAC address is written by the BIOS directly to the MAC register during POST, and is not stored in eeprom. If we don't succeed in fetching the MAC address from eeprom or spi, try reading it directly from the MAC register. Suggested by Xiong Huang. And do some cleanup while we've got the hood up... Signed-off-by: Jay Cliburn <jacliburn@bellsouth.net> Signed-off-by: Chris Snook <csnook@redhat.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/atl1')
-rw-r--r--drivers/net/atl1/atl1_hw.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/drivers/net/atl1/atl1_hw.c b/drivers/net/atl1/atl1_hw.c
index e28707a2b482..314dbaabb642 100644
--- a/drivers/net/atl1/atl1_hw.c
+++ b/drivers/net/atl1/atl1_hw.c
@@ -243,14 +243,8 @@ static int atl1_get_permanent_address(struct atl1_hw *hw)
243 i += 4; 243 i += 4;
244 } 244 }
245 245
246/* 246 *(u32 *) &eth_addr[2] = swab32(addr[0]);
247 * The following 2 lines are the Attansic originals. Saving for posterity. 247 *(u16 *) &eth_addr[0] = swab16(*(u16 *) &addr[1]);
248 * *(u32 *) & eth_addr[2] = LONGSWAP(addr[0]);
249 * *(u16 *) & eth_addr[0] = SHORTSWAP(*(u16 *) & addr[1]);
250 */
251 *(u32 *) & eth_addr[2] = swab32(addr[0]);
252 *(u16 *) & eth_addr[0] = swab16(*(u16 *) & addr[1]);
253
254 if (is_valid_ether_addr(eth_addr)) { 248 if (is_valid_ether_addr(eth_addr)) {
255 memcpy(hw->perm_mac_addr, eth_addr, ETH_ALEN); 249 memcpy(hw->perm_mac_addr, eth_addr, ETH_ALEN);
256 return 0; 250 return 0;
@@ -281,17 +275,28 @@ static int atl1_get_permanent_address(struct atl1_hw *hw)
281 i += 4; 275 i += 4;
282 } 276 }
283 277
284/* 278 *(u32 *) &eth_addr[2] = swab32(addr[0]);
285 * The following 2 lines are the Attansic originals. Saving for posterity. 279 *(u16 *) &eth_addr[0] = swab16(*(u16 *) &addr[1]);
286 * *(u32 *) & eth_addr[2] = LONGSWAP(addr[0]);
287 * *(u16 *) & eth_addr[0] = SHORTSWAP(*(u16 *) & addr[1]);
288 */
289 *(u32 *) & eth_addr[2] = swab32(addr[0]);
290 *(u16 *) & eth_addr[0] = swab16(*(u16 *) & addr[1]);
291 if (is_valid_ether_addr(eth_addr)) { 280 if (is_valid_ether_addr(eth_addr)) {
292 memcpy(hw->perm_mac_addr, eth_addr, ETH_ALEN); 281 memcpy(hw->perm_mac_addr, eth_addr, ETH_ALEN);
293 return 0; 282 return 0;
294 } 283 }
284
285 /*
286 * On some motherboards, the MAC address is written by the
287 * BIOS directly to the MAC register during POST, and is
288 * not stored in eeprom. If all else thus far has failed
289 * to fetch the permanent MAC address, try reading it directly.
290 */
291 addr[0] = ioread32(hw->hw_addr + REG_MAC_STA_ADDR);
292 addr[1] = ioread16(hw->hw_addr + (REG_MAC_STA_ADDR + 4));
293 *(u32 *) &eth_addr[2] = swab32(addr[0]);
294 *(u16 *) &eth_addr[0] = swab16(*(u16 *) &addr[1]);
295 if (is_valid_ether_addr(eth_addr)) {
296 memcpy(hw->perm_mac_addr, eth_addr, ETH_ALEN);
297 return 0;
298 }
299
295 return 1; 300 return 1;
296} 301}
297 302