Lines Matching +full:smarteee +full:- +full:tw +full:- +full:us +full:- +full:1 +full:g
1 // SPDX-License-Identifier: GPL-2.0+
24 #include <dt-bindings/net/qca-ar803x.h>
34 #define AT803X_SFC_POLARITY_REVERSAL BIT(1)
40 #define AT803X_SS_SPEED_100 1
59 #define AT803X_INTR_ENABLE_POLARITY_CHANGED BIT(1)
67 #define AT803X_SMART_SPEED_BYPASS_TIMER BIT(1)
73 #define AT803X_CDT_STATUS_STAT_SHORT 1
104 #define AT803X_PSSR 0x11 /*PHY-Specific Status Register*/
145 #define AT803X_CLK_OUT_25MHZ_DSP 1
160 #define AT803X_CLK_OUT_STRENGTH_HALF 1
190 #define AT803X_PAGE_COPPER 1
194 #define AT803X_DISABLE_SMARTEEE BIT(1)
246 #define QCA808X_MASTER_SLAVE_SEED_ENABLE BIT(1)
272 #define QCA808X_CDT_STATUS_STAT_NORMAL 1
417 context->bmcr = phy_read(phydev, MII_BMCR); in at803x_context_save()
418 context->advertise = phy_read(phydev, MII_ADVERTISE); in at803x_context_save()
419 context->control1000 = phy_read(phydev, MII_CTRL1000); in at803x_context_save()
420 context->int_enable = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_context_save()
421 context->smart_speed = phy_read(phydev, AT803X_SMART_SPEED); in at803x_context_save()
422 context->led_control = phy_read(phydev, AT803X_LED_CONTROL); in at803x_context_save()
429 phy_write(phydev, MII_BMCR, context->bmcr); in at803x_context_restore()
430 phy_write(phydev, MII_ADVERTISE, context->advertise); in at803x_context_restore()
431 phy_write(phydev, MII_CTRL1000, context->control1000); in at803x_context_restore()
432 phy_write(phydev, AT803X_INTR_ENABLE, context->int_enable); in at803x_context_restore()
433 phy_write(phydev, AT803X_SMART_SPEED, context->smart_speed); in at803x_context_restore()
434 phy_write(phydev, AT803X_LED_CONTROL, context->led_control); in at803x_context_restore()
442 if (wol->wolopts & WAKE_MAGIC) { in at803x_set_wol()
443 struct net_device *ndev = phydev->attached_dev; in at803x_set_wol()
453 return -ENODEV; in at803x_set_wol()
455 mac = (const u8 *) ndev->dev_addr; in at803x_set_wol()
458 return -EINVAL; in at803x_set_wol()
462 mac[(i * 2) + 1] | (mac[(i * 2)] << 8)); in at803x_set_wol()
510 wol->supported = WAKE_MAGIC; in at803x_get_wol()
511 wol->wolopts = 0; in at803x_get_wol()
518 wol->wolopts |= WAKE_MAGIC; in at803x_get_wol()
539 struct at803x_priv *priv = phydev->priv; in at803x_get_stat()
552 priv->stats[i] += val; in at803x_get_stat()
553 ret = priv->stats[i]; in at803x_get_stat()
613 return (val & AT803X_DEBUG_RGMII_1V8) ? 1 : 0; in at803x_rgmii_reg_get_voltage_sel()
629 .of_match = of_match_ptr("vddio-regulator"),
642 .of_match = of_match_ptr("vddh-regulator"),
643 .n_voltages = 1,
652 struct at803x_priv *priv = phydev->priv; in at8031_register_regulators()
653 struct device *dev = &phydev->mdio.dev; in at8031_register_regulators()
659 priv->vddio_rdev = devm_regulator_register(dev, &vddio_desc, &config); in at8031_register_regulators()
660 if (IS_ERR(priv->vddio_rdev)) { in at8031_register_regulators()
662 return PTR_ERR(priv->vddio_rdev); in at8031_register_regulators()
665 priv->vddh_rdev = devm_regulator_register(dev, &vddh_desc, &config); in at8031_register_regulators()
666 if (IS_ERR(priv->vddh_rdev)) { in at8031_register_regulators()
668 return PTR_ERR(priv->vddh_rdev); in at8031_register_regulators()
690 sfp_parse_support(phydev->sfp_bus, id, sfp_support, interfaces); in at803x_sfp_insert()
691 /* Some modules support 10G modes as well as others we support. in at803x_sfp_insert()
692 * Mask out non-supported modes so the correct interface is picked. in at803x_sfp_insert()
697 dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n"); in at803x_sfp_insert()
698 return -EINVAL; in at803x_sfp_insert()
701 iface = sfp_select_interface(phydev->sfp_bus, sfp_support); in at803x_sfp_insert()
703 /* Only 1000Base-X is supported by AR8031/8033 as the downstream SerDes in at803x_sfp_insert()
706 * interface do default to and function in 1000Base-X mode, so just in at803x_sfp_insert()
711 dev_warn(&phydev->mdio.dev, "module may not function if 1000Base-X not supported\n"); in at803x_sfp_insert()
713 return -EINVAL; in at803x_sfp_insert()
726 struct device_node *node = phydev->mdio.dev.of_node; in at803x_parse_dt()
727 struct at803x_priv *priv = phydev->priv; in at803x_parse_dt()
728 u32 freq, strength, tw; in at803x_parse_dt() local
735 if (of_property_read_bool(node, "qca,disable-smarteee")) in at803x_parse_dt()
736 priv->flags |= AT803X_DISABLE_SMARTEEE; in at803x_parse_dt()
738 if (of_property_read_bool(node, "qca,disable-hibernation-mode")) in at803x_parse_dt()
739 priv->flags |= AT803X_DISABLE_HIBERNATION_MODE; in at803x_parse_dt()
741 if (!of_property_read_u32(node, "qca,smarteee-tw-us-1g", &tw)) { in at803x_parse_dt()
742 if (!tw || tw > 255) { in at803x_parse_dt()
743 phydev_err(phydev, "invalid qca,smarteee-tw-us-1g\n"); in at803x_parse_dt()
744 return -EINVAL; in at803x_parse_dt()
746 priv->smarteee_lpi_tw_1g = tw; in at803x_parse_dt()
749 if (!of_property_read_u32(node, "qca,smarteee-tw-us-100m", &tw)) { in at803x_parse_dt()
750 if (!tw || tw > 255) { in at803x_parse_dt()
751 phydev_err(phydev, "invalid qca,smarteee-tw-us-100m\n"); in at803x_parse_dt()
752 return -EINVAL; in at803x_parse_dt()
754 priv->smarteee_lpi_tw_100m = tw; in at803x_parse_dt()
757 ret = of_property_read_u32(node, "qca,clk-out-frequency", &freq); in at803x_parse_dt()
773 phydev_err(phydev, "invalid qca,clk-out-frequency\n"); in at803x_parse_dt()
774 return -EINVAL; in at803x_parse_dt()
777 priv->clk_25m_reg |= FIELD_PREP(AT803X_CLK_OUT_MASK, sel); in at803x_parse_dt()
778 priv->clk_25m_mask |= AT803X_CLK_OUT_MASK; in at803x_parse_dt()
791 if (phydev->drv->phy_id == ATH8030_PHY_ID || in at803x_parse_dt()
792 phydev->drv->phy_id == ATH8035_PHY_ID) { in at803x_parse_dt()
793 priv->clk_25m_reg &= AT8035_CLK_OUT_MASK; in at803x_parse_dt()
794 priv->clk_25m_mask &= AT8035_CLK_OUT_MASK; in at803x_parse_dt()
798 ret = of_property_read_u32(node, "qca,clk-out-strength", &strength); in at803x_parse_dt()
800 priv->clk_25m_mask |= AT803X_CLK_OUT_STRENGTH_MASK; in at803x_parse_dt()
803 priv->clk_25m_reg |= AT803X_CLK_OUT_STRENGTH_FULL; in at803x_parse_dt()
806 priv->clk_25m_reg |= AT803X_CLK_OUT_STRENGTH_HALF; in at803x_parse_dt()
809 priv->clk_25m_reg |= AT803X_CLK_OUT_STRENGTH_QUARTER; in at803x_parse_dt()
812 phydev_err(phydev, "invalid qca,clk-out-strength\n"); in at803x_parse_dt()
813 return -EINVAL; in at803x_parse_dt()
820 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_parse_dt()
821 if (of_property_read_bool(node, "qca,keep-pll-enabled")) in at803x_parse_dt()
822 priv->flags |= AT803X_KEEP_PLL_ENABLED; in at803x_parse_dt()
828 priv->vddio = devm_regulator_get_optional(&phydev->mdio.dev, in at803x_parse_dt()
830 if (IS_ERR(priv->vddio)) { in at803x_parse_dt()
832 return PTR_ERR(priv->vddio); in at803x_parse_dt()
835 /* Only AR8031/8033 support 1000Base-X for SFP modules */ in at803x_parse_dt()
846 struct device *dev = &phydev->mdio.dev; in at803x_probe()
852 return -ENOMEM; in at803x_probe()
854 phydev->priv = priv; in at803x_probe()
860 if (priv->vddio) { in at803x_probe()
861 ret = regulator_enable(priv->vddio); in at803x_probe()
866 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_probe()
882 priv->is_1000basex = true; in at803x_probe()
886 priv->is_fiber = true; in at803x_probe()
901 if (priv->vddio) in at803x_probe()
902 regulator_disable(priv->vddio); in at803x_probe()
909 struct at803x_priv *priv = phydev->priv; in at803x_remove()
911 if (priv->vddio) in at803x_remove()
912 regulator_disable(priv->vddio); in at803x_remove()
917 struct at803x_priv *priv = phydev->priv; in at803x_get_features()
924 if (phydev->drv->phy_id == QCA8081_PHY_ID) { in at803x_get_features()
929 linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported, in at803x_get_features()
933 if (phydev->drv->phy_id != ATH8031_PHY_ID) in at803x_get_features()
942 * to 1 even when operating in copper TP mode. in at803x_get_features()
947 if (!priv->is_1000basex) in at803x_get_features()
949 phydev->supported); in at803x_get_features()
956 struct at803x_priv *priv = phydev->priv; in at803x_smarteee_config()
960 if (priv->flags & AT803X_DISABLE_SMARTEEE) in at803x_smarteee_config()
965 if (priv->smarteee_lpi_tw_1g) { in at803x_smarteee_config()
967 val |= priv->smarteee_lpi_tw_1g << 8; in at803x_smarteee_config()
969 if (priv->smarteee_lpi_tw_100m) { in at803x_smarteee_config()
971 val |= priv->smarteee_lpi_tw_100m; in at803x_smarteee_config()
988 struct at803x_priv *priv = phydev->priv; in at803x_clk_out_config()
990 if (!priv->clk_25m_mask) in at803x_clk_out_config()
994 priv->clk_25m_mask, priv->clk_25m_reg); in at803x_clk_out_config()
999 struct at803x_priv *priv = phydev->priv; in at8031_pll_config()
1004 if (priv->flags & AT803X_KEEP_PLL_ENABLED) in at8031_pll_config()
1014 struct at803x_priv *priv = phydev->priv; in at803x_hibernation_mode_config()
1019 if (!(priv->flags & AT803X_DISABLE_HIBERNATION_MODE)) in at803x_hibernation_mode_config()
1028 struct at803x_priv *priv = phydev->priv; in at803x_config_init()
1031 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_config_init()
1038 priv->is_fiber ? AT803X_PAGE_FIBER : in at803x_config_init()
1054 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in at803x_config_init()
1055 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in at803x_config_init()
1062 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in at803x_config_init()
1063 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in at803x_config_init()
1102 struct at803x_priv *priv = phydev->priv; in at803x_config_intr()
1108 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in at803x_config_intr()
1119 if (priv->is_fiber) { in at803x_config_intr()
1172 if (phydev->state == PHY_NOLINK && phydev->mdio.reset_gpio) { in at803x_link_change_notify()
1177 phy_device_reset(phydev, 1); in at803x_link_change_notify()
1178 msleep(1); in at803x_link_change_notify()
1180 msleep(1); in at803x_link_change_notify()
1192 /* Read the AT8035 PHY-Specific Status register, which indicates the in at803x_read_specific_status()
1208 if (phydev->drv->phy_id == QCA8081_PHY_ID) in at803x_read_specific_status()
1215 phydev->speed = SPEED_10; in at803x_read_specific_status()
1218 phydev->speed = SPEED_100; in at803x_read_specific_status()
1221 phydev->speed = SPEED_1000; in at803x_read_specific_status()
1224 phydev->speed = SPEED_2500; in at803x_read_specific_status()
1228 phydev->duplex = DUPLEX_FULL; in at803x_read_specific_status()
1230 phydev->duplex = DUPLEX_HALF; in at803x_read_specific_status()
1233 phydev->mdix = ETH_TP_MDI_X; in at803x_read_specific_status()
1235 phydev->mdix = ETH_TP_MDI; in at803x_read_specific_status()
1239 phydev->mdix_ctrl = ETH_TP_MDI; in at803x_read_specific_status()
1242 phydev->mdix_ctrl = ETH_TP_MDI_X; in at803x_read_specific_status()
1245 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in at803x_read_specific_status()
1255 struct at803x_priv *priv = phydev->priv; in at803x_read_status()
1256 int err, old_link = phydev->link; in at803x_read_status()
1258 if (priv->is_1000basex) in at803x_read_status()
1267 if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) in at803x_read_status()
1270 phydev->speed = SPEED_UNKNOWN; in at803x_read_status()
1271 phydev->duplex = DUPLEX_UNKNOWN; in at803x_read_status()
1272 phydev->pause = 0; in at803x_read_status()
1273 phydev->asym_pause = 0; in at803x_read_status()
1283 if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) in at803x_read_status()
1314 struct at803x_priv *priv = phydev->priv; in at803x_config_aneg()
1317 ret = at803x_config_mdix(phydev, phydev->mdix_ctrl); in at803x_config_aneg()
1325 if (ret == 1) { in at803x_config_aneg()
1331 if (priv->is_1000basex) in at803x_config_aneg()
1334 /* Do not restart auto-negotiation by setting ret to 0 defautly, in at803x_config_aneg()
1339 if (phydev->drv->phy_id == QCA8081_PHY_ID) { in at803x_config_aneg()
1345 if (phydev->autoneg == AUTONEG_DISABLE) in at803x_config_aneg()
1348 if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->advertising)) in at803x_config_aneg()
1388 FIELD_PREP(AT803X_SMART_SPEED_RETRY_LIMIT_MASK, cnt - 2); in at803x_set_downshift()
1397 return -EINVAL; in at803x_set_downshift()
1406 if (ret == 1) in at803x_set_downshift()
1415 switch (tuna->id) { in at803x_get_tunable()
1419 return -EOPNOTSUPP; in at803x_get_tunable()
1426 switch (tuna->id) { in at803x_set_tunable()
1430 return -EOPNOTSUPP; in at803x_set_tunable()
1494 if (phydev->drv->phy_id == QCA8081_PHY_ID) in at803x_cdt_start()
1510 if (phydev->drv->phy_id == QCA8081_PHY_ID) in at803x_cdt_wait_for_completion()
1555 return 1; in at803x_cable_test_one_pair()
1565 if (phydev->phy_id == ATH9331_PHY_ID || in at803x_cable_test_get_status()
1566 phydev->phy_id == ATH8032_PHY_ID || in at803x_cable_test_get_status()
1567 phydev->phy_id == QCA9561_PHY_ID) in at803x_cable_test_get_status()
1576 * auto-negotiating. Starting the test will restart the AN in at803x_cable_test_get_status()
1581 while (pair_mask && retries--) { in at803x_cable_test_get_status()
1600 /* Enable auto-negotiation, but advertise no capabilities, no link in at803x_cable_test_start()
1601 * will be established. A restart of the auto-negotiation is not in at803x_cable_test_start()
1606 if (phydev->phy_id != ATH9331_PHY_ID && in at803x_cable_test_start()
1607 phydev->phy_id != ATH8032_PHY_ID && in at803x_cable_test_start()
1608 phydev->phy_id != QCA9561_PHY_ID) in at803x_cable_test_start()
1619 switch_revision = phydev->dev_flags & QCA8K_DEVFLAGS_REVISION_MASK; in qca83xx_config_init()
1622 case 1: in qca83xx_config_init()
1644 if (phydev->drv->phy_id == QCA8327_A_PHY_ID || in qca83xx_config_init()
1645 phydev->drv->phy_id == QCA8327_B_PHY_ID) in qca83xx_config_init()
1658 if (phydev->drv->phy_id == QCA8337_PHY_ID) in qca83xx_link_change_notify()
1662 if (phydev->state == PHY_RUNNING) { in qca83xx_link_change_notify()
1663 if (phydev->speed == SPEED_100) in qca83xx_link_change_notify()
1679 if (!phydev->suspended) in qca83xx_resume()
1689 * restart auto-negotiation. Wait for reset to complete. in qca83xx_resume()
1696 msleep(1); in qca83xx_resume()
1709 if (phydev->drv->phy_id == QCA8337_PHY_ID) { in qca83xx_suspend()
1825 linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->lp_advertising, in qca808x_read_status()
1836 if (phydev->link) { in qca808x_read_status()
1837 if (phydev->speed == SPEED_2500) in qca808x_read_status()
1838 phydev->interface = PHY_INTERFACE_MODE_2500BASEX; in qca808x_read_status()
1840 phydev->interface = PHY_INTERFACE_MODE_SGMII; in qca808x_read_status()
1849 if (phydev->master_slave_state == MASTER_SLAVE_STATE_ERR) { in qca808x_read_status()
1916 return -EINVAL; in qca808x_cdt_fault_length()
1931 * 1. disable hibernation. in qca808x_cable_test_start()
1945 /* Force 1000base-T needs to configure PMA/PMD and MII_BMCR */ in qca808x_cable_test_start()
1946 phydev->duplex = DUPLEX_FULL; in qca808x_cable_test_start()
1947 phydev->speed = SPEED_1000; in qca808x_cable_test_start()
2102 .name = "Qualcomm Atheros AR9331 built-in PHY",
2119 .name = "Qualcomm Atheros QCA9561 built-in PHY",
2150 /* QCA8327-A from switch QCA8327-AL1A */
2153 .name = "Qualcomm Atheros 8327-A internal PHY",
2166 /* QCA8327-B from switch QCA8327-BL1A */
2169 .name = "Qualcomm Atheros 8327-B internal PHY",