Lines Matching +full:eee +full:- +full:broken +full:- +full:100 +full:tx
1 // SPDX-License-Identifier: GPL-2.0+
33 #include <linux/pse-pd/pse.h>
137 /* 10/100 half/full*/ in features_init()
145 /* 100 full, TP */ in features_init()
155 /* 10/100 half/full + 1000 half/full */ in features_init()
166 /* 10/100 half/full + 1000 half/full + fibre*/ in features_init()
178 /* 10/100 half/full + 1000 half/full + 10G full*/ in features_init()
203 put_device(&phydev->mdio.dev); in phy_device_free()
217 fwnode_handle_put(dev->fwnode); in phy_device_release()
245 struct net_device *netdev = phydev->attached_dev; in phy_link_change()
251 phydev->adjust_link(netdev); in phy_link_change()
252 if (phydev->mii_ts && phydev->mii_ts->link_state) in phy_link_change()
253 phydev->mii_ts->link_state(phydev->mii_ts, phydev); in phy_link_change()
257 * phy_uses_state_machine - test whether consumer driver uses PAL state machine
276 if (phydev->phy_link_change == phy_link_change) in phy_uses_state_machine()
277 return phydev->attached_dev && phydev->adjust_link; in phy_uses_state_machine()
279 /* phydev->phy_link_change is implicitly phylink_phy_change() */ in phy_uses_state_machine()
285 struct device_driver *drv = phydev->mdio.dev.driver; in mdio_bus_phy_may_suspend()
287 struct net_device *netdev = phydev->attached_dev; in mdio_bus_phy_may_suspend()
289 if (!drv || !phydrv->suspend) in mdio_bus_phy_may_suspend()
299 * suspended as part of a prior call to phy_disconnect() -> in mdio_bus_phy_may_suspend()
300 * phy_detach() -> phy_suspend() because the parent netdev might be the in mdio_bus_phy_may_suspend()
306 if (netdev->ethtool->wol_enabled) in mdio_bus_phy_may_suspend()
314 if (netdev->dev.parent && device_may_wakeup(netdev->dev.parent)) in mdio_bus_phy_may_suspend()
321 if (device_may_wakeup(&netdev->dev)) in mdio_bus_phy_may_suspend()
325 return !phydev->suspended; in mdio_bus_phy_may_suspend()
332 if (phydev->mac_managed_pm) in mdio_bus_phy_suspend()
340 phydev->irq_suspended = 1; in mdio_bus_phy_suspend()
341 synchronize_irq(phydev->irq); in mdio_bus_phy_suspend()
345 * control, possibly with the phydev->lock held. Upon resume, netdev in mdio_bus_phy_suspend()
355 phydev->suspended_by_mdio_bus = 1; in mdio_bus_phy_suspend()
365 if (phydev->mac_managed_pm) in mdio_bus_phy_resume()
368 if (!phydev->suspended_by_mdio_bus) in mdio_bus_phy_resume()
371 phydev->suspended_by_mdio_bus = 0; in mdio_bus_phy_resume()
378 WARN_ON(phydev->state != PHY_HALTED && phydev->state != PHY_READY && in mdio_bus_phy_resume()
379 phydev->state != PHY_UP); in mdio_bus_phy_resume()
390 phydev->irq_suspended = 0; in mdio_bus_phy_resume()
391 synchronize_irq(phydev->irq); in mdio_bus_phy_resume()
396 if (phydev->irq_rerun) { in mdio_bus_phy_resume()
397 phydev->irq_rerun = 0; in mdio_bus_phy_resume()
398 enable_irq(phydev->irq); in mdio_bus_phy_resume()
399 irq_wake_thread(phydev->irq, phydev); in mdio_bus_phy_resume()
413 * phy_register_fixup - creates a new phy_fixup and adds it to the list
414 * @bus_id: A string which matches phydev->mdio.dev.bus_id (or PHY_ANY_ID)
415 * @phy_uid: Used to match against phydev->phy_id (the UID of the PHY)
417 * @phy_uid_mask: Applied to phydev->phy_id and fixup->phy_uid before
427 return -ENOMEM; in phy_register_fixup()
429 strscpy(fixup->bus_id, bus_id, sizeof(fixup->bus_id)); in phy_register_fixup()
430 fixup->phy_uid = phy_uid; in phy_register_fixup()
431 fixup->phy_uid_mask = phy_uid_mask; in phy_register_fixup()
432 fixup->run = run; in phy_register_fixup()
435 list_add_tail(&fixup->list, &phy_fixup_list); in phy_register_fixup()
459 * phy_unregister_fixup - remove a phy_fixup from the list
460 * @bus_id: A string matches fixup->bus_id (or PHY_ANY_ID) in phy_fixup_list
461 * @phy_uid: A phy id matches fixup->phy_id (or PHY_ANY_UID) in phy_fixup_list
462 * @phy_uid_mask: Applied to phy_uid and fixup->phy_uid before comparison
470 ret = -ENODEV; in phy_unregister_fixup()
476 if ((!strcmp(fixup->bus_id, bus_id)) && in phy_unregister_fixup()
477 phy_id_compare(fixup->phy_uid, phy_uid, phy_uid_mask)) { in phy_unregister_fixup()
478 list_del(&fixup->list); in phy_unregister_fixup()
509 if (strcmp(fixup->bus_id, phydev_name(phydev)) != 0) in phy_needs_fixup()
510 if (strcmp(fixup->bus_id, PHY_ANY_ID) != 0) in phy_needs_fixup()
513 if (!phy_id_compare(phydev->phy_id, fixup->phy_uid, in phy_needs_fixup()
514 fixup->phy_uid_mask)) in phy_needs_fixup()
515 if (fixup->phy_uid != PHY_ANY_UID) in phy_needs_fixup()
529 int err = fixup->run(phydev); in phy_scan_fixups()
535 phydev->has_fixups = true; in phy_scan_fixups()
547 const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids); in phy_bus_match()
550 if (!(phydrv->mdiodrv.flags & MDIO_DEVICE_IS_PHY)) in phy_bus_match()
553 if (phydrv->match_phy_device) in phy_bus_match()
554 return phydrv->match_phy_device(phydev); in phy_bus_match()
556 if (phydev->is_c45) { in phy_bus_match()
558 if (phydev->c45_ids.device_ids[i] == 0xffffffff) in phy_bus_match()
561 if (phy_id_compare(phydev->c45_ids.device_ids[i], in phy_bus_match()
562 phydrv->phy_id, phydrv->phy_id_mask)) in phy_bus_match()
567 return phy_id_compare(phydev->phy_id, phydrv->phy_id, in phy_bus_match()
568 phydrv->phy_id_mask); in phy_bus_match()
577 return sysfs_emit(buf, "0x%.8lx\n", (unsigned long)phydev->phy_id); in phy_id_show()
590 mode = phy_modes(phydev->interface); in phy_interface_show()
602 return sysfs_emit(buf, "%d\n", phydev->has_fixups); in phy_has_fixups_show()
612 return sysfs_emit(buf, "0x%08x\n", phydev->dev_flags); in phy_dev_flags_show()
640 * Accept -ENOENT because this may occur in case no initramfs exists, in phy_request_driver_module()
643 if (IS_ENABLED(CONFIG_MODULES) && ret < 0 && ret != -ENOENT) { in phy_request_driver_module()
663 return ERR_PTR(-ENOMEM); in phy_device_create()
665 mdiodev = &dev->mdio; in phy_device_create()
666 mdiodev->dev.parent = &bus->dev; in phy_device_create()
667 mdiodev->dev.bus = &mdio_bus_type; in phy_device_create()
668 mdiodev->dev.type = &mdio_bus_phy_type; in phy_device_create()
669 mdiodev->bus = bus; in phy_device_create()
670 mdiodev->bus_match = phy_bus_match; in phy_device_create()
671 mdiodev->addr = addr; in phy_device_create()
672 mdiodev->flags = MDIO_DEVICE_FLAG_PHY; in phy_device_create()
673 mdiodev->device_free = phy_mdio_device_free; in phy_device_create()
674 mdiodev->device_remove = phy_mdio_device_remove; in phy_device_create()
675 mdiodev->reset_state = -1; in phy_device_create()
677 dev->speed = SPEED_UNKNOWN; in phy_device_create()
678 dev->duplex = DUPLEX_UNKNOWN; in phy_device_create()
679 dev->pause = 0; in phy_device_create()
680 dev->asym_pause = 0; in phy_device_create()
681 dev->link = 0; in phy_device_create()
682 dev->port = PORT_TP; in phy_device_create()
683 dev->interface = PHY_INTERFACE_MODE_GMII; in phy_device_create()
685 dev->autoneg = AUTONEG_ENABLE; in phy_device_create()
687 dev->pma_extable = -ENODATA; in phy_device_create()
688 dev->is_c45 = is_c45; in phy_device_create()
689 dev->phy_id = phy_id; in phy_device_create()
691 dev->c45_ids = *c45_ids; in phy_device_create()
692 dev->irq = bus->irq[addr]; in phy_device_create()
694 dev_set_name(&mdiodev->dev, PHY_ID_FMT, bus->id, addr); in phy_device_create()
695 device_initialize(&mdiodev->dev); in phy_device_create()
697 dev->state = PHY_DOWN; in phy_device_create()
698 INIT_LIST_HEAD(&dev->leds); in phy_device_create()
700 mutex_init(&dev->lock); in phy_device_create()
701 INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine); in phy_device_create()
708 * -- because it relies on the device staying around for long in phy_device_create()
714 const int num_ids = ARRAY_SIZE(c45_ids->device_ids); in phy_device_create()
718 if (c45_ids->device_ids[i] == 0xffffffff) in phy_device_create()
722 c45_ids->device_ids[i]); in phy_device_create()
731 put_device(&mdiodev->dev); in phy_device_create()
739 /* phy_c45_probe_present - checks to see if a MMD is present in the package
761 /* get_phy_c45_devs_in_pkg - reads a MMD's devices in package registers.
770 * Returns: 0 on success, -EIO on failure.
779 return -EIO; in get_phy_c45_devs_in_pkg()
784 return -EIO; in get_phy_c45_devs_in_pkg()
791 * get_phy_c45_ids - reads the specified addr for its 802.3-c45 IDs.
800 * Returns zero on success, %-EIO on bus access error, or %-ENODEV if
806 const int num_ids = ARRAY_SIZE(c45_ids->device_ids); in get_phy_c45_ids()
810 /* Find first non-zero Devices In package. Device zero is reserved in get_phy_c45_ids()
817 * address before reading the devices-in-package in get_phy_c45_ids()
824 /* returning -ENODEV doesn't stop bus in get_phy_c45_ids()
827 return (phy_reg == -EIO || in get_phy_c45_ids()
828 phy_reg == -ENODEV) ? -ENODEV : -EIO; in get_phy_c45_ids()
835 return -EIO; in get_phy_c45_ids()
845 return -EIO; in get_phy_c45_ids()
849 return -ENODEV; in get_phy_c45_ids()
872 return -EIO; in get_phy_c45_ids()
873 c45_ids->device_ids[i] = phy_reg << 16; in get_phy_c45_ids()
877 return -EIO; in get_phy_c45_ids()
878 c45_ids->device_ids[i] |= phy_reg; in get_phy_c45_ids()
881 c45_ids->devices_in_package = devs_in_pkg; in get_phy_c45_ids()
883 c45_ids->mmds_present = devs_in_pkg & ~BIT(0); in get_phy_c45_ids()
889 * get_phy_c22_id - reads the specified addr for its clause 22 ID.
896 * valid, %-EIO on bus access error, or %-ENODEV if no device responds
906 /* returning -ENODEV doesn't stop bus scanning */ in get_phy_c22_id()
907 return (phy_reg == -EIO || phy_reg == -ENODEV) ? -ENODEV : -EIO; in get_phy_c22_id()
915 /* returning -ENODEV doesn't stop bus scanning */ in get_phy_c22_id()
916 return (phy_reg == -EIO || phy_reg == -ENODEV) ? -ENODEV : -EIO; in get_phy_c22_id()
923 return -ENODEV; in get_phy_c22_id()
929 * ethernet-phy-idAAAA.BBBB.
941 if (sscanf(cp, "ethernet-phy-id%4x.%4x", &upper, &lower) != 2) in fwnode_get_phy_id()
942 return -EINVAL; in fwnode_get_phy_id()
950 * get_phy_device - reads the specified PHY device and returns its @phy_device
965 * Returns an allocated &struct phy_device on success, %-ENODEV if there is
966 * no PHY present, or %-EIO on bus access error.
991 if (!is_c45 && phy_id == 0 && bus->read_c45) { in get_phy_device()
1003 * phy_device_register - Register the phy device on the MDIO bus
1010 err = mdiobus_register_device(&phydev->mdio); in phy_device_register()
1024 err = device_add(&phydev->mdio.dev); in phy_device_register()
1036 mdiobus_unregister_device(&phydev->mdio); in phy_device_register()
1042 * phy_device_remove - Remove a previously registered phy device from the MDIO bus
1051 unregister_mii_timestamper(phydev->mii_ts); in phy_device_remove()
1052 pse_control_put(phydev->psec); in phy_device_remove()
1054 device_del(&phydev->mdio.dev); in phy_device_remove()
1059 mdiobus_unregister_device(&phydev->mdio); in phy_device_remove()
1064 * phy_get_c45_ids - Read 802.3-c45 IDs for phy device.
1065 * @phydev: phy_device structure to read 802.3-c45 IDs
1067 * Returns zero on success, %-EIO on bus access error, or %-ENODEV if
1072 return get_phy_c45_ids(phydev->mdio.bus, phydev->mdio.addr, in phy_get_c45_ids()
1073 &phydev->c45_ids); in phy_get_c45_ids()
1078 * phy_find_first - finds the first PHY device on the bus
1096 * phy_prepare_link - prepares the PHY layer to monitor link status
1110 phydev->adjust_link = handler; in phy_prepare_link()
1114 * phy_connect_direct - connect an ethernet device to a specific phy_device
1127 return -EINVAL; in phy_connect_direct()
1129 rc = phy_attach_direct(dev, phydev, phydev->dev_flags, interface); in phy_connect_direct()
1142 * phy_connect - connect an ethernet device to a PHY device
1170 return ERR_PTR(-ENODEV); in phy_connect()
1184 * phy_disconnect - disable interrupts, stop state machine, and detach a PHY
1196 phydev->adjust_link = NULL; in phy_disconnect()
1203 * phy_poll_reset - Safely wait until a PHY reset has properly completed
1215 * even *REQUIRE* a soft-reset to properly restart autonegotiation. In an
1216 * effort to support such broken PHYs, this function is separate from the
1218 * and reapply all driver-specific and board-specific fixups.
1243 if (!phydev->drv) in phy_init_hw()
1246 if (phydev->drv->soft_reset) { in phy_init_hw()
1247 ret = phydev->drv->soft_reset(phydev); in phy_init_hw()
1252 phydev->suspended = 0; in phy_init_hw()
1259 phy_interface_zero(phydev->possible_interfaces); in phy_init_hw()
1261 if (phydev->drv->config_init) { in phy_init_hw()
1262 ret = phydev->drv->config_init(phydev); in phy_init_hw()
1267 if (phydev->drv->config_intr) { in phy_init_hw()
1268 ret = phydev->drv->config_intr(phydev); in phy_init_hw()
1289 switch(phydev->irq) { in phy_attached_info_irq()
1297 snprintf(irq_num, sizeof(irq_num), "%d", phydev->irq); in phy_attached_info_irq()
1308 const char *unbound = phydev->drv ? "" : "[unbound] "; in phy_attached_print()
1330 struct net_device *dev = phydev->attached_dev; in phy_sysfs_create_links()
1336 err = sysfs_create_link(&phydev->mdio.dev.kobj, &dev->dev.kobj, in phy_sysfs_create_links()
1341 err = sysfs_create_link_nowarn(&dev->dev.kobj, in phy_sysfs_create_links()
1342 &phydev->mdio.dev.kobj, in phy_sysfs_create_links()
1345 dev_err(&dev->dev, "could not add device link to %s err %d\n", in phy_sysfs_create_links()
1346 kobject_name(&phydev->mdio.dev.kobj), in phy_sysfs_create_links()
1348 /* non-fatal - some net drivers can use one netdevice in phy_sysfs_create_links()
1353 phydev->sysfs_links = true; in phy_sysfs_create_links()
1362 return sysfs_emit(buf, "%d\n", !phydev->attached_dev); in phy_standalone_show()
1367 * phy_sfp_connect_phy - Connect the SFP module's PHY to the upstream PHY
1379 struct net_device *dev = phydev->attached_dev; in phy_sfp_connect_phy()
1389 * phy_sfp_disconnect_phy - Disconnect the SFP module's PHY from the upstream PHY
1395 * will be destroyed, re-inserting the same module will add a new phy with a
1401 struct net_device *dev = phydev->attached_dev; in phy_sfp_disconnect_phy()
1409 * phy_sfp_attach - attach the SFP bus to the PHY upstream network device
1419 if (phydev->attached_dev) in phy_sfp_attach()
1420 phydev->attached_dev->sfp_bus = bus; in phy_sfp_attach()
1421 phydev->sfp_bus_attached = true; in phy_sfp_attach()
1426 * phy_sfp_detach - detach the SFP bus from the PHY upstream network device
1436 if (phydev->attached_dev) in phy_sfp_detach()
1437 phydev->attached_dev->sfp_bus = NULL; in phy_sfp_detach()
1438 phydev->sfp_bus_attached = false; in phy_sfp_detach()
1443 * phy_sfp_probe - probe for a SFP cage attached to this PHY device
1453 if (phydev->mdio.dev.fwnode) { in phy_sfp_probe()
1454 bus = sfp_bus_find_fwnode(phydev->mdio.dev.fwnode); in phy_sfp_probe()
1458 phydev->sfp_bus = bus; in phy_sfp_probe()
1469 return phydrv->config_intr && phydrv->handle_interrupt; in phy_drv_supports_irq()
1473 * phy_attach_direct - attach a network device to a given PHY device pointer
1490 struct mii_bus *bus = phydev->mdio.bus; in phy_attach_direct()
1491 struct device *d = &phydev->mdio.dev; in phy_attach_direct()
1497 * will have bus->owner match ndev_mod, so we do not want to increment in phy_attach_direct()
1498 * our own module->refcnt here, otherwise we would not be able to in phy_attach_direct()
1502 ndev_owner = dev->dev.parent->driver->owner; in phy_attach_direct()
1503 if (ndev_owner != bus->owner && !try_module_get(bus->owner)) { in phy_attach_direct()
1505 return -EIO; in phy_attach_direct()
1513 if (!d->driver) { in phy_attach_direct()
1514 if (phydev->is_c45) in phy_attach_direct()
1515 d->driver = &genphy_c45_driver.mdiodrv.driver; in phy_attach_direct()
1517 d->driver = &genphy_driver.mdiodrv.driver; in phy_attach_direct()
1522 if (!try_module_get(d->driver->owner)) { in phy_attach_direct()
1524 err = -EIO; in phy_attach_direct()
1529 err = d->driver->probe(d); in phy_attach_direct()
1537 if (phydev->attached_dev) { in phy_attach_direct()
1538 dev_err(&dev->dev, "PHY already attached\n"); in phy_attach_direct()
1539 err = -EBUSY; in phy_attach_direct()
1543 phydev->phy_link_change = phy_link_change; in phy_attach_direct()
1545 phydev->attached_dev = dev; in phy_attach_direct()
1546 dev->phydev = phydev; in phy_attach_direct()
1548 if (phydev->sfp_bus_attached) in phy_attach_direct()
1549 dev->sfp_bus = phydev->sfp_bus; in phy_attach_direct()
1557 * calling register_netdevice() -> netdev_register_kobject() and in phy_attach_direct()
1558 * does the dev->dev.kobj initialization. Here we only check for in phy_attach_direct()
1564 phydev->sysfs_links = false; in phy_attach_direct()
1568 if (!phydev->attached_dev) { in phy_attach_direct()
1569 err = sysfs_create_file(&phydev->mdio.dev.kobj, in phy_attach_direct()
1575 phydev->dev_flags |= flags; in phy_attach_direct()
1577 phydev->interface = interface; in phy_attach_direct()
1579 phydev->state = PHY_READY; in phy_attach_direct()
1581 phydev->interrupts = PHY_INTERRUPT_DISABLED; in phy_attach_direct()
1585 * detect a broken interrupt handling. in phy_attach_direct()
1587 if (phydev->dev_flags & PHY_F_NO_IRQ) in phy_attach_direct()
1588 phydev->irq = PHY_POLL; in phy_attach_direct()
1590 if (!phy_drv_supports_irq(phydev->drv) && phy_interrupt_is_valid(phydev)) in phy_attach_direct()
1591 phydev->irq = PHY_POLL; in phy_attach_direct()
1599 phydev->port = PORT_MII; in phy_attach_direct()
1605 netif_carrier_off(phydev->attached_dev); in phy_attach_direct()
1616 if (!phydev->is_on_sfp_module) in phy_attach_direct()
1624 if (dev && phydev->mdio.bus->parent && dev->dev.parent != phydev->mdio.bus->parent) in phy_attach_direct()
1625 phydev->devlink = device_link_add(dev->dev.parent, &phydev->mdio.dev, in phy_attach_direct()
1636 module_put(d->driver->owner); in phy_attach_direct()
1637 d->driver = NULL; in phy_attach_direct()
1640 if (ndev_owner != bus->owner) in phy_attach_direct()
1641 module_put(bus->owner); in phy_attach_direct()
1647 * phy_attach - attach a network device to a particular PHY device
1663 return ERR_PTR(-EINVAL); in phy_attach()
1671 return ERR_PTR(-ENODEV); in phy_attach()
1675 rc = phy_attach_direct(dev, phydev, phydev->dev_flags, interface); in phy_attach()
1687 struct device *d = &phydev->mdio.dev; in phy_driver_is_genphy_kind()
1690 if (!phydev->drv) in phy_driver_is_genphy_kind()
1694 ret = d->driver == driver; in phy_driver_is_genphy_kind()
1715 * phy_package_join - join a common PHY group
1719 * @priv_size: if non-zero allocate this amount of bytes for private data
1736 * allocated. If priv_size is non-zero, the given amount of bytes are
1744 struct mii_bus *bus = phydev->mdio.bus; in phy_package_join()
1749 return -EINVAL; in phy_package_join()
1751 mutex_lock(&bus->shared_lock); in phy_package_join()
1752 shared = bus->shared[base_addr]; in phy_package_join()
1754 ret = -ENOMEM; in phy_package_join()
1759 shared->priv = kzalloc(priv_size, GFP_KERNEL); in phy_package_join()
1760 if (!shared->priv) in phy_package_join()
1762 shared->priv_size = priv_size; in phy_package_join()
1764 shared->base_addr = base_addr; in phy_package_join()
1765 shared->np = NULL; in phy_package_join()
1766 refcount_set(&shared->refcnt, 1); in phy_package_join()
1767 bus->shared[base_addr] = shared; in phy_package_join()
1769 ret = -EINVAL; in phy_package_join()
1770 if (priv_size && priv_size != shared->priv_size) in phy_package_join()
1772 refcount_inc(&shared->refcnt); in phy_package_join()
1774 mutex_unlock(&bus->shared_lock); in phy_package_join()
1776 phydev->shared = shared; in phy_package_join()
1783 mutex_unlock(&bus->shared_lock); in phy_package_join()
1789 * of_phy_package_join - join a common PHY group in PHY package
1791 * @priv_size: if non-zero allocate this amount of bytes for private data
1796 * structure (by matching the node name "ethernet-phy-package") and the
1810 struct device_node *node = phydev->mdio.dev.of_node; in of_phy_package_join()
1816 return -EINVAL; in of_phy_package_join()
1820 return -EINVAL; in of_phy_package_join()
1822 if (!of_node_name_eq(package_node, "ethernet-phy-package")) { in of_phy_package_join()
1823 ret = -EINVAL; in of_phy_package_join()
1828 ret = -EINVAL; in of_phy_package_join()
1836 phydev->shared->np = package_node; in of_phy_package_join()
1846 * phy_package_leave - leave a common PHY group
1851 * freed. Resets the phydev->shared pointer to NULL.
1855 struct phy_package_shared *shared = phydev->shared; in phy_package_leave()
1856 struct mii_bus *bus = phydev->mdio.bus; in phy_package_leave()
1862 if (shared->np) in phy_package_leave()
1863 of_node_put(shared->np); in phy_package_leave()
1865 if (refcount_dec_and_mutex_lock(&shared->refcnt, &bus->shared_lock)) { in phy_package_leave()
1866 bus->shared[shared->base_addr] = NULL; in phy_package_leave()
1867 mutex_unlock(&bus->shared_lock); in phy_package_leave()
1868 kfree(shared->priv); in phy_package_leave()
1872 phydev->shared = NULL; in phy_package_leave()
1882 * devm_phy_package_join - resource managed phy_package_join()
1887 * @priv_size: if non-zero allocate this amount of bytes for private data
1902 return -ENOMEM; in devm_phy_package_join()
1918 * devm_of_phy_package_join - resource managed of_phy_package_join()
1921 * @priv_size: if non-zero allocate this amount of bytes for private data
1936 return -ENOMEM; in devm_of_phy_package_join()
1952 * phy_detach - detach a PHY device from its network device
1960 struct net_device *dev = phydev->attached_dev; in phy_detach()
1964 if (phydev->devlink) in phy_detach()
1965 device_link_del(phydev->devlink); in phy_detach()
1967 if (phydev->sysfs_links) { in phy_detach()
1969 sysfs_remove_link(&dev->dev.kobj, "phydev"); in phy_detach()
1970 sysfs_remove_link(&phydev->mdio.dev.kobj, "attached_dev"); in phy_detach()
1973 if (!phydev->attached_dev) in phy_detach()
1974 sysfs_remove_file(&phydev->mdio.dev.kobj, in phy_detach()
1981 hwprov = rtnl_dereference(dev->hwprov); in phy_detach()
1983 if (hwprov && hwprov->phydev == phydev) { in phy_detach()
1984 rcu_assign_pointer(dev->hwprov, NULL); in phy_detach()
1988 phydev->attached_dev->phydev = NULL; in phy_detach()
1989 phydev->attached_dev = NULL; in phy_detach()
1992 phydev->phylink = NULL; in phy_detach()
1994 if (!phydev->is_on_sfp_module) in phy_detach()
1997 if (phydev->mdio.dev.driver) in phy_detach()
1998 module_put(phydev->mdio.dev.driver->owner); in phy_detach()
2000 /* If the device had no specific driver before (i.e. - it in phy_detach()
2007 device_release_driver(&phydev->mdio.dev); in phy_detach()
2014 * a use-after-free bug by reading the underlying bus first. in phy_detach()
2016 bus = phydev->mdio.bus; in phy_detach()
2018 put_device(&phydev->mdio.dev); in phy_detach()
2020 ndev_owner = dev->dev.parent->driver->owner; in phy_detach()
2021 if (ndev_owner != bus->owner) in phy_detach()
2022 module_put(bus->owner); in phy_detach()
2028 struct net_device *netdev = phydev->attached_dev; in phy_suspend()
2029 const struct phy_driver *phydrv = phydev->drv; in phy_suspend()
2032 if (phydev->suspended || !phydrv) in phy_suspend()
2035 phydev->wol_enabled = phy_drv_wol_enabled(phydev) || in phy_suspend()
2036 (netdev && netdev->ethtool->wol_enabled); in phy_suspend()
2038 if (phydev->wol_enabled && !(phydrv->flags & PHY_ALWAYS_CALL_SUSPEND)) in phy_suspend()
2039 return -EBUSY; in phy_suspend()
2041 if (!phydrv->suspend) in phy_suspend()
2044 ret = phydrv->suspend(phydev); in phy_suspend()
2046 phydev->suspended = true; in phy_suspend()
2054 const struct phy_driver *phydrv = phydev->drv; in __phy_resume()
2057 lockdep_assert_held(&phydev->lock); in __phy_resume()
2059 if (!phydrv || !phydrv->resume) in __phy_resume()
2062 ret = phydrv->resume(phydev); in __phy_resume()
2064 phydev->suspended = false; in __phy_resume()
2074 mutex_lock(&phydev->lock); in phy_resume()
2076 mutex_unlock(&phydev->lock); in phy_resume()
2086 if (!phydev->drv) in phy_loopback()
2087 return -EIO; in phy_loopback()
2089 mutex_lock(&phydev->lock); in phy_loopback()
2091 if (enable && phydev->loopback_enabled) { in phy_loopback()
2092 ret = -EBUSY; in phy_loopback()
2096 if (!enable && !phydev->loopback_enabled) { in phy_loopback()
2097 ret = -EINVAL; in phy_loopback()
2101 if (phydev->drv->set_loopback) in phy_loopback()
2102 ret = phydev->drv->set_loopback(phydev, enable); in phy_loopback()
2109 phydev->loopback_enabled = enable; in phy_loopback()
2112 mutex_unlock(&phydev->lock); in phy_loopback()
2118 * phy_reset_after_clk_enable - perform a PHY reset if needed
2128 if (!phydev || !phydev->drv) in phy_reset_after_clk_enable()
2129 return -ENODEV; in phy_reset_after_clk_enable()
2131 if (phydev->drv->flags & PHY_RST_AFTER_CLK_EN) { in phy_reset_after_clk_enable()
2144 * genphy_config_advert - sanitize and advertise auto-negotiation parameters
2146 * @advert: auto-negotiation parameters to advertise
2175 /* Per 802.3-2008, Section 22.2.4.2.16 Extended status all in genphy_config_advert()
2196 * genphy_c37_config_advert - sanitize and advertise auto-negotiation parameters
2203 * for Clause 37 1000Base-X mode.
2210 linkmode_and(phydev->advertising, phydev->advertising, in genphy_c37_config_advert()
2211 phydev->supported); in genphy_c37_config_advert()
2214 phydev->advertising)) in genphy_c37_config_advert()
2217 phydev->advertising)) in genphy_c37_config_advert()
2220 phydev->advertising)) in genphy_c37_config_advert()
2230 * genphy_setup_forced - configures/forces speed/duplex from @phydev
2241 phydev->pause = 0; in genphy_setup_forced()
2242 phydev->asym_pause = 0; in genphy_setup_forced()
2244 ctl = mii_bmcr_encode_fixed(phydev->speed, phydev->duplex); in genphy_setup_forced()
2255 if (!phydev->is_gigabit_capable) in genphy_setup_master_slave()
2258 switch (phydev->master_slave_set) { in genphy_setup_master_slave()
2275 return -EOPNOTSUPP; in genphy_setup_master_slave()
2288 phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN; in genphy_read_master_slave()
2289 phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; in genphy_read_master_slave()
2313 } else if (phydev->link) { in genphy_read_master_slave()
2323 phydev->master_slave_get = cfg; in genphy_read_master_slave()
2324 phydev->master_slave_state = state; in genphy_read_master_slave()
2331 * genphy_restart_aneg - Enable and Restart Autonegotiation
2343 * genphy_check_and_restart_aneg - Enable and restart auto-negotiation
2347 * Check, and restart auto-negotiation if needed.
2373 * __genphy_config_aneg - restart auto-negotiation or write BMCR
2377 * Description: If auto-negotiation is enabled, we configure the
2378 * advertising, and then restart auto-negotiation. If it is not
2400 if (phydev->autoneg == AUTONEG_ENABLE) { in __genphy_config_aneg()
2402 linkmode_and(phydev->advertising, phydev->advertising, in __genphy_config_aneg()
2403 phydev->supported); in __genphy_config_aneg()
2404 advert = phydev->advertising; in __genphy_config_aneg()
2405 } else if (phydev->speed < SPEED_1000) { in __genphy_config_aneg()
2410 set = phy_lookup_setting(phydev->speed, phydev->duplex, in __genphy_config_aneg()
2411 phydev->supported, true); in __genphy_config_aneg()
2413 linkmode_set_bit(set->bit, fixed_advert); in __genphy_config_aneg()
2429 * genphy_c37_config_aneg - restart auto-negotiation or write BMCR
2432 * Description: If auto-negotiation is enabled, we configure the
2433 * advertising, and then restart auto-negotiation. If it is not
2435 * for use with Clause 37 1000Base-X mode.
2441 if (phydev->autoneg != AUTONEG_ENABLE) in genphy_c37_config_aneg()
2477 * genphy_aneg_done - return auto-negotiation status
2481 * auto-negotiation is incomplete, or if there was an error.
2482 * Returns BMSR_ANEGCOMPLETE if auto-negotiation is done.
2493 * genphy_update_link - update link status in @phydev
2496 * Description: Update the value in phydev->link to reflect the
2515 * drops can be detected. Do not double-read the status in genphy_update_link()
2519 if (!phy_polling_mode(phydev) || !phydev->link) { in genphy_update_link()
2532 phydev->link = status & BMSR_LSTATUS ? 1 : 0; in genphy_update_link()
2533 phydev->autoneg_complete = status & BMSR_ANEGCOMPLETE ? 1 : 0; in genphy_update_link()
2538 if (phydev->autoneg == AUTONEG_ENABLE && !phydev->autoneg_complete) in genphy_update_link()
2539 phydev->link = 0; in genphy_update_link()
2549 if (phydev->autoneg == AUTONEG_ENABLE) { in genphy_read_lpa()
2550 if (!phydev->autoneg_complete) { in genphy_read_lpa()
2551 mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, in genphy_read_lpa()
2553 mii_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, 0); in genphy_read_lpa()
2557 if (phydev->is_gigabit_capable) { in genphy_read_lpa()
2572 return -ENOLINK; in genphy_read_lpa()
2575 mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, in genphy_read_lpa()
2583 mii_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); in genphy_read_lpa()
2585 linkmode_zero(phydev->lp_advertising); in genphy_read_lpa()
2593 * genphy_read_status_fixed - read the link parameters for !aneg mode
2607 phydev->duplex = DUPLEX_FULL; in genphy_read_status_fixed()
2609 phydev->duplex = DUPLEX_HALF; in genphy_read_status_fixed()
2612 phydev->speed = SPEED_1000; in genphy_read_status_fixed()
2614 phydev->speed = SPEED_100; in genphy_read_status_fixed()
2616 phydev->speed = SPEED_10; in genphy_read_status_fixed()
2623 * genphy_read_status - check the link status and update current link state
2629 * then move on to 10/100.
2633 int err, old_link = phydev->link; in genphy_read_status()
2641 if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) in genphy_read_status()
2644 phydev->master_slave_get = MASTER_SLAVE_CFG_UNSUPPORTED; in genphy_read_status()
2645 phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED; in genphy_read_status()
2646 phydev->speed = SPEED_UNKNOWN; in genphy_read_status()
2647 phydev->duplex = DUPLEX_UNKNOWN; in genphy_read_status()
2648 phydev->pause = 0; in genphy_read_status()
2649 phydev->asym_pause = 0; in genphy_read_status()
2651 if (phydev->is_gigabit_capable) { in genphy_read_status()
2661 if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) { in genphy_read_status()
2663 } else if (phydev->autoneg == AUTONEG_DISABLE) { in genphy_read_status()
2674 * genphy_c37_read_status - check the link status and update current link state
2680 * advertises. This function is for Clause 37 1000Base-X mode.
2686 int lpa, err, old_link = phydev->link; in genphy_c37_read_status()
2694 if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) { in genphy_c37_read_status()
2701 phydev->duplex = DUPLEX_UNKNOWN; in genphy_c37_read_status()
2702 phydev->pause = 0; in genphy_c37_read_status()
2703 phydev->asym_pause = 0; in genphy_c37_read_status()
2705 if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) { in genphy_c37_read_status()
2711 phydev->lp_advertising, lpa & LPA_LPACK); in genphy_c37_read_status()
2713 phydev->lp_advertising, lpa & LPA_1000XFULL); in genphy_c37_read_status()
2715 phydev->lp_advertising, lpa & LPA_1000XPAUSE); in genphy_c37_read_status()
2717 phydev->lp_advertising, in genphy_c37_read_status()
2721 } else if (phydev->autoneg == AUTONEG_DISABLE) { in genphy_c37_read_status()
2728 phydev->duplex = DUPLEX_FULL; in genphy_c37_read_status()
2730 phydev->duplex = DUPLEX_HALF; in genphy_c37_read_status()
2738 * genphy_soft_reset - software reset the PHY via BMCR_RESET bit
2751 if (phydev->autoneg == AUTONEG_ENABLE) in genphy_soft_reset()
2762 phydev->suspended = 0; in genphy_soft_reset()
2769 if (phydev->autoneg == AUTONEG_DISABLE) in genphy_soft_reset()
2790 * genphy_read_abilities - read PHY abilities from Clause 22 registers
2794 * phydev->supported accordingly.
2804 phydev->supported); in genphy_read_abilities()
2810 linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported, in genphy_read_abilities()
2813 linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, phydev->supported, in genphy_read_abilities()
2815 linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, phydev->supported, in genphy_read_abilities()
2817 linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, phydev->supported, in genphy_read_abilities()
2819 linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT, phydev->supported, in genphy_read_abilities()
2828 phydev->supported, val & ESTATUS_1000_TFULL); in genphy_read_abilities()
2830 phydev->supported, val & ESTATUS_1000_THALF); in genphy_read_abilities()
2832 phydev->supported, val & ESTATUS_1000_XFULL); in genphy_read_abilities()
2850 return -EOPNOTSUPP; in genphy_read_mmd_unsupported()
2857 return -EOPNOTSUPP; in genphy_write_mmd_unsupported()
2879 ctl |= mii_bmcr_encode_fixed(phydev->speed, phydev->duplex); in genphy_loopback()
2899 * phy_remove_link_mode - Remove a supported link mode
2909 linkmode_clear_bit(link_mode, phydev->supported); in phy_remove_link_mode()
2923 * phy_advertise_supported - Advertise all supported modes
2933 linkmode_copy(new, phydev->supported); in phy_advertise_supported()
2934 phy_copy_pause_bits(new, phydev->advertising); in phy_advertise_supported()
2935 linkmode_copy(phydev->advertising, new); in phy_advertise_supported()
2940 * phy_advertise_eee_all - Advertise all supported EEE modes
2943 * Description: Per default phylib preserves the EEE advertising at the time of
2944 * phy probing, which might be a subset of the supported EEE modes. Use this
2945 * function when all supported EEE modes should be advertised. This does not
2946 * trigger auto-negotiation, so must be called before phy_start()/
2947 * phylink_start() which will start auto-negotiation.
2951 linkmode_copy(phydev->advertising_eee, phydev->supported_eee); in phy_advertise_eee_all()
2956 * phy_support_eee - Set initial EEE policy configuration
2960 * (EEE) on the specified PHY device, influencing that EEE capabilities are
2966 * The function sets default EEE policy parameters, including preparing the PHY
2967 * to advertise EEE capabilities based on hardware support.
2971 * advertisements support EEE, and the negotiated link mode is compatible with
2972 * EEE, it will set enable_tx_lpi = true. The MAC driver is expected to act on
2977 linkmode_copy(phydev->advertising_eee, phydev->supported_eee); in phy_support_eee()
2978 phydev->eee_cfg.tx_lpi_enabled = true; in phy_support_eee()
2979 phydev->eee_cfg.eee_enabled = true; in phy_support_eee()
2984 * phy_disable_eee - Disable EEE for the PHY
2987 * This function is used by MAC drivers for MAC's which don't support EEE.
2988 * It disables EEE on the PHY layer.
2992 linkmode_zero(phydev->advertising_eee); in phy_disable_eee()
2993 phydev->eee_cfg.tx_lpi_enabled = false; in phy_disable_eee()
2994 phydev->eee_cfg.eee_enabled = false; in phy_disable_eee()
2995 /* don't let userspace re-enable EEE advertisement */ in phy_disable_eee()
2996 linkmode_fill(phydev->eee_broken_modes); in phy_disable_eee()
3001 * phy_support_sym_pause - Enable support of symmetrical pause
3009 linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydev->supported); in phy_support_sym_pause()
3010 phy_copy_pause_bits(phydev->advertising, phydev->supported); in phy_support_sym_pause()
3015 * phy_support_asym_pause - Enable support of asym pause
3022 phy_copy_pause_bits(phydev->advertising, phydev->supported); in phy_support_asym_pause()
3027 * phy_set_sym_pause - Configure symmetric Pause
3030 * @tx: Transmit Pause is supported
3037 void phy_set_sym_pause(struct phy_device *phydev, bool rx, bool tx, in phy_set_sym_pause() argument
3040 linkmode_clear_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported); in phy_set_sym_pause()
3042 if (rx && tx && autoneg) in phy_set_sym_pause()
3044 phydev->supported); in phy_set_sym_pause()
3046 linkmode_copy(phydev->advertising, phydev->supported); in phy_set_sym_pause()
3051 * phy_set_asym_pause - Configure Pause and Asym Pause
3054 * @tx: Transmit Pause is supported
3061 void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx) in phy_set_asym_pause() argument
3065 linkmode_copy(oldadv, phydev->advertising); in phy_set_asym_pause()
3066 linkmode_set_pause(phydev->advertising, tx, rx); in phy_set_asym_pause()
3068 if (!linkmode_equal(oldadv, phydev->advertising) && in phy_set_asym_pause()
3069 phydev->autoneg) in phy_set_asym_pause()
3075 * phy_validate_pause - Test if the PHY/MAC support the pause configuration
3087 phydev->supported) && pp->rx_pause) in phy_validate_pause()
3091 phydev->supported) && in phy_validate_pause()
3092 pp->rx_pause != pp->tx_pause) in phy_validate_pause()
3100 * phy_get_pause - resolve negotiated pause modes
3113 if (phydev->duplex != DUPLEX_FULL) { in phy_get_pause()
3119 return linkmode_resolve_pause(phydev->advertising, in phy_get_pause()
3120 phydev->lp_advertising, in phy_get_pause()
3140 return -EINVAL; in phy_get_int_delay_property()
3145 * phy_get_internal_delay - returns the index of the internal delay
3158 * Return -EINVAL if the delay is invalid or cannot be found.
3167 delay = phy_get_int_delay_property(dev, "rx-internal-delay-ps"); in phy_get_internal_delay()
3169 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in phy_get_internal_delay()
3170 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in phy_get_internal_delay()
3177 delay = phy_get_int_delay_property(dev, "tx-internal-delay-ps"); in phy_get_internal_delay()
3179 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in phy_get_internal_delay()
3180 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in phy_get_internal_delay()
3193 if (delay < delay_values[0] || delay > delay_values[size - 1]) { in phy_get_internal_delay()
3195 return -EINVAL; in phy_get_internal_delay()
3206 if (delay > delay_values[i - 1] && in phy_get_internal_delay()
3208 if (delay - delay_values[i - 1] < in phy_get_internal_delay()
3209 delay_values[i] - delay) in phy_get_internal_delay()
3210 return i - 1; in phy_get_internal_delay()
3219 return -EINVAL; in phy_get_internal_delay()
3227 struct phy_device *phydev = phyled->phydev; in phy_led_set_brightness()
3230 mutex_lock(&phydev->lock); in phy_led_set_brightness()
3231 err = phydev->drv->led_brightness_set(phydev, phyled->index, value); in phy_led_set_brightness()
3232 mutex_unlock(&phydev->lock); in phy_led_set_brightness()
3242 struct phy_device *phydev = phyled->phydev; in phy_led_blink_set()
3245 mutex_lock(&phydev->lock); in phy_led_blink_set()
3246 err = phydev->drv->led_blink_set(phydev, phyled->index, in phy_led_blink_set()
3248 mutex_unlock(&phydev->lock); in phy_led_blink_set()
3257 struct phy_device *phydev = phyled->phydev; in phy_led_hw_control_get_device()
3259 if (phydev->attached_dev) in phy_led_hw_control_get_device()
3260 return &phydev->attached_dev->dev; in phy_led_hw_control_get_device()
3269 struct phy_device *phydev = phyled->phydev; in phy_led_hw_control_get()
3272 mutex_lock(&phydev->lock); in phy_led_hw_control_get()
3273 err = phydev->drv->led_hw_control_get(phydev, phyled->index, rules); in phy_led_hw_control_get()
3274 mutex_unlock(&phydev->lock); in phy_led_hw_control_get()
3284 struct phy_device *phydev = phyled->phydev; in phy_led_hw_control_set()
3287 mutex_lock(&phydev->lock); in phy_led_hw_control_set()
3288 err = phydev->drv->led_hw_control_set(phydev, phyled->index, rules); in phy_led_hw_control_set()
3289 mutex_unlock(&phydev->lock); in phy_led_hw_control_set()
3298 struct phy_device *phydev = phyled->phydev; in phy_led_hw_is_supported()
3301 mutex_lock(&phydev->lock); in phy_led_hw_is_supported()
3302 err = phydev->drv->led_hw_is_supported(phydev, phyled->index, rules); in phy_led_hw_is_supported()
3303 mutex_unlock(&phydev->lock); in phy_led_hw_is_supported()
3312 list_for_each_entry_safe(phyled, tmp, &phydev->leds, list) { in phy_leds_unregister()
3313 led_classdev_unregister(&phyled->led_cdev); in phy_leds_unregister()
3314 list_del(&phyled->list); in phy_leds_unregister()
3321 struct device *dev = &phydev->mdio.dev; in of_phy_led()
3331 return -ENOMEM; in of_phy_led()
3333 cdev = &phyled->led_cdev; in of_phy_led()
3334 phyled->phydev = phydev; in of_phy_led()
3340 return -EINVAL; in of_phy_led()
3342 if (of_property_read_bool(led, "active-high")) in of_phy_led()
3344 if (of_property_read_bool(led, "active-low")) in of_phy_led()
3346 if (of_property_read_bool(led, "inactive-high-impedance")) in of_phy_led()
3351 return -EINVAL; in of_phy_led()
3355 if (!phydev->drv->led_polarity_set) in of_phy_led()
3356 return -EINVAL; in of_phy_led()
3358 err = phydev->drv->led_polarity_set(phydev, index, modes); in of_phy_led()
3363 phyled->index = index; in of_phy_led()
3364 if (phydev->drv->led_brightness_set) in of_phy_led()
3365 cdev->brightness_set_blocking = phy_led_set_brightness; in of_phy_led()
3366 if (phydev->drv->led_blink_set) in of_phy_led()
3367 cdev->blink_set = phy_led_blink_set; in of_phy_led()
3370 if (phydev->drv->led_hw_is_supported && in of_phy_led()
3371 phydev->drv->led_hw_control_set && in of_phy_led()
3372 phydev->drv->led_hw_control_get) { in of_phy_led()
3373 cdev->hw_control_is_supported = phy_led_hw_is_supported; in of_phy_led()
3374 cdev->hw_control_set = phy_led_hw_control_set; in of_phy_led()
3375 cdev->hw_control_get = phy_led_hw_control_get; in of_phy_led()
3376 cdev->hw_control_trigger = "netdev"; in of_phy_led()
3379 cdev->hw_control_get_device = phy_led_hw_control_get_device; in of_phy_led()
3381 cdev->max_brightness = 1; in of_phy_led()
3382 init_data.devicename = dev_name(&phydev->mdio.dev); in of_phy_led()
3390 list_add(&phyled->list, &phydev->leds); in of_phy_led()
3397 struct device_node *node = phydev->mdio.dev.of_node; in of_phy_leds()
3414 if (!(phydev->drv->led_brightness_set || in of_phy_leds()
3415 phydev->drv->led_blink_set || in of_phy_leds()
3416 phydev->drv->led_hw_control_set)) { in of_phy_leds()
3436 * fwnode_mdio_find_device - Given a fwnode, find the mdio_device
3459 * fwnode_phy_find_device - For provided phy_fwnode, find phy_device.
3474 if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) in fwnode_phy_find_device()
3475 return to_phy_device(&mdiodev->dev); in fwnode_phy_find_device()
3477 put_device(&mdiodev->dev); in fwnode_phy_find_device()
3484 * device_phy_find_device - For the given device, get the phy_device
3496 * fwnode_get_phy_node - Get the phy_node using the named reference.
3500 * For ACPI, only "phy-handle" is supported. Legacy DT properties "phy"
3501 * and "phy-device" are not supported in ACPI. DT supports all the three
3508 /* Only phy-handle is used for ACPI */ in fwnode_get_phy_node()
3509 phy_node = fwnode_find_reference(fwnode, "phy-handle", 0); in fwnode_get_phy_node()
3514 phy_node = fwnode_find_reference(fwnode, "phy-device", 0); in fwnode_get_phy_node()
3520 * phy_probe - probe and init a PHY device
3528 struct device_driver *drv = phydev->mdio.dev.driver; in phy_probe()
3532 phydev->drv = phydrv; in phy_probe()
3538 phydev->irq = PHY_POLL; in phy_probe()
3540 if (phydrv->flags & PHY_IS_INTERNAL) in phy_probe()
3541 phydev->is_internal = true; in phy_probe()
3546 if (phydev->drv->probe) { in phy_probe()
3547 err = phydev->drv->probe(phydev); in phy_probe()
3558 if (phydrv->features) { in phy_probe()
3559 linkmode_copy(phydev->supported, phydrv->features); in phy_probe()
3562 else if (phydrv->get_features) in phy_probe()
3563 err = phydrv->get_features(phydev); in phy_probe()
3564 else if (phydev->is_c45) in phy_probe()
3573 phydev->supported)) in phy_probe()
3574 phydev->autoneg = 0; in phy_probe()
3577 phydev->supported)) in phy_probe()
3578 phydev->is_gigabit_capable = 1; in phy_probe()
3580 phydev->supported)) in phy_probe()
3581 phydev->is_gigabit_capable = 1; in phy_probe()
3586 /* Get PHY default EEE advertising modes and handle them as potentially in phy_probe()
3589 err = genphy_c45_read_eee_adv(phydev, phydev->advertising_eee); in phy_probe()
3596 phydev->eee_cfg.eee_enabled = !linkmode_empty(phydev->advertising_eee); in phy_probe()
3598 /* Some PHYs may advertise, by default, not support EEE modes. So, in phy_probe()
3601 if (phydev->eee_cfg.eee_enabled) in phy_probe()
3602 linkmode_and(phydev->advertising_eee, phydev->supported_eee, in phy_probe()
3603 phydev->advertising_eee); in phy_probe()
3605 /* Get the EEE modes we want to prohibit. We will ask in phy_probe()
3624 if (!test_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported) && in phy_probe()
3625 !test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydev->supported)) { in phy_probe()
3627 phydev->supported); in phy_probe()
3629 phydev->supported); in phy_probe()
3633 phydev->state = PHY_READY; in phy_probe()
3642 /* Re-assert the reset signal on error */ in phy_probe()
3653 cancel_delayed_work_sync(&phydev->state_queue); in phy_remove()
3658 phydev->state = PHY_DOWN; in phy_remove()
3660 sfp_bus_del_upstream(phydev->sfp_bus); in phy_remove()
3661 phydev->sfp_bus = NULL; in phy_remove()
3663 if (phydev->drv && phydev->drv->remove) in phy_remove()
3664 phydev->drv->remove(phydev); in phy_remove()
3669 phydev->drv = NULL; in phy_remove()
3675 * phy_driver_register - register a phy_driver with the PHY layer
3686 if (WARN_ON(new_driver->features && new_driver->get_features)) { in phy_driver_register()
3688 new_driver->name); in phy_driver_register()
3689 return -EINVAL; in phy_driver_register()
3695 * make out-of-bounds accesses and lockup in phydev->lock. in phy_driver_register()
3697 if (WARN(new_driver->mdiodrv.driver.of_match_table, in phy_driver_register()
3699 new_driver->name)) in phy_driver_register()
3700 return -EINVAL; in phy_driver_register()
3702 new_driver->mdiodrv.flags |= MDIO_DEVICE_IS_PHY; in phy_driver_register()
3703 new_driver->mdiodrv.driver.name = new_driver->name; in phy_driver_register()
3704 new_driver->mdiodrv.driver.bus = &mdio_bus_type; in phy_driver_register()
3705 new_driver->mdiodrv.driver.probe = phy_probe; in phy_driver_register()
3706 new_driver->mdiodrv.driver.remove = phy_remove; in phy_driver_register()
3707 new_driver->mdiodrv.driver.owner = owner; in phy_driver_register()
3708 new_driver->mdiodrv.driver.probe_type = PROBE_FORCE_SYNCHRONOUS; in phy_driver_register()
3710 retval = driver_register(&new_driver->mdiodrv.driver); in phy_driver_register()
3713 new_driver->name, retval); in phy_driver_register()
3718 pr_debug("%s: Registered new driver\n", new_driver->name); in phy_driver_register()
3732 while (i-- > 0) in phy_drivers_register()
3743 driver_unregister(&drv->mdiodrv.driver); in phy_driver_unregister()