aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Stach <dev@lynxeye.de>2013-01-15 23:24:06 -0500
committerDavid S. Miller <davem@davemloft.net>2013-01-18 14:13:29 -0500
commit5620df65d81292c5fb1beba8d380ef58cd98b53f (patch)
tree833399b11c1212ae82ddf78659c3c260f701b6ff
parenta16af2ffa2f640f094a3ad3543996a37b588a3cc (diff)
net: asix: init ASIX AX88772B MAC from EEPROM
The device comes up with a MAC address of all zeros. We need to read the initial device MAC from EEPROM so it can be set properly later. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/usb/asix.h3
-rw-r--r--drivers/net/usb/asix_devices.c30
2 files changed, 30 insertions, 3 deletions
diff --git a/drivers/net/usb/asix.h b/drivers/net/usb/asix.h
index e889631161b8..7afe8ac078e8 100644
--- a/drivers/net/usb/asix.h
+++ b/drivers/net/usb/asix.h
@@ -167,6 +167,9 @@ struct asix_data {
167 u8 res; 167 u8 res;
168}; 168};
169 169
170/* ASIX specific flags */
171#define FLAG_EEPROM_MAC (1UL << 0) /* init device MAC from eeprom */
172
170int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 173int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
171 u16 size, void *data); 174 u16 size, void *data);
172 175
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 7a6e758f48e7..0ecc3bc6c3d7 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -422,14 +422,25 @@ static const struct net_device_ops ax88772_netdev_ops = {
422 422
423static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) 423static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
424{ 424{
425 int ret, embd_phy; 425 int ret, embd_phy, i;
426 u8 buf[ETH_ALEN]; 426 u8 buf[ETH_ALEN];
427 u32 phyid; 427 u32 phyid;
428 428
429 usbnet_get_endpoints(dev,intf); 429 usbnet_get_endpoints(dev,intf);
430 430
431 /* Get the MAC address */ 431 /* Get the MAC address */
432 ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); 432 if (dev->driver_info->data & FLAG_EEPROM_MAC) {
433 for (i = 0; i < (ETH_ALEN >> 1); i++) {
434 ret = asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x04 + i,
435 0, 2, buf + i * 2);
436 if (ret < 0)
437 break;
438 }
439 } else {
440 ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID,
441 0, 0, ETH_ALEN, buf);
442 }
443
433 if (ret < 0) { 444 if (ret < 0) {
434 netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret); 445 netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
435 return ret; 446 return ret;
@@ -872,6 +883,19 @@ static const struct driver_info ax88772_info = {
872 .tx_fixup = asix_tx_fixup, 883 .tx_fixup = asix_tx_fixup,
873}; 884};
874 885
886static const struct driver_info ax88772b_info = {
887 .description = "ASIX AX88772B USB 2.0 Ethernet",
888 .bind = ax88772_bind,
889 .status = asix_status,
890 .link_reset = ax88772_link_reset,
891 .reset = ax88772_reset,
892 .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR |
893 FLAG_MULTI_PACKET,
894 .rx_fixup = asix_rx_fixup,
895 .tx_fixup = asix_tx_fixup,
896 .data = FLAG_EEPROM_MAC,
897};
898
875static const struct driver_info ax88178_info = { 899static const struct driver_info ax88178_info = {
876 .description = "ASIX AX88178 USB 2.0 Ethernet", 900 .description = "ASIX AX88178 USB 2.0 Ethernet",
877 .bind = ax88178_bind, 901 .bind = ax88178_bind,
@@ -953,7 +977,7 @@ static const struct usb_device_id products [] = {
953}, { 977}, {
954 // ASIX AX88772B 10/100 978 // ASIX AX88772B 10/100
955 USB_DEVICE (0x0b95, 0x772b), 979 USB_DEVICE (0x0b95, 0x772b),
956 .driver_info = (unsigned long) &ax88772_info, 980 .driver_info = (unsigned long) &ax88772b_info,
957}, { 981}, {
958 // ASIX AX88772 10/100 982 // ASIX AX88772 10/100
959 USB_DEVICE (0x0b95, 0x7720), 983 USB_DEVICE (0x0b95, 0x7720),