Lines Matching full:phydev
201 void phy_device_free(struct phy_device *phydev) in phy_device_free() argument
203 put_device(&phydev->mdio.dev); in phy_device_free()
209 struct phy_device *phydev; in phy_mdio_device_free() local
211 phydev = container_of(mdiodev, struct phy_device, mdio); in phy_mdio_device_free()
212 phy_device_free(phydev); in phy_mdio_device_free()
223 struct phy_device *phydev; in phy_mdio_device_remove() local
225 phydev = container_of(mdiodev, struct phy_device, mdio); in phy_mdio_device_remove()
226 phy_device_remove(phydev); in phy_mdio_device_remove()
234 static bool phy_drv_wol_enabled(struct phy_device *phydev) in phy_drv_wol_enabled() argument
238 phy_ethtool_get_wol(phydev, &wol); in phy_drv_wol_enabled()
243 static void phy_link_change(struct phy_device *phydev, bool up) in phy_link_change() argument
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()
258 * @phydev: the target PHY device structure
274 static bool phy_uses_state_machine(struct phy_device *phydev) in phy_uses_state_machine() argument
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()
283 static bool mdio_bus_phy_may_suspend(struct phy_device *phydev) in mdio_bus_phy_may_suspend() argument
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()
295 if (!netdev && phy_drv_wol_enabled(phydev)) in mdio_bus_phy_may_suspend()
325 return !phydev->suspended; in mdio_bus_phy_may_suspend()
330 struct phy_device *phydev = to_phy_device(dev); in mdio_bus_phy_suspend() local
332 if (phydev->mac_managed_pm) in mdio_bus_phy_suspend()
339 if (phy_interrupt_is_valid(phydev)) { 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()
349 if (phy_uses_state_machine(phydev)) in mdio_bus_phy_suspend()
350 phy_stop_machine(phydev); in mdio_bus_phy_suspend()
352 if (!mdio_bus_phy_may_suspend(phydev)) in mdio_bus_phy_suspend()
355 phydev->suspended_by_mdio_bus = 1; in mdio_bus_phy_suspend()
357 return phy_suspend(phydev); in mdio_bus_phy_suspend()
362 struct phy_device *phydev = to_phy_device(dev); in mdio_bus_phy_resume() local
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()
381 ret = phy_init_hw(phydev); in mdio_bus_phy_resume()
385 ret = phy_resume(phydev); in mdio_bus_phy_resume()
389 if (phy_interrupt_is_valid(phydev)) { 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()
403 if (phy_uses_state_machine(phydev)) in mdio_bus_phy_resume()
404 phy_start_machine(phydev); in mdio_bus_phy_resume()
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
504 /* Returns 1 if fixup matches phydev in bus_id and phy_uid.
507 static int phy_needs_fixup(struct phy_device *phydev, struct phy_fixup *fixup) in phy_needs_fixup() argument
509 if (strcmp(fixup->bus_id, phydev_name(phydev)) != 0) in phy_needs_fixup()
513 if (!phy_id_compare(phydev->phy_id, fixup->phy_uid, in phy_needs_fixup()
521 /* Runs any matching fixups for this phydev */
522 static int phy_scan_fixups(struct phy_device *phydev) in phy_scan_fixups() argument
528 if (phy_needs_fixup(phydev, fixup)) { in phy_scan_fixups()
529 int err = fixup->run(phydev); in phy_scan_fixups()
535 phydev->has_fixups = true; in phy_scan_fixups()
545 struct phy_device *phydev = to_phy_device(dev); in phy_bus_match() local
547 const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids); 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()
567 return phy_id_compare(phydev->phy_id, phydrv->phy_id, in phy_bus_match()
575 struct phy_device *phydev = to_phy_device(dev); in phy_id_show() local
577 return sysfs_emit(buf, "0x%.8lx\n", (unsigned long)phydev->phy_id); in phy_id_show()
584 struct phy_device *phydev = to_phy_device(dev); in phy_interface_show() local
587 if (phy_is_internal(phydev)) in phy_interface_show()
590 mode = phy_modes(phydev->interface); in phy_interface_show()
600 struct phy_device *phydev = to_phy_device(dev); in phy_has_fixups_show() local
602 return sysfs_emit(buf, "%d\n", phydev->has_fixups); in phy_has_fixups_show()
610 struct phy_device *phydev = to_phy_device(dev); in phy_dev_flags_show() local
612 return sysfs_emit(buf, "0x%08x\n", phydev->dev_flags); in phy_dev_flags_show()
1004 * @phydev: phy_device structure to be added to the MDIO bus
1006 int phy_device_register(struct phy_device *phydev) in phy_device_register() argument
1010 err = mdiobus_register_device(&phydev->mdio); in phy_device_register()
1015 phy_device_reset(phydev, 0); in phy_device_register()
1018 err = phy_scan_fixups(phydev); in phy_device_register()
1020 phydev_err(phydev, "failed to initialize\n"); in phy_device_register()
1024 err = device_add(&phydev->mdio.dev); in phy_device_register()
1026 phydev_err(phydev, "failed to add\n"); in phy_device_register()
1034 phy_device_reset(phydev, 1); in phy_device_register()
1036 mdiobus_unregister_device(&phydev->mdio); in phy_device_register()
1043 * @phydev: phy_device structure to remove
1049 void phy_device_remove(struct phy_device *phydev) in phy_device_remove() argument
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()
1057 phy_device_reset(phydev, 1); in phy_device_remove()
1059 mdiobus_unregister_device(&phydev->mdio); in phy_device_remove()
1065 * @phydev: phy_device structure to read 802.3-c45 IDs
1070 int phy_get_c45_ids(struct phy_device *phydev) in phy_get_c45_ids() argument
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()
1083 struct phy_device *phydev; in phy_find_first() local
1087 phydev = mdiobus_get_phy(bus, addr); in phy_find_first()
1088 if (phydev) in phy_find_first()
1089 return phydev; in phy_find_first()
1097 * @phydev: target phy_device struct
1107 static void phy_prepare_link(struct phy_device *phydev, in phy_prepare_link() argument
1110 phydev->adjust_link = handler; in phy_prepare_link()
1116 * @phydev: the pointer to the phy device
1120 int phy_connect_direct(struct net_device *dev, struct phy_device *phydev, in phy_connect_direct() argument
1129 rc = phy_attach_direct(dev, phydev, phydev->dev_flags, interface); in phy_connect_direct()
1133 phy_prepare_link(phydev, handler); in phy_connect_direct()
1134 if (phy_interrupt_is_valid(phydev)) in phy_connect_direct()
1135 phy_request_interrupt(phydev); in phy_connect_direct()
1160 struct phy_device *phydev; in phy_connect() local
1172 phydev = to_phy_device(d); in phy_connect()
1174 rc = phy_connect_direct(dev, phydev, handler, interface); in phy_connect()
1179 return phydev; in phy_connect()
1186 * @phydev: target phy_device struct
1188 void phy_disconnect(struct phy_device *phydev) in phy_disconnect() argument
1190 if (phy_is_started(phydev)) in phy_disconnect()
1191 phy_stop(phydev); in phy_disconnect()
1193 if (phy_interrupt_is_valid(phydev)) in phy_disconnect()
1194 phy_free_interrupt(phydev); in phy_disconnect()
1196 phydev->adjust_link = NULL; in phy_disconnect()
1198 phy_detach(phydev); in phy_disconnect()
1204 * @phydev: The PHY device to poll
1220 static int phy_poll_reset(struct phy_device *phydev) in phy_poll_reset() argument
1225 ret = phy_read_poll_timeout(phydev, MII_BMCR, val, !(val & BMCR_RESET), in phy_poll_reset()
1236 int phy_init_hw(struct phy_device *phydev) in phy_init_hw() argument
1241 phy_device_reset(phydev, 0); in phy_init_hw()
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()
1255 ret = phy_scan_fixups(phydev); 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()
1277 void phy_attached_info(struct phy_device *phydev) in phy_attached_info() argument
1279 phy_attached_print(phydev, NULL); in phy_attached_info()
1284 char *phy_attached_info_irq(struct phy_device *phydev) in phy_attached_info_irq() argument
1289 switch(phydev->irq) { in phy_attached_info_irq()
1297 snprintf(irq_num, sizeof(irq_num), "%d", phydev->irq); in phy_attached_info_irq()
1306 void phy_attached_print(struct phy_device *phydev, const char *fmt, ...) in phy_attached_print() argument
1308 const char *unbound = phydev->drv ? "" : "[unbound] "; in phy_attached_print()
1309 char *irq_str = phy_attached_info_irq(phydev); in phy_attached_print()
1312 phydev_info(phydev, ATTACHED_FMT "\n", unbound, in phy_attached_print()
1313 phydev_name(phydev), irq_str); in phy_attached_print()
1317 phydev_info(phydev, ATTACHED_FMT, unbound, in phy_attached_print()
1318 phydev_name(phydev), irq_str); in phy_attached_print()
1328 static void phy_sysfs_create_links(struct phy_device *phydev) in phy_sysfs_create_links() argument
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()
1342 &phydev->mdio.dev.kobj, in phy_sysfs_create_links()
1343 "phydev"); in phy_sysfs_create_links()
1346 kobject_name(&phydev->mdio.dev.kobj), in phy_sysfs_create_links()
1353 phydev->sysfs_links = true; in phy_sysfs_create_links()
1360 struct phy_device *phydev = to_phy_device(dev); in phy_standalone_show() local
1362 return sysfs_emit(buf, "%d\n", !phydev->attached_dev); in phy_standalone_show()
1378 struct phy_device *phydev = upstream; in phy_sfp_connect_phy() local
1379 struct net_device *dev = phydev->attached_dev; in phy_sfp_connect_phy()
1382 return phy_link_topo_add_phy(dev, phy, PHY_UPSTREAM_PHY, phydev); in phy_sfp_connect_phy()
1400 struct phy_device *phydev = upstream; in phy_sfp_disconnect_phy() local
1401 struct net_device *dev = phydev->attached_dev; in phy_sfp_disconnect_phy()
1417 struct phy_device *phydev = upstream; in phy_sfp_attach() local
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()
1434 struct phy_device *phydev = upstream; in phy_sfp_detach() local
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()
1444 * @phydev: Pointer to phy_device
1447 int phy_sfp_probe(struct phy_device *phydev, in phy_sfp_probe() argument
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()
1460 ret = sfp_bus_add_upstream(bus, phydev, ops); in phy_sfp_probe()
1475 * @phydev: Pointer to phy_device to attach
1487 int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, in phy_attach_direct() argument
1490 struct mii_bus *bus = phydev->mdio.bus; in phy_attach_direct()
1491 struct device *d = &phydev->mdio.dev; in phy_attach_direct()
1504 phydev_err(phydev, "failed to get the bus module\n"); in phy_attach_direct()
1514 if (phydev->is_c45) in phy_attach_direct()
1523 phydev_err(phydev, "failed to get the device driver module\n"); in phy_attach_direct()
1537 if (phydev->attached_dev) { 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()
1551 err = phy_link_topo_add_phy(dev, phydev, PHY_UPSTREAM_MAC, dev); in phy_attach_direct()
1564 phydev->sysfs_links = false; in phy_attach_direct()
1566 phy_sysfs_create_links(phydev); 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()
1572 phydev_err(phydev, "error creating 'phy_standalone' sysfs entry\n"); 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()
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()
1611 err = phy_init_hw(phydev); in phy_attach_direct()
1615 phy_resume(phydev); in phy_attach_direct()
1616 if (!phydev->is_on_sfp_module) in phy_attach_direct()
1617 phy_led_triggers_register(phydev); 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()
1632 phy_detach(phydev); in phy_attach_direct()
1658 struct phy_device *phydev; in phy_attach() local
1673 phydev = to_phy_device(d); in phy_attach()
1675 rc = phy_attach_direct(dev, phydev, phydev->dev_flags, interface); in phy_attach()
1680 return phydev; in phy_attach()
1684 static bool phy_driver_is_genphy_kind(struct phy_device *phydev, in phy_driver_is_genphy_kind() argument
1687 struct device *d = &phydev->mdio.dev; in phy_driver_is_genphy_kind()
1690 if (!phydev->drv) in phy_driver_is_genphy_kind()
1700 bool phy_driver_is_genphy(struct phy_device *phydev) in phy_driver_is_genphy() argument
1702 return phy_driver_is_genphy_kind(phydev, in phy_driver_is_genphy()
1707 bool phy_driver_is_genphy_10g(struct phy_device *phydev) in phy_driver_is_genphy_10g() argument
1709 return phy_driver_is_genphy_kind(phydev, in phy_driver_is_genphy_10g()
1716 * @phydev: target phy_device struct
1734 * This will set the shared pointer of the phydev to the shared storage.
1742 int phy_package_join(struct phy_device *phydev, int base_addr, size_t priv_size) in phy_package_join() argument
1744 struct mii_bus *bus = phydev->mdio.bus; in phy_package_join()
1776 phydev->shared = shared; in phy_package_join()
1790 * @phydev: target phy_device struct
1795 * The parent node of the @phydev is checked as a valid PHY package node
1808 int of_phy_package_join(struct phy_device *phydev, size_t priv_size) in of_phy_package_join() argument
1810 struct device_node *node = phydev->mdio.dev.of_node; in of_phy_package_join()
1832 ret = phy_package_join(phydev, base_addr, priv_size); in of_phy_package_join()
1836 phydev->shared->np = package_node; in of_phy_package_join()
1847 * @phydev: target phy_device struct
1849 * This leaves a PHY group created by phy_package_join(). If this phydev
1851 * freed. Resets the phydev->shared pointer to NULL.
1853 void phy_package_leave(struct phy_device *phydev) in phy_package_leave() argument
1855 struct phy_package_shared *shared = phydev->shared; in phy_package_leave()
1856 struct mii_bus *bus = phydev->mdio.bus; in phy_package_leave()
1872 phydev->shared = NULL; in phy_package_leave()
1884 * @phydev: target phy_device struct
1893 int devm_phy_package_join(struct device *dev, struct phy_device *phydev, in devm_phy_package_join() argument
1904 ret = phy_package_join(phydev, base_addr, priv_size); in devm_phy_package_join()
1907 *ptr = phydev; in devm_phy_package_join()
1920 * @phydev: target phy_device struct
1927 int devm_of_phy_package_join(struct device *dev, struct phy_device *phydev, in devm_of_phy_package_join() argument
1938 ret = of_phy_package_join(phydev, priv_size); in devm_of_phy_package_join()
1941 *ptr = phydev; in devm_of_phy_package_join()
1953 * @phydev: target phy_device struct
1958 void phy_detach(struct phy_device *phydev) in phy_detach() argument
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()
1977 phy_suspend(phydev); in phy_detach()
1983 if (hwprov && hwprov->phydev == phydev) { in phy_detach()
1988 phydev->attached_dev->phydev = NULL; in phy_detach()
1989 phydev->attached_dev = NULL; in phy_detach()
1990 phy_link_topo_del_phy(dev, phydev); in phy_detach()
1992 phydev->phylink = NULL; in phy_detach()
1994 if (!phydev->is_on_sfp_module) in phy_detach()
1995 phy_led_triggers_unregister(phydev); in phy_detach()
1997 if (phydev->mdio.dev.driver) in phy_detach()
1998 module_put(phydev->mdio.dev.driver->owner); in phy_detach()
2005 if (phy_driver_is_genphy(phydev) || in phy_detach()
2006 phy_driver_is_genphy_10g(phydev)) in phy_detach()
2007 device_release_driver(&phydev->mdio.dev); in phy_detach()
2010 phy_device_reset(phydev, 1); in phy_detach()
2013 * The phydev might go away on the put_device() below, so avoid in phy_detach()
2016 bus = phydev->mdio.bus; in phy_detach()
2018 put_device(&phydev->mdio.dev); in phy_detach()
2026 int phy_suspend(struct phy_device *phydev) in phy_suspend() argument
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()
2038 if (phydev->wol_enabled && !(phydrv->flags & PHY_ALWAYS_CALL_SUSPEND)) in phy_suspend()
2044 ret = phydrv->suspend(phydev); in phy_suspend()
2046 phydev->suspended = true; in phy_suspend()
2052 int __phy_resume(struct phy_device *phydev) in __phy_resume() argument
2054 const struct phy_driver *phydrv = phydev->drv; in __phy_resume()
2057 lockdep_assert_held(&phydev->lock); in __phy_resume()
2062 ret = phydrv->resume(phydev); in __phy_resume()
2064 phydev->suspended = false; in __phy_resume()
2070 int phy_resume(struct phy_device *phydev) in phy_resume() argument
2074 mutex_lock(&phydev->lock); in phy_resume()
2075 ret = __phy_resume(phydev); in phy_resume()
2076 mutex_unlock(&phydev->lock); in phy_resume()
2082 int phy_loopback(struct phy_device *phydev, bool enable) in phy_loopback() argument
2086 if (!phydev->drv) in phy_loopback()
2089 mutex_lock(&phydev->lock); in phy_loopback()
2091 if (enable && phydev->loopback_enabled) { in phy_loopback()
2096 if (!enable && !phydev->loopback_enabled) { in phy_loopback()
2101 if (phydev->drv->set_loopback) in phy_loopback()
2102 ret = phydev->drv->set_loopback(phydev, enable); in phy_loopback()
2104 ret = genphy_loopback(phydev, enable); in phy_loopback()
2109 phydev->loopback_enabled = enable; in phy_loopback()
2112 mutex_unlock(&phydev->lock); in phy_loopback()
2119 * @phydev: target phy_device struct
2126 int phy_reset_after_clk_enable(struct phy_device *phydev) in phy_reset_after_clk_enable() argument
2128 if (!phydev || !phydev->drv) in phy_reset_after_clk_enable()
2131 if (phydev->drv->flags & PHY_RST_AFTER_CLK_EN) { in phy_reset_after_clk_enable()
2132 phy_device_reset(phydev, 1); in phy_reset_after_clk_enable()
2133 phy_device_reset(phydev, 0); in phy_reset_after_clk_enable()
2145 * @phydev: target phy_device struct
2153 static int genphy_config_advert(struct phy_device *phydev, in genphy_config_advert() argument
2162 err = phy_modify_changed(phydev, MII_ADVERTISE, in genphy_config_advert()
2171 bmsr = phy_read(phydev, MII_BMSR); in genphy_config_advert()
2184 err = phy_modify_changed(phydev, MII_CTRL1000, in genphy_config_advert()
2197 * @phydev: target phy_device struct
2205 static int genphy_c37_config_advert(struct phy_device *phydev) in genphy_c37_config_advert() argument
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()
2223 return phy_modify_changed(phydev, MII_ADVERTISE, in genphy_c37_config_advert()
2230 * genphy_setup_forced - configures/forces speed/duplex from @phydev
2231 * @phydev: target phy_device struct
2234 * to the values in phydev. Assumes that the values are valid.
2237 int genphy_setup_forced(struct phy_device *phydev) in genphy_setup_forced() argument
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()
2246 return phy_modify(phydev, MII_BMCR, in genphy_setup_forced()
2251 static int genphy_setup_master_slave(struct phy_device *phydev) in genphy_setup_master_slave() argument
2255 if (!phydev->is_gigabit_capable) in genphy_setup_master_slave()
2258 switch (phydev->master_slave_set) { in genphy_setup_master_slave()
2274 phydev_warn(phydev, "Unsupported Master/Slave mode\n"); in genphy_setup_master_slave()
2278 return phy_modify_changed(phydev, MII_CTRL1000, in genphy_setup_master_slave()
2283 int genphy_read_master_slave(struct phy_device *phydev) in genphy_read_master_slave() argument
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()
2291 val = phy_read(phydev, MII_CTRL1000); in genphy_read_master_slave()
2307 val = phy_read(phydev, MII_STAT1000); 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()
2332 * @phydev: target phy_device struct
2334 int genphy_restart_aneg(struct phy_device *phydev) in genphy_restart_aneg() argument
2337 return phy_modify(phydev, MII_BMCR, BMCR_ISOLATE, in genphy_restart_aneg()
2344 * @phydev: target phy_device struct
2349 int genphy_check_and_restart_aneg(struct phy_device *phydev, bool restart) in genphy_check_and_restart_aneg() argument
2357 ret = phy_read(phydev, MII_BMCR); in genphy_check_and_restart_aneg()
2366 return genphy_restart_aneg(phydev); in genphy_check_and_restart_aneg()
2374 * @phydev: target phy_device struct
2381 int __genphy_config_aneg(struct phy_device *phydev, bool changed) in __genphy_config_aneg() argument
2388 err = genphy_c45_an_config_eee_aneg(phydev); in __genphy_config_aneg()
2394 err = genphy_setup_master_slave(phydev); in __genphy_config_aneg()
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()
2406 return genphy_setup_forced(phydev); 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()
2418 err = genphy_config_advert(phydev, advert); in __genphy_config_aneg()
2424 return genphy_check_and_restart_aneg(phydev, changed); in __genphy_config_aneg()
2430 * @phydev: target phy_device struct
2437 int genphy_c37_config_aneg(struct phy_device *phydev) in genphy_c37_config_aneg() argument
2441 if (phydev->autoneg != AUTONEG_ENABLE) in genphy_c37_config_aneg()
2442 return genphy_setup_forced(phydev); in genphy_c37_config_aneg()
2444 err = phy_modify(phydev, MII_BMCR, BMCR_SPEED1000 | BMCR_SPEED100, in genphy_c37_config_aneg()
2449 changed = genphy_c37_config_advert(phydev); in genphy_c37_config_aneg()
2457 int ctl = phy_read(phydev, MII_BMCR); in genphy_c37_config_aneg()
2470 return genphy_restart_aneg(phydev); in genphy_c37_config_aneg()
2478 * @phydev: target phy_device struct
2484 int genphy_aneg_done(struct phy_device *phydev) in genphy_aneg_done() argument
2486 int retval = phy_read(phydev, MII_BMSR); in genphy_aneg_done()
2493 * genphy_update_link - update link status in @phydev
2494 * @phydev: target phy_device struct
2496 * Description: Update the value in phydev->link to reflect the
2500 int genphy_update_link(struct phy_device *phydev) in genphy_update_link() argument
2504 bmcr = phy_read(phydev, MII_BMCR); in genphy_update_link()
2519 if (!phy_polling_mode(phydev) || !phydev->link) { in genphy_update_link()
2520 status = phy_read(phydev, MII_BMSR); in genphy_update_link()
2528 status = phy_read(phydev, MII_BMSR); 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()
2545 int genphy_read_lpa(struct phy_device *phydev) in genphy_read_lpa() argument
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()
2558 lpagb = phy_read(phydev, MII_STAT1000); in genphy_read_lpa()
2563 int adv = phy_read(phydev, MII_CTRL1000); in genphy_read_lpa()
2569 phydev_err(phydev, "Master/Slave resolution failed, maybe conflicting manual settings?\n"); in genphy_read_lpa()
2571 phydev_err(phydev, "Master/Slave resolution failed\n"); in genphy_read_lpa()
2575 mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, in genphy_read_lpa()
2579 lpa = phy_read(phydev, MII_LPA); 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()
2594 * @phydev: target phy_device struct
2599 int genphy_read_status_fixed(struct phy_device *phydev) in genphy_read_status_fixed() argument
2601 int bmcr = phy_read(phydev, MII_BMCR); in genphy_read_status_fixed()
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()
2624 * @phydev: target phy_device struct
2631 int genphy_read_status(struct phy_device *phydev) in genphy_read_status() argument
2633 int err, old_link = phydev->link; in genphy_read_status()
2636 err = genphy_update_link(phydev); 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()
2652 err = genphy_read_master_slave(phydev); in genphy_read_status()
2657 err = genphy_read_lpa(phydev); in genphy_read_status()
2661 if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) { in genphy_read_status()
2662 phy_resolve_aneg_linkmode(phydev); in genphy_read_status()
2663 } else if (phydev->autoneg == AUTONEG_DISABLE) { in genphy_read_status()
2664 err = genphy_read_status_fixed(phydev); in genphy_read_status()
2675 * @phydev: target phy_device struct
2684 int genphy_c37_read_status(struct phy_device *phydev, bool *changed) in genphy_c37_read_status() argument
2686 int lpa, err, old_link = phydev->link; in genphy_c37_read_status()
2689 err = genphy_update_link(phydev); 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()
2706 lpa = phy_read(phydev, MII_LPA); 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()
2720 phy_resolve_aneg_linkmode(phydev); in genphy_c37_read_status()
2721 } else if (phydev->autoneg == AUTONEG_DISABLE) { in genphy_c37_read_status()
2722 int bmcr = phy_read(phydev, MII_BMCR); 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()
2739 * @phydev: target phy_device struct
2746 int genphy_soft_reset(struct phy_device *phydev) in genphy_soft_reset() argument
2751 if (phydev->autoneg == AUTONEG_ENABLE) in genphy_soft_reset()
2754 ret = phy_modify(phydev, MII_BMCR, BMCR_ISOLATE, res); in genphy_soft_reset()
2762 phydev->suspended = 0; in genphy_soft_reset()
2764 ret = phy_poll_reset(phydev); in genphy_soft_reset()
2769 if (phydev->autoneg == AUTONEG_DISABLE) in genphy_soft_reset()
2770 ret = genphy_setup_forced(phydev); in genphy_soft_reset()
2776 irqreturn_t genphy_handle_interrupt_no_ack(struct phy_device *phydev) in genphy_handle_interrupt_no_ack() argument
2783 phy_trigger_machine(phydev); in genphy_handle_interrupt_no_ack()
2791 * @phydev: target phy_device struct
2794 * phydev->supported accordingly.
2798 int genphy_read_abilities(struct phy_device *phydev) in genphy_read_abilities() argument
2804 phydev->supported); in genphy_read_abilities()
2806 val = phy_read(phydev, MII_BMSR); 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()
2823 val = phy_read(phydev, MII_ESTATUS); 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()
2838 genphy_c45_read_eee_abilities(phydev); in genphy_read_abilities()
2861 int genphy_suspend(struct phy_device *phydev) in genphy_suspend() argument
2863 return phy_set_bits(phydev, MII_BMCR, BMCR_PDOWN); in genphy_suspend()
2867 int genphy_resume(struct phy_device *phydev) in genphy_resume() argument
2869 return phy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN); in genphy_resume()
2873 int genphy_loopback(struct phy_device *phydev, bool enable) in genphy_loopback() argument
2879 ctl |= mii_bmcr_encode_fixed(phydev->speed, phydev->duplex); in genphy_loopback()
2881 phy_modify(phydev, MII_BMCR, ~0, ctl); in genphy_loopback()
2883 ret = phy_read_poll_timeout(phydev, MII_BMSR, val, in genphy_loopback()
2889 phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK, 0); in genphy_loopback()
2891 phy_config_aneg(phydev); in genphy_loopback()
2900 * @phydev: phy_device structure to remove link mode from
2907 void phy_remove_link_mode(struct phy_device *phydev, u32 link_mode) in phy_remove_link_mode() argument
2909 linkmode_clear_bit(link_mode, phydev->supported); in phy_remove_link_mode()
2910 phy_advertise_supported(phydev); in phy_remove_link_mode()
2924 * @phydev: target phy_device struct
2929 void phy_advertise_supported(struct phy_device *phydev) in phy_advertise_supported() argument
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()
2941 * @phydev: target phy_device struct
2949 void phy_advertise_eee_all(struct phy_device *phydev) in phy_advertise_eee_all() argument
2951 linkmode_copy(phydev->advertising_eee, phydev->supported_eee); in phy_advertise_eee_all()
2957 * @phydev: Target phy_device struct
2975 void phy_support_eee(struct phy_device *phydev) in phy_support_eee() argument
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()
2985 * @phydev: Target phy_device struct
2990 void phy_disable_eee(struct phy_device *phydev) in phy_disable_eee() argument
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()
2996 linkmode_fill(phydev->eee_broken_modes); in phy_disable_eee()
3002 * @phydev: target phy_device struct
3007 void phy_support_sym_pause(struct phy_device *phydev) in phy_support_sym_pause() argument
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()
3016 * @phydev: target phy_device struct
3020 void phy_support_asym_pause(struct phy_device *phydev) in phy_support_asym_pause() argument
3022 phy_copy_pause_bits(phydev->advertising, phydev->supported); in phy_support_asym_pause()
3028 * @phydev: target phy_device struct
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()
3044 phydev->supported); in phy_set_sym_pause()
3046 linkmode_copy(phydev->advertising, phydev->supported); in phy_set_sym_pause()
3052 * @phydev: target phy_device struct
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()
3070 phy_start_aneg(phydev); in phy_set_asym_pause()
3076 * @phydev: phy_device struct
3083 bool phy_validate_pause(struct phy_device *phydev, in phy_validate_pause() argument
3087 phydev->supported) && pp->rx_pause) in phy_validate_pause()
3091 phydev->supported) && in phy_validate_pause()
3101 * @phydev: phy_device struct
3111 void phy_get_pause(struct phy_device *phydev, bool *tx_pause, bool *rx_pause) in phy_get_pause() argument
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()
3146 * @phydev: phy_device struct
3160 s32 phy_get_internal_delay(struct phy_device *phydev, struct device *dev, in phy_get_internal_delay() argument
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()
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()
3194 phydev_err(phydev, "Delay %d is out of range\n", delay); in phy_get_internal_delay()
3216 phydev_err(phydev, "error finding internal delay index for %d\n", in phy_get_internal_delay()
3227 struct phy_device *phydev = phyled->phydev; in phy_led_set_brightness() local
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() local
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() local
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() local
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() local
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() local
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()
3308 static void phy_leds_unregister(struct phy_device *phydev) in phy_leds_unregister() argument
3312 list_for_each_entry_safe(phyled, tmp, &phydev->leds, list) { in phy_leds_unregister()
3318 static int of_phy_led(struct phy_device *phydev, in of_phy_led() argument
3321 struct device *dev = &phydev->mdio.dev; in of_phy_led()
3334 phyled->phydev = phydev; in of_phy_led()
3355 if (!phydev->drv->led_polarity_set) in of_phy_led()
3358 err = phydev->drv->led_polarity_set(phydev, index, modes); in of_phy_led()
3364 if (phydev->drv->led_brightness_set) in of_phy_led()
3366 if (phydev->drv->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()
3382 init_data.devicename = dev_name(&phydev->mdio.dev); in of_phy_led()
3390 list_add(&phyled->list, &phydev->leds); in of_phy_led()
3395 static int of_phy_leds(struct phy_device *phydev) in of_phy_leds() argument
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()
3417 phydev_dbg(phydev, "ignoring leds node defined with no PHY driver support\n"); in of_phy_leds()
3422 err = of_phy_led(phydev, led); in of_phy_leds()
3425 phy_leds_unregister(phydev); in of_phy_leds()
3527 struct phy_device *phydev = to_phy_device(dev); in phy_probe() local
3528 struct device_driver *drv = phydev->mdio.dev.driver; in phy_probe()
3532 phydev->drv = phydrv; in phy_probe()
3537 if (!phy_drv_supports_irq(phydrv) && phy_interrupt_is_valid(phydev)) in phy_probe()
3538 phydev->irq = PHY_POLL; in phy_probe()
3541 phydev->is_internal = true; in phy_probe()
3544 phy_device_reset(phydev, 0); in phy_probe()
3546 if (phydev->drv->probe) { in phy_probe()
3547 err = phydev->drv->probe(phydev); in phy_probe()
3552 phy_disable_interrupts(phydev); in phy_probe()
3559 linkmode_copy(phydev->supported, phydrv->features); in phy_probe()
3560 genphy_c45_read_eee_abilities(phydev); in phy_probe()
3563 err = phydrv->get_features(phydev); in phy_probe()
3564 else if (phydev->is_c45) in phy_probe()
3565 err = genphy_c45_pma_read_abilities(phydev); in phy_probe()
3567 err = genphy_read_abilities(phydev); 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()
3583 of_set_phy_supported(phydev); in phy_probe()
3584 phy_advertise_supported(phydev); 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()
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()
3608 of_set_phy_eee_broken(phydev); in phy_probe()
3611 of_set_phy_timing_role(phydev); 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()
3639 err = of_phy_leds(phydev); in phy_probe()
3644 phy_device_reset(phydev, 1); in phy_probe()
3651 struct phy_device *phydev = to_phy_device(dev); in phy_remove() local
3653 cancel_delayed_work_sync(&phydev->state_queue); in phy_remove()
3656 phy_leds_unregister(phydev); 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()
3667 phy_device_reset(phydev, 1); in phy_remove()
3669 phydev->drv = NULL; in phy_remove()
3695 * make out-of-bounds accesses and lockup in phydev->lock. in phy_driver_register()