Lines Matching +full:tx +full:- +full:clk +full:- +full:1000 +full:- +full:inverted
1 // SPDX-License-Identifier: GPL-2.0+
6 * Author: Frank <Frank.Sae@motor-comm.com>
22 * ------------------------------------------------------------
26 * ------------------------------------------------------------
28 * ------------------------------------------------------------
104 /* FIBER Auto-Negotiation link partner ability */
122 /* RX Delay enabled = 1.8ns 1000T, 8ns 10/100T */
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
193 * 1b1 use inverted tx_clk_rgmii.
298 * ytphy_read_ext() - read a PHY's extended register
318 * ytphy_read_ext_with_lock() - read a PHY's extended register
336 * ytphy_write_ext() - write a PHY's extended register
357 * ytphy_write_ext_with_lock() - write a PHY's extended register
377 * ytphy_modify_ext() - bits modify a PHY's extended register
402 * ytphy_modify_ext_with_lock() - bits modify a PHY's extended register
426 * ytphy_get_wol() - report whether wake-on-lan is enabled
437 wol->supported = WAKE_MAGIC; in ytphy_get_wol()
438 wol->wolopts = 0; in ytphy_get_wol()
445 wol->wolopts |= WAKE_MAGIC; in ytphy_get_wol()
449 * ytphy_set_wol() - turn wake-on-lan on or off
474 if (wol->wolopts & WAKE_MAGIC) { in ytphy_set_wol()
475 p_attached_dev = phydev->attached_dev; in ytphy_set_wol()
477 return -ENODEV; in ytphy_set_wol()
479 mac_addr = (const u8 *)p_attached_dev->dev_addr; in ytphy_set_wol()
481 return -EINVAL; in ytphy_set_wol()
544 if (wol->wolopts & WAKE_MAGIC) { in yt8531_set_wol()
545 mac_addr = phydev->attached_dev->dev_addr; in yt8531_set_wol()
606 switch (phydev->interface) { in yt8511_config_init()
624 ret = -EOPNOTSUPP; in yt8511_config_init()
660 * yt8521_read_page() - read reg page
681 * yt8521_write_page() - write reg page
701 * struct ytphy_cfg_reg_map - map a config value to a register value
711 /* for tx delay / rx delay with YT8521_CCR_RXC_DLY_EN is not set. */
725 { 1950, YT8521_RC1R_RGMII_1_950_NS }, /* default tx/rx delay */
755 struct device_node *node = phydev->mdio.dev.of_node; in ytphy_get_delay_reg_value()
763 /* when rxc_dly_en is NULL, it is get the delay for tx, only half of in ytphy_get_delay_reg_value()
799 rx_reg = ytphy_get_delay_reg_value(phydev, "rx-internal-delay-ps", in ytphy_rgmii_clk_delay_config()
803 tx_reg = ytphy_get_delay_reg_value(phydev, "tx-internal-delay-ps", in ytphy_rgmii_clk_delay_config()
807 switch (phydev->interface) { in ytphy_rgmii_clk_delay_config()
823 return -EOPNOTSUPP; in ytphy_rgmii_clk_delay_config()
848 * struct ytphy_ldo_vol_map - map a current value to a register value
899 return -EINVAL; in yt8531_get_ds_map()
904 struct device_node *node = phydev->mdio.dev.of_node; in yt8531_set_ds()
908 /* set rgmii rx clk driver strength */ in yt8531_set_ds()
909 if (!of_property_read_u32(node, "motorcomm,rx-clk-drv-microamp", &val)) { in yt8531_set_ds()
912 return dev_err_probe(&phydev->mdio.dev, ds, in yt8531_set_ds()
926 if (!of_property_read_u32(node, "motorcomm,rx-data-drv-microamp", &val)) { in yt8531_set_ds()
929 return dev_err_probe(&phydev->mdio.dev, ds, in yt8531_set_ds()
952 * yt8521_probe() - read chip config then set suitable polling_mode
959 struct device_node *node = phydev->mdio.dev.of_node; in yt8521_probe()
960 struct device *dev = &phydev->mdio.dev; in yt8521_probe()
969 return -ENOMEM; in yt8521_probe()
971 phydev->priv = priv; in yt8521_probe()
977 priv->strap_mode = chip_config & YT8521_CCR_MODE_SEL_MASK; in yt8521_probe()
978 switch (priv->strap_mode) { in yt8521_probe()
982 priv->polling_mode = YT8521_MODE_FIBER; in yt8521_probe()
983 priv->reg_page = YT8521_RSSR_FIBER_SPACE; in yt8521_probe()
984 phydev->port = PORT_FIBRE; in yt8521_probe()
989 priv->polling_mode = YT8521_MODE_POLL; in yt8521_probe()
990 priv->reg_page = YT8521_RSSR_TO_BE_ARBITRATED; in yt8521_probe()
991 phydev->port = PORT_NONE; in yt8521_probe()
995 priv->polling_mode = YT8521_MODE_UTP; in yt8521_probe()
996 priv->reg_page = YT8521_RSSR_UTP_SPACE; in yt8521_probe()
997 phydev->port = PORT_TP; in yt8521_probe()
1001 if (priv->reg_page != YT8521_RSSR_TO_BE_ARBITRATED) { in yt8521_probe()
1004 priv->reg_page); in yt8521_probe()
1009 if (of_property_read_u32(node, "motorcomm,clk-out-frequency-hz", &freq)) in yt8521_probe()
1012 if (phydev->drv->phy_id == PHY_ID_YT8521) { in yt8521_probe()
1037 return -EINVAL; in yt8521_probe()
1039 } else if (phydev->drv->phy_id == PHY_ID_YT8531S) { in yt8521_probe()
1064 return -EINVAL; in yt8521_probe()
1068 return -EINVAL; in yt8521_probe()
1077 struct device_node *node = phydev->mdio.dev.of_node; in yt8531_probe()
1081 if (of_property_read_u32(node, "motorcomm,clk-out-frequency-hz", &freq)) in yt8531_probe()
1105 return -EINVAL; in yt8531_probe()
1113 * ytphy_utp_read_lpa() - read LPA then setup lp_advertising for utp
1124 if (phydev->autoneg == AUTONEG_ENABLE) { in ytphy_utp_read_lpa()
1125 if (!phydev->autoneg_complete) { in ytphy_utp_read_lpa()
1126 mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, in ytphy_utp_read_lpa()
1128 mii_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, 0); in ytphy_utp_read_lpa()
1132 if (phydev->is_gigabit_capable) { in ytphy_utp_read_lpa()
1147 return -ENOLINK; in ytphy_utp_read_lpa()
1150 mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, in ytphy_utp_read_lpa()
1158 mii_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); in ytphy_utp_read_lpa()
1160 linkmode_zero(phydev->lp_advertising); in ytphy_utp_read_lpa()
1167 * yt8521_adjust_status() - update speed and duplex to phydev. when in fiber
1214 phydev->speed = speed; in yt8521_adjust_status()
1215 phydev->duplex = duplex; in yt8521_adjust_status()
1228 /* only support 1000baseX Full */ in yt8521_adjust_status()
1230 phydev->lp_advertising, lpa & LPA_1000XFULL); in yt8521_adjust_status()
1233 phydev->pause = 0; in yt8521_adjust_status()
1234 phydev->asym_pause = 0; in yt8521_adjust_status()
1236 phydev->pause = 1; in yt8521_adjust_status()
1237 phydev->asym_pause = 1; in yt8521_adjust_status()
1239 phydev->pause = 1; in yt8521_adjust_status()
1240 phydev->asym_pause = 0; in yt8521_adjust_status()
1248 * yt8521_read_status_paged() - determines the speed and duplex of one page
1264 linkmode_zero(phydev->lp_advertising); in yt8521_read_status_paged()
1265 phydev->duplex = DUPLEX_UNKNOWN; in yt8521_read_status_paged()
1266 phydev->speed = SPEED_UNKNOWN; in yt8521_read_status_paged()
1267 phydev->asym_pause = 0; in yt8521_read_status_paged()
1268 phydev->pause = 0; in yt8521_read_status_paged()
1292 /* When PHY is in fiber mode, speed transferred from 1000Mbps to in yt8521_read_status_paged()
1319 phydev->autoneg_complete = ret & BMSR_ANEGCOMPLETE ? 1 : 0; in yt8521_read_status_paged()
1335 * yt8521_read_status() - determines the negotiated speed and duplex
1342 struct yt8521_priv *priv = phydev->priv; in yt8521_read_status()
1348 if (priv->reg_page != YT8521_RSSR_TO_BE_ARBITRATED) { in yt8521_read_status()
1349 link = yt8521_read_status_paged(phydev, priv->reg_page); in yt8521_read_status()
1373 if (phydev->link == 0) { in yt8521_read_status()
1375 if (priv->polling_mode == YT8521_MODE_POLL && in yt8521_read_status()
1376 priv->reg_page == YT8521_RSSR_TO_BE_ARBITRATED) { in yt8521_read_status()
1378 priv->reg_page = in yt8521_read_status()
1381 priv->reg_page = YT8521_RSSR_UTP_SPACE; in yt8521_read_status()
1385 priv->reg_page); in yt8521_read_status()
1389 phydev->port = link_fiber ? PORT_FIBRE : PORT_TP; in yt8521_read_status()
1393 (phydev->port == PORT_TP) ? in yt8521_read_status()
1397 phydev->link = 1; in yt8521_read_status()
1399 if (phydev->link == 1) { in yt8521_read_status()
1401 __func__, (phydev->port == PORT_TP) ? in yt8521_read_status()
1407 if (priv->polling_mode == YT8521_MODE_POLL) { in yt8521_read_status()
1408 priv->reg_page = YT8521_RSSR_TO_BE_ARBITRATED; in yt8521_read_status()
1409 phydev->port = PORT_NONE; in yt8521_read_status()
1413 phydev->link = 0; in yt8521_read_status()
1420 * yt8521_modify_bmcr_paged - bits modify a PHY's BMCR register of one page
1451 while (max_cnt--) { in yt8521_modify_bmcr_paged()
1452 usleep_range(1000, 1100); in yt8521_modify_bmcr_paged()
1467 * yt8521_modify_utp_fiber_bmcr - bits modify a PHY's BMCR register
1482 struct yt8521_priv *priv = phydev->priv; in yt8521_modify_utp_fiber_bmcr()
1485 if (priv->reg_page != YT8521_RSSR_TO_BE_ARBITRATED) { in yt8521_modify_utp_fiber_bmcr()
1486 ret = yt8521_modify_bmcr_paged(phydev, priv->reg_page, mask, in yt8521_modify_utp_fiber_bmcr()
1505 * yt8521_soft_reset() - called to issue a PHY software reset
1516 * yt8521_suspend() - suspend the hardware
1538 * yt8521_resume() - resume the hardware
1567 * yt8521_config_init() - called to initialize the PHY
1574 struct device_node *node = phydev->mdio.dev.of_node; in yt8521_config_init()
1583 if (phydev->interface != PHY_INTERFACE_MODE_SGMII) { in yt8521_config_init()
1589 if (of_property_read_bool(node, "motorcomm,auto-sleep-disabled")) { in yt8521_config_init()
1597 if (of_property_read_bool(node, "motorcomm,keep-pll-enabled")) { in yt8521_config_init()
1610 struct device_node *node = phydev->mdio.dev.of_node; in yt8531_config_init()
1617 if (of_property_read_bool(node, "motorcomm,auto-sleep-disabled")) { in yt8531_config_init()
1626 if (of_property_read_bool(node, "motorcomm,keep-pll-enabled")) { in yt8531_config_init()
1643 * yt8531_link_change_notify() - Adjust the tx clock direction according to
1648 * keep "motorcomm,tx-clk-adj-enabled" not exist in dts when the soc is not
1653 struct device_node *node = phydev->mdio.dev.of_node; in yt8531_link_change_notify()
1661 if (of_property_read_bool(node, "motorcomm,tx-clk-adj-enabled")) in yt8531_link_change_notify()
1667 if (of_property_read_bool(node, "motorcomm,tx-clk-10-inverted")) in yt8531_link_change_notify()
1669 if (of_property_read_bool(node, "motorcomm,tx-clk-100-inverted")) in yt8531_link_change_notify()
1671 if (of_property_read_bool(node, "motorcomm,tx-clk-1000-inverted")) in yt8531_link_change_notify()
1674 if (phydev->speed < 0) in yt8531_link_change_notify()
1677 switch (phydev->speed) { in yt8531_link_change_notify()
1701 * yt8521_prepare_fiber_features() - A small helper function that setup
1716 * yt8521_fiber_setup_forced - configures/forces speed from @phydev
1728 if (phydev->speed == SPEED_1000) in yt8521_fiber_setup_forced()
1730 else if (phydev->speed == SPEED_100) in yt8521_fiber_setup_forced()
1733 return -EINVAL; in yt8521_fiber_setup_forced()
1755 * ytphy_check_and_restart_aneg - Enable and restart auto-negotiation
1789 * yt8521_fiber_config_aneg - restart auto-negotiation or write
1803 if (phydev->autoneg != AUTONEG_ENABLE) in yt8521_fiber_config_aneg()
1826 usleep_range(1000, 1100); in yt8521_fiber_config_aneg()
1830 adv = linkmode_adv_to_mii_adv_x(phydev->advertising, in yt8521_fiber_config_aneg()
1860 if (!phydev->is_gigabit_capable) in ytphy_setup_master_slave()
1863 switch (phydev->master_slave_set) { in ytphy_setup_master_slave()
1880 return -EOPNOTSUPP; in ytphy_setup_master_slave()
1889 * ytphy_utp_config_advert - sanitize and advertise auto-negotiation parameters
1906 linkmode_and(phydev->advertising, phydev->advertising, in ytphy_utp_config_advert()
1907 phydev->supported); in ytphy_utp_config_advert()
1909 adv = linkmode_adv_to_mii_adv_t(phydev->advertising); in ytphy_utp_config_advert()
1925 /* Per 802.3-2008, Section 22.2.4.2.16 Extended status all in ytphy_utp_config_advert()
1926 * 1000Mbits/sec capable PHYs shall have the BMSR_ESTATEN bit set to a in ytphy_utp_config_advert()
1932 adv = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising); in ytphy_utp_config_advert()
1946 * ytphy_utp_config_aneg - restart auto-negotiation or write BMCR
1950 * NOTE: If auto-negotiation is enabled, we configure the
1951 * advertising, and then restart auto-negotiation. If it is not
1968 if (phydev->autoneg != AUTONEG_ENABLE) { in ytphy_utp_config_aneg()
1971 ctl = mii_bmcr_encode_fixed(phydev->speed, phydev->duplex); in ytphy_utp_config_aneg()
1987 * yt8521_config_aneg_paged() - switch reg space then call genphy_config_aneg
1998 struct yt8521_priv *priv = phydev->priv; in yt8521_config_aneg_paged()
2009 * phydev->advertising should be updated. in yt8521_config_aneg_paged()
2011 if (priv->reg_page == YT8521_RSSR_TO_BE_ARBITRATED) { in yt8521_config_aneg_paged()
2021 linkmode_and(phydev->advertising, in yt8521_config_aneg_paged()
2022 priv->combo_advertising, fiber_supported); in yt8521_config_aneg_paged()
2027 linkmode_andnot(phydev->advertising, in yt8521_config_aneg_paged()
2028 priv->combo_advertising, in yt8521_config_aneg_paged()
2043 * yt8521_config_aneg() - change reg space then call yt8521_config_aneg_paged
2050 struct yt8521_priv *priv = phydev->priv; in yt8521_config_aneg()
2053 if (priv->reg_page != YT8521_RSSR_TO_BE_ARBITRATED) { in yt8521_config_aneg()
2054 ret = yt8521_config_aneg_paged(phydev, priv->reg_page); in yt8521_config_aneg()
2059 * phydev->advertising need to be saved at first run. in yt8521_config_aneg()
2063 if (linkmode_empty(priv->combo_advertising)) { in yt8521_config_aneg()
2064 linkmode_copy(priv->combo_advertising, in yt8521_config_aneg()
2065 phydev->advertising); in yt8521_config_aneg()
2077 * phydev->advertising as default value. in yt8521_config_aneg()
2079 linkmode_copy(phydev->advertising, priv->combo_advertising); in yt8521_config_aneg()
2085 * yt8521_aneg_done_paged() - determines the auto negotiation result of one
2115 * yt8521_aneg_done() - determines the auto negotiation result
2122 struct yt8521_priv *priv = phydev->priv; in yt8521_aneg_done()
2127 if (priv->reg_page != YT8521_RSSR_TO_BE_ARBITRATED) { in yt8521_aneg_done()
2128 link = yt8521_aneg_done_paged(phydev, priv->reg_page); in yt8521_aneg_done()
2150 * ytphy_utp_read_abilities - read PHY abilities from Clause 22 registers
2154 * phydev->supported accordingly.
2165 phydev->supported); in ytphy_utp_read_abilities()
2171 linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported, in ytphy_utp_read_abilities()
2174 linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, phydev->supported, in ytphy_utp_read_abilities()
2176 linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, phydev->supported, in ytphy_utp_read_abilities()
2178 linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, phydev->supported, in ytphy_utp_read_abilities()
2180 linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT, phydev->supported, in ytphy_utp_read_abilities()
2189 phydev->supported, val & ESTATUS_1000_TFULL); in ytphy_utp_read_abilities()
2191 phydev->supported, val & ESTATUS_1000_THALF); in ytphy_utp_read_abilities()
2193 phydev->supported, val & ESTATUS_1000_XFULL); in ytphy_utp_read_abilities()
2200 * yt8521_get_features_paged() - read supported link modes for one page
2218 linkmode_zero(phydev->supported); in yt8521_get_features_paged()
2219 yt8521_prepare_fiber_features(phydev, phydev->supported); in yt8521_get_features_paged()
2231 * yt8521_get_features - switch reg space then call yt8521_get_features_paged
2238 struct yt8521_priv *priv = phydev->priv; in yt8521_get_features()
2241 if (priv->reg_page != YT8521_RSSR_TO_BE_ARBITRATED) { in yt8521_get_features()
2242 ret = yt8521_get_features_paged(phydev, priv->reg_page); in yt8521_get_features()
2249 /* add fiber's features to phydev->supported */ in yt8521_get_features()
2250 yt8521_prepare_fiber_features(phydev, phydev->supported); in yt8521_get_features()