From patchwork Tue Dec 18 15:21:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 207148 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 63E3C2C0091 for ; Wed, 19 Dec 2012 02:21:42 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932219Ab2LRPVb (ORCPT ); Tue, 18 Dec 2012 10:21:31 -0500 Received: from ns.km20343-01.keymachine.de ([84.19.182.79]:60746 "EHLO km20343-01.keymachine.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932067Ab2LRPV2 (ORCPT ); Tue, 18 Dec 2012 10:21:28 -0500 Received: from localhost.localdomain (g224199001.adsl.alicedsl.de [92.224.199.1]) by km20343-01.keymachine.de (Postfix) with ESMTPA id 4D9A47D416E; Tue, 18 Dec 2012 16:21:27 +0100 (CET) From: Lucas Stach To: netdev@vger.kernel.org Cc: Oliver Neukum , linux-usb@vger.kernel.org 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> X-Mailer: git-send-email 1.7.11.7 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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ändert, 30 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-) 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; }; +/* 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); diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.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 = { 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; usbnet_get_endpoints(dev,intf); /* Get the MAC address */ - ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); + if (dev->driver_info->data & FLAG_EEPROM_MAC) { + for (i = 0; i < (ETH_ALEN >> 1); i++) { + ret = asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x04 + i, + 0, 2, buf + i * 2); + if (ret < 0) + break; + } + } else { + ret = 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 = { .tx_fixup = asix_tx_fixup, }; +static const struct driver_info ax88772b_info = { + .description = "ASIX AX88772B USB 2.0 Ethernet", + .bind = ax88772_bind, + .status = asix_status, + .link_reset = ax88772_link_reset, + .reset = ax88772_reset, + .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | + FLAG_MULTI_PACKET, + .rx_fixup = asix_rx_fixup, + .tx_fixup = asix_tx_fixup, + .data = FLAG_EEPROM_MAC, +}; + static const struct driver_info ax88178_info = { .description = "ASIX AX88178 USB 2.0 Ethernet", .bind = ax88178_bind, @@ -953,7 +977,7 @@ static const struct usb_device_id products [] = { }, { // ASIX AX88772B 10/100 USB_DEVICE (0x0b95, 0x772b), - .driver_info = (unsigned long) &ax88772_info, + .driver_info = (unsigned long) &ax88772b_info, }, { // ASIX AX88772 10/100 USB_DEVICE (0x0b95, 0x7720),