Lines Matching +full:10 +full:base +full:- +full:t1s

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (C) 2007-2008 SMSC
59 #define PHY_HWIRQ (SMSC95XX_NR_IRQS - 1)
85 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_read_reg()
90 if (current != pdata->pm_task) in smsc95xx_read_reg()
99 ret = ret < 0 ? ret : -ENODATA; in smsc95xx_read_reg()
101 if (ret != -ENODEV) in smsc95xx_read_reg()
102 netdev_warn(dev->net, "Failed to read reg index 0x%08x: %d\n", in smsc95xx_read_reg()
116 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_write_reg()
121 if (current != pdata->pm_task) in smsc95xx_write_reg()
132 if (ret < 0 && ret != -ENODEV) in smsc95xx_write_reg()
133 netdev_warn(dev->net, "Failed to write reg index 0x%08x: %d\n", in smsc95xx_write_reg()
150 /* Ignore -ENODEV error during disconnect() */ in smsc95xx_phy_wait_not_busy()
151 if (ret == -ENODEV) in smsc95xx_phy_wait_not_busy()
153 netdev_warn(dev->net, "Error reading MII_ACCESS\n"); in smsc95xx_phy_wait_not_busy()
161 return -EIO; in smsc95xx_phy_wait_not_busy()
174 mutex_lock(&dev->phy_mutex); in smsc95xx_mdio_read()
179 netdev_warn(dev->net, "%s: MII is busy\n", __func__); in smsc95xx_mdio_read()
187 if (ret != -ENODEV) in smsc95xx_mdio_read()
188 netdev_warn(dev->net, "Error writing MII_ADDR\n"); in smsc95xx_mdio_read()
194 netdev_warn(dev->net, "Timed out reading MII reg %02X\n", idx); in smsc95xx_mdio_read()
200 if (ret != -ENODEV) in smsc95xx_mdio_read()
201 netdev_warn(dev->net, "Error reading MII_DATA\n"); in smsc95xx_mdio_read()
208 mutex_unlock(&dev->phy_mutex); in smsc95xx_mdio_read()
210 /* Ignore -ENODEV error during disconnect() */ in smsc95xx_mdio_read()
211 if (ret == -ENODEV) in smsc95xx_mdio_read()
222 mutex_lock(&dev->phy_mutex); in smsc95xx_mdio_write()
227 netdev_warn(dev->net, "%s: MII is busy\n", __func__); in smsc95xx_mdio_write()
234 if (ret != -ENODEV) in smsc95xx_mdio_write()
235 netdev_warn(dev->net, "Error writing MII_DATA\n"); in smsc95xx_mdio_write()
243 if (ret != -ENODEV) in smsc95xx_mdio_write()
244 netdev_warn(dev->net, "Error writing MII_ADDR\n"); in smsc95xx_mdio_write()
250 netdev_warn(dev->net, "Timed out writing MII reg %02X\n", idx); in smsc95xx_mdio_write()
255 mutex_unlock(&dev->phy_mutex); in smsc95xx_mdio_write()
265 dev = bus->priv; in smsc95xx_mdiobus_reset()
266 pdata = dev->driver_priv; in smsc95xx_mdiobus_reset()
268 if (pdata->is_internal_phy) in smsc95xx_mdiobus_reset()
271 mutex_lock(&dev->phy_mutex); in smsc95xx_mdiobus_reset()
290 mutex_unlock(&dev->phy_mutex); in smsc95xx_mdiobus_reset()
297 struct usbnet *dev = bus->priv; in smsc95xx_mdiobus_read()
305 struct usbnet *dev = bus->priv; in smsc95xx_mdiobus_write()
320 netdev_warn(dev->net, "Error reading E2P_CMD\n"); in smsc95xx_wait_eeprom()
330 netdev_warn(dev->net, "EEPROM read operation timeout\n"); in smsc95xx_wait_eeprom()
331 return -EIO; in smsc95xx_wait_eeprom()
346 netdev_warn(dev->net, "Error reading E2P_CMD\n"); in smsc95xx_eeprom_confirm_not_busy()
356 netdev_warn(dev->net, "EEPROM is busy\n"); in smsc95xx_eeprom_confirm_not_busy()
357 return -EIO; in smsc95xx_eeprom_confirm_not_busy()
377 netdev_warn(dev->net, "Error writing E2P_CMD\n"); in smsc95xx_read_eeprom()
387 netdev_warn(dev->net, "Error reading E2P_DATA\n"); in smsc95xx_read_eeprom()
415 netdev_warn(dev->net, "Error writing E2P_DATA\n"); in smsc95xx_write_eeprom()
429 netdev_warn(dev->net, "Error writing E2P_DATA\n"); in smsc95xx_write_eeprom()
437 netdev_warn(dev->net, "Error writing E2P_CMD\n"); in smsc95xx_write_eeprom()
466 netdev_warn(dev->net, "Error write async cmd, sts=%d\n", in smsc95xx_write_reg_async()
473 * 01 00 5E 00 00 01 -> returns bit number 31 */
482 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_set_multicast()
486 pdata->hash_hi = 0; in smsc95xx_set_multicast()
487 pdata->hash_lo = 0; in smsc95xx_set_multicast()
489 spin_lock_irqsave(&pdata->mac_cr_lock, flags); in smsc95xx_set_multicast()
491 if (dev->net->flags & IFF_PROMISC) { in smsc95xx_set_multicast()
492 netif_dbg(dev, drv, dev->net, "promiscuous mode enabled\n"); in smsc95xx_set_multicast()
493 pdata->mac_cr |= MAC_CR_PRMS_; in smsc95xx_set_multicast()
494 pdata->mac_cr &= ~(MAC_CR_MCPAS_ | MAC_CR_HPFILT_); in smsc95xx_set_multicast()
495 } else if (dev->net->flags & IFF_ALLMULTI) { in smsc95xx_set_multicast()
496 netif_dbg(dev, drv, dev->net, "receive all multicast enabled\n"); in smsc95xx_set_multicast()
497 pdata->mac_cr |= MAC_CR_MCPAS_; in smsc95xx_set_multicast()
498 pdata->mac_cr &= ~(MAC_CR_PRMS_ | MAC_CR_HPFILT_); in smsc95xx_set_multicast()
499 } else if (!netdev_mc_empty(dev->net)) { in smsc95xx_set_multicast()
502 pdata->mac_cr |= MAC_CR_HPFILT_; in smsc95xx_set_multicast()
503 pdata->mac_cr &= ~(MAC_CR_PRMS_ | MAC_CR_MCPAS_); in smsc95xx_set_multicast()
506 u32 bitnum = smsc95xx_hash(ha->addr); in smsc95xx_set_multicast()
509 pdata->hash_hi |= mask; in smsc95xx_set_multicast()
511 pdata->hash_lo |= mask; in smsc95xx_set_multicast()
514 netif_dbg(dev, drv, dev->net, "HASHH=0x%08X, HASHL=0x%08X\n", in smsc95xx_set_multicast()
515 pdata->hash_hi, pdata->hash_lo); in smsc95xx_set_multicast()
517 netif_dbg(dev, drv, dev->net, "receive own packets only\n"); in smsc95xx_set_multicast()
518 pdata->mac_cr &= in smsc95xx_set_multicast()
522 spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); in smsc95xx_set_multicast()
525 ret = smsc95xx_write_reg_async(dev, HASHH, pdata->hash_hi); in smsc95xx_set_multicast()
527 netdev_warn(dev->net, "failed to initiate async write to HASHH\n"); in smsc95xx_set_multicast()
529 ret = smsc95xx_write_reg_async(dev, HASHL, pdata->hash_lo); in smsc95xx_set_multicast()
531 netdev_warn(dev->net, "failed to initiate async write to HASHL\n"); in smsc95xx_set_multicast()
533 ret = smsc95xx_write_reg_async(dev, MAC_CR, pdata->mac_cr); in smsc95xx_set_multicast()
535 netdev_warn(dev->net, "failed to initiate async write to MAC_CR\n"); in smsc95xx_set_multicast()
541 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_phy_update_flowcontrol()
548 if (pdata->phydev->duplex == DUPLEX_FULL) { in smsc95xx_phy_update_flowcontrol()
549 phy_get_pause(pdata->phydev, &tx_pause, &rx_pause); in smsc95xx_phy_update_flowcontrol()
561 netif_dbg(dev, link, dev->net, "rx pause %s, tx pause %s\n", in smsc95xx_phy_update_flowcontrol()
565 netif_dbg(dev, link, dev->net, "half duplex\n"); in smsc95xx_phy_update_flowcontrol()
578 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_mac_update_fullduplex()
582 spin_lock_irqsave(&pdata->mac_cr_lock, flags); in smsc95xx_mac_update_fullduplex()
583 if (pdata->phydev->duplex != DUPLEX_FULL) { in smsc95xx_mac_update_fullduplex()
584 pdata->mac_cr &= ~MAC_CR_FDPX_; in smsc95xx_mac_update_fullduplex()
585 pdata->mac_cr |= MAC_CR_RCVOWN_; in smsc95xx_mac_update_fullduplex()
587 pdata->mac_cr &= ~MAC_CR_RCVOWN_; in smsc95xx_mac_update_fullduplex()
588 pdata->mac_cr |= MAC_CR_FDPX_; in smsc95xx_mac_update_fullduplex()
590 spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); in smsc95xx_mac_update_fullduplex()
592 ret = smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); in smsc95xx_mac_update_fullduplex()
594 if (ret != -ENODEV) in smsc95xx_mac_update_fullduplex()
595 netdev_warn(dev->net, in smsc95xx_mac_update_fullduplex()
602 netdev_warn(dev->net, "Error updating PHY flow control\n"); in smsc95xx_mac_update_fullduplex()
607 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_status()
611 if (urb->actual_length != 4) { in smsc95xx_status()
612 netdev_warn(dev->net, "unexpected urb length %d\n", in smsc95xx_status()
613 urb->actual_length); in smsc95xx_status()
617 intdata = get_unaligned_le32(urb->transfer_buffer); in smsc95xx_status()
618 netif_dbg(dev, link, dev->net, "intdata: 0x%08X\n", intdata); in smsc95xx_status()
623 generic_handle_domain_irq(pdata->irqdomain, PHY_HWIRQ); in smsc95xx_status()
625 netdev_warn(dev->net, "unexpected interrupt, intdata=0x%08X\n", in smsc95xx_status()
657 netif_dbg(dev, hw, dev->net, "COE_CR = 0x%08x\n", read_buf); in smsc95xx_set_features()
671 ee->magic = LAN95XX_EEPROM_MAGIC; in smsc95xx_ethtool_get_eeprom()
673 return smsc95xx_read_eeprom(dev, ee->offset, ee->len, data); in smsc95xx_ethtool_get_eeprom()
681 if (ee->magic != LAN95XX_EEPROM_MAGIC) { in smsc95xx_ethtool_set_eeprom()
682 netdev_warn(dev->net, "EEPROM: magic value mismatch, magic = 0x%x\n", in smsc95xx_ethtool_set_eeprom()
683 ee->magic); in smsc95xx_ethtool_set_eeprom()
684 return -EINVAL; in smsc95xx_ethtool_set_eeprom()
687 return smsc95xx_write_eeprom(dev, ee->offset, ee->len, data); in smsc95xx_ethtool_set_eeprom()
693 return COE_CR - ID_REV + sizeof(u32); in smsc95xx_ethtool_getregslen()
705 retval = smsc95xx_read_reg(dev, ID_REV, &regs->version); in smsc95xx_ethtool_getregs()
724 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_ethtool_get_wol()
726 wolinfo->supported = SUPPORTED_WAKE; in smsc95xx_ethtool_get_wol()
727 wolinfo->wolopts = pdata->wolopts; in smsc95xx_ethtool_get_wol()
734 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_ethtool_set_wol()
737 if (wolinfo->wolopts & ~SUPPORTED_WAKE) in smsc95xx_ethtool_set_wol()
738 return -EINVAL; in smsc95xx_ethtool_set_wol()
740 pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE; in smsc95xx_ethtool_set_wol()
742 ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts); in smsc95xx_ethtool_set_wol()
744 netdev_warn(dev->net, "device_set_wakeup_enable error %d\n", ret); in smsc95xx_ethtool_set_wol()
751 phy_read_status(net->phydev); in smsc95xx_get_link()
752 return net->phydev->link; in smsc95xx_get_link()
771 return -EOPNOTSUPP; in smsc95xx_ethtool_get_sset_count()
799 return -EINVAL; in smsc95xx_ioctl()
801 return phy_mii_ioctl(netdev->phydev, rq, cmd); in smsc95xx_ioctl()
809 if (!platform_get_ethdev_address(&dev->udev->dev, dev->net)) { in smsc95xx_init_mac_address()
810 if (is_valid_ether_addr(dev->net->dev_addr)) { in smsc95xx_init_mac_address()
812 netif_dbg(dev, ifup, dev->net, "MAC address read from the device tree\n"); in smsc95xx_init_mac_address()
819 eth_hw_addr_set(dev->net, addr); in smsc95xx_init_mac_address()
820 if (is_valid_ether_addr(dev->net->dev_addr)) { in smsc95xx_init_mac_address()
822 netif_dbg(dev, ifup, dev->net, "MAC address read from EEPROM\n"); in smsc95xx_init_mac_address()
828 eth_hw_addr_random(dev->net); in smsc95xx_init_mac_address()
829 netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n"); in smsc95xx_init_mac_address()
834 u32 addr_lo = dev->net->dev_addr[0] | dev->net->dev_addr[1] << 8 | in smsc95xx_set_mac_address()
835 dev->net->dev_addr[2] << 16 | dev->net->dev_addr[3] << 24; in smsc95xx_set_mac_address()
836 u32 addr_hi = dev->net->dev_addr[4] | dev->net->dev_addr[5] << 8; in smsc95xx_set_mac_address()
849 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_start_tx_path()
854 spin_lock_irqsave(&pdata->mac_cr_lock, flags); in smsc95xx_start_tx_path()
855 pdata->mac_cr |= MAC_CR_TXEN_; in smsc95xx_start_tx_path()
856 spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); in smsc95xx_start_tx_path()
858 ret = smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); in smsc95xx_start_tx_path()
869 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_start_rx_path()
872 spin_lock_irqsave(&pdata->mac_cr_lock, flags); in smsc95xx_start_rx_path()
873 pdata->mac_cr |= MAC_CR_RXEN_; in smsc95xx_start_rx_path()
874 spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); in smsc95xx_start_rx_path()
876 return smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); in smsc95xx_start_rx_path()
881 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_reset()
885 netif_dbg(dev, ifup, dev->net, "entering smsc95xx_reset\n"); in smsc95xx_reset()
893 msleep(10); in smsc95xx_reset()
901 netdev_warn(dev->net, "timeout waiting for completion of Lite Reset\n"); in smsc95xx_reset()
902 return -ETIMEDOUT; in smsc95xx_reset()
909 netif_dbg(dev, ifup, dev->net, "MAC Address: %pM\n", in smsc95xx_reset()
910 dev->net->dev_addr); in smsc95xx_reset()
916 netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG : 0x%08x\n", in smsc95xx_reset()
929 netif_dbg(dev, ifup, dev->net, in smsc95xx_reset()
935 dev->rx_urb_size = MAX_SINGLE_PACKET_SIZE; in smsc95xx_reset()
936 } else if (dev->udev->speed == USB_SPEED_HIGH) { in smsc95xx_reset()
938 dev->rx_urb_size = DEFAULT_HS_BURST_CAP_SIZE; in smsc95xx_reset()
941 dev->rx_urb_size = DEFAULT_FS_BURST_CAP_SIZE; in smsc95xx_reset()
944 netif_dbg(dev, ifup, dev->net, "rx_urb_size=%ld\n", in smsc95xx_reset()
945 (ulong)dev->rx_urb_size); in smsc95xx_reset()
955 netif_dbg(dev, ifup, dev->net, in smsc95xx_reset()
967 netif_dbg(dev, ifup, dev->net, in smsc95xx_reset()
975 netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG: 0x%08x\n", in smsc95xx_reset()
994 netif_dbg(dev, ifup, dev->net, in smsc95xx_reset()
1004 netif_dbg(dev, ifup, dev->net, "ID_REV = 0x%08x\n", read_buf); in smsc95xx_reset()
1026 ret = smsc95xx_read_reg(dev, MAC_CR, &pdata->mac_cr); in smsc95xx_reset()
1037 ret = smsc95xx_set_features(dev->net, dev->net->features); in smsc95xx_reset()
1039 netdev_warn(dev->net, "Failed to set checksum offload features\n"); in smsc95xx_reset()
1043 smsc95xx_set_multicast(dev->net); in smsc95xx_reset()
1058 netdev_warn(dev->net, "Failed to start TX path\n"); in smsc95xx_reset()
1064 netdev_warn(dev->net, "Failed to start RX path\n"); in smsc95xx_reset()
1068 netif_dbg(dev, ifup, dev->net, "smsc95xx_reset, return 0\n"); in smsc95xx_reset()
1090 phy_print_status(net->phydev); in smsc95xx_handle_link_change()
1106 netdev_warn(dev->net, "usbnet_get_endpoints failed: %d\n", ret); in smsc95xx_bind()
1112 return -ENOMEM; in smsc95xx_bind()
1114 dev->driver_priv = pdata; in smsc95xx_bind()
1116 spin_lock_init(&pdata->mac_cr_lock); in smsc95xx_bind()
1126 dev->net->features |= NETIF_F_IP_CSUM; in smsc95xx_bind()
1128 dev->net->features |= NETIF_F_RXCSUM; in smsc95xx_bind()
1130 dev->net->hw_features = NETIF_F_IP_CSUM | NETIF_F_RXCSUM; in smsc95xx_bind()
1131 set_bit(EVENT_NO_IP_ALIGN, &dev->flags); in smsc95xx_bind()
1141 usb_make_path(dev->udev, usb_path, sizeof(usb_path)); in smsc95xx_bind()
1142 pdata->irqfwnode = irq_domain_alloc_named_fwnode(usb_path); in smsc95xx_bind()
1143 if (!pdata->irqfwnode) { in smsc95xx_bind()
1144 ret = -ENOMEM; in smsc95xx_bind()
1148 pdata->irqdomain = irq_domain_create_linear(pdata->irqfwnode, in smsc95xx_bind()
1152 if (!pdata->irqdomain) { in smsc95xx_bind()
1153 ret = -ENOMEM; in smsc95xx_bind()
1157 phy_irq = irq_create_mapping(pdata->irqdomain, PHY_HWIRQ); in smsc95xx_bind()
1159 ret = -ENOENT; in smsc95xx_bind()
1163 pdata->irqchip = dummy_irq_chip; in smsc95xx_bind()
1164 pdata->irqchip.name = SMSC_CHIPNAME; in smsc95xx_bind()
1165 irq_set_chip_and_handler_name(phy_irq, &pdata->irqchip, in smsc95xx_bind()
1168 pdata->mdiobus = mdiobus_alloc(); in smsc95xx_bind()
1169 if (!pdata->mdiobus) { in smsc95xx_bind()
1170 ret = -ENOMEM; in smsc95xx_bind()
1178 pdata->is_internal_phy = !(val & HW_CFG_PSEL_); in smsc95xx_bind()
1179 if (pdata->is_internal_phy) in smsc95xx_bind()
1180 pdata->mdiobus->phy_mask = ~(1u << SMSC95XX_INTERNAL_PHY_ID); in smsc95xx_bind()
1182 pdata->mdiobus->priv = dev; in smsc95xx_bind()
1183 pdata->mdiobus->read = smsc95xx_mdiobus_read; in smsc95xx_bind()
1184 pdata->mdiobus->write = smsc95xx_mdiobus_write; in smsc95xx_bind()
1185 pdata->mdiobus->reset = smsc95xx_mdiobus_reset; in smsc95xx_bind()
1186 pdata->mdiobus->name = "smsc95xx-mdiobus"; in smsc95xx_bind()
1187 pdata->mdiobus->parent = &dev->udev->dev; in smsc95xx_bind()
1189 snprintf(pdata->mdiobus->id, ARRAY_SIZE(pdata->mdiobus->id), in smsc95xx_bind()
1190 "usb-%03d:%03d", dev->udev->bus->busnum, dev->udev->devnum); in smsc95xx_bind()
1192 ret = mdiobus_register(pdata->mdiobus); in smsc95xx_bind()
1194 netdev_err(dev->net, "Could not register MDIO bus\n"); in smsc95xx_bind()
1198 pdata->phydev = phy_find_first(pdata->mdiobus); in smsc95xx_bind()
1199 if (!pdata->phydev) { in smsc95xx_bind()
1200 netdev_err(dev->net, "no PHY found\n"); in smsc95xx_bind()
1201 ret = -ENODEV; in smsc95xx_bind()
1205 pdata->phydev->irq = phy_irq; in smsc95xx_bind()
1206 pdata->phydev->is_internal = pdata->is_internal_phy; in smsc95xx_bind()
1216 pdata->features = (FEATURE_8_WAKEUP_FILTERS | in smsc95xx_bind()
1220 pdata->features = FEATURE_8_WAKEUP_FILTERS; in smsc95xx_bind()
1222 dev->net->netdev_ops = &smsc95xx_netdev_ops; in smsc95xx_bind()
1223 dev->net->ethtool_ops = &smsc95xx_ethtool_ops; in smsc95xx_bind()
1224 dev->net->flags |= IFF_MULTICAST; in smsc95xx_bind()
1225 dev->net->hard_header_len += SMSC95XX_TX_OVERHEAD_CSUM; in smsc95xx_bind()
1226 dev->net->min_mtu = ETH_MIN_MTU; in smsc95xx_bind()
1227 dev->net->max_mtu = ETH_DATA_LEN; in smsc95xx_bind()
1228 dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; in smsc95xx_bind()
1230 ret = phy_connect_direct(dev->net, pdata->phydev, in smsc95xx_bind()
1234 netdev_err(dev->net, "can't attach PHY to %s\n", pdata->mdiobus->id); in smsc95xx_bind()
1238 phy_attached_info(dev->net->phydev); in smsc95xx_bind()
1243 mdiobus_unregister(pdata->mdiobus); in smsc95xx_bind()
1246 mdiobus_free(pdata->mdiobus); in smsc95xx_bind()
1252 irq_domain_remove(pdata->irqdomain); in smsc95xx_bind()
1255 irq_domain_free_fwnode(pdata->irqfwnode); in smsc95xx_bind()
1264 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_unbind()
1266 phy_disconnect(dev->net->phydev); in smsc95xx_unbind()
1267 mdiobus_unregister(pdata->mdiobus); in smsc95xx_unbind()
1268 mdiobus_free(pdata->mdiobus); in smsc95xx_unbind()
1269 irq_dispose_mapping(irq_find_mapping(pdata->irqdomain, PHY_HWIRQ)); in smsc95xx_unbind()
1270 irq_domain_remove(pdata->irqdomain); in smsc95xx_unbind()
1271 irq_domain_free_fwnode(pdata->irqfwnode); in smsc95xx_unbind()
1272 netif_dbg(dev, ifdown, dev->net, "free pdata\n"); in smsc95xx_unbind()
1278 phy_start(dev->net->phydev); in smsc95xx_start_phy()
1285 phy_stop(dev->net->phydev); in smsc95xx_stop()
1298 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_link_ok()
1302 ret = smsc95xx_mdio_read(dev, pdata->phydev->mdio.addr, MII_BMSR); in smsc95xx_link_ok()
1306 ret = smsc95xx_mdio_read(dev, pdata->phydev->mdio.addr, MII_BMSR); in smsc95xx_link_ok()
1315 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_enter_suspend0()
1335 if (pdata->wolopts & WAKE_PHY) in smsc95xx_enter_suspend0()
1347 pdata->suspend_flags |= SUSPEND_SUSPEND0; in smsc95xx_enter_suspend0()
1354 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_enter_suspend1()
1355 int ret, phy_id = pdata->phydev->mdio.addr; in smsc95xx_enter_suspend1()
1359 * compatibility with non-standard link partners in smsc95xx_enter_suspend1()
1361 if (pdata->features & FEATURE_PHY_NLP_CROSSOVER) in smsc95xx_enter_suspend1()
1365 /* enable energy detect power-down mode */ in smsc95xx_enter_suspend1()
1394 pdata->suspend_flags |= SUSPEND_SUSPEND1; in smsc95xx_enter_suspend1()
1401 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_enter_suspend2()
1416 pdata->suspend_flags |= SUSPEND_SUSPEND2; in smsc95xx_enter_suspend2()
1423 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_enter_suspend3()
1432 netdev_info(dev->net, "rx fifo not empty in autosuspend\n"); in smsc95xx_enter_suspend3()
1433 return -EBUSY; in smsc95xx_enter_suspend3()
1455 pdata->suspend_flags |= SUSPEND_SUSPEND3; in smsc95xx_enter_suspend3()
1462 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_autosuspend()
1464 if (!netif_running(dev->net)) { in smsc95xx_autosuspend()
1466 netdev_dbg(dev->net, "autosuspend entering SUSPEND2\n"); in smsc95xx_autosuspend()
1475 if (!(pdata->features & FEATURE_PHY_NLP_CROSSOVER)) { in smsc95xx_autosuspend()
1476 netdev_warn(dev->net, "EDPD not supported\n"); in smsc95xx_autosuspend()
1477 return -EBUSY; in smsc95xx_autosuspend()
1480 netdev_dbg(dev->net, "autosuspend entering SUSPEND1\n"); in smsc95xx_autosuspend()
1481 netdev_info(dev->net, "entering SUSPEND1 mode\n"); in smsc95xx_autosuspend()
1485 netdev_dbg(dev->net, "autosuspend entering SUSPEND3\n"); in smsc95xx_autosuspend()
1492 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_suspend()
1496 pdata->pm_task = current; in smsc95xx_suspend()
1500 netdev_warn(dev->net, "usbnet_suspend error\n"); in smsc95xx_suspend()
1501 pdata->pm_task = NULL; in smsc95xx_suspend()
1505 if (pdata->suspend_flags) { in smsc95xx_suspend()
1506 netdev_warn(dev->net, "error during last resume\n"); in smsc95xx_suspend()
1507 pdata->suspend_flags = 0; in smsc95xx_suspend()
1513 (pdata->features & FEATURE_REMOTE_WAKEUP)) { in smsc95xx_suspend()
1522 if (!(pdata->wolopts & SUPPORTED_WAKE) || in smsc95xx_suspend()
1523 !(link_up || (pdata->wolopts & WAKE_PHY))) { in smsc95xx_suspend()
1524 netdev_info(dev->net, "entering SUSPEND2 mode\n"); in smsc95xx_suspend()
1551 if (pdata->wolopts & WAKE_PHY) { in smsc95xx_suspend()
1556 netdev_info(dev->net, "entering SUSPEND1 mode\n"); in smsc95xx_suspend()
1562 if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) { in smsc95xx_suspend()
1568 (pdata->features & FEATURE_8_WAKEUP_FILTERS) ? in smsc95xx_suspend()
1573 netdev_warn(dev->net, "Unable to allocate filter_mask\n"); in smsc95xx_suspend()
1574 ret = -ENOMEM; in smsc95xx_suspend()
1582 if (pdata->wolopts & WAKE_BCAST) { in smsc95xx_suspend()
1584 netdev_info(dev->net, "enabling broadcast detection\n"); in smsc95xx_suspend()
1595 if (pdata->wolopts & WAKE_MCAST) { in smsc95xx_suspend()
1597 netdev_info(dev->net, "enabling multicast detection\n"); in smsc95xx_suspend()
1608 if (pdata->wolopts & WAKE_ARP) { in smsc95xx_suspend()
1610 netdev_info(dev->net, "enabling ARP detection\n"); in smsc95xx_suspend()
1621 if (pdata->wolopts & WAKE_UCAST) { in smsc95xx_suspend()
1622 netdev_info(dev->net, "enabling unicast detection\n"); in smsc95xx_suspend()
1629 crc[filter/2] |= smsc_crc(dev->net->dev_addr, ETH_ALEN, filter); in smsc95xx_suspend()
1672 if (pdata->wolopts & WAKE_MAGIC) { in smsc95xx_suspend()
1690 if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) { in smsc95xx_suspend()
1691 netdev_info(dev->net, "enabling pattern match wakeup\n"); in smsc95xx_suspend()
1694 netdev_info(dev->net, "disabling pattern match wakeup\n"); in smsc95xx_suspend()
1698 if (pdata->wolopts & WAKE_MAGIC) { in smsc95xx_suspend()
1699 netdev_info(dev->net, "enabling magic packet wakeup\n"); in smsc95xx_suspend()
1702 netdev_info(dev->net, "disabling magic packet wakeup\n"); in smsc95xx_suspend()
1718 if (pdata->wolopts & WAKE_PHY) in smsc95xx_suspend()
1729 netdev_info(dev->net, "entering SUSPEND0 mode\n"); in smsc95xx_suspend()
1740 pdata->pm_task = NULL; in smsc95xx_suspend()
1753 pdata = dev->driver_priv; in smsc95xx_resume()
1754 suspend_flags = pdata->suspend_flags; in smsc95xx_resume()
1756 netdev_dbg(dev->net, "resume suspend_flags=0x%02x\n", suspend_flags); in smsc95xx_resume()
1759 pdata->suspend_flags = 0; in smsc95xx_resume()
1761 pdata->pm_task = current; in smsc95xx_resume()
1764 /* clear wake-up sources */ in smsc95xx_resume()
1775 /* clear wake-up status */ in smsc95xx_resume()
1788 phy_init_hw(pdata->phydev); in smsc95xx_resume()
1792 netdev_warn(dev->net, "usbnet_resume error\n"); in smsc95xx_resume()
1795 pdata->pm_task = NULL; in smsc95xx_resume()
1802 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_reset_resume()
1805 pdata->pm_task = current; in smsc95xx_reset_resume()
1807 pdata->pm_task = NULL; in smsc95xx_reset_resume()
1816 u16 *csum_ptr = (u16 *)(skb_tail_pointer(skb) - 2); in smsc95xx_rx_csum_offload()
1818 skb->csum = (__force __wsum)get_unaligned(csum_ptr); in smsc95xx_rx_csum_offload()
1819 skb->ip_summed = CHECKSUM_COMPLETE; in smsc95xx_rx_csum_offload()
1820 skb_trim(skb, skb->len - 2); /* remove csum */ in smsc95xx_rx_csum_offload()
1826 if (skb->len < dev->net->hard_header_len) in smsc95xx_rx_fixup()
1829 while (skb->len > 0) { in smsc95xx_rx_fixup()
1835 header = get_unaligned_le32(skb->data); in smsc95xx_rx_fixup()
1837 packet = skb->data; in smsc95xx_rx_fixup()
1841 align_count = (4 - ((size + NET_IP_ALIGN) % 4)) % 4; in smsc95xx_rx_fixup()
1843 if (unlikely(size > skb->len)) { in smsc95xx_rx_fixup()
1844 netif_dbg(dev, rx_err, dev->net, in smsc95xx_rx_fixup()
1850 netif_dbg(dev, rx_err, dev->net, in smsc95xx_rx_fixup()
1852 dev->net->stats.rx_errors++; in smsc95xx_rx_fixup()
1853 dev->net->stats.rx_dropped++; in smsc95xx_rx_fixup()
1856 dev->net->stats.rx_crc_errors++; in smsc95xx_rx_fixup()
1859 dev->net->stats.rx_frame_errors++; in smsc95xx_rx_fixup()
1863 dev->net->stats.rx_length_errors++; in smsc95xx_rx_fixup()
1868 netif_dbg(dev, rx_err, dev->net, in smsc95xx_rx_fixup()
1874 if (skb->len == size) { in smsc95xx_rx_fixup()
1875 if (dev->net->features & NETIF_F_RXCSUM) in smsc95xx_rx_fixup()
1877 skb_trim(skb, skb->len - 4); /* remove fcs */ in smsc95xx_rx_fixup()
1882 ax_skb = netdev_alloc_skb_ip_align(dev->net, size); in smsc95xx_rx_fixup()
1884 netdev_warn(dev->net, "Error allocating skb\n"); in smsc95xx_rx_fixup()
1889 memcpy(ax_skb->data, packet, size); in smsc95xx_rx_fixup()
1891 if (dev->net->features & NETIF_F_RXCSUM) in smsc95xx_rx_fixup()
1893 skb_trim(ax_skb, ax_skb->len - 4); /* remove fcs */ in smsc95xx_rx_fixup()
1901 if (skb->len) in smsc95xx_rx_fixup()
1911 u16 high_16 = low_16 + skb->csum_offset; in smsc95xx_calc_csum_preamble()
1925 unsigned int len = skb->len - skb_checksum_start_offset(skb); in smsc95xx_can_tx_checksum()
1927 if (skb->len <= 45) in smsc95xx_can_tx_checksum()
1929 return skb->csum_offset < (len - (4 + 1)); in smsc95xx_can_tx_checksum()
1935 bool csum = skb->ip_summed == CHECKSUM_PARTIAL; in smsc95xx_tx_fixup()
1941 BUG_ON(skb_shinfo(skb)->nr_frags); in smsc95xx_tx_fixup()
1952 tx_cmd_b = (u32)skb->len; in smsc95xx_tx_fixup()
1957 /* workaround - hardware tx checksum does not work in smsc95xx_tx_fixup()
1960 __wsum calc = csum_partial(skb->data + csstart, in smsc95xx_tx_fixup()
1961 skb->len - csstart, 0); in smsc95xx_tx_fixup()
1962 *((__sum16 *)(skb->data + csstart in smsc95xx_tx_fixup()
1963 + skb->csum_offset)) = csum_fold(calc); in smsc95xx_tx_fixup()
1986 struct smsc95xx_priv *pdata = dev->driver_priv; in smsc95xx_manage_power()
1988 dev->intf->needs_remote_wakeup = on; in smsc95xx_manage_power()
1990 if (pdata->features & FEATURE_REMOTE_WAKEUP) in smsc95xx_manage_power()
1994 netdev_info(dev->net, "hardware isn't capable of remote wakeup\n"); in smsc95xx_manage_power()
1997 usb_autopm_get_interface_no_resume(dev->intf); in smsc95xx_manage_power()
1999 usb_autopm_put_interface(dev->intf); in smsc95xx_manage_power()
2110 /* SYSTEC USB-SPEmodule1 10BASE-T1L Ethernet Device */
2115 /* Microchip's EVB-LAN8670-USB 10BASE-T1S Ethernet Device */