Lines Matching +full:sense +full:- +full:bitfield +full:- +full:width
1 // SPDX-License-Identifier: GPL-2.0+
33 #include <linux/bitfield.h>
188 /* RGMII to 1000BASE-X */
190 /* RGMII to 100BASE-FX */
347 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in marvell_config_intr()
411 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in marvell_config_aneg()
426 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in marvell_config_aneg()
476 * marvell,reg-init property stored in the of_node for the phydev.
478 * marvell,reg-init = <reg-page reg mask value>,...;
480 * There may be one or more sets of <reg-page reg mask value>:
482 * reg-page: which register bank to use.
484 * mask: if non-zero, ANDed with existing register value.
493 if (!phydev->mdio.dev.of_node) in marvell_of_reg_init()
496 paddr = of_get_property(phydev->mdio.dev.of_node, in marvell_of_reg_init()
497 "marvell,reg-init", &len); in marvell_of_reg_init()
507 for (i = 0; i < len - 3; i += 4) { in marvell_of_reg_init()
550 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) in m88e1121_config_aneg_rgmii_delays()
553 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in m88e1121_config_aneg_rgmii_delays()
555 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in m88e1121_config_aneg_rgmii_delays()
578 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1121_config_aneg()
588 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in m88e1121_config_aneg()
640 * marvell_config_aneg_fiber - restart auto-negotiation or write BMCR
643 * Description: If auto-negotiation is enabled, we configure the
644 * advertising, and then restart auto-negotiation. If it is not
654 if (phydev->autoneg != AUTONEG_ENABLE) in marvell_config_aneg_fiber()
658 linkmode_and(phydev->advertising, phydev->advertising, in marvell_config_aneg_fiber()
659 phydev->supported); in marvell_config_aneg_fiber()
661 adv = linkmode_adv_to_fiber_adv_t(phydev->advertising); in marvell_config_aneg_fiber()
687 if (phydev->interface != PHY_INTERFACE_MODE_SGMII && in m88e1111_config_aneg()
706 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1111_config_aneg()
707 /* Do not touch the fiber advertisement if we're in copper->sgmii mode. in m88e1111_config_aneg()
708 * Just ensure that SGMII-side autonegotiation is enabled. in m88e1111_config_aneg()
737 /* Do not touch the fiber page if we're in copper->sgmii mode */ in m88e1510_config_aneg()
738 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1510_config_aneg()
762 switch (MARVELL_PHY_FAMILY_ID(phydev->phy_id)) { in marvell_config_led()
774 if (phydev->dev_flags & MARVELL_PHY_LED0_LINK_LED1_ACTIVE) in marvell_config_led()
794 /* Set registers from marvell,reg-init DT property */ in marvell_config_init()
802 /* Enable Scrambler and Auto-Crossover */ in m88e3016_config_init()
830 switch (phydev->interface) { in m88e1111_config_init_rgmii_delays()
922 /* If using copper mode, ensure 1000BaseX auto-negotiation is enabled */ in m88e1111_config_init_1000basex()
946 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1111_config_init()
952 if (phydev->interface == PHY_INTERFACE_MODE_RTBI) { in m88e1111_config_init()
958 if (phydev->interface == PHY_INTERFACE_MODE_1000BASEX) { in m88e1111_config_init()
972 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1111_config_init()
979 linkmode_or(phydev->advertising, phydev->advertising, in m88e1111_config_init()
980 phydev->supported); in m88e1111_config_init()
1006 return -E2BIG; in m88e1111_set_downshift()
1013 val |= FIELD_PREP(MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK, cnt - 1); in m88e1111_set_downshift()
1030 switch (tuna->id) { in m88e1111_get_tunable()
1034 return -EOPNOTSUPP; in m88e1111_get_tunable()
1041 switch (tuna->id) { in m88e1111_set_tunable()
1045 return -EOPNOTSUPP; in m88e1111_set_tunable()
1070 return -E2BIG; in m88e1011_set_downshift()
1077 val |= FIELD_PREP(MII_M1011_PHY_SCR_DOWNSHIFT_MASK, cnt - 1); in m88e1011_set_downshift()
1094 switch (tuna->id) { in m88e1011_get_tunable()
1098 return -EOPNOTSUPP; in m88e1011_get_tunable()
1105 switch (tuna->id) { in m88e1011_set_tunable()
1109 return -EOPNOTSUPP; in m88e1011_set_tunable()
1159 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1116r_config_init()
1209 /* As per Marvell Release Notes - Alaska 88E1510/88E1518/88E1512/ in m88e1510_config_init()
1237 /* SGMII-to-Copper mode initialization */ in m88e1510_config_init()
1238 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1510_config_init()
1273 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1118_config_aneg()
1302 if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS) in m88e1118_config_init()
1357 if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) { in m88e1145_config_init_rgmii()
1405 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { in m88e1145_config_init()
1411 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1145_config_init()
1456 return -EINVAL; in m88e1540_get_fld()
1477 return -EBUSY; in m88e1540_set_fld()
1503 switch (tuna->id) { in m88e1540_get_tunable()
1509 return -EOPNOTSUPP; in m88e1540_get_tunable()
1516 switch (tuna->id) { in m88e1540_set_tunable()
1522 return -EOPNOTSUPP; in m88e1540_set_tunable()
1584 phydev->link = 0; in marvell_read_status_page_an()
1589 phydev->duplex = DUPLEX_FULL; in marvell_read_status_page_an()
1591 phydev->duplex = DUPLEX_HALF; in marvell_read_status_page_an()
1595 phydev->speed = SPEED_1000; in marvell_read_status_page_an()
1599 phydev->speed = SPEED_100; in marvell_read_status_page_an()
1603 phydev->speed = SPEED_10; in marvell_read_status_page_an()
1619 fiber_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); in marvell_read_status_page_an()
1621 if (phydev->duplex == DUPLEX_FULL) { in marvell_read_status_page_an()
1623 phydev->pause = 0; in marvell_read_status_page_an()
1624 phydev->asym_pause = 0; in marvell_read_status_page_an()
1626 phydev->pause = 1; in marvell_read_status_page_an()
1627 phydev->asym_pause = 1; in marvell_read_status_page_an()
1629 phydev->pause = 1; in marvell_read_status_page_an()
1630 phydev->asym_pause = 0; in marvell_read_status_page_an()
1660 phydev->link = !!(status & MII_M1011_PHY_STATUS_LINK); in marvell_read_status_page()
1672 linkmode_zero(phydev->lp_advertising); in marvell_read_status_page()
1673 phydev->pause = 0; in marvell_read_status_page()
1674 phydev->asym_pause = 0; in marvell_read_status_page()
1675 phydev->speed = SPEED_UNKNOWN; in marvell_read_status_page()
1676 phydev->duplex = DUPLEX_UNKNOWN; in marvell_read_status_page()
1677 phydev->port = fiber ? PORT_FIBRE : PORT_TP; in marvell_read_status_page()
1679 if (phydev->autoneg == AUTONEG_ENABLE) in marvell_read_status_page()
1702 phydev->supported) && in marvell_read_status()
1703 phydev->interface != PHY_INTERFACE_MODE_SGMII) { in marvell_read_status()
1719 if (phydev->link) in marvell_read_status()
1746 phydev->supported)) { in marvell_suspend()
1781 phydev->supported)) { in marvell_resume()
1817 wol->supported = WAKE_MAGIC | WAKE_PHY; in m88e1318_get_wol()
1818 wol->wolopts = 0; in m88e1318_get_wol()
1826 wol->wolopts |= WAKE_MAGIC; in m88e1318_get_wol()
1829 wol->wolopts |= WAKE_PHY; in m88e1318_get_wol()
1841 if (wol->wolopts & (WAKE_MAGIC | WAKE_PHY)) { in m88e1318_set_wol()
1875 if (wol->wolopts & WAKE_MAGIC) { in m88e1318_set_wol()
1882 ((phydev->attached_dev->dev_addr[5] << 8) | in m88e1318_set_wol()
1883 phydev->attached_dev->dev_addr[4])); in m88e1318_set_wol()
1887 ((phydev->attached_dev->dev_addr[3] << 8) | in m88e1318_set_wol()
1888 phydev->attached_dev->dev_addr[2])); in m88e1318_set_wol()
1892 ((phydev->attached_dev->dev_addr[1] << 8) | in m88e1318_set_wol()
1893 phydev->attached_dev->dev_addr[0])); in m88e1318_set_wol()
1916 if (wol->wolopts & WAKE_PHY) { in m88e1318_set_wol()
1947 phydev->supported)) in marvell_get_sset_count()
1950 return ARRAY_SIZE(marvell_hw_stats) - NB_FIBER_STATS; in marvell_get_sset_count()
1967 struct marvell_priv *priv = phydev->priv; in marvell_get_stat()
1975 val = val & ((1 << stat.bits) - 1); in marvell_get_stat()
1976 priv->stats[i] += val; in marvell_get_stat()
1977 ret = priv->stats[i]; in marvell_get_stat()
2000 bmcr_ctl = mii_bmcr_encode_fixed(phydev->speed, phydev->duplex); in m88e1510_loopback()
2006 if (phydev->speed == SPEED_1000) in m88e1510_loopback()
2008 else if (phydev->speed == SPEED_100) in m88e1510_loopback()
2027 * into/out-of loopback mode. in m88e1510_loopback()
2056 return -ETIMEDOUT; in marvell_vct5_wait_complete()
2075 amplitude = -amplitude; in marvell_vct5_amplitude()
2129 struct marvell_priv *priv = phydev->priv; in marvell_vct5_amplitude_graph()
2131 u16 width; in marvell_vct5_amplitude_graph() local
2136 if (priv->first <= TDR_SHORT_CABLE_LENGTH) in marvell_vct5_amplitude_graph()
2137 width = MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_32nS; in marvell_vct5_amplitude_graph()
2139 width = MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_128nS; in marvell_vct5_amplitude_graph()
2143 MII_VCT5_TX_PULSE_CTRL_MAX_AMP | width; in marvell_vct5_amplitude_graph()
2160 for (distance = priv->first; in marvell_vct5_amplitude_graph()
2161 distance <= priv->last; in marvell_vct5_amplitude_graph()
2162 distance += priv->step) { in marvell_vct5_amplitude_graph()
2164 priv->pair); in marvell_vct5_amplitude_graph()
2169 width == MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_32nS) { in marvell_vct5_amplitude_graph()
2170 width = MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_128nS; in marvell_vct5_amplitude_graph()
2173 MII_VCT5_TX_PULSE_CTRL_MAX_AMP | width; in marvell_vct5_amplitude_graph()
2188 /* If auto-negotiation is enabled, but not complete, the cable in marvell_cable_test_start_common()
2189 * test never completes. So disable auto-neg. in marvell_cable_test_start_common()
2218 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_start()
2225 priv->cable_test_tdr = false; in marvell_vct7_cable_test_start()
2253 struct marvell_priv *priv = phydev->priv; in marvell_vct5_cable_test_tdr_start()
2256 priv->cable_test_tdr = true; in marvell_vct5_cable_test_tdr_start()
2257 priv->first = marvell_vct5_cm2distance(cfg->first); in marvell_vct5_cable_test_tdr_start()
2258 priv->last = marvell_vct5_cm2distance(cfg->last); in marvell_vct5_cable_test_tdr_start()
2259 priv->step = marvell_vct5_cm2distance(cfg->step); in marvell_vct5_cable_test_tdr_start()
2260 priv->pair = cfg->pair; in marvell_vct5_cable_test_tdr_start()
2262 if (priv->first > MII_VCT5_SAMPLE_POINT_DISTANCE_MAX) in marvell_vct5_cable_test_tdr_start()
2263 return -EINVAL; in marvell_vct5_cable_test_tdr_start()
2265 if (priv->last > MII_VCT5_SAMPLE_POINT_DISTANCE_MAX) in marvell_vct5_cable_test_tdr_start()
2266 return -EINVAL; in marvell_vct5_cable_test_tdr_start()
2283 marvell_vct5_distance2cm(priv->first), in marvell_vct5_cable_test_tdr_start()
2284 marvell_vct5_distance2cm(priv->last), in marvell_vct5_cable_test_tdr_start()
2285 marvell_vct5_distance2cm(priv->step)); in marvell_vct5_cable_test_tdr_start()
2391 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_get_status()
2394 if (priv->cable_test_tdr) { in marvell_vct7_cable_test_get_status()
2429 return phydev->drv->driver_data; in to_marvell_hwmon_ops()
2469 *temp = ((val & MII_88E1121_MISC_TEST_TEMP_MASK) - 5) * 5000; in m88e1121_get_temp()
2486 *temp = ((ret & MII_88E1510_TEMP_SENSOR_MASK) - 25) * 1000; in m88e1510_get_temp()
2503 MII_88E1510_MISC_TEST_TEMP_THRESHOLD_SHIFT) * 5) - 25; in m88e1510_get_temp_critical()
2565 /* Reading the temperature sense has an errata. You need to read in m88e6390_get_temp()
2576 *temp = (sum - 75) * 1000; in m88e6390_get_temp()
2603 *temp -= 50000; in m88e6393_get_temp()
2620 MII_88E6393_TEMP_SENSOR_THRESHOLD_SHIFT) - 75) * 1000; in m88e6393_get_temp_critical()
2658 int err = -EOPNOTSUPP; in marvell_hwmon_read()
2662 if (ops->get_temp) in marvell_hwmon_read()
2663 err = ops->get_temp(phydev, temp); in marvell_hwmon_read()
2666 if (ops->get_temp_critical) in marvell_hwmon_read()
2667 err = ops->get_temp_critical(phydev, temp); in marvell_hwmon_read()
2670 if (ops->get_temp_alarm) in marvell_hwmon_read()
2671 err = ops->get_temp_alarm(phydev, temp); in marvell_hwmon_read()
2683 int err = -EOPNOTSUPP; in marvell_hwmon_write()
2687 if (ops->set_temp_critical) in marvell_hwmon_write()
2688 err = ops->set_temp_critical(phydev, temp); in marvell_hwmon_write()
2707 return ops->get_temp ? 0444 : 0; in marvell_hwmon_is_visible()
2709 return ops->get_temp_alarm ? 0444 : 0; in marvell_hwmon_is_visible()
2711 return (ops->get_temp_critical ? 0444 : 0) | in marvell_hwmon_is_visible()
2712 (ops->set_temp_critical ? 0200 : 0); in marvell_hwmon_is_visible()
2761 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_name()
2762 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_name()
2767 priv->hwmon_name = devm_kzalloc(dev, len, GFP_KERNEL); in marvell_hwmon_name()
2768 if (!priv->hwmon_name) in marvell_hwmon_name()
2769 return -ENOMEM; in marvell_hwmon_name()
2773 priv->hwmon_name[j++] = devname[i]; in marvell_hwmon_name()
2782 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_probe()
2783 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_probe()
2793 priv->hwmon_dev = devm_hwmon_device_register_with_info( in marvell_hwmon_probe()
2794 dev, priv->hwmon_name, phydev, &marvell_hwmon_chip_info, NULL); in marvell_hwmon_probe()
2795 if (IS_ERR(priv->hwmon_dev)) in marvell_hwmon_probe()
2796 return PTR_ERR(priv->hwmon_dev); in marvell_hwmon_probe()
2798 if (ops->config) in marvell_hwmon_probe()
2799 err = ops->config(phydev); in marvell_hwmon_probe()
2860 return -EINVAL; in m88e1318_led_brightness_set()
2889 return -EINVAL; in m88e1318_led_blink_set()
3030 return -EOPNOTSUPP; in marvell_find_led_mode()
3051 ret = -EINVAL; in marvell_get_led_mode()
3070 return -EOPNOTSUPP; in marvell_find_led_rules()
3091 ret = -EOPNOTSUPP; in marvell_get_led_rules()
3109 ret = -EINVAL; in m88e1318_led_hw_is_supported()
3127 ret = -EINVAL; in m88e1318_led_hw_control_set()
3150 return -EINVAL; in m88e1318_led_hw_control_get()
3166 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in marvell_probe()
3168 return -ENOMEM; in marvell_probe()
3170 phydev->priv = priv; in marvell_probe()
3187 dev = &phydev->mdio.dev; in m88e1510_sfp_insert()
3189 sfp_parse_support(phydev->sfp_bus, id, supported, interfaces); in m88e1510_sfp_insert()
3190 interface = sfp_select_interface(phydev->sfp_bus, supported); in m88e1510_sfp_insert()
3210 return -EINVAL; in m88e1510_sfp_insert()