1 /***************************************************************************
3 * Copyright (C) 2007-2008 SMSC
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 *****************************************************************************/
20 #include <linux/module.h>
21 #include <linux/kmod.h>
22 #include <linux/netdevice.h>
23 #include <linux/etherdevice.h>
24 #include <linux/ethtool.h>
25 #include <linux/mii.h>
26 #include <linux/usb.h>
27 #include <linux/bitrev.h>
28 #include <linux/crc16.h>
29 #include <linux/crc32.h>
30 #include <linux/usb/usbnet.h>
31 #include <linux/slab.h>
32 #include <linux/of_net.h>
35 #define SMSC_CHIPNAME "smsc95xx"
36 #define SMSC_DRIVER_VERSION "1.0.6"
37 #define HS_USB_PKT_SIZE (512)
38 #define FS_USB_PKT_SIZE (64)
39 #define DEFAULT_HS_BURST_CAP_SIZE (16 * 1024 + 5 * HS_USB_PKT_SIZE)
40 #define DEFAULT_FS_BURST_CAP_SIZE (6 * 1024 + 33 * FS_USB_PKT_SIZE)
41 #define DEFAULT_BULK_IN_DELAY (0x00002000)
42 #define MAX_SINGLE_PACKET_SIZE (2048)
43 #define LAN95XX_EEPROM_MAGIC (0x9500)
44 #define EEPROM_MAC_OFFSET (0x01)
45 #define DEFAULT_TX_CSUM_ENABLE (true)
46 #define DEFAULT_RX_CSUM_ENABLE (true)
47 #define SMSC95XX_INTERNAL_PHY_ID (1)
48 #define SMSC95XX_TX_OVERHEAD (8)
49 #define SMSC95XX_TX_OVERHEAD_CSUM (12)
50 #define SUPPORTED_WAKE (WAKE_PHY | WAKE_UCAST | WAKE_BCAST | \
51 WAKE_MCAST | WAKE_ARP | WAKE_MAGIC)
53 #define FEATURE_8_WAKEUP_FILTERS (0x01)
54 #define FEATURE_PHY_NLP_CROSSOVER (0x02)
55 #define FEATURE_REMOTE_WAKEUP (0x04)
57 #define SUSPEND_SUSPEND0 (0x01)
58 #define SUSPEND_SUSPEND1 (0x02)
59 #define SUSPEND_SUSPEND2 (0x04)
60 #define SUSPEND_SUSPEND3 (0x08)
61 #define SUSPEND_ALLMODES (SUSPEND_SUSPEND0 | SUSPEND_SUSPEND1 | \
62 SUSPEND_SUSPEND2 | SUSPEND_SUSPEND3)
64 #define CARRIER_CHECK_DELAY (2 * HZ)
66 struct smsc95xx_priv
{
72 spinlock_t mac_cr_lock
;
77 struct delayed_work carrier_check
;
81 static bool turbo_mode
= true;
82 module_param(turbo_mode
, bool, 0644);
83 MODULE_PARM_DESC(turbo_mode
, "Enable multiple frames per Rx transaction");
85 static int __must_check
__smsc95xx_read_reg(struct usbnet
*dev
, u32 index
,
90 int (*fn
)(struct usbnet
*, u8
, u8
, u16
, u16
, void *, u16
);
97 fn
= usbnet_read_cmd_nopm
;
99 ret
= fn(dev
, USB_VENDOR_REQUEST_READ_REGISTER
, USB_DIR_IN
100 | USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
102 if (unlikely(ret
< 0)) {
103 netdev_warn(dev
->net
, "Failed to read reg index 0x%08x: %d\n",
114 static int __must_check
__smsc95xx_write_reg(struct usbnet
*dev
, u32 index
,
119 int (*fn
)(struct usbnet
*, u8
, u8
, u16
, u16
, const void *, u16
);
124 fn
= usbnet_write_cmd
;
126 fn
= usbnet_write_cmd_nopm
;
131 ret
= fn(dev
, USB_VENDOR_REQUEST_WRITE_REGISTER
, USB_DIR_OUT
132 | USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
134 if (unlikely(ret
< 0))
135 netdev_warn(dev
->net
, "Failed to write reg index 0x%08x: %d\n",
141 static int __must_check
smsc95xx_read_reg_nopm(struct usbnet
*dev
, u32 index
,
144 return __smsc95xx_read_reg(dev
, index
, data
, 1);
147 static int __must_check
smsc95xx_write_reg_nopm(struct usbnet
*dev
, u32 index
,
150 return __smsc95xx_write_reg(dev
, index
, data
, 1);
153 static int __must_check
smsc95xx_read_reg(struct usbnet
*dev
, u32 index
,
156 return __smsc95xx_read_reg(dev
, index
, data
, 0);
159 static int __must_check
smsc95xx_write_reg(struct usbnet
*dev
, u32 index
,
162 return __smsc95xx_write_reg(dev
, index
, data
, 0);
165 /* Loop until the read is completed with timeout
166 * called with phy_mutex held */
167 static int __must_check
__smsc95xx_phy_wait_not_busy(struct usbnet
*dev
,
170 unsigned long start_time
= jiffies
;
175 ret
= __smsc95xx_read_reg(dev
, MII_ADDR
, &val
, in_pm
);
177 netdev_warn(dev
->net
, "Error reading MII_ACCESS\n");
181 if (!(val
& MII_BUSY_
))
183 } while (!time_after(jiffies
, start_time
+ HZ
));
188 static int __smsc95xx_mdio_read(struct net_device
*netdev
, int phy_id
, int idx
,
191 struct usbnet
*dev
= netdev_priv(netdev
);
195 mutex_lock(&dev
->phy_mutex
);
197 /* confirm MII not busy */
198 ret
= __smsc95xx_phy_wait_not_busy(dev
, in_pm
);
200 netdev_warn(dev
->net
, "MII is busy in smsc95xx_mdio_read\n");
204 /* set the address, index & direction (read from PHY) */
205 phy_id
&= dev
->mii
.phy_id_mask
;
206 idx
&= dev
->mii
.reg_num_mask
;
207 addr
= (phy_id
<< 11) | (idx
<< 6) | MII_READ_
| MII_BUSY_
;
208 ret
= __smsc95xx_write_reg(dev
, MII_ADDR
, addr
, in_pm
);
210 netdev_warn(dev
->net
, "Error writing MII_ADDR\n");
214 ret
= __smsc95xx_phy_wait_not_busy(dev
, in_pm
);
216 netdev_warn(dev
->net
, "Timed out reading MII reg %02X\n", idx
);
220 ret
= __smsc95xx_read_reg(dev
, MII_DATA
, &val
, in_pm
);
222 netdev_warn(dev
->net
, "Error reading MII_DATA\n");
226 ret
= (u16
)(val
& 0xFFFF);
229 mutex_unlock(&dev
->phy_mutex
);
233 static void __smsc95xx_mdio_write(struct net_device
*netdev
, int phy_id
,
234 int idx
, int regval
, int in_pm
)
236 struct usbnet
*dev
= netdev_priv(netdev
);
240 mutex_lock(&dev
->phy_mutex
);
242 /* confirm MII not busy */
243 ret
= __smsc95xx_phy_wait_not_busy(dev
, in_pm
);
245 netdev_warn(dev
->net
, "MII is busy in smsc95xx_mdio_write\n");
250 ret
= __smsc95xx_write_reg(dev
, MII_DATA
, val
, in_pm
);
252 netdev_warn(dev
->net
, "Error writing MII_DATA\n");
256 /* set the address, index & direction (write to PHY) */
257 phy_id
&= dev
->mii
.phy_id_mask
;
258 idx
&= dev
->mii
.reg_num_mask
;
259 addr
= (phy_id
<< 11) | (idx
<< 6) | MII_WRITE_
| MII_BUSY_
;
260 ret
= __smsc95xx_write_reg(dev
, MII_ADDR
, addr
, in_pm
);
262 netdev_warn(dev
->net
, "Error writing MII_ADDR\n");
266 ret
= __smsc95xx_phy_wait_not_busy(dev
, in_pm
);
268 netdev_warn(dev
->net
, "Timed out writing MII reg %02X\n", idx
);
273 mutex_unlock(&dev
->phy_mutex
);
276 static int smsc95xx_mdio_read_nopm(struct net_device
*netdev
, int phy_id
,
279 return __smsc95xx_mdio_read(netdev
, phy_id
, idx
, 1);
282 static void smsc95xx_mdio_write_nopm(struct net_device
*netdev
, int phy_id
,
285 __smsc95xx_mdio_write(netdev
, phy_id
, idx
, regval
, 1);
288 static int smsc95xx_mdio_read(struct net_device
*netdev
, int phy_id
, int idx
)
290 return __smsc95xx_mdio_read(netdev
, phy_id
, idx
, 0);
293 static void smsc95xx_mdio_write(struct net_device
*netdev
, int phy_id
, int idx
,
296 __smsc95xx_mdio_write(netdev
, phy_id
, idx
, regval
, 0);
299 static int __must_check
smsc95xx_wait_eeprom(struct usbnet
*dev
)
301 unsigned long start_time
= jiffies
;
306 ret
= smsc95xx_read_reg(dev
, E2P_CMD
, &val
);
308 netdev_warn(dev
->net
, "Error reading E2P_CMD\n");
312 if (!(val
& E2P_CMD_BUSY_
) || (val
& E2P_CMD_TIMEOUT_
))
315 } while (!time_after(jiffies
, start_time
+ HZ
));
317 if (val
& (E2P_CMD_TIMEOUT_
| E2P_CMD_BUSY_
)) {
318 netdev_warn(dev
->net
, "EEPROM read operation timeout\n");
325 static int __must_check
smsc95xx_eeprom_confirm_not_busy(struct usbnet
*dev
)
327 unsigned long start_time
= jiffies
;
332 ret
= smsc95xx_read_reg(dev
, E2P_CMD
, &val
);
334 netdev_warn(dev
->net
, "Error reading E2P_CMD\n");
338 if (!(val
& E2P_CMD_BUSY_
))
342 } while (!time_after(jiffies
, start_time
+ HZ
));
344 netdev_warn(dev
->net
, "EEPROM is busy\n");
348 static int smsc95xx_read_eeprom(struct usbnet
*dev
, u32 offset
, u32 length
,
357 ret
= smsc95xx_eeprom_confirm_not_busy(dev
);
361 for (i
= 0; i
< length
; i
++) {
362 val
= E2P_CMD_BUSY_
| E2P_CMD_READ_
| (offset
& E2P_CMD_ADDR_
);
363 ret
= smsc95xx_write_reg(dev
, E2P_CMD
, val
);
365 netdev_warn(dev
->net
, "Error writing E2P_CMD\n");
369 ret
= smsc95xx_wait_eeprom(dev
);
373 ret
= smsc95xx_read_reg(dev
, E2P_DATA
, &val
);
375 netdev_warn(dev
->net
, "Error reading E2P_DATA\n");
379 data
[i
] = val
& 0xFF;
386 static int smsc95xx_write_eeprom(struct usbnet
*dev
, u32 offset
, u32 length
,
395 ret
= smsc95xx_eeprom_confirm_not_busy(dev
);
399 /* Issue write/erase enable command */
400 val
= E2P_CMD_BUSY_
| E2P_CMD_EWEN_
;
401 ret
= smsc95xx_write_reg(dev
, E2P_CMD
, val
);
403 netdev_warn(dev
->net
, "Error writing E2P_DATA\n");
407 ret
= smsc95xx_wait_eeprom(dev
);
411 for (i
= 0; i
< length
; i
++) {
413 /* Fill data register */
415 ret
= smsc95xx_write_reg(dev
, E2P_DATA
, val
);
417 netdev_warn(dev
->net
, "Error writing E2P_DATA\n");
421 /* Send "write" command */
422 val
= E2P_CMD_BUSY_
| E2P_CMD_WRITE_
| (offset
& E2P_CMD_ADDR_
);
423 ret
= smsc95xx_write_reg(dev
, E2P_CMD
, val
);
425 netdev_warn(dev
->net
, "Error writing E2P_CMD\n");
429 ret
= smsc95xx_wait_eeprom(dev
);
439 static int __must_check
smsc95xx_write_reg_async(struct usbnet
*dev
, u16 index
,
449 ret
= usbnet_write_cmd_async(dev
, USB_VENDOR_REQUEST_WRITE_REGISTER
,
450 USB_DIR_OUT
| USB_TYPE_VENDOR
|
452 0, index
, &buf
, size
);
454 netdev_warn(dev
->net
, "Error write async cmd, sts=%d\n",
459 /* returns hash bit number for given MAC address
461 * 01 00 5E 00 00 01 -> returns bit number 31 */
462 static unsigned int smsc95xx_hash(char addr
[ETH_ALEN
])
464 return (ether_crc(ETH_ALEN
, addr
) >> 26) & 0x3f;
467 static void smsc95xx_set_multicast(struct net_device
*netdev
)
469 struct usbnet
*dev
= netdev_priv(netdev
);
470 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
477 spin_lock_irqsave(&pdata
->mac_cr_lock
, flags
);
479 if (dev
->net
->flags
& IFF_PROMISC
) {
480 netif_dbg(dev
, drv
, dev
->net
, "promiscuous mode enabled\n");
481 pdata
->mac_cr
|= MAC_CR_PRMS_
;
482 pdata
->mac_cr
&= ~(MAC_CR_MCPAS_
| MAC_CR_HPFILT_
);
483 } else if (dev
->net
->flags
& IFF_ALLMULTI
) {
484 netif_dbg(dev
, drv
, dev
->net
, "receive all multicast enabled\n");
485 pdata
->mac_cr
|= MAC_CR_MCPAS_
;
486 pdata
->mac_cr
&= ~(MAC_CR_PRMS_
| MAC_CR_HPFILT_
);
487 } else if (!netdev_mc_empty(dev
->net
)) {
488 struct netdev_hw_addr
*ha
;
490 pdata
->mac_cr
|= MAC_CR_HPFILT_
;
491 pdata
->mac_cr
&= ~(MAC_CR_PRMS_
| MAC_CR_MCPAS_
);
493 netdev_for_each_mc_addr(ha
, netdev
) {
494 u32 bitnum
= smsc95xx_hash(ha
->addr
);
495 u32 mask
= 0x01 << (bitnum
& 0x1F);
497 pdata
->hash_hi
|= mask
;
499 pdata
->hash_lo
|= mask
;
502 netif_dbg(dev
, drv
, dev
->net
, "HASHH=0x%08X, HASHL=0x%08X\n",
503 pdata
->hash_hi
, pdata
->hash_lo
);
505 netif_dbg(dev
, drv
, dev
->net
, "receive own packets only\n");
507 ~(MAC_CR_PRMS_
| MAC_CR_MCPAS_
| MAC_CR_HPFILT_
);
510 spin_unlock_irqrestore(&pdata
->mac_cr_lock
, flags
);
512 /* Initiate async writes, as we can't wait for completion here */
513 ret
= smsc95xx_write_reg_async(dev
, HASHH
, pdata
->hash_hi
);
515 netdev_warn(dev
->net
, "failed to initiate async write to HASHH\n");
517 ret
= smsc95xx_write_reg_async(dev
, HASHL
, pdata
->hash_lo
);
519 netdev_warn(dev
->net
, "failed to initiate async write to HASHL\n");
521 ret
= smsc95xx_write_reg_async(dev
, MAC_CR
, pdata
->mac_cr
);
523 netdev_warn(dev
->net
, "failed to initiate async write to MAC_CR\n");
526 static int smsc95xx_phy_update_flowcontrol(struct usbnet
*dev
, u8 duplex
,
527 u16 lcladv
, u16 rmtadv
)
529 u32 flow
= 0, afc_cfg
;
531 int ret
= smsc95xx_read_reg(dev
, AFC_CFG
, &afc_cfg
);
535 if (duplex
== DUPLEX_FULL
) {
536 u8 cap
= mii_resolve_flowctrl_fdx(lcladv
, rmtadv
);
538 if (cap
& FLOW_CTRL_RX
)
541 if (cap
& FLOW_CTRL_TX
) {
548 netif_dbg(dev
, link
, dev
->net
, "rx pause %s, tx pause %s\n",
549 cap
& FLOW_CTRL_RX
? "enabled" : "disabled",
550 cap
& FLOW_CTRL_TX
? "enabled" : "disabled");
552 netif_dbg(dev
, link
, dev
->net
, "half duplex\n");
556 ret
= smsc95xx_write_reg(dev
, FLOW
, flow
);
560 return smsc95xx_write_reg(dev
, AFC_CFG
, afc_cfg
);
563 static int smsc95xx_link_reset(struct usbnet
*dev
)
565 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
566 struct mii_if_info
*mii
= &dev
->mii
;
567 struct ethtool_cmd ecmd
= { .cmd
= ETHTOOL_GSET
};
572 /* clear interrupt status */
573 ret
= smsc95xx_mdio_read(dev
->net
, mii
->phy_id
, PHY_INT_SRC
);
577 ret
= smsc95xx_write_reg(dev
, INT_STS
, INT_STS_CLEAR_ALL_
);
581 mii_check_media(mii
, 1, 1);
582 mii_ethtool_gset(&dev
->mii
, &ecmd
);
583 lcladv
= smsc95xx_mdio_read(dev
->net
, mii
->phy_id
, MII_ADVERTISE
);
584 rmtadv
= smsc95xx_mdio_read(dev
->net
, mii
->phy_id
, MII_LPA
);
586 netif_dbg(dev
, link
, dev
->net
,
587 "speed: %u duplex: %d lcladv: %04x rmtadv: %04x\n",
588 ethtool_cmd_speed(&ecmd
), ecmd
.duplex
, lcladv
, rmtadv
);
590 spin_lock_irqsave(&pdata
->mac_cr_lock
, flags
);
591 if (ecmd
.duplex
!= DUPLEX_FULL
) {
592 pdata
->mac_cr
&= ~MAC_CR_FDPX_
;
593 pdata
->mac_cr
|= MAC_CR_RCVOWN_
;
595 pdata
->mac_cr
&= ~MAC_CR_RCVOWN_
;
596 pdata
->mac_cr
|= MAC_CR_FDPX_
;
598 spin_unlock_irqrestore(&pdata
->mac_cr_lock
, flags
);
600 ret
= smsc95xx_write_reg(dev
, MAC_CR
, pdata
->mac_cr
);
604 ret
= smsc95xx_phy_update_flowcontrol(dev
, ecmd
.duplex
, lcladv
, rmtadv
);
606 netdev_warn(dev
->net
, "Error updating PHY flow control\n");
611 static void smsc95xx_status(struct usbnet
*dev
, struct urb
*urb
)
615 if (urb
->actual_length
!= 4) {
616 netdev_warn(dev
->net
, "unexpected urb length %d\n",
621 memcpy(&intdata
, urb
->transfer_buffer
, 4);
622 le32_to_cpus(&intdata
);
624 netif_dbg(dev
, link
, dev
->net
, "intdata: 0x%08X\n", intdata
);
626 if (intdata
& INT_ENP_PHY_INT_
)
627 usbnet_defer_kevent(dev
, EVENT_LINK_RESET
);
629 netdev_warn(dev
->net
, "unexpected interrupt, intdata=0x%08X\n",
633 static void set_carrier(struct usbnet
*dev
, bool link
)
635 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
637 if (pdata
->link_ok
== link
)
640 pdata
->link_ok
= link
;
643 usbnet_link_change(dev
, 1, 0);
645 usbnet_link_change(dev
, 0, 0);
648 static void check_carrier(struct work_struct
*work
)
650 struct smsc95xx_priv
*pdata
= container_of(work
, struct smsc95xx_priv
,
652 struct usbnet
*dev
= pdata
->dev
;
655 if (pdata
->suspend_flags
!= 0)
658 ret
= smsc95xx_mdio_read(dev
->net
, dev
->mii
.phy_id
, MII_BMSR
);
660 netdev_warn(dev
->net
, "Failed to read MII_BMSR\n");
663 if (ret
& BMSR_LSTATUS
)
668 schedule_delayed_work(&pdata
->carrier_check
, CARRIER_CHECK_DELAY
);
671 /* Enable or disable Tx & Rx checksum offload engines */
672 static int smsc95xx_set_features(struct net_device
*netdev
,
673 netdev_features_t features
)
675 struct usbnet
*dev
= netdev_priv(netdev
);
679 ret
= smsc95xx_read_reg(dev
, COE_CR
, &read_buf
);
683 if (features
& NETIF_F_IP_CSUM
)
684 read_buf
|= Tx_COE_EN_
;
686 read_buf
&= ~Tx_COE_EN_
;
688 if (features
& NETIF_F_RXCSUM
)
689 read_buf
|= Rx_COE_EN_
;
691 read_buf
&= ~Rx_COE_EN_
;
693 ret
= smsc95xx_write_reg(dev
, COE_CR
, read_buf
);
697 netif_dbg(dev
, hw
, dev
->net
, "COE_CR = 0x%08x\n", read_buf
);
701 static int smsc95xx_ethtool_get_eeprom_len(struct net_device
*net
)
703 return MAX_EEPROM_SIZE
;
706 static int smsc95xx_ethtool_get_eeprom(struct net_device
*netdev
,
707 struct ethtool_eeprom
*ee
, u8
*data
)
709 struct usbnet
*dev
= netdev_priv(netdev
);
711 ee
->magic
= LAN95XX_EEPROM_MAGIC
;
713 return smsc95xx_read_eeprom(dev
, ee
->offset
, ee
->len
, data
);
716 static int smsc95xx_ethtool_set_eeprom(struct net_device
*netdev
,
717 struct ethtool_eeprom
*ee
, u8
*data
)
719 struct usbnet
*dev
= netdev_priv(netdev
);
721 if (ee
->magic
!= LAN95XX_EEPROM_MAGIC
) {
722 netdev_warn(dev
->net
, "EEPROM: magic value mismatch, magic = 0x%x\n",
727 return smsc95xx_write_eeprom(dev
, ee
->offset
, ee
->len
, data
);
730 static int smsc95xx_ethtool_getregslen(struct net_device
*netdev
)
732 /* all smsc95xx registers */
733 return COE_CR
- ID_REV
+ sizeof(u32
);
737 smsc95xx_ethtool_getregs(struct net_device
*netdev
, struct ethtool_regs
*regs
,
740 struct usbnet
*dev
= netdev_priv(netdev
);
745 retval
= smsc95xx_read_reg(dev
, ID_REV
, ®s
->version
);
747 netdev_warn(netdev
, "REGS: cannot read ID_REV\n");
751 for (i
= ID_REV
, j
= 0; i
<= COE_CR
; i
+= (sizeof(u32
)), j
++) {
752 retval
= smsc95xx_read_reg(dev
, i
, &data
[j
]);
754 netdev_warn(netdev
, "REGS: cannot read reg[%x]\n", i
);
760 static void smsc95xx_ethtool_get_wol(struct net_device
*net
,
761 struct ethtool_wolinfo
*wolinfo
)
763 struct usbnet
*dev
= netdev_priv(net
);
764 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
766 wolinfo
->supported
= SUPPORTED_WAKE
;
767 wolinfo
->wolopts
= pdata
->wolopts
;
770 static int smsc95xx_ethtool_set_wol(struct net_device
*net
,
771 struct ethtool_wolinfo
*wolinfo
)
773 struct usbnet
*dev
= netdev_priv(net
);
774 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
777 pdata
->wolopts
= wolinfo
->wolopts
& SUPPORTED_WAKE
;
779 ret
= device_set_wakeup_enable(&dev
->udev
->dev
, pdata
->wolopts
);
781 netdev_warn(dev
->net
, "device_set_wakeup_enable error %d\n", ret
);
786 static int get_mdix_status(struct net_device
*net
)
788 struct usbnet
*dev
= netdev_priv(net
);
792 buf
= smsc95xx_mdio_read(dev
->net
, dev
->mii
.phy_id
, SPECIAL_CTRL_STS
);
793 if (buf
& SPECIAL_CTRL_STS_OVRRD_AMDIX_
) {
794 if (buf
& SPECIAL_CTRL_STS_AMDIX_ENABLE_
)
795 return ETH_TP_MDI_AUTO
;
796 else if (buf
& SPECIAL_CTRL_STS_AMDIX_STATE_
)
799 buf
= smsc95xx_read_reg(dev
, STRAP_STATUS
, &val
);
800 if (val
& STRAP_STATUS_AMDIX_EN_
)
801 return ETH_TP_MDI_AUTO
;
807 static void set_mdix_status(struct net_device
*net
, __u8 mdix_ctrl
)
809 struct usbnet
*dev
= netdev_priv(net
);
810 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
813 if ((pdata
->chip_id
== ID_REV_CHIP_ID_9500A_
) ||
814 (pdata
->chip_id
== ID_REV_CHIP_ID_9530_
) ||
815 (pdata
->chip_id
== ID_REV_CHIP_ID_89530_
) ||
816 (pdata
->chip_id
== ID_REV_CHIP_ID_9730_
)) {
817 /* Extend Manual AutoMDIX timer for 9500A/9500Ai */
818 buf
= smsc95xx_mdio_read(dev
->net
, dev
->mii
.phy_id
,
820 buf
|= PHY_EDPD_CONFIG_EXT_CROSSOVER_
;
821 smsc95xx_mdio_write(dev
->net
, dev
->mii
.phy_id
,
822 PHY_EDPD_CONFIG
, buf
);
825 if (mdix_ctrl
== ETH_TP_MDI
) {
826 buf
= smsc95xx_mdio_read(dev
->net
, dev
->mii
.phy_id
,
828 buf
|= SPECIAL_CTRL_STS_OVRRD_AMDIX_
;
829 buf
&= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_
|
830 SPECIAL_CTRL_STS_AMDIX_STATE_
);
831 smsc95xx_mdio_write(dev
->net
, dev
->mii
.phy_id
,
832 SPECIAL_CTRL_STS
, buf
);
833 } else if (mdix_ctrl
== ETH_TP_MDI_X
) {
834 buf
= smsc95xx_mdio_read(dev
->net
, dev
->mii
.phy_id
,
836 buf
|= SPECIAL_CTRL_STS_OVRRD_AMDIX_
;
837 buf
&= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_
|
838 SPECIAL_CTRL_STS_AMDIX_STATE_
);
839 buf
|= SPECIAL_CTRL_STS_AMDIX_STATE_
;
840 smsc95xx_mdio_write(dev
->net
, dev
->mii
.phy_id
,
841 SPECIAL_CTRL_STS
, buf
);
842 } else if (mdix_ctrl
== ETH_TP_MDI_AUTO
) {
843 buf
= smsc95xx_mdio_read(dev
->net
, dev
->mii
.phy_id
,
845 buf
&= ~SPECIAL_CTRL_STS_OVRRD_AMDIX_
;
846 buf
&= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_
|
847 SPECIAL_CTRL_STS_AMDIX_STATE_
);
848 buf
|= SPECIAL_CTRL_STS_AMDIX_ENABLE_
;
849 smsc95xx_mdio_write(dev
->net
, dev
->mii
.phy_id
,
850 SPECIAL_CTRL_STS
, buf
);
852 pdata
->mdix_ctrl
= mdix_ctrl
;
855 static int smsc95xx_get_link_ksettings(struct net_device
*net
,
856 struct ethtool_link_ksettings
*cmd
)
858 struct usbnet
*dev
= netdev_priv(net
);
859 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
862 retval
= usbnet_get_link_ksettings(net
, cmd
);
864 cmd
->base
.eth_tp_mdix
= pdata
->mdix_ctrl
;
865 cmd
->base
.eth_tp_mdix_ctrl
= pdata
->mdix_ctrl
;
870 static int smsc95xx_set_link_ksettings(struct net_device
*net
,
871 const struct ethtool_link_ksettings
*cmd
)
873 struct usbnet
*dev
= netdev_priv(net
);
874 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
877 if (pdata
->mdix_ctrl
!= cmd
->base
.eth_tp_mdix_ctrl
)
878 set_mdix_status(net
, cmd
->base
.eth_tp_mdix_ctrl
);
880 retval
= usbnet_set_link_ksettings(net
, cmd
);
885 static const struct ethtool_ops smsc95xx_ethtool_ops
= {
886 .get_link
= usbnet_get_link
,
887 .nway_reset
= usbnet_nway_reset
,
888 .get_drvinfo
= usbnet_get_drvinfo
,
889 .get_msglevel
= usbnet_get_msglevel
,
890 .set_msglevel
= usbnet_set_msglevel
,
891 .get_eeprom_len
= smsc95xx_ethtool_get_eeprom_len
,
892 .get_eeprom
= smsc95xx_ethtool_get_eeprom
,
893 .set_eeprom
= smsc95xx_ethtool_set_eeprom
,
894 .get_regs_len
= smsc95xx_ethtool_getregslen
,
895 .get_regs
= smsc95xx_ethtool_getregs
,
896 .get_wol
= smsc95xx_ethtool_get_wol
,
897 .set_wol
= smsc95xx_ethtool_set_wol
,
898 .get_link_ksettings
= smsc95xx_get_link_ksettings
,
899 .set_link_ksettings
= smsc95xx_set_link_ksettings
,
900 .get_ts_info
= ethtool_op_get_ts_info
,
903 static int smsc95xx_ioctl(struct net_device
*netdev
, struct ifreq
*rq
, int cmd
)
905 struct usbnet
*dev
= netdev_priv(netdev
);
907 if (!netif_running(netdev
))
910 return generic_mii_ioctl(&dev
->mii
, if_mii(rq
), cmd
, NULL
);
913 static void smsc95xx_init_mac_address(struct usbnet
*dev
)
917 /* maybe the boot loader passed the MAC address in devicetree */
918 mac_addr
= of_get_mac_address(dev
->udev
->dev
.of_node
);
920 memcpy(dev
->net
->dev_addr
, mac_addr
, ETH_ALEN
);
924 /* try reading mac address from EEPROM */
925 if (smsc95xx_read_eeprom(dev
, EEPROM_MAC_OFFSET
, ETH_ALEN
,
926 dev
->net
->dev_addr
) == 0) {
927 if (is_valid_ether_addr(dev
->net
->dev_addr
)) {
928 /* eeprom values are valid so use them */
929 netif_dbg(dev
, ifup
, dev
->net
, "MAC address read from EEPROM\n");
934 /* no useful static MAC address found. generate a random one */
935 eth_hw_addr_random(dev
->net
);
936 netif_dbg(dev
, ifup
, dev
->net
, "MAC address set to eth_random_addr\n");
939 static int smsc95xx_set_mac_address(struct usbnet
*dev
)
941 u32 addr_lo
= dev
->net
->dev_addr
[0] | dev
->net
->dev_addr
[1] << 8 |
942 dev
->net
->dev_addr
[2] << 16 | dev
->net
->dev_addr
[3] << 24;
943 u32 addr_hi
= dev
->net
->dev_addr
[4] | dev
->net
->dev_addr
[5] << 8;
946 ret
= smsc95xx_write_reg(dev
, ADDRL
, addr_lo
);
950 return smsc95xx_write_reg(dev
, ADDRH
, addr_hi
);
953 /* starts the TX path */
954 static int smsc95xx_start_tx_path(struct usbnet
*dev
)
956 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
960 /* Enable Tx at MAC */
961 spin_lock_irqsave(&pdata
->mac_cr_lock
, flags
);
962 pdata
->mac_cr
|= MAC_CR_TXEN_
;
963 spin_unlock_irqrestore(&pdata
->mac_cr_lock
, flags
);
965 ret
= smsc95xx_write_reg(dev
, MAC_CR
, pdata
->mac_cr
);
969 /* Enable Tx at SCSRs */
970 return smsc95xx_write_reg(dev
, TX_CFG
, TX_CFG_ON_
);
973 /* Starts the Receive path */
974 static int smsc95xx_start_rx_path(struct usbnet
*dev
, int in_pm
)
976 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
979 spin_lock_irqsave(&pdata
->mac_cr_lock
, flags
);
980 pdata
->mac_cr
|= MAC_CR_RXEN_
;
981 spin_unlock_irqrestore(&pdata
->mac_cr_lock
, flags
);
983 return __smsc95xx_write_reg(dev
, MAC_CR
, pdata
->mac_cr
, in_pm
);
986 static int smsc95xx_phy_initialize(struct usbnet
*dev
)
988 int bmcr
, ret
, timeout
= 0;
990 /* Initialize MII structure */
991 dev
->mii
.dev
= dev
->net
;
992 dev
->mii
.mdio_read
= smsc95xx_mdio_read
;
993 dev
->mii
.mdio_write
= smsc95xx_mdio_write
;
994 dev
->mii
.phy_id_mask
= 0x1f;
995 dev
->mii
.reg_num_mask
= 0x1f;
996 dev
->mii
.phy_id
= SMSC95XX_INTERNAL_PHY_ID
;
998 /* reset phy and wait for reset to complete */
999 smsc95xx_mdio_write(dev
->net
, dev
->mii
.phy_id
, MII_BMCR
, BMCR_RESET
);
1003 bmcr
= smsc95xx_mdio_read(dev
->net
, dev
->mii
.phy_id
, MII_BMCR
);
1005 } while ((bmcr
& BMCR_RESET
) && (timeout
< 100));
1007 if (timeout
>= 100) {
1008 netdev_warn(dev
->net
, "timeout on PHY Reset");
1012 smsc95xx_mdio_write(dev
->net
, dev
->mii
.phy_id
, MII_ADVERTISE
,
1013 ADVERTISE_ALL
| ADVERTISE_CSMA
| ADVERTISE_PAUSE_CAP
|
1014 ADVERTISE_PAUSE_ASYM
);
1017 ret
= smsc95xx_mdio_read(dev
->net
, dev
->mii
.phy_id
, PHY_INT_SRC
);
1019 netdev_warn(dev
->net
, "Failed to read PHY_INT_SRC during init\n");
1023 smsc95xx_mdio_write(dev
->net
, dev
->mii
.phy_id
, PHY_INT_MASK
,
1024 PHY_INT_MASK_DEFAULT_
);
1025 mii_nway_restart(&dev
->mii
);
1027 netif_dbg(dev
, ifup
, dev
->net
, "phy initialised successfully\n");
1031 static int smsc95xx_reset(struct usbnet
*dev
)
1033 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
1034 u32 read_buf
, write_buf
, burst_cap
;
1035 int ret
= 0, timeout
;
1037 netif_dbg(dev
, ifup
, dev
->net
, "entering smsc95xx_reset\n");
1039 ret
= smsc95xx_write_reg(dev
, HW_CFG
, HW_CFG_LRST_
);
1046 ret
= smsc95xx_read_reg(dev
, HW_CFG
, &read_buf
);
1050 } while ((read_buf
& HW_CFG_LRST_
) && (timeout
< 100));
1052 if (timeout
>= 100) {
1053 netdev_warn(dev
->net
, "timeout waiting for completion of Lite Reset\n");
1057 ret
= smsc95xx_write_reg(dev
, PM_CTRL
, PM_CTL_PHY_RST_
);
1064 ret
= smsc95xx_read_reg(dev
, PM_CTRL
, &read_buf
);
1068 } while ((read_buf
& PM_CTL_PHY_RST_
) && (timeout
< 100));
1070 if (timeout
>= 100) {
1071 netdev_warn(dev
->net
, "timeout waiting for PHY Reset\n");
1075 ret
= smsc95xx_set_mac_address(dev
);
1079 netif_dbg(dev
, ifup
, dev
->net
, "MAC Address: %pM\n",
1080 dev
->net
->dev_addr
);
1082 ret
= smsc95xx_read_reg(dev
, HW_CFG
, &read_buf
);
1086 netif_dbg(dev
, ifup
, dev
->net
, "Read Value from HW_CFG : 0x%08x\n",
1089 read_buf
|= HW_CFG_BIR_
;
1091 ret
= smsc95xx_write_reg(dev
, HW_CFG
, read_buf
);
1095 ret
= smsc95xx_read_reg(dev
, HW_CFG
, &read_buf
);
1099 netif_dbg(dev
, ifup
, dev
->net
,
1100 "Read Value from HW_CFG after writing HW_CFG_BIR_: 0x%08x\n",
1105 dev
->rx_urb_size
= MAX_SINGLE_PACKET_SIZE
;
1106 } else if (dev
->udev
->speed
== USB_SPEED_HIGH
) {
1107 burst_cap
= DEFAULT_HS_BURST_CAP_SIZE
/ HS_USB_PKT_SIZE
;
1108 dev
->rx_urb_size
= DEFAULT_HS_BURST_CAP_SIZE
;
1110 burst_cap
= DEFAULT_FS_BURST_CAP_SIZE
/ FS_USB_PKT_SIZE
;
1111 dev
->rx_urb_size
= DEFAULT_FS_BURST_CAP_SIZE
;
1114 netif_dbg(dev
, ifup
, dev
->net
, "rx_urb_size=%ld\n",
1115 (ulong
)dev
->rx_urb_size
);
1117 ret
= smsc95xx_write_reg(dev
, BURST_CAP
, burst_cap
);
1121 ret
= smsc95xx_read_reg(dev
, BURST_CAP
, &read_buf
);
1125 netif_dbg(dev
, ifup
, dev
->net
,
1126 "Read Value from BURST_CAP after writing: 0x%08x\n",
1129 ret
= smsc95xx_write_reg(dev
, BULK_IN_DLY
, DEFAULT_BULK_IN_DELAY
);
1133 ret
= smsc95xx_read_reg(dev
, BULK_IN_DLY
, &read_buf
);
1137 netif_dbg(dev
, ifup
, dev
->net
,
1138 "Read Value from BULK_IN_DLY after writing: 0x%08x\n",
1141 ret
= smsc95xx_read_reg(dev
, HW_CFG
, &read_buf
);
1145 netif_dbg(dev
, ifup
, dev
->net
, "Read Value from HW_CFG: 0x%08x\n",
1149 read_buf
|= (HW_CFG_MEF_
| HW_CFG_BCE_
);
1151 read_buf
&= ~HW_CFG_RXDOFF_
;
1153 /* set Rx data offset=2, Make IP header aligns on word boundary. */
1154 read_buf
|= NET_IP_ALIGN
<< 9;
1156 ret
= smsc95xx_write_reg(dev
, HW_CFG
, read_buf
);
1160 ret
= smsc95xx_read_reg(dev
, HW_CFG
, &read_buf
);
1164 netif_dbg(dev
, ifup
, dev
->net
,
1165 "Read Value from HW_CFG after writing: 0x%08x\n", read_buf
);
1167 ret
= smsc95xx_write_reg(dev
, INT_STS
, INT_STS_CLEAR_ALL_
);
1171 ret
= smsc95xx_read_reg(dev
, ID_REV
, &read_buf
);
1174 netif_dbg(dev
, ifup
, dev
->net
, "ID_REV = 0x%08x\n", read_buf
);
1176 /* Configure GPIO pins as LED outputs */
1177 write_buf
= LED_GPIO_CFG_SPD_LED
| LED_GPIO_CFG_LNK_LED
|
1178 LED_GPIO_CFG_FDX_LED
;
1179 ret
= smsc95xx_write_reg(dev
, LED_GPIO_CFG
, write_buf
);
1184 ret
= smsc95xx_write_reg(dev
, FLOW
, 0);
1188 ret
= smsc95xx_write_reg(dev
, AFC_CFG
, AFC_CFG_DEFAULT
);
1192 /* Don't need mac_cr_lock during initialisation */
1193 ret
= smsc95xx_read_reg(dev
, MAC_CR
, &pdata
->mac_cr
);
1199 ret
= smsc95xx_write_reg(dev
, VLAN1
, (u32
)ETH_P_8021Q
);
1203 /* Enable or disable checksum offload engines */
1204 ret
= smsc95xx_set_features(dev
->net
, dev
->net
->features
);
1206 netdev_warn(dev
->net
, "Failed to set checksum offload features\n");
1210 smsc95xx_set_multicast(dev
->net
);
1212 ret
= smsc95xx_phy_initialize(dev
);
1214 netdev_warn(dev
->net
, "Failed to init PHY\n");
1218 ret
= smsc95xx_read_reg(dev
, INT_EP_CTL
, &read_buf
);
1222 /* enable PHY interrupts */
1223 read_buf
|= INT_EP_CTL_PHY_INT_
;
1225 ret
= smsc95xx_write_reg(dev
, INT_EP_CTL
, read_buf
);
1229 ret
= smsc95xx_start_tx_path(dev
);
1231 netdev_warn(dev
->net
, "Failed to start TX path\n");
1235 ret
= smsc95xx_start_rx_path(dev
, 0);
1237 netdev_warn(dev
->net
, "Failed to start RX path\n");
1241 netif_dbg(dev
, ifup
, dev
->net
, "smsc95xx_reset, return 0\n");
1245 static const struct net_device_ops smsc95xx_netdev_ops
= {
1246 .ndo_open
= usbnet_open
,
1247 .ndo_stop
= usbnet_stop
,
1248 .ndo_start_xmit
= usbnet_start_xmit
,
1249 .ndo_tx_timeout
= usbnet_tx_timeout
,
1250 .ndo_change_mtu
= usbnet_change_mtu
,
1251 .ndo_get_stats64
= usbnet_get_stats64
,
1252 .ndo_set_mac_address
= eth_mac_addr
,
1253 .ndo_validate_addr
= eth_validate_addr
,
1254 .ndo_do_ioctl
= smsc95xx_ioctl
,
1255 .ndo_set_rx_mode
= smsc95xx_set_multicast
,
1256 .ndo_set_features
= smsc95xx_set_features
,
1259 static int smsc95xx_bind(struct usbnet
*dev
, struct usb_interface
*intf
)
1261 struct smsc95xx_priv
*pdata
= NULL
;
1265 printk(KERN_INFO SMSC_CHIPNAME
" v" SMSC_DRIVER_VERSION
"\n");
1267 ret
= usbnet_get_endpoints(dev
, intf
);
1269 netdev_warn(dev
->net
, "usbnet_get_endpoints failed: %d\n", ret
);
1273 dev
->data
[0] = (unsigned long)kzalloc(sizeof(struct smsc95xx_priv
),
1276 pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
1280 spin_lock_init(&pdata
->mac_cr_lock
);
1282 /* LAN95xx devices do not alter the computed checksum of 0 to 0xffff.
1283 * RFC 2460, ipv6 UDP calculated checksum yields a result of zero must
1284 * be changed to 0xffff. RFC 768, ipv4 UDP computed checksum is zero,
1285 * it is transmitted as all ones. The zero transmitted checksum means
1286 * transmitter generated no checksum. Hence, enable csum offload only
1289 if (DEFAULT_TX_CSUM_ENABLE
)
1290 dev
->net
->features
|= NETIF_F_IP_CSUM
;
1291 if (DEFAULT_RX_CSUM_ENABLE
)
1292 dev
->net
->features
|= NETIF_F_RXCSUM
;
1294 dev
->net
->hw_features
= NETIF_F_IP_CSUM
| NETIF_F_RXCSUM
;
1296 smsc95xx_init_mac_address(dev
);
1298 /* Init all registers */
1299 ret
= smsc95xx_reset(dev
);
1301 /* detect device revision as different features may be available */
1302 ret
= smsc95xx_read_reg(dev
, ID_REV
, &val
);
1306 pdata
->chip_id
= val
;
1307 pdata
->mdix_ctrl
= get_mdix_status(dev
->net
);
1309 if ((val
== ID_REV_CHIP_ID_9500A_
) || (val
== ID_REV_CHIP_ID_9530_
) ||
1310 (val
== ID_REV_CHIP_ID_89530_
) || (val
== ID_REV_CHIP_ID_9730_
))
1311 pdata
->features
= (FEATURE_8_WAKEUP_FILTERS
|
1312 FEATURE_PHY_NLP_CROSSOVER
|
1313 FEATURE_REMOTE_WAKEUP
);
1314 else if (val
== ID_REV_CHIP_ID_9512_
)
1315 pdata
->features
= FEATURE_8_WAKEUP_FILTERS
;
1317 dev
->net
->netdev_ops
= &smsc95xx_netdev_ops
;
1318 dev
->net
->ethtool_ops
= &smsc95xx_ethtool_ops
;
1319 dev
->net
->flags
|= IFF_MULTICAST
;
1320 dev
->net
->hard_header_len
+= SMSC95XX_TX_OVERHEAD_CSUM
;
1321 dev
->hard_mtu
= dev
->net
->mtu
+ dev
->net
->hard_header_len
;
1324 INIT_DELAYED_WORK(&pdata
->carrier_check
, check_carrier
);
1325 schedule_delayed_work(&pdata
->carrier_check
, CARRIER_CHECK_DELAY
);
1330 static void smsc95xx_unbind(struct usbnet
*dev
, struct usb_interface
*intf
)
1332 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
1335 cancel_delayed_work(&pdata
->carrier_check
);
1336 netif_dbg(dev
, ifdown
, dev
->net
, "free pdata\n");
1343 static u32
smsc_crc(const u8
*buffer
, size_t len
, int filter
)
1345 u32 crc
= bitrev16(crc16(0xFFFF, buffer
, len
));
1346 return crc
<< ((filter
% 2) * 16);
1349 static int smsc95xx_enable_phy_wakeup_interrupts(struct usbnet
*dev
, u16 mask
)
1351 struct mii_if_info
*mii
= &dev
->mii
;
1354 netdev_dbg(dev
->net
, "enabling PHY wakeup interrupts\n");
1357 ret
= smsc95xx_mdio_read_nopm(dev
->net
, mii
->phy_id
, PHY_INT_SRC
);
1361 /* enable interrupt source */
1362 ret
= smsc95xx_mdio_read_nopm(dev
->net
, mii
->phy_id
, PHY_INT_MASK
);
1368 smsc95xx_mdio_write_nopm(dev
->net
, mii
->phy_id
, PHY_INT_MASK
, ret
);
1373 static int smsc95xx_link_ok_nopm(struct usbnet
*dev
)
1375 struct mii_if_info
*mii
= &dev
->mii
;
1378 /* first, a dummy read, needed to latch some MII phys */
1379 ret
= smsc95xx_mdio_read_nopm(dev
->net
, mii
->phy_id
, MII_BMSR
);
1383 ret
= smsc95xx_mdio_read_nopm(dev
->net
, mii
->phy_id
, MII_BMSR
);
1387 return !!(ret
& BMSR_LSTATUS
);
1390 static int smsc95xx_enter_suspend0(struct usbnet
*dev
)
1392 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
1396 ret
= smsc95xx_read_reg_nopm(dev
, PM_CTRL
, &val
);
1400 val
&= (~(PM_CTL_SUS_MODE_
| PM_CTL_WUPS_
| PM_CTL_PHY_RST_
));
1401 val
|= PM_CTL_SUS_MODE_0
;
1403 ret
= smsc95xx_write_reg_nopm(dev
, PM_CTRL
, val
);
1407 /* clear wol status */
1408 val
&= ~PM_CTL_WUPS_
;
1409 val
|= PM_CTL_WUPS_WOL_
;
1411 /* enable energy detection */
1412 if (pdata
->wolopts
& WAKE_PHY
)
1413 val
|= PM_CTL_WUPS_ED_
;
1415 ret
= smsc95xx_write_reg_nopm(dev
, PM_CTRL
, val
);
1419 /* read back PM_CTRL */
1420 ret
= smsc95xx_read_reg_nopm(dev
, PM_CTRL
, &val
);
1424 pdata
->suspend_flags
|= SUSPEND_SUSPEND0
;
1429 static int smsc95xx_enter_suspend1(struct usbnet
*dev
)
1431 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
1432 struct mii_if_info
*mii
= &dev
->mii
;
1436 /* reconfigure link pulse detection timing for
1437 * compatibility with non-standard link partners
1439 if (pdata
->features
& FEATURE_PHY_NLP_CROSSOVER
)
1440 smsc95xx_mdio_write_nopm(dev
->net
, mii
->phy_id
, PHY_EDPD_CONFIG
,
1441 PHY_EDPD_CONFIG_DEFAULT
);
1443 /* enable energy detect power-down mode */
1444 ret
= smsc95xx_mdio_read_nopm(dev
->net
, mii
->phy_id
, PHY_MODE_CTRL_STS
);
1448 ret
|= MODE_CTRL_STS_EDPWRDOWN_
;
1450 smsc95xx_mdio_write_nopm(dev
->net
, mii
->phy_id
, PHY_MODE_CTRL_STS
, ret
);
1452 /* enter SUSPEND1 mode */
1453 ret
= smsc95xx_read_reg_nopm(dev
, PM_CTRL
, &val
);
1457 val
&= ~(PM_CTL_SUS_MODE_
| PM_CTL_WUPS_
| PM_CTL_PHY_RST_
);
1458 val
|= PM_CTL_SUS_MODE_1
;
1460 ret
= smsc95xx_write_reg_nopm(dev
, PM_CTRL
, val
);
1464 /* clear wol status, enable energy detection */
1465 val
&= ~PM_CTL_WUPS_
;
1466 val
|= (PM_CTL_WUPS_ED_
| PM_CTL_ED_EN_
);
1468 ret
= smsc95xx_write_reg_nopm(dev
, PM_CTRL
, val
);
1472 pdata
->suspend_flags
|= SUSPEND_SUSPEND1
;
1477 static int smsc95xx_enter_suspend2(struct usbnet
*dev
)
1479 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
1483 ret
= smsc95xx_read_reg_nopm(dev
, PM_CTRL
, &val
);
1487 val
&= ~(PM_CTL_SUS_MODE_
| PM_CTL_WUPS_
| PM_CTL_PHY_RST_
);
1488 val
|= PM_CTL_SUS_MODE_2
;
1490 ret
= smsc95xx_write_reg_nopm(dev
, PM_CTRL
, val
);
1494 pdata
->suspend_flags
|= SUSPEND_SUSPEND2
;
1499 static int smsc95xx_enter_suspend3(struct usbnet
*dev
)
1501 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
1505 ret
= smsc95xx_read_reg_nopm(dev
, RX_FIFO_INF
, &val
);
1509 if (val
& RX_FIFO_INF_USED_
) {
1510 netdev_info(dev
->net
, "rx fifo not empty in autosuspend\n");
1514 ret
= smsc95xx_read_reg_nopm(dev
, PM_CTRL
, &val
);
1518 val
&= ~(PM_CTL_SUS_MODE_
| PM_CTL_WUPS_
| PM_CTL_PHY_RST_
);
1519 val
|= PM_CTL_SUS_MODE_3
| PM_CTL_RES_CLR_WKP_STS
;
1521 ret
= smsc95xx_write_reg_nopm(dev
, PM_CTRL
, val
);
1525 /* clear wol status */
1526 val
&= ~PM_CTL_WUPS_
;
1527 val
|= PM_CTL_WUPS_WOL_
;
1529 ret
= smsc95xx_write_reg_nopm(dev
, PM_CTRL
, val
);
1533 pdata
->suspend_flags
|= SUSPEND_SUSPEND3
;
1538 static int smsc95xx_autosuspend(struct usbnet
*dev
, u32 link_up
)
1540 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
1543 if (!netif_running(dev
->net
)) {
1544 /* interface is ifconfig down so fully power down hw */
1545 netdev_dbg(dev
->net
, "autosuspend entering SUSPEND2\n");
1546 return smsc95xx_enter_suspend2(dev
);
1550 /* link is down so enter EDPD mode, but only if device can
1551 * reliably resume from it. This check should be redundant
1552 * as current FEATURE_REMOTE_WAKEUP parts also support
1553 * FEATURE_PHY_NLP_CROSSOVER but it's included for clarity */
1554 if (!(pdata
->features
& FEATURE_PHY_NLP_CROSSOVER
)) {
1555 netdev_warn(dev
->net
, "EDPD not supported\n");
1559 netdev_dbg(dev
->net
, "autosuspend entering SUSPEND1\n");
1561 /* enable PHY wakeup events for if cable is attached */
1562 ret
= smsc95xx_enable_phy_wakeup_interrupts(dev
,
1563 PHY_INT_MASK_ANEG_COMP_
);
1565 netdev_warn(dev
->net
, "error enabling PHY wakeup ints\n");
1569 netdev_info(dev
->net
, "entering SUSPEND1 mode\n");
1570 return smsc95xx_enter_suspend1(dev
);
1573 /* enable PHY wakeup events so we remote wakeup if cable is pulled */
1574 ret
= smsc95xx_enable_phy_wakeup_interrupts(dev
,
1575 PHY_INT_MASK_LINK_DOWN_
);
1577 netdev_warn(dev
->net
, "error enabling PHY wakeup ints\n");
1581 netdev_dbg(dev
->net
, "autosuspend entering SUSPEND3\n");
1582 return smsc95xx_enter_suspend3(dev
);
1585 static int smsc95xx_suspend(struct usb_interface
*intf
, pm_message_t message
)
1587 struct usbnet
*dev
= usb_get_intfdata(intf
);
1588 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
1592 ret
= usbnet_suspend(intf
, message
);
1594 netdev_warn(dev
->net
, "usbnet_suspend error\n");
1598 if (pdata
->suspend_flags
) {
1599 netdev_warn(dev
->net
, "error during last resume\n");
1600 pdata
->suspend_flags
= 0;
1603 /* determine if link is up using only _nopm functions */
1604 link_up
= smsc95xx_link_ok_nopm(dev
);
1606 if (message
.event
== PM_EVENT_AUTO_SUSPEND
&&
1607 (pdata
->features
& FEATURE_REMOTE_WAKEUP
)) {
1608 ret
= smsc95xx_autosuspend(dev
, link_up
);
1612 /* if we get this far we're not autosuspending */
1613 /* if no wol options set, or if link is down and we're not waking on
1614 * PHY activity, enter lowest power SUSPEND2 mode
1616 if (!(pdata
->wolopts
& SUPPORTED_WAKE
) ||
1617 !(link_up
|| (pdata
->wolopts
& WAKE_PHY
))) {
1618 netdev_info(dev
->net
, "entering SUSPEND2 mode\n");
1620 /* disable energy detect (link up) & wake up events */
1621 ret
= smsc95xx_read_reg_nopm(dev
, WUCSR
, &val
);
1625 val
&= ~(WUCSR_MPEN_
| WUCSR_WAKE_EN_
);
1627 ret
= smsc95xx_write_reg_nopm(dev
, WUCSR
, val
);
1631 ret
= smsc95xx_read_reg_nopm(dev
, PM_CTRL
, &val
);
1635 val
&= ~(PM_CTL_ED_EN_
| PM_CTL_WOL_EN_
);
1637 ret
= smsc95xx_write_reg_nopm(dev
, PM_CTRL
, val
);
1641 ret
= smsc95xx_enter_suspend2(dev
);
1645 if (pdata
->wolopts
& WAKE_PHY
) {
1646 ret
= smsc95xx_enable_phy_wakeup_interrupts(dev
,
1647 (PHY_INT_MASK_ANEG_COMP_
| PHY_INT_MASK_LINK_DOWN_
));
1649 netdev_warn(dev
->net
, "error enabling PHY wakeup ints\n");
1653 /* if link is down then configure EDPD and enter SUSPEND1,
1654 * otherwise enter SUSPEND0 below
1657 netdev_info(dev
->net
, "entering SUSPEND1 mode\n");
1658 ret
= smsc95xx_enter_suspend1(dev
);
1663 if (pdata
->wolopts
& (WAKE_BCAST
| WAKE_MCAST
| WAKE_ARP
| WAKE_UCAST
)) {
1664 u32
*filter_mask
= kzalloc(sizeof(u32
) * 32, GFP_KERNEL
);
1668 int wuff_filter_count
=
1669 (pdata
->features
& FEATURE_8_WAKEUP_FILTERS
) ?
1670 LAN9500A_WUFF_NUM
: LAN9500_WUFF_NUM
;
1674 netdev_warn(dev
->net
, "Unable to allocate filter_mask\n");
1679 memset(command
, 0, sizeof(command
));
1680 memset(offset
, 0, sizeof(offset
));
1681 memset(crc
, 0, sizeof(crc
));
1683 if (pdata
->wolopts
& WAKE_BCAST
) {
1684 const u8 bcast
[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
1685 netdev_info(dev
->net
, "enabling broadcast detection\n");
1686 filter_mask
[filter
* 4] = 0x003F;
1687 filter_mask
[filter
* 4 + 1] = 0x00;
1688 filter_mask
[filter
* 4 + 2] = 0x00;
1689 filter_mask
[filter
* 4 + 3] = 0x00;
1690 command
[filter
/4] |= 0x05UL
<< ((filter
% 4) * 8);
1691 offset
[filter
/4] |= 0x00 << ((filter
% 4) * 8);
1692 crc
[filter
/2] |= smsc_crc(bcast
, 6, filter
);
1696 if (pdata
->wolopts
& WAKE_MCAST
) {
1697 const u8 mcast
[] = {0x01, 0x00, 0x5E};
1698 netdev_info(dev
->net
, "enabling multicast detection\n");
1699 filter_mask
[filter
* 4] = 0x0007;
1700 filter_mask
[filter
* 4 + 1] = 0x00;
1701 filter_mask
[filter
* 4 + 2] = 0x00;
1702 filter_mask
[filter
* 4 + 3] = 0x00;
1703 command
[filter
/4] |= 0x09UL
<< ((filter
% 4) * 8);
1704 offset
[filter
/4] |= 0x00 << ((filter
% 4) * 8);
1705 crc
[filter
/2] |= smsc_crc(mcast
, 3, filter
);
1709 if (pdata
->wolopts
& WAKE_ARP
) {
1710 const u8 arp
[] = {0x08, 0x06};
1711 netdev_info(dev
->net
, "enabling ARP detection\n");
1712 filter_mask
[filter
* 4] = 0x0003;
1713 filter_mask
[filter
* 4 + 1] = 0x00;
1714 filter_mask
[filter
* 4 + 2] = 0x00;
1715 filter_mask
[filter
* 4 + 3] = 0x00;
1716 command
[filter
/4] |= 0x05UL
<< ((filter
% 4) * 8);
1717 offset
[filter
/4] |= 0x0C << ((filter
% 4) * 8);
1718 crc
[filter
/2] |= smsc_crc(arp
, 2, filter
);
1722 if (pdata
->wolopts
& WAKE_UCAST
) {
1723 netdev_info(dev
->net
, "enabling unicast detection\n");
1724 filter_mask
[filter
* 4] = 0x003F;
1725 filter_mask
[filter
* 4 + 1] = 0x00;
1726 filter_mask
[filter
* 4 + 2] = 0x00;
1727 filter_mask
[filter
* 4 + 3] = 0x00;
1728 command
[filter
/4] |= 0x01UL
<< ((filter
% 4) * 8);
1729 offset
[filter
/4] |= 0x00 << ((filter
% 4) * 8);
1730 crc
[filter
/2] |= smsc_crc(dev
->net
->dev_addr
, ETH_ALEN
, filter
);
1734 for (i
= 0; i
< (wuff_filter_count
* 4); i
++) {
1735 ret
= smsc95xx_write_reg_nopm(dev
, WUFF
, filter_mask
[i
]);
1743 for (i
= 0; i
< (wuff_filter_count
/ 4); i
++) {
1744 ret
= smsc95xx_write_reg_nopm(dev
, WUFF
, command
[i
]);
1749 for (i
= 0; i
< (wuff_filter_count
/ 4); i
++) {
1750 ret
= smsc95xx_write_reg_nopm(dev
, WUFF
, offset
[i
]);
1755 for (i
= 0; i
< (wuff_filter_count
/ 2); i
++) {
1756 ret
= smsc95xx_write_reg_nopm(dev
, WUFF
, crc
[i
]);
1761 /* clear any pending pattern match packet status */
1762 ret
= smsc95xx_read_reg_nopm(dev
, WUCSR
, &val
);
1768 ret
= smsc95xx_write_reg_nopm(dev
, WUCSR
, val
);
1773 if (pdata
->wolopts
& WAKE_MAGIC
) {
1774 /* clear any pending magic packet status */
1775 ret
= smsc95xx_read_reg_nopm(dev
, WUCSR
, &val
);
1781 ret
= smsc95xx_write_reg_nopm(dev
, WUCSR
, val
);
1786 /* enable/disable wakeup sources */
1787 ret
= smsc95xx_read_reg_nopm(dev
, WUCSR
, &val
);
1791 if (pdata
->wolopts
& (WAKE_BCAST
| WAKE_MCAST
| WAKE_ARP
| WAKE_UCAST
)) {
1792 netdev_info(dev
->net
, "enabling pattern match wakeup\n");
1793 val
|= WUCSR_WAKE_EN_
;
1795 netdev_info(dev
->net
, "disabling pattern match wakeup\n");
1796 val
&= ~WUCSR_WAKE_EN_
;
1799 if (pdata
->wolopts
& WAKE_MAGIC
) {
1800 netdev_info(dev
->net
, "enabling magic packet wakeup\n");
1803 netdev_info(dev
->net
, "disabling magic packet wakeup\n");
1804 val
&= ~WUCSR_MPEN_
;
1807 ret
= smsc95xx_write_reg_nopm(dev
, WUCSR
, val
);
1811 /* enable wol wakeup source */
1812 ret
= smsc95xx_read_reg_nopm(dev
, PM_CTRL
, &val
);
1816 val
|= PM_CTL_WOL_EN_
;
1818 /* phy energy detect wakeup source */
1819 if (pdata
->wolopts
& WAKE_PHY
)
1820 val
|= PM_CTL_ED_EN_
;
1822 ret
= smsc95xx_write_reg_nopm(dev
, PM_CTRL
, val
);
1826 /* enable receiver to enable frame reception */
1827 smsc95xx_start_rx_path(dev
, 1);
1829 /* some wol options are enabled, so enter SUSPEND0 */
1830 netdev_info(dev
->net
, "entering SUSPEND0 mode\n");
1831 ret
= smsc95xx_enter_suspend0(dev
);
1835 * TODO: resume() might need to handle the suspend failure
1838 if (ret
&& PMSG_IS_AUTO(message
))
1839 usbnet_resume(intf
);
1843 static int smsc95xx_resume(struct usb_interface
*intf
)
1845 struct usbnet
*dev
= usb_get_intfdata(intf
);
1846 struct smsc95xx_priv
*pdata
;
1852 pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
1853 suspend_flags
= pdata
->suspend_flags
;
1855 netdev_dbg(dev
->net
, "resume suspend_flags=0x%02x\n", suspend_flags
);
1857 /* do this first to ensure it's cleared even in error case */
1858 pdata
->suspend_flags
= 0;
1859 schedule_delayed_work(&pdata
->carrier_check
, CARRIER_CHECK_DELAY
);
1861 if (suspend_flags
& SUSPEND_ALLMODES
) {
1862 /* clear wake-up sources */
1863 ret
= smsc95xx_read_reg_nopm(dev
, WUCSR
, &val
);
1867 val
&= ~(WUCSR_WAKE_EN_
| WUCSR_MPEN_
);
1869 ret
= smsc95xx_write_reg_nopm(dev
, WUCSR
, val
);
1873 /* clear wake-up status */
1874 ret
= smsc95xx_read_reg_nopm(dev
, PM_CTRL
, &val
);
1878 val
&= ~PM_CTL_WOL_EN_
;
1879 val
|= PM_CTL_WUPS_
;
1881 ret
= smsc95xx_write_reg_nopm(dev
, PM_CTRL
, val
);
1886 ret
= usbnet_resume(intf
);
1888 netdev_warn(dev
->net
, "usbnet_resume error\n");
1893 static int smsc95xx_reset_resume(struct usb_interface
*intf
)
1895 struct usbnet
*dev
= usb_get_intfdata(intf
);
1898 ret
= smsc95xx_reset(dev
);
1902 return smsc95xx_resume(intf
);
1905 static void smsc95xx_rx_csum_offload(struct sk_buff
*skb
)
1907 skb
->csum
= *(u16
*)(skb_tail_pointer(skb
) - 2);
1908 skb
->ip_summed
= CHECKSUM_COMPLETE
;
1909 skb_trim(skb
, skb
->len
- 2);
1912 static int smsc95xx_rx_fixup(struct usbnet
*dev
, struct sk_buff
*skb
)
1914 /* This check is no longer done by usbnet */
1915 if (skb
->len
< dev
->net
->hard_header_len
)
1918 while (skb
->len
> 0) {
1919 u32 header
, align_count
;
1920 struct sk_buff
*ax_skb
;
1921 unsigned char *packet
;
1924 memcpy(&header
, skb
->data
, sizeof(header
));
1925 le32_to_cpus(&header
);
1926 skb_pull(skb
, 4 + NET_IP_ALIGN
);
1929 /* get the packet length */
1930 size
= (u16
)((header
& RX_STS_FL_
) >> 16);
1931 align_count
= (4 - ((size
+ NET_IP_ALIGN
) % 4)) % 4;
1933 if (unlikely(header
& RX_STS_ES_
)) {
1934 netif_dbg(dev
, rx_err
, dev
->net
,
1935 "Error header=0x%08x\n", header
);
1936 dev
->net
->stats
.rx_errors
++;
1937 dev
->net
->stats
.rx_dropped
++;
1939 if (header
& RX_STS_CRC_
) {
1940 dev
->net
->stats
.rx_crc_errors
++;
1942 if (header
& (RX_STS_TL_
| RX_STS_RF_
))
1943 dev
->net
->stats
.rx_frame_errors
++;
1945 if ((header
& RX_STS_LE_
) &&
1946 (!(header
& RX_STS_FT_
)))
1947 dev
->net
->stats
.rx_length_errors
++;
1950 /* ETH_FRAME_LEN + 4(CRC) + 2(COE) + 4(Vlan) */
1951 if (unlikely(size
> (ETH_FRAME_LEN
+ 12))) {
1952 netif_dbg(dev
, rx_err
, dev
->net
,
1953 "size err header=0x%08x\n", header
);
1957 /* last frame in this batch */
1958 if (skb
->len
== size
) {
1959 if (dev
->net
->features
& NETIF_F_RXCSUM
)
1960 smsc95xx_rx_csum_offload(skb
);
1961 skb_trim(skb
, skb
->len
- 4); /* remove fcs */
1962 skb
->truesize
= size
+ sizeof(struct sk_buff
);
1967 ax_skb
= skb_clone(skb
, GFP_ATOMIC
);
1968 if (unlikely(!ax_skb
)) {
1969 netdev_warn(dev
->net
, "Error allocating skb\n");
1974 ax_skb
->data
= packet
;
1975 skb_set_tail_pointer(ax_skb
, size
);
1977 if (dev
->net
->features
& NETIF_F_RXCSUM
)
1978 smsc95xx_rx_csum_offload(ax_skb
);
1979 skb_trim(ax_skb
, ax_skb
->len
- 4); /* remove fcs */
1980 ax_skb
->truesize
= size
+ sizeof(struct sk_buff
);
1982 usbnet_skb_return(dev
, ax_skb
);
1985 skb_pull(skb
, size
);
1987 /* padding bytes before the next frame starts */
1989 skb_pull(skb
, align_count
);
1995 static u32
smsc95xx_calc_csum_preamble(struct sk_buff
*skb
)
1997 u16 low_16
= (u16
)skb_checksum_start_offset(skb
);
1998 u16 high_16
= low_16
+ skb
->csum_offset
;
1999 return (high_16
<< 16) | low_16
;
2002 static struct sk_buff
*smsc95xx_tx_fixup(struct usbnet
*dev
,
2003 struct sk_buff
*skb
, gfp_t flags
)
2005 bool csum
= skb
->ip_summed
== CHECKSUM_PARTIAL
;
2006 int overhead
= csum
? SMSC95XX_TX_OVERHEAD_CSUM
: SMSC95XX_TX_OVERHEAD
;
2007 u32 tx_cmd_a
, tx_cmd_b
;
2009 /* We do not advertise SG, so skbs should be already linearized */
2010 BUG_ON(skb_shinfo(skb
)->nr_frags
);
2012 /* Make writable and expand header space by overhead if required */
2013 if (skb_cow_head(skb
, overhead
)) {
2014 /* Must deallocate here as returning NULL to indicate error
2015 * means the skb won't be deallocated in the caller.
2017 dev_kfree_skb_any(skb
);
2022 if (skb
->len
<= 45) {
2023 /* workaround - hardware tx checksum does not work
2024 * properly with extremely small packets */
2025 long csstart
= skb_checksum_start_offset(skb
);
2026 __wsum calc
= csum_partial(skb
->data
+ csstart
,
2027 skb
->len
- csstart
, 0);
2028 *((__sum16
*)(skb
->data
+ csstart
2029 + skb
->csum_offset
)) = csum_fold(calc
);
2033 u32 csum_preamble
= smsc95xx_calc_csum_preamble(skb
);
2035 cpu_to_le32s(&csum_preamble
);
2036 memcpy(skb
->data
, &csum_preamble
, 4);
2041 tx_cmd_b
= (u32
)(skb
->len
- 4);
2043 tx_cmd_b
|= TX_CMD_B_CSUM_ENABLE
;
2044 cpu_to_le32s(&tx_cmd_b
);
2045 memcpy(skb
->data
, &tx_cmd_b
, 4);
2048 tx_cmd_a
= (u32
)(skb
->len
- 8) | TX_CMD_A_FIRST_SEG_
|
2050 cpu_to_le32s(&tx_cmd_a
);
2051 memcpy(skb
->data
, &tx_cmd_a
, 4);
2056 static int smsc95xx_manage_power(struct usbnet
*dev
, int on
)
2058 struct smsc95xx_priv
*pdata
= (struct smsc95xx_priv
*)(dev
->data
[0]);
2060 dev
->intf
->needs_remote_wakeup
= on
;
2062 if (pdata
->features
& FEATURE_REMOTE_WAKEUP
)
2065 /* this chip revision isn't capable of remote wakeup */
2066 netdev_info(dev
->net
, "hardware isn't capable of remote wakeup\n");
2069 usb_autopm_get_interface_no_resume(dev
->intf
);
2071 usb_autopm_put_interface(dev
->intf
);
2076 static const struct driver_info smsc95xx_info
= {
2077 .description
= "smsc95xx USB 2.0 Ethernet",
2078 .bind
= smsc95xx_bind
,
2079 .unbind
= smsc95xx_unbind
,
2080 .link_reset
= smsc95xx_link_reset
,
2081 .reset
= smsc95xx_reset
,
2082 .rx_fixup
= smsc95xx_rx_fixup
,
2083 .tx_fixup
= smsc95xx_tx_fixup
,
2084 .status
= smsc95xx_status
,
2085 .manage_power
= smsc95xx_manage_power
,
2086 .flags
= FLAG_ETHER
| FLAG_SEND_ZLP
| FLAG_LINK_INTR
,
2089 static const struct usb_device_id products
[] = {
2091 /* SMSC9500 USB Ethernet Device */
2092 USB_DEVICE(0x0424, 0x9500),
2093 .driver_info
= (unsigned long) &smsc95xx_info
,
2096 /* SMSC9505 USB Ethernet Device */
2097 USB_DEVICE(0x0424, 0x9505),
2098 .driver_info
= (unsigned long) &smsc95xx_info
,
2101 /* SMSC9500A USB Ethernet Device */
2102 USB_DEVICE(0x0424, 0x9E00),
2103 .driver_info
= (unsigned long) &smsc95xx_info
,
2106 /* SMSC9505A USB Ethernet Device */
2107 USB_DEVICE(0x0424, 0x9E01),
2108 .driver_info
= (unsigned long) &smsc95xx_info
,
2111 /* SMSC9512/9514 USB Hub & Ethernet Device */
2112 USB_DEVICE(0x0424, 0xec00),
2113 .driver_info
= (unsigned long) &smsc95xx_info
,
2116 /* SMSC9500 USB Ethernet Device (SAL10) */
2117 USB_DEVICE(0x0424, 0x9900),
2118 .driver_info
= (unsigned long) &smsc95xx_info
,
2121 /* SMSC9505 USB Ethernet Device (SAL10) */
2122 USB_DEVICE(0x0424, 0x9901),
2123 .driver_info
= (unsigned long) &smsc95xx_info
,
2126 /* SMSC9500A USB Ethernet Device (SAL10) */
2127 USB_DEVICE(0x0424, 0x9902),
2128 .driver_info
= (unsigned long) &smsc95xx_info
,
2131 /* SMSC9505A USB Ethernet Device (SAL10) */
2132 USB_DEVICE(0x0424, 0x9903),
2133 .driver_info
= (unsigned long) &smsc95xx_info
,
2136 /* SMSC9512/9514 USB Hub & Ethernet Device (SAL10) */
2137 USB_DEVICE(0x0424, 0x9904),
2138 .driver_info
= (unsigned long) &smsc95xx_info
,
2141 /* SMSC9500A USB Ethernet Device (HAL) */
2142 USB_DEVICE(0x0424, 0x9905),
2143 .driver_info
= (unsigned long) &smsc95xx_info
,
2146 /* SMSC9505A USB Ethernet Device (HAL) */
2147 USB_DEVICE(0x0424, 0x9906),
2148 .driver_info
= (unsigned long) &smsc95xx_info
,
2151 /* SMSC9500 USB Ethernet Device (Alternate ID) */
2152 USB_DEVICE(0x0424, 0x9907),
2153 .driver_info
= (unsigned long) &smsc95xx_info
,
2156 /* SMSC9500A USB Ethernet Device (Alternate ID) */
2157 USB_DEVICE(0x0424, 0x9908),
2158 .driver_info
= (unsigned long) &smsc95xx_info
,
2161 /* SMSC9512/9514 USB Hub & Ethernet Device (Alternate ID) */
2162 USB_DEVICE(0x0424, 0x9909),
2163 .driver_info
= (unsigned long) &smsc95xx_info
,
2166 /* SMSC LAN9530 USB Ethernet Device */
2167 USB_DEVICE(0x0424, 0x9530),
2168 .driver_info
= (unsigned long) &smsc95xx_info
,
2171 /* SMSC LAN9730 USB Ethernet Device */
2172 USB_DEVICE(0x0424, 0x9730),
2173 .driver_info
= (unsigned long) &smsc95xx_info
,
2176 /* SMSC LAN89530 USB Ethernet Device */
2177 USB_DEVICE(0x0424, 0x9E08),
2178 .driver_info
= (unsigned long) &smsc95xx_info
,
2182 MODULE_DEVICE_TABLE(usb
, products
);
2184 static struct usb_driver smsc95xx_driver
= {
2186 .id_table
= products
,
2187 .probe
= usbnet_probe
,
2188 .suspend
= smsc95xx_suspend
,
2189 .resume
= smsc95xx_resume
,
2190 .reset_resume
= smsc95xx_reset_resume
,
2191 .disconnect
= usbnet_disconnect
,
2192 .disable_hub_initiated_lpm
= 1,
2193 .supports_autosuspend
= 1,
2196 module_usb_driver(smsc95xx_driver
);
2198 MODULE_AUTHOR("Nancy Lin");
2199 MODULE_AUTHOR("Steve Glendinning <steve.glendinning@shawell.net>");
2200 MODULE_DESCRIPTION("SMSC95XX USB 2.0 Ethernet Devices");
2201 MODULE_LICENSE("GPL");