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