From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lucas Stach Subject: =?UTF-8?q?=5BPATCH=20v2=201/2=5D=20net=3A=20asix=3A=20init=20ASIX=20AX88772B=20MAC=20from=20EEPROM?= Date: Tue, 18 Dec 2012 16:21:22 +0100 Message-ID: <1355844083-14285-1-git-send-email-dev@lynxeye.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Oliver Neukum , linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Return-path: Sender: linux-usb-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: netdev.vger.kernel.org The device comes up with a MAC address of all zeros. We need to read th= e initial device MAC from EEPROM so it can be set properly later. Signed-off-by: Lucas Stach --- A similar fix was added into U-Boot: http://patchwork.ozlabs.org/patch/179409/ v2: pass flag in the data field instead of clobbering the global flags space --- drivers/net/usb/asix.h | 3 +++ drivers/net/usb/asix_devices.c | 30 +++++++++++++++++++++++++++--- 2 Dateien ge=C3=A4ndert, 30 Zeilen hinzugef=C3=BCgt(+), 3 Zeilen entfe= rnt(-) diff --git a/drivers/net/usb/asix.h b/drivers/net/usb/asix.h index e889631..7afe8ac 100644 --- a/drivers/net/usb/asix.h +++ b/drivers/net/usb/asix.h @@ -167,6 +167,9 @@ struct asix_data { u8 res; }; =20 +/* ASIX specific flags */ +#define FLAG_EEPROM_MAC (1UL << 0) /* init device MAC from eeprom */ + int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size, void *data); =20 diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devi= ces.c index 7a6e758..0ecc3bc 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 =3D { =20 static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf= ) { - int ret, embd_phy; + int ret, embd_phy, i; u8 buf[ETH_ALEN]; u32 phyid; =20 usbnet_get_endpoints(dev,intf); =20 /* Get the MAC address */ - ret =3D asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); + if (dev->driver_info->data & FLAG_EEPROM_MAC) { + for (i =3D 0; i < (ETH_ALEN >> 1); i++) { + ret =3D asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x04 + i, + 0, 2, buf + i * 2); + if (ret < 0) + break; + } + } else { + ret =3D asix_read_cmd(dev, AX_CMD_READ_NODE_ID, + 0, 0, ETH_ALEN, buf); + } + if (ret < 0) { netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret); return ret; @@ -872,6 +883,19 @@ static const struct driver_info ax88772_info =3D { .tx_fixup =3D asix_tx_fixup, }; =20 +static const struct driver_info ax88772b_info =3D { + .description =3D "ASIX AX88772B USB 2.0 Ethernet", + .bind =3D ax88772_bind, + .status =3D asix_status, + .link_reset =3D ax88772_link_reset, + .reset =3D ax88772_reset, + .flags =3D FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | + FLAG_MULTI_PACKET, + .rx_fixup =3D asix_rx_fixup, + .tx_fixup =3D asix_tx_fixup, + .data =3D FLAG_EEPROM_MAC, +}; + static const struct driver_info ax88178_info =3D { .description =3D "ASIX AX88178 USB 2.0 Ethernet", .bind =3D ax88178_bind, @@ -953,7 +977,7 @@ static const struct usb_device_id products [] =3D { }, { // ASIX AX88772B 10/100 USB_DEVICE (0x0b95, 0x772b), - .driver_info =3D (unsigned long) &ax88772_info, + .driver_info =3D (unsigned long) &ax88772b_info, }, { // ASIX AX88772 10/100 USB_DEVICE (0x0b95, 0x7720), --=20 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html