Lines Matching +full:auto +full:- +full:poll

1 // SPDX-License-Identifier: GPL-2.0+
6 * Author: Frank <Frank.Sae@motor-comm.com>
22 * ------------------------------------------------------------
26 * ------------------------------------------------------------
28 * ------------------------------------------------------------
86 /* Speed Auto Downgrade Control Register */
104 /* FIBER Auto-Negotiation link partner ability */
125 /* TX Gig-E Delay is bits 7:4, default 0x5
126 * TX Fast-E Delay is bits 15:12, default 0xf
127 * Delay = 150ps * N - 250ps
186 /* 3 phy polling modes,poll mode combines utp and fiber mode*/
375 * ytphy_read_ext() - read a PHY's extended register
395 * ytphy_read_ext_with_lock() - read a PHY's extended register
413 * ytphy_write_ext() - write a PHY's extended register
434 * ytphy_write_ext_with_lock() - write a PHY's extended register
454 * ytphy_modify_ext() - bits modify a PHY's extended register
479 * ytphy_modify_ext_with_lock() - bits modify a PHY's extended register
503 * ytphy_get_wol() - report whether wake-on-lan is enabled
514 wol->supported = WAKE_MAGIC; in ytphy_get_wol()
515 wol->wolopts = 0; in ytphy_get_wol()
522 wol->wolopts |= WAKE_MAGIC; in ytphy_get_wol()
526 * ytphy_set_wol() - turn wake-on-lan on or off
551 if (wol->wolopts & WAKE_MAGIC) { in ytphy_set_wol()
552 p_attached_dev = phydev->attached_dev; in ytphy_set_wol()
554 return -ENODEV; in ytphy_set_wol()
556 mac_addr = (const u8 *)p_attached_dev->dev_addr; in ytphy_set_wol()
558 return -EINVAL; in ytphy_set_wol()
621 if (wol->wolopts & WAKE_MAGIC) { in yt8531_set_wol()
622 mac_addr = phydev->attached_dev->dev_addr; in yt8531_set_wol()
683 switch (phydev->interface) { in yt8511_config_init()
701 ret = -EOPNOTSUPP; in yt8511_config_init()
737 * yt8521_read_page() - read reg page
758 * yt8521_write_page() - write reg page
778 * struct ytphy_cfg_reg_map - map a config value to a register value
832 struct device_node *node = phydev->mdio.dev.of_node; in ytphy_get_delay_reg_value()
876 rx_reg = ytphy_get_delay_reg_value(phydev, "rx-internal-delay-ps", in ytphy_rgmii_clk_delay_config()
880 tx_reg = ytphy_get_delay_reg_value(phydev, "tx-internal-delay-ps", in ytphy_rgmii_clk_delay_config()
884 switch (phydev->interface) { in ytphy_rgmii_clk_delay_config()
900 return -EOPNOTSUPP; in ytphy_rgmii_clk_delay_config()
925 * struct ytphy_ldo_vol_map - map a current value to a register value
976 return -EINVAL; in yt8531_get_ds_map()
981 struct device_node *node = phydev->mdio.dev.of_node; in yt8531_set_ds()
986 if (!of_property_read_u32(node, "motorcomm,rx-clk-drv-microamp", &val)) { in yt8531_set_ds()
989 return dev_err_probe(&phydev->mdio.dev, ds, in yt8531_set_ds()
1003 if (!of_property_read_u32(node, "motorcomm,rx-data-drv-microamp", &val)) { in yt8531_set_ds()
1006 return dev_err_probe(&phydev->mdio.dev, ds, in yt8531_set_ds()
1029 * yt8521_probe() - read chip config then set suitable polling_mode
1036 struct device_node *node = phydev->mdio.dev.of_node; in yt8521_probe()
1037 struct device *dev = &phydev->mdio.dev; in yt8521_probe()
1046 return -ENOMEM; in yt8521_probe()
1048 phydev->priv = priv; in yt8521_probe()
1054 priv->strap_mode = chip_config & YT8521_CCR_MODE_SEL_MASK; in yt8521_probe()
1055 switch (priv->strap_mode) { in yt8521_probe()
1059 priv->polling_mode = YT8521_MODE_FIBER; in yt8521_probe()
1060 priv->reg_page = YT8521_RSSR_FIBER_SPACE; in yt8521_probe()
1061 phydev->port = PORT_FIBRE; in yt8521_probe()
1066 priv->polling_mode = YT8521_MODE_POLL; in yt8521_probe()
1067 priv->reg_page = YT8521_RSSR_TO_BE_ARBITRATED; in yt8521_probe()
1068 phydev->port = PORT_NONE; in yt8521_probe()
1072 priv->polling_mode = YT8521_MODE_UTP; in yt8521_probe()
1073 priv->reg_page = YT8521_RSSR_UTP_SPACE; in yt8521_probe()
1074 phydev->port = PORT_TP; in yt8521_probe()
1078 if (priv->reg_page != YT8521_RSSR_TO_BE_ARBITRATED) { in yt8521_probe()
1081 priv->reg_page); in yt8521_probe()
1086 if (of_property_read_u32(node, "motorcomm,clk-out-frequency-hz", &freq)) in yt8521_probe()
1089 if (phydev->drv->phy_id == PHY_ID_YT8521) { in yt8521_probe()
1114 return -EINVAL; in yt8521_probe()
1116 } else if (phydev->drv->phy_id == PHY_ID_YT8531S) { in yt8521_probe()
1141 return -EINVAL; in yt8521_probe()
1145 return -EINVAL; in yt8521_probe()
1154 struct device_node *node = phydev->mdio.dev.of_node; in yt8531_probe()
1158 if (of_property_read_u32(node, "motorcomm,clk-out-frequency-hz", &freq)) in yt8531_probe()
1182 return -EINVAL; in yt8531_probe()
1190 * ytphy_utp_read_lpa() - read LPA then setup lp_advertising for utp
1201 if (phydev->autoneg == AUTONEG_ENABLE) { in ytphy_utp_read_lpa()
1202 if (!phydev->autoneg_complete) { in ytphy_utp_read_lpa()
1203 mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, in ytphy_utp_read_lpa()
1205 mii_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, 0); in ytphy_utp_read_lpa()
1209 if (phydev->is_gigabit_capable) { in ytphy_utp_read_lpa()
1224 return -ENOLINK; in ytphy_utp_read_lpa()
1227 mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, in ytphy_utp_read_lpa()
1235 mii_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); in ytphy_utp_read_lpa()
1237 linkmode_zero(phydev->lp_advertising); in ytphy_utp_read_lpa()
1244 * yt8521_adjust_status() - update speed and duplex to phydev. when in fiber
1290 phydev->speed = speed; in yt8521_adjust_status()
1291 phydev->duplex = duplex; in yt8521_adjust_status()
1306 phydev->lp_advertising, lpa & LPA_1000XFULL); in yt8521_adjust_status()
1309 phydev->pause = 0; in yt8521_adjust_status()
1310 phydev->asym_pause = 0; in yt8521_adjust_status()
1312 phydev->pause = 1; in yt8521_adjust_status()
1313 phydev->asym_pause = 1; in yt8521_adjust_status()
1315 phydev->pause = 1; in yt8521_adjust_status()
1316 phydev->asym_pause = 0; in yt8521_adjust_status()
1324 * yt8521_read_status_paged() - determines the speed and duplex of one page
1340 linkmode_zero(phydev->lp_advertising); in yt8521_read_status_paged()
1341 phydev->duplex = DUPLEX_UNKNOWN; in yt8521_read_status_paged()
1342 phydev->speed = SPEED_UNKNOWN; in yt8521_read_status_paged()
1343 phydev->asym_pause = 0; in yt8521_read_status_paged()
1344 phydev->pause = 0; in yt8521_read_status_paged()
1395 phydev->autoneg_complete = ret & BMSR_ANEGCOMPLETE ? 1 : 0; in yt8521_read_status_paged()
1411 * yt8521_read_status() - determines the negotiated speed and duplex
1418 struct yt8521_priv *priv = phydev->priv; in yt8521_read_status()
1424 if (priv->reg_page != YT8521_RSSR_TO_BE_ARBITRATED) { in yt8521_read_status()
1425 link = yt8521_read_status_paged(phydev, priv->reg_page); in yt8521_read_status()
1449 if (phydev->link == 0) { in yt8521_read_status()
1451 if (priv->polling_mode == YT8521_MODE_POLL && in yt8521_read_status()
1452 priv->reg_page == YT8521_RSSR_TO_BE_ARBITRATED) { in yt8521_read_status()
1454 priv->reg_page = in yt8521_read_status()
1457 priv->reg_page = YT8521_RSSR_UTP_SPACE; in yt8521_read_status()
1461 priv->reg_page); in yt8521_read_status()
1465 phydev->port = link_fiber ? PORT_FIBRE : PORT_TP; in yt8521_read_status()
1469 (phydev->port == PORT_TP) ? in yt8521_read_status()
1473 phydev->link = 1; in yt8521_read_status()
1475 if (phydev->link == 1) { in yt8521_read_status()
1477 __func__, (phydev->port == PORT_TP) ? in yt8521_read_status()
1483 if (priv->polling_mode == YT8521_MODE_POLL) { in yt8521_read_status()
1484 priv->reg_page = YT8521_RSSR_TO_BE_ARBITRATED; in yt8521_read_status()
1485 phydev->port = PORT_NONE; in yt8521_read_status()
1489 phydev->link = 0; in yt8521_read_status()
1496 * yt8521_modify_bmcr_paged - bits modify a PHY's BMCR register of one page
1504 * YT8521 has two space (utp/fiber) and three mode (utp/fiber/poll), each space
1505 * has MII_BMCR. poll mode combines utp and faber,so need do both.
1527 while (max_cnt--) { in yt8521_modify_bmcr_paged()
1543 * yt8521_modify_utp_fiber_bmcr - bits modify a PHY's BMCR register
1550 * YT8521 has two space (utp/fiber) and three mode (utp/fiber/poll), each space
1551 * has MII_BMCR. poll mode combines utp and faber,so need do both.
1558 struct yt8521_priv *priv = phydev->priv; in yt8521_modify_utp_fiber_bmcr()
1561 if (priv->reg_page != YT8521_RSSR_TO_BE_ARBITRATED) { in yt8521_modify_utp_fiber_bmcr()
1562 ret = yt8521_modify_bmcr_paged(phydev, priv->reg_page, mask, in yt8521_modify_utp_fiber_bmcr()
1581 * yt8521_soft_reset() - called to issue a PHY software reset
1592 * yt8521_suspend() - suspend the hardware
1614 * yt8521_resume() - resume the hardware
1624 /* disable auto sleep */ in yt8521_resume()
1643 * yt8521_config_init() - called to initialize the PHY
1650 struct device_node *node = phydev->mdio.dev.of_node; in yt8521_config_init()
1659 if (phydev->interface != PHY_INTERFACE_MODE_SGMII) { in yt8521_config_init()
1665 if (of_property_read_bool(node, "motorcomm,auto-sleep-disabled")) { in yt8521_config_init()
1666 /* disable auto sleep */ in yt8521_config_init()
1673 if (of_property_read_bool(node, "motorcomm,keep-pll-enabled")) { in yt8521_config_init()
1686 struct device_node *node = phydev->mdio.dev.of_node; in yt8531_config_init()
1693 if (of_property_read_bool(node, "motorcomm,auto-sleep-disabled")) { in yt8531_config_init()
1694 /* disable auto sleep */ in yt8531_config_init()
1702 if (of_property_read_bool(node, "motorcomm,keep-pll-enabled")) { in yt8531_config_init()
1719 * yt8531_link_change_notify() - Adjust the tx clock direction according to
1724 * keep "motorcomm,tx-clk-adj-enabled" not exist in dts when the soc is not
1729 struct device_node *node = phydev->mdio.dev.of_node; in yt8531_link_change_notify()
1737 if (of_property_read_bool(node, "motorcomm,tx-clk-adj-enabled")) in yt8531_link_change_notify()
1743 if (of_property_read_bool(node, "motorcomm,tx-clk-10-inverted")) in yt8531_link_change_notify()
1745 if (of_property_read_bool(node, "motorcomm,tx-clk-100-inverted")) in yt8531_link_change_notify()
1747 if (of_property_read_bool(node, "motorcomm,tx-clk-1000-inverted")) in yt8531_link_change_notify()
1750 if (phydev->speed < 0) in yt8531_link_change_notify()
1753 switch (phydev->speed) { in yt8531_link_change_notify()
1777 * yt8521_prepare_fiber_features() - A small helper function that setup
1792 * yt8521_fiber_setup_forced - configures/forces speed from @phydev
1804 if (phydev->speed == SPEED_1000) in yt8521_fiber_setup_forced()
1806 else if (phydev->speed == SPEED_100) in yt8521_fiber_setup_forced()
1809 return -EINVAL; in yt8521_fiber_setup_forced()
1815 /* disable Fiber auto sensing */ in yt8521_fiber_setup_forced()
1831 * ytphy_check_and_restart_aneg - Enable and restart auto-negotiation
1865 * yt8521_fiber_config_aneg - restart auto-negotiation or write
1879 if (phydev->autoneg != AUTONEG_ENABLE) in yt8521_fiber_config_aneg()
1882 /* enable Fiber auto sensing */ in yt8521_fiber_config_aneg()
1906 adv = linkmode_adv_to_mii_adv_x(phydev->advertising, in yt8521_fiber_config_aneg()
1936 if (!phydev->is_gigabit_capable) in ytphy_setup_master_slave()
1939 switch (phydev->master_slave_set) { in ytphy_setup_master_slave()
1956 return -EOPNOTSUPP; in ytphy_setup_master_slave()
1965 * ytphy_utp_config_advert - sanitize and advertise auto-negotiation parameters
1982 linkmode_and(phydev->advertising, phydev->advertising, in ytphy_utp_config_advert()
1983 phydev->supported); in ytphy_utp_config_advert()
1985 adv = linkmode_adv_to_mii_adv_t(phydev->advertising); in ytphy_utp_config_advert()
2001 /* Per 802.3-2008, Section 22.2.4.2.16 Extended status all in ytphy_utp_config_advert()
2008 adv = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising); in ytphy_utp_config_advert()
2022 * ytphy_utp_config_aneg - restart auto-negotiation or write BMCR
2026 * NOTE: If auto-negotiation is enabled, we configure the
2027 * advertising, and then restart auto-negotiation. If it is not
2044 if (phydev->autoneg != AUTONEG_ENABLE) { in ytphy_utp_config_aneg()
2047 ctl = mii_bmcr_encode_fixed(phydev->speed, phydev->duplex); in ytphy_utp_config_aneg()
2063 * yt8521_config_aneg_paged() - switch reg space then call genphy_config_aneg
2074 struct yt8521_priv *priv = phydev->priv; in yt8521_config_aneg_paged()
2085 * phydev->advertising should be updated. in yt8521_config_aneg_paged()
2087 if (priv->reg_page == YT8521_RSSR_TO_BE_ARBITRATED) { in yt8521_config_aneg_paged()
2097 linkmode_and(phydev->advertising, in yt8521_config_aneg_paged()
2098 priv->combo_advertising, fiber_supported); in yt8521_config_aneg_paged()
2103 linkmode_andnot(phydev->advertising, in yt8521_config_aneg_paged()
2104 priv->combo_advertising, in yt8521_config_aneg_paged()
2119 * yt8521_config_aneg() - change reg space then call yt8521_config_aneg_paged
2126 struct yt8521_priv *priv = phydev->priv; in yt8521_config_aneg()
2129 if (priv->reg_page != YT8521_RSSR_TO_BE_ARBITRATED) { in yt8521_config_aneg()
2130 ret = yt8521_config_aneg_paged(phydev, priv->reg_page); in yt8521_config_aneg()
2135 * phydev->advertising need to be saved at first run. in yt8521_config_aneg()
2139 if (linkmode_empty(priv->combo_advertising)) { in yt8521_config_aneg()
2140 linkmode_copy(priv->combo_advertising, in yt8521_config_aneg()
2141 phydev->advertising); in yt8521_config_aneg()
2153 * phydev->advertising as default value. in yt8521_config_aneg()
2155 linkmode_copy(phydev->advertising, priv->combo_advertising); in yt8521_config_aneg()
2161 * yt8521_aneg_done_paged() - determines the auto negotiation result of one
2191 * yt8521_aneg_done() - determines the auto negotiation result
2198 struct yt8521_priv *priv = phydev->priv; in yt8521_aneg_done()
2203 if (priv->reg_page != YT8521_RSSR_TO_BE_ARBITRATED) { in yt8521_aneg_done()
2204 link = yt8521_aneg_done_paged(phydev, priv->reg_page); in yt8521_aneg_done()
2226 * ytphy_utp_read_abilities - read PHY abilities from Clause 22 registers
2230 * phydev->supported accordingly.
2241 phydev->supported); in ytphy_utp_read_abilities()
2247 linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported, in ytphy_utp_read_abilities()
2250 linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, phydev->supported, in ytphy_utp_read_abilities()
2252 linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, phydev->supported, in ytphy_utp_read_abilities()
2254 linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, phydev->supported, in ytphy_utp_read_abilities()
2256 linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT, phydev->supported, in ytphy_utp_read_abilities()
2265 phydev->supported, val & ESTATUS_1000_TFULL); in ytphy_utp_read_abilities()
2267 phydev->supported, val & ESTATUS_1000_THALF); in ytphy_utp_read_abilities()
2269 phydev->supported, val & ESTATUS_1000_XFULL); in ytphy_utp_read_abilities()
2276 * yt8521_get_features_paged() - read supported link modes for one page
2294 linkmode_zero(phydev->supported); in yt8521_get_features_paged()
2295 yt8521_prepare_fiber_features(phydev, phydev->supported); in yt8521_get_features_paged()
2307 * yt8521_get_features - switch reg space then call yt8521_get_features_paged
2314 struct yt8521_priv *priv = phydev->priv; in yt8521_get_features()
2317 if (priv->reg_page != YT8521_RSSR_TO_BE_ARBITRATED) { in yt8521_get_features()
2318 ret = yt8521_get_features_paged(phydev, priv->reg_page); in yt8521_get_features()
2325 /* add fiber's features to phydev->supported */ in yt8521_get_features()
2326 yt8521_prepare_fiber_features(phydev, phydev->supported); in yt8521_get_features()
2332 * yt8821_get_features - read mmd register to get 2.5G capability
2349 * yt8821_get_rate_matching - read register to get phy chip mode
2372 * yt8821_aneg_done() - determines the auto negotiation result
2383 * yt8821_serdes_init() - serdes init
2417 * yt8821_utp_init() - utp init
2609 * yt8821_auto_sleep_config() - phy auto sleep config
2611 * @enable: true enable auto sleep, false disable auto sleep
2638 * yt8821_soft_reset() - soft reset utp and serdes
2650 * yt8821_config_init() - phy initializatioin
2661 if (phydev->interface == PHY_INTERFACE_MODE_2500BASEX) in yt8821_config_init()
2673 phydev->possible_interfaces); in yt8821_config_init()
2677 phydev->possible_interfaces); in yt8821_config_init()
2679 phydev->rate_matching = RATE_MATCH_NONE; in yt8821_config_init()
2681 phydev->rate_matching = RATE_MATCH_PAUSE; in yt8821_config_init()
2692 /* disable auto sleep */ in yt8821_config_init()
2702 * yt8821_adjust_status() - update speed and duplex to phydev
2731 phydev->speed = speed; in yt8821_adjust_status()
2732 phydev->duplex = duplex; in yt8821_adjust_status()
2736 * yt8821_update_interface() - update interface per current speed
2741 if (!phydev->link) in yt8821_update_interface()
2744 switch (phydev->speed) { in yt8821_update_interface()
2746 phydev->interface = PHY_INTERFACE_MODE_2500BASEX; in yt8821_update_interface()
2751 phydev->interface = PHY_INTERFACE_MODE_SGMII; in yt8821_update_interface()
2754 phydev_warn(phydev, "phy speed err :%d\n", phydev->speed); in yt8821_update_interface()
2760 * yt8821_read_status() - determines the negotiated speed and duplex
2781 if (phydev->autoneg_complete) { in yt8821_read_status()
2798 if (phydev->link == 0) in yt8821_read_status()
2801 __func__, phydev->mdio.addr); in yt8821_read_status()
2802 phydev->link = 1; in yt8821_read_status()
2804 if (phydev->link == 1) in yt8821_read_status()
2807 __func__, phydev->mdio.addr); in yt8821_read_status()
2808 phydev->link = 0; in yt8821_read_status()
2823 * yt8821_modify_utp_fiber_bmcr - bits modify a PHY's BMCR register
2848 * yt8821_suspend() - suspend the hardware
2870 * yt8821_resume() - resume the hardware
2880 /* disable auto sleep */ in yt8821_resume()