Lines Matching +full:asym +full:- +full:pause

1 // SPDX-License-Identifier: GPL-2.0+
202 put_device(&phydev->mdio.dev); in phy_device_free()
236 struct device_driver *drv = phydev->mdio.dev.driver; in mdio_bus_phy_may_suspend()
238 struct net_device *netdev = phydev->attached_dev; in mdio_bus_phy_may_suspend()
240 if (!drv || !phydrv->suspend) in mdio_bus_phy_may_suspend()
244 * suspended as part of a prior call to phy_disconnect() -> in mdio_bus_phy_may_suspend()
245 * phy_detach() -> phy_suspend() because the parent netdev might be the in mdio_bus_phy_may_suspend()
249 return !phydev->suspended; in mdio_bus_phy_may_suspend()
251 if (netdev->wol_enabled) in mdio_bus_phy_may_suspend()
259 if (netdev->dev.parent && device_may_wakeup(netdev->dev.parent)) in mdio_bus_phy_may_suspend()
266 if (device_may_wakeup(&netdev->dev)) in mdio_bus_phy_may_suspend()
277 * control, possibly with the phydev->lock held. Upon resume, netdev in mdio_bus_phy_suspend()
281 if (phydev->attached_dev && phydev->adjust_link) in mdio_bus_phy_suspend()
303 if (phydev->attached_dev && phydev->adjust_link) in mdio_bus_phy_resume()
312 struct net_device *netdev = phydev->attached_dev; in mdio_bus_phy_restore()
322 if (phydev->attached_dev && phydev->adjust_link) in mdio_bus_phy_restore()
345 * phy_register_fixup - creates a new phy_fixup and adds it to the list
346 * @bus_id: A string which matches phydev->mdio.dev.bus_id (or PHY_ANY_ID)
347 * @phy_uid: Used to match against phydev->phy_id (the UID of the PHY)
349 * @phy_uid_mask: Applied to phydev->phy_id and fixup->phy_uid before
359 return -ENOMEM; in phy_register_fixup()
361 strlcpy(fixup->bus_id, bus_id, sizeof(fixup->bus_id)); in phy_register_fixup()
362 fixup->phy_uid = phy_uid; in phy_register_fixup()
363 fixup->phy_uid_mask = phy_uid_mask; in phy_register_fixup()
364 fixup->run = run; in phy_register_fixup()
367 list_add_tail(&fixup->list, &phy_fixup_list); in phy_register_fixup()
391 * phy_unregister_fixup - remove a phy_fixup from the list
392 * @bus_id: A string matches fixup->bus_id (or PHY_ANY_ID) in phy_fixup_list
393 * @phy_uid: A phy id matches fixup->phy_id (or PHY_ANY_UID) in phy_fixup_list
394 * @phy_uid_mask: Applied to phy_uid and fixup->phy_uid before comparison
402 ret = -ENODEV; in phy_unregister_fixup()
408 if ((!strcmp(fixup->bus_id, bus_id)) && in phy_unregister_fixup()
409 ((fixup->phy_uid & phy_uid_mask) == in phy_unregister_fixup()
411 list_del(&fixup->list); in phy_unregister_fixup()
442 if (strcmp(fixup->bus_id, phydev_name(phydev)) != 0) in phy_needs_fixup()
443 if (strcmp(fixup->bus_id, PHY_ANY_ID) != 0) in phy_needs_fixup()
446 if ((fixup->phy_uid & fixup->phy_uid_mask) != in phy_needs_fixup()
447 (phydev->phy_id & fixup->phy_uid_mask)) in phy_needs_fixup()
448 if (fixup->phy_uid != PHY_ANY_UID) in phy_needs_fixup()
462 int err = fixup->run(phydev); in phy_scan_fixups()
468 phydev->has_fixups = true; in phy_scan_fixups()
480 const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids); in phy_bus_match()
483 if (!(phydrv->mdiodrv.flags & MDIO_DEVICE_IS_PHY)) in phy_bus_match()
486 if (phydrv->match_phy_device) in phy_bus_match()
487 return phydrv->match_phy_device(phydev); in phy_bus_match()
489 if (phydev->is_c45) { in phy_bus_match()
491 if (!(phydev->c45_ids.devices_in_package & (1 << i))) in phy_bus_match()
494 if ((phydrv->phy_id & phydrv->phy_id_mask) == in phy_bus_match()
495 (phydev->c45_ids.device_ids[i] & in phy_bus_match()
496 phydrv->phy_id_mask)) in phy_bus_match()
501 return (phydrv->phy_id & phydrv->phy_id_mask) == in phy_bus_match()
502 (phydev->phy_id & phydrv->phy_id_mask); in phy_bus_match()
511 return sprintf(buf, "0x%.8lx\n", (unsigned long)phydev->phy_id); in phy_id_show()
524 mode = phy_modes(phydev->interface); in phy_interface_show()
536 return sprintf(buf, "%d\n", phydev->has_fixups); in phy_has_fixups_show()
563 * Accept -ENOENT because this may occur in case no initramfs exists, in phy_request_driver_module()
566 if (IS_ENABLED(CONFIG_MODULES) && ret < 0 && ret != -ENOENT) { in phy_request_driver_module()
586 return ERR_PTR(-ENOMEM); in phy_device_create()
588 mdiodev = &dev->mdio; in phy_device_create()
589 mdiodev->dev.parent = &bus->dev; in phy_device_create()
590 mdiodev->dev.bus = &mdio_bus_type; in phy_device_create()
591 mdiodev->dev.type = &mdio_bus_phy_type; in phy_device_create()
592 mdiodev->bus = bus; in phy_device_create()
593 mdiodev->bus_match = phy_bus_match; in phy_device_create()
594 mdiodev->addr = addr; in phy_device_create()
595 mdiodev->flags = MDIO_DEVICE_FLAG_PHY; in phy_device_create()
596 mdiodev->device_free = phy_mdio_device_free; in phy_device_create()
597 mdiodev->device_remove = phy_mdio_device_remove; in phy_device_create()
599 dev->speed = 0; in phy_device_create()
600 dev->duplex = -1; in phy_device_create()
601 dev->pause = 0; in phy_device_create()
602 dev->asym_pause = 0; in phy_device_create()
603 dev->link = 0; in phy_device_create()
604 dev->interface = PHY_INTERFACE_MODE_GMII; in phy_device_create()
606 dev->autoneg = AUTONEG_ENABLE; in phy_device_create()
608 dev->is_c45 = is_c45; in phy_device_create()
609 dev->phy_id = phy_id; in phy_device_create()
611 dev->c45_ids = *c45_ids; in phy_device_create()
612 dev->irq = bus->irq[addr]; in phy_device_create()
613 dev_set_name(&mdiodev->dev, PHY_ID_FMT, bus->id, addr); in phy_device_create()
615 dev->state = PHY_DOWN; in phy_device_create()
617 mutex_init(&dev->lock); in phy_device_create()
618 INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine); in phy_device_create()
625 * -- because it relies on the device staying around for long in phy_device_create()
631 const int num_ids = ARRAY_SIZE(c45_ids->device_ids); in phy_device_create()
635 if (!(c45_ids->devices_in_package & (1 << i))) in phy_device_create()
639 c45_ids->device_ids[i]); in phy_device_create()
648 device_initialize(&mdiodev->dev); in phy_device_create()
658 /* get_phy_c45_devs_in_pkg - reads a MMD's devices in package registers.
667 * Returns: 0 on success, -EIO on failure.
677 return -EIO; in get_phy_c45_devs_in_pkg()
683 return -EIO; in get_phy_c45_devs_in_pkg()
693 * get_phy_c45_ids - reads the specified addr for its 802.3-c45 IDs.
699 * If the PHY devices-in-package appears to be valid, it and the
709 const int num_ids = ARRAY_SIZE(c45_ids->device_ids); in get_phy_c45_ids()
710 u32 *devs = &c45_ids->devices_in_package; in get_phy_c45_ids()
712 /* Find first non-zero Devices In package. Device zero is reserved in get_phy_c45_ids()
718 return -EIO; in get_phy_c45_ids()
728 return -EIO; in get_phy_c45_ids()
741 if (!(c45_ids->devices_in_package & (1 << i))) in get_phy_c45_ids()
747 return -EIO; in get_phy_c45_ids()
748 c45_ids->device_ids[i] = phy_reg << 16; in get_phy_c45_ids()
753 return -EIO; in get_phy_c45_ids()
754 c45_ids->device_ids[i] |= phy_reg; in get_phy_c45_ids()
761 * get_phy_id - reads the specified addr for its ID.
768 * Description: In the case of a 802.3-c22 PHY, reads the ID registers
772 * In the case of a 802.3-c45 PHY, get_phy_c45_ids() is invoked, and
787 /* returning -ENODEV doesn't stop bus scanning */ in get_phy_id()
788 return (phy_reg == -EIO || phy_reg == -ENODEV) ? -ENODEV : -EIO; in get_phy_id()
796 return -EIO; in get_phy_id()
804 * get_phy_device - reads the specified PHY device and returns its @phy_device
825 return ERR_PTR(-ENODEV); in get_phy_device()
832 * phy_device_register - Register the phy device on the MDIO bus
839 err = mdiobus_register_device(&phydev->mdio); in phy_device_register()
853 err = device_add(&phydev->mdio.dev); in phy_device_register()
865 mdiobus_unregister_device(&phydev->mdio); in phy_device_register()
871 * phy_device_remove - Remove a previously registered phy device from the MDIO bus
880 device_del(&phydev->mdio.dev); in phy_device_remove()
885 mdiobus_unregister_device(&phydev->mdio); in phy_device_remove()
890 * phy_find_first - finds the first PHY device on the bus
909 struct net_device *netdev = phydev->attached_dev; in phy_link_change()
917 phydev->adjust_link(netdev); in phy_link_change()
921 * phy_prepare_link - prepares the PHY layer to monitor link status
935 phydev->adjust_link = handler; in phy_prepare_link()
939 * phy_connect_direct - connect an ethernet device to a specific phy_device
952 return -EINVAL; in phy_connect_direct()
954 rc = phy_attach_direct(dev, phydev, phydev->dev_flags, interface); in phy_connect_direct()
967 * phy_connect - connect an ethernet device to a PHY device
995 return ERR_PTR(-ENODEV); in phy_connect()
1009 * phy_disconnect - disable interrupts, stop state machine, and detach a PHY
1021 phydev->adjust_link = NULL; in phy_disconnect()
1028 * phy_poll_reset - Safely wait until a PHY reset has properly completed
1040 * even *REQUIRE* a soft-reset to properly restart autonegotiation. In an
1043 * and reapply all driver-specific and board-specific fixups.
1056 } while (ret & BMCR_RESET && --retries); in phy_poll_reset()
1058 return -ETIMEDOUT; in phy_poll_reset()
1074 if (!phydev->drv) in phy_init_hw()
1077 if (phydev->drv->soft_reset) in phy_init_hw()
1078 ret = phydev->drv->soft_reset(phydev); in phy_init_hw()
1087 if (phydev->drv->config_init) in phy_init_hw()
1088 ret = phydev->drv->config_init(phydev); in phy_init_hw()
1103 const char *drv_name = phydev->drv ? phydev->drv->name : "unbound"; in phy_attached_print()
1107 switch(phydev->irq) { in phy_attached_print()
1115 snprintf(irq_num, sizeof(irq_num), "%d", phydev->irq); in phy_attached_print()
1141 struct net_device *dev = phydev->attached_dev; in phy_sysfs_create_links()
1147 err = sysfs_create_link(&phydev->mdio.dev.kobj, &dev->dev.kobj, in phy_sysfs_create_links()
1152 err = sysfs_create_link_nowarn(&dev->dev.kobj, in phy_sysfs_create_links()
1153 &phydev->mdio.dev.kobj, in phy_sysfs_create_links()
1156 dev_err(&dev->dev, "could not add device link to %s err %d\n", in phy_sysfs_create_links()
1157 kobject_name(&phydev->mdio.dev.kobj), in phy_sysfs_create_links()
1159 /* non-fatal - some net drivers can use one netdevice in phy_sysfs_create_links()
1164 phydev->sysfs_links = true; in phy_sysfs_create_links()
1173 return sprintf(buf, "%d\n", !phydev->attached_dev); in phy_standalone_show()
1178 * phy_attach_direct - attach a network device to a given PHY device pointer
1195 struct mii_bus *bus = phydev->mdio.bus; in phy_attach_direct()
1196 struct device *d = &phydev->mdio.dev; in phy_attach_direct()
1202 * will have bus->owner match ndev_mod, so we do not want to increment in phy_attach_direct()
1203 * our own module->refcnt here, otherwise we would not be able to in phy_attach_direct()
1207 ndev_owner = dev->dev.parent->driver->owner; in phy_attach_direct()
1208 if (ndev_owner != bus->owner && !try_module_get(bus->owner)) { in phy_attach_direct()
1210 return -EIO; in phy_attach_direct()
1218 if (!d->driver) { in phy_attach_direct()
1219 if (phydev->is_c45) in phy_attach_direct()
1220 d->driver = &genphy_c45_driver.mdiodrv.driver; in phy_attach_direct()
1222 d->driver = &genphy_driver.mdiodrv.driver; in phy_attach_direct()
1227 if (!try_module_get(d->driver->owner)) { in phy_attach_direct()
1229 err = -EIO; in phy_attach_direct()
1234 err = d->driver->probe(d); in phy_attach_direct()
1242 if (phydev->attached_dev) { in phy_attach_direct()
1243 dev_err(&dev->dev, "PHY already attached\n"); in phy_attach_direct()
1244 err = -EBUSY; in phy_attach_direct()
1248 phydev->phy_link_change = phy_link_change; in phy_attach_direct()
1250 phydev->attached_dev = dev; in phy_attach_direct()
1251 dev->phydev = phydev; in phy_attach_direct()
1255 * calling register_netdevice() -> netdev_register_kobject() and in phy_attach_direct()
1256 * does the dev->dev.kobj initialization. Here we only check for in phy_attach_direct()
1262 phydev->sysfs_links = false; in phy_attach_direct()
1266 if (!phydev->attached_dev) { in phy_attach_direct()
1267 err = sysfs_create_file(&phydev->mdio.dev.kobj, in phy_attach_direct()
1273 phydev->dev_flags = flags; in phy_attach_direct()
1275 phydev->interface = interface; in phy_attach_direct()
1277 phydev->state = PHY_READY; in phy_attach_direct()
1283 netif_carrier_off(phydev->attached_dev); in phy_attach_direct()
1304 module_put(d->driver->owner); in phy_attach_direct()
1307 if (ndev_owner != bus->owner) in phy_attach_direct()
1308 module_put(bus->owner); in phy_attach_direct()
1314 * phy_attach - attach a network device to a particular PHY device
1331 return ERR_PTR(-EINVAL); in phy_attach()
1339 return ERR_PTR(-ENODEV); in phy_attach()
1343 rc = phy_attach_direct(dev, phydev, phydev->dev_flags, interface); in phy_attach()
1355 struct device *d = &phydev->mdio.dev; in phy_driver_is_genphy_kind()
1358 if (!phydev->drv) in phy_driver_is_genphy_kind()
1362 ret = d->driver == driver; in phy_driver_is_genphy_kind()
1383 * phy_detach - detach a PHY device from its network device
1391 struct net_device *dev = phydev->attached_dev; in phy_detach()
1395 if (phydev->sysfs_links) { in phy_detach()
1397 sysfs_remove_link(&dev->dev.kobj, "phydev"); in phy_detach()
1398 sysfs_remove_link(&phydev->mdio.dev.kobj, "attached_dev"); in phy_detach()
1401 if (!phydev->attached_dev) in phy_detach()
1402 sysfs_remove_file(&phydev->mdio.dev.kobj, in phy_detach()
1407 phydev->attached_dev->phydev = NULL; in phy_detach()
1408 phydev->attached_dev = NULL; in phy_detach()
1410 phydev->phylink = NULL; in phy_detach()
1414 module_put(phydev->mdio.dev.driver->owner); in phy_detach()
1416 /* If the device had no specific driver before (i.e. - it in phy_detach()
1423 device_release_driver(&phydev->mdio.dev); in phy_detach()
1427 * a use-after-free bug by reading the underlying bus first. in phy_detach()
1429 bus = phydev->mdio.bus; in phy_detach()
1431 put_device(&phydev->mdio.dev); in phy_detach()
1433 ndev_owner = dev->dev.parent->driver->owner; in phy_detach()
1434 if (ndev_owner != bus->owner) in phy_detach()
1435 module_put(bus->owner); in phy_detach()
1444 struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver); in phy_suspend()
1445 struct net_device *netdev = phydev->attached_dev; in phy_suspend()
1451 if (wol.wolopts || (netdev && netdev->wol_enabled)) in phy_suspend()
1452 return -EBUSY; in phy_suspend()
1454 if (phydev->drv && phydrv->suspend) in phy_suspend()
1455 ret = phydrv->suspend(phydev); in phy_suspend()
1460 phydev->suspended = true; in phy_suspend()
1468 struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver); in __phy_resume()
1471 WARN_ON(!mutex_is_locked(&phydev->lock)); in __phy_resume()
1473 if (phydev->drv && phydrv->resume) in __phy_resume()
1474 ret = phydrv->resume(phydev); in __phy_resume()
1479 phydev->suspended = false; in __phy_resume()
1489 mutex_lock(&phydev->lock); in phy_resume()
1491 mutex_unlock(&phydev->lock); in phy_resume()
1499 struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver); in phy_loopback()
1502 mutex_lock(&phydev->lock); in phy_loopback()
1504 if (enable && phydev->loopback_enabled) { in phy_loopback()
1505 ret = -EBUSY; in phy_loopback()
1509 if (!enable && !phydev->loopback_enabled) { in phy_loopback()
1510 ret = -EINVAL; in phy_loopback()
1514 if (phydev->drv && phydrv->set_loopback) in phy_loopback()
1515 ret = phydrv->set_loopback(phydev, enable); in phy_loopback()
1517 ret = -EOPNOTSUPP; in phy_loopback()
1522 phydev->loopback_enabled = enable; in phy_loopback()
1525 mutex_unlock(&phydev->lock); in phy_loopback()
1531 * phy_reset_after_clk_enable - perform a PHY reset if needed
1541 if (!phydev || !phydev->drv) in phy_reset_after_clk_enable()
1542 return -ENODEV; in phy_reset_after_clk_enable()
1544 if (phydev->drv->flags & PHY_RST_AFTER_CLK_EN) { in phy_reset_after_clk_enable()
1557 * genphy_config_advert - sanitize and advertise auto-negotiation parameters
1571 linkmode_and(phydev->advertising, phydev->advertising, in genphy_config_advert()
1572 phydev->supported); in genphy_config_advert()
1574 adv = linkmode_adv_to_mii_adv_t(phydev->advertising); in genphy_config_advert()
1590 /* Per 802.3-2008, Section 22.2.4.2.16 Extended status all in genphy_config_advert()
1597 adv = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising); in genphy_config_advert()
1611 * genphy_config_eee_advert - disable unwanted eee mode advertisement
1623 if (!phydev->eee_broken_modes) in genphy_config_eee_advert()
1627 phydev->eee_broken_modes, 0); in genphy_config_eee_advert()
1634 * genphy_setup_forced - configures/forces speed/duplex from @phydev
1645 phydev->pause = 0; in genphy_setup_forced()
1646 phydev->asym_pause = 0; in genphy_setup_forced()
1648 if (SPEED_1000 == phydev->speed) in genphy_setup_forced()
1650 else if (SPEED_100 == phydev->speed) in genphy_setup_forced()
1653 if (DUPLEX_FULL == phydev->duplex) in genphy_setup_forced()
1662 * genphy_restart_aneg - Enable and Restart Autonegotiation
1674 * __genphy_config_aneg - restart auto-negotiation or write BMCR
1678 * Description: If auto-negotiation is enabled, we configure the
1679 * advertising, and then restart auto-negotiation. If it is not
1689 if (AUTONEG_ENABLE != phydev->autoneg) in __genphy_config_aneg()
1719 * genphy_aneg_done - return auto-negotiation status
1723 * auto-negotiation is incomplete, or if there was an error.
1724 * Returns BMSR_ANEGCOMPLETE if auto-negotiation is done.
1735 * genphy_update_link - update link status in @phydev
1738 * Description: Update the value in phydev->link to reflect the
1757 * drops can be detected. Do not double-read the status in genphy_update_link()
1773 phydev->link = status & BMSR_LSTATUS ? 1 : 0; in genphy_update_link()
1774 phydev->autoneg_complete = status & BMSR_ANEGCOMPLETE ? 1 : 0; in genphy_update_link()
1779 if (phydev->autoneg == AUTONEG_ENABLE && !phydev->autoneg_complete) in genphy_update_link()
1780 phydev->link = 0; in genphy_update_link()
1790 if (phydev->autoneg == AUTONEG_ENABLE) { in genphy_read_lpa()
1791 if (!phydev->autoneg_complete) { in genphy_read_lpa()
1792 mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, in genphy_read_lpa()
1794 mii_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, 0); in genphy_read_lpa()
1798 if (phydev->is_gigabit_capable) { in genphy_read_lpa()
1813 return -ENOLINK; in genphy_read_lpa()
1816 mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, in genphy_read_lpa()
1824 mii_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); in genphy_read_lpa()
1826 linkmode_zero(phydev->lp_advertising); in genphy_read_lpa()
1834 * genphy_read_status - check the link status and update current link state
1844 int err, old_link = phydev->link; in genphy_read_status()
1852 if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) in genphy_read_status()
1855 phydev->speed = SPEED_UNKNOWN; in genphy_read_status()
1856 phydev->duplex = DUPLEX_UNKNOWN; in genphy_read_status()
1857 phydev->pause = 0; in genphy_read_status()
1858 phydev->asym_pause = 0; in genphy_read_status()
1864 if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) { in genphy_read_status()
1866 } else if (phydev->autoneg == AUTONEG_DISABLE) { in genphy_read_status()
1873 phydev->duplex = DUPLEX_FULL; in genphy_read_status()
1875 phydev->duplex = DUPLEX_HALF; in genphy_read_status()
1878 phydev->speed = SPEED_1000; in genphy_read_status()
1880 phydev->speed = SPEED_100; in genphy_read_status()
1882 phydev->speed = SPEED_10; in genphy_read_status()
1890 * genphy_soft_reset - software reset the PHY via BMCR_RESET bit
1903 if (phydev->autoneg == AUTONEG_ENABLE) in genphy_soft_reset()
1915 if (phydev->autoneg == AUTONEG_DISABLE) in genphy_soft_reset()
1923 * genphy_read_abilities - read PHY abilities from Clause 22 registers
1927 * phydev->supported accordingly.
1937 phydev->supported); in genphy_read_abilities()
1943 linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported, in genphy_read_abilities()
1946 linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, phydev->supported, in genphy_read_abilities()
1948 linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, phydev->supported, in genphy_read_abilities()
1950 linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, phydev->supported, in genphy_read_abilities()
1952 linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT, phydev->supported, in genphy_read_abilities()
1961 phydev->supported, val & ESTATUS_1000_TFULL); in genphy_read_abilities()
1963 phydev->supported, val & ESTATUS_1000_THALF); in genphy_read_abilities()
1965 phydev->supported, val & ESTATUS_1000_XFULL); in genphy_read_abilities()
1978 return -EOPNOTSUPP; in genphy_read_mmd_unsupported()
1985 return -EOPNOTSUPP; in genphy_write_mmd_unsupported()
2009 * phy_remove_link_mode - Remove a supported link mode
2019 linkmode_clear_bit(link_mode, phydev->supported); in phy_remove_link_mode()
2033 * phy_advertise_supported - Advertise all supported modes
2037 * pause mode advertising.
2043 linkmode_copy(new, phydev->supported); in phy_advertise_supported()
2044 phy_copy_pause_bits(new, phydev->advertising); in phy_advertise_supported()
2045 linkmode_copy(phydev->advertising, new); in phy_advertise_supported()
2050 * phy_support_sym_pause - Enable support of symmetrical pause
2054 * Pause, but not asym pause.
2058 linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydev->supported); in phy_support_sym_pause()
2059 phy_copy_pause_bits(phydev->advertising, phydev->supported); in phy_support_sym_pause()
2064 * phy_support_asym_pause - Enable support of asym pause
2067 * Description: Called by the MAC to indicate is supports Asym Pause.
2071 phy_copy_pause_bits(phydev->advertising, phydev->supported); in phy_support_asym_pause()
2076 * phy_set_sym_pause - Configure symmetric Pause
2078 * @rx: Receiver Pause is supported
2079 * @tx: Transmit Pause is supported
2082 * Description: Configure advertised Pause support depending on if
2083 * receiver pause and pause auto neg is supported. Generally called
2089 linkmode_clear_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported); in phy_set_sym_pause()
2093 phydev->supported); in phy_set_sym_pause()
2095 linkmode_copy(phydev->advertising, phydev->supported); in phy_set_sym_pause()
2100 * phy_set_asym_pause - Configure Pause and Asym Pause
2102 * @rx: Receiver Pause is supported
2103 * @tx: Transmit Pause is supported
2105 * Description: Configure advertised Pause support depending on if
2106 * transmit and receiver pause is supported. If there has been a
2114 linkmode_copy(oldadv, phydev->advertising); in phy_set_asym_pause()
2117 phydev->advertising); in phy_set_asym_pause()
2119 phydev->advertising); in phy_set_asym_pause()
2123 phydev->advertising); in phy_set_asym_pause()
2125 phydev->advertising); in phy_set_asym_pause()
2130 phydev->advertising); in phy_set_asym_pause()
2132 if (!linkmode_equal(oldadv, phydev->advertising) && in phy_set_asym_pause()
2133 phydev->autoneg) in phy_set_asym_pause()
2139 * phy_validate_pause - Test if the PHY/MAC support the pause configuration
2141 * @pp: requested pause configuration
2143 * Description: Test if the PHY/MAC combination supports the Pause
2151 phydev->supported) && pp->rx_pause) in phy_validate_pause()
2155 phydev->supported) && in phy_validate_pause()
2156 pp->rx_pause != pp->tx_pause) in phy_validate_pause()
2165 return phydrv->config_intr && phydrv->ack_interrupt; in phy_drv_supports_irq()
2169 * phy_probe - probe and init a PHY device
2179 struct device_driver *drv = phydev->mdio.dev.driver; in phy_probe()
2183 phydev->drv = phydrv; in phy_probe()
2189 phydev->irq = PHY_POLL; in phy_probe()
2191 if (phydrv->flags & PHY_IS_INTERNAL) in phy_probe()
2192 phydev->is_internal = true; in phy_probe()
2194 mutex_lock(&phydev->lock); in phy_probe()
2196 if (phydev->drv->probe) { in phy_probe()
2200 err = phydev->drv->probe(phydev); in phy_probe()
2212 if (phydrv->features) { in phy_probe()
2213 linkmode_copy(phydev->supported, phydrv->features); in phy_probe()
2214 } else if (phydrv->get_features) { in phy_probe()
2215 err = phydrv->get_features(phydev); in phy_probe()
2216 } else if (phydev->is_c45) { in phy_probe()
2226 phydev->supported)) in phy_probe()
2227 phydev->autoneg = 0; in phy_probe()
2230 phydev->supported)) in phy_probe()
2231 phydev->is_gigabit_capable = 1; in phy_probe()
2233 phydev->supported)) in phy_probe()
2234 phydev->is_gigabit_capable = 1; in phy_probe()
2244 /* The Pause Frame bits indicate that the PHY can support passing in phy_probe()
2245 * pause frames. During autonegotiation, the PHYs will determine if in phy_probe()
2246 * they should allow pause frames to pass. The MAC driver should then in phy_probe()
2248 * pause frames. in phy_probe()
2250 * Normally, PHY drivers should not set the Pause bits, and instead in phy_probe()
2255 if (!test_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported) && in phy_probe()
2256 !test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydev->supported)) { in phy_probe()
2258 phydev->supported); in phy_probe()
2260 phydev->supported); in phy_probe()
2264 phydev->state = PHY_READY; in phy_probe()
2267 mutex_unlock(&phydev->lock); in phy_probe()
2276 cancel_delayed_work_sync(&phydev->state_queue); in phy_remove()
2278 mutex_lock(&phydev->lock); in phy_remove()
2279 phydev->state = PHY_DOWN; in phy_remove()
2280 mutex_unlock(&phydev->lock); in phy_remove()
2282 if (phydev->drv && phydev->drv->remove) { in phy_remove()
2283 phydev->drv->remove(phydev); in phy_remove()
2288 phydev->drv = NULL; in phy_remove()
2294 * phy_driver_register - register a phy_driver with the PHY layer
2305 if (WARN_ON(new_driver->features && new_driver->get_features)) { in phy_driver_register()
2307 new_driver->name); in phy_driver_register()
2308 return -EINVAL; in phy_driver_register()
2311 new_driver->mdiodrv.flags |= MDIO_DEVICE_IS_PHY; in phy_driver_register()
2312 new_driver->mdiodrv.driver.name = new_driver->name; in phy_driver_register()
2313 new_driver->mdiodrv.driver.bus = &mdio_bus_type; in phy_driver_register()
2314 new_driver->mdiodrv.driver.probe = phy_probe; in phy_driver_register()
2315 new_driver->mdiodrv.driver.remove = phy_remove; in phy_driver_register()
2316 new_driver->mdiodrv.driver.owner = owner; in phy_driver_register()
2318 retval = driver_register(&new_driver->mdiodrv.driver); in phy_driver_register()
2321 new_driver->name, retval); in phy_driver_register()
2326 pr_debug("%s: Registered new driver\n", new_driver->name); in phy_driver_register()
2340 while (i-- > 0) in phy_drivers_register()
2351 driver_unregister(&drv->mdiodrv.driver); in phy_driver_unregister()