blob: 5edd0534c7abe16685718d95d6c677bc8400f974 [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>
28#include <linux/sched.h>
29#include <linux/init.h>
30#include <linux/netdevice.h>
31#include <linux/etherdevice.h>
32#include <linux/ethtool.h>
33#include <linux/workqueue.h>
34#include <linux/mii.h>
35#include <linux/usb.h>
36#include <linux/crc32.h>
37
38#include "usbnet.h"
39
David Hollis933a27d2006-07-29 10:12:50 -040040#define DRIVER_VERSION "14-Jun-2006"
41static const char driver_name [] = "asix";
42
David Brownell2e55cc72005-08-31 09:53:10 -070043/* ASIX AX8817X based USB 2.0 Ethernet Devices */
44
45#define AX_CMD_SET_SW_MII 0x06
46#define AX_CMD_READ_MII_REG 0x07
47#define AX_CMD_WRITE_MII_REG 0x08
48#define AX_CMD_SET_HW_MII 0x0a
49#define AX_CMD_READ_EEPROM 0x0b
50#define AX_CMD_WRITE_EEPROM 0x0c
51#define AX_CMD_WRITE_ENABLE 0x0d
52#define AX_CMD_WRITE_DISABLE 0x0e
David Hollis933a27d2006-07-29 10:12:50 -040053#define AX_CMD_READ_RX_CTL 0x0f
David Brownell2e55cc72005-08-31 09:53:10 -070054#define AX_CMD_WRITE_RX_CTL 0x10
55#define AX_CMD_READ_IPG012 0x11
56#define AX_CMD_WRITE_IPG0 0x12
57#define AX_CMD_WRITE_IPG1 0x13
David Hollis933a27d2006-07-29 10:12:50 -040058#define AX_CMD_READ_NODE_ID 0x13
David Brownell2e55cc72005-08-31 09:53:10 -070059#define AX_CMD_WRITE_IPG2 0x14
60#define AX_CMD_WRITE_MULTI_FILTER 0x16
David Hollis933a27d2006-07-29 10:12:50 -040061#define AX88172_CMD_READ_NODE_ID 0x17
David Brownell2e55cc72005-08-31 09:53:10 -070062#define AX_CMD_READ_PHY_ID 0x19
63#define AX_CMD_READ_MEDIUM_STATUS 0x1a
64#define AX_CMD_WRITE_MEDIUM_MODE 0x1b
65#define AX_CMD_READ_MONITOR_MODE 0x1c
66#define AX_CMD_WRITE_MONITOR_MODE 0x1d
David Hollis933a27d2006-07-29 10:12:50 -040067#define AX_CMD_READ_GPIOS 0x1e
David Brownell2e55cc72005-08-31 09:53:10 -070068#define AX_CMD_WRITE_GPIOS 0x1f
69#define AX_CMD_SW_RESET 0x20
70#define AX_CMD_SW_PHY_STATUS 0x21
71#define AX_CMD_SW_PHY_SELECT 0x22
David Brownell2e55cc72005-08-31 09:53:10 -070072
73#define AX_MONITOR_MODE 0x01
74#define AX_MONITOR_LINK 0x02
75#define AX_MONITOR_MAGIC 0x04
76#define AX_MONITOR_HSFS 0x10
77
78/* AX88172 Medium Status Register values */
David Hollis933a27d2006-07-29 10:12:50 -040079#define AX88172_MEDIUM_FD 0x02
80#define AX88172_MEDIUM_TX 0x04
81#define AX88172_MEDIUM_FC 0x10
82#define AX88172_MEDIUM_DEFAULT \
83 ( AX88172_MEDIUM_FD | AX88172_MEDIUM_TX | AX88172_MEDIUM_FC )
David Brownell2e55cc72005-08-31 09:53:10 -070084
85#define AX_MCAST_FILTER_SIZE 8
86#define AX_MAX_MCAST 64
87
David Brownell2e55cc72005-08-31 09:53:10 -070088#define AX_SWRESET_CLEAR 0x00
89#define AX_SWRESET_RR 0x01
90#define AX_SWRESET_RT 0x02
91#define AX_SWRESET_PRTE 0x04
92#define AX_SWRESET_PRL 0x08
93#define AX_SWRESET_BZ 0x10
94#define AX_SWRESET_IPRL 0x20
95#define AX_SWRESET_IPPD 0x40
96
97#define AX88772_IPG0_DEFAULT 0x15
98#define AX88772_IPG1_DEFAULT 0x0c
99#define AX88772_IPG2_DEFAULT 0x12
100
David Hollis933a27d2006-07-29 10:12:50 -0400101/* AX88772 & AX88178 Medium Mode Register */
102#define AX_MEDIUM_PF 0x0080
103#define AX_MEDIUM_JFE 0x0040
104#define AX_MEDIUM_TFC 0x0020
105#define AX_MEDIUM_RFC 0x0010
106#define AX_MEDIUM_ENCK 0x0008
107#define AX_MEDIUM_AC 0x0004
108#define AX_MEDIUM_FD 0x0002
109#define AX_MEDIUM_GM 0x0001
110#define AX_MEDIUM_SM 0x1000
111#define AX_MEDIUM_SBP 0x0800
112#define AX_MEDIUM_PS 0x0200
113#define AX_MEDIUM_RE 0x0100
David Brownell2e55cc72005-08-31 09:53:10 -0700114
David Hollis933a27d2006-07-29 10:12:50 -0400115#define AX88178_MEDIUM_DEFAULT \
116 (AX_MEDIUM_PS | AX_MEDIUM_FD | AX_MEDIUM_AC | \
117 AX_MEDIUM_RFC | AX_MEDIUM_TFC | AX_MEDIUM_JFE | \
118 AX_MEDIUM_RE )
119
120#define AX88772_MEDIUM_DEFAULT \
121 (AX_MEDIUM_FD | AX_MEDIUM_RFC | \
122 AX_MEDIUM_TFC | AX_MEDIUM_PS | \
123 AX_MEDIUM_AC | AX_MEDIUM_RE )
124
125/* AX88772 & AX88178 RX_CTL values */
126#define AX_RX_CTL_SO 0x0080
127#define AX_RX_CTL_AP 0x0020
128#define AX_RX_CTL_AM 0x0010
129#define AX_RX_CTL_AB 0x0008
130#define AX_RX_CTL_SEP 0x0004
131#define AX_RX_CTL_AMALL 0x0002
132#define AX_RX_CTL_PRO 0x0001
133#define AX_RX_CTL_MFB_2048 0x0000
134#define AX_RX_CTL_MFB_4096 0x0100
135#define AX_RX_CTL_MFB_8192 0x0200
136#define AX_RX_CTL_MFB_16384 0x0300
137
138#define AX_DEFAULT_RX_CTL \
139 (AX_RX_CTL_SO | AX_RX_CTL_AB )
140
141/* GPIO 0 .. 2 toggles */
142#define AX_GPIO_GPO0EN 0x01 /* GPIO0 Output enable */
143#define AX_GPIO_GPO_0 0x02 /* GPIO0 Output value */
144#define AX_GPIO_GPO1EN 0x04 /* GPIO1 Output enable */
145#define AX_GPIO_GPO_1 0x08 /* GPIO1 Output value */
146#define AX_GPIO_GPO2EN 0x10 /* GPIO2 Output enable */
147#define AX_GPIO_GPO_2 0x20 /* GPIO2 Output value */
148#define AX_GPIO_RESERVED 0x40 /* Reserved */
149#define AX_GPIO_RSE 0x80 /* Reload serial EEPROM */
150
151#define AX_EEPROM_MAGIC 0xdeadbeef
152#define AX88172_EEPROM_LEN 0x40
153#define AX88772_EEPROM_LEN 0xff
154
155#define PHY_MODE_MARVELL 0x0000
156#define MII_MARVELL_LED_CTRL 0x0018
157#define MII_MARVELL_STATUS 0x001b
158#define MII_MARVELL_CTRL 0x0014
159
160#define MARVELL_LED_MANUAL 0x0019
161
162#define MARVELL_STATUS_HWCFG 0x0004
163
164#define MARVELL_CTRL_TXDELAY 0x0002
165#define MARVELL_CTRL_RXDELAY 0x0080
David Brownell2e55cc72005-08-31 09:53:10 -0700166
167/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
David Hollis48b1be62006-03-28 20:15:42 -0500168struct asix_data {
David Brownell2e55cc72005-08-31 09:53:10 -0700169 u8 multi_filter[AX_MCAST_FILTER_SIZE];
David Hollis933a27d2006-07-29 10:12:50 -0400170 u8 phymode;
171 u8 ledmode;
172 u8 eeprom_len;
David Brownell2e55cc72005-08-31 09:53:10 -0700173};
174
175struct ax88172_int_data {
176 u16 res1;
177 u8 link;
178 u16 res2;
179 u8 status;
180 u16 res3;
181} __attribute__ ((packed));
182
David Hollis48b1be62006-03-28 20:15:42 -0500183static int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
David Brownell2e55cc72005-08-31 09:53:10 -0700184 u16 size, void *data)
185{
David Hollis933a27d2006-07-29 10:12:50 -0400186 devdbg(dev,"asix_read_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d",
187 cmd, value, index, size);
David Brownell2e55cc72005-08-31 09:53:10 -0700188 return usb_control_msg(
189 dev->udev,
190 usb_rcvctrlpipe(dev->udev, 0),
191 cmd,
192 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
193 value,
194 index,
195 data,
196 size,
197 USB_CTRL_GET_TIMEOUT);
198}
199
David Hollis48b1be62006-03-28 20:15:42 -0500200static int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
David Brownell2e55cc72005-08-31 09:53:10 -0700201 u16 size, void *data)
202{
David Hollis933a27d2006-07-29 10:12:50 -0400203 devdbg(dev,"asix_write_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d",
204 cmd, value, index, size);
David Brownell2e55cc72005-08-31 09:53:10 -0700205 return usb_control_msg(
206 dev->udev,
207 usb_sndctrlpipe(dev->udev, 0),
208 cmd,
209 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
210 value,
211 index,
212 data,
213 size,
214 USB_CTRL_SET_TIMEOUT);
215}
216
David Howells7d12e782006-10-05 14:55:46 +0100217static void asix_async_cmd_callback(struct urb *urb)
David Brownell2e55cc72005-08-31 09:53:10 -0700218{
219 struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
220
221 if (urb->status < 0)
David Hollis48b1be62006-03-28 20:15:42 -0500222 printk(KERN_DEBUG "asix_async_cmd_callback() failed with %d",
David Brownell2e55cc72005-08-31 09:53:10 -0700223 urb->status);
224
225 kfree(req);
226 usb_free_urb(urb);
227}
228
David Hollis933a27d2006-07-29 10:12:50 -0400229static void
230asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
231 u16 size, void *data)
David Hollis48b1be62006-03-28 20:15:42 -0500232{
David Hollis933a27d2006-07-29 10:12:50 -0400233 struct usb_ctrlrequest *req;
234 int status;
235 struct urb *urb;
David Hollis48b1be62006-03-28 20:15:42 -0500236
David Hollis933a27d2006-07-29 10:12:50 -0400237 devdbg(dev,"asix_write_cmd_async() cmd=0x%02x value=0x%04x index=0x%04x size=%d",
238 cmd, value, index, size);
239 if ((urb = usb_alloc_urb(0, GFP_ATOMIC)) == NULL) {
240 deverr(dev, "Error allocating URB in write_cmd_async!");
241 return;
David Hollis48b1be62006-03-28 20:15:42 -0500242 }
David Hollis933a27d2006-07-29 10:12:50 -0400243
244 if ((req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC)) == NULL) {
245 deverr(dev, "Failed to allocate memory for control request");
246 usb_free_urb(urb);
247 return;
248 }
249
250 req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
251 req->bRequest = cmd;
252 req->wValue = value;
253 req->wIndex = index;
254 req->wLength = size;
255
256 usb_fill_control_urb(urb, dev->udev,
257 usb_sndctrlpipe(dev->udev, 0),
258 (void *)req, data, size,
259 asix_async_cmd_callback, req);
260
261 if((status = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
262 deverr(dev, "Error submitting the control message: status=%d",
263 status);
264 kfree(req);
265 usb_free_urb(urb);
266 }
David Hollis48b1be62006-03-28 20:15:42 -0500267}
268
David Hollis933a27d2006-07-29 10:12:50 -0400269static int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
David Hollis48b1be62006-03-28 20:15:42 -0500270{
David Hollis933a27d2006-07-29 10:12:50 -0400271 u8 *head;
272 u32 header;
273 char *packet;
274 struct sk_buff *ax_skb;
275 u16 size;
David Hollis48b1be62006-03-28 20:15:42 -0500276
David Hollis933a27d2006-07-29 10:12:50 -0400277 head = (u8 *) skb->data;
278 memcpy(&header, head, sizeof(header));
279 le32_to_cpus(&header);
280 packet = head + sizeof(header);
David Hollis48b1be62006-03-28 20:15:42 -0500281
David Hollis933a27d2006-07-29 10:12:50 -0400282 skb_pull(skb, 4);
283
284 while (skb->len > 0) {
285 if ((short)(header & 0x0000ffff) !=
286 ~((short)((header & 0xffff0000) >> 16))) {
287 deverr(dev,"asix_rx_fixup() Bad Header Length");
288 }
289 /* get the packet length */
290 size = (u16) (header & 0x0000ffff);
291
292 if ((skb->len) - ((size + 1) & 0xfffe) == 0)
293 return 2;
294 if (size > ETH_FRAME_LEN) {
295 deverr(dev,"asix_rx_fixup() Bad RX Length %d", size);
296 return 0;
297 }
298 ax_skb = skb_clone(skb, GFP_ATOMIC);
299 if (ax_skb) {
300 ax_skb->len = size;
301 ax_skb->data = packet;
302 ax_skb->tail = packet + size;
303 usbnet_skb_return(dev, ax_skb);
304 } else {
305 return 0;
306 }
307
308 skb_pull(skb, (size + 1) & 0xfffe);
309
310 if (skb->len == 0)
311 break;
312
313 head = (u8 *) skb->data;
314 memcpy(&header, head, sizeof(header));
315 le32_to_cpus(&header);
316 packet = head + sizeof(header);
317 skb_pull(skb, 4);
318 }
319
320 if (skb->len < 0) {
321 deverr(dev,"asix_rx_fixup() Bad SKB Length %d", skb->len);
322 return 0;
323 }
324 return 1;
David Hollis48b1be62006-03-28 20:15:42 -0500325}
326
David Hollis933a27d2006-07-29 10:12:50 -0400327static struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
328 gfp_t flags)
David Hollis48b1be62006-03-28 20:15:42 -0500329{
David Hollis933a27d2006-07-29 10:12:50 -0400330 int padlen;
331 int headroom = skb_headroom(skb);
332 int tailroom = skb_tailroom(skb);
333 u32 packet_len;
334 u32 padbytes = 0xffff0000;
David Hollis48b1be62006-03-28 20:15:42 -0500335
David Hollis933a27d2006-07-29 10:12:50 -0400336 padlen = ((skb->len + 4) % 512) ? 0 : 4;
David Hollis48b1be62006-03-28 20:15:42 -0500337
David Hollis933a27d2006-07-29 10:12:50 -0400338 if ((!skb_cloned(skb))
339 && ((headroom + tailroom) >= (4 + padlen))) {
340 if ((headroom < 4) || (tailroom < padlen)) {
341 skb->data = memmove(skb->head + 4, skb->data, skb->len);
342 skb->tail = skb->data + skb->len;
343 }
344 } else {
345 struct sk_buff *skb2;
346 skb2 = skb_copy_expand(skb, 4, padlen, flags);
347 dev_kfree_skb_any(skb);
348 skb = skb2;
349 if (!skb)
350 return NULL;
351 }
352
353 skb_push(skb, 4);
354 packet_len = (((skb->len - 4) ^ 0x0000ffff) << 16) + (skb->len - 4);
355 memcpy(skb->data, &packet_len, sizeof(packet_len));
356
357 if ((skb->len % 512) == 0) {
358 memcpy( skb->tail, &padbytes, sizeof(padbytes));
359 skb_put(skb, sizeof(padbytes));
360 }
361 return skb;
David Hollis48b1be62006-03-28 20:15:42 -0500362}
363
364static void asix_status(struct usbnet *dev, struct urb *urb)
David Brownell2e55cc72005-08-31 09:53:10 -0700365{
366 struct ax88172_int_data *event;
367 int link;
368
369 if (urb->actual_length < 8)
370 return;
371
372 event = urb->transfer_buffer;
373 link = event->link & 0x01;
374 if (netif_carrier_ok(dev->net) != link) {
375 if (link) {
376 netif_carrier_on(dev->net);
377 usbnet_defer_kevent (dev, EVENT_LINK_RESET );
378 } else
379 netif_carrier_off(dev->net);
David Hollis48b1be62006-03-28 20:15:42 -0500380 devdbg(dev, "Link Status is: %d", link);
David Brownell2e55cc72005-08-31 09:53:10 -0700381 }
382}
383
David Hollis933a27d2006-07-29 10:12:50 -0400384static inline int asix_set_sw_mii(struct usbnet *dev)
David Brownell2e55cc72005-08-31 09:53:10 -0700385{
David Hollis933a27d2006-07-29 10:12:50 -0400386 int ret;
387 ret = asix_write_cmd(dev, AX_CMD_SET_SW_MII, 0x0000, 0, 0, NULL);
388 if (ret < 0)
389 deverr(dev, "Failed to enable software MII access");
390 return ret;
David Brownell2e55cc72005-08-31 09:53:10 -0700391}
392
David Hollis933a27d2006-07-29 10:12:50 -0400393static inline int asix_set_hw_mii(struct usbnet *dev)
394{
395 int ret;
396 ret = asix_write_cmd(dev, AX_CMD_SET_HW_MII, 0x0000, 0, 0, NULL);
397 if (ret < 0)
398 deverr(dev, "Failed to enable hardware MII access");
399 return ret;
400}
401
402static inline int asix_get_phy_addr(struct usbnet *dev)
403{
404 int ret = 0;
405 void *buf;
406
407 devdbg(dev, "asix_get_phy_addr()");
408
409 buf = kmalloc(2, GFP_KERNEL);
410 if (!buf)
411 goto out1;
412
413 if ((ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID,
414 0, 0, 2, buf)) < 2) {
415 deverr(dev, "Error reading PHYID register: %02x", ret);
416 goto out2;
417 }
418 devdbg(dev, "asix_get_phy_addr() returning 0x%04x", *((u16 *)buf));
419 ret = *((u8 *)buf + 1);
420out2:
421 kfree(buf);
422out1:
423 return ret;
424}
425
426static int asix_sw_reset(struct usbnet *dev, u8 flags)
427{
428 int ret;
429
430 ret = asix_write_cmd(dev, AX_CMD_SW_RESET, flags, 0, 0, NULL);
431 if (ret < 0)
432 deverr(dev,"Failed to send software reset: %02x", ret);
433
434 return ret;
435}
436
437static u16 asix_read_rx_ctl(struct usbnet *dev)
438{
439 u16 ret = 0;
440 void *buf;
441
442 buf = kmalloc(2, GFP_KERNEL);
443 if (!buf)
444 goto out1;
445
446 if ((ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL,
447 0, 0, 2, buf)) < 2) {
448 deverr(dev, "Error reading RX_CTL register: %02x", ret);
449 goto out2;
450 }
451 ret = le16_to_cpu(*((u16 *)buf));
452out2:
453 kfree(buf);
454out1:
455 return ret;
456}
457
458static int asix_write_rx_ctl(struct usbnet *dev, u16 mode)
459{
460 int ret;
461
462 devdbg(dev,"asix_write_rx_ctl() - mode = 0x%04x", mode);
463 ret = asix_write_cmd(dev, AX_CMD_WRITE_RX_CTL, mode, 0, 0, NULL);
464 if (ret < 0)
465 deverr(dev, "Failed to write RX_CTL mode to 0x%04x: %02x",
466 mode, ret);
467
468 return ret;
469}
470
471static u16 asix_read_medium_status(struct usbnet *dev)
472{
473 u16 ret = 0;
474 void *buf;
475
476 buf = kmalloc(2, GFP_KERNEL);
477 if (!buf)
478 goto out1;
479
480 if ((ret = asix_read_cmd(dev, AX_CMD_READ_MEDIUM_STATUS,
481 0, 0, 2, buf)) < 2) {
482 deverr(dev, "Error reading Medium Status register: %02x", ret);
483 goto out2;
484 }
485 ret = le16_to_cpu(*((u16 *)buf));
486out2:
487 kfree(buf);
488out1:
489 return ret;
490}
491
492static int asix_write_medium_mode(struct usbnet *dev, u16 mode)
493{
494 int ret;
495
496 devdbg(dev,"asix_write_medium_mode() - mode = 0x%04x", mode);
497 ret = asix_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL);
498 if (ret < 0)
499 deverr(dev, "Failed to write Medium Mode mode to 0x%04x: %02x",
500 mode, ret);
501
502 return ret;
503}
504
505static int asix_write_gpio(struct usbnet *dev, u16 value, int sleep)
506{
507 int ret;
508
509 devdbg(dev,"asix_write_gpio() - value = 0x%04x", value);
510 ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, value, 0, 0, NULL);
511 if (ret < 0)
512 deverr(dev, "Failed to write GPIO value 0x%04x: %02x",
513 value, ret);
514
515 if (sleep)
516 msleep(sleep);
517
518 return ret;
519}
520
521/*
522 * AX88772 & AX88178 have a 16-bit RX_CTL value
523 */
David Hollis48b1be62006-03-28 20:15:42 -0500524static void asix_set_multicast(struct net_device *net)
David Brownell2e55cc72005-08-31 09:53:10 -0700525{
526 struct usbnet *dev = netdev_priv(net);
David Hollis48b1be62006-03-28 20:15:42 -0500527 struct asix_data *data = (struct asix_data *)&dev->data;
David Hollis933a27d2006-07-29 10:12:50 -0400528 u16 rx_ctl = AX_DEFAULT_RX_CTL;
David Brownell2e55cc72005-08-31 09:53:10 -0700529
530 if (net->flags & IFF_PROMISC) {
David Hollis933a27d2006-07-29 10:12:50 -0400531 rx_ctl |= AX_RX_CTL_PRO;
David Brownell2e55cc72005-08-31 09:53:10 -0700532 } else if (net->flags & IFF_ALLMULTI
533 || net->mc_count > AX_MAX_MCAST) {
David Hollis933a27d2006-07-29 10:12:50 -0400534 rx_ctl |= AX_RX_CTL_AMALL;
David Brownell2e55cc72005-08-31 09:53:10 -0700535 } else if (net->mc_count == 0) {
536 /* just broadcast and directed */
537 } else {
538 /* We use the 20 byte dev->data
539 * for our 8 byte filter buffer
540 * to avoid allocating memory that
541 * is tricky to free later */
542 struct dev_mc_list *mc_list = net->mc_list;
543 u32 crc_bits;
544 int i;
545
546 memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE);
547
548 /* Build the multicast hash filter. */
549 for (i = 0; i < net->mc_count; i++) {
550 crc_bits =
551 ether_crc(ETH_ALEN,
552 mc_list->dmi_addr) >> 26;
553 data->multi_filter[crc_bits >> 3] |=
554 1 << (crc_bits & 7);
555 mc_list = mc_list->next;
556 }
557
David Hollis48b1be62006-03-28 20:15:42 -0500558 asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0,
David Brownell2e55cc72005-08-31 09:53:10 -0700559 AX_MCAST_FILTER_SIZE, data->multi_filter);
560
David Hollis933a27d2006-07-29 10:12:50 -0400561 rx_ctl |= AX_RX_CTL_AM;
David Brownell2e55cc72005-08-31 09:53:10 -0700562 }
563
David Hollis48b1be62006-03-28 20:15:42 -0500564 asix_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL);
David Brownell2e55cc72005-08-31 09:53:10 -0700565}
566
David Hollis48b1be62006-03-28 20:15:42 -0500567static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc)
David Brownell2e55cc72005-08-31 09:53:10 -0700568{
569 struct usbnet *dev = netdev_priv(netdev);
570 u16 res;
David Brownell2e55cc72005-08-31 09:53:10 -0700571
David Hollis48b1be62006-03-28 20:15:42 -0500572 asix_set_sw_mii(dev);
573 asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id,
David Brownell2e55cc72005-08-31 09:53:10 -0700574 (__u16)loc, 2, (u16 *)&res);
David Hollis48b1be62006-03-28 20:15:42 -0500575 asix_set_hw_mii(dev);
David Brownell2e55cc72005-08-31 09:53:10 -0700576
David Hollis933a27d2006-07-29 10:12:50 -0400577 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 -0700578
David Hollis933a27d2006-07-29 10:12:50 -0400579 return le16_to_cpu(res & 0xffff);
David Brownell2e55cc72005-08-31 09:53:10 -0700580}
581
582static void
David Hollis48b1be62006-03-28 20:15:42 -0500583asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
David Brownell2e55cc72005-08-31 09:53:10 -0700584{
585 struct usbnet *dev = netdev_priv(netdev);
David Hollis933a27d2006-07-29 10:12:50 -0400586 u16 res = cpu_to_le16(val);
David Brownell2e55cc72005-08-31 09:53:10 -0700587
David Hollis933a27d2006-07-29 10:12:50 -0400588 devdbg(dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x", phy_id, loc, val);
David Hollis48b1be62006-03-28 20:15:42 -0500589 asix_set_sw_mii(dev);
590 asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id,
David Brownell2e55cc72005-08-31 09:53:10 -0700591 (__u16)loc, 2, (u16 *)&res);
David Hollis48b1be62006-03-28 20:15:42 -0500592 asix_set_hw_mii(dev);
David Brownell2e55cc72005-08-31 09:53:10 -0700593}
594
David Hollis933a27d2006-07-29 10:12:50 -0400595/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */
596static u32 asix_get_phyid(struct usbnet *dev)
David Brownell2e55cc72005-08-31 09:53:10 -0700597{
David Hollis933a27d2006-07-29 10:12:50 -0400598 int phy_reg;
599 u32 phy_id;
David Brownell2e55cc72005-08-31 09:53:10 -0700600
David Hollis933a27d2006-07-29 10:12:50 -0400601 phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID1);
602 if (phy_reg < 0)
603 return 0;
David Brownell2e55cc72005-08-31 09:53:10 -0700604
David Hollis933a27d2006-07-29 10:12:50 -0400605 phy_id = (phy_reg & 0xffff) << 16;
David Brownell2e55cc72005-08-31 09:53:10 -0700606
David Hollis933a27d2006-07-29 10:12:50 -0400607 phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID2);
608 if (phy_reg < 0)
609 return 0;
610
611 phy_id |= (phy_reg & 0xffff);
612
613 return phy_id;
David Brownell2e55cc72005-08-31 09:53:10 -0700614}
615
616static void
David Hollis48b1be62006-03-28 20:15:42 -0500617asix_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
David Brownell2e55cc72005-08-31 09:53:10 -0700618{
619 struct usbnet *dev = netdev_priv(net);
620 u8 opt;
621
David Hollis48b1be62006-03-28 20:15:42 -0500622 if (asix_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, &opt) < 0) {
David Brownell2e55cc72005-08-31 09:53:10 -0700623 wolinfo->supported = 0;
624 wolinfo->wolopts = 0;
625 return;
626 }
627 wolinfo->supported = WAKE_PHY | WAKE_MAGIC;
628 wolinfo->wolopts = 0;
629 if (opt & AX_MONITOR_MODE) {
630 if (opt & AX_MONITOR_LINK)
631 wolinfo->wolopts |= WAKE_PHY;
632 if (opt & AX_MONITOR_MAGIC)
633 wolinfo->wolopts |= WAKE_MAGIC;
634 }
635}
636
637static int
David Hollis48b1be62006-03-28 20:15:42 -0500638asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
David Brownell2e55cc72005-08-31 09:53:10 -0700639{
640 struct usbnet *dev = netdev_priv(net);
641 u8 opt = 0;
642 u8 buf[1];
643
644 if (wolinfo->wolopts & WAKE_PHY)
645 opt |= AX_MONITOR_LINK;
646 if (wolinfo->wolopts & WAKE_MAGIC)
647 opt |= AX_MONITOR_MAGIC;
648 if (opt != 0)
649 opt |= AX_MONITOR_MODE;
650
David Hollis48b1be62006-03-28 20:15:42 -0500651 if (asix_write_cmd(dev, AX_CMD_WRITE_MONITOR_MODE,
David Brownell2e55cc72005-08-31 09:53:10 -0700652 opt, 0, 0, &buf) < 0)
653 return -EINVAL;
654
655 return 0;
656}
657
David Hollis48b1be62006-03-28 20:15:42 -0500658static int asix_get_eeprom_len(struct net_device *net)
David Brownell2e55cc72005-08-31 09:53:10 -0700659{
David Hollis933a27d2006-07-29 10:12:50 -0400660 struct usbnet *dev = netdev_priv(net);
661 struct asix_data *data = (struct asix_data *)&dev->data;
662
663 return data->eeprom_len;
David Brownell2e55cc72005-08-31 09:53:10 -0700664}
665
David Hollis48b1be62006-03-28 20:15:42 -0500666static int asix_get_eeprom(struct net_device *net,
David Brownell2e55cc72005-08-31 09:53:10 -0700667 struct ethtool_eeprom *eeprom, u8 *data)
668{
669 struct usbnet *dev = netdev_priv(net);
670 u16 *ebuf = (u16 *)data;
671 int i;
672
673 /* Crude hack to ensure that we don't overwrite memory
674 * if an odd length is supplied
675 */
676 if (eeprom->len % 2)
677 return -EINVAL;
678
679 eeprom->magic = AX_EEPROM_MAGIC;
680
681 /* ax8817x returns 2 bytes from eeprom on read */
682 for (i=0; i < eeprom->len / 2; i++) {
David Hollis48b1be62006-03-28 20:15:42 -0500683 if (asix_read_cmd(dev, AX_CMD_READ_EEPROM,
David Brownell2e55cc72005-08-31 09:53:10 -0700684 eeprom->offset + i, 0, 2, &ebuf[i]) < 0)
685 return -EINVAL;
686 }
687 return 0;
688}
689
David Hollis48b1be62006-03-28 20:15:42 -0500690static void asix_get_drvinfo (struct net_device *net,
David Brownell2e55cc72005-08-31 09:53:10 -0700691 struct ethtool_drvinfo *info)
692{
David Hollis933a27d2006-07-29 10:12:50 -0400693 struct usbnet *dev = netdev_priv(net);
694 struct asix_data *data = (struct asix_data *)&dev->data;
695
David Brownell2e55cc72005-08-31 09:53:10 -0700696 /* Inherit standard device info */
697 usbnet_get_drvinfo(net, info);
David Hollis933a27d2006-07-29 10:12:50 -0400698 strncpy (info->driver, driver_name, sizeof info->driver);
699 strncpy (info->version, DRIVER_VERSION, sizeof info->version);
700 info->eedump_len = data->eeprom_len;
David Brownell2e55cc72005-08-31 09:53:10 -0700701}
702
David Hollis933a27d2006-07-29 10:12:50 -0400703static u32 asix_get_link(struct net_device *net)
704{
705 struct usbnet *dev = netdev_priv(net);
706
707 return mii_link_ok(&dev->mii);
708}
709
710static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd)
711{
712 struct usbnet *dev = netdev_priv(net);
713
714 return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
David Brownell2e55cc72005-08-31 09:53:10 -0700715}
716
717/* We need to override some ethtool_ops so we require our
718 own structure so we don't interfere with other usbnet
719 devices that may be connected at the same time. */
David Hollis48b1be62006-03-28 20:15:42 -0500720static struct ethtool_ops ax88172_ethtool_ops = {
721 .get_drvinfo = asix_get_drvinfo,
David Hollis933a27d2006-07-29 10:12:50 -0400722 .get_link = asix_get_link,
David Brownell2e55cc72005-08-31 09:53:10 -0700723 .get_msglevel = usbnet_get_msglevel,
724 .set_msglevel = usbnet_set_msglevel,
David Hollis48b1be62006-03-28 20:15:42 -0500725 .get_wol = asix_get_wol,
726 .set_wol = asix_set_wol,
727 .get_eeprom_len = asix_get_eeprom_len,
728 .get_eeprom = asix_get_eeprom,
Arnd Bergmannc41286f2006-10-09 00:08:01 +0200729 .get_settings = usbnet_get_settings,
730 .set_settings = usbnet_set_settings,
731 .nway_reset = usbnet_nway_reset,
David Brownell2e55cc72005-08-31 09:53:10 -0700732};
733
David Hollis933a27d2006-07-29 10:12:50 -0400734static void ax88172_set_multicast(struct net_device *net)
David Brownell2e55cc72005-08-31 09:53:10 -0700735{
736 struct usbnet *dev = netdev_priv(net);
David Hollis933a27d2006-07-29 10:12:50 -0400737 struct asix_data *data = (struct asix_data *)&dev->data;
738 u8 rx_ctl = 0x8c;
David Brownell2e55cc72005-08-31 09:53:10 -0700739
David Hollis933a27d2006-07-29 10:12:50 -0400740 if (net->flags & IFF_PROMISC) {
741 rx_ctl |= 0x01;
742 } else if (net->flags & IFF_ALLMULTI
743 || net->mc_count > AX_MAX_MCAST) {
744 rx_ctl |= 0x02;
745 } else if (net->mc_count == 0) {
746 /* just broadcast and directed */
747 } else {
748 /* We use the 20 byte dev->data
749 * for our 8 byte filter buffer
750 * to avoid allocating memory that
751 * is tricky to free later */
752 struct dev_mc_list *mc_list = net->mc_list;
753 u32 crc_bits;
754 int i;
755
756 memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE);
757
758 /* Build the multicast hash filter. */
759 for (i = 0; i < net->mc_count; i++) {
760 crc_bits =
761 ether_crc(ETH_ALEN,
762 mc_list->dmi_addr) >> 26;
763 data->multi_filter[crc_bits >> 3] |=
764 1 << (crc_bits & 7);
765 mc_list = mc_list->next;
766 }
767
768 asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0,
769 AX_MCAST_FILTER_SIZE, data->multi_filter);
770
771 rx_ctl |= 0x10;
772 }
773
774 asix_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL);
775}
776
777static int ax88172_link_reset(struct usbnet *dev)
778{
779 u8 mode;
780 struct ethtool_cmd ecmd;
781
782 mii_check_media(&dev->mii, 1, 1);
783 mii_ethtool_gset(&dev->mii, &ecmd);
784 mode = AX88172_MEDIUM_DEFAULT;
785
786 if (ecmd.duplex != DUPLEX_FULL)
787 mode |= ~AX88172_MEDIUM_FD;
788
789 devdbg(dev, "ax88172_link_reset() speed: %d duplex: %d setting mode to 0x%04x", ecmd.speed, ecmd.duplex, mode);
790
791 asix_write_medium_mode(dev, mode);
792
793 return 0;
David Brownell2e55cc72005-08-31 09:53:10 -0700794}
795
David Hollis48b1be62006-03-28 20:15:42 -0500796static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
David Brownell2e55cc72005-08-31 09:53:10 -0700797{
798 int ret = 0;
799 void *buf;
800 int i;
801 unsigned long gpio_bits = dev->driver_info->data;
David Hollis933a27d2006-07-29 10:12:50 -0400802 struct asix_data *data = (struct asix_data *)&dev->data;
803
804 data->eeprom_len = AX88172_EEPROM_LEN;
David Brownell2e55cc72005-08-31 09:53:10 -0700805
806 usbnet_get_endpoints(dev,intf);
807
808 buf = kmalloc(ETH_ALEN, GFP_KERNEL);
809 if(!buf) {
810 ret = -ENOMEM;
811 goto out1;
812 }
813
814 /* Toggle the GPIOs in a manufacturer/model specific way */
815 for (i = 2; i >= 0; i--) {
David Hollis48b1be62006-03-28 20:15:42 -0500816 if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS,
David Brownell2e55cc72005-08-31 09:53:10 -0700817 (gpio_bits >> (i * 8)) & 0xff, 0, 0,
818 buf)) < 0)
819 goto out2;
820 msleep(5);
821 }
822
David Hollis933a27d2006-07-29 10:12:50 -0400823 if ((ret = asix_write_rx_ctl(dev, 0x80)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -0700824 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -0700825
826 /* Get the MAC address */
827 memset(buf, 0, ETH_ALEN);
David Hollis933a27d2006-07-29 10:12:50 -0400828 if ((ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID,
David Brownell2e55cc72005-08-31 09:53:10 -0700829 0, 0, 6, buf)) < 0) {
830 dbg("read AX_CMD_READ_NODE_ID failed: %d", ret);
831 goto out2;
832 }
833 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
834
David Brownell2e55cc72005-08-31 09:53:10 -0700835 /* Initialize MII structure */
836 dev->mii.dev = dev->net;
David Hollis48b1be62006-03-28 20:15:42 -0500837 dev->mii.mdio_read = asix_mdio_read;
838 dev->mii.mdio_write = asix_mdio_write;
David Brownell2e55cc72005-08-31 09:53:10 -0700839 dev->mii.phy_id_mask = 0x3f;
840 dev->mii.reg_num_mask = 0x1f;
David Hollis933a27d2006-07-29 10:12:50 -0400841 dev->mii.phy_id = asix_get_phy_addr(dev);
David Hollis48b1be62006-03-28 20:15:42 -0500842 dev->net->do_ioctl = asix_ioctl;
David Brownell2e55cc72005-08-31 09:53:10 -0700843
David Hollis933a27d2006-07-29 10:12:50 -0400844 dev->net->set_multicast_list = ax88172_set_multicast;
David Hollis48b1be62006-03-28 20:15:42 -0500845 dev->net->ethtool_ops = &ax88172_ethtool_ops;
David Brownell2e55cc72005-08-31 09:53:10 -0700846
David Hollis933a27d2006-07-29 10:12:50 -0400847 asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
848 asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
David Brownell2e55cc72005-08-31 09:53:10 -0700849 ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
850 mii_nway_restart(&dev->mii);
851
852 return 0;
853out2:
854 kfree(buf);
855out1:
856 return ret;
857}
858
859static struct ethtool_ops ax88772_ethtool_ops = {
David Hollis48b1be62006-03-28 20:15:42 -0500860 .get_drvinfo = asix_get_drvinfo,
David Hollis933a27d2006-07-29 10:12:50 -0400861 .get_link = asix_get_link,
David Brownell2e55cc72005-08-31 09:53:10 -0700862 .get_msglevel = usbnet_get_msglevel,
863 .set_msglevel = usbnet_set_msglevel,
David Hollis48b1be62006-03-28 20:15:42 -0500864 .get_wol = asix_get_wol,
865 .set_wol = asix_set_wol,
866 .get_eeprom_len = asix_get_eeprom_len,
867 .get_eeprom = asix_get_eeprom,
Arnd Bergmannc41286f2006-10-09 00:08:01 +0200868 .get_settings = usbnet_get_settings,
869 .set_settings = usbnet_set_settings,
870 .nway_reset = usbnet_nway_reset,
David Brownell2e55cc72005-08-31 09:53:10 -0700871};
872
David Hollis933a27d2006-07-29 10:12:50 -0400873static int ax88772_link_reset(struct usbnet *dev)
874{
875 u16 mode;
876 struct ethtool_cmd ecmd;
877
878 mii_check_media(&dev->mii, 1, 1);
879 mii_ethtool_gset(&dev->mii, &ecmd);
880 mode = AX88772_MEDIUM_DEFAULT;
881
882 if (ecmd.speed != SPEED_100)
883 mode &= ~AX_MEDIUM_PS;
884
885 if (ecmd.duplex != DUPLEX_FULL)
886 mode &= ~AX_MEDIUM_FD;
887
888 devdbg(dev, "ax88772_link_reset() speed: %d duplex: %d setting mode to 0x%04x", ecmd.speed, ecmd.duplex, mode);
889
890 asix_write_medium_mode(dev, mode);
891
892 return 0;
893}
894
David Brownell2e55cc72005-08-31 09:53:10 -0700895static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
896{
897 int ret;
898 void *buf;
David Hollis933a27d2006-07-29 10:12:50 -0400899 u16 rx_ctl;
900 struct asix_data *data = (struct asix_data *)&dev->data;
901 u32 phyid;
902
903 data->eeprom_len = AX88772_EEPROM_LEN;
David Brownell2e55cc72005-08-31 09:53:10 -0700904
905 usbnet_get_endpoints(dev,intf);
906
907 buf = kmalloc(6, GFP_KERNEL);
908 if(!buf) {
909 dbg ("Cannot allocate memory for buffer");
910 ret = -ENOMEM;
911 goto out1;
912 }
913
David Hollis933a27d2006-07-29 10:12:50 -0400914 if ((ret = asix_write_gpio(dev,
915 AX_GPIO_RSE | AX_GPIO_GPO_2 | AX_GPIO_GPO2EN, 5)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -0700916 goto out2;
917
David Hollis48b1be62006-03-28 20:15:42 -0500918 if ((ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT,
David Hollis933a27d2006-07-29 10:12:50 -0400919 0x0000, 0, 0, buf)) < 0) {
David Brownell2e55cc72005-08-31 09:53:10 -0700920 dbg("Select PHY #1 failed: %d", ret);
921 goto out2;
922 }
923
David Hollis48b1be62006-03-28 20:15:42 -0500924 if ((ret = asix_sw_reset(dev, AX_SWRESET_IPPD)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -0700925 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -0700926
927 msleep(150);
David Hollis48b1be62006-03-28 20:15:42 -0500928 if ((ret = asix_sw_reset(dev, AX_SWRESET_CLEAR)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -0700929 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -0700930
931 msleep(150);
David Hollis48b1be62006-03-28 20:15:42 -0500932 if ((ret = asix_sw_reset(dev, AX_SWRESET_IPRL | AX_SWRESET_PRL)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -0700933 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -0700934
935 msleep(150);
David Hollis933a27d2006-07-29 10:12:50 -0400936 rx_ctl = asix_read_rx_ctl(dev);
937 dbg("RX_CTL is 0x%04x after software reset", rx_ctl);
938 if ((ret = asix_write_rx_ctl(dev, 0x0000)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -0700939 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -0700940
David Hollis933a27d2006-07-29 10:12:50 -0400941 rx_ctl = asix_read_rx_ctl(dev);
942 dbg("RX_CTL is 0x%04x setting to 0x0000", rx_ctl);
943
David Brownell2e55cc72005-08-31 09:53:10 -0700944 /* Get the MAC address */
945 memset(buf, 0, ETH_ALEN);
David Hollis933a27d2006-07-29 10:12:50 -0400946 if ((ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID,
David Brownell2e55cc72005-08-31 09:53:10 -0700947 0, 0, ETH_ALEN, buf)) < 0) {
948 dbg("Failed to read MAC address: %d", ret);
949 goto out2;
950 }
951 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
952
David Brownell2e55cc72005-08-31 09:53:10 -0700953 /* Initialize MII structure */
954 dev->mii.dev = dev->net;
David Hollis48b1be62006-03-28 20:15:42 -0500955 dev->mii.mdio_read = asix_mdio_read;
956 dev->mii.mdio_write = asix_mdio_write;
David Hollis933a27d2006-07-29 10:12:50 -0400957 dev->mii.phy_id_mask = 0x1f;
958 dev->mii.reg_num_mask = 0x1f;
David Hollis48b1be62006-03-28 20:15:42 -0500959 dev->net->do_ioctl = asix_ioctl;
David Hollis933a27d2006-07-29 10:12:50 -0400960 dev->mii.phy_id = asix_get_phy_addr(dev);
961
962 phyid = asix_get_phyid(dev);
963 dbg("PHYID=0x%08x", phyid);
David Brownell2e55cc72005-08-31 09:53:10 -0700964
David Hollis48b1be62006-03-28 20:15:42 -0500965 if ((ret = asix_sw_reset(dev, AX_SWRESET_PRL)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -0700966 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -0700967
David Brownell2e55cc72005-08-31 09:53:10 -0700968 msleep(150);
969
David Hollis48b1be62006-03-28 20:15:42 -0500970 if ((ret = asix_sw_reset(dev, AX_SWRESET_IPRL | AX_SWRESET_PRL)) < 0)
971 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -0700972
David Hollis48b1be62006-03-28 20:15:42 -0500973 msleep(150);
974
975 dev->net->set_multicast_list = asix_set_multicast;
David Brownell2e55cc72005-08-31 09:53:10 -0700976 dev->net->ethtool_ops = &ax88772_ethtool_ops;
977
David Hollis933a27d2006-07-29 10:12:50 -0400978 asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
979 asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
David Brownell2e55cc72005-08-31 09:53:10 -0700980 ADVERTISE_ALL | ADVERTISE_CSMA);
981 mii_nway_restart(&dev->mii);
982
David Hollis933a27d2006-07-29 10:12:50 -0400983 if ((ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -0700984 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -0700985
David Hollis48b1be62006-03-28 20:15:42 -0500986 if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0,
David Brownell2e55cc72005-08-31 09:53:10 -0700987 AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,
988 AX88772_IPG2_DEFAULT, 0, buf)) < 0) {
989 dbg("Write IPG,IPG1,IPG2 failed: %d", ret);
990 goto out2;
991 }
David Brownell2e55cc72005-08-31 09:53:10 -0700992
993 /* Set RX_CTL to default values with 2k buffer, and enable cactus */
David Hollis933a27d2006-07-29 10:12:50 -0400994 if ((ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL)) < 0)
David Brownell2e55cc72005-08-31 09:53:10 -0700995 goto out2;
David Brownell2e55cc72005-08-31 09:53:10 -0700996
David Hollis933a27d2006-07-29 10:12:50 -0400997 rx_ctl = asix_read_rx_ctl(dev);
998 dbg("RX_CTL is 0x%04x after all initializations", rx_ctl);
999
1000 rx_ctl = asix_read_medium_status(dev);
1001 dbg("Medium Status is 0x%04x after all initializations", rx_ctl);
1002
David Brownell2e55cc72005-08-31 09:53:10 -07001003 kfree(buf);
1004
1005 /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
1006 if (dev->driver_info->flags & FLAG_FRAMING_AX) {
1007 /* hard_mtu is still the default - the device does not support
1008 jumbo eth frames */
1009 dev->rx_urb_size = 2048;
1010 }
1011
1012 return 0;
1013
1014out2:
1015 kfree(buf);
1016out1:
1017 return ret;
1018}
1019
David Hollis933a27d2006-07-29 10:12:50 -04001020static struct ethtool_ops ax88178_ethtool_ops = {
1021 .get_drvinfo = asix_get_drvinfo,
1022 .get_link = asix_get_link,
David Hollis933a27d2006-07-29 10:12:50 -04001023 .get_msglevel = usbnet_get_msglevel,
1024 .set_msglevel = usbnet_set_msglevel,
1025 .get_wol = asix_get_wol,
1026 .set_wol = asix_set_wol,
1027 .get_eeprom_len = asix_get_eeprom_len,
1028 .get_eeprom = asix_get_eeprom,
Arnd Bergmannc41286f2006-10-09 00:08:01 +02001029 .get_settings = usbnet_get_settings,
1030 .set_settings = usbnet_set_settings,
1031 .nway_reset = usbnet_nway_reset,
David Hollis933a27d2006-07-29 10:12:50 -04001032};
1033
1034static int marvell_phy_init(struct usbnet *dev)
David Brownell2e55cc72005-08-31 09:53:10 -07001035{
David Hollis933a27d2006-07-29 10:12:50 -04001036 struct asix_data *data = (struct asix_data *)&dev->data;
1037 u16 reg;
David Brownell2e55cc72005-08-31 09:53:10 -07001038
David Hollis933a27d2006-07-29 10:12:50 -04001039 devdbg(dev,"marvell_phy_init()");
David Brownell2e55cc72005-08-31 09:53:10 -07001040
David Hollis933a27d2006-07-29 10:12:50 -04001041 reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_MARVELL_STATUS);
1042 devdbg(dev,"MII_MARVELL_STATUS = 0x%04x", reg);
David Brownell2e55cc72005-08-31 09:53:10 -07001043
David Hollis933a27d2006-07-29 10:12:50 -04001044 asix_mdio_write(dev->net, dev->mii.phy_id, MII_MARVELL_CTRL,
1045 MARVELL_CTRL_RXDELAY | MARVELL_CTRL_TXDELAY);
David Brownell2e55cc72005-08-31 09:53:10 -07001046
David Hollis933a27d2006-07-29 10:12:50 -04001047 if (data->ledmode) {
1048 reg = asix_mdio_read(dev->net, dev->mii.phy_id,
1049 MII_MARVELL_LED_CTRL);
1050 devdbg(dev,"MII_MARVELL_LED_CTRL (1) = 0x%04x", reg);
David Brownell2e55cc72005-08-31 09:53:10 -07001051
David Hollis933a27d2006-07-29 10:12:50 -04001052 reg &= 0xf8ff;
1053 reg |= (1 + 0x0100);
1054 asix_mdio_write(dev->net, dev->mii.phy_id,
1055 MII_MARVELL_LED_CTRL, reg);
David Brownell2e55cc72005-08-31 09:53:10 -07001056
David Hollis933a27d2006-07-29 10:12:50 -04001057 reg = asix_mdio_read(dev->net, dev->mii.phy_id,
1058 MII_MARVELL_LED_CTRL);
1059 devdbg(dev,"MII_MARVELL_LED_CTRL (2) = 0x%04x", reg);
1060 reg &= 0xfc0f;
David Brownell2e55cc72005-08-31 09:53:10 -07001061 }
1062
David Brownell2e55cc72005-08-31 09:53:10 -07001063 return 0;
1064}
1065
David Hollis933a27d2006-07-29 10:12:50 -04001066static int marvell_led_status(struct usbnet *dev, u16 speed)
1067{
1068 u16 reg = asix_mdio_read(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL);
1069
1070 devdbg(dev, "marvell_led_status() read 0x%04x", reg);
1071
1072 /* Clear out the center LED bits - 0x03F0 */
1073 reg &= 0xfc0f;
1074
1075 switch (speed) {
1076 case SPEED_1000:
1077 reg |= 0x03e0;
1078 break;
1079 case SPEED_100:
1080 reg |= 0x03b0;
1081 break;
1082 default:
1083 reg |= 0x02f0;
1084 }
1085
1086 devdbg(dev, "marvell_led_status() writing 0x%04x", reg);
1087 asix_mdio_write(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL, reg);
1088
1089 return 0;
1090}
1091
1092static int ax88178_link_reset(struct usbnet *dev)
1093{
1094 u16 mode;
1095 struct ethtool_cmd ecmd;
1096 struct asix_data *data = (struct asix_data *)&dev->data;
1097
1098 devdbg(dev,"ax88178_link_reset()");
1099
1100 mii_check_media(&dev->mii, 1, 1);
1101 mii_ethtool_gset(&dev->mii, &ecmd);
1102 mode = AX88178_MEDIUM_DEFAULT;
1103
1104 if (ecmd.speed == SPEED_1000)
1105 mode |= AX_MEDIUM_GM | AX_MEDIUM_ENCK;
1106 else if (ecmd.speed == SPEED_100)
1107 mode |= AX_MEDIUM_PS;
1108 else
1109 mode &= ~(AX_MEDIUM_PS | AX_MEDIUM_GM);
1110
1111 if (ecmd.duplex == DUPLEX_FULL)
1112 mode |= AX_MEDIUM_FD;
1113 else
1114 mode &= ~AX_MEDIUM_FD;
1115
1116 devdbg(dev, "ax88178_link_reset() speed: %d duplex: %d setting mode to 0x%04x", ecmd.speed, ecmd.duplex, mode);
1117
1118 asix_write_medium_mode(dev, mode);
1119
1120 if (data->phymode == PHY_MODE_MARVELL && data->ledmode)
1121 marvell_led_status(dev, ecmd.speed);
1122
1123 return 0;
1124}
1125
1126static void ax88178_set_mfb(struct usbnet *dev)
1127{
1128 u16 mfb = AX_RX_CTL_MFB_16384;
1129 u16 rxctl;
1130 u16 medium;
1131 int old_rx_urb_size = dev->rx_urb_size;
1132
1133 if (dev->hard_mtu < 2048) {
1134 dev->rx_urb_size = 2048;
1135 mfb = AX_RX_CTL_MFB_2048;
1136 } else if (dev->hard_mtu < 4096) {
1137 dev->rx_urb_size = 4096;
1138 mfb = AX_RX_CTL_MFB_4096;
1139 } else if (dev->hard_mtu < 8192) {
1140 dev->rx_urb_size = 8192;
1141 mfb = AX_RX_CTL_MFB_8192;
1142 } else if (dev->hard_mtu < 16384) {
1143 dev->rx_urb_size = 16384;
1144 mfb = AX_RX_CTL_MFB_16384;
1145 }
1146
1147 rxctl = asix_read_rx_ctl(dev);
1148 asix_write_rx_ctl(dev, (rxctl & ~AX_RX_CTL_MFB_16384) | mfb);
1149
1150 medium = asix_read_medium_status(dev);
1151 if (dev->net->mtu > 1500)
1152 medium |= AX_MEDIUM_JFE;
1153 else
1154 medium &= ~AX_MEDIUM_JFE;
1155 asix_write_medium_mode(dev, medium);
1156
1157 if (dev->rx_urb_size > old_rx_urb_size)
1158 usbnet_unlink_rx_urbs(dev);
1159}
1160
1161static int ax88178_change_mtu(struct net_device *net, int new_mtu)
1162{
1163 struct usbnet *dev = netdev_priv(net);
1164 int ll_mtu = new_mtu + net->hard_header_len + 4;
1165
1166 devdbg(dev, "ax88178_change_mtu() new_mtu=%d", new_mtu);
1167
1168 if (new_mtu <= 0 || ll_mtu > 16384)
1169 return -EINVAL;
1170
1171 if ((ll_mtu % dev->maxpacket) == 0)
1172 return -EDOM;
1173
1174 net->mtu = new_mtu;
1175 dev->hard_mtu = net->mtu + net->hard_header_len;
1176 ax88178_set_mfb(dev);
1177
1178 return 0;
1179}
1180
1181static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
1182{
1183 struct asix_data *data = (struct asix_data *)&dev->data;
1184 int ret;
1185 void *buf;
1186 u16 eeprom;
1187 int gpio0 = 0;
1188 u32 phyid;
1189
1190 usbnet_get_endpoints(dev,intf);
1191
1192 buf = kmalloc(6, GFP_KERNEL);
1193 if(!buf) {
1194 dbg ("Cannot allocate memory for buffer");
1195 ret = -ENOMEM;
1196 goto out1;
1197 }
1198
1199 eeprom = 0;
1200 asix_read_cmd(dev, AX_CMD_READ_GPIOS, 0, 0, 1, &eeprom);
1201 dbg("GPIO Status: 0x%04x", eeprom);
1202
1203 asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0, 0, 0, NULL);
1204 asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2, &eeprom);
1205 asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0, 0, 0, NULL);
1206
1207 dbg("EEPROM index 0x17 is 0x%04x", eeprom);
1208
1209 if (eeprom == 0xffff) {
1210 data->phymode = PHY_MODE_MARVELL;
1211 data->ledmode = 0;
1212 gpio0 = 1;
1213 } else {
1214 data->phymode = eeprom & 7;
1215 data->ledmode = eeprom >> 8;
1216 gpio0 = (eeprom & 0x80) ? 0 : 1;
1217 }
1218 dbg("GPIO0: %d, PhyMode: %d", gpio0, data->phymode);
1219
1220 asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_1 | AX_GPIO_GPO1EN, 40);
1221 if ((eeprom >> 8) != 1) {
1222 asix_write_gpio(dev, 0x003c, 30);
1223 asix_write_gpio(dev, 0x001c, 300);
1224 asix_write_gpio(dev, 0x003c, 30);
1225 } else {
1226 dbg("gpio phymode == 1 path");
1227 asix_write_gpio(dev, AX_GPIO_GPO1EN, 30);
1228 asix_write_gpio(dev, AX_GPIO_GPO1EN | AX_GPIO_GPO_1, 30);
1229 }
1230
1231 asix_sw_reset(dev, 0);
1232 msleep(150);
1233
1234 asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD);
1235 msleep(150);
1236
1237 asix_write_rx_ctl(dev, 0);
1238
1239 /* Get the MAC address */
1240 memset(buf, 0, ETH_ALEN);
1241 if ((ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID,
1242 0, 0, ETH_ALEN, buf)) < 0) {
1243 dbg("Failed to read MAC address: %d", ret);
1244 goto out2;
1245 }
1246 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
1247
1248 /* Initialize MII structure */
1249 dev->mii.dev = dev->net;
1250 dev->mii.mdio_read = asix_mdio_read;
1251 dev->mii.mdio_write = asix_mdio_write;
1252 dev->mii.phy_id_mask = 0x1f;
1253 dev->mii.reg_num_mask = 0xff;
1254 dev->mii.supports_gmii = 1;
1255 dev->net->do_ioctl = asix_ioctl;
1256 dev->mii.phy_id = asix_get_phy_addr(dev);
1257 dev->net->set_multicast_list = asix_set_multicast;
1258 dev->net->ethtool_ops = &ax88178_ethtool_ops;
1259 dev->net->change_mtu = &ax88178_change_mtu;
1260
1261 phyid = asix_get_phyid(dev);
1262 dbg("PHYID=0x%08x", phyid);
1263
1264 if (data->phymode == PHY_MODE_MARVELL) {
1265 marvell_phy_init(dev);
1266 msleep(60);
1267 }
1268
1269 asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR,
1270 BMCR_RESET | BMCR_ANENABLE);
1271 asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
1272 ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
1273 asix_mdio_write(dev->net, dev->mii.phy_id, MII_CTRL1000,
1274 ADVERTISE_1000FULL);
1275
1276 mii_nway_restart(&dev->mii);
1277
1278 if ((ret = asix_write_medium_mode(dev, AX88178_MEDIUM_DEFAULT)) < 0)
1279 goto out2;
1280
1281 if ((ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL)) < 0)
1282 goto out2;
1283
1284 kfree(buf);
1285
1286 /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
1287 if (dev->driver_info->flags & FLAG_FRAMING_AX) {
1288 /* hard_mtu is still the default - the device does not support
1289 jumbo eth frames */
1290 dev->rx_urb_size = 2048;
1291 }
1292
1293 return 0;
1294
1295out2:
1296 kfree(buf);
1297out1:
1298 return ret;
1299}
1300
David Brownell2e55cc72005-08-31 09:53:10 -07001301static const struct driver_info ax8817x_info = {
1302 .description = "ASIX AX8817x USB 2.0 Ethernet",
David Hollis48b1be62006-03-28 20:15:42 -05001303 .bind = ax88172_bind,
1304 .status = asix_status,
David Brownell2e55cc72005-08-31 09:53:10 -07001305 .link_reset = ax88172_link_reset,
1306 .reset = ax88172_link_reset,
1307 .flags = FLAG_ETHER,
1308 .data = 0x00130103,
1309};
1310
1311static const struct driver_info dlink_dub_e100_info = {
1312 .description = "DLink DUB-E100 USB Ethernet",
David Hollis48b1be62006-03-28 20:15:42 -05001313 .bind = ax88172_bind,
1314 .status = asix_status,
David Brownell2e55cc72005-08-31 09:53:10 -07001315 .link_reset = ax88172_link_reset,
1316 .reset = ax88172_link_reset,
1317 .flags = FLAG_ETHER,
1318 .data = 0x009f9d9f,
1319};
1320
1321static const struct driver_info netgear_fa120_info = {
1322 .description = "Netgear FA-120 USB Ethernet",
David Hollis48b1be62006-03-28 20:15:42 -05001323 .bind = ax88172_bind,
1324 .status = asix_status,
David Brownell2e55cc72005-08-31 09:53:10 -07001325 .link_reset = ax88172_link_reset,
1326 .reset = ax88172_link_reset,
1327 .flags = FLAG_ETHER,
1328 .data = 0x00130103,
1329};
1330
1331static const struct driver_info hawking_uf200_info = {
1332 .description = "Hawking UF200 USB Ethernet",
David Hollis48b1be62006-03-28 20:15:42 -05001333 .bind = ax88172_bind,
1334 .status = asix_status,
David Brownell2e55cc72005-08-31 09:53:10 -07001335 .link_reset = ax88172_link_reset,
1336 .reset = ax88172_link_reset,
1337 .flags = FLAG_ETHER,
1338 .data = 0x001f1d1f,
1339};
1340
1341static const struct driver_info ax88772_info = {
1342 .description = "ASIX AX88772 USB 2.0 Ethernet",
1343 .bind = ax88772_bind,
David Hollis48b1be62006-03-28 20:15:42 -05001344 .status = asix_status,
David Brownell2e55cc72005-08-31 09:53:10 -07001345 .link_reset = ax88772_link_reset,
1346 .reset = ax88772_link_reset,
1347 .flags = FLAG_ETHER | FLAG_FRAMING_AX,
David Hollis933a27d2006-07-29 10:12:50 -04001348 .rx_fixup = asix_rx_fixup,
1349 .tx_fixup = asix_tx_fixup,
1350};
1351
1352static const struct driver_info ax88178_info = {
1353 .description = "ASIX AX88178 USB 2.0 Ethernet",
1354 .bind = ax88178_bind,
1355 .status = asix_status,
1356 .link_reset = ax88178_link_reset,
1357 .reset = ax88178_link_reset,
1358 .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1359 .rx_fixup = asix_rx_fixup,
1360 .tx_fixup = asix_tx_fixup,
David Brownell2e55cc72005-08-31 09:53:10 -07001361};
1362
1363static const struct usb_device_id products [] = {
1364{
1365 // Linksys USB200M
1366 USB_DEVICE (0x077b, 0x2226),
1367 .driver_info = (unsigned long) &ax8817x_info,
1368}, {
1369 // Netgear FA120
1370 USB_DEVICE (0x0846, 0x1040),
1371 .driver_info = (unsigned long) &netgear_fa120_info,
1372}, {
1373 // DLink DUB-E100
1374 USB_DEVICE (0x2001, 0x1a00),
1375 .driver_info = (unsigned long) &dlink_dub_e100_info,
1376}, {
1377 // Intellinet, ST Lab USB Ethernet
1378 USB_DEVICE (0x0b95, 0x1720),
1379 .driver_info = (unsigned long) &ax8817x_info,
1380}, {
1381 // Hawking UF200, TrendNet TU2-ET100
1382 USB_DEVICE (0x07b8, 0x420a),
1383 .driver_info = (unsigned long) &hawking_uf200_info,
1384}, {
1385 // Billionton Systems, USB2AR
1386 USB_DEVICE (0x08dd, 0x90ff),
1387 .driver_info = (unsigned long) &ax8817x_info,
1388}, {
1389 // ATEN UC210T
1390 USB_DEVICE (0x0557, 0x2009),
1391 .driver_info = (unsigned long) &ax8817x_info,
1392}, {
1393 // Buffalo LUA-U2-KTX
1394 USB_DEVICE (0x0411, 0x003d),
1395 .driver_info = (unsigned long) &ax8817x_info,
1396}, {
1397 // Sitecom LN-029 "USB 2.0 10/100 Ethernet adapter"
1398 USB_DEVICE (0x6189, 0x182d),
1399 .driver_info = (unsigned long) &ax8817x_info,
1400}, {
1401 // corega FEther USB2-TX
1402 USB_DEVICE (0x07aa, 0x0017),
1403 .driver_info = (unsigned long) &ax8817x_info,
1404}, {
1405 // Surecom EP-1427X-2
1406 USB_DEVICE (0x1189, 0x0893),
1407 .driver_info = (unsigned long) &ax8817x_info,
1408}, {
1409 // goodway corp usb gwusb2e
1410 USB_DEVICE (0x1631, 0x6200),
1411 .driver_info = (unsigned long) &ax8817x_info,
1412}, {
1413 // ASIX AX88772 10/100
1414 USB_DEVICE (0x0b95, 0x7720),
1415 .driver_info = (unsigned long) &ax88772_info,
David Hollis5e0f76c2005-12-19 13:58:38 -05001416}, {
Eduard Warkentin73274132006-05-18 01:13:17 -07001417 // ASIX AX88178 10/100/1000
1418 USB_DEVICE (0x0b95, 0x1780),
David Hollis933a27d2006-07-29 10:12:50 -04001419 .driver_info = (unsigned long) &ax88178_info,
Eduard Warkentin73274132006-05-18 01:13:17 -07001420}, {
David Hollis5e0f76c2005-12-19 13:58:38 -05001421 // Linksys USB200M Rev 2
1422 USB_DEVICE (0x13b1, 0x0018),
1423 .driver_info = (unsigned long) &ax88772_info,
David Hollis5732ce82006-01-05 14:39:49 -05001424}, {
1425 // 0Q0 cable ethernet
1426 USB_DEVICE (0x1557, 0x7720),
1427 .driver_info = (unsigned long) &ax88772_info,
David Hollis933a27d2006-07-29 10:12:50 -04001428}, {
1429 // DLink DUB-E100 H/W Ver B1
1430 USB_DEVICE (0x07d1, 0x3c05),
1431 .driver_info = (unsigned long) &ax88772_info,
1432}, {
David Hollisb923e7f2006-09-21 08:09:29 -04001433 // DLink DUB-E100 H/W Ver B1 Alternate
1434 USB_DEVICE (0x2001, 0x3c05),
1435 .driver_info = (unsigned long) &ax88772_info,
1436}, {
David Hollis933a27d2006-07-29 10:12:50 -04001437 // Linksys USB1000
1438 USB_DEVICE (0x1737, 0x0039),
1439 .driver_info = (unsigned long) &ax88178_info,
David Brownell2e55cc72005-08-31 09:53:10 -07001440},
1441 { }, // END
1442};
1443MODULE_DEVICE_TABLE(usb, products);
1444
1445static struct usb_driver asix_driver = {
David Brownell2e55cc72005-08-31 09:53:10 -07001446 .name = "asix",
1447 .id_table = products,
1448 .probe = usbnet_probe,
1449 .suspend = usbnet_suspend,
1450 .resume = usbnet_resume,
1451 .disconnect = usbnet_disconnect,
1452};
1453
1454static int __init asix_init(void)
1455{
1456 return usb_register(&asix_driver);
1457}
1458module_init(asix_init);
1459
1460static void __exit asix_exit(void)
1461{
1462 usb_deregister(&asix_driver);
1463}
1464module_exit(asix_exit);
1465
1466MODULE_AUTHOR("David Hollis");
1467MODULE_DESCRIPTION("ASIX AX8817X based USB 2.0 Ethernet Devices");
1468MODULE_LICENSE("GPL");
1469