xref: /linux/drivers/net/usb/mcs7830.c (revision 61e94cbdf8220915c033ec5f07977a2de1b1d790)
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,
144 				       const unsigned char *addr)
145 {
146 	int ret = mcs7830_set_reg(dev, HIF_REG_ETHERNET_ADDR, ETH_ALEN, addr);
147 
148 	if (ret < 0)
149 		return ret;
150 	return 0;
151 }
152 
153 static int mcs7830_set_mac_address(struct net_device *netdev, void *p)
154 {
155 	int ret;
156 	struct usbnet *dev = netdev_priv(netdev);
157 	struct sockaddr *addr = p;
158 
159 	if (netif_running(netdev))
160 		return -EBUSY;
161 
162 	if (!is_valid_ether_addr(addr->sa_data))
163 		return -EADDRNOTAVAIL;
164 
165 	ret = mcs7830_hif_set_mac_address(dev, addr->sa_data);
166 
167 	if (ret < 0)
168 		return ret;
169 
170 	/* it worked --> adopt it on netdev side */
171 	eth_hw_addr_set(netdev, addr->sa_data);
172 
173 	return 0;
174 }
175 
176 static int mcs7830_read_phy(struct usbnet *dev, u8 index)
177 {
178 	int ret;
179 	int i;
180 	__le16 val;
181 
182 	u8 cmd[2] = {
183 		HIF_REG_PHY_CMD1_READ | HIF_REG_PHY_CMD1_PHYADDR,
184 		HIF_REG_PHY_CMD2_PEND_FLAG_BIT | index,
185 	};
186 
187 	mutex_lock(&dev->phy_mutex);
188 	/* write the MII command */
189 	ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
190 	if (ret < 0)
191 		goto out;
192 
193 	/* wait for the data to become valid, should be within < 1ms */
194 	for (i = 0; i < 10; i++) {
195 		ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
196 		if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT))
197 			break;
198 		ret = -EIO;
199 		msleep(1);
200 	}
201 	if (ret < 0)
202 		goto out;
203 
204 	/* read actual register contents */
205 	ret = mcs7830_get_reg(dev, HIF_REG_PHY_DATA, 2, &val);
206 	if (ret < 0)
207 		goto out;
208 	ret = le16_to_cpu(val);
209 	dev_dbg(&dev->udev->dev, "read PHY reg %02x: %04x (%d tries)\n",
210 		index, val, i);
211 out:
212 	mutex_unlock(&dev->phy_mutex);
213 	return ret;
214 }
215 
216 static int mcs7830_write_phy(struct usbnet *dev, u8 index, u16 val)
217 {
218 	int ret;
219 	int i;
220 	__le16 le_val;
221 
222 	u8 cmd[2] = {
223 		HIF_REG_PHY_CMD1_WRITE | HIF_REG_PHY_CMD1_PHYADDR,
224 		HIF_REG_PHY_CMD2_PEND_FLAG_BIT | (index & 0x1F),
225 	};
226 
227 	mutex_lock(&dev->phy_mutex);
228 
229 	/* write the new register contents */
230 	le_val = cpu_to_le16(val);
231 	ret = mcs7830_set_reg(dev, HIF_REG_PHY_DATA, 2, &le_val);
232 	if (ret < 0)
233 		goto out;
234 
235 	/* write the MII command */
236 	ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
237 	if (ret < 0)
238 		goto out;
239 
240 	/* wait for the command to be accepted by the PHY */
241 	for (i = 0; i < 10; i++) {
242 		ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
243 		if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT))
244 			break;
245 		ret = -EIO;
246 		msleep(1);
247 	}
248 	if (ret < 0)
249 		goto out;
250 
251 	ret = 0;
252 	dev_dbg(&dev->udev->dev, "write PHY reg %02x: %04x (%d tries)\n",
253 		index, val, i);
254 out:
255 	mutex_unlock(&dev->phy_mutex);
256 	return ret;
257 }
258 
259 /*
260  * This algorithm comes from the original mcs7830 version 1.4 driver,
261  * not sure if it is needed.
262  */
263 static int mcs7830_set_autoneg(struct usbnet *dev, int ptrUserPhyMode)
264 {
265 	int ret;
266 	/* Enable all media types */
267 	ret = mcs7830_write_phy(dev, MII_ADVERTISE, MCS7830_MII_ADVERTISE);
268 
269 	/* First reset BMCR */
270 	if (!ret)
271 		ret = mcs7830_write_phy(dev, MII_BMCR, 0x0000);
272 	/* Enable Auto Neg */
273 	if (!ret)
274 		ret = mcs7830_write_phy(dev, MII_BMCR, BMCR_ANENABLE);
275 	/* Restart Auto Neg (Keep the Enable Auto Neg Bit Set) */
276 	if (!ret)
277 		ret = mcs7830_write_phy(dev, MII_BMCR,
278 				BMCR_ANENABLE | BMCR_ANRESTART	);
279 	return ret;
280 }
281 
282 
283 /*
284  * if we can read register 22, the chip revision is C or higher
285  */
286 static int mcs7830_get_rev(struct usbnet *dev)
287 {
288 	u8 dummy[2];
289 	int ret;
290 	ret = mcs7830_get_reg(dev, HIF_REG_FRAME_DROP_COUNTER, 2, dummy);
291 	if (ret > 0)
292 		return 2; /* Rev C or later */
293 	return 1; /* earlier revision */
294 }
295 
296 /*
297  * On rev. C we need to set the pause threshold
298  */
299 static void mcs7830_rev_C_fixup(struct usbnet *dev)
300 {
301 	u8 pause_threshold = HIF_REG_PAUSE_THRESHOLD_DEFAULT;
302 	int retry;
303 
304 	for (retry = 0; retry < 2; retry++) {
305 		if (mcs7830_get_rev(dev) == 2) {
306 			dev_info(&dev->udev->dev, "applying rev.C fixup\n");
307 			mcs7830_set_reg(dev, HIF_REG_PAUSE_THRESHOLD,
308 					1, &pause_threshold);
309 		}
310 		msleep(1);
311 	}
312 }
313 
314 static int mcs7830_mdio_read(struct net_device *netdev, int phy_id,
315 			     int location)
316 {
317 	struct usbnet *dev = netdev_priv(netdev);
318 	return mcs7830_read_phy(dev, location);
319 }
320 
321 static void mcs7830_mdio_write(struct net_device *netdev, int phy_id,
322 				int location, int val)
323 {
324 	struct usbnet *dev = netdev_priv(netdev);
325 	mcs7830_write_phy(dev, location, val);
326 }
327 
328 static inline struct mcs7830_data *mcs7830_get_data(struct usbnet *dev)
329 {
330 	return (struct mcs7830_data *)&dev->data;
331 }
332 
333 static void mcs7830_hif_update_multicast_hash(struct usbnet *dev)
334 {
335 	struct mcs7830_data *data = mcs7830_get_data(dev);
336 	mcs7830_set_reg_async(dev, HIF_REG_MULTICAST_HASH,
337 				sizeof data->multi_filter,
338 				data->multi_filter);
339 }
340 
341 static void mcs7830_hif_update_config(struct usbnet *dev)
342 {
343 	/* implementation specific to data->config
344            (argument needs to be heap-based anyway - USB DMA!) */
345 	struct mcs7830_data *data = mcs7830_get_data(dev);
346 	mcs7830_set_reg_async(dev, HIF_REG_CONFIG, 1, &data->config);
347 }
348 
349 static void mcs7830_data_set_multicast(struct net_device *net)
350 {
351 	struct usbnet *dev = netdev_priv(net);
352 	struct mcs7830_data *data = mcs7830_get_data(dev);
353 
354 	memset(data->multi_filter, 0, sizeof data->multi_filter);
355 
356 	data->config = HIF_REG_CONFIG_TXENABLE;
357 
358 	/* this should not be needed, but it doesn't work otherwise */
359 	data->config |= HIF_REG_CONFIG_ALLMULTICAST;
360 
361 	if (net->flags & IFF_PROMISC) {
362 		data->config |= HIF_REG_CONFIG_PROMISCUOUS;
363 	} else if (net->flags & IFF_ALLMULTI ||
364 		   netdev_mc_count(net) > MCS7830_MAX_MCAST) {
365 		data->config |= HIF_REG_CONFIG_ALLMULTICAST;
366 	} else if (netdev_mc_empty(net)) {
367 		/* just broadcast and directed */
368 	} else {
369 		/* We use the 20 byte dev->data
370 		 * for our 8 byte filter buffer
371 		 * to avoid allocating memory that
372 		 * is tricky to free later */
373 		struct netdev_hw_addr *ha;
374 		u32 crc_bits;
375 
376 		/* Build the multicast hash filter. */
377 		netdev_for_each_mc_addr(ha, net) {
378 			crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
379 			data->multi_filter[crc_bits >> 3] |= 1 << (crc_bits & 7);
380 		}
381 	}
382 }
383 
384 static int mcs7830_apply_base_config(struct usbnet *dev)
385 {
386 	int ret;
387 
388 	/* re-configure known MAC (suspend case etc.) */
389 	ret = mcs7830_hif_set_mac_address(dev, dev->net->dev_addr);
390 	if (ret) {
391 		dev_info(&dev->udev->dev, "Cannot set MAC address\n");
392 		goto out;
393 	}
394 
395 	/* Set up PHY */
396 	ret = mcs7830_set_autoneg(dev, 0);
397 	if (ret) {
398 		dev_info(&dev->udev->dev, "Cannot set autoneg\n");
399 		goto out;
400 	}
401 
402 	mcs7830_hif_update_multicast_hash(dev);
403 	mcs7830_hif_update_config(dev);
404 
405 	mcs7830_rev_C_fixup(dev);
406 	ret = 0;
407 out:
408 	return ret;
409 }
410 
411 /* credits go to asix_set_multicast */
412 static void mcs7830_set_multicast(struct net_device *net)
413 {
414 	struct usbnet *dev = netdev_priv(net);
415 
416 	mcs7830_data_set_multicast(net);
417 
418 	mcs7830_hif_update_multicast_hash(dev);
419 	mcs7830_hif_update_config(dev);
420 }
421 
422 static int mcs7830_get_regs_len(struct net_device *net)
423 {
424 	struct usbnet *dev = netdev_priv(net);
425 
426 	switch (mcs7830_get_rev(dev)) {
427 	case 1:
428 		return 21;
429 	case 2:
430 		return 32;
431 	}
432 	return 0;
433 }
434 
435 static void mcs7830_get_regs(struct net_device *net, struct ethtool_regs *regs, void *data)
436 {
437 	struct usbnet *dev = netdev_priv(net);
438 
439 	regs->version = mcs7830_get_rev(dev);
440 	mcs7830_get_reg(dev, 0, regs->len, data);
441 }
442 
443 static const struct ethtool_ops mcs7830_ethtool_ops = {
444 	.get_regs_len		= mcs7830_get_regs_len,
445 	.get_regs		= mcs7830_get_regs,
446 
447 	/* common usbnet calls */
448 	.get_drvinfo		= usbnet_get_drvinfo,
449 	.get_link		= usbnet_get_link,
450 	.get_msglevel		= usbnet_get_msglevel,
451 	.set_msglevel		= usbnet_set_msglevel,
452 	.nway_reset		= usbnet_nway_reset,
453 	.get_link_ksettings	= usbnet_get_link_ksettings_mii,
454 	.set_link_ksettings	= usbnet_set_link_ksettings_mii,
455 };
456 
457 static const struct net_device_ops mcs7830_netdev_ops = {
458 	.ndo_open		= usbnet_open,
459 	.ndo_stop		= usbnet_stop,
460 	.ndo_start_xmit		= usbnet_start_xmit,
461 	.ndo_tx_timeout		= usbnet_tx_timeout,
462 	.ndo_change_mtu		= usbnet_change_mtu,
463 	.ndo_get_stats64	= dev_get_tstats64,
464 	.ndo_validate_addr	= eth_validate_addr,
465 	.ndo_eth_ioctl		= usbnet_mii_ioctl,
466 	.ndo_set_rx_mode	= mcs7830_set_multicast,
467 	.ndo_set_mac_address	= mcs7830_set_mac_address,
468 };
469 
470 static int mcs7830_bind(struct usbnet *dev, struct usb_interface *udev)
471 {
472 	struct net_device *net = dev->net;
473 	u8 addr[ETH_ALEN];
474 	int ret;
475 	int retry;
476 
477 	/* Initial startup: Gather MAC address setting from EEPROM */
478 	ret = -EINVAL;
479 	for (retry = 0; retry < 5 && ret; retry++)
480 		ret = mcs7830_hif_get_mac_address(dev, addr);
481 	if (ret) {
482 		dev_warn(&dev->udev->dev, "Cannot read MAC address\n");
483 		goto out;
484 	}
485 	eth_hw_addr_set(net, addr);
486 
487 	mcs7830_data_set_multicast(net);
488 
489 	ret = mcs7830_apply_base_config(dev);
490 	if (ret)
491 		goto out;
492 
493 	net->ethtool_ops = &mcs7830_ethtool_ops;
494 	net->netdev_ops = &mcs7830_netdev_ops;
495 
496 	/* reserve space for the status byte on rx */
497 	dev->rx_urb_size = ETH_FRAME_LEN + 1;
498 
499 	dev->mii.mdio_read = mcs7830_mdio_read;
500 	dev->mii.mdio_write = mcs7830_mdio_write;
501 	dev->mii.dev = net;
502 	dev->mii.phy_id_mask = 0x3f;
503 	dev->mii.reg_num_mask = 0x1f;
504 	dev->mii.phy_id = *((u8 *) net->dev_addr + 1);
505 
506 	ret = usbnet_get_endpoints(dev, udev);
507 out:
508 	return ret;
509 }
510 
511 /* The chip always appends a status byte that we need to strip */
512 static int mcs7830_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
513 {
514 	u8 status;
515 
516 	/* This check is no longer done by usbnet */
517 	if (skb->len < dev->net->hard_header_len) {
518 		dev_err(&dev->udev->dev, "unexpected tiny rx frame\n");
519 		return 0;
520 	}
521 
522 	skb_trim(skb, skb->len - 1);
523 	status = skb->data[skb->len];
524 
525 	if (status != MCS7830_RX_FRAME_CORRECT) {
526 		dev_dbg(&dev->udev->dev, "rx fixup status %x\n", status);
527 
528 		/* hmm, perhaps usbnet.c already sees a globally visible
529 		   frame error and increments rx_errors on its own already? */
530 		dev->net->stats.rx_errors++;
531 
532 		if (status &	(MCS7830_RX_SHORT_FRAME
533 				|MCS7830_RX_LENGTH_ERROR
534 				|MCS7830_RX_LARGE_FRAME))
535 			dev->net->stats.rx_length_errors++;
536 		if (status & MCS7830_RX_ALIGNMENT_ERROR)
537 			dev->net->stats.rx_frame_errors++;
538 		if (status & MCS7830_RX_CRC_ERROR)
539 			dev->net->stats.rx_crc_errors++;
540 	}
541 
542 	return skb->len > 0;
543 }
544 
545 static void mcs7830_status(struct usbnet *dev, struct urb *urb)
546 {
547 	u8 *buf = urb->transfer_buffer;
548 	bool link, link_changed;
549 
550 	if (urb->actual_length < 16)
551 		return;
552 
553 	link = !(buf[1] == 0x20);
554 	link_changed = netif_carrier_ok(dev->net) != link;
555 	if (link_changed) {
556 		usbnet_link_change(dev, link, 0);
557 		netdev_dbg(dev->net, "Link Status is: %d\n", link);
558 	}
559 }
560 
561 static const struct driver_info moschip_info = {
562 	.description	= "MOSCHIP 7830/7832/7730 usb-NET adapter",
563 	.bind		= mcs7830_bind,
564 	.rx_fixup	= mcs7830_rx_fixup,
565 	.flags		= FLAG_ETHER | FLAG_LINK_INTR,
566 	.status		= mcs7830_status,
567 	.in		= 1,
568 	.out		= 2,
569 };
570 
571 static const struct driver_info sitecom_info = {
572 	.description    = "Sitecom LN-30 usb-NET adapter",
573 	.bind		= mcs7830_bind,
574 	.rx_fixup	= mcs7830_rx_fixup,
575 	.flags		= FLAG_ETHER | FLAG_LINK_INTR,
576 	.status		= mcs7830_status,
577 	.in		= 1,
578 	.out		= 2,
579 };
580 
581 static const struct usb_device_id products[] = {
582 	{
583 		USB_DEVICE(MCS7830_VENDOR_ID, MCS7832_PRODUCT_ID),
584 		.driver_info = (unsigned long) &moschip_info,
585 	},
586 	{
587 		USB_DEVICE(MCS7830_VENDOR_ID, MCS7830_PRODUCT_ID),
588 		.driver_info = (unsigned long) &moschip_info,
589 	},
590 	{
591 		USB_DEVICE(MCS7830_VENDOR_ID, MCS7730_PRODUCT_ID),
592 		.driver_info = (unsigned long) &moschip_info,
593 	},
594 	{
595 		USB_DEVICE(SITECOM_VENDOR_ID, LN_030_PRODUCT_ID),
596 		.driver_info = (unsigned long) &sitecom_info,
597 	},
598 	{},
599 };
600 MODULE_DEVICE_TABLE(usb, products);
601 
602 static int mcs7830_reset_resume (struct usb_interface *intf)
603 {
604 	/* YES, this function is successful enough that ethtool -d
605            does show same output pre-/post-suspend */
606 
607 	struct usbnet		*dev = usb_get_intfdata(intf);
608 
609 	mcs7830_apply_base_config(dev);
610 
611 	usbnet_resume(intf);
612 
613 	return 0;
614 }
615 
616 static struct usb_driver mcs7830_driver = {
617 	.name = driver_name,
618 	.id_table = products,
619 	.probe = usbnet_probe,
620 	.disconnect = usbnet_disconnect,
621 	.suspend = usbnet_suspend,
622 	.resume = usbnet_resume,
623 	.reset_resume = mcs7830_reset_resume,
624 	.disable_hub_initiated_lpm = 1,
625 };
626 
627 module_usb_driver(mcs7830_driver);
628 
629 MODULE_DESCRIPTION("USB to network adapter MCS7830)");
630 MODULE_LICENSE("GPL");
631