summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Ziswiler <marcel.ziswiler@toradex.com>2012-12-05 16:20:01 +0100
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2012-12-05 16:20:01 +0100
commit93596956391157d9ec9103b0c8033d0505b8b102 (patch)
treef0dec9b14a6490e3fc2b889008ab507e1afdda4a
parent2034faa3dd221a751d347e7830b61a809cf81530 (diff)
net: asix: revise Ethernet MAC address assignment
Revise Ethernet MAC address assignment: should now use MAC from EEPROM if set and further handles up to two instances of custom user MACs (2nd one with a 0x100000 offset). This way customer does not have to put EEPROM on a secondary Ethernet on the carrier board and still gets a valid official MAC address from us (e.g. analogous to how we did it on our Protea carrier board).
-rw-r--r--drivers/net/usb/asix.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 6f4f9e206a79..3218f52b3a3d 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -1703,6 +1703,7 @@ static int ax88772b_bind(struct usbnet *dev, struct usb_interface *intf)
u8 i;
u8 TempPhySelect;
bool InternalPhy;
+ u8 default_asix_mac[ETH_ALEN] = { 0x00, 0x0e, 0xc6, 0x87, 0x72, 0x01 };
axusbnet_get_endpoints(dev,intf);
@@ -1783,20 +1784,30 @@ static int ax88772b_bind(struct usbnet *dev, struct usb_interface *intf)
ax772b_data->psc = *tmp16 & 0xFF00;
/* End of get EEPROM data */
- if (g_usr_mac) {
- /* Get user set MAC address */
- memcpy(buf, g_mac_addr, ETH_ALEN);
- } else {
- /* Get the MAC address from EEPROM */
- memset(buf, 0, ETH_ALEN);
- for (i = 0; i < (ETH_ALEN >> 1); i++) {
- if ((ret = ax8817x_read_cmd (dev, AX_CMD_READ_EEPROM,
- 0x04 + i, 0, 2, (buf + i * 2))) < 0) {
- deverr(dev, "read SROM address 04h failed: %d", ret);
- goto err_out;
- }
+ /* Get the MAC address from EEPROM */
+ memset(buf, 0, ETH_ALEN);
+ for (i = 0; i < (ETH_ALEN >> 1); i++) {
+ if ((ret = ax8817x_read_cmd (dev, AX_CMD_READ_EEPROM,
+ 0x04 + i, 0, 2, (buf + i * 2))) < 0) {
+ deverr(dev, "read SROM address 04h failed: %d", ret);
+ goto err_out;
}
}
+
+ /* Check for default ASIX MAC (e.g. 00:0e:c6:87:72:01) in case of no EEPROM being present */
+ if (!memcmp(buf, default_asix_mac, ETH_ALEN)) {
+ if (g_usr_mac && (g_usr_mac < 3)) {
+ /* Get user set MAC address */
+ if (g_usr_mac == 2) {
+ /* 0x100000 offset for 2nd Ethernet MAC */
+ g_mac_addr[3] += 0x10;
+ if (g_mac_addr[3] < 0x10)
+ devwarn(dev, "MAC address byte 3 (0x%02x) wrap around", g_mac_addr[3]);
+ }
+ memcpy(buf, g_mac_addr, ETH_ALEN);
+ g_usr_mac++;
+ } else devwarn(dev, "using default ASIX MAC");
+ }
memcpy(dev->net->dev_addr, buf, ETH_ALEN);
/* Set the MAC address */