]> Pileus Git - ~andy/linux/blob - drivers/net/usb/mcs7830.c
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next
[~andy/linux] / drivers / net / usb / mcs7830.c
1 /*
2  * MOSCHIP MCS7830 based (7730/7830/7832) USB 2.0 Ethernet Devices
3  *
4  * based on usbnet.c, asix.c and the vendor provided mcs7830 driver
5  *
6  * Copyright (C) 2010 Andreas Mohr <andi@lisas.de>
7  * Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de>
8  * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
9  * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net>
10  * Copyright (c) 2002-2003 TiVo Inc.
11  *
12  * Definitions gathered from MOSCHIP, Data Sheet_7830DA.pdf (thanks!).
13  *
14  * 2010-12-19: add 7832 USB PID ("functionality same as MCS7830"),
15  *             per active notification by manufacturer
16  *
17  * TODO:
18  * - support HIF_REG_CONFIG_SLEEPMODE/HIF_REG_CONFIG_TXENABLE (via autopm?)
19  * - implement ethtool_ops get_pauseparam/set_pauseparam
20  *   via HIF_REG_PAUSE_THRESHOLD (>= revision C only!)
21  * - implement get_eeprom/[set_eeprom]
22  * - switch PHY on/off on ifup/ifdown (perhaps in usbnet.c, via MII)
23  * - mcs7830_get_regs() handling is weird: for rev 2 we return 32 regs,
24  *   can access only ~ 24, remaining user buffer is uninitialized garbage
25  * - anything else?
26  *
27  *
28  * This program is free software; you can redistribute it and/or modify
29  * it under the terms of the GNU General Public License as published by
30  * the Free Software Foundation; either version 2 of the License, or
31  * (at your option) any later version.
32  *
33  * This program is distributed in the hope that it will be useful,
34  * but WITHOUT ANY WARRANTY; without even the implied warranty of
35  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
36  * GNU General Public License for more details.
37  *
38  * You should have received a copy of the GNU General Public License
39  * along with this program; if not, see <http://www.gnu.org/licenses/>.
40  */
41
42 #include <linux/crc32.h>
43 #include <linux/etherdevice.h>
44 #include <linux/ethtool.h>
45 #include <linux/init.h>
46 #include <linux/mii.h>
47 #include <linux/module.h>
48 #include <linux/netdevice.h>
49 #include <linux/slab.h>
50 #include <linux/usb.h>
51 #include <linux/usb/usbnet.h>
52
53 /* requests */
54 #define MCS7830_RD_BMREQ        (USB_DIR_IN  | USB_TYPE_VENDOR | \
55                                  USB_RECIP_DEVICE)
56 #define MCS7830_WR_BMREQ        (USB_DIR_OUT | USB_TYPE_VENDOR | \
57                                  USB_RECIP_DEVICE)
58 #define MCS7830_RD_BREQ         0x0E
59 #define MCS7830_WR_BREQ         0x0D
60
61 #define MCS7830_CTRL_TIMEOUT    1000
62 #define MCS7830_MAX_MCAST       64
63
64 #define MCS7830_VENDOR_ID       0x9710
65 #define MCS7832_PRODUCT_ID      0x7832
66 #define MCS7830_PRODUCT_ID      0x7830
67 #define MCS7730_PRODUCT_ID      0x7730
68
69 #define SITECOM_VENDOR_ID       0x0DF6
70 #define LN_030_PRODUCT_ID       0x0021
71
72 #define MCS7830_MII_ADVERTISE   (ADVERTISE_PAUSE_CAP | ADVERTISE_100FULL | \
73                                  ADVERTISE_100HALF | ADVERTISE_10FULL | \
74                                  ADVERTISE_10HALF | ADVERTISE_CSMA)
75
76 /* HIF_REG_XX corresponding index value */
77 enum {
78         HIF_REG_MULTICAST_HASH                  = 0x00,
79         HIF_REG_PACKET_GAP1                     = 0x08,
80         HIF_REG_PACKET_GAP2                     = 0x09,
81         HIF_REG_PHY_DATA                        = 0x0a,
82         HIF_REG_PHY_CMD1                        = 0x0c,
83            HIF_REG_PHY_CMD1_READ                = 0x40,
84            HIF_REG_PHY_CMD1_WRITE               = 0x20,
85            HIF_REG_PHY_CMD1_PHYADDR             = 0x01,
86         HIF_REG_PHY_CMD2                        = 0x0d,
87            HIF_REG_PHY_CMD2_PEND_FLAG_BIT       = 0x80,
88            HIF_REG_PHY_CMD2_READY_FLAG_BIT      = 0x40,
89         HIF_REG_CONFIG                          = 0x0e,
90         /* hmm, spec sez: "R/W", "Except bit 3" (likely TXENABLE). */
91            HIF_REG_CONFIG_CFG                   = 0x80,
92            HIF_REG_CONFIG_SPEED100              = 0x40,
93            HIF_REG_CONFIG_FULLDUPLEX_ENABLE     = 0x20,
94            HIF_REG_CONFIG_RXENABLE              = 0x10,
95            HIF_REG_CONFIG_TXENABLE              = 0x08,
96            HIF_REG_CONFIG_SLEEPMODE             = 0x04,
97            HIF_REG_CONFIG_ALLMULTICAST          = 0x02,
98            HIF_REG_CONFIG_PROMISCUOUS           = 0x01,
99         HIF_REG_ETHERNET_ADDR                   = 0x0f,
100         HIF_REG_FRAME_DROP_COUNTER              = 0x15, /* 0..ff; reset: 0 */
101         HIF_REG_PAUSE_THRESHOLD                 = 0x16,
102            HIF_REG_PAUSE_THRESHOLD_DEFAULT      = 0,
103 };
104
105 /* Trailing status byte in Ethernet Rx frame */
106 enum {
107         MCS7830_RX_SHORT_FRAME          = 0x01, /* < 64 bytes */
108         MCS7830_RX_LENGTH_ERROR         = 0x02, /* framelen != Ethernet length field */
109         MCS7830_RX_ALIGNMENT_ERROR      = 0x04, /* non-even number of nibbles */
110         MCS7830_RX_CRC_ERROR            = 0x08,
111         MCS7830_RX_LARGE_FRAME          = 0x10, /* > 1518 bytes */
112         MCS7830_RX_FRAME_CORRECT        = 0x20, /* frame is correct */
113         /* [7:6] reserved */
114 };
115
116 struct mcs7830_data {
117         u8 multi_filter[8];
118         u8 config;
119 };
120
121 static const char driver_name[] = "MOSCHIP usb-ethernet driver";
122
123 static int mcs7830_get_reg(struct usbnet *dev, u16 index, u16 size, void *data)
124 {
125         return usbnet_read_cmd(dev, MCS7830_RD_BREQ, MCS7830_RD_BMREQ,
126                                 0x0000, index, data, size);
127 }
128
129 static int mcs7830_set_reg(struct usbnet *dev, u16 index, u16 size, const void *data)
130 {
131         return usbnet_write_cmd(dev, MCS7830_WR_BREQ, MCS7830_WR_BMREQ,
132                                 0x0000, index, data, size);
133 }
134
135 static void mcs7830_set_reg_async(struct usbnet *dev, u16 index, u16 size, void *data)
136 {
137         usbnet_write_cmd_async(dev, MCS7830_WR_BREQ, MCS7830_WR_BMREQ,
138                                 0x0000, index, data, size);
139 }
140
141 static int mcs7830_hif_get_mac_address(struct usbnet *dev, unsigned char *addr)
142 {
143         int ret = mcs7830_get_reg(dev, HIF_REG_ETHERNET_ADDR, ETH_ALEN, addr);
144         if (ret < 0)
145                 return ret;
146         return 0;
147 }
148
149 static int mcs7830_hif_set_mac_address(struct usbnet *dev, unsigned char *addr)
150 {
151         int ret = mcs7830_set_reg(dev, HIF_REG_ETHERNET_ADDR, ETH_ALEN, addr);
152
153         if (ret < 0)
154                 return ret;
155         return 0;
156 }
157
158 static int mcs7830_set_mac_address(struct net_device *netdev, void *p)
159 {
160         int ret;
161         struct usbnet *dev = netdev_priv(netdev);
162         struct sockaddr *addr = p;
163
164         if (netif_running(netdev))
165                 return -EBUSY;
166
167         if (!is_valid_ether_addr(addr->sa_data))
168                 return -EADDRNOTAVAIL;
169
170         ret = mcs7830_hif_set_mac_address(dev, addr->sa_data);
171
172         if (ret < 0)
173                 return ret;
174
175         /* it worked --> adopt it on netdev side */
176         memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
177
178         return 0;
179 }
180
181 static int mcs7830_read_phy(struct usbnet *dev, u8 index)
182 {
183         int ret;
184         int i;
185         __le16 val;
186
187         u8 cmd[2] = {
188                 HIF_REG_PHY_CMD1_READ | HIF_REG_PHY_CMD1_PHYADDR,
189                 HIF_REG_PHY_CMD2_PEND_FLAG_BIT | index,
190         };
191
192         mutex_lock(&dev->phy_mutex);
193         /* write the MII command */
194         ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
195         if (ret < 0)
196                 goto out;
197
198         /* wait for the data to become valid, should be within < 1ms */
199         for (i = 0; i < 10; i++) {
200                 ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
201                 if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT))
202                         break;
203                 ret = -EIO;
204                 msleep(1);
205         }
206         if (ret < 0)
207                 goto out;
208
209         /* read actual register contents */
210         ret = mcs7830_get_reg(dev, HIF_REG_PHY_DATA, 2, &val);
211         if (ret < 0)
212                 goto out;
213         ret = le16_to_cpu(val);
214         dev_dbg(&dev->udev->dev, "read PHY reg %02x: %04x (%d tries)\n",
215                 index, val, i);
216 out:
217         mutex_unlock(&dev->phy_mutex);
218         return ret;
219 }
220
221 static int mcs7830_write_phy(struct usbnet *dev, u8 index, u16 val)
222 {
223         int ret;
224         int i;
225         __le16 le_val;
226
227         u8 cmd[2] = {
228                 HIF_REG_PHY_CMD1_WRITE | HIF_REG_PHY_CMD1_PHYADDR,
229                 HIF_REG_PHY_CMD2_PEND_FLAG_BIT | (index & 0x1F),
230         };
231
232         mutex_lock(&dev->phy_mutex);
233
234         /* write the new register contents */
235         le_val = cpu_to_le16(val);
236         ret = mcs7830_set_reg(dev, HIF_REG_PHY_DATA, 2, &le_val);
237         if (ret < 0)
238                 goto out;
239
240         /* write the MII command */
241         ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
242         if (ret < 0)
243                 goto out;
244
245         /* wait for the command to be accepted by the PHY */
246         for (i = 0; i < 10; i++) {
247                 ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
248                 if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT))
249                         break;
250                 ret = -EIO;
251                 msleep(1);
252         }
253         if (ret < 0)
254                 goto out;
255
256         ret = 0;
257         dev_dbg(&dev->udev->dev, "write PHY reg %02x: %04x (%d tries)\n",
258                 index, val, i);
259 out:
260         mutex_unlock(&dev->phy_mutex);
261         return ret;
262 }
263
264 /*
265  * This algorithm comes from the original mcs7830 version 1.4 driver,
266  * not sure if it is needed.
267  */
268 static int mcs7830_set_autoneg(struct usbnet *dev, int ptrUserPhyMode)
269 {
270         int ret;
271         /* Enable all media types */
272         ret = mcs7830_write_phy(dev, MII_ADVERTISE, MCS7830_MII_ADVERTISE);
273
274         /* First reset BMCR */
275         if (!ret)
276                 ret = mcs7830_write_phy(dev, MII_BMCR, 0x0000);
277         /* Enable Auto Neg */
278         if (!ret)
279                 ret = mcs7830_write_phy(dev, MII_BMCR, BMCR_ANENABLE);
280         /* Restart Auto Neg (Keep the Enable Auto Neg Bit Set) */
281         if (!ret)
282                 ret = mcs7830_write_phy(dev, MII_BMCR,
283                                 BMCR_ANENABLE | BMCR_ANRESTART  );
284         return ret;
285 }
286
287
288 /*
289  * if we can read register 22, the chip revision is C or higher
290  */
291 static int mcs7830_get_rev(struct usbnet *dev)
292 {
293         u8 dummy[2];
294         int ret;
295         ret = mcs7830_get_reg(dev, HIF_REG_FRAME_DROP_COUNTER, 2, dummy);
296         if (ret > 0)
297                 return 2; /* Rev C or later */
298         return 1; /* earlier revision */
299 }
300
301 /*
302  * On rev. C we need to set the pause threshold
303  */
304 static void mcs7830_rev_C_fixup(struct usbnet *dev)
305 {
306         u8 pause_threshold = HIF_REG_PAUSE_THRESHOLD_DEFAULT;
307         int retry;
308
309         for (retry = 0; retry < 2; retry++) {
310                 if (mcs7830_get_rev(dev) == 2) {
311                         dev_info(&dev->udev->dev, "applying rev.C fixup\n");
312                         mcs7830_set_reg(dev, HIF_REG_PAUSE_THRESHOLD,
313                                         1, &pause_threshold);
314                 }
315                 msleep(1);
316         }
317 }
318
319 static int mcs7830_mdio_read(struct net_device *netdev, int phy_id,
320                              int location)
321 {
322         struct usbnet *dev = netdev_priv(netdev);
323         return mcs7830_read_phy(dev, location);
324 }
325
326 static void mcs7830_mdio_write(struct net_device *netdev, int phy_id,
327                                 int location, int val)
328 {
329         struct usbnet *dev = netdev_priv(netdev);
330         mcs7830_write_phy(dev, location, val);
331 }
332
333 static int mcs7830_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
334 {
335         struct usbnet *dev = netdev_priv(net);
336         return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
337 }
338
339 static inline struct mcs7830_data *mcs7830_get_data(struct usbnet *dev)
340 {
341         return (struct mcs7830_data *)&dev->data;
342 }
343
344 static void mcs7830_hif_update_multicast_hash(struct usbnet *dev)
345 {
346         struct mcs7830_data *data = mcs7830_get_data(dev);
347         mcs7830_set_reg_async(dev, HIF_REG_MULTICAST_HASH,
348                                 sizeof data->multi_filter,
349                                 data->multi_filter);
350 }
351
352 static void mcs7830_hif_update_config(struct usbnet *dev)
353 {
354         /* implementation specific to data->config
355            (argument needs to be heap-based anyway - USB DMA!) */
356         struct mcs7830_data *data = mcs7830_get_data(dev);
357         mcs7830_set_reg_async(dev, HIF_REG_CONFIG, 1, &data->config);
358 }
359
360 static void mcs7830_data_set_multicast(struct net_device *net)
361 {
362         struct usbnet *dev = netdev_priv(net);
363         struct mcs7830_data *data = mcs7830_get_data(dev);
364
365         memset(data->multi_filter, 0, sizeof data->multi_filter);
366
367         data->config = HIF_REG_CONFIG_TXENABLE;
368
369         /* this should not be needed, but it doesn't work otherwise */
370         data->config |= HIF_REG_CONFIG_ALLMULTICAST;
371
372         if (net->flags & IFF_PROMISC) {
373                 data->config |= HIF_REG_CONFIG_PROMISCUOUS;
374         } else if (net->flags & IFF_ALLMULTI ||
375                    netdev_mc_count(net) > MCS7830_MAX_MCAST) {
376                 data->config |= HIF_REG_CONFIG_ALLMULTICAST;
377         } else if (netdev_mc_empty(net)) {
378                 /* just broadcast and directed */
379         } else {
380                 /* We use the 20 byte dev->data
381                  * for our 8 byte filter buffer
382                  * to avoid allocating memory that
383                  * is tricky to free later */
384                 struct netdev_hw_addr *ha;
385                 u32 crc_bits;
386
387                 /* Build the multicast hash filter. */
388                 netdev_for_each_mc_addr(ha, net) {
389                         crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
390                         data->multi_filter[crc_bits >> 3] |= 1 << (crc_bits & 7);
391                 }
392         }
393 }
394
395 static int mcs7830_apply_base_config(struct usbnet *dev)
396 {
397         int ret;
398
399         /* re-configure known MAC (suspend case etc.) */
400         ret = mcs7830_hif_set_mac_address(dev, dev->net->dev_addr);
401         if (ret) {
402                 dev_info(&dev->udev->dev, "Cannot set MAC address\n");
403                 goto out;
404         }
405
406         /* Set up PHY */
407         ret = mcs7830_set_autoneg(dev, 0);
408         if (ret) {
409                 dev_info(&dev->udev->dev, "Cannot set autoneg\n");
410                 goto out;
411         }
412
413         mcs7830_hif_update_multicast_hash(dev);
414         mcs7830_hif_update_config(dev);
415
416         mcs7830_rev_C_fixup(dev);
417         ret = 0;
418 out:
419         return ret;
420 }
421
422 /* credits go to asix_set_multicast */
423 static void mcs7830_set_multicast(struct net_device *net)
424 {
425         struct usbnet *dev = netdev_priv(net);
426
427         mcs7830_data_set_multicast(net);
428
429         mcs7830_hif_update_multicast_hash(dev);
430         mcs7830_hif_update_config(dev);
431 }
432
433 static int mcs7830_get_regs_len(struct net_device *net)
434 {
435         struct usbnet *dev = netdev_priv(net);
436
437         switch (mcs7830_get_rev(dev)) {
438         case 1:
439                 return 21;
440         case 2:
441                 return 32;
442         }
443         return 0;
444 }
445
446 static void mcs7830_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *drvinfo)
447 {
448         usbnet_get_drvinfo(net, drvinfo);
449         drvinfo->regdump_len = mcs7830_get_regs_len(net);
450 }
451
452 static void mcs7830_get_regs(struct net_device *net, struct ethtool_regs *regs, void *data)
453 {
454         struct usbnet *dev = netdev_priv(net);
455
456         regs->version = mcs7830_get_rev(dev);
457         mcs7830_get_reg(dev, 0, regs->len, data);
458 }
459
460 static const struct ethtool_ops mcs7830_ethtool_ops = {
461         .get_drvinfo            = mcs7830_get_drvinfo,
462         .get_regs_len           = mcs7830_get_regs_len,
463         .get_regs               = mcs7830_get_regs,
464
465         /* common usbnet calls */
466         .get_link               = usbnet_get_link,
467         .get_msglevel           = usbnet_get_msglevel,
468         .set_msglevel           = usbnet_set_msglevel,
469         .get_settings           = usbnet_get_settings,
470         .set_settings           = usbnet_set_settings,
471         .nway_reset             = usbnet_nway_reset,
472 };
473
474 static const struct net_device_ops mcs7830_netdev_ops = {
475         .ndo_open               = usbnet_open,
476         .ndo_stop               = usbnet_stop,
477         .ndo_start_xmit         = usbnet_start_xmit,
478         .ndo_tx_timeout         = usbnet_tx_timeout,
479         .ndo_change_mtu         = usbnet_change_mtu,
480         .ndo_validate_addr      = eth_validate_addr,
481         .ndo_do_ioctl           = mcs7830_ioctl,
482         .ndo_set_rx_mode        = mcs7830_set_multicast,
483         .ndo_set_mac_address    = mcs7830_set_mac_address,
484 };
485
486 static int mcs7830_bind(struct usbnet *dev, struct usb_interface *udev)
487 {
488         struct net_device *net = dev->net;
489         int ret;
490         int retry;
491
492         /* Initial startup: Gather MAC address setting from EEPROM */
493         ret = -EINVAL;
494         for (retry = 0; retry < 5 && ret; retry++)
495                 ret = mcs7830_hif_get_mac_address(dev, net->dev_addr);
496         if (ret) {
497                 dev_warn(&dev->udev->dev, "Cannot read MAC address\n");
498                 goto out;
499         }
500
501         mcs7830_data_set_multicast(net);
502
503         ret = mcs7830_apply_base_config(dev);
504         if (ret)
505                 goto out;
506
507         net->ethtool_ops = &mcs7830_ethtool_ops;
508         net->netdev_ops = &mcs7830_netdev_ops;
509
510         /* reserve space for the status byte on rx */
511         dev->rx_urb_size = ETH_FRAME_LEN + 1;
512
513         dev->mii.mdio_read = mcs7830_mdio_read;
514         dev->mii.mdio_write = mcs7830_mdio_write;
515         dev->mii.dev = net;
516         dev->mii.phy_id_mask = 0x3f;
517         dev->mii.reg_num_mask = 0x1f;
518         dev->mii.phy_id = *((u8 *) net->dev_addr + 1);
519
520         ret = usbnet_get_endpoints(dev, udev);
521 out:
522         return ret;
523 }
524
525 /* The chip always appends a status byte that we need to strip */
526 static int mcs7830_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
527 {
528         u8 status;
529
530         if (skb->len == 0) {
531                 dev_err(&dev->udev->dev, "unexpected empty rx frame\n");
532                 return 0;
533         }
534
535         skb_trim(skb, skb->len - 1);
536         status = skb->data[skb->len];
537
538         if (status != MCS7830_RX_FRAME_CORRECT) {
539                 dev_dbg(&dev->udev->dev, "rx fixup status %x\n", status);
540
541                 /* hmm, perhaps usbnet.c already sees a globally visible
542                    frame error and increments rx_errors on its own already? */
543                 dev->net->stats.rx_errors++;
544
545                 if (status &    (MCS7830_RX_SHORT_FRAME
546                                 |MCS7830_RX_LENGTH_ERROR
547                                 |MCS7830_RX_LARGE_FRAME))
548                         dev->net->stats.rx_length_errors++;
549                 if (status & MCS7830_RX_ALIGNMENT_ERROR)
550                         dev->net->stats.rx_frame_errors++;
551                 if (status & MCS7830_RX_CRC_ERROR)
552                         dev->net->stats.rx_crc_errors++;
553         }
554
555         return skb->len > 0;
556 }
557
558 static void mcs7830_status(struct usbnet *dev, struct urb *urb)
559 {
560         u8 *buf = urb->transfer_buffer;
561         bool link, link_changed;
562
563         if (urb->actual_length < 16)
564                 return;
565
566         link = !(buf[1] == 0x20);
567         link_changed = netif_carrier_ok(dev->net) != link;
568         if (link_changed) {
569                 usbnet_link_change(dev, link, 0);
570                 netdev_dbg(dev->net, "Link Status is: %d\n", link);
571         }
572 }
573
574 static const struct driver_info moschip_info = {
575         .description    = "MOSCHIP 7830/7832/7730 usb-NET adapter",
576         .bind           = mcs7830_bind,
577         .rx_fixup       = mcs7830_rx_fixup,
578         .flags          = FLAG_ETHER | FLAG_LINK_INTR,
579         .status         = mcs7830_status,
580         .in             = 1,
581         .out            = 2,
582 };
583
584 static const struct driver_info sitecom_info = {
585         .description    = "Sitecom LN-30 usb-NET adapter",
586         .bind           = mcs7830_bind,
587         .rx_fixup       = mcs7830_rx_fixup,
588         .flags          = FLAG_ETHER | FLAG_LINK_INTR,
589         .status         = mcs7830_status,
590         .in             = 1,
591         .out            = 2,
592 };
593
594 static const struct usb_device_id products[] = {
595         {
596                 USB_DEVICE(MCS7830_VENDOR_ID, MCS7832_PRODUCT_ID),
597                 .driver_info = (unsigned long) &moschip_info,
598         },
599         {
600                 USB_DEVICE(MCS7830_VENDOR_ID, MCS7830_PRODUCT_ID),
601                 .driver_info = (unsigned long) &moschip_info,
602         },
603         {
604                 USB_DEVICE(MCS7830_VENDOR_ID, MCS7730_PRODUCT_ID),
605                 .driver_info = (unsigned long) &moschip_info,
606         },
607         {
608                 USB_DEVICE(SITECOM_VENDOR_ID, LN_030_PRODUCT_ID),
609                 .driver_info = (unsigned long) &sitecom_info,
610         },
611         {},
612 };
613 MODULE_DEVICE_TABLE(usb, products);
614
615 static int mcs7830_reset_resume (struct usb_interface *intf)
616 {
617         /* YES, this function is successful enough that ethtool -d
618            does show same output pre-/post-suspend */
619
620         struct usbnet           *dev = usb_get_intfdata(intf);
621
622         mcs7830_apply_base_config(dev);
623
624         usbnet_resume(intf);
625
626         return 0;
627 }
628
629 static struct usb_driver mcs7830_driver = {
630         .name = driver_name,
631         .id_table = products,
632         .probe = usbnet_probe,
633         .disconnect = usbnet_disconnect,
634         .suspend = usbnet_suspend,
635         .resume = usbnet_resume,
636         .reset_resume = mcs7830_reset_resume,
637         .disable_hub_initiated_lpm = 1,
638 };
639
640 module_usb_driver(mcs7830_driver);
641
642 MODULE_DESCRIPTION("USB to network adapter MCS7830)");
643 MODULE_LICENSE("GPL");