blob: 6d95cacd5284dec9642d41d2e4dfce146eb65189 [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
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23// #define DEBUG // error path messages, extra info
24// #define VERBOSE // more; success messages
25
David Brownell2e55cc72005-08-31 09:53:10 -070026#include <linux/module.h>
27#include <linux/kmod.h>
David Brownell2e55cc72005-08-31 09:53:10 -070028#include <linux/init.h>
29#include <linux/netdevice.h>
30#include <linux/etherdevice.h>
31#include <linux/ethtool.h>
32#include <linux/workqueue.h>
33#include <linux/mii.h>
34#include <linux/usb.h>
35#include <linux/crc32.h>
36
37#include "usbnet.h"
38
David Hollis933a27d2006-07-29 10:12:50 -040039#define DRIVER_VERSION "14-Jun-2006"
40static const char driver_name [] = "asix";
41
David Brownell2e55cc72005-08-31 09:53:10 -070042/* ASIX AX8817X based USB 2.0 Ethernet Devices */
43
44#define AX_CMD_SET_SW_MII 0x06
45#define AX_CMD_READ_MII_REG 0x07
46#define AX_CMD_WRITE_MII_REG 0x08
47#define AX_CMD_SET_HW_MII 0x0a
48#define AX_CMD_READ_EEPROM 0x0b
49#define AX_CMD_WRITE_EEPROM 0x0c
50#define AX_CMD_WRITE_ENABLE 0x0d
51#define AX_CMD_WRITE_DISABLE 0x0e
David Hollis933a27d2006-07-29 10:12:50 -040052#define AX_CMD_READ_RX_CTL 0x0f
David Brownell2e55cc72005-08-31 09:53:10 -070053#define AX_CMD_WRITE_RX_CTL 0x10
54#define AX_CMD_READ_IPG012 0x11
55#define AX_CMD_WRITE_IPG0 0x12
56#define AX_CMD_WRITE_IPG1 0x13
David Hollis933a27d2006-07-29 10:12:50 -040057#define AX_CMD_READ_NODE_ID 0x13
David Brownell2e55cc72005-08-31 09:53:10 -070058#define AX_CMD_WRITE_IPG2 0x14
59#define AX_CMD_WRITE_MULTI_FILTER 0x16
David Hollis933a27d2006-07-29 10:12:50 -040060#define AX88172_CMD_READ_NODE_ID 0x17
David Brownell2e55cc72005-08-31 09:53:10 -070061#define AX_CMD_READ_PHY_ID 0x19
62#define AX_CMD_READ_MEDIUM_STATUS 0x1a
63#define AX_CMD_WRITE_MEDIUM_MODE 0x1b
64#define AX_CMD_READ_MONITOR_MODE 0x1c
65#define AX_CMD_WRITE_MONITOR_MODE 0x1d
David Hollis933a27d2006-07-29 10:12:50 -040066#define AX_CMD_READ_GPIOS 0x1e
David Brownell2e55cc72005-08-31 09:53:10 -070067#define AX_CMD_WRITE_GPIOS 0x1f
68#define AX_CMD_SW_RESET 0x20
69#define AX_CMD_SW_PHY_STATUS 0x21
70#define AX_CMD_SW_PHY_SELECT 0x22
David Brownell2e55cc72005-08-31 09:53:10 -070071
72#define AX_MONITOR_MODE 0x01
73#define AX_MONITOR_LINK 0x02
74#define AX_MONITOR_MAGIC 0x04
75#define AX_MONITOR_HSFS 0x10
76
77/* AX88172 Medium Status Register values */
David Hollis933a27d2006-07-29 10:12:50 -040078#define AX88172_MEDIUM_FD 0x02
79#define AX88172_MEDIUM_TX 0x04
80#define AX88172_MEDIUM_FC 0x10
81#define AX88172_MEDIUM_DEFAULT \
82 ( AX88172_MEDIUM_FD | AX88172_MEDIUM_TX | AX88172_MEDIUM_FC )
David Brownell2e55cc72005-08-31 09:53:10 -070083
84#define AX_MCAST_FILTER_SIZE 8
85#define AX_MAX_MCAST 64
86
David Brownell2e55cc72005-08-31 09:53:10 -070087#define AX_SWRESET_CLEAR 0x00
88#define AX_SWRESET_RR 0x01
89#define AX_SWRESET_RT 0x02
90#define AX_SWRESET_PRTE 0x04
91#define AX_SWRESET_PRL 0x08
92#define AX_SWRESET_BZ 0x10
93#define AX_SWRESET_IPRL 0x20
94#define AX_SWRESET_IPPD 0x40
95
96#define AX88772_IPG0_DEFAULT 0x15
97#define AX88772_IPG1_DEFAULT 0x0c
98#define AX88772_IPG2_DEFAULT 0x12
99
David Hollis933a27d2006-07-29 10:12:50 -0400100/* AX88772 & AX88178 Medium Mode Register */
101#define AX_MEDIUM_PF 0x0080
102#define AX_MEDIUM_JFE 0x0040
103#define AX_MEDIUM_TFC 0x0020
104#define AX_MEDIUM_RFC 0x0010
105#define AX_MEDIUM_ENCK 0x0008
106#define AX_MEDIUM_AC 0x0004
107#define AX_MEDIUM_FD 0x0002
108#define AX_MEDIUM_GM 0x0001
109#define AX_MEDIUM_SM 0x1000
110#define AX_MEDIUM_SBP 0x0800
111#define AX_MEDIUM_PS 0x0200
112#define AX_MEDIUM_RE 0x0100
David Brownell2e55cc72005-08-31 09:53:10 -0700113
David Hollis933a27d2006-07-29 10:12:50 -0400114#define AX88178_MEDIUM_DEFAULT \
115 (AX_MEDIUM_PS | AX_MEDIUM_FD | AX_MEDIUM_AC | \
116 AX_MEDIUM_RFC | AX_MEDIUM_TFC | AX_MEDIUM_JFE | \
117 AX_MEDIUM_RE )
118
119#define AX88772_MEDIUM_DEFAULT \
120 (AX_MEDIUM_FD | AX_MEDIUM_RFC | \
121 AX_MEDIUM_TFC | AX_MEDIUM_PS | \
122 AX_MEDIUM_AC | AX_MEDIUM_RE )
123
124/* AX88772 & AX88178 RX_CTL values */
125#define AX_RX_CTL_SO 0x0080
126#define AX_RX_CTL_AP 0x0020
127#define AX_RX_CTL_AM 0x0010
128#define AX_RX_CTL_AB 0x0008
129#define AX_RX_CTL_SEP 0x0004
130#define AX_RX_CTL_AMALL 0x0002
131#define AX_RX_CTL_PRO 0x0001
132#define AX_RX_CTL_MFB_2048 0x0000
133#define AX_RX_CTL_MFB_4096 0x0100
134#define AX_RX_CTL_MFB_8192 0x0200
135#define AX_RX_CTL_MFB_16384 0x0300
136
137#define AX_DEFAULT_RX_CTL \
138 (AX_RX_CTL_SO | AX_RX_CTL_AB )
139
140/* GPIO 0 .. 2 toggles */
141#define AX_GPIO_GPO0EN 0x01 /* GPIO0 Output enable */
142#define AX_GPIO_GPO_0 0x02 /* GPIO0 Output value */
143#define AX_GPIO_GPO1EN 0x04 /* GPIO1 Output enable */
144#define AX_GPIO_GPO_1 0x08 /* GPIO1 Output value */
145#define AX_GPIO_GPO2EN 0x10 /* GPIO2 Output enable */
146#define AX_GPIO_GPO_2 0x20 /* GPIO2 Output value */
147#define AX_GPIO_RESERVED 0x40 /* Reserved */
148#define AX_GPIO_RSE 0x80 /* Reload serial EEPROM */
149
150#define AX_EEPROM_MAGIC 0xdeadbeef
151#define AX88172_EEPROM_LEN 0x40
152#define AX88772_EEPROM_LEN 0xff
153
154#define PHY_MODE_MARVELL 0x0000
155#define MII_MARVELL_LED_CTRL 0x0018
156#define MII_MARVELL_STATUS 0x001b
157#define MII_MARVELL_CTRL 0x0014
158
159#define MARVELL_LED_MANUAL 0x0019
160
161#define MARVELL_STATUS_HWCFG 0x0004
162
163#define MARVELL_CTRL_TXDELAY 0x0002
164#define MARVELL_CTRL_RXDELAY 0x0080
David Brownell2e55cc72005-08-31 09:53:10 -0700165
166/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
David Hollis48b1be62006-03-28 20:15:42 -0500167struct asix_data {
David Brownell2e55cc72005-08-31 09:53:10 -0700168 u8 multi_filter[AX_MCAST_FILTER_SIZE];
David Hollis933a27d2006-07-29 10:12:50 -0400169 u8 phymode;
170 u8 ledmode;
171 u8 eeprom_len;
David Brownell2e55cc72005-08-31 09:53:10 -0700172};
173
174struct ax88172_int_data {
175 u16 res1;
176 u8 link;
177 u16 res2;
178 u8 status;
179 u16 res3;
180} __attribute__ ((packed));
181
David Hollis48b1be62006-03-28 20:15:42 -0500182static int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
David Brownell2e55cc72005-08-31 09:53:10 -0700183 u16 size, void *data)
184{
David Hollis933a27d2006-07-29 10:12:50 -0400185 devdbg(dev,"asix_read_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d",
186 cmd, value, index, size);
David Brownell2e55cc72005-08-31 09:53:10 -0700187 return usb_control_msg(
188 dev->udev,
189 usb_rcvctrlpipe(dev->udev, 0),
190 cmd,
191 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
192 value,
193 index,
194 data,
195 size,
196 USB_CTRL_GET_TIMEOUT);
197}
198
David Hollis48b1be62006-03-28 20:15:42 -0500199static int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
David Brownell2e55cc72005-08-31 09:53:10 -0700200 u16 size, void *data)
201{
David Hollis933a27d2006-07-29 10:12:50 -0400202 devdbg(dev,"asix_write_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d",
203 cmd, value, index, size);
David Brownell2e55cc72005-08-31 09:53:10 -0700204 return usb_control_msg(
205 dev->udev,
206 usb_sndctrlpipe(dev->udev, 0),
207 cmd,
208 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
209 value,
210 index,
211 data,
212 size,
213 USB_CTRL_SET_TIMEOUT);
214}
215
David Howells7d12e782006-10-05 14:55:46 +0100216static void asix_async_cmd_callback(struct urb *urb)
David Brownell2e55cc72005-08-31 09:53:10 -0700217{
218 struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
219
220 if (urb->status < 0)
David Hollis48b1be62006-03-28 20:15:42 -0500221 printk(KERN_DEBUG "asix_async_cmd_callback() failed with %d",
David Brownell2e55cc72005-08-31 09:53:10 -0700222 urb->status);
223
224 kfree(req);
225 usb_free_urb(urb);
226}
227
David Hollis933a27d2006-07-29 10:12:50 -0400228static void
229asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
230 u16 size, void *data)
David Hollis48b1be62006-03-28 20:15:42 -0500231{
David Hollis933a27d2006-07-29 10:12:50 -0400232 struct usb_ctrlrequest *req;
233 int status;
234 struct urb *urb;
David Hollis48b1be62006-03-28 20:15:42 -0500235
David Hollis933a27d2006-07-29 10:12:50 -0400236 devdbg(dev,"asix_write_cmd_async() cmd=0x%02x value=0x%04x index=0x%04x size=%d",
237 cmd, value, index, size);
238 if ((urb = usb_alloc_urb(0, GFP_ATOMIC)) == NULL) {
239 deverr(dev, "Error allocating URB in write_cmd_async!");
240 return;
David Hollis48b1be62006-03-28 20:15:42 -0500241 }
David Hollis933a27d2006-07-29 10:12:50 -0400242
243 if ((req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC)) == NULL) {
244 deverr(dev, "Failed to allocate memory for control request");
245 usb_free_urb(urb);
246 return;
247 }
248
249 req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
250 req->bRequest = cmd;
Oliver Neukum9aa742e2006-11-23 12:45:31 +0100251 req->wValue = cpu_to_le16(value);
252 req->wIndex = cpu_to_le16(index);
253 req->wLength = cpu_to_le16(size);
David Hollis933a27d2006-07-29 10:12:50 -0400254
255 usb_fill_control_urb(urb, dev->udev,
256 usb_sndctrlpipe(dev->udev, 0),
257 (void *)req, data, size,
258 asix_async_cmd_callback, req);
259
260 if((status = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
261 deverr(dev, "Error submitting the control message: status=%d",
262 status);
263 kfree(req);
264 usb_free_urb(urb);
265 }
David Hollis48b1be62006-03-28 20:15:42 -0500266}
267
David Hollis933a27d2006-07-29 10:12:50 -0400268static int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
David Hollis48b1be62006-03-28 20:15:42 -0500269{
David Hollis933a27d2006-07-29 10:12:50 -0400270 u8 *head;
271 u32 header;
272 char *packet;
273 struct sk_buff *ax_skb;
274 u16 size;
David Hollis48b1be62006-03-28 20:15:42 -0500275
David Hollis933a27d2006-07-29 10:12:50 -0400276 head = (u8 *) skb->data;
277 memcpy(&header, head, sizeof(header));
278 le32_to_cpus(&header);
279 packet = head + sizeof(header);
David Hollis48b1be62006-03-28 20:15:42 -0500280
David Hollis933a27d2006-07-29 10:12:50 -0400281 skb_pull(skb, 4);
282
283 while (skb->len > 0) {
284 if ((short)(header & 0x0000ffff) !=
285 ~((short)((header & 0xffff0000) >> 16))) {
286 deverr(dev,"asix_rx_fixup() Bad Header Length");
287 }
288 /* get the packet length */
289 size = (u16) (header & 0x0000ffff);
290
291 if ((skb->len) - ((size + 1) & 0xfffe) == 0)
292 return 2;
293 if (size > ETH_FRAME_LEN) {
294 deverr(dev,"asix_rx_fixup() Bad RX Length %d", size);
295 return 0;
296 }
297 ax_skb = skb_clone(skb, GFP_ATOMIC);
298 if (ax_skb) {
299 ax_skb->len = size;
300 ax_skb->data = packet;
Arnaldo Carvalho de Melo27a884d2007-04-19 20:29:13 -0700301 skb_set_tail_pointer(ax_skb, size);
David Hollis933a27d2006-07-29 10:12:50 -0400302 usbnet_skb_return(dev, ax_skb);
303 } else {
304 return 0;
305 }
306
307 skb_pull(skb, (size + 1) & 0xfffe);
308
309 if (skb->len == 0)
310 break;
311
312 head = (u8 *) skb->data;
313 memcpy(&header, head, sizeof(header));
314 le32_to_cpus(&header);
315 packet = head + sizeof(header);
316 skb_pull(skb, 4);
317 }
318
319 if (skb->len < 0) {
320 deverr(dev,"asix_rx_fixup() Bad SKB Length %d", skb->len);
321 return 0;
322 }
323 return 1;
David Hollis48b1be62006-03-28 20:15:42 -0500324}
325
David Hollis933a27d2006-07-29 10:12:50 -0400326static struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
327 gfp_t flags)
David Hollis48b1be62006-03-28 20:15:42 -0500328{
David Hollis933a27d2006-07-29 10:12:50 -0400329 int padlen;
330 int headroom = skb_headroom(skb);
331 int tailroom = skb_tailroom(skb);
332 u32 packet_len;
333 u32 padbytes = 0xffff0000;
David Hollis48b1be62006-03-28 20:15:42 -0500334
David Hollis933a27d2006-07-29 10:12:50 -0400335 padlen = ((skb->len + 4) % 512) ? 0 : 4;
David Hollis48b1be62006-03-28 20:15:42 -0500336
David Hollis933a27d2006-07-29 10:12:50 -0400337 if ((!skb_cloned(skb))
338 && ((headroom + tailroom) >= (4 + padlen))) {
339 if ((headroom < 4) || (tailroom < padlen)) {
340 skb->data = memmove(skb->head + 4, skb->data, skb->len);
Arnaldo Carvalho de Melo27a884d2007-04-19 20:29:13 -0700341 skb_set_tail_pointer(skb, skb->len);
David Hollis933a27d2006-07-29 10:12:50 -0400342 }
343 } else {
344 struct sk_buff *skb2;
345 skb2 = skb_copy_expand(skb, 4, padlen, flags);
346 dev_kfree_skb_any(skb);
347 skb = skb2;
348 if (!skb)
349 return NULL;
350 }
351
352 skb_push(skb, 4);
353 packet_len = (((skb->len - 4) ^ 0x0000ffff) << 16) + (skb->len - 4);
David Hollis57e4f042007-02-05 12:03:03 -0500354 cpu_to_le32s(&packet_len);
Arnaldo Carvalho de Melo27d7ff42007-03-31 11:55:19 -0300355 skb_copy_to_linear_data(skb, &packet_len, sizeof(packet_len));
David Hollis933a27d2006-07-29 10:12:50 -0400356
357 if ((skb->len % 512) == 0) {
David Hollis57e4f042007-02-05 12:03:03 -0500358 cpu_to_le32s(&padbytes);
Arnaldo Carvalho de Melo27a884d2007-04-19 20:29:13 -0700359 memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes));
David Hollis933a27d2006-07-29 10:12:50 -0400360 skb_put(skb, sizeof(padbytes));
361 }
362 return skb;
David Hollis48b1be62006-03-28 20:15:42 -0500363}
364
365static void asix_status(struct usbnet *dev, struct urb *urb)
David Brownell2e55cc72005-08-31 09:53:10 -0700366{
367 struct ax88172_int_data *event;
368 int link;
369
370 if (urb->actual_length < 8)
371 return;
372
373 event = urb->transfer_buffer;
374 link = event->link & 0x01;
375 if (netif_carrier_ok(dev->net) != link) {
376 if (link) {
377 netif_carrier_on(dev->net);
378 usbnet_defer_kevent (dev, EVENT_LINK_RESET );
379 } else
380 netif_carrier_off(dev->net);
David Hollis48b1be62006-03-28 20:15:42 -0500381 devdbg(dev, "Link Status is: %d", link);
David Brownell2e55cc72005-08-31 09:53:10 -0700382 }
383}
384
David Hollis933a27d2006-07-29 10:12:50 -0400385static inline int asix_set_sw_mii(struct usbnet *dev)
David Brownell2e55cc72005-08-31 09:53:10 -0700386{
David Hollis933a27d2006-07-29 10:12:50 -0400387 int ret;
388 ret = asix_write_cmd(dev, AX_CMD_SET_SW_MII, 0x0000, 0, 0, NULL);
389 if (ret < 0)
390 deverr(dev, "Failed to enable software MII access");
391 return ret;
David Brownell2e55cc72005-08-31 09:53:10 -0700392}
393
David Hollis933a27d2006-07-29 10:12:50 -0400394static inline int asix_set_hw_mii(struct usbnet *dev)
395{
396 int ret;
397 ret = asix_write_cmd(dev, AX_CMD_SET_HW_MII, 0x0000, 0, 0, NULL);
398 if (ret < 0)
399 deverr(dev, "Failed to enable hardware MII access");
400 return ret;
401}
402
403static inline int asix_get_phy_addr(struct usbnet *dev)
404{
405 int ret = 0;
406 void *buf;
407
408 devdbg(dev, "asix_get_phy_addr()");
409
410 buf = kmalloc(2, GFP_KERNEL);
411 if (!buf)
412 goto out1;
413
414 if ((ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID,
415 0, 0, 2, buf)) < 2) {
416 deverr(dev, "Error reading PHYID register: %02x", ret);
417 goto out2;
418 }
419 devdbg(dev, "asix_get_phy_addr() returning 0x%04x", *((u16 *)buf));
420 ret = *((u8 *)buf + 1);
421out2:
422 kfree(buf);
423out1:
424 return ret;
425}
426
427static int asix_sw_reset(struct usbnet *dev, u8 flags)
428{
429 int ret;
430
431 ret = asix_write_cmd(dev, AX_CMD_SW_RESET, flags, 0, 0, NULL);
432 if (ret < 0)
433 deverr(dev,"Failed to send software reset: %02x", ret);
434
435 return ret;
436}
437
438static u16 asix_read_rx_ctl(struct usbnet *dev)
439{
440 u16 ret = 0;
441 void *buf;
442
443 buf = kmalloc(2, GFP_KERNEL);
444 if (!buf)
445 goto out1;
446
447 if ((ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL,
448 0, 0, 2, buf)) < 2) {
449 deverr(dev, "Error reading RX_CTL register: %02x", ret);
450 goto out2;
451 }
452 ret = le16_to_cpu(*((u16 *)buf));
453out2:
454 kfree(buf);
455out1:
456 return ret;
457}
458
459static int asix_write_rx_ctl(struct usbnet *dev, u16 mode)
460{
461 int ret;
462
463 devdbg(dev,"asix_write_rx_ctl() - mode = 0x%04x", mode);
464 ret = asix_write_cmd(dev, AX_CMD_WRITE_RX_CTL, mode, 0, 0, NULL);
465 if (ret < 0)
466 deverr(dev, "Failed to write RX_CTL mode to 0x%04x: %02x",
467 mode, ret);
468
469 return ret;
470}
471
472static u16 asix_read_medium_status(struct usbnet *dev)
473{
474 u16 ret = 0;
475 void *buf;
476
477 buf = kmalloc(2, GFP_KERNEL);
478 if (!buf)
479 goto out1;
480
481 if ((ret = asix_read_cmd(dev, AX_CMD_READ_MEDIUM_STATUS,
482 0, 0, 2, buf)) < 2) {
483 deverr(dev, "Error reading Medium Status register: %02x", ret);
484 goto out2;
485 }
486 ret = le16_to_cpu(*((u16 *)buf));
487out2:
488 kfree(buf);
489out1:
490 return ret;
491}
492
493static int asix_write_medium_mode(struct usbnet *dev, u16 mode)
494{
495 int ret;
496
497 devdbg(dev,"asix_write_medium_mode() - mode = 0x%04x", mode);
498 ret = asix_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL);
499 if (ret < 0)
500 deverr(dev, "Failed to write Medium Mode mode to 0x%04x: %02x",
501 mode, ret);
502
503 return ret;
504}
505
506static int asix_write_gpio(struct usbnet *dev, u16 value, int sleep)
507{
508 int ret;
509
510 devdbg(dev,"asix_write_gpio() - value = 0x%04x", value);
511 ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, value, 0, 0, NULL);
512 if (ret < 0)
513 deverr(dev, "Failed to write GPIO value 0x%04x: %02x",
514 value, ret);
515
516 if (sleep)
517 msleep(sleep);
518
519 return ret;
520}
521
522/*
523 * AX88772 & AX88178 have a 16-bit RX_CTL value
524 */
David Hollis48b1be62006-03-28 20:15:42 -0500525static void asix_set_multicast(struct net_device *net)
David Brownell2e55cc72005-08-31 09:53:10 -0700526{
527 struct usbnet *dev = netdev_priv(net);
David Hollis48b1be62006-03-28 20:15:42 -0500528 struct asix_data *data = (struct asix_data *)&dev->data;
David Hollis933a27d2006-07-29 10:12:50 -0400529 u16 rx_ctl = AX_DEFAULT_RX_CTL;
David Brownell2e55cc72005-08-31 09:53:10 -0700530
531 if (net->flags & IFF_PROMISC) {
David Hollis933a27d2006-07-29 10:12:50 -0400532 rx_ctl |= AX_RX_CTL_PRO;
David Brownell2e55cc72005-08-31 09:53:10 -0700533 } else if (net->flags & IFF_ALLMULTI
534 || net->mc_count > AX_MAX_MCAST) {
David Hollis933a27d2006-07-29 10:12:50 -0400535 rx_ctl |= AX_RX_CTL_AMALL;
David Brownell2e55cc72005-08-31 09:53:10 -0700536 } else if (net->mc_count == 0) {
537 /* just broadcast and directed */
538 } else {
539 /* We use the 20 byte dev->data
540 * for our 8 byte filter buffer
541 * to avoid allocating memory that
542 * is tricky to free later */
543 struct dev_mc_list *mc_list = net->mc_list;
544 u32 crc_bits;
545 int i;
546
547 memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE);
548
549 /* Build the multicast hash filter. */
550 for (i = 0; i < net->mc_count; i++) {
551 crc_bits =
552 ether_crc(ETH_ALEN,
553 mc_list->dmi_addr) >> 26;
554 data->multi_filter[crc_bits >> 3] |=
555 1 << (crc_bits & 7);
556 mc_list = mc_list->next;
557 }
558
David Hollis48b1be62006-03-28 20:15:42 -0500559 asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0,
David Brownell2e55cc72005-08-31 09:53:10 -0700560 AX_MCAST_FILTER_SIZE, data->multi_filter);
561
David Hollis933a27d2006-07-29 10:12:50 -0400562 rx_ctl |= AX_RX_CTL_AM;
David Brownell2e55cc72005-08-31 09:53:10 -0700563 }
564
David Hollis48b1be62006-03-28 20:15:42 -0500565 asix_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL);
David Brownell2e55cc72005-08-31 09:53:10 -0700566}
567
David Hollis48b1be62006-03-28 20:15:42 -0500568static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc)
David Brownell2e55cc72005-08-31 09:53:10 -0700569{
570 struct usbnet *dev = netdev_priv(netdev);
571 u16 res;
David Brownell2e55cc72005-08-31 09:53:10 -0700572
Arnd Bergmanna9fc6332006-10-09 00:08:02 +0200573 mutex_lock(&dev->phy_mutex);
David Hollis48b1be62006-03-28 20:15:42 -0500574 asix_set_sw_mii(dev);
575 asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id,
David Brownell2e55cc72005-08-31 09:53:10 -0700576 (__u16)loc, 2, (u16 *)&res);
David Hollis48b1be62006-03-28 20:15:42 -0500577 asix_set_hw_mii(dev);
Arnd Bergmanna9fc6332006-10-09 00:08:02 +0200578 mutex_unlock(&dev->phy_mutex);
David Brownell2e55cc72005-08-31 09:53:10 -0700579
David Hollis933a27d2006-07-29 10:12:50 -0400580 devdbg(dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x", phy_id, loc, le16_to_cpu(res & 0xffff));
David Brownell2e55cc72005-08-31 09:53:10 -0700581
David Hollis933a27d2006-07-29 10:12:50 -0400582 return le16_to_cpu(res & 0xffff);
David Brownell2e55cc72005-08-31 09:53:10 -0700583}
584
585static void
David Hollis48b1be62006-03-28 20:15:42 -0500586asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
David Brownell2e55cc72005-08-31 09:53:10 -0700587{
588 struct usbnet *dev = netdev_priv(netdev);
David Hollis933a27d2006-07-29 10:12:50 -0400589 u16 res = cpu_to_le16(val);
David Brownell2e55cc72005-08-31 09:53:10 -0700590
David Hollis933a27d2006-07-29 10:12:50 -0400591 devdbg(dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x", phy_id, loc, val);
Arnd Bergmanna9fc6332006-10-09 00:08:02 +0200592 mutex_lock(&dev->phy_mutex);
David Hollis48b1be62006-03-28 20:15:42 -0500593 asix_set_sw_mii(dev);
594 asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id,
David Brownell2e55cc72005-08-31 09:53:10 -0700595 (__u16)loc, 2, (u16 *)&res);
David Hollis48b1be62006-03-28 20:15:42 -0500596 asix_set_hw_mii(dev);
Arnd Bergmanna9fc6332006-10-09 00:08:02 +0200597 mutex_unlock(&dev->phy_mutex);
David Brownell2e55cc72005-08-31 09:53:10 -0700598}
599
David Hollis933a27d2006-07-29 10:12:50 -0400600/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */
601static u32 asix_get_phyid(struct usbnet *dev)
David Brownell2e55cc72005-08-31 09:53:10 -0700602{
David Hollis933a27d2006-07-29 10:12:50 -0400603 int phy_reg;
604 u32 phy_id;
David Brownell2e55cc72005-08-31 09:53:10 -0700605
David Hollis933a27d2006-07-29 10:12:50 -0400606 phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID1);
607 if (phy_reg < 0)
608 return 0;
David Brownell2e55cc72005-08-31 09:53:10 -0700609
David Hollis933a27d2006-07-29 10:12:50 -0400610 phy_id = (phy_reg & 0xffff) << 16;
David Brownell2e55cc72005-08-31 09:53:10 -0700611
David Hollis933a27d2006-07-29 10:12:50 -0400612 phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID2);
613 if (phy_reg < 0)
614 return 0;
615
616 phy_id |= (phy_reg & 0xffff);
617
618 return phy_id;
David Brownell2e55cc72005-08-31 09:53:10 -0700619}
620
621static void
David Hollis48b1be62006-03-28 20:15:42 -0500622asix_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
David Brownell2e55cc72005-08-31 09:53:10 -0700623{
624 struct usbnet *dev = netdev_priv(net);
625 u8 opt;
626
David Hollis48b1be62006-03-28 20:15:42 -0500627 if (asix_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, &opt) < 0) {
David Brownell2e55cc72005-08-31 09:53:10 -0700628 wolinfo->supported = 0;
629 wolinfo->wolopts = 0;
630 return;
631 }
632 wolinfo->supported = WAKE_PHY | WAKE_MAGIC;
633 wolinfo->wolopts = 0;
634 if (opt & AX_MONITOR_MODE) {
635 if (opt & AX_MONITOR_LINK)
636 wolinfo->wolopts |= WAKE_PHY;
637 if (opt & AX_MONITOR_MAGIC)
638 wolinfo->wolopts |= WAKE_MAGIC;
639 }
640}
641
642static int
David Hollis48b1be62006-03-28 20:15:42 -0500643asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
David Brownell2e55cc72005-08-31 09:53:10 -0700644{
645 struct usbnet *dev = netdev_priv(net);
646 u8 opt = 0;
647 u8 buf[1];
648
649 if (wolinfo->wolopts & WAKE_PHY)
650 opt |= AX_MONITOR_LINK;
651 if (wolinfo->wolopts & WAKE_MAGIC)
652 opt |= AX_MONITOR_MAGIC;
653 if (opt != 0)
654 opt |= AX_MONITOR_MODE;
655
David Hollis48b1be62006-03-28 20:15:42 -0500656 if (asix_write_cmd(dev, AX_CMD_WRITE_MONITOR_MODE,
David Brownell2e55cc72005-08-31 09:53:10 -0700657 opt, 0, 0, &buf) < 0)
658 return -EINVAL;
659
660 return 0;
661}
662
David Hollis48b1be62006-03-28 20:15:42 -0500663static int asix_get_eeprom_len(struct net_device *net)
David Brownell2e55cc72005-08-31 09:53:10 -0700664{
David Hollis933a27d2006-07-29 10:12:50 -0400665 struct usbnet *dev = netdev_priv(net);
666 struct asix_data *data = (struct asix_data *)&dev->data;
667
668 return data->eeprom_len;
David Brownell2e55cc72005-08-31 09:53:10 -0700669}
670
David Hollis48b1be62006-03-28 20:15:42 -0500671static int asix_get_eeprom(struct net_device *net,
David Brownell2e55cc72005-08-31 09:53:10 -0700672 struct ethtool_eeprom *eeprom, u8 *data)
673{
674 struct usbnet *dev = netdev_priv(net);
675 u16 *ebuf = (u16 *)data;
676 int i;
677
678 /* Crude hack to ensure that we don't overwrite memory
679 * if an odd length is supplied
680 */
681 if (eeprom->len % 2)
682 return -EINVAL;
683
684 eeprom->magic = AX_EEPROM_MAGIC;
685
686 /* ax8817x returns 2 bytes from eeprom on read */
687 for (i=0; i < eeprom->len / 2; i++) {
David Hollis48b1be62006-03-28 20:15:42 -0500688 if (asix_read_cmd(dev, AX_CMD_READ_EEPROM,
David Brownell2e55cc72005-08-31 09:53:10 -0700689 eeprom->offset + i, 0, 2, &ebuf[i]) < 0)
690 return -EINVAL;
691 }
692 return 0;
693}
694
David Hollis48b1be62006-03-28 20:15:42 -0500695static void asix_get_drvinfo (struct net_device *net,
David Brownell2e55cc72005-08-31 09:53:10 -0700696 struct ethtool_drvinfo *info)
697{
David Hollis933a27d2006-07-29 10:12:50 -0400698 struct usbnet *dev = netdev_priv(net);
699 struct asix_data *data = (struct asix_data *)&dev->data;
700
David Brownell2e55cc72005-08-31 09:53:10 -0700701 /* Inherit standard device info */
702 usbnet_get_drvinfo(net, info);
David Hollis933a27d2006-07-29 10:12:50 -0400703 strncpy (info->driver, driver_name, sizeof info->driver);
704 strncpy (info->version, DRIVER_VERSION, sizeof info->version);
705 info->eedump_len = data->eeprom_len;
David Brownell2e55cc72005-08-31 09:53:10 -0700706}
707
David Hollis933a27d2006-07-29 10:12:50 -0400708static u32 asix_get_link(struct net_device *net)
709{
710 struct usbnet *dev = netdev_priv(net);
711
712 return mii_link_ok(&dev->mii);
713}
714
715static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd)
716{
717 struct usbnet *dev = netdev_priv(net);
718
719 return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
David Brownell2e55cc72005-08-31 09:53:10 -0700720}
721
722/* We need to override some ethtool_ops so we require our
723 own structure so we don't interfere with other usbnet
724 devices that may be connected at the same time. */
David Hollis48b1be62006-03-28 20:15:42 -0500725static struct ethtool_ops ax88172_ethtool_ops = {
726 .get_drvinfo = asix_get_drvinfo,
David Hollis933a27d2006-07-29 10:12:50 -0400727 .get_link = asix_get_link,
David Brownell2e55cc72005-08-31 09:53:10 -0700728 .get_msglevel = usbnet_get_msglevel,
729 .set_msglevel = usbnet_set_msglevel,
David Hollis48b1be62006-03-28 20:15:42 -0500730 .get_wol = asix_get_wol,
731 .set_wol = asix_set_wol,
732 .get_eeprom_len = asix_get_eeprom_len,
733 .get_eeprom = asix_get_eeprom,
Arnd Bergmannc41286f2006-10-09 00:08:01 +0200734 .get_settings = usbnet_get_settings,
735 .set_settings = usbnet_set_settings,
736 .nway_reset = usbnet_nway_reset,
David Brownell2e55cc72005-08-31 09:53:10 -0700737};
738
David Hollis933a27d2006-07-29 10:12:50 -0400739static void ax88172_set_multicast(struct net_device *net)
David Brownell2e55cc72005-08-31 09:53:10 -0700740{
741 struct usbnet *dev = netdev_priv(net);
David Hollis933a27d2006-07-29 10:12:50 -0400742 struct asix_data *data = (struct asix_data *)&dev->data;
743 u8 rx_ctl = 0x8c;
David Brownell2e55cc72005-08-31 09:53:10 -0700744
David Hollis933a27d2006-07-29 10:12:50 -0400745 if (net->flags & IFF_PROMISC) {
746 rx_ctl |= 0x01;
747 } else if (net->flags & IFF_ALLMULTI
748 || net->mc_count > AX_MAX_MCAST) {
749 rx_ctl |= 0x02;
750 } else if (net->mc_count == 0) {
751 /* just broadcast and directed */
752 } else {
753 /* We use the 20 byte dev->data
754 * for our 8 byte filter buffer
755 * to avoid allocating memory that
756 * is tricky to free later */
757 struct dev_mc_list *mc_list = net->mc_list;
758 u32 crc_bits;
759 int i;
760
761 memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE);
762
763 /* Build the multicast hash filter. */
764 for (i = 0; i < net->mc_count; i++) {
765 crc_bits =
766 ether_crc(ETH_ALEN,
767 mc_list->dmi_addr) >> 26;
768 data->multi_filter[crc_bits >> 3] |=
769 1 << (crc_bits & 7);
770 mc_list = mc_list->next;
771 }
772
773 asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0,
774 AX_MCAST_FILTER_SIZE, data->multi_filter);
775
776 rx_ctl |= 0x10;
777 }
778
779 asix_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL);
780}
781
782static int ax88172_link_reset(struct usbnet *dev)
783{
784 u8 mode;
785 struct ethtool_cmd ecmd;
786
787 mii_check_media(&dev->mii, 1, 1);
788 mii_ethtool_gset(&dev->mii, &ecmd);
789 mode = AX88172_MEDIUM_DEFAULT;
790
791 if (ecmd.duplex != DUPLEX_FULL)
792 mode |= ~AX88172_MEDIUM_FD;
793
794 devdbg(dev, "ax88172_link_reset() speed: %d duplex: %d setting mode to 0x%04x", ecmd.speed, ecmd.duplex, mode);
795
796 asix_write_medium_mode(dev, mode);
797
798 return 0;
David Brownell2e55cc72005-08-31 09:53:10 -0700799}
800
David Hollis48b1be62006-03-28 20:15:42 -0500801static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
David Brownell2e55cc72005-08-31 09:53:10 -0700802{
803 int ret = 0;
804 void *buf;
805 int i;
806 unsigned long gpio_bits = dev->driver_info->data;
David Hollis933a27d2006-07-29 10:12:50 -0400807 struct asix_data *data = (struct asix_data *)&dev->data;
808
809 data->eeprom_len = AX88172_EEPROM_LEN;
David Brownell2e55cc72005-08-31 09:53:10 -0700810
811 usbnet_get_endpoints(dev,intf);
812
813 buf = kmalloc(ETH_ALEN, GFP_KERNEL);
814 if(!buf) {
815 ret = -ENOMEM;
816 goto out1;
817 }
818
819 /* Toggle the GPIOs in a manufacturer/model specific way */
820 for (i = 2; i >= 0; i--) {
David Hollis48b1be62006-03-28 20:15:42 -0500821 if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS,
David Brownell2e55cc72005-08-31 09:53:10 -0700822 (gpio_bits >> (i * 8)) & 0xff, 0, 0,
823 buf)) < 0)
824 goto out2;
825 msleep(5);
826 }
827
David Hollis933a27d2006-07-29 10:12:50 -0400828 if ((ret = asix_write_rx_ctl(dev, 0x80)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -0700829 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -0700830
831 /* Get the MAC address */
832 memset(buf, 0, ETH_ALEN);
David Hollis933a27d2006-07-29 10:12:50 -0400833 if ((ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID,
David Brownell2e55cc72005-08-31 09:53:10 -0700834 0, 0, 6, buf)) < 0) {
835 dbg("read AX_CMD_READ_NODE_ID failed: %d", ret);
836 goto out2;
837 }
838 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
839
David Brownell2e55cc72005-08-31 09:53:10 -0700840 /* Initialize MII structure */
841 dev->mii.dev = dev->net;
David Hollis48b1be62006-03-28 20:15:42 -0500842 dev->mii.mdio_read = asix_mdio_read;
843 dev->mii.mdio_write = asix_mdio_write;
David Brownell2e55cc72005-08-31 09:53:10 -0700844 dev->mii.phy_id_mask = 0x3f;
845 dev->mii.reg_num_mask = 0x1f;
David Hollis933a27d2006-07-29 10:12:50 -0400846 dev->mii.phy_id = asix_get_phy_addr(dev);
David Hollis48b1be62006-03-28 20:15:42 -0500847 dev->net->do_ioctl = asix_ioctl;
David Brownell2e55cc72005-08-31 09:53:10 -0700848
David Hollis933a27d2006-07-29 10:12:50 -0400849 dev->net->set_multicast_list = ax88172_set_multicast;
David Hollis48b1be62006-03-28 20:15:42 -0500850 dev->net->ethtool_ops = &ax88172_ethtool_ops;
David Brownell2e55cc72005-08-31 09:53:10 -0700851
David Hollis933a27d2006-07-29 10:12:50 -0400852 asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
853 asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
David Brownell2e55cc72005-08-31 09:53:10 -0700854 ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
855 mii_nway_restart(&dev->mii);
856
857 return 0;
858out2:
859 kfree(buf);
860out1:
861 return ret;
862}
863
864static struct ethtool_ops ax88772_ethtool_ops = {
David Hollis48b1be62006-03-28 20:15:42 -0500865 .get_drvinfo = asix_get_drvinfo,
David Hollis933a27d2006-07-29 10:12:50 -0400866 .get_link = asix_get_link,
David Brownell2e55cc72005-08-31 09:53:10 -0700867 .get_msglevel = usbnet_get_msglevel,
868 .set_msglevel = usbnet_set_msglevel,
David Hollis48b1be62006-03-28 20:15:42 -0500869 .get_wol = asix_get_wol,
870 .set_wol = asix_set_wol,
871 .get_eeprom_len = asix_get_eeprom_len,
872 .get_eeprom = asix_get_eeprom,
Arnd Bergmannc41286f2006-10-09 00:08:01 +0200873 .get_settings = usbnet_get_settings,
874 .set_settings = usbnet_set_settings,
875 .nway_reset = usbnet_nway_reset,
David Brownell2e55cc72005-08-31 09:53:10 -0700876};
877
David Hollis933a27d2006-07-29 10:12:50 -0400878static int ax88772_link_reset(struct usbnet *dev)
879{
880 u16 mode;
881 struct ethtool_cmd ecmd;
882
883 mii_check_media(&dev->mii, 1, 1);
884 mii_ethtool_gset(&dev->mii, &ecmd);
885 mode = AX88772_MEDIUM_DEFAULT;
886
887 if (ecmd.speed != SPEED_100)
888 mode &= ~AX_MEDIUM_PS;
889
890 if (ecmd.duplex != DUPLEX_FULL)
891 mode &= ~AX_MEDIUM_FD;
892
893 devdbg(dev, "ax88772_link_reset() speed: %d duplex: %d setting mode to 0x%04x", ecmd.speed, ecmd.duplex, mode);
894
895 asix_write_medium_mode(dev, mode);
896
897 return 0;
898}
899
David Brownell2e55cc72005-08-31 09:53:10 -0700900static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
901{
Andres Salomond0ffff82007-01-11 18:39:16 -0500902 int ret, embd_phy;
David Brownell2e55cc72005-08-31 09:53:10 -0700903 void *buf;
David Hollis933a27d2006-07-29 10:12:50 -0400904 u16 rx_ctl;
905 struct asix_data *data = (struct asix_data *)&dev->data;
906 u32 phyid;
907
908 data->eeprom_len = AX88772_EEPROM_LEN;
David Brownell2e55cc72005-08-31 09:53:10 -0700909
910 usbnet_get_endpoints(dev,intf);
911
912 buf = kmalloc(6, GFP_KERNEL);
913 if(!buf) {
914 dbg ("Cannot allocate memory for buffer");
915 ret = -ENOMEM;
916 goto out1;
917 }
918
David Hollis933a27d2006-07-29 10:12:50 -0400919 if ((ret = asix_write_gpio(dev,
920 AX_GPIO_RSE | AX_GPIO_GPO_2 | AX_GPIO_GPO2EN, 5)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -0700921 goto out2;
922
Andres Salomond0ffff82007-01-11 18:39:16 -0500923 /* 0x10 is the phy id of the embedded 10/100 ethernet phy */
924 embd_phy = ((asix_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0);
David Hollis48b1be62006-03-28 20:15:42 -0500925 if ((ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT,
Andres Salomond0ffff82007-01-11 18:39:16 -0500926 embd_phy, 0, 0, buf)) < 0) {
David Brownell2e55cc72005-08-31 09:53:10 -0700927 dbg("Select PHY #1 failed: %d", ret);
928 goto out2;
929 }
930
Andres Salomond0ffff82007-01-11 18:39:16 -0500931 if ((ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -0700932 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -0700933
934 msleep(150);
David Hollis48b1be62006-03-28 20:15:42 -0500935 if ((ret = asix_sw_reset(dev, AX_SWRESET_CLEAR)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -0700936 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -0700937
938 msleep(150);
Andres Salomond0ffff82007-01-11 18:39:16 -0500939 if (embd_phy) {
940 if ((ret = asix_sw_reset(dev, AX_SWRESET_IPRL)) < 0)
941 goto out2;
942 }
943 else {
944 if ((ret = asix_sw_reset(dev, AX_SWRESET_PRTE)) < 0)
945 goto out2;
946 }
David Brownell2e55cc72005-08-31 09:53:10 -0700947
948 msleep(150);
David Hollis933a27d2006-07-29 10:12:50 -0400949 rx_ctl = asix_read_rx_ctl(dev);
950 dbg("RX_CTL is 0x%04x after software reset", rx_ctl);
951 if ((ret = asix_write_rx_ctl(dev, 0x0000)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -0700952 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -0700953
David Hollis933a27d2006-07-29 10:12:50 -0400954 rx_ctl = asix_read_rx_ctl(dev);
955 dbg("RX_CTL is 0x%04x setting to 0x0000", rx_ctl);
956
David Brownell2e55cc72005-08-31 09:53:10 -0700957 /* Get the MAC address */
958 memset(buf, 0, ETH_ALEN);
David Hollis933a27d2006-07-29 10:12:50 -0400959 if ((ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID,
David Brownell2e55cc72005-08-31 09:53:10 -0700960 0, 0, ETH_ALEN, buf)) < 0) {
961 dbg("Failed to read MAC address: %d", ret);
962 goto out2;
963 }
964 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
965
David Brownell2e55cc72005-08-31 09:53:10 -0700966 /* Initialize MII structure */
967 dev->mii.dev = dev->net;
David Hollis48b1be62006-03-28 20:15:42 -0500968 dev->mii.mdio_read = asix_mdio_read;
969 dev->mii.mdio_write = asix_mdio_write;
David Hollis933a27d2006-07-29 10:12:50 -0400970 dev->mii.phy_id_mask = 0x1f;
971 dev->mii.reg_num_mask = 0x1f;
David Hollis48b1be62006-03-28 20:15:42 -0500972 dev->net->do_ioctl = asix_ioctl;
David Hollis933a27d2006-07-29 10:12:50 -0400973 dev->mii.phy_id = asix_get_phy_addr(dev);
974
975 phyid = asix_get_phyid(dev);
976 dbg("PHYID=0x%08x", phyid);
David Brownell2e55cc72005-08-31 09:53:10 -0700977
David Hollis48b1be62006-03-28 20:15:42 -0500978 if ((ret = asix_sw_reset(dev, AX_SWRESET_PRL)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -0700979 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -0700980
David Brownell2e55cc72005-08-31 09:53:10 -0700981 msleep(150);
982
David Hollis48b1be62006-03-28 20:15:42 -0500983 if ((ret = asix_sw_reset(dev, AX_SWRESET_IPRL | AX_SWRESET_PRL)) < 0)
984 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -0700985
David Hollis48b1be62006-03-28 20:15:42 -0500986 msleep(150);
987
988 dev->net->set_multicast_list = asix_set_multicast;
David Brownell2e55cc72005-08-31 09:53:10 -0700989 dev->net->ethtool_ops = &ax88772_ethtool_ops;
990
David Hollis933a27d2006-07-29 10:12:50 -0400991 asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
992 asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
David Brownell2e55cc72005-08-31 09:53:10 -0700993 ADVERTISE_ALL | ADVERTISE_CSMA);
994 mii_nway_restart(&dev->mii);
995
David Hollis933a27d2006-07-29 10:12:50 -0400996 if ((ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -0700997 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -0700998
David Hollis48b1be62006-03-28 20:15:42 -0500999 if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0,
David Brownell2e55cc72005-08-31 09:53:10 -07001000 AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,
1001 AX88772_IPG2_DEFAULT, 0, buf)) < 0) {
1002 dbg("Write IPG,IPG1,IPG2 failed: %d", ret);
1003 goto out2;
1004 }
David Brownell2e55cc72005-08-31 09:53:10 -07001005
1006 /* Set RX_CTL to default values with 2k buffer, and enable cactus */
David Hollis933a27d2006-07-29 10:12:50 -04001007 if ((ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -07001008 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -07001009
David Hollis933a27d2006-07-29 10:12:50 -04001010 rx_ctl = asix_read_rx_ctl(dev);
1011 dbg("RX_CTL is 0x%04x after all initializations", rx_ctl);
1012
1013 rx_ctl = asix_read_medium_status(dev);
1014 dbg("Medium Status is 0x%04x after all initializations", rx_ctl);
1015
David Brownell2e55cc72005-08-31 09:53:10 -07001016 kfree(buf);
1017
1018 /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
1019 if (dev->driver_info->flags & FLAG_FRAMING_AX) {
1020 /* hard_mtu is still the default - the device does not support
1021 jumbo eth frames */
1022 dev->rx_urb_size = 2048;
1023 }
1024
1025 return 0;
1026
1027out2:
1028 kfree(buf);
1029out1:
1030 return ret;
1031}
1032
David Hollis933a27d2006-07-29 10:12:50 -04001033static struct ethtool_ops ax88178_ethtool_ops = {
1034 .get_drvinfo = asix_get_drvinfo,
1035 .get_link = asix_get_link,
David Hollis933a27d2006-07-29 10:12:50 -04001036 .get_msglevel = usbnet_get_msglevel,
1037 .set_msglevel = usbnet_set_msglevel,
1038 .get_wol = asix_get_wol,
1039 .set_wol = asix_set_wol,
1040 .get_eeprom_len = asix_get_eeprom_len,
1041 .get_eeprom = asix_get_eeprom,
Arnd Bergmannc41286f2006-10-09 00:08:01 +02001042 .get_settings = usbnet_get_settings,
1043 .set_settings = usbnet_set_settings,
1044 .nway_reset = usbnet_nway_reset,
David Hollis933a27d2006-07-29 10:12:50 -04001045};
1046
1047static int marvell_phy_init(struct usbnet *dev)
David Brownell2e55cc72005-08-31 09:53:10 -07001048{
David Hollis933a27d2006-07-29 10:12:50 -04001049 struct asix_data *data = (struct asix_data *)&dev->data;
1050 u16 reg;
David Brownell2e55cc72005-08-31 09:53:10 -07001051
David Hollis933a27d2006-07-29 10:12:50 -04001052 devdbg(dev,"marvell_phy_init()");
David Brownell2e55cc72005-08-31 09:53:10 -07001053
David Hollis933a27d2006-07-29 10:12:50 -04001054 reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_MARVELL_STATUS);
1055 devdbg(dev,"MII_MARVELL_STATUS = 0x%04x", reg);
David Brownell2e55cc72005-08-31 09:53:10 -07001056
David Hollis933a27d2006-07-29 10:12:50 -04001057 asix_mdio_write(dev->net, dev->mii.phy_id, MII_MARVELL_CTRL,
1058 MARVELL_CTRL_RXDELAY | MARVELL_CTRL_TXDELAY);
David Brownell2e55cc72005-08-31 09:53:10 -07001059
David Hollis933a27d2006-07-29 10:12:50 -04001060 if (data->ledmode) {
1061 reg = asix_mdio_read(dev->net, dev->mii.phy_id,
1062 MII_MARVELL_LED_CTRL);
1063 devdbg(dev,"MII_MARVELL_LED_CTRL (1) = 0x%04x", reg);
David Brownell2e55cc72005-08-31 09:53:10 -07001064
David Hollis933a27d2006-07-29 10:12:50 -04001065 reg &= 0xf8ff;
1066 reg |= (1 + 0x0100);
1067 asix_mdio_write(dev->net, dev->mii.phy_id,
1068 MII_MARVELL_LED_CTRL, reg);
David Brownell2e55cc72005-08-31 09:53:10 -07001069
David Hollis933a27d2006-07-29 10:12:50 -04001070 reg = asix_mdio_read(dev->net, dev->mii.phy_id,
1071 MII_MARVELL_LED_CTRL);
1072 devdbg(dev,"MII_MARVELL_LED_CTRL (2) = 0x%04x", reg);
1073 reg &= 0xfc0f;
David Brownell2e55cc72005-08-31 09:53:10 -07001074 }
1075
David Brownell2e55cc72005-08-31 09:53:10 -07001076 return 0;
1077}
1078
David Hollis933a27d2006-07-29 10:12:50 -04001079static int marvell_led_status(struct usbnet *dev, u16 speed)
1080{
1081 u16 reg = asix_mdio_read(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL);
1082
1083 devdbg(dev, "marvell_led_status() read 0x%04x", reg);
1084
1085 /* Clear out the center LED bits - 0x03F0 */
1086 reg &= 0xfc0f;
1087
1088 switch (speed) {
1089 case SPEED_1000:
1090 reg |= 0x03e0;
1091 break;
1092 case SPEED_100:
1093 reg |= 0x03b0;
1094 break;
1095 default:
1096 reg |= 0x02f0;
1097 }
1098
1099 devdbg(dev, "marvell_led_status() writing 0x%04x", reg);
1100 asix_mdio_write(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL, reg);
1101
1102 return 0;
1103}
1104
1105static int ax88178_link_reset(struct usbnet *dev)
1106{
1107 u16 mode;
1108 struct ethtool_cmd ecmd;
1109 struct asix_data *data = (struct asix_data *)&dev->data;
1110
1111 devdbg(dev,"ax88178_link_reset()");
1112
1113 mii_check_media(&dev->mii, 1, 1);
1114 mii_ethtool_gset(&dev->mii, &ecmd);
1115 mode = AX88178_MEDIUM_DEFAULT;
1116
1117 if (ecmd.speed == SPEED_1000)
1118 mode |= AX_MEDIUM_GM | AX_MEDIUM_ENCK;
1119 else if (ecmd.speed == SPEED_100)
1120 mode |= AX_MEDIUM_PS;
1121 else
1122 mode &= ~(AX_MEDIUM_PS | AX_MEDIUM_GM);
1123
1124 if (ecmd.duplex == DUPLEX_FULL)
1125 mode |= AX_MEDIUM_FD;
1126 else
1127 mode &= ~AX_MEDIUM_FD;
1128
1129 devdbg(dev, "ax88178_link_reset() speed: %d duplex: %d setting mode to 0x%04x", ecmd.speed, ecmd.duplex, mode);
1130
1131 asix_write_medium_mode(dev, mode);
1132
1133 if (data->phymode == PHY_MODE_MARVELL && data->ledmode)
1134 marvell_led_status(dev, ecmd.speed);
1135
1136 return 0;
1137}
1138
1139static void ax88178_set_mfb(struct usbnet *dev)
1140{
1141 u16 mfb = AX_RX_CTL_MFB_16384;
1142 u16 rxctl;
1143 u16 medium;
1144 int old_rx_urb_size = dev->rx_urb_size;
1145
1146 if (dev->hard_mtu < 2048) {
1147 dev->rx_urb_size = 2048;
1148 mfb = AX_RX_CTL_MFB_2048;
1149 } else if (dev->hard_mtu < 4096) {
1150 dev->rx_urb_size = 4096;
1151 mfb = AX_RX_CTL_MFB_4096;
1152 } else if (dev->hard_mtu < 8192) {
1153 dev->rx_urb_size = 8192;
1154 mfb = AX_RX_CTL_MFB_8192;
1155 } else if (dev->hard_mtu < 16384) {
1156 dev->rx_urb_size = 16384;
1157 mfb = AX_RX_CTL_MFB_16384;
1158 }
1159
1160 rxctl = asix_read_rx_ctl(dev);
1161 asix_write_rx_ctl(dev, (rxctl & ~AX_RX_CTL_MFB_16384) | mfb);
1162
1163 medium = asix_read_medium_status(dev);
1164 if (dev->net->mtu > 1500)
1165 medium |= AX_MEDIUM_JFE;
1166 else
1167 medium &= ~AX_MEDIUM_JFE;
1168 asix_write_medium_mode(dev, medium);
1169
1170 if (dev->rx_urb_size > old_rx_urb_size)
1171 usbnet_unlink_rx_urbs(dev);
1172}
1173
1174static int ax88178_change_mtu(struct net_device *net, int new_mtu)
1175{
1176 struct usbnet *dev = netdev_priv(net);
1177 int ll_mtu = new_mtu + net->hard_header_len + 4;
1178
1179 devdbg(dev, "ax88178_change_mtu() new_mtu=%d", new_mtu);
1180
1181 if (new_mtu <= 0 || ll_mtu > 16384)
1182 return -EINVAL;
1183
1184 if ((ll_mtu % dev->maxpacket) == 0)
1185 return -EDOM;
1186
1187 net->mtu = new_mtu;
1188 dev->hard_mtu = net->mtu + net->hard_header_len;
1189 ax88178_set_mfb(dev);
1190
1191 return 0;
1192}
1193
1194static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
1195{
1196 struct asix_data *data = (struct asix_data *)&dev->data;
1197 int ret;
1198 void *buf;
1199 u16 eeprom;
1200 int gpio0 = 0;
1201 u32 phyid;
1202
1203 usbnet_get_endpoints(dev,intf);
1204
1205 buf = kmalloc(6, GFP_KERNEL);
1206 if(!buf) {
1207 dbg ("Cannot allocate memory for buffer");
1208 ret = -ENOMEM;
1209 goto out1;
1210 }
1211
1212 eeprom = 0;
1213 asix_read_cmd(dev, AX_CMD_READ_GPIOS, 0, 0, 1, &eeprom);
1214 dbg("GPIO Status: 0x%04x", eeprom);
1215
1216 asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0, 0, 0, NULL);
1217 asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2, &eeprom);
1218 asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0, 0, 0, NULL);
1219
1220 dbg("EEPROM index 0x17 is 0x%04x", eeprom);
1221
1222 if (eeprom == 0xffff) {
1223 data->phymode = PHY_MODE_MARVELL;
1224 data->ledmode = 0;
1225 gpio0 = 1;
1226 } else {
1227 data->phymode = eeprom & 7;
1228 data->ledmode = eeprom >> 8;
1229 gpio0 = (eeprom & 0x80) ? 0 : 1;
1230 }
1231 dbg("GPIO0: %d, PhyMode: %d", gpio0, data->phymode);
1232
1233 asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_1 | AX_GPIO_GPO1EN, 40);
1234 if ((eeprom >> 8) != 1) {
1235 asix_write_gpio(dev, 0x003c, 30);
1236 asix_write_gpio(dev, 0x001c, 300);
1237 asix_write_gpio(dev, 0x003c, 30);
1238 } else {
1239 dbg("gpio phymode == 1 path");
1240 asix_write_gpio(dev, AX_GPIO_GPO1EN, 30);
1241 asix_write_gpio(dev, AX_GPIO_GPO1EN | AX_GPIO_GPO_1, 30);
1242 }
1243
1244 asix_sw_reset(dev, 0);
1245 msleep(150);
1246
1247 asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD);
1248 msleep(150);
1249
1250 asix_write_rx_ctl(dev, 0);
1251
1252 /* Get the MAC address */
1253 memset(buf, 0, ETH_ALEN);
1254 if ((ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID,
1255 0, 0, ETH_ALEN, buf)) < 0) {
1256 dbg("Failed to read MAC address: %d", ret);
1257 goto out2;
1258 }
1259 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
1260
1261 /* Initialize MII structure */
1262 dev->mii.dev = dev->net;
1263 dev->mii.mdio_read = asix_mdio_read;
1264 dev->mii.mdio_write = asix_mdio_write;
1265 dev->mii.phy_id_mask = 0x1f;
1266 dev->mii.reg_num_mask = 0xff;
1267 dev->mii.supports_gmii = 1;
1268 dev->net->do_ioctl = asix_ioctl;
1269 dev->mii.phy_id = asix_get_phy_addr(dev);
1270 dev->net->set_multicast_list = asix_set_multicast;
1271 dev->net->ethtool_ops = &ax88178_ethtool_ops;
1272 dev->net->change_mtu = &ax88178_change_mtu;
1273
1274 phyid = asix_get_phyid(dev);
1275 dbg("PHYID=0x%08x", phyid);
1276
1277 if (data->phymode == PHY_MODE_MARVELL) {
1278 marvell_phy_init(dev);
1279 msleep(60);
1280 }
1281
1282 asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR,
1283 BMCR_RESET | BMCR_ANENABLE);
1284 asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
1285 ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
1286 asix_mdio_write(dev->net, dev->mii.phy_id, MII_CTRL1000,
1287 ADVERTISE_1000FULL);
1288
1289 mii_nway_restart(&dev->mii);
1290
1291 if ((ret = asix_write_medium_mode(dev, AX88178_MEDIUM_DEFAULT)) < 0)
1292 goto out2;
1293
1294 if ((ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL)) < 0)
1295 goto out2;
1296
1297 kfree(buf);
1298
1299 /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
1300 if (dev->driver_info->flags & FLAG_FRAMING_AX) {
1301 /* hard_mtu is still the default - the device does not support
1302 jumbo eth frames */
1303 dev->rx_urb_size = 2048;
1304 }
1305
1306 return 0;
1307
1308out2:
1309 kfree(buf);
1310out1:
1311 return ret;
1312}
1313
David Brownell2e55cc72005-08-31 09:53:10 -07001314static const struct driver_info ax8817x_info = {
1315 .description = "ASIX AX8817x USB 2.0 Ethernet",
David Hollis48b1be62006-03-28 20:15:42 -05001316 .bind = ax88172_bind,
1317 .status = asix_status,
David Brownell2e55cc72005-08-31 09:53:10 -07001318 .link_reset = ax88172_link_reset,
1319 .reset = ax88172_link_reset,
1320 .flags = FLAG_ETHER,
1321 .data = 0x00130103,
1322};
1323
1324static const struct driver_info dlink_dub_e100_info = {
1325 .description = "DLink DUB-E100 USB Ethernet",
David Hollis48b1be62006-03-28 20:15:42 -05001326 .bind = ax88172_bind,
1327 .status = asix_status,
David Brownell2e55cc72005-08-31 09:53:10 -07001328 .link_reset = ax88172_link_reset,
1329 .reset = ax88172_link_reset,
1330 .flags = FLAG_ETHER,
1331 .data = 0x009f9d9f,
1332};
1333
1334static const struct driver_info netgear_fa120_info = {
1335 .description = "Netgear FA-120 USB Ethernet",
David Hollis48b1be62006-03-28 20:15:42 -05001336 .bind = ax88172_bind,
1337 .status = asix_status,
David Brownell2e55cc72005-08-31 09:53:10 -07001338 .link_reset = ax88172_link_reset,
1339 .reset = ax88172_link_reset,
1340 .flags = FLAG_ETHER,
1341 .data = 0x00130103,
1342};
1343
1344static const struct driver_info hawking_uf200_info = {
1345 .description = "Hawking UF200 USB Ethernet",
David Hollis48b1be62006-03-28 20:15:42 -05001346 .bind = ax88172_bind,
1347 .status = asix_status,
David Brownell2e55cc72005-08-31 09:53:10 -07001348 .link_reset = ax88172_link_reset,
1349 .reset = ax88172_link_reset,
1350 .flags = FLAG_ETHER,
1351 .data = 0x001f1d1f,
1352};
1353
1354static const struct driver_info ax88772_info = {
1355 .description = "ASIX AX88772 USB 2.0 Ethernet",
1356 .bind = ax88772_bind,
David Hollis48b1be62006-03-28 20:15:42 -05001357 .status = asix_status,
David Brownell2e55cc72005-08-31 09:53:10 -07001358 .link_reset = ax88772_link_reset,
1359 .reset = ax88772_link_reset,
1360 .flags = FLAG_ETHER | FLAG_FRAMING_AX,
David Hollis933a27d2006-07-29 10:12:50 -04001361 .rx_fixup = asix_rx_fixup,
1362 .tx_fixup = asix_tx_fixup,
1363};
1364
1365static const struct driver_info ax88178_info = {
1366 .description = "ASIX AX88178 USB 2.0 Ethernet",
1367 .bind = ax88178_bind,
1368 .status = asix_status,
1369 .link_reset = ax88178_link_reset,
1370 .reset = ax88178_link_reset,
1371 .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1372 .rx_fixup = asix_rx_fixup,
1373 .tx_fixup = asix_tx_fixup,
David Brownell2e55cc72005-08-31 09:53:10 -07001374};
1375
1376static const struct usb_device_id products [] = {
1377{
1378 // Linksys USB200M
1379 USB_DEVICE (0x077b, 0x2226),
1380 .driver_info = (unsigned long) &ax8817x_info,
1381}, {
1382 // Netgear FA120
1383 USB_DEVICE (0x0846, 0x1040),
1384 .driver_info = (unsigned long) &netgear_fa120_info,
1385}, {
1386 // DLink DUB-E100
1387 USB_DEVICE (0x2001, 0x1a00),
1388 .driver_info = (unsigned long) &dlink_dub_e100_info,
1389}, {
1390 // Intellinet, ST Lab USB Ethernet
1391 USB_DEVICE (0x0b95, 0x1720),
1392 .driver_info = (unsigned long) &ax8817x_info,
1393}, {
1394 // Hawking UF200, TrendNet TU2-ET100
1395 USB_DEVICE (0x07b8, 0x420a),
1396 .driver_info = (unsigned long) &hawking_uf200_info,
1397}, {
David Hollis39c4b382007-02-20 08:02:24 -05001398 // Billionton Systems, USB2AR
1399 USB_DEVICE (0x08dd, 0x90ff),
1400 .driver_info = (unsigned long) &ax8817x_info,
David Brownell2e55cc72005-08-31 09:53:10 -07001401}, {
1402 // ATEN UC210T
1403 USB_DEVICE (0x0557, 0x2009),
1404 .driver_info = (unsigned long) &ax8817x_info,
1405}, {
1406 // Buffalo LUA-U2-KTX
1407 USB_DEVICE (0x0411, 0x003d),
1408 .driver_info = (unsigned long) &ax8817x_info,
1409}, {
1410 // Sitecom LN-029 "USB 2.0 10/100 Ethernet adapter"
1411 USB_DEVICE (0x6189, 0x182d),
1412 .driver_info = (unsigned long) &ax8817x_info,
1413}, {
1414 // corega FEther USB2-TX
1415 USB_DEVICE (0x07aa, 0x0017),
1416 .driver_info = (unsigned long) &ax8817x_info,
1417}, {
1418 // Surecom EP-1427X-2
1419 USB_DEVICE (0x1189, 0x0893),
1420 .driver_info = (unsigned long) &ax8817x_info,
1421}, {
1422 // goodway corp usb gwusb2e
1423 USB_DEVICE (0x1631, 0x6200),
1424 .driver_info = (unsigned long) &ax8817x_info,
1425}, {
David Hollis39c4b382007-02-20 08:02:24 -05001426 // JVC MP-PRX1 Port Replicator
1427 USB_DEVICE (0x04f1, 0x3008),
1428 .driver_info = (unsigned long) &ax8817x_info,
1429}, {
David Brownell2e55cc72005-08-31 09:53:10 -07001430 // ASIX AX88772 10/100
David Hollis39c4b382007-02-20 08:02:24 -05001431 USB_DEVICE (0x0b95, 0x7720),
1432 .driver_info = (unsigned long) &ax88772_info,
David Hollis5e0f76c2005-12-19 13:58:38 -05001433}, {
Eduard Warkentin73274132006-05-18 01:13:17 -07001434 // ASIX AX88178 10/100/1000
1435 USB_DEVICE (0x0b95, 0x1780),
David Hollis933a27d2006-07-29 10:12:50 -04001436 .driver_info = (unsigned long) &ax88178_info,
Eduard Warkentin73274132006-05-18 01:13:17 -07001437}, {
David Hollis5e0f76c2005-12-19 13:58:38 -05001438 // Linksys USB200M Rev 2
1439 USB_DEVICE (0x13b1, 0x0018),
1440 .driver_info = (unsigned long) &ax88772_info,
David Hollis5732ce82006-01-05 14:39:49 -05001441}, {
1442 // 0Q0 cable ethernet
1443 USB_DEVICE (0x1557, 0x7720),
1444 .driver_info = (unsigned long) &ax88772_info,
David Hollis933a27d2006-07-29 10:12:50 -04001445}, {
1446 // DLink DUB-E100 H/W Ver B1
1447 USB_DEVICE (0x07d1, 0x3c05),
1448 .driver_info = (unsigned long) &ax88772_info,
1449}, {
David Hollisb923e7f2006-09-21 08:09:29 -04001450 // DLink DUB-E100 H/W Ver B1 Alternate
1451 USB_DEVICE (0x2001, 0x3c05),
1452 .driver_info = (unsigned long) &ax88772_info,
1453}, {
David Hollis933a27d2006-07-29 10:12:50 -04001454 // Linksys USB1000
1455 USB_DEVICE (0x1737, 0x0039),
1456 .driver_info = (unsigned long) &ax88178_info,
YOSHIFUJI Hideaki / 吉藤英明b29cf312007-01-26 22:57:38 +09001457}, {
1458 // IO-DATA ETG-US2
1459 USB_DEVICE (0x04bb, 0x0930),
1460 .driver_info = (unsigned long) &ax88178_info,
David Hollis2ed22bc2007-05-23 07:33:17 -04001461}, {
1462 // Belkin F5D5055
1463 USB_DEVICE(0x050d, 0x5055),
1464 .driver_info = (unsigned long) &ax88178_info,
David Brownell2e55cc72005-08-31 09:53:10 -07001465},
1466 { }, // END
1467};
1468MODULE_DEVICE_TABLE(usb, products);
1469
1470static struct usb_driver asix_driver = {
David Brownell2e55cc72005-08-31 09:53:10 -07001471 .name = "asix",
1472 .id_table = products,
1473 .probe = usbnet_probe,
1474 .suspend = usbnet_suspend,
1475 .resume = usbnet_resume,
1476 .disconnect = usbnet_disconnect,
1477};
1478
1479static int __init asix_init(void)
1480{
1481 return usb_register(&asix_driver);
1482}
1483module_init(asix_init);
1484
1485static void __exit asix_exit(void)
1486{
1487 usb_deregister(&asix_driver);
1488}
1489module_exit(asix_exit);
1490
1491MODULE_AUTHOR("David Hollis");
1492MODULE_DESCRIPTION("ASIX AX8817X based USB 2.0 Ethernet Devices");
1493MODULE_LICENSE("GPL");
1494