Lines Matching +full:enable +full:- +full:lpa

1 // SPDX-License-Identifier: GPL-2.0+
142 /* Copper Specific Interrupt Enable Register */
144 /* WOL Event Interrupt Enable */
188 /* RGMII to 1000BASE-X */
190 /* RGMII to 100BASE-FX */
390 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in marvell_config_intr()
454 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in marvell_config_aneg()
469 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in marvell_config_aneg()
519 * marvell,reg-init property stored in the of_node for the phydev.
521 * marvell,reg-init = <reg-page reg mask value>,...;
523 * There may be one or more sets of <reg-page reg mask value>:
525 * reg-page: which register bank to use.
527 * mask: if non-zero, ANDed with existing register value.
536 if (!phydev->mdio.dev.of_node) in marvell_of_reg_init()
539 paddr = of_get_property(phydev->mdio.dev.of_node, in marvell_of_reg_init()
540 "marvell,reg-init", &len); in marvell_of_reg_init()
550 for (i = 0; i < len - 3; i += 4) { in marvell_of_reg_init()
593 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) in m88e1121_config_aneg_rgmii_delays()
596 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in m88e1121_config_aneg_rgmii_delays()
598 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in m88e1121_config_aneg_rgmii_delays()
621 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1121_config_aneg()
631 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in m88e1121_config_aneg()
683 * marvell_config_aneg_fiber - restart auto-negotiation or write BMCR
686 * Description: If auto-negotiation is enabled, we configure the
687 * advertising, and then restart auto-negotiation. If it is not
697 if (phydev->autoneg != AUTONEG_ENABLE) in marvell_config_aneg_fiber()
701 linkmode_and(phydev->advertising, phydev->advertising, in marvell_config_aneg_fiber()
702 phydev->supported); in marvell_config_aneg_fiber()
704 adv = linkmode_adv_to_fiber_adv_t(phydev->advertising); in marvell_config_aneg_fiber()
730 if (phydev->interface != PHY_INTERFACE_MODE_SGMII && in m88e1111_config_aneg()
749 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1111_config_aneg()
750 /* Do not touch the fiber advertisement if we're in copper->sgmii mode. in m88e1111_config_aneg()
751 * Just ensure that SGMII-side autonegotiation is enabled. in m88e1111_config_aneg()
780 /* Do not touch the fiber page if we're in copper->sgmii mode */ in m88e1510_config_aneg()
781 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1510_config_aneg()
805 switch (MARVELL_PHY_FAMILY_ID(phydev->phy_id)) { in marvell_config_led()
817 if (phydev->dev_flags & MARVELL_PHY_LED0_LINK_LED1_ACTIVE) in marvell_config_led()
837 /* Set registers from marvell,reg-init DT property */ in marvell_config_init()
845 /* Enable Scrambler and Auto-Crossover */ in m88e3016_config_init()
873 switch (phydev->interface) { in m88e1111_config_init_rgmii_delays()
965 /* If using copper mode, ensure 1000BaseX auto-negotiation is enabled. in m88e1111_config_init_1000basex()
966 * FIXME: this does not actually enable 1000BaseX auto-negotiation if in m88e1111_config_init_1000basex()
992 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1111_config_init()
998 if (phydev->interface == PHY_INTERFACE_MODE_RTBI) { in m88e1111_config_init()
1004 if (phydev->interface == PHY_INTERFACE_MODE_1000BASEX) { in m88e1111_config_init()
1018 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1111_config_init()
1025 linkmode_or(phydev->advertising, phydev->advertising, in m88e1111_config_init()
1026 phydev->supported); in m88e1111_config_init()
1033 int val, cnt, enable; in m88e1111_get_downshift() local
1039 enable = FIELD_GET(MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN, val); in m88e1111_get_downshift()
1042 *data = enable ? cnt : DOWNSHIFT_DEV_DISABLE; in m88e1111_get_downshift()
1052 return -E2BIG; in m88e1111_set_downshift()
1059 val |= FIELD_PREP(MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK, cnt - 1); in m88e1111_set_downshift()
1076 switch (tuna->id) { in m88e1111_get_tunable()
1080 return -EOPNOTSUPP; in m88e1111_get_tunable()
1087 switch (tuna->id) { in m88e1111_set_tunable()
1091 return -EOPNOTSUPP; in m88e1111_set_tunable()
1097 int val, cnt, enable; in m88e1011_get_downshift() local
1103 enable = FIELD_GET(MII_M1011_PHY_SCR_DOWNSHIFT_EN, val); in m88e1011_get_downshift()
1106 *data = enable ? cnt : DOWNSHIFT_DEV_DISABLE; in m88e1011_get_downshift()
1116 return -E2BIG; in m88e1011_set_downshift()
1123 val |= FIELD_PREP(MII_M1011_PHY_SCR_DOWNSHIFT_MASK, cnt - 1); in m88e1011_set_downshift()
1140 switch (tuna->id) { in m88e1011_get_tunable()
1144 return -EOPNOTSUPP; in m88e1011_get_tunable()
1151 switch (tuna->id) { in m88e1011_set_tunable()
1155 return -EOPNOTSUPP; in m88e1011_set_tunable()
1205 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1116r_config_init()
1255 /* As per Marvell Release Notes - Alaska 88E1510/88E1518/88E1512/ in m88e1510_config_init()
1283 /* SGMII-to-Copper mode initialization */ in m88e1510_config_init()
1284 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1510_config_init()
1319 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1118_config_aneg()
1335 /* Enable 1000 Mbit */ in m88e1118_config_init()
1348 if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS) in m88e1118_config_init()
1378 /* Enable 1000 Mbit */ in m88e1149_config_init()
1403 if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) { in m88e1145_config_init_rgmii()
1451 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { in m88e1145_config_init()
1457 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1145_config_init()
1502 return -EINVAL; in m88e1540_get_fld()
1523 return -EBUSY; in m88e1540_set_fld()
1549 switch (tuna->id) { in m88e1540_get_tunable()
1555 return -EOPNOTSUPP; in m88e1540_get_tunable()
1562 switch (tuna->id) { in m88e1540_set_tunable()
1568 return -EOPNOTSUPP; in m88e1540_set_tunable()
1608 * @lpa: value of the MII_LPA register for fiber link
1614 static void fiber_lpa_mod_linkmode_lpa_t(unsigned long *advertising, u32 lpa) in fiber_lpa_mod_linkmode_lpa_t() argument
1617 advertising, lpa & LPA_1000XHALF); in fiber_lpa_mod_linkmode_lpa_t()
1620 advertising, lpa & LPA_1000XFULL); in fiber_lpa_mod_linkmode_lpa_t()
1626 int lpa; in marvell_read_status_page_an() local
1630 phydev->link = 0; in marvell_read_status_page_an()
1635 phydev->duplex = DUPLEX_FULL; in marvell_read_status_page_an()
1637 phydev->duplex = DUPLEX_HALF; in marvell_read_status_page_an()
1641 phydev->speed = SPEED_1000; in marvell_read_status_page_an()
1645 phydev->speed = SPEED_100; in marvell_read_status_page_an()
1649 phydev->speed = SPEED_10; in marvell_read_status_page_an()
1660 lpa = phy_read(phydev, MII_LPA); in marvell_read_status_page_an()
1661 if (lpa < 0) in marvell_read_status_page_an()
1662 return lpa; in marvell_read_status_page_an()
1665 fiber_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); in marvell_read_status_page_an()
1667 if (phydev->duplex == DUPLEX_FULL) { in marvell_read_status_page_an()
1668 if (!(lpa & LPA_PAUSE_FIBER)) { in marvell_read_status_page_an()
1669 phydev->pause = 0; in marvell_read_status_page_an()
1670 phydev->asym_pause = 0; in marvell_read_status_page_an()
1671 } else if ((lpa & LPA_PAUSE_ASYM_FIBER)) { in marvell_read_status_page_an()
1672 phydev->pause = 1; in marvell_read_status_page_an()
1673 phydev->asym_pause = 1; in marvell_read_status_page_an()
1675 phydev->pause = 1; in marvell_read_status_page_an()
1676 phydev->asym_pause = 0; in marvell_read_status_page_an()
1706 phydev->link = !!(status & MII_M1011_PHY_STATUS_LINK); in marvell_read_status_page()
1718 linkmode_zero(phydev->lp_advertising); in marvell_read_status_page()
1719 phydev->pause = 0; in marvell_read_status_page()
1720 phydev->asym_pause = 0; in marvell_read_status_page()
1721 phydev->speed = SPEED_UNKNOWN; in marvell_read_status_page()
1722 phydev->duplex = DUPLEX_UNKNOWN; in marvell_read_status_page()
1723 phydev->port = fiber ? PORT_FIBRE : PORT_TP; in marvell_read_status_page()
1725 if (phydev->autoneg == AUTONEG_ENABLE) in marvell_read_status_page()
1748 phydev->supported) && in marvell_read_status()
1749 phydev->interface != PHY_INTERFACE_MODE_SGMII) { in marvell_read_status()
1765 if (phydev->link) in marvell_read_status()
1792 phydev->supported)) { in marvell_suspend()
1827 phydev->supported)) { in marvell_resume()
1863 wol->supported = WAKE_MAGIC | WAKE_PHY; in m88e1318_get_wol()
1864 wol->wolopts = 0; in m88e1318_get_wol()
1872 wol->wolopts |= WAKE_MAGIC; in m88e1318_get_wol()
1875 wol->wolopts |= WAKE_PHY; in m88e1318_get_wol()
1887 if (wol->wolopts & (WAKE_MAGIC | WAKE_PHY)) { in m88e1318_set_wol()
1902 /* Enable the WOL interrupt */ in m88e1318_set_wol()
1921 if (wol->wolopts & WAKE_MAGIC) { in m88e1318_set_wol()
1928 ((phydev->attached_dev->dev_addr[5] << 8) | in m88e1318_set_wol()
1929 phydev->attached_dev->dev_addr[4])); in m88e1318_set_wol()
1933 ((phydev->attached_dev->dev_addr[3] << 8) | in m88e1318_set_wol()
1934 phydev->attached_dev->dev_addr[2])); in m88e1318_set_wol()
1938 ((phydev->attached_dev->dev_addr[1] << 8) | in m88e1318_set_wol()
1939 phydev->attached_dev->dev_addr[0])); in m88e1318_set_wol()
1943 /* Clear WOL status and enable magic packet matching */ in m88e1318_set_wol()
1962 if (wol->wolopts & WAKE_PHY) { in m88e1318_set_wol()
1967 /* Clear WOL status and enable link up event */ in m88e1318_set_wol()
1993 phydev->supported)) in marvell_get_sset_count()
1996 return ARRAY_SIZE(marvell_hw_stats) - NB_FIBER_STATS; in marvell_get_sset_count()
2029 struct marvell_priv *priv = phydev->priv; in marvell_get_stat()
2037 val = val & ((1 << stat.bits) - 1); in marvell_get_stat()
2038 priv->stats[i] += val; in marvell_get_stat()
2039 ret = priv->stats[i]; in marvell_get_stat()
2048 struct marvell_priv *priv = phydev->priv; in marvell_get_stat_simple()
2056 val = val & ((1 << stat.bits) - 1); in marvell_get_stat_simple()
2057 priv->stats[i] += val; in marvell_get_stat_simple()
2058 ret = priv->stats[i]; in marvell_get_stat_simple()
2084 static int m88e1510_loopback(struct phy_device *phydev, bool enable) in m88e1510_loopback() argument
2088 if (enable) { in m88e1510_loopback()
2091 bmcr_ctl = mii_bmcr_encode_fixed(phydev->speed, phydev->duplex); in m88e1510_loopback()
2097 if (phydev->speed == SPEED_1000) in m88e1510_loopback()
2099 else if (phydev->speed == SPEED_100) in m88e1510_loopback()
2118 * into/out-of loopback mode. in m88e1510_loopback()
2147 return -ETIMEDOUT; in marvell_vct5_wait_complete()
2166 amplitude = -amplitude; in marvell_vct5_amplitude()
2220 struct marvell_priv *priv = phydev->priv; in marvell_vct5_amplitude_graph()
2227 if (priv->first <= TDR_SHORT_CABLE_LENGTH) in marvell_vct5_amplitude_graph()
2251 for (distance = priv->first; in marvell_vct5_amplitude_graph()
2252 distance <= priv->last; in marvell_vct5_amplitude_graph()
2253 distance += priv->step) { in marvell_vct5_amplitude_graph()
2255 priv->pair); in marvell_vct5_amplitude_graph()
2279 /* If auto-negotiation is enabled, but not complete, the cable in marvell_cable_test_start_common()
2280 * test never completes. So disable auto-neg. in marvell_cable_test_start_common()
2309 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_start()
2316 priv->cable_test_tdr = false; in marvell_vct7_cable_test_start()
2344 struct marvell_priv *priv = phydev->priv; in marvell_vct5_cable_test_tdr_start()
2347 priv->cable_test_tdr = true; in marvell_vct5_cable_test_tdr_start()
2348 priv->first = marvell_vct5_cm2distance(cfg->first); in marvell_vct5_cable_test_tdr_start()
2349 priv->last = marvell_vct5_cm2distance(cfg->last); in marvell_vct5_cable_test_tdr_start()
2350 priv->step = marvell_vct5_cm2distance(cfg->step); in marvell_vct5_cable_test_tdr_start()
2351 priv->pair = cfg->pair; in marvell_vct5_cable_test_tdr_start()
2353 if (priv->first > MII_VCT5_SAMPLE_POINT_DISTANCE_MAX) in marvell_vct5_cable_test_tdr_start()
2354 return -EINVAL; in marvell_vct5_cable_test_tdr_start()
2356 if (priv->last > MII_VCT5_SAMPLE_POINT_DISTANCE_MAX) in marvell_vct5_cable_test_tdr_start()
2357 return -EINVAL; in marvell_vct5_cable_test_tdr_start()
2374 marvell_vct5_distance2cm(priv->first), in marvell_vct5_cable_test_tdr_start()
2375 marvell_vct5_distance2cm(priv->last), in marvell_vct5_cable_test_tdr_start()
2376 marvell_vct5_distance2cm(priv->step)); in marvell_vct5_cable_test_tdr_start()
2482 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_get_status()
2485 if (priv->cable_test_tdr) { in marvell_vct7_cable_test_get_status()
2510 struct marvell_priv *priv = phydev->priv; in m88e3082_vct_cable_test_start()
2523 if (priv->vct_phase == M88E3082_VCT_PHASE1) { in m88e3082_vct_cable_test_start()
2550 if (priv->vct_phase == M88E3082_VCT_OFF) { in m88e3082_vct_cable_test_start()
2551 priv->vct_phase = M88E3082_VCT_PHASE1; in m88e3082_vct_cable_test_start()
2552 priv->pair = 0; in m88e3082_vct_cable_test_start()
2565 priv->vct_phase = M88E3082_VCT_PHASE2; in m88e3082_vct_cable_test_start()
2591 /* Original function for meters: y = 0.7861x - 18.862 */ in m88e3082_vct_distrfln_2_cm()
2592 return (7861 * distrfln - 188620) / 100; in m88e3082_vct_distrfln_2_cm()
2599 struct marvell_priv *priv = phydev->priv; in m88e3082_vct_cable_test_get_status()
2625 switch (priv->vct_phase) { in m88e3082_vct_cable_test_get_status()
2639 priv->pair |= M88E3082_PAIR_A; in m88e3082_vct_cable_test_get_status()
2649 priv->pair |= M88E3082_PAIR_B; in m88e3082_vct_cable_test_get_status()
2659 if (priv->pair & M88E3082_PAIR_A && in m88e3082_vct_cable_test_get_status()
2667 if (priv->pair & M88E3082_PAIR_B && in m88e3082_vct_cable_test_get_status()
2678 return -EINVAL; in m88e3082_vct_cable_test_get_status()
2686 priv->vct_phase = M88E3082_VCT_OFF; in m88e3082_vct_cable_test_get_status()
2737 /* Original function for meters: y = 0.8018x - 28.751 */ in m88e1111_vct_distrfln_2_cm()
2738 return (8018 * distrfln - 287510) / 100; in m88e1111_vct_distrfln_2_cm()
2749 /* Each pair use one page: A-0, B-1, C-2, D-3 */ in m88e1111_vct_cable_test_get_status()
2788 return phydev->drv->driver_data; in to_marvell_hwmon_ops()
2803 /* Enable temperature sensor */ in m88e1121_get_temp()
2828 *temp = ((val & MII_88E1121_MISC_TEST_TEMP_MASK) - 5) * 5000; in m88e1121_get_temp()
2845 *temp = ((ret & MII_88E1510_TEMP_SENSOR_MASK) - 25) * 1000; in m88e1510_get_temp()
2862 MII_88E1510_MISC_TEST_TEMP_THRESHOLD_SHIFT) * 5) - 25; in m88e1510_get_temp_critical()
2909 /* Enable temperature sensor */ in m88e6390_get_temp()
2935 *temp = (sum - 75) * 1000; in m88e6390_get_temp()
2962 *temp -= 50000; in m88e6393_get_temp()
2979 MII_88E6393_TEMP_SENSOR_THRESHOLD_SHIFT) - 75) * 1000; in m88e6393_get_temp_critical()
3017 int err = -EOPNOTSUPP; in marvell_hwmon_read()
3021 if (ops->get_temp) in marvell_hwmon_read()
3022 err = ops->get_temp(phydev, temp); in marvell_hwmon_read()
3025 if (ops->get_temp_critical) in marvell_hwmon_read()
3026 err = ops->get_temp_critical(phydev, temp); in marvell_hwmon_read()
3029 if (ops->get_temp_alarm) in marvell_hwmon_read()
3030 err = ops->get_temp_alarm(phydev, temp); in marvell_hwmon_read()
3042 int err = -EOPNOTSUPP; in marvell_hwmon_write()
3046 if (ops->set_temp_critical) in marvell_hwmon_write()
3047 err = ops->set_temp_critical(phydev, temp); in marvell_hwmon_write()
3066 return ops->get_temp ? 0444 : 0; in marvell_hwmon_is_visible()
3068 return ops->get_temp_alarm ? 0444 : 0; in marvell_hwmon_is_visible()
3070 return (ops->get_temp_critical ? 0444 : 0) | in marvell_hwmon_is_visible()
3071 (ops->set_temp_critical ? 0200 : 0); in marvell_hwmon_is_visible()
3120 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_name()
3121 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_name()
3126 priv->hwmon_name = devm_kzalloc(dev, len, GFP_KERNEL); in marvell_hwmon_name()
3127 if (!priv->hwmon_name) in marvell_hwmon_name()
3128 return -ENOMEM; in marvell_hwmon_name()
3132 priv->hwmon_name[j++] = devname[i]; in marvell_hwmon_name()
3141 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_probe()
3142 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_probe()
3152 priv->hwmon_dev = devm_hwmon_device_register_with_info( in marvell_hwmon_probe()
3153 dev, priv->hwmon_name, phydev, &marvell_hwmon_chip_info, NULL); in marvell_hwmon_probe()
3154 if (IS_ERR(priv->hwmon_dev)) in marvell_hwmon_probe()
3155 return PTR_ERR(priv->hwmon_dev); in marvell_hwmon_probe()
3157 if (ops->config) in marvell_hwmon_probe()
3158 err = ops->config(phydev); in marvell_hwmon_probe()
3219 return -EINVAL; in m88e1318_led_brightness_set()
3248 return -EINVAL; in m88e1318_led_blink_set()
3389 return -EOPNOTSUPP; in marvell_find_led_mode()
3410 ret = -EINVAL; in marvell_get_led_mode()
3429 return -EOPNOTSUPP; in marvell_find_led_rules()
3450 ret = -EOPNOTSUPP; in marvell_get_led_rules()
3468 ret = -EINVAL; in m88e1318_led_hw_is_supported()
3486 ret = -EINVAL; in m88e1318_led_hw_control_set()
3509 return -EINVAL; in m88e1318_led_hw_control_get()
3525 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in marvell_probe()
3527 return -ENOMEM; in marvell_probe()
3529 phydev->priv = priv; in marvell_probe()
3546 dev = &phydev->mdio.dev; in m88e1510_sfp_insert()
3548 sfp_parse_support(phydev->sfp_bus, id, supported, interfaces); in m88e1510_sfp_insert()
3549 interface = sfp_select_interface(phydev->sfp_bus, supported); in m88e1510_sfp_insert()
3569 return -EINVAL; in m88e1510_sfp_insert()