blob: ebeb73014fdfc3693677ef0224f551a3ad80ee8e [file] [log] [blame]
David Brownell2e55cc72005-08-31 09:53:10 -07001/*
2 * ASIX AX8817X based USB 2.0 Ethernet Devices
David Hollis933a27d2006-07-29 10:12:50 -04003 * Copyright (C) 2003-2006 David Hollis <dhollis@davehollis.com>
David Brownell2e55cc72005-08-31 09:53:10 -07004 * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net>
David Hollis933a27d2006-07-29 10:12:50 -04005 * Copyright (C) 2006 James Painter <jamie.painter@iname.com>
David Brownell2e55cc72005-08-31 09:53:10 -07006 * Copyright (c) 2002-2003 TiVo Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
Jeff Kirsher9cb00072013-12-06 06:28:46 -080019 * along with this program; if not, see <http://www.gnu.org/licenses/>.
David Brownell2e55cc72005-08-31 09:53:10 -070020 */
21
Christian Riesch607740b2012-07-13 05:26:30 +000022#include "asix.h"
David Hollis933a27d2006-07-29 10:12:50 -040023
24#define PHY_MODE_MARVELL 0x0000
25#define MII_MARVELL_LED_CTRL 0x0018
26#define MII_MARVELL_STATUS 0x001b
27#define MII_MARVELL_CTRL 0x0014
28
29#define MARVELL_LED_MANUAL 0x0019
30
31#define MARVELL_STATUS_HWCFG 0x0004
32
33#define MARVELL_CTRL_TXDELAY 0x0002
34#define MARVELL_CTRL_RXDELAY 0x0080
David Brownell2e55cc72005-08-31 09:53:10 -070035
Grant Grundler34861402011-11-15 07:12:39 +000036#define PHY_MODE_RTL8211CL 0x000C
Grant Grundler610d8852011-10-04 09:55:17 +000037
David Brownell2e55cc72005-08-31 09:53:10 -070038struct ax88172_int_data {
Al Viro51bf2972007-12-22 17:42:36 +000039 __le16 res1;
David Brownell2e55cc72005-08-31 09:53:10 -070040 u8 link;
Al Viro51bf2972007-12-22 17:42:36 +000041 __le16 res2;
David Brownell2e55cc72005-08-31 09:53:10 -070042 u8 status;
Al Viro51bf2972007-12-22 17:42:36 +000043 __le16 res3;
Eric Dumazetba2d3582010-06-02 18:10:09 +000044} __packed;
David Brownell2e55cc72005-08-31 09:53:10 -070045
David Hollis48b1be62006-03-28 20:15:42 -050046static void asix_status(struct usbnet *dev, struct urb *urb)
David Brownell2e55cc72005-08-31 09:53:10 -070047{
48 struct ax88172_int_data *event;
49 int link;
50
51 if (urb->actual_length < 8)
52 return;
53
54 event = urb->transfer_buffer;
55 link = event->link & 0x01;
56 if (netif_carrier_ok(dev->net) != link) {
Ming Leieae65912013-04-11 04:40:34 +000057 usbnet_link_change(dev, link, 1);
Joe Perches60b86752010-02-17 10:30:23 +000058 netdev_dbg(dev->net, "Link Status is: %d\n", link);
David Brownell2e55cc72005-08-31 09:53:10 -070059 }
60}
61
Jean-Christophe PLAGNIOL-VILLARD452b5ec2012-11-21 21:35:17 +000062static void asix_set_netdev_dev_addr(struct usbnet *dev, u8 *addr)
63{
64 if (is_valid_ether_addr(addr)) {
65 memcpy(dev->net->dev_addr, addr, ETH_ALEN);
66 } else {
67 netdev_info(dev->net, "invalid hw address, using random\n");
68 eth_hw_addr_random(dev->net);
69 }
70}
71
David Hollis933a27d2006-07-29 10:12:50 -040072/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */
73static u32 asix_get_phyid(struct usbnet *dev)
David Brownell2e55cc72005-08-31 09:53:10 -070074{
David Hollis933a27d2006-07-29 10:12:50 -040075 int phy_reg;
76 u32 phy_id;
Grant Grundlera77929a2011-11-15 07:12:40 +000077 int i;
David Brownell2e55cc72005-08-31 09:53:10 -070078
Grant Grundlera77929a2011-11-15 07:12:40 +000079 /* Poll for the rare case the FW or phy isn't ready yet. */
80 for (i = 0; i < 100; i++) {
81 phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID1);
Robert Foss8a46f662016-08-29 09:32:16 -040082 if (phy_reg < 0)
83 return 0;
Grant Grundlera77929a2011-11-15 07:12:40 +000084 if (phy_reg != 0 && phy_reg != 0xFFFF)
85 break;
86 mdelay(1);
87 }
88
89 if (phy_reg <= 0 || phy_reg == 0xFFFF)
David Hollis933a27d2006-07-29 10:12:50 -040090 return 0;
David Brownell2e55cc72005-08-31 09:53:10 -070091
David Hollis933a27d2006-07-29 10:12:50 -040092 phy_id = (phy_reg & 0xffff) << 16;
David Brownell2e55cc72005-08-31 09:53:10 -070093
David Hollis933a27d2006-07-29 10:12:50 -040094 phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID2);
95 if (phy_reg < 0)
96 return 0;
97
98 phy_id |= (phy_reg & 0xffff);
99
100 return phy_id;
David Brownell2e55cc72005-08-31 09:53:10 -0700101}
102
David Hollis933a27d2006-07-29 10:12:50 -0400103static u32 asix_get_link(struct net_device *net)
104{
105 struct usbnet *dev = netdev_priv(net);
106
107 return mii_link_ok(&dev->mii);
108}
109
110static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd)
111{
112 struct usbnet *dev = netdev_priv(net);
113
114 return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
David Brownell2e55cc72005-08-31 09:53:10 -0700115}
116
117/* We need to override some ethtool_ops so we require our
118 own structure so we don't interfere with other usbnet
119 devices that may be connected at the same time. */
Stephen Hemminger0fc0b732009-09-02 01:03:33 -0700120static const struct ethtool_ops ax88172_ethtool_ops = {
David Hollis48b1be62006-03-28 20:15:42 -0500121 .get_drvinfo = asix_get_drvinfo,
David Hollis933a27d2006-07-29 10:12:50 -0400122 .get_link = asix_get_link,
David Brownell2e55cc72005-08-31 09:53:10 -0700123 .get_msglevel = usbnet_get_msglevel,
124 .set_msglevel = usbnet_set_msglevel,
David Hollis48b1be62006-03-28 20:15:42 -0500125 .get_wol = asix_get_wol,
126 .set_wol = asix_set_wol,
127 .get_eeprom_len = asix_get_eeprom_len,
128 .get_eeprom = asix_get_eeprom,
Christian Rieschcb7b24c2012-07-19 00:23:07 +0000129 .set_eeprom = asix_set_eeprom,
Arnd Bergmannc41286f2006-10-09 00:08:01 +0200130 .get_settings = usbnet_get_settings,
131 .set_settings = usbnet_set_settings,
132 .nway_reset = usbnet_nway_reset,
David Brownell2e55cc72005-08-31 09:53:10 -0700133};
134
David Hollis933a27d2006-07-29 10:12:50 -0400135static void ax88172_set_multicast(struct net_device *net)
David Brownell2e55cc72005-08-31 09:53:10 -0700136{
137 struct usbnet *dev = netdev_priv(net);
David Hollis933a27d2006-07-29 10:12:50 -0400138 struct asix_data *data = (struct asix_data *)&dev->data;
139 u8 rx_ctl = 0x8c;
David Brownell2e55cc72005-08-31 09:53:10 -0700140
David Hollis933a27d2006-07-29 10:12:50 -0400141 if (net->flags & IFF_PROMISC) {
142 rx_ctl |= 0x01;
Joe Perches8e95a202009-12-03 07:58:21 +0000143 } else if (net->flags & IFF_ALLMULTI ||
Jiri Pirko4cd24ea2010-02-08 04:30:35 +0000144 netdev_mc_count(net) > AX_MAX_MCAST) {
David Hollis933a27d2006-07-29 10:12:50 -0400145 rx_ctl |= 0x02;
Jiri Pirko4cd24ea2010-02-08 04:30:35 +0000146 } else if (netdev_mc_empty(net)) {
David Hollis933a27d2006-07-29 10:12:50 -0400147 /* just broadcast and directed */
148 } else {
149 /* We use the 20 byte dev->data
150 * for our 8 byte filter buffer
151 * to avoid allocating memory that
152 * is tricky to free later */
Jiri Pirko22bedad32010-04-01 21:22:57 +0000153 struct netdev_hw_addr *ha;
David Hollis933a27d2006-07-29 10:12:50 -0400154 u32 crc_bits;
David Hollis933a27d2006-07-29 10:12:50 -0400155
156 memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE);
157
158 /* Build the multicast hash filter. */
Jiri Pirko22bedad32010-04-01 21:22:57 +0000159 netdev_for_each_mc_addr(ha, net) {
160 crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
David Hollis933a27d2006-07-29 10:12:50 -0400161 data->multi_filter[crc_bits >> 3] |=
162 1 << (crc_bits & 7);
David Hollis933a27d2006-07-29 10:12:50 -0400163 }
164
165 asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0,
166 AX_MCAST_FILTER_SIZE, data->multi_filter);
167
168 rx_ctl |= 0x10;
169 }
170
171 asix_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL);
172}
173
174static int ax88172_link_reset(struct usbnet *dev)
175{
176 u8 mode;
David Decotigny8ae6daca2011-04-27 18:32:38 +0000177 struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
David Hollis933a27d2006-07-29 10:12:50 -0400178
179 mii_check_media(&dev->mii, 1, 1);
180 mii_ethtool_gset(&dev->mii, &ecmd);
181 mode = AX88172_MEDIUM_DEFAULT;
182
183 if (ecmd.duplex != DUPLEX_FULL)
184 mode |= ~AX88172_MEDIUM_FD;
185
David Decotigny8ae6daca2011-04-27 18:32:38 +0000186 netdev_dbg(dev->net, "ax88172_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n",
187 ethtool_cmd_speed(&ecmd), ecmd.duplex, mode);
David Hollis933a27d2006-07-29 10:12:50 -0400188
Robert Fossd9fe64e2016-08-29 09:32:15 -0400189 asix_write_medium_mode(dev, mode, 0);
David Hollis933a27d2006-07-29 10:12:50 -0400190
191 return 0;
David Brownell2e55cc72005-08-31 09:53:10 -0700192}
193
Stephen Hemminger17033382009-03-20 19:35:55 +0000194static const struct net_device_ops ax88172_netdev_ops = {
195 .ndo_open = usbnet_open,
196 .ndo_stop = usbnet_stop,
197 .ndo_start_xmit = usbnet_start_xmit,
198 .ndo_tx_timeout = usbnet_tx_timeout,
199 .ndo_change_mtu = usbnet_change_mtu,
200 .ndo_set_mac_address = eth_mac_addr,
201 .ndo_validate_addr = eth_validate_addr,
202 .ndo_do_ioctl = asix_ioctl,
Jiri Pirkoafc4b132011-08-16 06:29:01 +0000203 .ndo_set_rx_mode = ax88172_set_multicast,
Stephen Hemminger17033382009-03-20 19:35:55 +0000204};
205
David Hollis48b1be62006-03-28 20:15:42 -0500206static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
David Brownell2e55cc72005-08-31 09:53:10 -0700207{
208 int ret = 0;
Al Viro51bf2972007-12-22 17:42:36 +0000209 u8 buf[ETH_ALEN];
David Brownell2e55cc72005-08-31 09:53:10 -0700210 int i;
211 unsigned long gpio_bits = dev->driver_info->data;
212
213 usbnet_get_endpoints(dev,intf);
214
David Brownell2e55cc72005-08-31 09:53:10 -0700215 /* Toggle the GPIOs in a manufacturer/model specific way */
216 for (i = 2; i >= 0; i--) {
Grant Grundler83e1b912011-10-04 09:55:18 +0000217 ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS,
Robert Fossd9fe64e2016-08-29 09:32:15 -0400218 (gpio_bits >> (i * 8)) & 0xff, 0, 0, NULL, 0);
Grant Grundler83e1b912011-10-04 09:55:18 +0000219 if (ret < 0)
Al Viro51bf2972007-12-22 17:42:36 +0000220 goto out;
David Brownell2e55cc72005-08-31 09:53:10 -0700221 msleep(5);
222 }
223
Robert Fossd9fe64e2016-08-29 09:32:15 -0400224 ret = asix_write_rx_ctl(dev, 0x80, 0);
Grant Grundler83e1b912011-10-04 09:55:18 +0000225 if (ret < 0)
Al Viro51bf2972007-12-22 17:42:36 +0000226 goto out;
David Brownell2e55cc72005-08-31 09:53:10 -0700227
228 /* Get the MAC address */
Robert Fossd9fe64e2016-08-29 09:32:15 -0400229 ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID,
230 0, 0, ETH_ALEN, buf, 0);
Grant Grundler83e1b912011-10-04 09:55:18 +0000231 if (ret < 0) {
Greg Kroah-Hartman49ae25b2012-09-19 09:46:14 +0000232 netdev_dbg(dev->net, "read AX_CMD_READ_NODE_ID failed: %d\n",
233 ret);
Al Viro51bf2972007-12-22 17:42:36 +0000234 goto out;
David Brownell2e55cc72005-08-31 09:53:10 -0700235 }
Jean-Christophe PLAGNIOL-VILLARD452b5ec2012-11-21 21:35:17 +0000236
237 asix_set_netdev_dev_addr(dev, buf);
David Brownell2e55cc72005-08-31 09:53:10 -0700238
David Brownell2e55cc72005-08-31 09:53:10 -0700239 /* Initialize MII structure */
240 dev->mii.dev = dev->net;
David Hollis48b1be62006-03-28 20:15:42 -0500241 dev->mii.mdio_read = asix_mdio_read;
242 dev->mii.mdio_write = asix_mdio_write;
David Brownell2e55cc72005-08-31 09:53:10 -0700243 dev->mii.phy_id_mask = 0x3f;
244 dev->mii.reg_num_mask = 0x1f;
David Hollis933a27d2006-07-29 10:12:50 -0400245 dev->mii.phy_id = asix_get_phy_addr(dev);
David Brownell2e55cc72005-08-31 09:53:10 -0700246
Stephen Hemminger17033382009-03-20 19:35:55 +0000247 dev->net->netdev_ops = &ax88172_netdev_ops;
David Hollis48b1be62006-03-28 20:15:42 -0500248 dev->net->ethtool_ops = &ax88172_ethtool_ops;
Eric Dumazet95162d62012-07-05 04:31:01 +0000249 dev->net->needed_headroom = 4; /* cf asix_tx_fixup() */
250 dev->net->needed_tailroom = 4; /* cf asix_tx_fixup() */
David Brownell2e55cc72005-08-31 09:53:10 -0700251
David Hollis933a27d2006-07-29 10:12:50 -0400252 asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
253 asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
David Brownell2e55cc72005-08-31 09:53:10 -0700254 ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
255 mii_nway_restart(&dev->mii);
256
257 return 0;
Al Viro51bf2972007-12-22 17:42:36 +0000258
259out:
David Brownell2e55cc72005-08-31 09:53:10 -0700260 return ret;
261}
262
Stephen Hemminger0fc0b732009-09-02 01:03:33 -0700263static const struct ethtool_ops ax88772_ethtool_ops = {
David Hollis48b1be62006-03-28 20:15:42 -0500264 .get_drvinfo = asix_get_drvinfo,
David Hollis933a27d2006-07-29 10:12:50 -0400265 .get_link = asix_get_link,
David Brownell2e55cc72005-08-31 09:53:10 -0700266 .get_msglevel = usbnet_get_msglevel,
267 .set_msglevel = usbnet_set_msglevel,
David Hollis48b1be62006-03-28 20:15:42 -0500268 .get_wol = asix_get_wol,
269 .set_wol = asix_set_wol,
270 .get_eeprom_len = asix_get_eeprom_len,
271 .get_eeprom = asix_get_eeprom,
Christian Rieschcb7b24c2012-07-19 00:23:07 +0000272 .set_eeprom = asix_set_eeprom,
Arnd Bergmannc41286f2006-10-09 00:08:01 +0200273 .get_settings = usbnet_get_settings,
274 .set_settings = usbnet_set_settings,
275 .nway_reset = usbnet_nway_reset,
David Brownell2e55cc72005-08-31 09:53:10 -0700276};
277
David Hollis933a27d2006-07-29 10:12:50 -0400278static int ax88772_link_reset(struct usbnet *dev)
279{
280 u16 mode;
David Decotigny8ae6daca2011-04-27 18:32:38 +0000281 struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
David Hollis933a27d2006-07-29 10:12:50 -0400282
283 mii_check_media(&dev->mii, 1, 1);
284 mii_ethtool_gset(&dev->mii, &ecmd);
285 mode = AX88772_MEDIUM_DEFAULT;
286
David Decotigny8ae6daca2011-04-27 18:32:38 +0000287 if (ethtool_cmd_speed(&ecmd) != SPEED_100)
David Hollis933a27d2006-07-29 10:12:50 -0400288 mode &= ~AX_MEDIUM_PS;
289
290 if (ecmd.duplex != DUPLEX_FULL)
291 mode &= ~AX_MEDIUM_FD;
292
David Decotigny8ae6daca2011-04-27 18:32:38 +0000293 netdev_dbg(dev->net, "ax88772_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n",
294 ethtool_cmd_speed(&ecmd), ecmd.duplex, mode);
David Hollis933a27d2006-07-29 10:12:50 -0400295
Robert Fossd9fe64e2016-08-29 09:32:15 -0400296 asix_write_medium_mode(dev, mode, 0);
David Hollis933a27d2006-07-29 10:12:50 -0400297
298 return 0;
299}
300
Grant Grundler4ad14382011-10-04 09:55:16 +0000301static int ax88772_reset(struct usbnet *dev)
David Brownell2e55cc72005-08-31 09:53:10 -0700302{
Jussi Kivilinna8ef66bd2012-01-10 06:40:17 +0000303 struct asix_data *data = (struct asix_data *)&dev->data;
Robert Fossd9fe64e2016-08-29 09:32:15 -0400304 int ret;
David Brownell2e55cc72005-08-31 09:53:10 -0700305
Robert Fossd9fe64e2016-08-29 09:32:15 -0400306 /* Rewrite MAC address */
307 ether_addr_copy(data->mac_addr, dev->net->dev_addr);
308 ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0,
309 ETH_ALEN, data->mac_addr, 0);
Grant Grundler83e1b912011-10-04 09:55:18 +0000310 if (ret < 0)
Al Viro51bf2972007-12-22 17:42:36 +0000311 goto out;
David Brownell2e55cc72005-08-31 09:53:10 -0700312
Robert Fossd9fe64e2016-08-29 09:32:15 -0400313 /* Set RX_CTL to default values with 2k buffer, and enable cactus */
314 ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL, 0);
315 if (ret < 0)
316 goto out;
Grant Grundler4ad14382011-10-04 09:55:16 +0000317
Robert Fossd9fe64e2016-08-29 09:32:15 -0400318 asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT, 0);
319 if (ret < 0)
320 goto out;
321
322 return 0;
323
324out:
325 return ret;
326}
327
328static int ax88772_hw_reset(struct usbnet *dev, int in_pm)
329{
330 struct asix_data *data = (struct asix_data *)&dev->data;
331 int ret, embd_phy;
332 u16 rx_ctl;
333
334 ret = asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_2 |
335 AX_GPIO_GPO2EN, 5, in_pm);
336 if (ret < 0)
337 goto out;
338
339 embd_phy = ((dev->mii.phy_id & 0x1f) == 0x10 ? 1 : 0);
340
341 ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy,
342 0, 0, NULL, in_pm);
Grant Grundler83e1b912011-10-04 09:55:18 +0000343 if (ret < 0) {
Greg Kroah-Hartman49ae25b2012-09-19 09:46:14 +0000344 netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret);
Al Viro51bf2972007-12-22 17:42:36 +0000345 goto out;
David Brownell2e55cc72005-08-31 09:53:10 -0700346 }
347
Andres Salomond0ffff82007-01-11 18:39:16 -0500348 if (embd_phy) {
Robert Fossd9fe64e2016-08-29 09:32:15 -0400349 ret = asix_sw_reset(dev, AX_SWRESET_IPPD, in_pm);
350 if (ret < 0)
351 goto out;
352
353 usleep_range(10000, 11000);
354
355 ret = asix_sw_reset(dev, AX_SWRESET_CLEAR, in_pm);
356 if (ret < 0)
357 goto out;
358
359 msleep(60);
360
361 ret = asix_sw_reset(dev, AX_SWRESET_IPRL | AX_SWRESET_PRL,
362 in_pm);
Grant Grundler83e1b912011-10-04 09:55:18 +0000363 if (ret < 0)
Al Viro51bf2972007-12-22 17:42:36 +0000364 goto out;
Grant Grundler83e1b912011-10-04 09:55:18 +0000365 } else {
Robert Fossd9fe64e2016-08-29 09:32:15 -0400366 ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL,
367 in_pm);
Grant Grundler83e1b912011-10-04 09:55:18 +0000368 if (ret < 0)
Al Viro51bf2972007-12-22 17:42:36 +0000369 goto out;
Andres Salomond0ffff82007-01-11 18:39:16 -0500370 }
David Brownell2e55cc72005-08-31 09:53:10 -0700371
372 msleep(150);
Robert Fossd9fe64e2016-08-29 09:32:15 -0400373
374 if (in_pm && (!asix_mdio_read_nopm(dev->net, dev->mii.phy_id,
375 MII_PHYSID1))){
376 ret = -EIO;
377 goto out;
378 }
379
380 ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL, in_pm);
Grant Grundler83e1b912011-10-04 09:55:18 +0000381 if (ret < 0)
Al Viro51bf2972007-12-22 17:42:36 +0000382 goto out;
David Brownell2e55cc72005-08-31 09:53:10 -0700383
Robert Fossd9fe64e2016-08-29 09:32:15 -0400384 ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT, in_pm);
Grant Grundler83e1b912011-10-04 09:55:18 +0000385 if (ret < 0)
Al Viro51bf2972007-12-22 17:42:36 +0000386 goto out;
David Brownell2e55cc72005-08-31 09:53:10 -0700387
Grant Grundler83e1b912011-10-04 09:55:18 +0000388 ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0,
Robert Fossd9fe64e2016-08-29 09:32:15 -0400389 AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,
390 AX88772_IPG2_DEFAULT, 0, NULL, in_pm);
Grant Grundler83e1b912011-10-04 09:55:18 +0000391 if (ret < 0) {
Greg Kroah-Hartman49ae25b2012-09-19 09:46:14 +0000392 netdev_dbg(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", ret);
Al Viro51bf2972007-12-22 17:42:36 +0000393 goto out;
David Brownell2e55cc72005-08-31 09:53:10 -0700394 }
David Brownell2e55cc72005-08-31 09:53:10 -0700395
Jussi Kivilinna8ef66bd2012-01-10 06:40:17 +0000396 /* Rewrite MAC address */
Robert Fossd9fe64e2016-08-29 09:32:15 -0400397 ether_addr_copy(data->mac_addr, dev->net->dev_addr);
398 ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0,
399 ETH_ALEN, data->mac_addr, in_pm);
Jussi Kivilinna8ef66bd2012-01-10 06:40:17 +0000400 if (ret < 0)
401 goto out;
402
David Brownell2e55cc72005-08-31 09:53:10 -0700403 /* Set RX_CTL to default values with 2k buffer, and enable cactus */
Robert Fossd9fe64e2016-08-29 09:32:15 -0400404 ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL, in_pm);
Grant Grundler83e1b912011-10-04 09:55:18 +0000405 if (ret < 0)
Al Viro51bf2972007-12-22 17:42:36 +0000406 goto out;
David Brownell2e55cc72005-08-31 09:53:10 -0700407
Robert Fossd9fe64e2016-08-29 09:32:15 -0400408 rx_ctl = asix_read_rx_ctl(dev, in_pm);
Greg Kroah-Hartman49ae25b2012-09-19 09:46:14 +0000409 netdev_dbg(dev->net, "RX_CTL is 0x%04x after all initializations\n",
410 rx_ctl);
David Hollis933a27d2006-07-29 10:12:50 -0400411
Robert Fossd9fe64e2016-08-29 09:32:15 -0400412 rx_ctl = asix_read_medium_status(dev, in_pm);
Greg Kroah-Hartman49ae25b2012-09-19 09:46:14 +0000413 netdev_dbg(dev->net,
414 "Medium Status is 0x%04x after all initializations\n",
415 rx_ctl);
David Hollis933a27d2006-07-29 10:12:50 -0400416
Grant Grundler4ad14382011-10-04 09:55:16 +0000417 return 0;
418
419out:
420 return ret;
Robert Fossd9fe64e2016-08-29 09:32:15 -0400421}
Grant Grundler4ad14382011-10-04 09:55:16 +0000422
Robert Fossd9fe64e2016-08-29 09:32:15 -0400423static int ax88772a_hw_reset(struct usbnet *dev, int in_pm)
424{
425 struct asix_data *data = (struct asix_data *)&dev->data;
426 int ret, embd_phy;
427 u16 rx_ctl;
428 u8 chipcode = 0;
429
430 ret = asix_write_gpio(dev, AX_GPIO_RSE, 5, in_pm);
431 if (ret < 0)
432 goto out;
433
434 embd_phy = ((dev->mii.phy_id & 0x1f) == 0x10 ? 1 : 0);
435
436 ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy |
437 AX_PHYSEL_SSEN, 0, 0, NULL, in_pm);
438 if (ret < 0) {
439 netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret);
440 goto out;
441 }
442 usleep_range(10000, 11000);
443
444 ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_IPRL, in_pm);
445 if (ret < 0)
446 goto out;
447
448 usleep_range(10000, 11000);
449
450 ret = asix_sw_reset(dev, AX_SWRESET_IPRL, in_pm);
451 if (ret < 0)
452 goto out;
453
454 msleep(160);
455
456 ret = asix_sw_reset(dev, AX_SWRESET_CLEAR, in_pm);
457 if (ret < 0)
458 goto out;
459
460 ret = asix_sw_reset(dev, AX_SWRESET_IPRL, in_pm);
461 if (ret < 0)
462 goto out;
463
464 msleep(200);
465
466 if (in_pm && (!asix_mdio_read_nopm(dev->net, dev->mii.phy_id,
467 MII_PHYSID1))) {
468 ret = -1;
469 goto out;
470 }
471
472 ret = asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG, 0,
473 0, 1, &chipcode, in_pm);
474 if (ret < 0)
475 goto out;
476
477 if ((chipcode & AX_CHIPCODE_MASK) == AX_AX88772B_CHIPCODE) {
478 ret = asix_write_cmd(dev, AX_QCTCTRL, 0x8000, 0x8001,
479 0, NULL, in_pm);
480 if (ret < 0) {
481 netdev_dbg(dev->net, "Write BQ setting failed: %d\n",
482 ret);
483 goto out;
484 }
485 }
486
487 ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0,
488 AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,
489 AX88772_IPG2_DEFAULT, 0, NULL, in_pm);
490 if (ret < 0) {
491 netdev_dbg(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", ret);
492 goto out;
493 }
494
495 /* Rewrite MAC address */
496 memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN);
497 ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN,
498 data->mac_addr, in_pm);
499 if (ret < 0)
500 goto out;
501
502 /* Set RX_CTL to default values with 2k buffer, and enable cactus */
503 ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL, in_pm);
504 if (ret < 0)
505 goto out;
506
507 ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT, in_pm);
508 if (ret < 0)
509 return ret;
510
511 /* Set RX_CTL to default values with 2k buffer, and enable cactus */
512 ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL, in_pm);
513 if (ret < 0)
514 goto out;
515
516 rx_ctl = asix_read_rx_ctl(dev, in_pm);
517 netdev_dbg(dev->net, "RX_CTL is 0x%04x after all initializations\n",
518 rx_ctl);
519
520 rx_ctl = asix_read_medium_status(dev, in_pm);
521 netdev_dbg(dev->net,
522 "Medium Status is 0x%04x after all initializations\n",
523 rx_ctl);
524
525 return 0;
526
527out:
528 return ret;
Grant Grundler4ad14382011-10-04 09:55:16 +0000529}
530
531static const struct net_device_ops ax88772_netdev_ops = {
532 .ndo_open = usbnet_open,
533 .ndo_stop = usbnet_stop,
534 .ndo_start_xmit = usbnet_start_xmit,
535 .ndo_tx_timeout = usbnet_tx_timeout,
536 .ndo_change_mtu = usbnet_change_mtu,
537 .ndo_set_mac_address = asix_set_mac_address,
538 .ndo_validate_addr = eth_validate_addr,
539 .ndo_do_ioctl = asix_ioctl,
540 .ndo_set_rx_mode = asix_set_multicast,
541};
542
Robert Fossd9fe64e2016-08-29 09:32:15 -0400543static void ax88772_suspend(struct usbnet *dev)
544{
545 struct asix_common_private *priv = dev->driver_priv;
546
547 /* Preserve BMCR for restoring */
548 priv->presvd_phy_bmcr =
549 asix_mdio_read_nopm(dev->net, dev->mii.phy_id, MII_BMCR);
550
551 /* Preserve ANAR for restoring */
552 priv->presvd_phy_advertise =
553 asix_mdio_read_nopm(dev->net, dev->mii.phy_id, MII_ADVERTISE);
554}
555
556static int asix_suspend(struct usb_interface *intf, pm_message_t message)
557{
558 struct usbnet *dev = usb_get_intfdata(intf);
559 struct asix_common_private *priv = dev->driver_priv;
560
561 if (priv->suspend)
562 priv->suspend(dev);
563
564 return usbnet_suspend(intf, message);
565}
566
567static void ax88772_restore_phy(struct usbnet *dev)
568{
569 struct asix_common_private *priv = dev->driver_priv;
570
571 if (priv->presvd_phy_advertise) {
572 /* Restore Advertisement control reg */
573 asix_mdio_write_nopm(dev->net, dev->mii.phy_id, MII_ADVERTISE,
574 priv->presvd_phy_advertise);
575
576 /* Restore BMCR */
577 asix_mdio_write_nopm(dev->net, dev->mii.phy_id, MII_BMCR,
578 priv->presvd_phy_bmcr);
579
580 priv->presvd_phy_advertise = 0;
581 priv->presvd_phy_bmcr = 0;
582 }
583}
584
585static void ax88772_resume(struct usbnet *dev)
586{
587 int i;
588
589 for (i = 0; i < 3; i++)
590 if (!ax88772_hw_reset(dev, 1))
591 break;
592 ax88772_restore_phy(dev);
593}
594
595static void ax88772a_resume(struct usbnet *dev)
596{
597 int i;
598
599 for (i = 0; i < 3; i++) {
600 if (!ax88772a_hw_reset(dev, 1))
601 break;
602 }
603
604 ax88772_restore_phy(dev);
605}
606
607static int asix_resume(struct usb_interface *intf)
608{
609 struct usbnet *dev = usb_get_intfdata(intf);
610 struct asix_common_private *priv = dev->driver_priv;
611
612 if (priv->resume)
613 priv->resume(dev);
614
615 return usbnet_resume(intf);
616}
617
Grant Grundler4ad14382011-10-04 09:55:16 +0000618static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
619{
Robert Fossd9fe64e2016-08-29 09:32:15 -0400620 int ret, i;
621 u8 buf[ETH_ALEN], chipcode = 0;
Grant Grundler4ad14382011-10-04 09:55:16 +0000622 u32 phyid;
Robert Fossd9fe64e2016-08-29 09:32:15 -0400623 struct asix_common_private *priv;
Grant Grundler4ad14382011-10-04 09:55:16 +0000624
Grant Grundler4ad14382011-10-04 09:55:16 +0000625 usbnet_get_endpoints(dev,intf);
626
627 /* Get the MAC address */
Lucas Stach5620df62013-01-16 04:24:06 +0000628 if (dev->driver_info->data & FLAG_EEPROM_MAC) {
629 for (i = 0; i < (ETH_ALEN >> 1); i++) {
630 ret = asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x04 + i,
Robert Fossd9fe64e2016-08-29 09:32:15 -0400631 0, 2, buf + i * 2, 0);
Lucas Stach5620df62013-01-16 04:24:06 +0000632 if (ret < 0)
633 break;
634 }
635 } else {
636 ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID,
Robert Fossd9fe64e2016-08-29 09:32:15 -0400637 0, 0, ETH_ALEN, buf, 0);
Lucas Stach5620df62013-01-16 04:24:06 +0000638 }
639
Grant Grundler83e1b912011-10-04 09:55:18 +0000640 if (ret < 0) {
Greg Kroah-Hartman49ae25b2012-09-19 09:46:14 +0000641 netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
Grant Grundler83e1b912011-10-04 09:55:18 +0000642 return ret;
Grant Grundler4ad14382011-10-04 09:55:16 +0000643 }
Jean-Christophe PLAGNIOL-VILLARD452b5ec2012-11-21 21:35:17 +0000644
645 asix_set_netdev_dev_addr(dev, buf);
Grant Grundler4ad14382011-10-04 09:55:16 +0000646
647 /* Initialize MII structure */
648 dev->mii.dev = dev->net;
649 dev->mii.mdio_read = asix_mdio_read;
650 dev->mii.mdio_write = asix_mdio_write;
651 dev->mii.phy_id_mask = 0x1f;
652 dev->mii.reg_num_mask = 0x1f;
653 dev->mii.phy_id = asix_get_phy_addr(dev);
654
Grant Grundler4ad14382011-10-04 09:55:16 +0000655 dev->net->netdev_ops = &ax88772_netdev_ops;
656 dev->net->ethtool_ops = &ax88772_ethtool_ops;
Eric Dumazet95162d62012-07-05 04:31:01 +0000657 dev->net->needed_headroom = 4; /* cf asix_tx_fixup() */
658 dev->net->needed_tailroom = 4; /* cf asix_tx_fixup() */
Grant Grundler4ad14382011-10-04 09:55:16 +0000659
Robert Fossd9fe64e2016-08-29 09:32:15 -0400660 asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG, 0, 0, 1, &chipcode, 0);
661 chipcode &= AX_CHIPCODE_MASK;
Grant Grundlerd3665182011-11-15 07:12:41 +0000662
Robert Fossd9fe64e2016-08-29 09:32:15 -0400663 (chipcode == AX_AX88772_CHIPCODE) ? ax88772_hw_reset(dev, 0) :
664 ax88772a_hw_reset(dev, 0);
Grant Grundlerd3665182011-11-15 07:12:41 +0000665
666 /* Read PHYID register *AFTER* the PHY was reset properly */
667 phyid = asix_get_phyid(dev);
Greg Kroah-Hartman49ae25b2012-09-19 09:46:14 +0000668 netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid);
Grant Grundlerd3665182011-11-15 07:12:41 +0000669
David Brownell2e55cc72005-08-31 09:53:10 -0700670 /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
671 if (dev->driver_info->flags & FLAG_FRAMING_AX) {
672 /* hard_mtu is still the default - the device does not support
673 jumbo eth frames */
674 dev->rx_urb_size = 2048;
675 }
Grant Grundler83e1b912011-10-04 09:55:18 +0000676
Lucas Stach8b5b6f52013-01-16 04:24:07 +0000677 dev->driver_priv = kzalloc(sizeof(struct asix_common_private), GFP_KERNEL);
678 if (!dev->driver_priv)
679 return -ENOMEM;
680
Robert Fossd9fe64e2016-08-29 09:32:15 -0400681 priv = dev->driver_priv;
682
683 priv->presvd_phy_bmcr = 0;
684 priv->presvd_phy_advertise = 0;
685 if (chipcode == AX_AX88772_CHIPCODE) {
686 priv->resume = ax88772_resume;
687 priv->suspend = ax88772_suspend;
688 } else {
689 priv->resume = ax88772a_resume;
690 priv->suspend = ax88772_suspend;
691 }
692
David Brownell2e55cc72005-08-31 09:53:10 -0700693 return 0;
David Brownell2e55cc72005-08-31 09:53:10 -0700694}
695
Wu Fengguangad327912013-01-18 15:36:56 +0000696static void ax88772_unbind(struct usbnet *dev, struct usb_interface *intf)
Lucas Stach8b5b6f52013-01-16 04:24:07 +0000697{
Markus Elfring91ecee62014-11-20 16:11:56 +0100698 kfree(dev->driver_priv);
Lucas Stach8b5b6f52013-01-16 04:24:07 +0000699}
700
stephen hemmingerbc689c92012-01-05 19:10:23 +0000701static const struct ethtool_ops ax88178_ethtool_ops = {
David Hollis933a27d2006-07-29 10:12:50 -0400702 .get_drvinfo = asix_get_drvinfo,
703 .get_link = asix_get_link,
David Hollis933a27d2006-07-29 10:12:50 -0400704 .get_msglevel = usbnet_get_msglevel,
705 .set_msglevel = usbnet_set_msglevel,
706 .get_wol = asix_get_wol,
707 .set_wol = asix_set_wol,
708 .get_eeprom_len = asix_get_eeprom_len,
709 .get_eeprom = asix_get_eeprom,
Christian Rieschcb7b24c2012-07-19 00:23:07 +0000710 .set_eeprom = asix_set_eeprom,
Arnd Bergmannc41286f2006-10-09 00:08:01 +0200711 .get_settings = usbnet_get_settings,
712 .set_settings = usbnet_set_settings,
713 .nway_reset = usbnet_nway_reset,
David Hollis933a27d2006-07-29 10:12:50 -0400714};
715
716static int marvell_phy_init(struct usbnet *dev)
David Brownell2e55cc72005-08-31 09:53:10 -0700717{
David Hollis933a27d2006-07-29 10:12:50 -0400718 struct asix_data *data = (struct asix_data *)&dev->data;
719 u16 reg;
David Brownell2e55cc72005-08-31 09:53:10 -0700720
Joe Perches60b86752010-02-17 10:30:23 +0000721 netdev_dbg(dev->net, "marvell_phy_init()\n");
David Brownell2e55cc72005-08-31 09:53:10 -0700722
David Hollis933a27d2006-07-29 10:12:50 -0400723 reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_MARVELL_STATUS);
Joe Perches60b86752010-02-17 10:30:23 +0000724 netdev_dbg(dev->net, "MII_MARVELL_STATUS = 0x%04x\n", reg);
David Brownell2e55cc72005-08-31 09:53:10 -0700725
David Hollis933a27d2006-07-29 10:12:50 -0400726 asix_mdio_write(dev->net, dev->mii.phy_id, MII_MARVELL_CTRL,
727 MARVELL_CTRL_RXDELAY | MARVELL_CTRL_TXDELAY);
David Brownell2e55cc72005-08-31 09:53:10 -0700728
David Hollis933a27d2006-07-29 10:12:50 -0400729 if (data->ledmode) {
730 reg = asix_mdio_read(dev->net, dev->mii.phy_id,
731 MII_MARVELL_LED_CTRL);
Joe Perches60b86752010-02-17 10:30:23 +0000732 netdev_dbg(dev->net, "MII_MARVELL_LED_CTRL (1) = 0x%04x\n", reg);
David Brownell2e55cc72005-08-31 09:53:10 -0700733
David Hollis933a27d2006-07-29 10:12:50 -0400734 reg &= 0xf8ff;
735 reg |= (1 + 0x0100);
736 asix_mdio_write(dev->net, dev->mii.phy_id,
737 MII_MARVELL_LED_CTRL, reg);
David Brownell2e55cc72005-08-31 09:53:10 -0700738
David Hollis933a27d2006-07-29 10:12:50 -0400739 reg = asix_mdio_read(dev->net, dev->mii.phy_id,
740 MII_MARVELL_LED_CTRL);
Joe Perches60b86752010-02-17 10:30:23 +0000741 netdev_dbg(dev->net, "MII_MARVELL_LED_CTRL (2) = 0x%04x\n", reg);
David Hollis933a27d2006-07-29 10:12:50 -0400742 reg &= 0xfc0f;
David Brownell2e55cc72005-08-31 09:53:10 -0700743 }
744
David Brownell2e55cc72005-08-31 09:53:10 -0700745 return 0;
746}
747
Grant Grundler610d8852011-10-04 09:55:17 +0000748static int rtl8211cl_phy_init(struct usbnet *dev)
749{
750 struct asix_data *data = (struct asix_data *)&dev->data;
751
752 netdev_dbg(dev->net, "rtl8211cl_phy_init()\n");
753
754 asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0x0005);
755 asix_mdio_write (dev->net, dev->mii.phy_id, 0x0c, 0);
756 asix_mdio_write (dev->net, dev->mii.phy_id, 0x01,
757 asix_mdio_read (dev->net, dev->mii.phy_id, 0x01) | 0x0080);
758 asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0);
759
760 if (data->ledmode == 12) {
761 asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0x0002);
762 asix_mdio_write (dev->net, dev->mii.phy_id, 0x1a, 0x00cb);
763 asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0);
764 }
765
766 return 0;
767}
768
David Hollis933a27d2006-07-29 10:12:50 -0400769static int marvell_led_status(struct usbnet *dev, u16 speed)
770{
771 u16 reg = asix_mdio_read(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL);
772
Joe Perches60b86752010-02-17 10:30:23 +0000773 netdev_dbg(dev->net, "marvell_led_status() read 0x%04x\n", reg);
David Hollis933a27d2006-07-29 10:12:50 -0400774
775 /* Clear out the center LED bits - 0x03F0 */
776 reg &= 0xfc0f;
777
778 switch (speed) {
779 case SPEED_1000:
780 reg |= 0x03e0;
781 break;
782 case SPEED_100:
783 reg |= 0x03b0;
784 break;
785 default:
786 reg |= 0x02f0;
787 }
788
Joe Perches60b86752010-02-17 10:30:23 +0000789 netdev_dbg(dev->net, "marvell_led_status() writing 0x%04x\n", reg);
David Hollis933a27d2006-07-29 10:12:50 -0400790 asix_mdio_write(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL, reg);
791
792 return 0;
793}
794
Grant Grundler610d8852011-10-04 09:55:17 +0000795static int ax88178_reset(struct usbnet *dev)
796{
797 struct asix_data *data = (struct asix_data *)&dev->data;
798 int ret;
799 __le16 eeprom;
800 u8 status;
801 int gpio0 = 0;
Grant Grundlerb2d3ad292011-11-15 07:12:42 +0000802 u32 phyid;
Grant Grundler610d8852011-10-04 09:55:17 +0000803
Robert Fossd9fe64e2016-08-29 09:32:15 -0400804 asix_read_cmd(dev, AX_CMD_READ_GPIOS, 0, 0, 1, &status, 0);
Greg Kroah-Hartman49ae25b2012-09-19 09:46:14 +0000805 netdev_dbg(dev->net, "GPIO Status: 0x%04x\n", status);
Grant Grundler610d8852011-10-04 09:55:17 +0000806
Robert Fossd9fe64e2016-08-29 09:32:15 -0400807 asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0, 0, 0, NULL, 0);
808 asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2, &eeprom, 0);
809 asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0, 0, 0, NULL, 0);
Grant Grundler610d8852011-10-04 09:55:17 +0000810
Greg Kroah-Hartman49ae25b2012-09-19 09:46:14 +0000811 netdev_dbg(dev->net, "EEPROM index 0x17 is 0x%04x\n", eeprom);
Grant Grundler610d8852011-10-04 09:55:17 +0000812
813 if (eeprom == cpu_to_le16(0xffff)) {
814 data->phymode = PHY_MODE_MARVELL;
815 data->ledmode = 0;
816 gpio0 = 1;
817 } else {
Grant Grundlerb2d3ad292011-11-15 07:12:42 +0000818 data->phymode = le16_to_cpu(eeprom) & 0x7F;
Grant Grundler610d8852011-10-04 09:55:17 +0000819 data->ledmode = le16_to_cpu(eeprom) >> 8;
820 gpio0 = (le16_to_cpu(eeprom) & 0x80) ? 0 : 1;
821 }
Greg Kroah-Hartman49ae25b2012-09-19 09:46:14 +0000822 netdev_dbg(dev->net, "GPIO0: %d, PhyMode: %d\n", gpio0, data->phymode);
Grant Grundler610d8852011-10-04 09:55:17 +0000823
Grant Grundlerb2d3ad292011-11-15 07:12:42 +0000824 /* Power up external GigaPHY through AX88178 GPIO pin */
Robert Fossd9fe64e2016-08-29 09:32:15 -0400825 asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_1 |
826 AX_GPIO_GPO1EN, 40, 0);
Grant Grundler610d8852011-10-04 09:55:17 +0000827 if ((le16_to_cpu(eeprom) >> 8) != 1) {
Robert Fossd9fe64e2016-08-29 09:32:15 -0400828 asix_write_gpio(dev, 0x003c, 30, 0);
829 asix_write_gpio(dev, 0x001c, 300, 0);
830 asix_write_gpio(dev, 0x003c, 30, 0);
Grant Grundler610d8852011-10-04 09:55:17 +0000831 } else {
Greg Kroah-Hartman49ae25b2012-09-19 09:46:14 +0000832 netdev_dbg(dev->net, "gpio phymode == 1 path\n");
Robert Fossd9fe64e2016-08-29 09:32:15 -0400833 asix_write_gpio(dev, AX_GPIO_GPO1EN, 30, 0);
834 asix_write_gpio(dev, AX_GPIO_GPO1EN | AX_GPIO_GPO_1, 30, 0);
Grant Grundler610d8852011-10-04 09:55:17 +0000835 }
836
Grant Grundlerb2d3ad292011-11-15 07:12:42 +0000837 /* Read PHYID register *AFTER* powering up PHY */
838 phyid = asix_get_phyid(dev);
Greg Kroah-Hartman49ae25b2012-09-19 09:46:14 +0000839 netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid);
Grant Grundlerb2d3ad292011-11-15 07:12:42 +0000840
841 /* Set AX88178 to enable MII/GMII/RGMII interface for external PHY */
Robert Fossd9fe64e2016-08-29 09:32:15 -0400842 asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0, 0, 0, NULL, 0);
Grant Grundlerb2d3ad292011-11-15 07:12:42 +0000843
Robert Fossd9fe64e2016-08-29 09:32:15 -0400844 asix_sw_reset(dev, 0, 0);
Grant Grundler610d8852011-10-04 09:55:17 +0000845 msleep(150);
846
Robert Fossd9fe64e2016-08-29 09:32:15 -0400847 asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD, 0);
Grant Grundler610d8852011-10-04 09:55:17 +0000848 msleep(150);
849
Robert Fossd9fe64e2016-08-29 09:32:15 -0400850 asix_write_rx_ctl(dev, 0, 0);
Grant Grundler610d8852011-10-04 09:55:17 +0000851
852 if (data->phymode == PHY_MODE_MARVELL) {
853 marvell_phy_init(dev);
854 msleep(60);
855 } else if (data->phymode == PHY_MODE_RTL8211CL)
856 rtl8211cl_phy_init(dev);
857
858 asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR,
859 BMCR_RESET | BMCR_ANENABLE);
860 asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
861 ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
862 asix_mdio_write(dev->net, dev->mii.phy_id, MII_CTRL1000,
863 ADVERTISE_1000FULL);
864
865 mii_nway_restart(&dev->mii);
866
Robert Fossd9fe64e2016-08-29 09:32:15 -0400867 ret = asix_write_medium_mode(dev, AX88178_MEDIUM_DEFAULT, 0);
Grant Grundler83e1b912011-10-04 09:55:18 +0000868 if (ret < 0)
869 return ret;
Grant Grundler610d8852011-10-04 09:55:17 +0000870
Jussi Kivilinna71bc5d92012-01-10 06:40:23 +0000871 /* Rewrite MAC address */
872 memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN);
873 ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN,
Robert Fossd9fe64e2016-08-29 09:32:15 -0400874 data->mac_addr, 0);
Jussi Kivilinna71bc5d92012-01-10 06:40:23 +0000875 if (ret < 0)
876 return ret;
877
Robert Fossd9fe64e2016-08-29 09:32:15 -0400878 ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL, 0);
Grant Grundler83e1b912011-10-04 09:55:18 +0000879 if (ret < 0)
880 return ret;
Grant Grundler610d8852011-10-04 09:55:17 +0000881
882 return 0;
Grant Grundler610d8852011-10-04 09:55:17 +0000883}
884
David Hollis933a27d2006-07-29 10:12:50 -0400885static int ax88178_link_reset(struct usbnet *dev)
886{
887 u16 mode;
David Decotigny8ae6daca2011-04-27 18:32:38 +0000888 struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
David Hollis933a27d2006-07-29 10:12:50 -0400889 struct asix_data *data = (struct asix_data *)&dev->data;
David Decotigny8ae6daca2011-04-27 18:32:38 +0000890 u32 speed;
David Hollis933a27d2006-07-29 10:12:50 -0400891
Joe Perches60b86752010-02-17 10:30:23 +0000892 netdev_dbg(dev->net, "ax88178_link_reset()\n");
David Hollis933a27d2006-07-29 10:12:50 -0400893
894 mii_check_media(&dev->mii, 1, 1);
895 mii_ethtool_gset(&dev->mii, &ecmd);
896 mode = AX88178_MEDIUM_DEFAULT;
David Decotigny8ae6daca2011-04-27 18:32:38 +0000897 speed = ethtool_cmd_speed(&ecmd);
David Hollis933a27d2006-07-29 10:12:50 -0400898
David Decotigny8ae6daca2011-04-27 18:32:38 +0000899 if (speed == SPEED_1000)
Pantelis Koukousoulasa7f75c02008-11-20 01:48:46 -0800900 mode |= AX_MEDIUM_GM;
David Decotigny8ae6daca2011-04-27 18:32:38 +0000901 else if (speed == SPEED_100)
David Hollis933a27d2006-07-29 10:12:50 -0400902 mode |= AX_MEDIUM_PS;
903 else
904 mode &= ~(AX_MEDIUM_PS | AX_MEDIUM_GM);
905
Pantelis Koukousoulasa7f75c02008-11-20 01:48:46 -0800906 mode |= AX_MEDIUM_ENCK;
907
David Hollis933a27d2006-07-29 10:12:50 -0400908 if (ecmd.duplex == DUPLEX_FULL)
909 mode |= AX_MEDIUM_FD;
910 else
911 mode &= ~AX_MEDIUM_FD;
912
David Decotigny8ae6daca2011-04-27 18:32:38 +0000913 netdev_dbg(dev->net, "ax88178_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n",
914 speed, ecmd.duplex, mode);
David Hollis933a27d2006-07-29 10:12:50 -0400915
Robert Fossd9fe64e2016-08-29 09:32:15 -0400916 asix_write_medium_mode(dev, mode, 0);
David Hollis933a27d2006-07-29 10:12:50 -0400917
918 if (data->phymode == PHY_MODE_MARVELL && data->ledmode)
David Decotigny8ae6daca2011-04-27 18:32:38 +0000919 marvell_led_status(dev, speed);
David Hollis933a27d2006-07-29 10:12:50 -0400920
921 return 0;
922}
923
924static void ax88178_set_mfb(struct usbnet *dev)
925{
926 u16 mfb = AX_RX_CTL_MFB_16384;
927 u16 rxctl;
928 u16 medium;
929 int old_rx_urb_size = dev->rx_urb_size;
930
931 if (dev->hard_mtu < 2048) {
932 dev->rx_urb_size = 2048;
933 mfb = AX_RX_CTL_MFB_2048;
934 } else if (dev->hard_mtu < 4096) {
935 dev->rx_urb_size = 4096;
936 mfb = AX_RX_CTL_MFB_4096;
937 } else if (dev->hard_mtu < 8192) {
938 dev->rx_urb_size = 8192;
939 mfb = AX_RX_CTL_MFB_8192;
940 } else if (dev->hard_mtu < 16384) {
941 dev->rx_urb_size = 16384;
942 mfb = AX_RX_CTL_MFB_16384;
943 }
944
Robert Fossd9fe64e2016-08-29 09:32:15 -0400945 rxctl = asix_read_rx_ctl(dev, 0);
946 asix_write_rx_ctl(dev, (rxctl & ~AX_RX_CTL_MFB_16384) | mfb, 0);
David Hollis933a27d2006-07-29 10:12:50 -0400947
Robert Fossd9fe64e2016-08-29 09:32:15 -0400948 medium = asix_read_medium_status(dev, 0);
David Hollis933a27d2006-07-29 10:12:50 -0400949 if (dev->net->mtu > 1500)
950 medium |= AX_MEDIUM_JFE;
951 else
952 medium &= ~AX_MEDIUM_JFE;
Robert Fossd9fe64e2016-08-29 09:32:15 -0400953 asix_write_medium_mode(dev, medium, 0);
David Hollis933a27d2006-07-29 10:12:50 -0400954
955 if (dev->rx_urb_size > old_rx_urb_size)
956 usbnet_unlink_rx_urbs(dev);
957}
958
959static int ax88178_change_mtu(struct net_device *net, int new_mtu)
960{
961 struct usbnet *dev = netdev_priv(net);
962 int ll_mtu = new_mtu + net->hard_header_len + 4;
963
Joe Perches60b86752010-02-17 10:30:23 +0000964 netdev_dbg(dev->net, "ax88178_change_mtu() new_mtu=%d\n", new_mtu);
David Hollis933a27d2006-07-29 10:12:50 -0400965
966 if (new_mtu <= 0 || ll_mtu > 16384)
967 return -EINVAL;
968
969 if ((ll_mtu % dev->maxpacket) == 0)
970 return -EDOM;
971
972 net->mtu = new_mtu;
973 dev->hard_mtu = net->mtu + net->hard_header_len;
974 ax88178_set_mfb(dev);
975
Ming Leia88c32a2013-07-25 13:47:53 +0800976 /* max qlen depend on hard_mtu and rx_urb_size */
977 usbnet_update_max_qlen(dev);
978
David Hollis933a27d2006-07-29 10:12:50 -0400979 return 0;
980}
981
Stephen Hemminger17033382009-03-20 19:35:55 +0000982static const struct net_device_ops ax88178_netdev_ops = {
983 .ndo_open = usbnet_open,
984 .ndo_stop = usbnet_stop,
985 .ndo_start_xmit = usbnet_start_xmit,
986 .ndo_tx_timeout = usbnet_tx_timeout,
Jussi Kivilinna7f29a3b2010-03-09 12:24:38 +0000987 .ndo_set_mac_address = asix_set_mac_address,
Stephen Hemminger17033382009-03-20 19:35:55 +0000988 .ndo_validate_addr = eth_validate_addr,
Jiri Pirkoafc4b132011-08-16 06:29:01 +0000989 .ndo_set_rx_mode = asix_set_multicast,
Stephen Hemminger17033382009-03-20 19:35:55 +0000990 .ndo_do_ioctl = asix_ioctl,
991 .ndo_change_mtu = ax88178_change_mtu,
992};
993
David Hollis933a27d2006-07-29 10:12:50 -0400994static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
995{
David Hollis933a27d2006-07-29 10:12:50 -0400996 int ret;
Al Viro51bf2972007-12-22 17:42:36 +0000997 u8 buf[ETH_ALEN];
David Hollis933a27d2006-07-29 10:12:50 -0400998
999 usbnet_get_endpoints(dev,intf);
1000
David Hollis933a27d2006-07-29 10:12:50 -04001001 /* Get the MAC address */
Robert Fossd9fe64e2016-08-29 09:32:15 -04001002 ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf, 0);
Grant Grundler83e1b912011-10-04 09:55:18 +00001003 if (ret < 0) {
Greg Kroah-Hartman49ae25b2012-09-19 09:46:14 +00001004 netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
Grant Grundler83e1b912011-10-04 09:55:18 +00001005 return ret;
David Hollis933a27d2006-07-29 10:12:50 -04001006 }
Jean-Christophe PLAGNIOL-VILLARD452b5ec2012-11-21 21:35:17 +00001007
1008 asix_set_netdev_dev_addr(dev, buf);
David Hollis933a27d2006-07-29 10:12:50 -04001009
1010 /* Initialize MII structure */
1011 dev->mii.dev = dev->net;
1012 dev->mii.mdio_read = asix_mdio_read;
1013 dev->mii.mdio_write = asix_mdio_write;
1014 dev->mii.phy_id_mask = 0x1f;
1015 dev->mii.reg_num_mask = 0xff;
1016 dev->mii.supports_gmii = 1;
David Hollis933a27d2006-07-29 10:12:50 -04001017 dev->mii.phy_id = asix_get_phy_addr(dev);
Stephen Hemminger17033382009-03-20 19:35:55 +00001018
1019 dev->net->netdev_ops = &ax88178_netdev_ops;
David Hollis933a27d2006-07-29 10:12:50 -04001020 dev->net->ethtool_ops = &ax88178_ethtool_ops;
David Hollis933a27d2006-07-29 10:12:50 -04001021
Grant Grundlerb2d3ad292011-11-15 07:12:42 +00001022 /* Blink LEDS so users know driver saw dongle */
Robert Fossd9fe64e2016-08-29 09:32:15 -04001023 asix_sw_reset(dev, 0, 0);
Grant Grundlerb2d3ad292011-11-15 07:12:42 +00001024 msleep(150);
David Hollis933a27d2006-07-29 10:12:50 -04001025
Robert Fossd9fe64e2016-08-29 09:32:15 -04001026 asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD, 0);
Grant Grundlerb2d3ad292011-11-15 07:12:42 +00001027 msleep(150);
David Hollis933a27d2006-07-29 10:12:50 -04001028
1029 /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
1030 if (dev->driver_info->flags & FLAG_FRAMING_AX) {
1031 /* hard_mtu is still the default - the device does not support
1032 jumbo eth frames */
1033 dev->rx_urb_size = 2048;
1034 }
David Hollis933a27d2006-07-29 10:12:50 -04001035
Lucas Stach8b5b6f52013-01-16 04:24:07 +00001036 dev->driver_priv = kzalloc(sizeof(struct asix_common_private), GFP_KERNEL);
1037 if (!dev->driver_priv)
1038 return -ENOMEM;
1039
Grant Grundler83e1b912011-10-04 09:55:18 +00001040 return 0;
David Hollis933a27d2006-07-29 10:12:50 -04001041}
1042
David Brownell2e55cc72005-08-31 09:53:10 -07001043static const struct driver_info ax8817x_info = {
1044 .description = "ASIX AX8817x USB 2.0 Ethernet",
David Hollis48b1be62006-03-28 20:15:42 -05001045 .bind = ax88172_bind,
1046 .status = asix_status,
David Brownell2e55cc72005-08-31 09:53:10 -07001047 .link_reset = ax88172_link_reset,
1048 .reset = ax88172_link_reset,
Ben Hutchings37e82732009-11-04 15:29:52 +00001049 .flags = FLAG_ETHER | FLAG_LINK_INTR,
David Brownell2e55cc72005-08-31 09:53:10 -07001050 .data = 0x00130103,
1051};
1052
1053static const struct driver_info dlink_dub_e100_info = {
1054 .description = "DLink DUB-E100 USB Ethernet",
David Hollis48b1be62006-03-28 20:15:42 -05001055 .bind = ax88172_bind,
1056 .status = asix_status,
David Brownell2e55cc72005-08-31 09:53:10 -07001057 .link_reset = ax88172_link_reset,
1058 .reset = ax88172_link_reset,
Ben Hutchings37e82732009-11-04 15:29:52 +00001059 .flags = FLAG_ETHER | FLAG_LINK_INTR,
David Brownell2e55cc72005-08-31 09:53:10 -07001060 .data = 0x009f9d9f,
1061};
1062
1063static const struct driver_info netgear_fa120_info = {
1064 .description = "Netgear FA-120 USB Ethernet",
David Hollis48b1be62006-03-28 20:15:42 -05001065 .bind = ax88172_bind,
1066 .status = asix_status,
David Brownell2e55cc72005-08-31 09:53:10 -07001067 .link_reset = ax88172_link_reset,
1068 .reset = ax88172_link_reset,
Ben Hutchings37e82732009-11-04 15:29:52 +00001069 .flags = FLAG_ETHER | FLAG_LINK_INTR,
David Brownell2e55cc72005-08-31 09:53:10 -07001070 .data = 0x00130103,
1071};
1072
1073static const struct driver_info hawking_uf200_info = {
1074 .description = "Hawking UF200 USB Ethernet",
David Hollis48b1be62006-03-28 20:15:42 -05001075 .bind = ax88172_bind,
1076 .status = asix_status,
David Brownell2e55cc72005-08-31 09:53:10 -07001077 .link_reset = ax88172_link_reset,
1078 .reset = ax88172_link_reset,
Ben Hutchings37e82732009-11-04 15:29:52 +00001079 .flags = FLAG_ETHER | FLAG_LINK_INTR,
David Brownell2e55cc72005-08-31 09:53:10 -07001080 .data = 0x001f1d1f,
1081};
1082
1083static const struct driver_info ax88772_info = {
1084 .description = "ASIX AX88772 USB 2.0 Ethernet",
1085 .bind = ax88772_bind,
Lucas Stach8b5b6f52013-01-16 04:24:07 +00001086 .unbind = ax88772_unbind,
David Hollis48b1be62006-03-28 20:15:42 -05001087 .status = asix_status,
David Brownell2e55cc72005-08-31 09:53:10 -07001088 .link_reset = ax88772_link_reset,
Robert Fossd9fe64e2016-08-29 09:32:15 -04001089 .reset = ax88772_reset,
Eric Dumazeta9e0aca2012-03-14 20:18:32 +00001090 .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | FLAG_MULTI_PACKET,
Lucas Stach8b5b6f52013-01-16 04:24:07 +00001091 .rx_fixup = asix_rx_fixup_common,
David Hollis933a27d2006-07-29 10:12:50 -04001092 .tx_fixup = asix_tx_fixup,
1093};
1094
Lucas Stach5620df62013-01-16 04:24:06 +00001095static const struct driver_info ax88772b_info = {
1096 .description = "ASIX AX88772B USB 2.0 Ethernet",
1097 .bind = ax88772_bind,
Lucas Stach8b5b6f52013-01-16 04:24:07 +00001098 .unbind = ax88772_unbind,
Lucas Stach5620df62013-01-16 04:24:06 +00001099 .status = asix_status,
1100 .link_reset = ax88772_link_reset,
1101 .reset = ax88772_reset,
1102 .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR |
1103 FLAG_MULTI_PACKET,
Lucas Stach8b5b6f52013-01-16 04:24:07 +00001104 .rx_fixup = asix_rx_fixup_common,
Lucas Stach5620df62013-01-16 04:24:06 +00001105 .tx_fixup = asix_tx_fixup,
1106 .data = FLAG_EEPROM_MAC,
1107};
1108
David Hollis933a27d2006-07-29 10:12:50 -04001109static const struct driver_info ax88178_info = {
1110 .description = "ASIX AX88178 USB 2.0 Ethernet",
1111 .bind = ax88178_bind,
Lucas Stach8b5b6f52013-01-16 04:24:07 +00001112 .unbind = ax88772_unbind,
David Hollis933a27d2006-07-29 10:12:50 -04001113 .status = asix_status,
1114 .link_reset = ax88178_link_reset,
Grant Grundler610d8852011-10-04 09:55:17 +00001115 .reset = ax88178_reset,
Emil Gooded43ff4c2014-02-13 19:30:39 +01001116 .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR |
1117 FLAG_MULTI_PACKET,
Lucas Stach8b5b6f52013-01-16 04:24:07 +00001118 .rx_fixup = asix_rx_fixup_common,
David Hollis933a27d2006-07-29 10:12:50 -04001119 .tx_fixup = asix_tx_fixup,
David Brownell2e55cc72005-08-31 09:53:10 -07001120};
1121
Glen Turner45af3fb2013-02-27 04:32:36 +00001122/*
1123 * USBLINK 20F9 "USB 2.0 LAN" USB ethernet adapter, typically found in
1124 * no-name packaging.
1125 * USB device strings are:
1126 * 1: Manufacturer: USBLINK
1127 * 2: Product: HG20F9 USB2.0
1128 * 3: Serial: 000003
1129 * Appears to be compatible with Asix 88772B.
1130 */
1131static const struct driver_info hg20f9_info = {
1132 .description = "HG20F9 USB 2.0 Ethernet",
1133 .bind = ax88772_bind,
1134 .unbind = ax88772_unbind,
1135 .status = asix_status,
1136 .link_reset = ax88772_link_reset,
1137 .reset = ax88772_reset,
1138 .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR |
1139 FLAG_MULTI_PACKET,
1140 .rx_fixup = asix_rx_fixup_common,
1141 .tx_fixup = asix_tx_fixup,
1142 .data = FLAG_EEPROM_MAC,
1143};
1144
David Brownell2e55cc72005-08-31 09:53:10 -07001145static const struct usb_device_id products [] = {
1146{
1147 // Linksys USB200M
1148 USB_DEVICE (0x077b, 0x2226),
1149 .driver_info = (unsigned long) &ax8817x_info,
1150}, {
1151 // Netgear FA120
1152 USB_DEVICE (0x0846, 0x1040),
1153 .driver_info = (unsigned long) &netgear_fa120_info,
1154}, {
1155 // DLink DUB-E100
1156 USB_DEVICE (0x2001, 0x1a00),
1157 .driver_info = (unsigned long) &dlink_dub_e100_info,
1158}, {
1159 // Intellinet, ST Lab USB Ethernet
1160 USB_DEVICE (0x0b95, 0x1720),
1161 .driver_info = (unsigned long) &ax8817x_info,
1162}, {
1163 // Hawking UF200, TrendNet TU2-ET100
1164 USB_DEVICE (0x07b8, 0x420a),
1165 .driver_info = (unsigned long) &hawking_uf200_info,
1166}, {
David Hollis39c4b382007-02-20 08:02:24 -05001167 // Billionton Systems, USB2AR
1168 USB_DEVICE (0x08dd, 0x90ff),
1169 .driver_info = (unsigned long) &ax8817x_info,
David Brownell2e55cc72005-08-31 09:53:10 -07001170}, {
Chia-Sheng Chang80083a32015-10-16 02:00:21 +08001171 // Billionton Systems, GUSB2AM-1G-B
1172 USB_DEVICE(0x08dd, 0x0114),
1173 .driver_info = (unsigned long) &ax88178_info,
1174}, {
David Brownell2e55cc72005-08-31 09:53:10 -07001175 // ATEN UC210T
1176 USB_DEVICE (0x0557, 0x2009),
1177 .driver_info = (unsigned long) &ax8817x_info,
1178}, {
1179 // Buffalo LUA-U2-KTX
1180 USB_DEVICE (0x0411, 0x003d),
1181 .driver_info = (unsigned long) &ax8817x_info,
1182}, {
Mattia Dongiliac7b77f2008-05-06 20:42:35 -07001183 // Buffalo LUA-U2-GT 10/100/1000
1184 USB_DEVICE (0x0411, 0x006e),
1185 .driver_info = (unsigned long) &ax88178_info,
1186}, {
David Brownell2e55cc72005-08-31 09:53:10 -07001187 // Sitecom LN-029 "USB 2.0 10/100 Ethernet adapter"
1188 USB_DEVICE (0x6189, 0x182d),
1189 .driver_info = (unsigned long) &ax8817x_info,
1190}, {
Joerg Neikes4e503912012-03-08 22:44:03 +00001191 // Sitecom LN-031 "USB 2.0 10/100/1000 Ethernet adapter"
1192 USB_DEVICE (0x0df6, 0x0056),
1193 .driver_info = (unsigned long) &ax88178_info,
1194}, {
Luca Ceresoli7488c3e2015-02-26 00:58:12 +01001195 // Sitecom LN-028 "USB 2.0 10/100/1000 Ethernet adapter"
1196 USB_DEVICE (0x0df6, 0x061c),
1197 .driver_info = (unsigned long) &ax88178_info,
1198}, {
David Brownell2e55cc72005-08-31 09:53:10 -07001199 // corega FEther USB2-TX
1200 USB_DEVICE (0x07aa, 0x0017),
1201 .driver_info = (unsigned long) &ax8817x_info,
1202}, {
1203 // Surecom EP-1427X-2
1204 USB_DEVICE (0x1189, 0x0893),
1205 .driver_info = (unsigned long) &ax8817x_info,
1206}, {
1207 // goodway corp usb gwusb2e
1208 USB_DEVICE (0x1631, 0x6200),
1209 .driver_info = (unsigned long) &ax8817x_info,
1210}, {
David Hollis39c4b382007-02-20 08:02:24 -05001211 // JVC MP-PRX1 Port Replicator
1212 USB_DEVICE (0x04f1, 0x3008),
1213 .driver_info = (unsigned long) &ax8817x_info,
1214}, {
Quinlan Pfiffer66dc81e2012-09-28 19:58:44 +00001215 // Lenovo U2L100P 10/100
1216 USB_DEVICE (0x17ef, 0x7203),
Robert Fossd9fe64e2016-08-29 09:32:15 -04001217 .driver_info = (unsigned long)&ax88772b_info,
Quinlan Pfiffer66dc81e2012-09-28 19:58:44 +00001218}, {
Marek Vasut30885902011-07-20 05:57:04 +00001219 // ASIX AX88772B 10/100
1220 USB_DEVICE (0x0b95, 0x772b),
Lucas Stach5620df62013-01-16 04:24:06 +00001221 .driver_info = (unsigned long) &ax88772b_info,
Marek Vasut30885902011-07-20 05:57:04 +00001222}, {
David Brownell2e55cc72005-08-31 09:53:10 -07001223 // ASIX AX88772 10/100
David Hollis39c4b382007-02-20 08:02:24 -05001224 USB_DEVICE (0x0b95, 0x7720),
1225 .driver_info = (unsigned long) &ax88772_info,
David Hollis5e0f76c2005-12-19 13:58:38 -05001226}, {
Eduard Warkentin73274132006-05-18 01:13:17 -07001227 // ASIX AX88178 10/100/1000
1228 USB_DEVICE (0x0b95, 0x1780),
David Hollis933a27d2006-07-29 10:12:50 -04001229 .driver_info = (unsigned long) &ax88178_info,
Eduard Warkentin73274132006-05-18 01:13:17 -07001230}, {
Arnaud Ebalardf4680d32010-12-15 12:16:30 +00001231 // Logitec LAN-GTJ/U2A
1232 USB_DEVICE (0x0789, 0x0160),
1233 .driver_info = (unsigned long) &ax88178_info,
1234}, {
David Hollis5e0f76c2005-12-19 13:58:38 -05001235 // Linksys USB200M Rev 2
1236 USB_DEVICE (0x13b1, 0x0018),
1237 .driver_info = (unsigned long) &ax88772_info,
David Hollis5732ce82006-01-05 14:39:49 -05001238}, {
1239 // 0Q0 cable ethernet
1240 USB_DEVICE (0x1557, 0x7720),
1241 .driver_info = (unsigned long) &ax88772_info,
David Hollis933a27d2006-07-29 10:12:50 -04001242}, {
1243 // DLink DUB-E100 H/W Ver B1
1244 USB_DEVICE (0x07d1, 0x3c05),
1245 .driver_info = (unsigned long) &ax88772_info,
1246}, {
David Hollisb923e7f2006-09-21 08:09:29 -04001247 // DLink DUB-E100 H/W Ver B1 Alternate
1248 USB_DEVICE (0x2001, 0x3c05),
1249 .driver_info = (unsigned long) &ax88772_info,
1250}, {
Søren holmed3770a2012-09-17 21:50:57 +00001251 // DLink DUB-E100 H/W Ver C1
1252 USB_DEVICE (0x2001, 0x1a02),
1253 .driver_info = (unsigned long) &ax88772_info,
1254}, {
David Hollis933a27d2006-07-29 10:12:50 -04001255 // Linksys USB1000
1256 USB_DEVICE (0x1737, 0x0039),
1257 .driver_info = (unsigned long) &ax88178_info,
YOSHIFUJI Hideaki / 吉藤英明b29cf312007-01-26 22:57:38 +09001258}, {
1259 // IO-DATA ETG-US2
1260 USB_DEVICE (0x04bb, 0x0930),
1261 .driver_info = (unsigned long) &ax88178_info,
David Hollis2ed22bc2007-05-23 07:33:17 -04001262}, {
1263 // Belkin F5D5055
1264 USB_DEVICE(0x050d, 0x5055),
1265 .driver_info = (unsigned long) &ax88178_info,
Aurelien Nephtali3d60efb52008-05-14 17:04:13 -07001266}, {
1267 // Apple USB Ethernet Adapter
1268 USB_DEVICE(0x05ac, 0x1402),
1269 .driver_info = (unsigned long) &ax88772_info,
Jason Cooperccf95402008-11-11 13:02:53 -05001270}, {
1271 // Cables-to-Go USB Ethernet Adapter
1272 USB_DEVICE(0x0b95, 0x772a),
1273 .driver_info = (unsigned long) &ax88772_info,
Greg Kroah-Hartmanfef7cc02009-02-24 23:52:24 -08001274}, {
1275 // ABOCOM for pci
1276 USB_DEVICE(0x14ea, 0xab11),
1277 .driver_info = (unsigned long) &ax88178_info,
1278}, {
1279 // ASIX 88772a
1280 USB_DEVICE(0x0db0, 0xa877),
1281 .driver_info = (unsigned long) &ax88772_info,
Aurelien Jacobse8303a32011-12-16 10:49:22 +00001282}, {
1283 // Asus USB Ethernet Adapter
1284 USB_DEVICE (0x0b95, 0x7e2b),
Robert Fossd9fe64e2016-08-29 09:32:15 -04001285 .driver_info = (unsigned long)&ax88772b_info,
Christian Riesch16626b02012-07-13 05:26:31 +00001286}, {
1287 /* ASIX 88172a demo board */
1288 USB_DEVICE(0x0b95, 0x172a),
1289 .driver_info = (unsigned long) &ax88172a_info,
Glen Turner45af3fb2013-02-27 04:32:36 +00001290}, {
1291 /*
1292 * USBLINK HG20F9 "USB 2.0 LAN"
1293 * Appears to have gazumped Linksys's manufacturer ID but
1294 * doesn't (yet) conflict with any known Linksys product.
1295 */
1296 USB_DEVICE(0x066b, 0x20f9),
1297 .driver_info = (unsigned long) &hg20f9_info,
David Brownell2e55cc72005-08-31 09:53:10 -07001298},
1299 { }, // END
1300};
1301MODULE_DEVICE_TABLE(usb, products);
1302
1303static struct usb_driver asix_driver = {
Grant Grundler83e1b912011-10-04 09:55:18 +00001304 .name = DRIVER_NAME,
David Brownell2e55cc72005-08-31 09:53:10 -07001305 .id_table = products,
1306 .probe = usbnet_probe,
Robert Fossd9fe64e2016-08-29 09:32:15 -04001307 .suspend = asix_suspend,
1308 .resume = asix_resume,
David Brownell2e55cc72005-08-31 09:53:10 -07001309 .disconnect = usbnet_disconnect,
Oliver Neukuma11a6542007-08-03 13:52:19 +02001310 .supports_autosuspend = 1,
Sarah Sharpe1f12eb2012-04-23 10:08:51 -07001311 .disable_hub_initiated_lpm = 1,
David Brownell2e55cc72005-08-31 09:53:10 -07001312};
1313
Greg Kroah-Hartmand632eb12011-11-18 09:44:20 -08001314module_usb_driver(asix_driver);
David Brownell2e55cc72005-08-31 09:53:10 -07001315
1316MODULE_AUTHOR("David Hollis");
Grant Grundler4ad14382011-10-04 09:55:16 +00001317MODULE_VERSION(DRIVER_VERSION);
David Brownell2e55cc72005-08-31 09:53:10 -07001318MODULE_DESCRIPTION("ASIX AX8817X based USB 2.0 Ethernet Devices");
1319MODULE_LICENSE("GPL");
1320