Commit fd8c5a7d authored by Jay Cliburn's avatar Jay Cliburn Committed by Jeff Garzik

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: default avatarJay Cliburn <jacliburn@bellsouth.net>
Signed-off-by: default avatarChris Snook <csnook@redhat.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent a62daa4c
...@@ -243,14 +243,8 @@ static int atl1_get_permanent_address(struct atl1_hw *hw) ...@@ -243,14 +243,8 @@ static int atl1_get_permanent_address(struct atl1_hw *hw)
i += 4; i += 4;
} }
/* *(u32 *) &eth_addr[2] = swab32(addr[0]);
* The following 2 lines are the Attansic originals. Saving for posterity. *(u16 *) &eth_addr[0] = swab16(*(u16 *) &addr[1]);
* *(u32 *) & eth_addr[2] = LONGSWAP(addr[0]);
* *(u16 *) & eth_addr[0] = SHORTSWAP(*(u16 *) & addr[1]);
*/
*(u32 *) & eth_addr[2] = swab32(addr[0]);
*(u16 *) & eth_addr[0] = swab16(*(u16 *) & addr[1]);
if (is_valid_ether_addr(eth_addr)) { if (is_valid_ether_addr(eth_addr)) {
memcpy(hw->perm_mac_addr, eth_addr, ETH_ALEN); memcpy(hw->perm_mac_addr, eth_addr, ETH_ALEN);
return 0; return 0;
...@@ -281,17 +275,28 @@ static int atl1_get_permanent_address(struct atl1_hw *hw) ...@@ -281,17 +275,28 @@ static int atl1_get_permanent_address(struct atl1_hw *hw)
i += 4; i += 4;
} }
/* *(u32 *) &eth_addr[2] = swab32(addr[0]);
* The following 2 lines are the Attansic originals. Saving for posterity. *(u16 *) &eth_addr[0] = swab16(*(u16 *) &addr[1]);
* *(u32 *) & eth_addr[2] = LONGSWAP(addr[0]); if (is_valid_ether_addr(eth_addr)) {
* *(u16 *) & eth_addr[0] = SHORTSWAP(*(u16 *) & addr[1]); memcpy(hw->perm_mac_addr, eth_addr, ETH_ALEN);
return 0;
}
/*
* On some motherboards, the MAC address is written by the
* BIOS directly to the MAC register during POST, and is
* not stored in eeprom. If all else thus far has failed
* to fetch the permanent MAC address, try reading it directly.
*/ */
*(u32 *) & eth_addr[2] = swab32(addr[0]); addr[0] = ioread32(hw->hw_addr + REG_MAC_STA_ADDR);
*(u16 *) & eth_addr[0] = swab16(*(u16 *) & addr[1]); addr[1] = ioread16(hw->hw_addr + (REG_MAC_STA_ADDR + 4));
*(u32 *) &eth_addr[2] = swab32(addr[0]);
*(u16 *) &eth_addr[0] = swab16(*(u16 *) &addr[1]);
if (is_valid_ether_addr(eth_addr)) { if (is_valid_ether_addr(eth_addr)) {
memcpy(hw->perm_mac_addr, eth_addr, ETH_ALEN); memcpy(hw->perm_mac_addr, eth_addr, ETH_ALEN);
return 0; return 0;
} }
return 1; return 1;
} }
......
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