Lines Matching +full:ethernet +full:- +full:phy +full:- +full:package
1 // SPDX-License-Identifier: GPL-2.0+
3 * Core PHY library, taken from phy.c
6 #include <linux/phy.h>
10 * phy_speed_to_str - Return a string representing the PHY link speed
19 "and the PHY settings array.\n"); in phy_speed_to_str()
57 return "Unsupported (update phy-core.c)"; in phy_speed_to_str()
63 * phy_duplex_to_str - Return string describing the duplex
75 return "Unsupported (update phy-core.c)"; in phy_duplex_to_str()
80 * phy_rate_matching_to_str - Return a string describing the rate matching
94 return "open-loop"; in phy_rate_matching_to_str()
96 return "Unsupported (update phy-core.c)"; in phy_rate_matching_to_str()
101 * phy_interface_num_ports - Return the number of links that can be carried by
102 * a given MAC-PHY physical link. Returns 0 if this is
158 * - iow, descending speed.
274 * phy_lookup_setting - lookup a PHY setting
297 if (p->bit < __ETHTOOL_LINK_MODE_MASK_NBITS && in phy_lookup_setting()
298 test_bit(p->bit, mask)) { in phy_lookup_setting()
300 if (p->speed == speed && p->duplex == duplex) { in phy_lookup_setting()
305 if (!match && p->speed <= speed) in phy_lookup_setting()
309 if (p->speed < speed) in phy_lookup_setting()
331 (count == 0 || speeds[count - 1] != settings[i].speed)) in phy_speeds()
343 if (p->speed > max_speed) in __set_linkmode_max_speed()
344 linkmode_clear_bit(p->bit, addr); in __set_linkmode_max_speed()
352 __set_linkmode_max_speed(max_speed, phydev->supported); in __set_phy_supported()
356 * phy_set_max_speed - Set the maximum speed the PHY should support
361 * The PHY might be more capable than the MAC. For example a Fast Ethernet
362 * is connected to a 1G PHY. This function allows the MAC to indicate its
363 * maximum speed, and so limit what the PHY will advertise.
375 struct device_node *node = phydev->mdio.dev.of_node; in of_set_phy_supported()
384 if (!of_property_read_u32(node, "max-speed", &max_speed)) in of_set_phy_supported()
390 struct device_node *node = phydev->mdio.dev.of_node; in of_set_phy_eee_broken()
399 if (of_property_read_bool(node, "eee-broken-100tx")) in of_set_phy_eee_broken()
401 if (of_property_read_bool(node, "eee-broken-1000t")) in of_set_phy_eee_broken()
403 if (of_property_read_bool(node, "eee-broken-10gt")) in of_set_phy_eee_broken()
405 if (of_property_read_bool(node, "eee-broken-1000kx")) in of_set_phy_eee_broken()
407 if (of_property_read_bool(node, "eee-broken-10gkx4")) in of_set_phy_eee_broken()
409 if (of_property_read_bool(node, "eee-broken-10gkr")) in of_set_phy_eee_broken()
412 phydev->eee_broken_modes = broken; in of_set_phy_eee_broken()
416 * phy_resolve_aneg_pause - Determine pause autoneg results
427 if (phydev->duplex == DUPLEX_FULL) { in phy_resolve_aneg_pause()
428 phydev->pause = linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT, in phy_resolve_aneg_pause()
429 phydev->lp_advertising); in phy_resolve_aneg_pause()
430 phydev->asym_pause = linkmode_test_bit( in phy_resolve_aneg_pause()
432 phydev->lp_advertising); in phy_resolve_aneg_pause()
438 * phy_resolve_aneg_linkmode - resolve the advertisements into PHY settings
450 linkmode_and(common, phydev->lp_advertising, phydev->advertising); in phy_resolve_aneg_linkmode()
454 phydev->speed = settings[i].speed; in phy_resolve_aneg_linkmode()
455 phydev->duplex = settings[i].duplex; in phy_resolve_aneg_linkmode()
464 * phy_check_downshift - check whether downshift occurred
469 * Prerequisite for detecting downshift is that PHY driver implements the
470 * read_status callback and sets phydev->speed to the actual link speed.
477 phydev->downshifted_rate = 0; in phy_check_downshift()
479 if (phydev->autoneg == AUTONEG_DISABLE || in phy_check_downshift()
480 phydev->speed == SPEED_UNKNOWN) in phy_check_downshift()
483 linkmode_and(common, phydev->lp_advertising, phydev->advertising); in phy_check_downshift()
491 if (speed == SPEED_UNKNOWN || phydev->speed >= speed) in phy_check_downshift()
495 phy_speed_to_str(speed), phy_speed_to_str(phydev->speed)); in phy_check_downshift()
497 phydev->downshifted_rate = 1; in phy_check_downshift()
506 linkmode_and(common, phydev->lp_advertising, phydev->advertising); in phy_resolve_min_speed()
508 while (--i >= 0) { in phy_resolve_min_speed()
524 return -EINVAL; in phy_speed_down_core()
526 __set_linkmode_max_speed(min_common_speed, phydev->advertising); in phy_speed_down_core()
568 * __phy_read_mmd - Convenience function for reading a register
569 * from an MMD on a given PHY.
579 return -EINVAL; in __phy_read_mmd()
581 if (phydev->drv && phydev->drv->read_mmd) in __phy_read_mmd()
582 return phydev->drv->read_mmd(phydev, devad, regnum); in __phy_read_mmd()
584 return mmd_phy_read(phydev->mdio.bus, phydev->mdio.addr, in __phy_read_mmd()
585 phydev->is_c45, devad, regnum); in __phy_read_mmd()
590 * phy_read_mmd - Convenience function for reading a register
591 * from an MMD on a given PHY.
611 * __phy_write_mmd - Convenience function for writing a register
612 * on an MMD on a given PHY.
623 return -EINVAL; in __phy_write_mmd()
625 if (phydev->drv && phydev->drv->write_mmd) in __phy_write_mmd()
626 return phydev->drv->write_mmd(phydev, devad, regnum, val); in __phy_write_mmd()
628 return mmd_phy_write(phydev->mdio.bus, phydev->mdio.addr, in __phy_write_mmd()
629 phydev->is_c45, devad, regnum, val); in __phy_write_mmd()
634 * phy_write_mmd - Convenience function for writing a register
635 * on an MMD on a given PHY.
656 * __phy_package_read_mmd - read MMD reg relative to PHY package base addr
658 * @addr_offset: The offset to be added to PHY package base_addr
662 * Convenience helper for reading a register of an MMD on a given PHY
663 * using the PHY package base address. The base address is added to
668 * NOTE: It's assumed that the entire PHY package is either C22 or C45.
680 return -EINVAL; in __phy_package_read_mmd()
682 return mmd_phy_read(phydev->mdio.bus, addr, phydev->is_c45, devad, in __phy_package_read_mmd()
688 * phy_package_read_mmd - read MMD reg relative to PHY package base addr
690 * @addr_offset: The offset to be added to PHY package base_addr
694 * Convenience helper for reading a register of an MMD on a given PHY
695 * using the PHY package base address. The base address is added to
700 * NOTE: It's assumed that the entire PHY package is either C22 or C45.
713 return -EINVAL; in phy_package_read_mmd()
716 val = mmd_phy_read(phydev->mdio.bus, addr, phydev->is_c45, devad, in phy_package_read_mmd()
725 * __phy_package_write_mmd - write MMD reg relative to PHY package base addr
727 * @addr_offset: The offset to be added to PHY package base_addr
732 * Convenience helper for writing a register of an MMD on a given PHY
733 * using the PHY package base address. The base address is added to
738 * NOTE: It's assumed that the entire PHY package is either C22 or C45.
750 return -EINVAL; in __phy_package_write_mmd()
752 return mmd_phy_write(phydev->mdio.bus, addr, phydev->is_c45, devad, in __phy_package_write_mmd()
758 * phy_package_write_mmd - write MMD reg relative to PHY package base addr
760 * @addr_offset: The offset to be added to PHY package base_addr
765 * Convenience helper for writing a register of an MMD on a given PHY
766 * using the PHY package base address. The base address is added to
771 * NOTE: It's assumed that the entire PHY package is either C22 or C45.
784 return -EINVAL; in phy_package_write_mmd()
787 ret = mmd_phy_write(phydev->mdio.bus, addr, phydev->is_c45, devad, in phy_package_write_mmd()
796 * phy_modify_changed - Function for modifying a PHY register
821 * __phy_modify - Convenience function for modifying a PHY register
842 * phy_modify - Convenience function for modifying a given PHY register
865 * __phy_modify_mmd_changed - Function for modifying a register on MMD
897 * phy_modify_mmd_changed - Function for modifying a register on MMD
924 * __phy_modify_mmd - Convenience function for modifying a register on MMD
947 * phy_modify_mmd - Convenience function for modifying a register on MMD
973 …if (WARN_ONCE(!phydev->drv->read_page, "read_page callback not available, PHY driver not loaded?\n… in __phy_read_page()
974 return -EOPNOTSUPP; in __phy_read_page()
976 return phydev->drv->read_page(phydev); in __phy_read_page()
981 …if (WARN_ONCE(!phydev->drv->write_page, "write_page callback not available, PHY driver not loaded?… in __phy_write_page()
982 return -EOPNOTSUPP; in __phy_write_page()
984 return phydev->drv->write_page(phydev, page); in __phy_write_page()
988 * phy_save_page() - take the bus lock and save the current page
1003 * phy_select_page() - take the bus lock, save the current page, and set a page
1008 * current PHY page, and set the current page. On error, returns a
1032 * phy_restore_page() - restore the page register and release the bus lock
1060 /* Propagate the phy page selection error code */ in phy_restore_page()
1071 * phy_read_paged() - Convenience function for reading a paged register
1073 * @page: the page for the phy
1091 * phy_write_paged() - Convenience function for writing a paged register
1093 * @page: the page for the phy
1112 * phy_modify_paged_changed() - Function for modifying a paged register
1114 * @page: the page for the phy
1135 * phy_modify_paged() - Convenience function for modifying a paged register
1137 * @page: the page for the phy