Lines Matching +full:phy +full:- +full:device
1 // SPDX-License-Identifier: GPL-2.0+
3 * Also contains generic PHY driver
26 #include <linux/phy.h>
36 MODULE_DESCRIPTION("PHY library");
203 put_device(&phydev->mdio.dev); in phy_device_free()
215 static void phy_device_release(struct device *dev) in phy_device_release()
235 struct device_driver *drv = phydev->mdio.dev.driver; in mdio_bus_phy_may_suspend()
237 struct net_device *netdev = phydev->attached_dev; in mdio_bus_phy_may_suspend()
239 if (!drv || !phydrv->suspend) in mdio_bus_phy_may_suspend()
242 /* PHY not attached? May suspend if the PHY has not already been in mdio_bus_phy_may_suspend()
243 * suspended as part of a prior call to phy_disconnect() -> in mdio_bus_phy_may_suspend()
244 * phy_detach() -> phy_suspend() because the parent netdev might be the in mdio_bus_phy_may_suspend()
250 if (netdev->wol_enabled) in mdio_bus_phy_may_suspend()
255 * Don't suspend PHY if the attached netdev parent may wake up. in mdio_bus_phy_may_suspend()
256 * The parent may point to a PCI device, as in tg3 driver. in mdio_bus_phy_may_suspend()
258 if (netdev->dev.parent && device_may_wakeup(netdev->dev.parent)) in mdio_bus_phy_may_suspend()
261 /* Also don't suspend PHY if the netdev itself may wakeup. This in mdio_bus_phy_may_suspend()
265 if (device_may_wakeup(&netdev->dev)) in mdio_bus_phy_may_suspend()
269 return !phydev->suspended; in mdio_bus_phy_may_suspend()
272 static __maybe_unused int mdio_bus_phy_suspend(struct device *dev) in mdio_bus_phy_suspend()
277 * control, possibly with the phydev->lock held. Upon resume, netdev in mdio_bus_phy_suspend()
278 * may call phy routines that try to grab the same lock, and that may in mdio_bus_phy_suspend()
281 if (phydev->attached_dev && phydev->adjust_link) in mdio_bus_phy_suspend()
287 phydev->suspended_by_mdio_bus = 1; in mdio_bus_phy_suspend()
292 static __maybe_unused int mdio_bus_phy_resume(struct device *dev) in mdio_bus_phy_resume()
297 if (!phydev->suspended_by_mdio_bus) in mdio_bus_phy_resume()
300 phydev->suspended_by_mdio_bus = 0; in mdio_bus_phy_resume()
310 if (phydev->attached_dev && phydev->adjust_link) in mdio_bus_phy_resume()
320 * phy_register_fixup - creates a new phy_fixup and adds it to the list
321 * @bus_id: A string which matches phydev->mdio.dev.bus_id (or PHY_ANY_ID)
322 * @phy_uid: Used to match against phydev->phy_id (the UID of the PHY)
324 * @phy_uid_mask: Applied to phydev->phy_id and fixup->phy_uid before
326 * @run: The actual code to be run when a matching PHY is found
334 return -ENOMEM; in phy_register_fixup()
336 strlcpy(fixup->bus_id, bus_id, sizeof(fixup->bus_id)); in phy_register_fixup()
337 fixup->phy_uid = phy_uid; in phy_register_fixup()
338 fixup->phy_uid_mask = phy_uid_mask; in phy_register_fixup()
339 fixup->run = run; in phy_register_fixup()
342 list_add_tail(&fixup->list, &phy_fixup_list); in phy_register_fixup()
349 /* Registers a fixup to be run on any PHY with the UID in phy_uid */
357 /* Registers a fixup to be run on the PHY with id string bus_id */
366 * phy_unregister_fixup - remove a phy_fixup from the list
367 * @bus_id: A string matches fixup->bus_id (or PHY_ANY_ID) in phy_fixup_list
368 * @phy_uid: A phy id matches fixup->phy_id (or PHY_ANY_UID) in phy_fixup_list
369 * @phy_uid_mask: Applied to phy_uid and fixup->phy_uid before comparison
377 ret = -ENODEV; in phy_unregister_fixup()
383 if ((!strcmp(fixup->bus_id, bus_id)) && in phy_unregister_fixup()
384 ((fixup->phy_uid & phy_uid_mask) == in phy_unregister_fixup()
386 list_del(&fixup->list); in phy_unregister_fixup()
398 /* Unregisters a fixup of any PHY with the UID in phy_uid */
405 /* Unregisters a fixup of the PHY with id string bus_id */
417 if (strcmp(fixup->bus_id, phydev_name(phydev)) != 0) in phy_needs_fixup()
418 if (strcmp(fixup->bus_id, PHY_ANY_ID) != 0) in phy_needs_fixup()
421 if ((fixup->phy_uid & fixup->phy_uid_mask) != in phy_needs_fixup()
422 (phydev->phy_id & fixup->phy_uid_mask)) in phy_needs_fixup()
423 if (fixup->phy_uid != PHY_ANY_UID) in phy_needs_fixup()
437 int err = fixup->run(phydev); in phy_scan_fixups()
443 phydev->has_fixups = true; in phy_scan_fixups()
451 static int phy_bus_match(struct device *dev, struct device_driver *drv) in phy_bus_match()
455 const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids); in phy_bus_match()
458 if (!(phydrv->mdiodrv.flags & MDIO_DEVICE_IS_PHY)) in phy_bus_match()
461 if (phydrv->match_phy_device) in phy_bus_match()
462 return phydrv->match_phy_device(phydev); in phy_bus_match()
464 if (phydev->is_c45) { in phy_bus_match()
466 if (phydev->c45_ids.device_ids[i] == 0xffffffff) in phy_bus_match()
469 if ((phydrv->phy_id & phydrv->phy_id_mask) == in phy_bus_match()
470 (phydev->c45_ids.device_ids[i] & in phy_bus_match()
471 phydrv->phy_id_mask)) in phy_bus_match()
476 return (phydrv->phy_id & phydrv->phy_id_mask) == in phy_bus_match()
477 (phydev->phy_id & phydrv->phy_id_mask); in phy_bus_match()
482 phy_id_show(struct device *dev, struct device_attribute *attr, char *buf) in phy_id_show()
486 return sprintf(buf, "0x%.8lx\n", (unsigned long)phydev->phy_id); in phy_id_show()
491 phy_interface_show(struct device *dev, struct device_attribute *attr, char *buf) in phy_interface_show()
499 mode = phy_modes(phydev->interface); in phy_interface_show()
506 phy_has_fixups_show(struct device *dev, struct device_attribute *attr, in phy_has_fixups_show()
511 return sprintf(buf, "%d\n", phydev->has_fixups); in phy_has_fixups_show()
516 phy_registers_show(struct device *dev, struct device_attribute *attr, char *buf) in phy_registers_show()
529 phy_registers_store(struct device *dev, in phy_registers_store()
557 pr_info("Set Ethernet PHY register %d to 0x%x\n", (int)index, (int)val); in phy_registers_store()
582 .name = "PHY",
595 * not whether a PHY driver module exists for the PHY ID. in phy_request_driver_module()
596 * Accept -ENOENT because this may occur in case no initramfs exists, in phy_request_driver_module()
599 if (IS_ENABLED(CONFIG_MODULES) && ret < 0 && ret != -ENOENT) { in phy_request_driver_module()
600 phydev_err(dev, "error %d loading PHY driver module for ID 0x%08lx\n", in phy_request_driver_module()
616 /* We allocate the device, and initialize the default values */ in phy_device_create()
619 return ERR_PTR(-ENOMEM); in phy_device_create()
621 mdiodev = &dev->mdio; in phy_device_create()
622 mdiodev->dev.parent = &bus->dev; in phy_device_create()
623 mdiodev->dev.bus = &mdio_bus_type; in phy_device_create()
624 mdiodev->dev.type = &mdio_bus_phy_type; in phy_device_create()
625 mdiodev->bus = bus; in phy_device_create()
626 mdiodev->bus_match = phy_bus_match; in phy_device_create()
627 mdiodev->addr = addr; in phy_device_create()
628 mdiodev->flags = MDIO_DEVICE_FLAG_PHY; in phy_device_create()
629 mdiodev->device_free = phy_mdio_device_free; in phy_device_create()
630 mdiodev->device_remove = phy_mdio_device_remove; in phy_device_create()
632 dev->speed = SPEED_UNKNOWN; in phy_device_create()
633 dev->duplex = DUPLEX_UNKNOWN; in phy_device_create()
634 dev->pause = 0; in phy_device_create()
635 dev->asym_pause = 0; in phy_device_create()
636 dev->link = 0; in phy_device_create()
637 dev->port = PORT_TP; in phy_device_create()
638 dev->interface = PHY_INTERFACE_MODE_GMII; in phy_device_create()
640 dev->autoneg = AUTONEG_ENABLE; in phy_device_create()
642 dev->is_c45 = is_c45; in phy_device_create()
643 dev->phy_id = phy_id; in phy_device_create()
645 dev->c45_ids = *c45_ids; in phy_device_create()
646 dev->irq = bus->irq[addr]; in phy_device_create()
648 dev_set_name(&mdiodev->dev, PHY_ID_FMT, bus->id, addr); in phy_device_create()
649 device_initialize(&mdiodev->dev); in phy_device_create()
651 dev->state = PHY_DOWN; in phy_device_create()
653 mutex_init(&dev->lock); in phy_device_create()
654 INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine); in phy_device_create()
661 * -- because it relies on the device staying around for long in phy_device_create()
667 const int num_ids = ARRAY_SIZE(c45_ids->device_ids); in phy_device_create()
671 if (c45_ids->device_ids[i] == 0xffffffff) in phy_device_create()
675 c45_ids->device_ids[i]); in phy_device_create()
684 put_device(&mdiodev->dev); in phy_device_create()
692 /* phy_c45_probe_present - checks to see if a MMD is present in the package
694 * @prtad: PHY package address on the MII bus
695 * @devad: PHY device (MMD) address
697 * Read the MDIO_STAT2 register, and check whether a device is responding
700 * Returns: negative error number on bus access error, zero if no device
701 * is responding, or positive if a device is present.
714 /* get_phy_c45_devs_in_pkg - reads a MMD's devices in package registers.
716 * @addr: PHY address on the MII bus
717 * @dev_addr: MMD address in the PHY.
721 * from PHY at @addr on @bus.
723 * Returns: 0 on success, -EIO on failure.
732 return -EIO; in get_phy_c45_devs_in_pkg()
737 return -EIO; in get_phy_c45_devs_in_pkg()
744 * get_phy_c45_ids - reads the specified addr for its 802.3-c45 IDs.
746 * @addr: PHY address on the MII bus
749 * Read the PHY "devices in package". If this appears to be valid, read
750 * the PHY identifiers for each device. Return the "devices in package"
753 * Returns zero on success, %-EIO on bus access error, or %-ENODEV if
759 const int num_ids = ARRAY_SIZE(c45_ids->device_ids); in get_phy_c45_ids()
763 /* Find first non-zero Devices In package. Device zero is reserved in get_phy_c45_ids()
769 /* Check that there is a device present at this in get_phy_c45_ids()
770 * address before reading the devices-in-package in get_phy_c45_ids()
771 * register to avoid reading garbage from the PHY. in get_phy_c45_ids()
777 return -EIO; in get_phy_c45_ids()
784 return -EIO; in get_phy_c45_ids()
788 /* If mostly Fs, there is no device there, then let's probe in get_phy_c45_ids()
790 * e.g. Cortina CS4315/CS4340 PHY. in get_phy_c45_ids()
794 return -EIO; in get_phy_c45_ids()
796 /* no device there, let's get out of here */ in get_phy_c45_ids()
798 return -ENODEV; in get_phy_c45_ids()
801 /* Now probe Device Identifiers for each device present. */ in get_phy_c45_ids()
807 /* Probe the "Device Present" bits for the vendor MMDs in get_phy_c45_ids()
821 return -EIO; in get_phy_c45_ids()
822 c45_ids->device_ids[i] = phy_reg << 16; in get_phy_c45_ids()
826 return -EIO; in get_phy_c45_ids()
827 c45_ids->device_ids[i] |= phy_reg; in get_phy_c45_ids()
830 c45_ids->devices_in_package = devs_in_pkg; in get_phy_c45_ids()
831 /* Bit 0 doesn't represent a device, it indicates c22 regs presence */ in get_phy_c45_ids()
832 c45_ids->mmds_present = devs_in_pkg & ~BIT(0); in get_phy_c45_ids()
838 * get_phy_c22_id - reads the specified addr for its clause 22 ID.
840 * @addr: PHY address on the MII bus
843 * Read the 802.3 clause 22 PHY ID from the PHY at @addr on the @bus,
845 * valid, %-EIO on bus access error, or %-ENODEV if no device responds
855 /* returning -ENODEV doesn't stop bus scanning */ in get_phy_c22_id()
856 return (phy_reg == -EIO || phy_reg == -ENODEV) ? -ENODEV : -EIO; in get_phy_c22_id()
864 /* returning -ENODEV doesn't stop bus scanning */ in get_phy_c22_id()
865 return (phy_reg == -EIO || phy_reg == -ENODEV) ? -ENODEV : -EIO; in get_phy_c22_id()
870 /* If the phy_id is mostly Fs, there is no device there */ in get_phy_c22_id()
872 return -ENODEV; in get_phy_c22_id()
878 * get_phy_device - reads the specified PHY device and returns its @phy_device
881 * @addr: PHY address on the MII bus
882 * @is_c45: If true the PHY uses the 802.3 clause 45 protocol
884 * Probe for a PHY at @addr on @bus.
886 * When probing for a clause 22 PHY, then read the ID registers. If we find
889 * When probing for a clause 45 PHY, read the "devices in package" registers.
893 * Returns an allocated &struct phy_device on success, %-ENODEV if there is
894 * no PHY present, or %-EIO on bus access error.
919 * phy_device_register - Register the phy device on the MDIO bus
926 err = mdiobus_register_device(&phydev->mdio); in phy_device_register()
933 /* Run all of the fixups for this PHY */ in phy_device_register()
940 err = device_add(&phydev->mdio.dev); in phy_device_register()
952 mdiobus_unregister_device(&phydev->mdio); in phy_device_register()
958 * phy_device_remove - Remove a previously registered phy device from the MDIO bus
962 * of phy_device_register(). Use phy_device_free() to free the device
967 if (phydev->mii_ts) in phy_device_remove()
968 unregister_mii_timestamper(phydev->mii_ts); in phy_device_remove()
970 device_del(&phydev->mdio.dev); in phy_device_remove()
975 mdiobus_unregister_device(&phydev->mdio); in phy_device_remove()
980 * phy_find_first - finds the first PHY device on the bus
999 struct net_device *netdev = phydev->attached_dev; in phy_link_change()
1005 phydev->adjust_link(netdev); in phy_link_change()
1006 if (phydev->mii_ts && phydev->mii_ts->link_state) in phy_link_change()
1007 phydev->mii_ts->link_state(phydev->mii_ts, phydev); in phy_link_change()
1011 * phy_prepare_link - prepares the PHY layer to monitor link status
1015 * Description: Tells the PHY infrastructure to handle the
1018 * connected device driver when the link status changes.
1025 phydev->adjust_link = handler; in phy_prepare_link()
1029 * phy_connect_direct - connect an ethernet device to a specific phy_device
1030 * @dev: the network device to connect
1031 * @phydev: the pointer to the phy device
1033 * @interface: PHY device's interface
1042 return -EINVAL; in phy_connect_direct()
1044 rc = phy_attach_direct(dev, phydev, phydev->dev_flags, interface); in phy_connect_direct()
1057 * phy_connect - connect an ethernet device to a PHY device
1058 * @dev: the network device to connect
1059 * @bus_id: the id string of the PHY device to connect
1061 * @interface: PHY device's interface
1064 * devices to PHY devices. The default behavior is for
1065 * the PHY infrastructure to handle everything, and only notify
1076 struct device *d; in phy_connect()
1079 /* Search the list of PHY devices on the mdio bus for the in phy_connect()
1080 * PHY with the requested name in phy_connect()
1084 pr_err("PHY %s not found\n", bus_id); in phy_connect()
1085 return ERR_PTR(-ENODEV); in phy_connect()
1099 * phy_disconnect - disable interrupts, stop state machine, and detach a PHY
1100 * device
1111 phydev->adjust_link = NULL; in phy_disconnect()
1118 * phy_poll_reset - Safely wait until a PHY reset has properly completed
1119 * @phydev: The PHY device to poll
1122 * published in 2008, a PHY reset may take up to 0.5 seconds. The MII BMCR
1125 * Furthermore, any attempts to write to PHY registers may have no effect
1130 * even *REQUIRE* a soft-reset to properly restart autonegotiation. In an
1133 * and reapply all driver-specific and board-specific fixups.
1158 if (!phydev->drv) in phy_init_hw()
1161 if (phydev->drv->soft_reset) { in phy_init_hw()
1162 ret = phydev->drv->soft_reset(phydev); in phy_init_hw()
1165 phydev->suspended = 0; in phy_init_hw()
1175 if (phydev->drv->config_init) { in phy_init_hw()
1176 ret = phydev->drv->config_init(phydev); in phy_init_hw()
1181 if (phydev->drv->config_intr) { in phy_init_hw()
1182 ret = phydev->drv->config_intr(phydev); in phy_init_hw()
1197 #define ATTACHED_FMT "attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%s)"
1203 switch(phydev->irq) { in phy_attached_info_irq()
1211 snprintf(irq_num, sizeof(irq_num), "%d", phydev->irq); in phy_attached_info_irq()
1222 const char *drv_name = phydev->drv ? phydev->drv->name : "unbound"; in phy_attached_print()
1246 struct net_device *dev = phydev->attached_dev; in phy_sysfs_create_links()
1252 err = sysfs_create_link(&phydev->mdio.dev.kobj, &dev->dev.kobj, in phy_sysfs_create_links()
1257 err = sysfs_create_link_nowarn(&dev->dev.kobj, in phy_sysfs_create_links()
1258 &phydev->mdio.dev.kobj, in phy_sysfs_create_links()
1261 dev_err(&dev->dev, "could not add device link to %s err %d\n", in phy_sysfs_create_links()
1262 kobject_name(&phydev->mdio.dev.kobj), in phy_sysfs_create_links()
1264 /* non-fatal - some net drivers can use one netdevice in phy_sysfs_create_links()
1265 * with more then one phy in phy_sysfs_create_links()
1269 phydev->sysfs_links = true; in phy_sysfs_create_links()
1273 phy_standalone_show(struct device *dev, struct device_attribute *attr, in phy_standalone_show()
1278 return sprintf(buf, "%d\n", !phydev->attached_dev); in phy_standalone_show()
1283 * phy_sfp_attach - attach the SFP bus to the PHY upstream network device
1284 * @upstream: pointer to the phy device
1293 if (phydev->attached_dev) in phy_sfp_attach()
1294 phydev->attached_dev->sfp_bus = bus; in phy_sfp_attach()
1295 phydev->sfp_bus_attached = true; in phy_sfp_attach()
1300 * phy_sfp_detach - detach the SFP bus from the PHY upstream network device
1301 * @upstream: pointer to the phy device
1310 if (phydev->attached_dev) in phy_sfp_detach()
1311 phydev->attached_dev->sfp_bus = NULL; in phy_sfp_detach()
1312 phydev->sfp_bus_attached = false; in phy_sfp_detach()
1317 * phy_sfp_probe - probe for a SFP cage attached to this PHY device
1327 if (phydev->mdio.dev.fwnode) { in phy_sfp_probe()
1328 bus = sfp_bus_find_fwnode(phydev->mdio.dev.fwnode); in phy_sfp_probe()
1332 phydev->sfp_bus = bus; in phy_sfp_probe()
1342 * phy_attach_direct - attach a network device to a given PHY device pointer
1343 * @dev: network device to attach
1345 * @flags: PHY device's dev_flags
1346 * @interface: PHY device's interface
1348 * Description: Called by drivers to attach to a particular PHY
1349 * device. The phy_device is found, and properly hooked up
1352 * the attaching device, and given a callback for link status
1354 * This function takes a reference on the phy device.
1359 struct mii_bus *bus = phydev->mdio.bus; in phy_attach_direct()
1360 struct device *d = &phydev->mdio.dev; in phy_attach_direct()
1365 /* For Ethernet device drivers that register their own MDIO bus, we in phy_attach_direct()
1366 * will have bus->owner match ndev_mod, so we do not want to increment in phy_attach_direct()
1367 * our own module->refcnt here, otherwise we would not be able to in phy_attach_direct()
1371 ndev_owner = dev->dev.parent->driver->owner; in phy_attach_direct()
1372 if (ndev_owner != bus->owner && !try_module_get(bus->owner)) { in phy_attach_direct()
1374 return -EIO; in phy_attach_direct()
1382 if (!d->driver) { in phy_attach_direct()
1383 if (phydev->is_c45) in phy_attach_direct()
1384 d->driver = &genphy_c45_driver.mdiodrv.driver; in phy_attach_direct()
1386 d->driver = &genphy_driver.mdiodrv.driver; in phy_attach_direct()
1391 if (!try_module_get(d->driver->owner)) { in phy_attach_direct()
1392 phydev_err(phydev, "failed to get the device driver module\n"); in phy_attach_direct()
1393 err = -EIO; in phy_attach_direct()
1398 err = d->driver->probe(d); in phy_attach_direct()
1406 if (phydev->attached_dev) { in phy_attach_direct()
1407 dev_err(&dev->dev, "PHY already attached\n"); in phy_attach_direct()
1408 err = -EBUSY; in phy_attach_direct()
1412 phydev->phy_link_change = phy_link_change; in phy_attach_direct()
1414 phydev->attached_dev = dev; in phy_attach_direct()
1415 dev->phydev = phydev; in phy_attach_direct()
1417 if (phydev->sfp_bus_attached) in phy_attach_direct()
1418 dev->sfp_bus = phydev->sfp_bus; in phy_attach_direct()
1421 /* Some Ethernet drivers try to connect to a PHY device before in phy_attach_direct()
1422 * calling register_netdevice() -> netdev_register_kobject() and in phy_attach_direct()
1423 * does the dev->dev.kobj initialization. Here we only check for in phy_attach_direct()
1424 * success which indicates that the network device kobject is in phy_attach_direct()
1429 phydev->sysfs_links = false; in phy_attach_direct()
1433 if (!phydev->attached_dev) { in phy_attach_direct()
1434 err = sysfs_create_file(&phydev->mdio.dev.kobj, in phy_attach_direct()
1440 phydev->dev_flags |= flags; in phy_attach_direct()
1442 phydev->interface = interface; in phy_attach_direct()
1444 phydev->state = PHY_READY; in phy_attach_direct()
1446 /* Port is set to PORT_TP by default and the actual PHY driver will set in phy_attach_direct()
1447 * it to different value depending on the PHY configuration. If we have in phy_attach_direct()
1448 * the generic PHY driver we can't figure it out, thus set the old in phy_attach_direct()
1452 phydev->port = PORT_MII; in phy_attach_direct()
1454 /* Initial carrier state is off as the phy is about to be in phy_attach_direct()
1458 netif_carrier_off(phydev->attached_dev); in phy_attach_direct()
1483 module_put(d->driver->owner); in phy_attach_direct()
1484 d->driver = NULL; in phy_attach_direct()
1487 if (ndev_owner != bus->owner) in phy_attach_direct()
1488 module_put(bus->owner); in phy_attach_direct()
1494 * phy_attach - attach a network device to a particular PHY device
1495 * @dev: network device to attach
1496 * @bus_id: Bus ID of PHY device to attach
1497 * @interface: PHY device's interface
1499 * Description: Same as phy_attach_direct() except that a PHY bus_id
1507 struct device *d; in phy_attach()
1511 return ERR_PTR(-EINVAL); in phy_attach()
1513 /* Search the list of PHY devices on the mdio bus for the in phy_attach()
1514 * PHY with the requested name in phy_attach()
1518 pr_err("PHY %s not found\n", bus_id); in phy_attach()
1519 return ERR_PTR(-ENODEV); in phy_attach()
1523 rc = phy_attach_direct(dev, phydev, phydev->dev_flags, interface); in phy_attach()
1535 struct device *d = &phydev->mdio.dev; in phy_driver_is_genphy_kind()
1538 if (!phydev->drv) in phy_driver_is_genphy_kind()
1542 ret = d->driver == driver; in phy_driver_is_genphy_kind()
1563 * phy_package_join - join a common PHY group
1565 * @addr: cookie and PHY address for global register access
1566 * @priv_size: if non-zero allocate this amount of bytes for private data
1568 * This joins a PHY group and provides a shared storage for all phydevs in
1570 * more than one PHY, for example a quad PHY transceiver.
1573 * for all members of one group and as a PHY address to access generic
1574 * registers of a PHY package. Usually, one of the PHY addresses of the
1577 * and phy_package_write() convenience functions. If your PHY doesn't have
1578 * global registers you can just pick any of the PHY addresses.
1582 * allocated. If priv_size is non-zero, the given amount of bytes are
1590 struct mii_bus *bus = phydev->mdio.bus; in phy_package_join()
1595 return -EINVAL; in phy_package_join()
1597 mutex_lock(&bus->shared_lock); in phy_package_join()
1598 shared = bus->shared[addr]; in phy_package_join()
1600 ret = -ENOMEM; in phy_package_join()
1605 shared->priv = kzalloc(priv_size, GFP_KERNEL); in phy_package_join()
1606 if (!shared->priv) in phy_package_join()
1608 shared->priv_size = priv_size; in phy_package_join()
1610 shared->addr = addr; in phy_package_join()
1611 refcount_set(&shared->refcnt, 1); in phy_package_join()
1612 bus->shared[addr] = shared; in phy_package_join()
1614 ret = -EINVAL; in phy_package_join()
1615 if (priv_size && priv_size != shared->priv_size) in phy_package_join()
1617 refcount_inc(&shared->refcnt); in phy_package_join()
1619 mutex_unlock(&bus->shared_lock); in phy_package_join()
1621 phydev->shared = shared; in phy_package_join()
1628 mutex_unlock(&bus->shared_lock); in phy_package_join()
1634 * phy_package_leave - leave a common PHY group
1637 * This leaves a PHY group created by phy_package_join(). If this phydev
1639 * freed. Resets the phydev->shared pointer to NULL.
1643 struct phy_package_shared *shared = phydev->shared; in phy_package_leave()
1644 struct mii_bus *bus = phydev->mdio.bus; in phy_package_leave()
1649 if (refcount_dec_and_mutex_lock(&shared->refcnt, &bus->shared_lock)) { in phy_package_leave()
1650 bus->shared[shared->addr] = NULL; in phy_package_leave()
1651 mutex_unlock(&bus->shared_lock); in phy_package_leave()
1652 kfree(shared->priv); in phy_package_leave()
1656 phydev->shared = NULL; in phy_package_leave()
1660 static void devm_phy_package_leave(struct device *dev, void *res) in devm_phy_package_leave()
1666 * devm_phy_package_join - resource managed phy_package_join()
1667 * @dev: device that is registering this PHY package
1669 * @addr: cookie and PHY address for global register access
1670 * @priv_size: if non-zero allocate this amount of bytes for private data
1676 int devm_phy_package_join(struct device *dev, struct phy_device *phydev, in devm_phy_package_join()
1685 return -ENOMEM; in devm_phy_package_join()
1701 * phy_detach - detach a PHY device from its network device
1704 * This detaches the phy device from its network device and the phy
1709 struct net_device *dev = phydev->attached_dev; in phy_detach()
1713 if (phydev->sysfs_links) { in phy_detach()
1715 sysfs_remove_link(&dev->dev.kobj, "phydev"); in phy_detach()
1716 sysfs_remove_link(&phydev->mdio.dev.kobj, "attached_dev"); in phy_detach()
1719 if (!phydev->attached_dev) in phy_detach()
1720 sysfs_remove_file(&phydev->mdio.dev.kobj, in phy_detach()
1725 phydev->attached_dev->phydev = NULL; in phy_detach()
1726 phydev->attached_dev = NULL; in phy_detach()
1728 phydev->phylink = NULL; in phy_detach()
1732 if (phydev->mdio.dev.driver) in phy_detach()
1733 module_put(phydev->mdio.dev.driver->owner); in phy_detach()
1735 /* If the device had no specific driver before (i.e. - it in phy_detach()
1736 * was using the generic driver), we unbind the device in phy_detach()
1742 device_release_driver(&phydev->mdio.dev); in phy_detach()
1749 * a use-after-free bug by reading the underlying bus first. in phy_detach()
1751 bus = phydev->mdio.bus; in phy_detach()
1753 put_device(&phydev->mdio.dev); in phy_detach()
1755 ndev_owner = dev->dev.parent->driver->owner; in phy_detach()
1756 if (ndev_owner != bus->owner) in phy_detach()
1757 module_put(bus->owner); in phy_detach()
1764 struct net_device *netdev = phydev->attached_dev; in phy_suspend()
1765 struct phy_driver *phydrv = phydev->drv; in phy_suspend()
1768 if (phydev->suspended) in phy_suspend()
1771 /* If the device has WOL enabled, we cannot suspend the PHY */ in phy_suspend()
1773 if (wol.wolopts || (netdev && netdev->wol_enabled)) in phy_suspend()
1774 return -EBUSY; in phy_suspend()
1776 if (!phydrv || !phydrv->suspend) in phy_suspend()
1779 ret = phydrv->suspend(phydev); in phy_suspend()
1781 phydev->suspended = true; in phy_suspend()
1789 struct phy_driver *phydrv = phydev->drv; in __phy_resume()
1792 WARN_ON(!mutex_is_locked(&phydev->lock)); in __phy_resume()
1794 if (!phydrv || !phydrv->resume) in __phy_resume()
1797 ret = phydrv->resume(phydev); in __phy_resume()
1799 phydev->suspended = false; in __phy_resume()
1809 mutex_lock(&phydev->lock); in phy_resume()
1811 mutex_unlock(&phydev->lock); in phy_resume()
1819 struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver); in phy_loopback()
1822 mutex_lock(&phydev->lock); in phy_loopback()
1824 if (enable && phydev->loopback_enabled) { in phy_loopback()
1825 ret = -EBUSY; in phy_loopback()
1829 if (!enable && !phydev->loopback_enabled) { in phy_loopback()
1830 ret = -EINVAL; in phy_loopback()
1834 if (phydev->drv && phydrv->set_loopback) in phy_loopback()
1835 ret = phydrv->set_loopback(phydev, enable); in phy_loopback()
1837 ret = -EOPNOTSUPP; in phy_loopback()
1842 phydev->loopback_enabled = enable; in phy_loopback()
1845 mutex_unlock(&phydev->lock); in phy_loopback()
1851 * phy_reset_after_clk_enable - perform a PHY reset if needed
1856 * needed. Returns < 0 on error, 0 if the phy wasn't reset and 1 if the phy
1861 if (!phydev || !phydev->drv) in phy_reset_after_clk_enable()
1862 return -ENODEV; in phy_reset_after_clk_enable()
1864 if (phydev->drv->flags & PHY_RST_AFTER_CLK_EN) { in phy_reset_after_clk_enable()
1874 /* Generic PHY support and helper functions */
1877 * genphy_config_advert - sanitize and advertise auto-negotiation parameters
1882 * what is supported. Returns < 0 on error, 0 if the PHY's advertisement
1890 /* Only allow advertising what this PHY supports */ in genphy_config_advert()
1891 linkmode_and(phydev->advertising, phydev->advertising, in genphy_config_advert()
1892 phydev->supported); in genphy_config_advert()
1894 adv = linkmode_adv_to_mii_adv_t(phydev->advertising); in genphy_config_advert()
1910 /* Per 802.3-2008, Section 22.2.4.2.16 Extended status all in genphy_config_advert()
1917 adv = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising); in genphy_config_advert()
1931 * genphy_c37_config_advert - sanitize and advertise auto-negotiation parameters
1936 * what is supported. Returns < 0 on error, 0 if the PHY's advertisement
1938 * for Clause 37 1000Base-X mode.
1944 /* Only allow advertising what this PHY supports */ in genphy_c37_config_advert()
1945 linkmode_and(phydev->advertising, phydev->advertising, in genphy_c37_config_advert()
1946 phydev->supported); in genphy_c37_config_advert()
1949 phydev->advertising)) in genphy_c37_config_advert()
1952 phydev->advertising)) in genphy_c37_config_advert()
1955 phydev->advertising)) in genphy_c37_config_advert()
1965 * genphy_config_eee_advert - disable unwanted eee mode advertisement
1969 * efficent ethernet modes. Returns 0 if the PHY's advertisement hasn't
1977 if (!phydev->eee_broken_modes) in genphy_config_eee_advert()
1981 phydev->eee_broken_modes, 0); in genphy_config_eee_advert()
1988 * genphy_setup_forced - configures/forces speed/duplex from @phydev
1999 phydev->pause = 0; in genphy_setup_forced()
2000 phydev->asym_pause = 0; in genphy_setup_forced()
2002 if (SPEED_1000 == phydev->speed) in genphy_setup_forced()
2004 else if (SPEED_100 == phydev->speed) in genphy_setup_forced()
2007 if (DUPLEX_FULL == phydev->duplex) in genphy_setup_forced()
2019 if (!phydev->is_gigabit_capable) in genphy_setup_master_slave()
2022 switch (phydev->master_slave_set) { in genphy_setup_master_slave()
2039 return -EOPNOTSUPP; in genphy_setup_master_slave()
2052 if (!phydev->is_gigabit_capable) { in genphy_read_master_slave()
2053 phydev->master_slave_get = MASTER_SLAVE_CFG_UNSUPPORTED; in genphy_read_master_slave()
2054 phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED; in genphy_read_master_slave()
2058 phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN; in genphy_read_master_slave()
2059 phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; in genphy_read_master_slave()
2083 } else if (phydev->link) { in genphy_read_master_slave()
2093 phydev->master_slave_get = cfg; in genphy_read_master_slave()
2094 phydev->master_slave_state = state; in genphy_read_master_slave()
2100 * genphy_restart_aneg - Enable and Restart Autonegotiation
2105 /* Don't isolate the PHY if we're negotiating */ in genphy_restart_aneg()
2112 * genphy_check_and_restart_aneg - Enable and restart auto-negotiation
2116 * Check, and restart auto-negotiation if needed.
2124 * begin with? Or maybe phy was isolated? in genphy_check_and_restart_aneg()
2142 * __genphy_config_aneg - restart auto-negotiation or write BMCR
2146 * Description: If auto-negotiation is enabled, we configure the
2147 * advertising, and then restart auto-negotiation. If it is not
2163 if (AUTONEG_ENABLE != phydev->autoneg) in __genphy_config_aneg()
2177 * genphy_c37_config_aneg - restart auto-negotiation or write BMCR
2180 * Description: If auto-negotiation is enabled, we configure the
2181 * advertising, and then restart auto-negotiation. If it is not
2183 * for use with Clause 37 1000Base-X mode.
2189 if (phydev->autoneg != AUTONEG_ENABLE) in genphy_c37_config_aneg()
2203 * begin with? Or maybe phy was isolated? in genphy_c37_config_aneg()
2225 * genphy_aneg_done - return auto-negotiation status
2229 * auto-negotiation is incomplete, or if there was an error.
2230 * Returns BMSR_ANEGCOMPLETE if auto-negotiation is done.
2241 * genphy_update_link - update link status in @phydev
2244 * Description: Update the value in phydev->link to reflect the
2263 * drops can be detected. Do not double-read the status in genphy_update_link()
2267 if (!phy_polling_mode(phydev) || !phydev->link) { in genphy_update_link()
2280 phydev->link = status & BMSR_LSTATUS ? 1 : 0; in genphy_update_link()
2281 phydev->autoneg_complete = status & BMSR_ANEGCOMPLETE ? 1 : 0; in genphy_update_link()
2286 if (phydev->autoneg == AUTONEG_ENABLE && !phydev->autoneg_complete) in genphy_update_link()
2287 phydev->link = 0; in genphy_update_link()
2297 if (phydev->autoneg == AUTONEG_ENABLE) { in genphy_read_lpa()
2298 if (!phydev->autoneg_complete) { in genphy_read_lpa()
2299 mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, in genphy_read_lpa()
2301 mii_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, 0); in genphy_read_lpa()
2305 if (phydev->is_gigabit_capable) { in genphy_read_lpa()
2320 return -ENOLINK; in genphy_read_lpa()
2323 mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, in genphy_read_lpa()
2331 mii_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); in genphy_read_lpa()
2333 linkmode_zero(phydev->lp_advertising); in genphy_read_lpa()
2341 * genphy_read_status_fixed - read the link parameters for !aneg mode
2344 * Read the current duplex and speed state for a PHY operating with
2355 phydev->duplex = DUPLEX_FULL; in genphy_read_status_fixed()
2357 phydev->duplex = DUPLEX_HALF; in genphy_read_status_fixed()
2360 phydev->speed = SPEED_1000; in genphy_read_status_fixed()
2362 phydev->speed = SPEED_100; in genphy_read_status_fixed()
2364 phydev->speed = SPEED_10; in genphy_read_status_fixed()
2371 * genphy_read_status - check the link status and update current link state
2381 int err, old_link = phydev->link; in genphy_read_status()
2388 /* why bother the PHY if nothing can have changed */ in genphy_read_status()
2389 if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) in genphy_read_status()
2392 phydev->speed = SPEED_UNKNOWN; in genphy_read_status()
2393 phydev->duplex = DUPLEX_UNKNOWN; in genphy_read_status()
2394 phydev->pause = 0; in genphy_read_status()
2395 phydev->asym_pause = 0; in genphy_read_status()
2405 if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) { in genphy_read_status()
2407 } else if (phydev->autoneg == AUTONEG_DISABLE) { in genphy_read_status()
2418 * genphy_c37_read_status - check the link status and update current link state
2423 * advertises. This function is for Clause 37 1000Base-X mode.
2427 int lpa, err, old_link = phydev->link; in genphy_c37_read_status()
2434 /* why bother the PHY if nothing can have changed */ in genphy_c37_read_status()
2435 if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) in genphy_c37_read_status()
2438 phydev->duplex = DUPLEX_UNKNOWN; in genphy_c37_read_status()
2439 phydev->pause = 0; in genphy_c37_read_status()
2440 phydev->asym_pause = 0; in genphy_c37_read_status()
2442 if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) { in genphy_c37_read_status()
2448 phydev->lp_advertising, lpa & LPA_LPACK); in genphy_c37_read_status()
2450 phydev->lp_advertising, lpa & LPA_1000XFULL); in genphy_c37_read_status()
2452 phydev->lp_advertising, lpa & LPA_1000XPAUSE); in genphy_c37_read_status()
2454 phydev->lp_advertising, in genphy_c37_read_status()
2458 } else if (phydev->autoneg == AUTONEG_DISABLE) { in genphy_c37_read_status()
2465 phydev->duplex = DUPLEX_FULL; in genphy_c37_read_status()
2467 phydev->duplex = DUPLEX_HALF; in genphy_c37_read_status()
2475 * genphy_soft_reset - software reset the PHY via BMCR_RESET bit
2478 * Description: Perform a software PHY reset using the standard
2488 if (phydev->autoneg == AUTONEG_ENABLE) in genphy_soft_reset()
2499 phydev->suspended = 0; in genphy_soft_reset()
2506 if (phydev->autoneg == AUTONEG_DISABLE) in genphy_soft_reset()
2514 * genphy_read_abilities - read PHY abilities from Clause 22 registers
2517 * Description: Reads the PHY's abilities and populates
2518 * phydev->supported accordingly.
2528 phydev->supported); in genphy_read_abilities()
2534 linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported, in genphy_read_abilities()
2537 linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, phydev->supported, in genphy_read_abilities()
2539 linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, phydev->supported, in genphy_read_abilities()
2541 linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, phydev->supported, in genphy_read_abilities()
2543 linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT, phydev->supported, in genphy_read_abilities()
2552 phydev->supported, val & ESTATUS_1000_TFULL); in genphy_read_abilities()
2554 phydev->supported, val & ESTATUS_1000_THALF); in genphy_read_abilities()
2556 phydev->supported, val & ESTATUS_1000_XFULL); in genphy_read_abilities()
2563 /* This is used for the phy device which doesn't support the MMD extended
2569 return -EOPNOTSUPP; in genphy_read_mmd_unsupported()
2576 return -EOPNOTSUPP; in genphy_write_mmd_unsupported()
2600 * phy_remove_link_mode - Remove a supported link mode
2604 * Description: Some MACs don't support all link modes which the PHY
2610 linkmode_clear_bit(link_mode, phydev->supported); in phy_remove_link_mode()
2624 * phy_advertise_supported - Advertise all supported modes
2634 linkmode_copy(new, phydev->supported); in phy_advertise_supported()
2635 phy_copy_pause_bits(new, phydev->advertising); in phy_advertise_supported()
2636 linkmode_copy(phydev->advertising, new); in phy_advertise_supported()
2641 * phy_support_sym_pause - Enable support of symmetrical pause
2649 linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydev->supported); in phy_support_sym_pause()
2650 phy_copy_pause_bits(phydev->advertising, phydev->supported); in phy_support_sym_pause()
2655 * phy_support_asym_pause - Enable support of asym pause
2662 phy_copy_pause_bits(phydev->advertising, phydev->supported); in phy_support_asym_pause()
2667 * phy_set_sym_pause - Configure symmetric Pause
2680 linkmode_clear_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported); in phy_set_sym_pause()
2684 phydev->supported); in phy_set_sym_pause()
2686 linkmode_copy(phydev->advertising, phydev->supported); in phy_set_sym_pause()
2691 * phy_set_asym_pause - Configure Pause and Asym Pause
2705 linkmode_copy(oldadv, phydev->advertising); in phy_set_asym_pause()
2706 linkmode_set_pause(phydev->advertising, tx, rx); in phy_set_asym_pause()
2708 if (!linkmode_equal(oldadv, phydev->advertising) && in phy_set_asym_pause()
2709 phydev->autoneg) in phy_set_asym_pause()
2715 * phy_validate_pause - Test if the PHY/MAC support the pause configuration
2719 * Description: Test if the PHY/MAC combination supports the Pause
2727 phydev->supported) && pp->rx_pause) in phy_validate_pause()
2731 phydev->supported) && in phy_validate_pause()
2732 pp->rx_pause != pp->tx_pause) in phy_validate_pause()
2740 * phy_get_pause - resolve negotiated pause modes
2753 if (phydev->duplex != DUPLEX_FULL) { in phy_get_pause()
2759 return linkmode_resolve_pause(phydev->advertising, in phy_get_pause()
2760 phydev->lp_advertising, in phy_get_pause()
2766 static int phy_get_int_delay_property(struct device *dev, const char *name) in phy_get_int_delay_property()
2778 static int phy_get_int_delay_property(struct device *dev, const char *name) in phy_get_int_delay_property()
2780 return -EINVAL; in phy_get_int_delay_property()
2785 * phy_get_delay_index - returns the index of the internal delay
2787 * @dev: pointer to the devices device struct
2788 * @delay_values: array of delays the PHY supports
2793 * If the device property is not present then the interface type is checked
2796 * The array must be in ascending order. If PHY does not have an ascending order
2798 * Return -EINVAL if the delay is invalid or cannot be found.
2800 s32 phy_get_internal_delay(struct phy_device *phydev, struct device *dev, in phy_get_internal_delay()
2807 delay = phy_get_int_delay_property(dev, "rx-internal-delay-ps"); in phy_get_internal_delay()
2809 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in phy_get_internal_delay()
2810 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in phy_get_internal_delay()
2817 delay = phy_get_int_delay_property(dev, "tx-internal-delay-ps"); in phy_get_internal_delay()
2819 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in phy_get_internal_delay()
2820 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in phy_get_internal_delay()
2833 if (delay < delay_values[0] || delay > delay_values[size - 1]) { in phy_get_internal_delay()
2835 return -EINVAL; in phy_get_internal_delay()
2846 if (delay > delay_values[i - 1] && in phy_get_internal_delay()
2848 if (delay - delay_values[i - 1] < in phy_get_internal_delay()
2849 delay_values[i] - delay) in phy_get_internal_delay()
2850 return i - 1; in phy_get_internal_delay()
2859 return -EINVAL; in phy_get_internal_delay()
2865 return phydrv->config_intr && phydrv->ack_interrupt; in phy_drv_supports_irq()
2869 * phy_probe - probe and init a PHY device
2870 * @dev: device to probe and init
2876 static int phy_probe(struct device *dev) in phy_probe()
2879 struct device_driver *drv = phydev->mdio.dev.driver; in phy_probe()
2883 phydev->drv = phydrv; in phy_probe()
2885 /* Disable the interrupt if the PHY doesn't support it in phy_probe()
2889 phydev->irq = PHY_POLL; in phy_probe()
2891 if (phydrv->flags & PHY_IS_INTERNAL) in phy_probe()
2892 phydev->is_internal = true; in phy_probe()
2894 mutex_lock(&phydev->lock); in phy_probe()
2899 if (phydev->drv->probe) { in phy_probe()
2900 err = phydev->drv->probe(phydev); in phy_probe()
2909 if (phydrv->features) { in phy_probe()
2910 linkmode_copy(phydev->supported, phydrv->features); in phy_probe()
2911 } else if (phydrv->get_features) { in phy_probe()
2912 err = phydrv->get_features(phydev); in phy_probe()
2913 } else if (phydev->is_c45) { in phy_probe()
2923 phydev->supported)) in phy_probe()
2924 phydev->autoneg = 0; in phy_probe()
2927 phydev->supported)) in phy_probe()
2928 phydev->is_gigabit_capable = 1; in phy_probe()
2930 phydev->supported)) in phy_probe()
2931 phydev->is_gigabit_capable = 1; in phy_probe()
2937 * the PHY stop advertising these mode later on in phy_probe()
2941 /* The Pause Frame bits indicate that the PHY can support passing in phy_probe()
2947 * Normally, PHY drivers should not set the Pause bits, and instead in phy_probe()
2952 if (!test_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported) && in phy_probe()
2953 !test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydev->supported)) { in phy_probe()
2955 phydev->supported); in phy_probe()
2957 phydev->supported); in phy_probe()
2961 phydev->state = PHY_READY; in phy_probe()
2968 mutex_unlock(&phydev->lock); in phy_probe()
2973 static int phy_remove(struct device *dev) in phy_remove()
2977 cancel_delayed_work_sync(&phydev->state_queue); in phy_remove()
2979 mutex_lock(&phydev->lock); in phy_remove()
2980 phydev->state = PHY_DOWN; in phy_remove()
2981 mutex_unlock(&phydev->lock); in phy_remove()
2983 sfp_bus_del_upstream(phydev->sfp_bus); in phy_remove()
2984 phydev->sfp_bus = NULL; in phy_remove()
2986 if (phydev->drv && phydev->drv->remove) in phy_remove()
2987 phydev->drv->remove(phydev); in phy_remove()
2992 phydev->drv = NULL; in phy_remove()
2998 * phy_driver_register - register a phy_driver with the PHY layer
3000 * @owner: module owning this PHY
3009 if (WARN_ON(new_driver->features && new_driver->get_features)) { in phy_driver_register()
3011 new_driver->name); in phy_driver_register()
3012 return -EINVAL; in phy_driver_register()
3015 new_driver->mdiodrv.flags |= MDIO_DEVICE_IS_PHY; in phy_driver_register()
3016 new_driver->mdiodrv.driver.name = new_driver->name; in phy_driver_register()
3017 new_driver->mdiodrv.driver.bus = &mdio_bus_type; in phy_driver_register()
3018 new_driver->mdiodrv.driver.probe = phy_probe; in phy_driver_register()
3019 new_driver->mdiodrv.driver.remove = phy_remove; in phy_driver_register()
3020 new_driver->mdiodrv.driver.owner = owner; in phy_driver_register()
3021 new_driver->mdiodrv.driver.probe_type = PROBE_FORCE_SYNCHRONOUS; in phy_driver_register()
3023 retval = driver_register(&new_driver->mdiodrv.driver); in phy_driver_register()
3026 new_driver->name, retval); in phy_driver_register()
3031 pr_debug("%s: Registered new driver\n", new_driver->name); in phy_driver_register()
3045 while (i-- > 0) in phy_drivers_register()
3056 driver_unregister(&drv->mdiodrv.driver); in phy_driver_unregister()
3072 .name = "Generic PHY",