xref: /openbmc/linux/drivers/net/usb/smsc75xx.c (revision e68235c8)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2  /***************************************************************************
3  *
4  * Copyright (C) 2007-2010 SMSC
5  *
6  *****************************************************************************/
7 
8 #include <linux/module.h>
9 #include <linux/kmod.h>
10 #include <linux/netdevice.h>
11 #include <linux/etherdevice.h>
12 #include <linux/ethtool.h>
13 #include <linux/mii.h>
14 #include <linux/usb.h>
15 #include <linux/bitrev.h>
16 #include <linux/crc16.h>
17 #include <linux/crc32.h>
18 #include <linux/usb/usbnet.h>
19 #include <linux/slab.h>
20 #include <linux/of_net.h>
21 #include "smsc75xx.h"
22 
23 #define SMSC_CHIPNAME			"smsc75xx"
24 #define SMSC_DRIVER_VERSION		"1.0.0"
25 #define HS_USB_PKT_SIZE			(512)
26 #define FS_USB_PKT_SIZE			(64)
27 #define DEFAULT_HS_BURST_CAP_SIZE	(16 * 1024 + 5 * HS_USB_PKT_SIZE)
28 #define DEFAULT_FS_BURST_CAP_SIZE	(6 * 1024 + 33 * FS_USB_PKT_SIZE)
29 #define DEFAULT_BULK_IN_DELAY		(0x00002000)
30 #define MAX_SINGLE_PACKET_SIZE		(9000)
31 #define LAN75XX_EEPROM_MAGIC		(0x7500)
32 #define EEPROM_MAC_OFFSET		(0x01)
33 #define DEFAULT_TX_CSUM_ENABLE		(true)
34 #define DEFAULT_RX_CSUM_ENABLE		(true)
35 #define SMSC75XX_INTERNAL_PHY_ID	(1)
36 #define SMSC75XX_TX_OVERHEAD		(8)
37 #define MAX_RX_FIFO_SIZE		(20 * 1024)
38 #define MAX_TX_FIFO_SIZE		(12 * 1024)
39 #define USB_VENDOR_ID_SMSC		(0x0424)
40 #define USB_PRODUCT_ID_LAN7500		(0x7500)
41 #define USB_PRODUCT_ID_LAN7505		(0x7505)
42 #define RXW_PADDING			2
43 #define SUPPORTED_WAKE			(WAKE_PHY | WAKE_UCAST | WAKE_BCAST | \
44 					 WAKE_MCAST | WAKE_ARP | WAKE_MAGIC)
45 
46 #define SUSPEND_SUSPEND0		(0x01)
47 #define SUSPEND_SUSPEND1		(0x02)
48 #define SUSPEND_SUSPEND2		(0x04)
49 #define SUSPEND_SUSPEND3		(0x08)
50 #define SUSPEND_ALLMODES		(SUSPEND_SUSPEND0 | SUSPEND_SUSPEND1 | \
51 					 SUSPEND_SUSPEND2 | SUSPEND_SUSPEND3)
52 
53 struct smsc75xx_priv {
54 	struct usbnet *dev;
55 	u32 rfe_ctl;
56 	u32 wolopts;
57 	u32 multicast_hash_table[DP_SEL_VHF_HASH_LEN];
58 	struct mutex dataport_mutex;
59 	spinlock_t rfe_ctl_lock;
60 	struct work_struct set_multicast;
61 	u8 suspend_flags;
62 };
63 
64 struct usb_context {
65 	struct usb_ctrlrequest req;
66 	struct usbnet *dev;
67 };
68 
69 static bool turbo_mode = true;
70 module_param(turbo_mode, bool, 0644);
71 MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
72 
73 static int smsc75xx_link_ok_nopm(struct usbnet *dev);
74 static int smsc75xx_phy_gig_workaround(struct usbnet *dev);
75 
76 static int __must_check __smsc75xx_read_reg(struct usbnet *dev, u32 index,
77 					    u32 *data, int in_pm)
78 {
79 	u32 buf;
80 	int ret;
81 	int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16);
82 
83 	BUG_ON(!dev);
84 
85 	if (!in_pm)
86 		fn = usbnet_read_cmd;
87 	else
88 		fn = usbnet_read_cmd_nopm;
89 
90 	ret = fn(dev, USB_VENDOR_REQUEST_READ_REGISTER, USB_DIR_IN
91 		 | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
92 		 0, index, &buf, 4);
93 	if (unlikely(ret < 0)) {
94 		netdev_warn(dev->net, "Failed to read reg index 0x%08x: %d\n",
95 			    index, ret);
96 		return ret;
97 	}
98 
99 	le32_to_cpus(&buf);
100 	*data = buf;
101 
102 	return ret;
103 }
104 
105 static int __must_check __smsc75xx_write_reg(struct usbnet *dev, u32 index,
106 					     u32 data, int in_pm)
107 {
108 	u32 buf;
109 	int ret;
110 	int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16);
111 
112 	BUG_ON(!dev);
113 
114 	if (!in_pm)
115 		fn = usbnet_write_cmd;
116 	else
117 		fn = usbnet_write_cmd_nopm;
118 
119 	buf = data;
120 	cpu_to_le32s(&buf);
121 
122 	ret = fn(dev, USB_VENDOR_REQUEST_WRITE_REGISTER, USB_DIR_OUT
123 		 | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
124 		 0, index, &buf, 4);
125 	if (unlikely(ret < 0))
126 		netdev_warn(dev->net, "Failed to write reg index 0x%08x: %d\n",
127 			    index, ret);
128 
129 	return ret;
130 }
131 
132 static int __must_check smsc75xx_read_reg_nopm(struct usbnet *dev, u32 index,
133 					       u32 *data)
134 {
135 	return __smsc75xx_read_reg(dev, index, data, 1);
136 }
137 
138 static int __must_check smsc75xx_write_reg_nopm(struct usbnet *dev, u32 index,
139 						u32 data)
140 {
141 	return __smsc75xx_write_reg(dev, index, data, 1);
142 }
143 
144 static int __must_check smsc75xx_read_reg(struct usbnet *dev, u32 index,
145 					  u32 *data)
146 {
147 	return __smsc75xx_read_reg(dev, index, data, 0);
148 }
149 
150 static int __must_check smsc75xx_write_reg(struct usbnet *dev, u32 index,
151 					   u32 data)
152 {
153 	return __smsc75xx_write_reg(dev, index, data, 0);
154 }
155 
156 /* Loop until the read is completed with timeout
157  * called with phy_mutex held */
158 static __must_check int __smsc75xx_phy_wait_not_busy(struct usbnet *dev,
159 						     int in_pm)
160 {
161 	unsigned long start_time = jiffies;
162 	u32 val;
163 	int ret;
164 
165 	do {
166 		ret = __smsc75xx_read_reg(dev, MII_ACCESS, &val, in_pm);
167 		if (ret < 0) {
168 			netdev_warn(dev->net, "Error reading MII_ACCESS\n");
169 			return ret;
170 		}
171 
172 		if (!(val & MII_ACCESS_BUSY))
173 			return 0;
174 	} while (!time_after(jiffies, start_time + HZ));
175 
176 	return -EIO;
177 }
178 
179 static int __smsc75xx_mdio_read(struct net_device *netdev, int phy_id, int idx,
180 				int in_pm)
181 {
182 	struct usbnet *dev = netdev_priv(netdev);
183 	u32 val, addr;
184 	int ret;
185 
186 	mutex_lock(&dev->phy_mutex);
187 
188 	/* confirm MII not busy */
189 	ret = __smsc75xx_phy_wait_not_busy(dev, in_pm);
190 	if (ret < 0) {
191 		netdev_warn(dev->net, "MII is busy in smsc75xx_mdio_read\n");
192 		goto done;
193 	}
194 
195 	/* set the address, index & direction (read from PHY) */
196 	phy_id &= dev->mii.phy_id_mask;
197 	idx &= dev->mii.reg_num_mask;
198 	addr = ((phy_id << MII_ACCESS_PHY_ADDR_SHIFT) & MII_ACCESS_PHY_ADDR)
199 		| ((idx << MII_ACCESS_REG_ADDR_SHIFT) & MII_ACCESS_REG_ADDR)
200 		| MII_ACCESS_READ | MII_ACCESS_BUSY;
201 	ret = __smsc75xx_write_reg(dev, MII_ACCESS, addr, in_pm);
202 	if (ret < 0) {
203 		netdev_warn(dev->net, "Error writing MII_ACCESS\n");
204 		goto done;
205 	}
206 
207 	ret = __smsc75xx_phy_wait_not_busy(dev, in_pm);
208 	if (ret < 0) {
209 		netdev_warn(dev->net, "Timed out reading MII reg %02X\n", idx);
210 		goto done;
211 	}
212 
213 	ret = __smsc75xx_read_reg(dev, MII_DATA, &val, in_pm);
214 	if (ret < 0) {
215 		netdev_warn(dev->net, "Error reading MII_DATA\n");
216 		goto done;
217 	}
218 
219 	ret = (u16)(val & 0xFFFF);
220 
221 done:
222 	mutex_unlock(&dev->phy_mutex);
223 	return ret;
224 }
225 
226 static void __smsc75xx_mdio_write(struct net_device *netdev, int phy_id,
227 				  int idx, int regval, int in_pm)
228 {
229 	struct usbnet *dev = netdev_priv(netdev);
230 	u32 val, addr;
231 	int ret;
232 
233 	mutex_lock(&dev->phy_mutex);
234 
235 	/* confirm MII not busy */
236 	ret = __smsc75xx_phy_wait_not_busy(dev, in_pm);
237 	if (ret < 0) {
238 		netdev_warn(dev->net, "MII is busy in smsc75xx_mdio_write\n");
239 		goto done;
240 	}
241 
242 	val = regval;
243 	ret = __smsc75xx_write_reg(dev, MII_DATA, val, in_pm);
244 	if (ret < 0) {
245 		netdev_warn(dev->net, "Error writing MII_DATA\n");
246 		goto done;
247 	}
248 
249 	/* set the address, index & direction (write to PHY) */
250 	phy_id &= dev->mii.phy_id_mask;
251 	idx &= dev->mii.reg_num_mask;
252 	addr = ((phy_id << MII_ACCESS_PHY_ADDR_SHIFT) & MII_ACCESS_PHY_ADDR)
253 		| ((idx << MII_ACCESS_REG_ADDR_SHIFT) & MII_ACCESS_REG_ADDR)
254 		| MII_ACCESS_WRITE | MII_ACCESS_BUSY;
255 	ret = __smsc75xx_write_reg(dev, MII_ACCESS, addr, in_pm);
256 	if (ret < 0) {
257 		netdev_warn(dev->net, "Error writing MII_ACCESS\n");
258 		goto done;
259 	}
260 
261 	ret = __smsc75xx_phy_wait_not_busy(dev, in_pm);
262 	if (ret < 0) {
263 		netdev_warn(dev->net, "Timed out writing MII reg %02X\n", idx);
264 		goto done;
265 	}
266 
267 done:
268 	mutex_unlock(&dev->phy_mutex);
269 }
270 
271 static int smsc75xx_mdio_read_nopm(struct net_device *netdev, int phy_id,
272 				   int idx)
273 {
274 	return __smsc75xx_mdio_read(netdev, phy_id, idx, 1);
275 }
276 
277 static void smsc75xx_mdio_write_nopm(struct net_device *netdev, int phy_id,
278 				     int idx, int regval)
279 {
280 	__smsc75xx_mdio_write(netdev, phy_id, idx, regval, 1);
281 }
282 
283 static int smsc75xx_mdio_read(struct net_device *netdev, int phy_id, int idx)
284 {
285 	return __smsc75xx_mdio_read(netdev, phy_id, idx, 0);
286 }
287 
288 static void smsc75xx_mdio_write(struct net_device *netdev, int phy_id, int idx,
289 				int regval)
290 {
291 	__smsc75xx_mdio_write(netdev, phy_id, idx, regval, 0);
292 }
293 
294 static int smsc75xx_wait_eeprom(struct usbnet *dev)
295 {
296 	unsigned long start_time = jiffies;
297 	u32 val;
298 	int ret;
299 
300 	do {
301 		ret = smsc75xx_read_reg(dev, E2P_CMD, &val);
302 		if (ret < 0) {
303 			netdev_warn(dev->net, "Error reading E2P_CMD\n");
304 			return ret;
305 		}
306 
307 		if (!(val & E2P_CMD_BUSY) || (val & E2P_CMD_TIMEOUT))
308 			break;
309 		udelay(40);
310 	} while (!time_after(jiffies, start_time + HZ));
311 
312 	if (val & (E2P_CMD_TIMEOUT | E2P_CMD_BUSY)) {
313 		netdev_warn(dev->net, "EEPROM read operation timeout\n");
314 		return -EIO;
315 	}
316 
317 	return 0;
318 }
319 
320 static int smsc75xx_eeprom_confirm_not_busy(struct usbnet *dev)
321 {
322 	unsigned long start_time = jiffies;
323 	u32 val;
324 	int ret;
325 
326 	do {
327 		ret = smsc75xx_read_reg(dev, E2P_CMD, &val);
328 		if (ret < 0) {
329 			netdev_warn(dev->net, "Error reading E2P_CMD\n");
330 			return ret;
331 		}
332 
333 		if (!(val & E2P_CMD_BUSY))
334 			return 0;
335 
336 		udelay(40);
337 	} while (!time_after(jiffies, start_time + HZ));
338 
339 	netdev_warn(dev->net, "EEPROM is busy\n");
340 	return -EIO;
341 }
342 
343 static int smsc75xx_read_eeprom(struct usbnet *dev, u32 offset, u32 length,
344 				u8 *data)
345 {
346 	u32 val;
347 	int i, ret;
348 
349 	BUG_ON(!dev);
350 	BUG_ON(!data);
351 
352 	ret = smsc75xx_eeprom_confirm_not_busy(dev);
353 	if (ret)
354 		return ret;
355 
356 	for (i = 0; i < length; i++) {
357 		val = E2P_CMD_BUSY | E2P_CMD_READ | (offset & E2P_CMD_ADDR);
358 		ret = smsc75xx_write_reg(dev, E2P_CMD, val);
359 		if (ret < 0) {
360 			netdev_warn(dev->net, "Error writing E2P_CMD\n");
361 			return ret;
362 		}
363 
364 		ret = smsc75xx_wait_eeprom(dev);
365 		if (ret < 0)
366 			return ret;
367 
368 		ret = smsc75xx_read_reg(dev, E2P_DATA, &val);
369 		if (ret < 0) {
370 			netdev_warn(dev->net, "Error reading E2P_DATA\n");
371 			return ret;
372 		}
373 
374 		data[i] = val & 0xFF;
375 		offset++;
376 	}
377 
378 	return 0;
379 }
380 
381 static int smsc75xx_write_eeprom(struct usbnet *dev, u32 offset, u32 length,
382 				 u8 *data)
383 {
384 	u32 val;
385 	int i, ret;
386 
387 	BUG_ON(!dev);
388 	BUG_ON(!data);
389 
390 	ret = smsc75xx_eeprom_confirm_not_busy(dev);
391 	if (ret)
392 		return ret;
393 
394 	/* Issue write/erase enable command */
395 	val = E2P_CMD_BUSY | E2P_CMD_EWEN;
396 	ret = smsc75xx_write_reg(dev, E2P_CMD, val);
397 	if (ret < 0) {
398 		netdev_warn(dev->net, "Error writing E2P_CMD\n");
399 		return ret;
400 	}
401 
402 	ret = smsc75xx_wait_eeprom(dev);
403 	if (ret < 0)
404 		return ret;
405 
406 	for (i = 0; i < length; i++) {
407 
408 		/* Fill data register */
409 		val = data[i];
410 		ret = smsc75xx_write_reg(dev, E2P_DATA, val);
411 		if (ret < 0) {
412 			netdev_warn(dev->net, "Error writing E2P_DATA\n");
413 			return ret;
414 		}
415 
416 		/* Send "write" command */
417 		val = E2P_CMD_BUSY | E2P_CMD_WRITE | (offset & E2P_CMD_ADDR);
418 		ret = smsc75xx_write_reg(dev, E2P_CMD, val);
419 		if (ret < 0) {
420 			netdev_warn(dev->net, "Error writing E2P_CMD\n");
421 			return ret;
422 		}
423 
424 		ret = smsc75xx_wait_eeprom(dev);
425 		if (ret < 0)
426 			return ret;
427 
428 		offset++;
429 	}
430 
431 	return 0;
432 }
433 
434 static int smsc75xx_dataport_wait_not_busy(struct usbnet *dev)
435 {
436 	int i, ret;
437 
438 	for (i = 0; i < 100; i++) {
439 		u32 dp_sel;
440 		ret = smsc75xx_read_reg(dev, DP_SEL, &dp_sel);
441 		if (ret < 0) {
442 			netdev_warn(dev->net, "Error reading DP_SEL\n");
443 			return ret;
444 		}
445 
446 		if (dp_sel & DP_SEL_DPRDY)
447 			return 0;
448 
449 		udelay(40);
450 	}
451 
452 	netdev_warn(dev->net, "smsc75xx_dataport_wait_not_busy timed out\n");
453 
454 	return -EIO;
455 }
456 
457 static int smsc75xx_dataport_write(struct usbnet *dev, u32 ram_select, u32 addr,
458 				   u32 length, u32 *buf)
459 {
460 	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
461 	u32 dp_sel;
462 	int i, ret;
463 
464 	mutex_lock(&pdata->dataport_mutex);
465 
466 	ret = smsc75xx_dataport_wait_not_busy(dev);
467 	if (ret < 0) {
468 		netdev_warn(dev->net, "smsc75xx_dataport_write busy on entry\n");
469 		goto done;
470 	}
471 
472 	ret = smsc75xx_read_reg(dev, DP_SEL, &dp_sel);
473 	if (ret < 0) {
474 		netdev_warn(dev->net, "Error reading DP_SEL\n");
475 		goto done;
476 	}
477 
478 	dp_sel &= ~DP_SEL_RSEL;
479 	dp_sel |= ram_select;
480 	ret = smsc75xx_write_reg(dev, DP_SEL, dp_sel);
481 	if (ret < 0) {
482 		netdev_warn(dev->net, "Error writing DP_SEL\n");
483 		goto done;
484 	}
485 
486 	for (i = 0; i < length; i++) {
487 		ret = smsc75xx_write_reg(dev, DP_ADDR, addr + i);
488 		if (ret < 0) {
489 			netdev_warn(dev->net, "Error writing DP_ADDR\n");
490 			goto done;
491 		}
492 
493 		ret = smsc75xx_write_reg(dev, DP_DATA, buf[i]);
494 		if (ret < 0) {
495 			netdev_warn(dev->net, "Error writing DP_DATA\n");
496 			goto done;
497 		}
498 
499 		ret = smsc75xx_write_reg(dev, DP_CMD, DP_CMD_WRITE);
500 		if (ret < 0) {
501 			netdev_warn(dev->net, "Error writing DP_CMD\n");
502 			goto done;
503 		}
504 
505 		ret = smsc75xx_dataport_wait_not_busy(dev);
506 		if (ret < 0) {
507 			netdev_warn(dev->net, "smsc75xx_dataport_write timeout\n");
508 			goto done;
509 		}
510 	}
511 
512 done:
513 	mutex_unlock(&pdata->dataport_mutex);
514 	return ret;
515 }
516 
517 /* returns hash bit number for given MAC address */
518 static u32 smsc75xx_hash(char addr[ETH_ALEN])
519 {
520 	return (ether_crc(ETH_ALEN, addr) >> 23) & 0x1ff;
521 }
522 
523 static void smsc75xx_deferred_multicast_write(struct work_struct *param)
524 {
525 	struct smsc75xx_priv *pdata =
526 		container_of(param, struct smsc75xx_priv, set_multicast);
527 	struct usbnet *dev = pdata->dev;
528 	int ret;
529 
530 	netif_dbg(dev, drv, dev->net, "deferred multicast write 0x%08x\n",
531 		  pdata->rfe_ctl);
532 
533 	smsc75xx_dataport_write(dev, DP_SEL_VHF, DP_SEL_VHF_VLAN_LEN,
534 		DP_SEL_VHF_HASH_LEN, pdata->multicast_hash_table);
535 
536 	ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl);
537 	if (ret < 0)
538 		netdev_warn(dev->net, "Error writing RFE_CRL\n");
539 }
540 
541 static void smsc75xx_set_multicast(struct net_device *netdev)
542 {
543 	struct usbnet *dev = netdev_priv(netdev);
544 	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
545 	unsigned long flags;
546 	int i;
547 
548 	spin_lock_irqsave(&pdata->rfe_ctl_lock, flags);
549 
550 	pdata->rfe_ctl &=
551 		~(RFE_CTL_AU | RFE_CTL_AM | RFE_CTL_DPF | RFE_CTL_MHF);
552 	pdata->rfe_ctl |= RFE_CTL_AB;
553 
554 	for (i = 0; i < DP_SEL_VHF_HASH_LEN; i++)
555 		pdata->multicast_hash_table[i] = 0;
556 
557 	if (dev->net->flags & IFF_PROMISC) {
558 		netif_dbg(dev, drv, dev->net, "promiscuous mode enabled\n");
559 		pdata->rfe_ctl |= RFE_CTL_AM | RFE_CTL_AU;
560 	} else if (dev->net->flags & IFF_ALLMULTI) {
561 		netif_dbg(dev, drv, dev->net, "receive all multicast enabled\n");
562 		pdata->rfe_ctl |= RFE_CTL_AM | RFE_CTL_DPF;
563 	} else if (!netdev_mc_empty(dev->net)) {
564 		struct netdev_hw_addr *ha;
565 
566 		netif_dbg(dev, drv, dev->net, "receive multicast hash filter\n");
567 
568 		pdata->rfe_ctl |= RFE_CTL_MHF | RFE_CTL_DPF;
569 
570 		netdev_for_each_mc_addr(ha, netdev) {
571 			u32 bitnum = smsc75xx_hash(ha->addr);
572 			pdata->multicast_hash_table[bitnum / 32] |=
573 				(1 << (bitnum % 32));
574 		}
575 	} else {
576 		netif_dbg(dev, drv, dev->net, "receive own packets only\n");
577 		pdata->rfe_ctl |= RFE_CTL_DPF;
578 	}
579 
580 	spin_unlock_irqrestore(&pdata->rfe_ctl_lock, flags);
581 
582 	/* defer register writes to a sleepable context */
583 	schedule_work(&pdata->set_multicast);
584 }
585 
586 static int smsc75xx_update_flowcontrol(struct usbnet *dev, u8 duplex,
587 					    u16 lcladv, u16 rmtadv)
588 {
589 	u32 flow = 0, fct_flow = 0;
590 	int ret;
591 
592 	if (duplex == DUPLEX_FULL) {
593 		u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv);
594 
595 		if (cap & FLOW_CTRL_TX) {
596 			flow = (FLOW_TX_FCEN | 0xFFFF);
597 			/* set fct_flow thresholds to 20% and 80% */
598 			fct_flow = (8 << 8) | 32;
599 		}
600 
601 		if (cap & FLOW_CTRL_RX)
602 			flow |= FLOW_RX_FCEN;
603 
604 		netif_dbg(dev, link, dev->net, "rx pause %s, tx pause %s\n",
605 			  (cap & FLOW_CTRL_RX ? "enabled" : "disabled"),
606 			  (cap & FLOW_CTRL_TX ? "enabled" : "disabled"));
607 	} else {
608 		netif_dbg(dev, link, dev->net, "half duplex\n");
609 	}
610 
611 	ret = smsc75xx_write_reg(dev, FLOW, flow);
612 	if (ret < 0) {
613 		netdev_warn(dev->net, "Error writing FLOW\n");
614 		return ret;
615 	}
616 
617 	ret = smsc75xx_write_reg(dev, FCT_FLOW, fct_flow);
618 	if (ret < 0) {
619 		netdev_warn(dev->net, "Error writing FCT_FLOW\n");
620 		return ret;
621 	}
622 
623 	return 0;
624 }
625 
626 static int smsc75xx_link_reset(struct usbnet *dev)
627 {
628 	struct mii_if_info *mii = &dev->mii;
629 	struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
630 	u16 lcladv, rmtadv;
631 	int ret;
632 
633 	/* write to clear phy interrupt status */
634 	smsc75xx_mdio_write(dev->net, mii->phy_id, PHY_INT_SRC,
635 		PHY_INT_SRC_CLEAR_ALL);
636 
637 	ret = smsc75xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL);
638 	if (ret < 0) {
639 		netdev_warn(dev->net, "Error writing INT_STS\n");
640 		return ret;
641 	}
642 
643 	mii_check_media(mii, 1, 1);
644 	mii_ethtool_gset(&dev->mii, &ecmd);
645 	lcladv = smsc75xx_mdio_read(dev->net, mii->phy_id, MII_ADVERTISE);
646 	rmtadv = smsc75xx_mdio_read(dev->net, mii->phy_id, MII_LPA);
647 
648 	netif_dbg(dev, link, dev->net, "speed: %u duplex: %d lcladv: %04x rmtadv: %04x\n",
649 		  ethtool_cmd_speed(&ecmd), ecmd.duplex, lcladv, rmtadv);
650 
651 	return smsc75xx_update_flowcontrol(dev, ecmd.duplex, lcladv, rmtadv);
652 }
653 
654 static void smsc75xx_status(struct usbnet *dev, struct urb *urb)
655 {
656 	u32 intdata;
657 
658 	if (urb->actual_length != 4) {
659 		netdev_warn(dev->net, "unexpected urb length %d\n",
660 			    urb->actual_length);
661 		return;
662 	}
663 
664 	intdata = get_unaligned_le32(urb->transfer_buffer);
665 
666 	netif_dbg(dev, link, dev->net, "intdata: 0x%08X\n", intdata);
667 
668 	if (intdata & INT_ENP_PHY_INT)
669 		usbnet_defer_kevent(dev, EVENT_LINK_RESET);
670 	else
671 		netdev_warn(dev->net, "unexpected interrupt, intdata=0x%08X\n",
672 			    intdata);
673 }
674 
675 static int smsc75xx_ethtool_get_eeprom_len(struct net_device *net)
676 {
677 	return MAX_EEPROM_SIZE;
678 }
679 
680 static int smsc75xx_ethtool_get_eeprom(struct net_device *netdev,
681 				       struct ethtool_eeprom *ee, u8 *data)
682 {
683 	struct usbnet *dev = netdev_priv(netdev);
684 
685 	ee->magic = LAN75XX_EEPROM_MAGIC;
686 
687 	return smsc75xx_read_eeprom(dev, ee->offset, ee->len, data);
688 }
689 
690 static int smsc75xx_ethtool_set_eeprom(struct net_device *netdev,
691 				       struct ethtool_eeprom *ee, u8 *data)
692 {
693 	struct usbnet *dev = netdev_priv(netdev);
694 
695 	if (ee->magic != LAN75XX_EEPROM_MAGIC) {
696 		netdev_warn(dev->net, "EEPROM: magic value mismatch: 0x%x\n",
697 			    ee->magic);
698 		return -EINVAL;
699 	}
700 
701 	return smsc75xx_write_eeprom(dev, ee->offset, ee->len, data);
702 }
703 
704 static void smsc75xx_ethtool_get_wol(struct net_device *net,
705 				     struct ethtool_wolinfo *wolinfo)
706 {
707 	struct usbnet *dev = netdev_priv(net);
708 	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
709 
710 	wolinfo->supported = SUPPORTED_WAKE;
711 	wolinfo->wolopts = pdata->wolopts;
712 }
713 
714 static int smsc75xx_ethtool_set_wol(struct net_device *net,
715 				    struct ethtool_wolinfo *wolinfo)
716 {
717 	struct usbnet *dev = netdev_priv(net);
718 	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
719 	int ret;
720 
721 	if (wolinfo->wolopts & ~SUPPORTED_WAKE)
722 		return -EINVAL;
723 
724 	pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE;
725 
726 	ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts);
727 	if (ret < 0)
728 		netdev_warn(dev->net, "device_set_wakeup_enable error %d\n", ret);
729 
730 	return ret;
731 }
732 
733 static const struct ethtool_ops smsc75xx_ethtool_ops = {
734 	.get_link	= usbnet_get_link,
735 	.nway_reset	= usbnet_nway_reset,
736 	.get_drvinfo	= usbnet_get_drvinfo,
737 	.get_msglevel	= usbnet_get_msglevel,
738 	.set_msglevel	= usbnet_set_msglevel,
739 	.get_eeprom_len	= smsc75xx_ethtool_get_eeprom_len,
740 	.get_eeprom	= smsc75xx_ethtool_get_eeprom,
741 	.set_eeprom	= smsc75xx_ethtool_set_eeprom,
742 	.get_wol	= smsc75xx_ethtool_get_wol,
743 	.set_wol	= smsc75xx_ethtool_set_wol,
744 	.get_link_ksettings	= usbnet_get_link_ksettings_mii,
745 	.set_link_ksettings	= usbnet_set_link_ksettings_mii,
746 };
747 
748 static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
749 {
750 	struct usbnet *dev = netdev_priv(netdev);
751 
752 	if (!netif_running(netdev))
753 		return -EINVAL;
754 
755 	return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
756 }
757 
758 static void smsc75xx_init_mac_address(struct usbnet *dev)
759 {
760 	u8 addr[ETH_ALEN];
761 
762 	/* maybe the boot loader passed the MAC address in devicetree */
763 	if (!platform_get_ethdev_address(&dev->udev->dev, dev->net)) {
764 		if (is_valid_ether_addr(dev->net->dev_addr)) {
765 			/* device tree values are valid so use them */
766 			netif_dbg(dev, ifup, dev->net, "MAC address read from the device tree\n");
767 			return;
768 		}
769 	}
770 
771 	/* try reading mac address from EEPROM */
772 	if (smsc75xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN, addr) == 0) {
773 		eth_hw_addr_set(dev->net, addr);
774 		if (is_valid_ether_addr(dev->net->dev_addr)) {
775 			/* eeprom values are valid so use them */
776 			netif_dbg(dev, ifup, dev->net,
777 				  "MAC address read from EEPROM\n");
778 			return;
779 		}
780 	}
781 
782 	/* no useful static MAC address found. generate a random one */
783 	eth_hw_addr_random(dev->net);
784 	netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n");
785 }
786 
787 static int smsc75xx_set_mac_address(struct usbnet *dev)
788 {
789 	u32 addr_lo = dev->net->dev_addr[0] | dev->net->dev_addr[1] << 8 |
790 		dev->net->dev_addr[2] << 16 | dev->net->dev_addr[3] << 24;
791 	u32 addr_hi = dev->net->dev_addr[4] | dev->net->dev_addr[5] << 8;
792 
793 	int ret = smsc75xx_write_reg(dev, RX_ADDRH, addr_hi);
794 	if (ret < 0) {
795 		netdev_warn(dev->net, "Failed to write RX_ADDRH: %d\n", ret);
796 		return ret;
797 	}
798 
799 	ret = smsc75xx_write_reg(dev, RX_ADDRL, addr_lo);
800 	if (ret < 0) {
801 		netdev_warn(dev->net, "Failed to write RX_ADDRL: %d\n", ret);
802 		return ret;
803 	}
804 
805 	addr_hi |= ADDR_FILTX_FB_VALID;
806 	ret = smsc75xx_write_reg(dev, ADDR_FILTX, addr_hi);
807 	if (ret < 0) {
808 		netdev_warn(dev->net, "Failed to write ADDR_FILTX: %d\n", ret);
809 		return ret;
810 	}
811 
812 	ret = smsc75xx_write_reg(dev, ADDR_FILTX + 4, addr_lo);
813 	if (ret < 0)
814 		netdev_warn(dev->net, "Failed to write ADDR_FILTX+4: %d\n", ret);
815 
816 	return ret;
817 }
818 
819 static int smsc75xx_phy_initialize(struct usbnet *dev)
820 {
821 	int bmcr, ret, timeout = 0;
822 
823 	/* Initialize MII structure */
824 	dev->mii.dev = dev->net;
825 	dev->mii.mdio_read = smsc75xx_mdio_read;
826 	dev->mii.mdio_write = smsc75xx_mdio_write;
827 	dev->mii.phy_id_mask = 0x1f;
828 	dev->mii.reg_num_mask = 0x1f;
829 	dev->mii.supports_gmii = 1;
830 	dev->mii.phy_id = SMSC75XX_INTERNAL_PHY_ID;
831 
832 	/* reset phy and wait for reset to complete */
833 	smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
834 
835 	do {
836 		msleep(10);
837 		bmcr = smsc75xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR);
838 		if (bmcr < 0) {
839 			netdev_warn(dev->net, "Error reading MII_BMCR\n");
840 			return bmcr;
841 		}
842 		timeout++;
843 	} while ((bmcr & BMCR_RESET) && (timeout < 100));
844 
845 	if (timeout >= 100) {
846 		netdev_warn(dev->net, "timeout on PHY Reset\n");
847 		return -EIO;
848 	}
849 
850 	/* phy workaround for gig link */
851 	smsc75xx_phy_gig_workaround(dev);
852 
853 	smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
854 		ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP |
855 		ADVERTISE_PAUSE_ASYM);
856 	smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_CTRL1000,
857 		ADVERTISE_1000FULL);
858 
859 	/* read and write to clear phy interrupt status */
860 	ret = smsc75xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC);
861 	if (ret < 0) {
862 		netdev_warn(dev->net, "Error reading PHY_INT_SRC\n");
863 		return ret;
864 	}
865 
866 	smsc75xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_SRC, 0xffff);
867 
868 	smsc75xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_MASK,
869 		PHY_INT_MASK_DEFAULT);
870 	mii_nway_restart(&dev->mii);
871 
872 	netif_dbg(dev, ifup, dev->net, "phy initialised successfully\n");
873 	return 0;
874 }
875 
876 static int smsc75xx_set_rx_max_frame_length(struct usbnet *dev, int size)
877 {
878 	int ret = 0;
879 	u32 buf;
880 	bool rxenabled;
881 
882 	ret = smsc75xx_read_reg(dev, MAC_RX, &buf);
883 	if (ret < 0) {
884 		netdev_warn(dev->net, "Failed to read MAC_RX: %d\n", ret);
885 		return ret;
886 	}
887 
888 	rxenabled = ((buf & MAC_RX_RXEN) != 0);
889 
890 	if (rxenabled) {
891 		buf &= ~MAC_RX_RXEN;
892 		ret = smsc75xx_write_reg(dev, MAC_RX, buf);
893 		if (ret < 0) {
894 			netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret);
895 			return ret;
896 		}
897 	}
898 
899 	/* add 4 to size for FCS */
900 	buf &= ~MAC_RX_MAX_SIZE;
901 	buf |= (((size + 4) << MAC_RX_MAX_SIZE_SHIFT) & MAC_RX_MAX_SIZE);
902 
903 	ret = smsc75xx_write_reg(dev, MAC_RX, buf);
904 	if (ret < 0) {
905 		netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret);
906 		return ret;
907 	}
908 
909 	if (rxenabled) {
910 		buf |= MAC_RX_RXEN;
911 		ret = smsc75xx_write_reg(dev, MAC_RX, buf);
912 		if (ret < 0) {
913 			netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret);
914 			return ret;
915 		}
916 	}
917 
918 	return 0;
919 }
920 
921 static int smsc75xx_change_mtu(struct net_device *netdev, int new_mtu)
922 {
923 	struct usbnet *dev = netdev_priv(netdev);
924 	int ret;
925 
926 	ret = smsc75xx_set_rx_max_frame_length(dev, new_mtu + ETH_HLEN);
927 	if (ret < 0) {
928 		netdev_warn(dev->net, "Failed to set mac rx frame length\n");
929 		return ret;
930 	}
931 
932 	return usbnet_change_mtu(netdev, new_mtu);
933 }
934 
935 /* Enable or disable Rx checksum offload engine */
936 static int smsc75xx_set_features(struct net_device *netdev,
937 	netdev_features_t features)
938 {
939 	struct usbnet *dev = netdev_priv(netdev);
940 	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
941 	unsigned long flags;
942 	int ret;
943 
944 	spin_lock_irqsave(&pdata->rfe_ctl_lock, flags);
945 
946 	if (features & NETIF_F_RXCSUM)
947 		pdata->rfe_ctl |= RFE_CTL_TCPUDP_CKM | RFE_CTL_IP_CKM;
948 	else
949 		pdata->rfe_ctl &= ~(RFE_CTL_TCPUDP_CKM | RFE_CTL_IP_CKM);
950 
951 	spin_unlock_irqrestore(&pdata->rfe_ctl_lock, flags);
952 	/* it's racing here! */
953 
954 	ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl);
955 	if (ret < 0) {
956 		netdev_warn(dev->net, "Error writing RFE_CTL\n");
957 		return ret;
958 	}
959 	return 0;
960 }
961 
962 static int smsc75xx_wait_ready(struct usbnet *dev, int in_pm)
963 {
964 	int timeout = 0;
965 
966 	do {
967 		u32 buf;
968 		int ret;
969 
970 		ret = __smsc75xx_read_reg(dev, PMT_CTL, &buf, in_pm);
971 
972 		if (ret < 0) {
973 			netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret);
974 			return ret;
975 		}
976 
977 		if (buf & PMT_CTL_DEV_RDY)
978 			return 0;
979 
980 		msleep(10);
981 		timeout++;
982 	} while (timeout < 100);
983 
984 	netdev_warn(dev->net, "timeout waiting for device ready\n");
985 	return -EIO;
986 }
987 
988 static int smsc75xx_phy_gig_workaround(struct usbnet *dev)
989 {
990 	struct mii_if_info *mii = &dev->mii;
991 	int ret = 0, timeout = 0;
992 	u32 buf, link_up = 0;
993 
994 	/* Set the phy in Gig loopback */
995 	smsc75xx_mdio_write(dev->net, mii->phy_id, MII_BMCR, 0x4040);
996 
997 	/* Wait for the link up */
998 	do {
999 		link_up = smsc75xx_link_ok_nopm(dev);
1000 		usleep_range(10000, 20000);
1001 		timeout++;
1002 	} while ((!link_up) && (timeout < 1000));
1003 
1004 	if (timeout >= 1000) {
1005 		netdev_warn(dev->net, "Timeout waiting for PHY link up\n");
1006 		return -EIO;
1007 	}
1008 
1009 	/* phy reset */
1010 	ret = smsc75xx_read_reg(dev, PMT_CTL, &buf);
1011 	if (ret < 0) {
1012 		netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret);
1013 		return ret;
1014 	}
1015 
1016 	buf |= PMT_CTL_PHY_RST;
1017 
1018 	ret = smsc75xx_write_reg(dev, PMT_CTL, buf);
1019 	if (ret < 0) {
1020 		netdev_warn(dev->net, "Failed to write PMT_CTL: %d\n", ret);
1021 		return ret;
1022 	}
1023 
1024 	timeout = 0;
1025 	do {
1026 		usleep_range(10000, 20000);
1027 		ret = smsc75xx_read_reg(dev, PMT_CTL, &buf);
1028 		if (ret < 0) {
1029 			netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n",
1030 				    ret);
1031 			return ret;
1032 		}
1033 		timeout++;
1034 	} while ((buf & PMT_CTL_PHY_RST) && (timeout < 100));
1035 
1036 	if (timeout >= 100) {
1037 		netdev_warn(dev->net, "timeout waiting for PHY Reset\n");
1038 		return -EIO;
1039 	}
1040 
1041 	return 0;
1042 }
1043 
1044 static int smsc75xx_reset(struct usbnet *dev)
1045 {
1046 	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
1047 	u32 buf;
1048 	int ret = 0, timeout;
1049 
1050 	netif_dbg(dev, ifup, dev->net, "entering smsc75xx_reset\n");
1051 
1052 	ret = smsc75xx_wait_ready(dev, 0);
1053 	if (ret < 0) {
1054 		netdev_warn(dev->net, "device not ready in smsc75xx_reset\n");
1055 		return ret;
1056 	}
1057 
1058 	ret = smsc75xx_read_reg(dev, HW_CFG, &buf);
1059 	if (ret < 0) {
1060 		netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
1061 		return ret;
1062 	}
1063 
1064 	buf |= HW_CFG_LRST;
1065 
1066 	ret = smsc75xx_write_reg(dev, HW_CFG, buf);
1067 	if (ret < 0) {
1068 		netdev_warn(dev->net, "Failed to write HW_CFG: %d\n", ret);
1069 		return ret;
1070 	}
1071 
1072 	timeout = 0;
1073 	do {
1074 		msleep(10);
1075 		ret = smsc75xx_read_reg(dev, HW_CFG, &buf);
1076 		if (ret < 0) {
1077 			netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
1078 			return ret;
1079 		}
1080 		timeout++;
1081 	} while ((buf & HW_CFG_LRST) && (timeout < 100));
1082 
1083 	if (timeout >= 100) {
1084 		netdev_warn(dev->net, "timeout on completion of Lite Reset\n");
1085 		return -EIO;
1086 	}
1087 
1088 	netif_dbg(dev, ifup, dev->net, "Lite reset complete, resetting PHY\n");
1089 
1090 	ret = smsc75xx_read_reg(dev, PMT_CTL, &buf);
1091 	if (ret < 0) {
1092 		netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret);
1093 		return ret;
1094 	}
1095 
1096 	buf |= PMT_CTL_PHY_RST;
1097 
1098 	ret = smsc75xx_write_reg(dev, PMT_CTL, buf);
1099 	if (ret < 0) {
1100 		netdev_warn(dev->net, "Failed to write PMT_CTL: %d\n", ret);
1101 		return ret;
1102 	}
1103 
1104 	timeout = 0;
1105 	do {
1106 		msleep(10);
1107 		ret = smsc75xx_read_reg(dev, PMT_CTL, &buf);
1108 		if (ret < 0) {
1109 			netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret);
1110 			return ret;
1111 		}
1112 		timeout++;
1113 	} while ((buf & PMT_CTL_PHY_RST) && (timeout < 100));
1114 
1115 	if (timeout >= 100) {
1116 		netdev_warn(dev->net, "timeout waiting for PHY Reset\n");
1117 		return -EIO;
1118 	}
1119 
1120 	netif_dbg(dev, ifup, dev->net, "PHY reset complete\n");
1121 
1122 	ret = smsc75xx_set_mac_address(dev);
1123 	if (ret < 0) {
1124 		netdev_warn(dev->net, "Failed to set mac address\n");
1125 		return ret;
1126 	}
1127 
1128 	netif_dbg(dev, ifup, dev->net, "MAC Address: %pM\n",
1129 		  dev->net->dev_addr);
1130 
1131 	ret = smsc75xx_read_reg(dev, HW_CFG, &buf);
1132 	if (ret < 0) {
1133 		netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
1134 		return ret;
1135 	}
1136 
1137 	netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG : 0x%08x\n",
1138 		  buf);
1139 
1140 	buf |= HW_CFG_BIR;
1141 
1142 	ret = smsc75xx_write_reg(dev, HW_CFG, buf);
1143 	if (ret < 0) {
1144 		netdev_warn(dev->net,  "Failed to write HW_CFG: %d\n", ret);
1145 		return ret;
1146 	}
1147 
1148 	ret = smsc75xx_read_reg(dev, HW_CFG, &buf);
1149 	if (ret < 0) {
1150 		netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
1151 		return ret;
1152 	}
1153 
1154 	netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG after writing HW_CFG_BIR: 0x%08x\n",
1155 		  buf);
1156 
1157 	if (!turbo_mode) {
1158 		buf = 0;
1159 		dev->rx_urb_size = MAX_SINGLE_PACKET_SIZE;
1160 	} else if (dev->udev->speed == USB_SPEED_HIGH) {
1161 		buf = DEFAULT_HS_BURST_CAP_SIZE / HS_USB_PKT_SIZE;
1162 		dev->rx_urb_size = DEFAULT_HS_BURST_CAP_SIZE;
1163 	} else {
1164 		buf = DEFAULT_FS_BURST_CAP_SIZE / FS_USB_PKT_SIZE;
1165 		dev->rx_urb_size = DEFAULT_FS_BURST_CAP_SIZE;
1166 	}
1167 
1168 	netif_dbg(dev, ifup, dev->net, "rx_urb_size=%ld\n",
1169 		  (ulong)dev->rx_urb_size);
1170 
1171 	ret = smsc75xx_write_reg(dev, BURST_CAP, buf);
1172 	if (ret < 0) {
1173 		netdev_warn(dev->net, "Failed to write BURST_CAP: %d\n", ret);
1174 		return ret;
1175 	}
1176 
1177 	ret = smsc75xx_read_reg(dev, BURST_CAP, &buf);
1178 	if (ret < 0) {
1179 		netdev_warn(dev->net, "Failed to read BURST_CAP: %d\n", ret);
1180 		return ret;
1181 	}
1182 
1183 	netif_dbg(dev, ifup, dev->net,
1184 		  "Read Value from BURST_CAP after writing: 0x%08x\n", buf);
1185 
1186 	ret = smsc75xx_write_reg(dev, BULK_IN_DLY, DEFAULT_BULK_IN_DELAY);
1187 	if (ret < 0) {
1188 		netdev_warn(dev->net, "Failed to write BULK_IN_DLY: %d\n", ret);
1189 		return ret;
1190 	}
1191 
1192 	ret = smsc75xx_read_reg(dev, BULK_IN_DLY, &buf);
1193 	if (ret < 0) {
1194 		netdev_warn(dev->net, "Failed to read BULK_IN_DLY: %d\n", ret);
1195 		return ret;
1196 	}
1197 
1198 	netif_dbg(dev, ifup, dev->net,
1199 		  "Read Value from BULK_IN_DLY after writing: 0x%08x\n", buf);
1200 
1201 	if (turbo_mode) {
1202 		ret = smsc75xx_read_reg(dev, HW_CFG, &buf);
1203 		if (ret < 0) {
1204 			netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
1205 			return ret;
1206 		}
1207 
1208 		netif_dbg(dev, ifup, dev->net, "HW_CFG: 0x%08x\n", buf);
1209 
1210 		buf |= (HW_CFG_MEF | HW_CFG_BCE);
1211 
1212 		ret = smsc75xx_write_reg(dev, HW_CFG, buf);
1213 		if (ret < 0) {
1214 			netdev_warn(dev->net, "Failed to write HW_CFG: %d\n", ret);
1215 			return ret;
1216 		}
1217 
1218 		ret = smsc75xx_read_reg(dev, HW_CFG, &buf);
1219 		if (ret < 0) {
1220 			netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
1221 			return ret;
1222 		}
1223 
1224 		netif_dbg(dev, ifup, dev->net, "HW_CFG: 0x%08x\n", buf);
1225 	}
1226 
1227 	/* set FIFO sizes */
1228 	buf = (MAX_RX_FIFO_SIZE - 512) / 512;
1229 	ret = smsc75xx_write_reg(dev, FCT_RX_FIFO_END, buf);
1230 	if (ret < 0) {
1231 		netdev_warn(dev->net, "Failed to write FCT_RX_FIFO_END: %d\n", ret);
1232 		return ret;
1233 	}
1234 
1235 	netif_dbg(dev, ifup, dev->net, "FCT_RX_FIFO_END set to 0x%08x\n", buf);
1236 
1237 	buf = (MAX_TX_FIFO_SIZE - 512) / 512;
1238 	ret = smsc75xx_write_reg(dev, FCT_TX_FIFO_END, buf);
1239 	if (ret < 0) {
1240 		netdev_warn(dev->net, "Failed to write FCT_TX_FIFO_END: %d\n", ret);
1241 		return ret;
1242 	}
1243 
1244 	netif_dbg(dev, ifup, dev->net, "FCT_TX_FIFO_END set to 0x%08x\n", buf);
1245 
1246 	ret = smsc75xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL);
1247 	if (ret < 0) {
1248 		netdev_warn(dev->net, "Failed to write INT_STS: %d\n", ret);
1249 		return ret;
1250 	}
1251 
1252 	ret = smsc75xx_read_reg(dev, ID_REV, &buf);
1253 	if (ret < 0) {
1254 		netdev_warn(dev->net, "Failed to read ID_REV: %d\n", ret);
1255 		return ret;
1256 	}
1257 
1258 	netif_dbg(dev, ifup, dev->net, "ID_REV = 0x%08x\n", buf);
1259 
1260 	ret = smsc75xx_read_reg(dev, E2P_CMD, &buf);
1261 	if (ret < 0) {
1262 		netdev_warn(dev->net, "Failed to read E2P_CMD: %d\n", ret);
1263 		return ret;
1264 	}
1265 
1266 	/* only set default GPIO/LED settings if no EEPROM is detected */
1267 	if (!(buf & E2P_CMD_LOADED)) {
1268 		ret = smsc75xx_read_reg(dev, LED_GPIO_CFG, &buf);
1269 		if (ret < 0) {
1270 			netdev_warn(dev->net, "Failed to read LED_GPIO_CFG: %d\n", ret);
1271 			return ret;
1272 		}
1273 
1274 		buf &= ~(LED_GPIO_CFG_LED2_FUN_SEL | LED_GPIO_CFG_LED10_FUN_SEL);
1275 		buf |= LED_GPIO_CFG_LEDGPIO_EN | LED_GPIO_CFG_LED2_FUN_SEL;
1276 
1277 		ret = smsc75xx_write_reg(dev, LED_GPIO_CFG, buf);
1278 		if (ret < 0) {
1279 			netdev_warn(dev->net, "Failed to write LED_GPIO_CFG: %d\n", ret);
1280 			return ret;
1281 		}
1282 	}
1283 
1284 	ret = smsc75xx_write_reg(dev, FLOW, 0);
1285 	if (ret < 0) {
1286 		netdev_warn(dev->net, "Failed to write FLOW: %d\n", ret);
1287 		return ret;
1288 	}
1289 
1290 	ret = smsc75xx_write_reg(dev, FCT_FLOW, 0);
1291 	if (ret < 0) {
1292 		netdev_warn(dev->net, "Failed to write FCT_FLOW: %d\n", ret);
1293 		return ret;
1294 	}
1295 
1296 	/* Don't need rfe_ctl_lock during initialisation */
1297 	ret = smsc75xx_read_reg(dev, RFE_CTL, &pdata->rfe_ctl);
1298 	if (ret < 0) {
1299 		netdev_warn(dev->net, "Failed to read RFE_CTL: %d\n", ret);
1300 		return ret;
1301 	}
1302 
1303 	pdata->rfe_ctl |= RFE_CTL_AB | RFE_CTL_DPF;
1304 
1305 	ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl);
1306 	if (ret < 0) {
1307 		netdev_warn(dev->net, "Failed to write RFE_CTL: %d\n", ret);
1308 		return ret;
1309 	}
1310 
1311 	ret = smsc75xx_read_reg(dev, RFE_CTL, &pdata->rfe_ctl);
1312 	if (ret < 0) {
1313 		netdev_warn(dev->net, "Failed to read RFE_CTL: %d\n", ret);
1314 		return ret;
1315 	}
1316 
1317 	netif_dbg(dev, ifup, dev->net, "RFE_CTL set to 0x%08x\n",
1318 		  pdata->rfe_ctl);
1319 
1320 	/* Enable or disable checksum offload engines */
1321 	smsc75xx_set_features(dev->net, dev->net->features);
1322 
1323 	smsc75xx_set_multicast(dev->net);
1324 
1325 	ret = smsc75xx_phy_initialize(dev);
1326 	if (ret < 0) {
1327 		netdev_warn(dev->net, "Failed to initialize PHY: %d\n", ret);
1328 		return ret;
1329 	}
1330 
1331 	ret = smsc75xx_read_reg(dev, INT_EP_CTL, &buf);
1332 	if (ret < 0) {
1333 		netdev_warn(dev->net, "Failed to read INT_EP_CTL: %d\n", ret);
1334 		return ret;
1335 	}
1336 
1337 	/* enable PHY interrupts */
1338 	buf |= INT_ENP_PHY_INT;
1339 
1340 	ret = smsc75xx_write_reg(dev, INT_EP_CTL, buf);
1341 	if (ret < 0) {
1342 		netdev_warn(dev->net, "Failed to write INT_EP_CTL: %d\n", ret);
1343 		return ret;
1344 	}
1345 
1346 	/* allow mac to detect speed and duplex from phy */
1347 	ret = smsc75xx_read_reg(dev, MAC_CR, &buf);
1348 	if (ret < 0) {
1349 		netdev_warn(dev->net, "Failed to read MAC_CR: %d\n", ret);
1350 		return ret;
1351 	}
1352 
1353 	buf |= (MAC_CR_ADD | MAC_CR_ASD);
1354 	ret = smsc75xx_write_reg(dev, MAC_CR, buf);
1355 	if (ret < 0) {
1356 		netdev_warn(dev->net, "Failed to write MAC_CR: %d\n", ret);
1357 		return ret;
1358 	}
1359 
1360 	ret = smsc75xx_read_reg(dev, MAC_TX, &buf);
1361 	if (ret < 0) {
1362 		netdev_warn(dev->net, "Failed to read MAC_TX: %d\n", ret);
1363 		return ret;
1364 	}
1365 
1366 	buf |= MAC_TX_TXEN;
1367 
1368 	ret = smsc75xx_write_reg(dev, MAC_TX, buf);
1369 	if (ret < 0) {
1370 		netdev_warn(dev->net, "Failed to write MAC_TX: %d\n", ret);
1371 		return ret;
1372 	}
1373 
1374 	netif_dbg(dev, ifup, dev->net, "MAC_TX set to 0x%08x\n", buf);
1375 
1376 	ret = smsc75xx_read_reg(dev, FCT_TX_CTL, &buf);
1377 	if (ret < 0) {
1378 		netdev_warn(dev->net, "Failed to read FCT_TX_CTL: %d\n", ret);
1379 		return ret;
1380 	}
1381 
1382 	buf |= FCT_TX_CTL_EN;
1383 
1384 	ret = smsc75xx_write_reg(dev, FCT_TX_CTL, buf);
1385 	if (ret < 0) {
1386 		netdev_warn(dev->net, "Failed to write FCT_TX_CTL: %d\n", ret);
1387 		return ret;
1388 	}
1389 
1390 	netif_dbg(dev, ifup, dev->net, "FCT_TX_CTL set to 0x%08x\n", buf);
1391 
1392 	ret = smsc75xx_set_rx_max_frame_length(dev, dev->net->mtu + ETH_HLEN);
1393 	if (ret < 0) {
1394 		netdev_warn(dev->net, "Failed to set max rx frame length\n");
1395 		return ret;
1396 	}
1397 
1398 	ret = smsc75xx_read_reg(dev, MAC_RX, &buf);
1399 	if (ret < 0) {
1400 		netdev_warn(dev->net, "Failed to read MAC_RX: %d\n", ret);
1401 		return ret;
1402 	}
1403 
1404 	buf |= MAC_RX_RXEN;
1405 
1406 	ret = smsc75xx_write_reg(dev, MAC_RX, buf);
1407 	if (ret < 0) {
1408 		netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret);
1409 		return ret;
1410 	}
1411 
1412 	netif_dbg(dev, ifup, dev->net, "MAC_RX set to 0x%08x\n", buf);
1413 
1414 	ret = smsc75xx_read_reg(dev, FCT_RX_CTL, &buf);
1415 	if (ret < 0) {
1416 		netdev_warn(dev->net, "Failed to read FCT_RX_CTL: %d\n", ret);
1417 		return ret;
1418 	}
1419 
1420 	buf |= FCT_RX_CTL_EN;
1421 
1422 	ret = smsc75xx_write_reg(dev, FCT_RX_CTL, buf);
1423 	if (ret < 0) {
1424 		netdev_warn(dev->net, "Failed to write FCT_RX_CTL: %d\n", ret);
1425 		return ret;
1426 	}
1427 
1428 	netif_dbg(dev, ifup, dev->net, "FCT_RX_CTL set to 0x%08x\n", buf);
1429 
1430 	netif_dbg(dev, ifup, dev->net, "smsc75xx_reset, return 0\n");
1431 	return 0;
1432 }
1433 
1434 static const struct net_device_ops smsc75xx_netdev_ops = {
1435 	.ndo_open		= usbnet_open,
1436 	.ndo_stop		= usbnet_stop,
1437 	.ndo_start_xmit		= usbnet_start_xmit,
1438 	.ndo_tx_timeout		= usbnet_tx_timeout,
1439 	.ndo_get_stats64	= dev_get_tstats64,
1440 	.ndo_change_mtu		= smsc75xx_change_mtu,
1441 	.ndo_set_mac_address 	= eth_mac_addr,
1442 	.ndo_validate_addr	= eth_validate_addr,
1443 	.ndo_eth_ioctl		= smsc75xx_ioctl,
1444 	.ndo_set_rx_mode	= smsc75xx_set_multicast,
1445 	.ndo_set_features	= smsc75xx_set_features,
1446 };
1447 
1448 static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
1449 {
1450 	struct smsc75xx_priv *pdata = NULL;
1451 	int ret;
1452 
1453 	printk(KERN_INFO SMSC_CHIPNAME " v" SMSC_DRIVER_VERSION "\n");
1454 
1455 	ret = usbnet_get_endpoints(dev, intf);
1456 	if (ret < 0) {
1457 		netdev_warn(dev->net, "usbnet_get_endpoints failed: %d\n", ret);
1458 		return ret;
1459 	}
1460 
1461 	dev->data[0] = (unsigned long)kzalloc(sizeof(struct smsc75xx_priv),
1462 					      GFP_KERNEL);
1463 
1464 	pdata = (struct smsc75xx_priv *)(dev->data[0]);
1465 	if (!pdata)
1466 		return -ENOMEM;
1467 
1468 	pdata->dev = dev;
1469 
1470 	spin_lock_init(&pdata->rfe_ctl_lock);
1471 	mutex_init(&pdata->dataport_mutex);
1472 
1473 	INIT_WORK(&pdata->set_multicast, smsc75xx_deferred_multicast_write);
1474 
1475 	if (DEFAULT_TX_CSUM_ENABLE)
1476 		dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
1477 
1478 	if (DEFAULT_RX_CSUM_ENABLE)
1479 		dev->net->features |= NETIF_F_RXCSUM;
1480 
1481 	dev->net->hw_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
1482 				NETIF_F_RXCSUM;
1483 
1484 	ret = smsc75xx_wait_ready(dev, 0);
1485 	if (ret < 0) {
1486 		netdev_warn(dev->net, "device not ready in smsc75xx_bind\n");
1487 		goto free_pdata;
1488 	}
1489 
1490 	smsc75xx_init_mac_address(dev);
1491 
1492 	/* Init all registers */
1493 	ret = smsc75xx_reset(dev);
1494 	if (ret < 0) {
1495 		netdev_warn(dev->net, "smsc75xx_reset error %d\n", ret);
1496 		goto cancel_work;
1497 	}
1498 
1499 	dev->net->netdev_ops = &smsc75xx_netdev_ops;
1500 	dev->net->ethtool_ops = &smsc75xx_ethtool_ops;
1501 	dev->net->flags |= IFF_MULTICAST;
1502 	dev->net->hard_header_len += SMSC75XX_TX_OVERHEAD;
1503 	dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len;
1504 	dev->net->max_mtu = MAX_SINGLE_PACKET_SIZE;
1505 	return 0;
1506 
1507 cancel_work:
1508 	cancel_work_sync(&pdata->set_multicast);
1509 free_pdata:
1510 	kfree(pdata);
1511 	dev->data[0] = 0;
1512 	return ret;
1513 }
1514 
1515 static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf)
1516 {
1517 	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
1518 	if (pdata) {
1519 		cancel_work_sync(&pdata->set_multicast);
1520 		netif_dbg(dev, ifdown, dev->net, "free pdata\n");
1521 		kfree(pdata);
1522 		dev->data[0] = 0;
1523 	}
1524 }
1525 
1526 static u16 smsc_crc(const u8 *buffer, size_t len)
1527 {
1528 	return bitrev16(crc16(0xFFFF, buffer, len));
1529 }
1530 
1531 static int smsc75xx_write_wuff(struct usbnet *dev, int filter, u32 wuf_cfg,
1532 			       u32 wuf_mask1)
1533 {
1534 	int cfg_base = WUF_CFGX + filter * 4;
1535 	int mask_base = WUF_MASKX + filter * 16;
1536 	int ret;
1537 
1538 	ret = smsc75xx_write_reg(dev, cfg_base, wuf_cfg);
1539 	if (ret < 0) {
1540 		netdev_warn(dev->net, "Error writing WUF_CFGX\n");
1541 		return ret;
1542 	}
1543 
1544 	ret = smsc75xx_write_reg(dev, mask_base, wuf_mask1);
1545 	if (ret < 0) {
1546 		netdev_warn(dev->net, "Error writing WUF_MASKX\n");
1547 		return ret;
1548 	}
1549 
1550 	ret = smsc75xx_write_reg(dev, mask_base + 4, 0);
1551 	if (ret < 0) {
1552 		netdev_warn(dev->net, "Error writing WUF_MASKX\n");
1553 		return ret;
1554 	}
1555 
1556 	ret = smsc75xx_write_reg(dev, mask_base + 8, 0);
1557 	if (ret < 0) {
1558 		netdev_warn(dev->net, "Error writing WUF_MASKX\n");
1559 		return ret;
1560 	}
1561 
1562 	ret = smsc75xx_write_reg(dev, mask_base + 12, 0);
1563 	if (ret < 0) {
1564 		netdev_warn(dev->net, "Error writing WUF_MASKX\n");
1565 		return ret;
1566 	}
1567 
1568 	return 0;
1569 }
1570 
1571 static int smsc75xx_enter_suspend0(struct usbnet *dev)
1572 {
1573 	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
1574 	u32 val;
1575 	int ret;
1576 
1577 	ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val);
1578 	if (ret < 0) {
1579 		netdev_warn(dev->net, "Error reading PMT_CTL\n");
1580 		return ret;
1581 	}
1582 
1583 	val &= (~(PMT_CTL_SUS_MODE | PMT_CTL_PHY_RST));
1584 	val |= PMT_CTL_SUS_MODE_0 | PMT_CTL_WOL_EN | PMT_CTL_WUPS;
1585 
1586 	ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1587 	if (ret < 0) {
1588 		netdev_warn(dev->net, "Error writing PMT_CTL\n");
1589 		return ret;
1590 	}
1591 
1592 	pdata->suspend_flags |= SUSPEND_SUSPEND0;
1593 
1594 	return 0;
1595 }
1596 
1597 static int smsc75xx_enter_suspend1(struct usbnet *dev)
1598 {
1599 	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
1600 	u32 val;
1601 	int ret;
1602 
1603 	ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val);
1604 	if (ret < 0) {
1605 		netdev_warn(dev->net, "Error reading PMT_CTL\n");
1606 		return ret;
1607 	}
1608 
1609 	val &= ~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST);
1610 	val |= PMT_CTL_SUS_MODE_1;
1611 
1612 	ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1613 	if (ret < 0) {
1614 		netdev_warn(dev->net, "Error writing PMT_CTL\n");
1615 		return ret;
1616 	}
1617 
1618 	/* clear wol status, enable energy detection */
1619 	val &= ~PMT_CTL_WUPS;
1620 	val |= (PMT_CTL_WUPS_ED | PMT_CTL_ED_EN);
1621 
1622 	ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1623 	if (ret < 0) {
1624 		netdev_warn(dev->net, "Error writing PMT_CTL\n");
1625 		return ret;
1626 	}
1627 
1628 	pdata->suspend_flags |= SUSPEND_SUSPEND1;
1629 
1630 	return 0;
1631 }
1632 
1633 static int smsc75xx_enter_suspend2(struct usbnet *dev)
1634 {
1635 	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
1636 	u32 val;
1637 	int ret;
1638 
1639 	ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val);
1640 	if (ret < 0) {
1641 		netdev_warn(dev->net, "Error reading PMT_CTL\n");
1642 		return ret;
1643 	}
1644 
1645 	val &= ~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST);
1646 	val |= PMT_CTL_SUS_MODE_2;
1647 
1648 	ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1649 	if (ret < 0) {
1650 		netdev_warn(dev->net, "Error writing PMT_CTL\n");
1651 		return ret;
1652 	}
1653 
1654 	pdata->suspend_flags |= SUSPEND_SUSPEND2;
1655 
1656 	return 0;
1657 }
1658 
1659 static int smsc75xx_enter_suspend3(struct usbnet *dev)
1660 {
1661 	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
1662 	u32 val;
1663 	int ret;
1664 
1665 	ret = smsc75xx_read_reg_nopm(dev, FCT_RX_CTL, &val);
1666 	if (ret < 0) {
1667 		netdev_warn(dev->net, "Error reading FCT_RX_CTL\n");
1668 		return ret;
1669 	}
1670 
1671 	if (val & FCT_RX_CTL_RXUSED) {
1672 		netdev_dbg(dev->net, "rx fifo not empty in autosuspend\n");
1673 		return -EBUSY;
1674 	}
1675 
1676 	ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val);
1677 	if (ret < 0) {
1678 		netdev_warn(dev->net, "Error reading PMT_CTL\n");
1679 		return ret;
1680 	}
1681 
1682 	val &= ~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST);
1683 	val |= PMT_CTL_SUS_MODE_3 | PMT_CTL_RES_CLR_WKP_EN;
1684 
1685 	ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1686 	if (ret < 0) {
1687 		netdev_warn(dev->net, "Error writing PMT_CTL\n");
1688 		return ret;
1689 	}
1690 
1691 	/* clear wol status */
1692 	val &= ~PMT_CTL_WUPS;
1693 	val |= PMT_CTL_WUPS_WOL;
1694 
1695 	ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1696 	if (ret < 0) {
1697 		netdev_warn(dev->net, "Error writing PMT_CTL\n");
1698 		return ret;
1699 	}
1700 
1701 	pdata->suspend_flags |= SUSPEND_SUSPEND3;
1702 
1703 	return 0;
1704 }
1705 
1706 static int smsc75xx_enable_phy_wakeup_interrupts(struct usbnet *dev, u16 mask)
1707 {
1708 	struct mii_if_info *mii = &dev->mii;
1709 	int ret;
1710 
1711 	netdev_dbg(dev->net, "enabling PHY wakeup interrupts\n");
1712 
1713 	/* read to clear */
1714 	ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_SRC);
1715 	if (ret < 0) {
1716 		netdev_warn(dev->net, "Error reading PHY_INT_SRC\n");
1717 		return ret;
1718 	}
1719 
1720 	/* enable interrupt source */
1721 	ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_MASK);
1722 	if (ret < 0) {
1723 		netdev_warn(dev->net, "Error reading PHY_INT_MASK\n");
1724 		return ret;
1725 	}
1726 
1727 	ret |= mask;
1728 
1729 	smsc75xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_INT_MASK, ret);
1730 
1731 	return 0;
1732 }
1733 
1734 static int smsc75xx_link_ok_nopm(struct usbnet *dev)
1735 {
1736 	struct mii_if_info *mii = &dev->mii;
1737 	int ret;
1738 
1739 	/* first, a dummy read, needed to latch some MII phys */
1740 	ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR);
1741 	if (ret < 0) {
1742 		netdev_warn(dev->net, "Error reading MII_BMSR\n");
1743 		return ret;
1744 	}
1745 
1746 	ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR);
1747 	if (ret < 0) {
1748 		netdev_warn(dev->net, "Error reading MII_BMSR\n");
1749 		return ret;
1750 	}
1751 
1752 	return !!(ret & BMSR_LSTATUS);
1753 }
1754 
1755 static int smsc75xx_autosuspend(struct usbnet *dev, u32 link_up)
1756 {
1757 	int ret;
1758 
1759 	if (!netif_running(dev->net)) {
1760 		/* interface is ifconfig down so fully power down hw */
1761 		netdev_dbg(dev->net, "autosuspend entering SUSPEND2\n");
1762 		return smsc75xx_enter_suspend2(dev);
1763 	}
1764 
1765 	if (!link_up) {
1766 		/* link is down so enter EDPD mode */
1767 		netdev_dbg(dev->net, "autosuspend entering SUSPEND1\n");
1768 
1769 		/* enable PHY wakeup events for if cable is attached */
1770 		ret = smsc75xx_enable_phy_wakeup_interrupts(dev,
1771 			PHY_INT_MASK_ANEG_COMP);
1772 		if (ret < 0) {
1773 			netdev_warn(dev->net, "error enabling PHY wakeup ints\n");
1774 			return ret;
1775 		}
1776 
1777 		netdev_info(dev->net, "entering SUSPEND1 mode\n");
1778 		return smsc75xx_enter_suspend1(dev);
1779 	}
1780 
1781 	/* enable PHY wakeup events so we remote wakeup if cable is pulled */
1782 	ret = smsc75xx_enable_phy_wakeup_interrupts(dev,
1783 		PHY_INT_MASK_LINK_DOWN);
1784 	if (ret < 0) {
1785 		netdev_warn(dev->net, "error enabling PHY wakeup ints\n");
1786 		return ret;
1787 	}
1788 
1789 	netdev_dbg(dev->net, "autosuspend entering SUSPEND3\n");
1790 	return smsc75xx_enter_suspend3(dev);
1791 }
1792 
1793 static int smsc75xx_suspend(struct usb_interface *intf, pm_message_t message)
1794 {
1795 	struct usbnet *dev = usb_get_intfdata(intf);
1796 	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
1797 	u32 val, link_up;
1798 	int ret;
1799 
1800 	ret = usbnet_suspend(intf, message);
1801 	if (ret < 0) {
1802 		netdev_warn(dev->net, "usbnet_suspend error\n");
1803 		return ret;
1804 	}
1805 
1806 	if (pdata->suspend_flags) {
1807 		netdev_warn(dev->net, "error during last resume\n");
1808 		pdata->suspend_flags = 0;
1809 	}
1810 
1811 	/* determine if link is up using only _nopm functions */
1812 	link_up = smsc75xx_link_ok_nopm(dev);
1813 
1814 	if (message.event == PM_EVENT_AUTO_SUSPEND) {
1815 		ret = smsc75xx_autosuspend(dev, link_up);
1816 		goto done;
1817 	}
1818 
1819 	/* if we get this far we're not autosuspending */
1820 	/* if no wol options set, or if link is down and we're not waking on
1821 	 * PHY activity, enter lowest power SUSPEND2 mode
1822 	 */
1823 	if (!(pdata->wolopts & SUPPORTED_WAKE) ||
1824 		!(link_up || (pdata->wolopts & WAKE_PHY))) {
1825 		netdev_info(dev->net, "entering SUSPEND2 mode\n");
1826 
1827 		/* disable energy detect (link up) & wake up events */
1828 		ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
1829 		if (ret < 0) {
1830 			netdev_warn(dev->net, "Error reading WUCSR\n");
1831 			goto done;
1832 		}
1833 
1834 		val &= ~(WUCSR_MPEN | WUCSR_WUEN);
1835 
1836 		ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
1837 		if (ret < 0) {
1838 			netdev_warn(dev->net, "Error writing WUCSR\n");
1839 			goto done;
1840 		}
1841 
1842 		ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val);
1843 		if (ret < 0) {
1844 			netdev_warn(dev->net, "Error reading PMT_CTL\n");
1845 			goto done;
1846 		}
1847 
1848 		val &= ~(PMT_CTL_ED_EN | PMT_CTL_WOL_EN);
1849 
1850 		ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1851 		if (ret < 0) {
1852 			netdev_warn(dev->net, "Error writing PMT_CTL\n");
1853 			goto done;
1854 		}
1855 
1856 		ret = smsc75xx_enter_suspend2(dev);
1857 		goto done;
1858 	}
1859 
1860 	if (pdata->wolopts & WAKE_PHY) {
1861 		ret = smsc75xx_enable_phy_wakeup_interrupts(dev,
1862 			(PHY_INT_MASK_ANEG_COMP | PHY_INT_MASK_LINK_DOWN));
1863 		if (ret < 0) {
1864 			netdev_warn(dev->net, "error enabling PHY wakeup ints\n");
1865 			goto done;
1866 		}
1867 
1868 		/* if link is down then configure EDPD and enter SUSPEND1,
1869 		 * otherwise enter SUSPEND0 below
1870 		 */
1871 		if (!link_up) {
1872 			struct mii_if_info *mii = &dev->mii;
1873 			netdev_info(dev->net, "entering SUSPEND1 mode\n");
1874 
1875 			/* enable energy detect power-down mode */
1876 			ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id,
1877 				PHY_MODE_CTRL_STS);
1878 			if (ret < 0) {
1879 				netdev_warn(dev->net, "Error reading PHY_MODE_CTRL_STS\n");
1880 				goto done;
1881 			}
1882 
1883 			ret |= MODE_CTRL_STS_EDPWRDOWN;
1884 
1885 			smsc75xx_mdio_write_nopm(dev->net, mii->phy_id,
1886 				PHY_MODE_CTRL_STS, ret);
1887 
1888 			/* enter SUSPEND1 mode */
1889 			ret = smsc75xx_enter_suspend1(dev);
1890 			goto done;
1891 		}
1892 	}
1893 
1894 	if (pdata->wolopts & (WAKE_MCAST | WAKE_ARP)) {
1895 		int i, filter = 0;
1896 
1897 		/* disable all filters */
1898 		for (i = 0; i < WUF_NUM; i++) {
1899 			ret = smsc75xx_write_reg_nopm(dev, WUF_CFGX + i * 4, 0);
1900 			if (ret < 0) {
1901 				netdev_warn(dev->net, "Error writing WUF_CFGX\n");
1902 				goto done;
1903 			}
1904 		}
1905 
1906 		if (pdata->wolopts & WAKE_MCAST) {
1907 			const u8 mcast[] = {0x01, 0x00, 0x5E};
1908 			netdev_info(dev->net, "enabling multicast detection\n");
1909 
1910 			val = WUF_CFGX_EN | WUF_CFGX_ATYPE_MULTICAST
1911 				| smsc_crc(mcast, 3);
1912 			ret = smsc75xx_write_wuff(dev, filter++, val, 0x0007);
1913 			if (ret < 0) {
1914 				netdev_warn(dev->net, "Error writing wakeup filter\n");
1915 				goto done;
1916 			}
1917 		}
1918 
1919 		if (pdata->wolopts & WAKE_ARP) {
1920 			const u8 arp[] = {0x08, 0x06};
1921 			netdev_info(dev->net, "enabling ARP detection\n");
1922 
1923 			val = WUF_CFGX_EN | WUF_CFGX_ATYPE_ALL | (0x0C << 16)
1924 				| smsc_crc(arp, 2);
1925 			ret = smsc75xx_write_wuff(dev, filter++, val, 0x0003);
1926 			if (ret < 0) {
1927 				netdev_warn(dev->net, "Error writing wakeup filter\n");
1928 				goto done;
1929 			}
1930 		}
1931 
1932 		/* clear any pending pattern match packet status */
1933 		ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
1934 		if (ret < 0) {
1935 			netdev_warn(dev->net, "Error reading WUCSR\n");
1936 			goto done;
1937 		}
1938 
1939 		val |= WUCSR_WUFR;
1940 
1941 		ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
1942 		if (ret < 0) {
1943 			netdev_warn(dev->net, "Error writing WUCSR\n");
1944 			goto done;
1945 		}
1946 
1947 		netdev_info(dev->net, "enabling packet match detection\n");
1948 		ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
1949 		if (ret < 0) {
1950 			netdev_warn(dev->net, "Error reading WUCSR\n");
1951 			goto done;
1952 		}
1953 
1954 		val |= WUCSR_WUEN;
1955 
1956 		ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
1957 		if (ret < 0) {
1958 			netdev_warn(dev->net, "Error writing WUCSR\n");
1959 			goto done;
1960 		}
1961 	} else {
1962 		netdev_info(dev->net, "disabling packet match detection\n");
1963 		ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
1964 		if (ret < 0) {
1965 			netdev_warn(dev->net, "Error reading WUCSR\n");
1966 			goto done;
1967 		}
1968 
1969 		val &= ~WUCSR_WUEN;
1970 
1971 		ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
1972 		if (ret < 0) {
1973 			netdev_warn(dev->net, "Error writing WUCSR\n");
1974 			goto done;
1975 		}
1976 	}
1977 
1978 	/* disable magic, bcast & unicast wakeup sources */
1979 	ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
1980 	if (ret < 0) {
1981 		netdev_warn(dev->net, "Error reading WUCSR\n");
1982 		goto done;
1983 	}
1984 
1985 	val &= ~(WUCSR_MPEN | WUCSR_BCST_EN | WUCSR_PFDA_EN);
1986 
1987 	ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
1988 	if (ret < 0) {
1989 		netdev_warn(dev->net, "Error writing WUCSR\n");
1990 		goto done;
1991 	}
1992 
1993 	if (pdata->wolopts & WAKE_PHY) {
1994 		netdev_info(dev->net, "enabling PHY wakeup\n");
1995 
1996 		ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val);
1997 		if (ret < 0) {
1998 			netdev_warn(dev->net, "Error reading PMT_CTL\n");
1999 			goto done;
2000 		}
2001 
2002 		/* clear wol status, enable energy detection */
2003 		val &= ~PMT_CTL_WUPS;
2004 		val |= (PMT_CTL_WUPS_ED | PMT_CTL_ED_EN);
2005 
2006 		ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
2007 		if (ret < 0) {
2008 			netdev_warn(dev->net, "Error writing PMT_CTL\n");
2009 			goto done;
2010 		}
2011 	}
2012 
2013 	if (pdata->wolopts & WAKE_MAGIC) {
2014 		netdev_info(dev->net, "enabling magic packet wakeup\n");
2015 		ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
2016 		if (ret < 0) {
2017 			netdev_warn(dev->net, "Error reading WUCSR\n");
2018 			goto done;
2019 		}
2020 
2021 		/* clear any pending magic packet status */
2022 		val |= WUCSR_MPR | WUCSR_MPEN;
2023 
2024 		ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
2025 		if (ret < 0) {
2026 			netdev_warn(dev->net, "Error writing WUCSR\n");
2027 			goto done;
2028 		}
2029 	}
2030 
2031 	if (pdata->wolopts & WAKE_BCAST) {
2032 		netdev_info(dev->net, "enabling broadcast detection\n");
2033 		ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
2034 		if (ret < 0) {
2035 			netdev_warn(dev->net, "Error reading WUCSR\n");
2036 			goto done;
2037 		}
2038 
2039 		val |= WUCSR_BCAST_FR | WUCSR_BCST_EN;
2040 
2041 		ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
2042 		if (ret < 0) {
2043 			netdev_warn(dev->net, "Error writing WUCSR\n");
2044 			goto done;
2045 		}
2046 	}
2047 
2048 	if (pdata->wolopts & WAKE_UCAST) {
2049 		netdev_info(dev->net, "enabling unicast detection\n");
2050 		ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
2051 		if (ret < 0) {
2052 			netdev_warn(dev->net, "Error reading WUCSR\n");
2053 			goto done;
2054 		}
2055 
2056 		val |= WUCSR_WUFR | WUCSR_PFDA_EN;
2057 
2058 		ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
2059 		if (ret < 0) {
2060 			netdev_warn(dev->net, "Error writing WUCSR\n");
2061 			goto done;
2062 		}
2063 	}
2064 
2065 	/* enable receiver to enable frame reception */
2066 	ret = smsc75xx_read_reg_nopm(dev, MAC_RX, &val);
2067 	if (ret < 0) {
2068 		netdev_warn(dev->net, "Failed to read MAC_RX: %d\n", ret);
2069 		goto done;
2070 	}
2071 
2072 	val |= MAC_RX_RXEN;
2073 
2074 	ret = smsc75xx_write_reg_nopm(dev, MAC_RX, val);
2075 	if (ret < 0) {
2076 		netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret);
2077 		goto done;
2078 	}
2079 
2080 	/* some wol options are enabled, so enter SUSPEND0 */
2081 	netdev_info(dev->net, "entering SUSPEND0 mode\n");
2082 	ret = smsc75xx_enter_suspend0(dev);
2083 
2084 done:
2085 	/*
2086 	 * TODO: resume() might need to handle the suspend failure
2087 	 * in system sleep
2088 	 */
2089 	if (ret && PMSG_IS_AUTO(message))
2090 		usbnet_resume(intf);
2091 	return ret;
2092 }
2093 
2094 static int smsc75xx_resume(struct usb_interface *intf)
2095 {
2096 	struct usbnet *dev = usb_get_intfdata(intf);
2097 	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
2098 	u8 suspend_flags = pdata->suspend_flags;
2099 	int ret;
2100 	u32 val;
2101 
2102 	netdev_dbg(dev->net, "resume suspend_flags=0x%02x\n", suspend_flags);
2103 
2104 	/* do this first to ensure it's cleared even in error case */
2105 	pdata->suspend_flags = 0;
2106 
2107 	if (suspend_flags & SUSPEND_ALLMODES) {
2108 		/* Disable wakeup sources */
2109 		ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
2110 		if (ret < 0) {
2111 			netdev_warn(dev->net, "Error reading WUCSR\n");
2112 			return ret;
2113 		}
2114 
2115 		val &= ~(WUCSR_WUEN | WUCSR_MPEN | WUCSR_PFDA_EN
2116 			| WUCSR_BCST_EN);
2117 
2118 		ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
2119 		if (ret < 0) {
2120 			netdev_warn(dev->net, "Error writing WUCSR\n");
2121 			return ret;
2122 		}
2123 
2124 		/* clear wake-up status */
2125 		ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val);
2126 		if (ret < 0) {
2127 			netdev_warn(dev->net, "Error reading PMT_CTL\n");
2128 			return ret;
2129 		}
2130 
2131 		val &= ~PMT_CTL_WOL_EN;
2132 		val |= PMT_CTL_WUPS;
2133 
2134 		ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
2135 		if (ret < 0) {
2136 			netdev_warn(dev->net, "Error writing PMT_CTL\n");
2137 			return ret;
2138 		}
2139 	}
2140 
2141 	if (suspend_flags & SUSPEND_SUSPEND2) {
2142 		netdev_info(dev->net, "resuming from SUSPEND2\n");
2143 
2144 		ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val);
2145 		if (ret < 0) {
2146 			netdev_warn(dev->net, "Error reading PMT_CTL\n");
2147 			return ret;
2148 		}
2149 
2150 		val |= PMT_CTL_PHY_PWRUP;
2151 
2152 		ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
2153 		if (ret < 0) {
2154 			netdev_warn(dev->net, "Error writing PMT_CTL\n");
2155 			return ret;
2156 		}
2157 	}
2158 
2159 	ret = smsc75xx_wait_ready(dev, 1);
2160 	if (ret < 0) {
2161 		netdev_warn(dev->net, "device not ready in smsc75xx_resume\n");
2162 		return ret;
2163 	}
2164 
2165 	return usbnet_resume(intf);
2166 }
2167 
2168 static void smsc75xx_rx_csum_offload(struct usbnet *dev, struct sk_buff *skb,
2169 				     u32 rx_cmd_a, u32 rx_cmd_b)
2170 {
2171 	if (!(dev->net->features & NETIF_F_RXCSUM) ||
2172 	    unlikely(rx_cmd_a & RX_CMD_A_LCSM)) {
2173 		skb->ip_summed = CHECKSUM_NONE;
2174 	} else {
2175 		skb->csum = ntohs((u16)(rx_cmd_b >> RX_CMD_B_CSUM_SHIFT));
2176 		skb->ip_summed = CHECKSUM_COMPLETE;
2177 	}
2178 }
2179 
2180 static int smsc75xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
2181 {
2182 	/* This check is no longer done by usbnet */
2183 	if (skb->len < dev->net->hard_header_len)
2184 		return 0;
2185 
2186 	while (skb->len > 0) {
2187 		u32 rx_cmd_a, rx_cmd_b, align_count, size;
2188 		struct sk_buff *ax_skb;
2189 		unsigned char *packet;
2190 
2191 		rx_cmd_a = get_unaligned_le32(skb->data);
2192 		skb_pull(skb, 4);
2193 
2194 		rx_cmd_b = get_unaligned_le32(skb->data);
2195 		skb_pull(skb, 4 + RXW_PADDING);
2196 
2197 		packet = skb->data;
2198 
2199 		/* get the packet length */
2200 		size = (rx_cmd_a & RX_CMD_A_LEN) - RXW_PADDING;
2201 		align_count = (4 - ((size + RXW_PADDING) % 4)) % 4;
2202 
2203 		if (unlikely(size > skb->len)) {
2204 			netif_dbg(dev, rx_err, dev->net,
2205 				  "size err rx_cmd_a=0x%08x\n",
2206 				  rx_cmd_a);
2207 			return 0;
2208 		}
2209 
2210 		if (unlikely(rx_cmd_a & RX_CMD_A_RED)) {
2211 			netif_dbg(dev, rx_err, dev->net,
2212 				  "Error rx_cmd_a=0x%08x\n", rx_cmd_a);
2213 			dev->net->stats.rx_errors++;
2214 			dev->net->stats.rx_dropped++;
2215 
2216 			if (rx_cmd_a & RX_CMD_A_FCS)
2217 				dev->net->stats.rx_crc_errors++;
2218 			else if (rx_cmd_a & (RX_CMD_A_LONG | RX_CMD_A_RUNT))
2219 				dev->net->stats.rx_frame_errors++;
2220 		} else {
2221 			/* MAX_SINGLE_PACKET_SIZE + 4(CRC) + 2(COE) + 4(Vlan) */
2222 			if (unlikely(size > (MAX_SINGLE_PACKET_SIZE + ETH_HLEN + 12))) {
2223 				netif_dbg(dev, rx_err, dev->net,
2224 					  "size err rx_cmd_a=0x%08x\n",
2225 					  rx_cmd_a);
2226 				return 0;
2227 			}
2228 
2229 			/* last frame in this batch */
2230 			if (skb->len == size) {
2231 				smsc75xx_rx_csum_offload(dev, skb, rx_cmd_a,
2232 					rx_cmd_b);
2233 
2234 				skb_trim(skb, skb->len - 4); /* remove fcs */
2235 				skb->truesize = size + sizeof(struct sk_buff);
2236 
2237 				return 1;
2238 			}
2239 
2240 			ax_skb = skb_clone(skb, GFP_ATOMIC);
2241 			if (unlikely(!ax_skb)) {
2242 				netdev_warn(dev->net, "Error allocating skb\n");
2243 				return 0;
2244 			}
2245 
2246 			ax_skb->len = size;
2247 			ax_skb->data = packet;
2248 			skb_set_tail_pointer(ax_skb, size);
2249 
2250 			smsc75xx_rx_csum_offload(dev, ax_skb, rx_cmd_a,
2251 				rx_cmd_b);
2252 
2253 			skb_trim(ax_skb, ax_skb->len - 4); /* remove fcs */
2254 			ax_skb->truesize = size + sizeof(struct sk_buff);
2255 
2256 			usbnet_skb_return(dev, ax_skb);
2257 		}
2258 
2259 		skb_pull(skb, size);
2260 
2261 		/* padding bytes before the next frame starts */
2262 		if (skb->len)
2263 			skb_pull(skb, align_count);
2264 	}
2265 
2266 	return 1;
2267 }
2268 
2269 static struct sk_buff *smsc75xx_tx_fixup(struct usbnet *dev,
2270 					 struct sk_buff *skb, gfp_t flags)
2271 {
2272 	u32 tx_cmd_a, tx_cmd_b;
2273 	void *ptr;
2274 
2275 	if (skb_cow_head(skb, SMSC75XX_TX_OVERHEAD)) {
2276 		dev_kfree_skb_any(skb);
2277 		return NULL;
2278 	}
2279 
2280 	tx_cmd_a = (u32)(skb->len & TX_CMD_A_LEN) | TX_CMD_A_FCS;
2281 
2282 	if (skb->ip_summed == CHECKSUM_PARTIAL)
2283 		tx_cmd_a |= TX_CMD_A_IPE | TX_CMD_A_TPE;
2284 
2285 	if (skb_is_gso(skb)) {
2286 		u16 mss = max(skb_shinfo(skb)->gso_size, TX_MSS_MIN);
2287 		tx_cmd_b = (mss << TX_CMD_B_MSS_SHIFT) & TX_CMD_B_MSS;
2288 
2289 		tx_cmd_a |= TX_CMD_A_LSO;
2290 	} else {
2291 		tx_cmd_b = 0;
2292 	}
2293 
2294 	ptr = skb_push(skb, 8);
2295 	put_unaligned_le32(tx_cmd_a, ptr);
2296 	put_unaligned_le32(tx_cmd_b, ptr + 4);
2297 
2298 	return skb;
2299 }
2300 
2301 static int smsc75xx_manage_power(struct usbnet *dev, int on)
2302 {
2303 	dev->intf->needs_remote_wakeup = on;
2304 	return 0;
2305 }
2306 
2307 static const struct driver_info smsc75xx_info = {
2308 	.description	= "smsc75xx USB 2.0 Gigabit Ethernet",
2309 	.bind		= smsc75xx_bind,
2310 	.unbind		= smsc75xx_unbind,
2311 	.link_reset	= smsc75xx_link_reset,
2312 	.reset		= smsc75xx_reset,
2313 	.rx_fixup	= smsc75xx_rx_fixup,
2314 	.tx_fixup	= smsc75xx_tx_fixup,
2315 	.status		= smsc75xx_status,
2316 	.manage_power	= smsc75xx_manage_power,
2317 	.flags		= FLAG_ETHER | FLAG_SEND_ZLP | FLAG_LINK_INTR,
2318 };
2319 
2320 static const struct usb_device_id products[] = {
2321 	{
2322 		/* SMSC7500 USB Gigabit Ethernet Device */
2323 		USB_DEVICE(USB_VENDOR_ID_SMSC, USB_PRODUCT_ID_LAN7500),
2324 		.driver_info = (unsigned long) &smsc75xx_info,
2325 	},
2326 	{
2327 		/* SMSC7500 USB Gigabit Ethernet Device */
2328 		USB_DEVICE(USB_VENDOR_ID_SMSC, USB_PRODUCT_ID_LAN7505),
2329 		.driver_info = (unsigned long) &smsc75xx_info,
2330 	},
2331 	{ },		/* END */
2332 };
2333 MODULE_DEVICE_TABLE(usb, products);
2334 
2335 static struct usb_driver smsc75xx_driver = {
2336 	.name		= SMSC_CHIPNAME,
2337 	.id_table	= products,
2338 	.probe		= usbnet_probe,
2339 	.suspend	= smsc75xx_suspend,
2340 	.resume		= smsc75xx_resume,
2341 	.reset_resume	= smsc75xx_resume,
2342 	.disconnect	= usbnet_disconnect,
2343 	.disable_hub_initiated_lpm = 1,
2344 	.supports_autosuspend = 1,
2345 };
2346 
2347 module_usb_driver(smsc75xx_driver);
2348 
2349 MODULE_AUTHOR("Nancy Lin");
2350 MODULE_AUTHOR("Steve Glendinning <steve.glendinning@shawell.net>");
2351 MODULE_DESCRIPTION("SMSC75XX USB 2.0 Gigabit Ethernet Devices");
2352 MODULE_LICENSE("GPL");
2353