Lines Matching +full:sense +full:- +full:bitfield +full:- +full:width

1 // SPDX-License-Identifier: GPL-2.0+
33 #include <linux/bitfield.h>
189 /* RGMII to 1000BASE-X */
191 /* RGMII to 100BASE-FX */
391 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in marvell_config_intr()
455 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in marvell_config_aneg()
470 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in marvell_config_aneg()
520 * marvell,reg-init property stored in the of_node for the phydev.
522 * marvell,reg-init = <reg-page reg mask value>,...;
524 * There may be one or more sets of <reg-page reg mask value>:
526 * reg-page: which register bank to use.
528 * mask: if non-zero, ANDed with existing register value.
537 if (!phydev->mdio.dev.of_node) in marvell_of_reg_init()
540 paddr = of_get_property(phydev->mdio.dev.of_node, in marvell_of_reg_init()
541 "marvell,reg-init", &len); in marvell_of_reg_init()
551 for (i = 0; i < len - 3; i += 4) { in marvell_of_reg_init()
594 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) in m88e1121_config_aneg_rgmii_delays()
597 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in m88e1121_config_aneg_rgmii_delays()
599 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in m88e1121_config_aneg_rgmii_delays()
622 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1121_config_aneg()
632 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in m88e1121_config_aneg()
684 * marvell_config_aneg_fiber - restart auto-negotiation or write BMCR
687 * Description: If auto-negotiation is enabled, we configure the
688 * advertising, and then restart auto-negotiation. If it is not
698 if (phydev->autoneg != AUTONEG_ENABLE) in marvell_config_aneg_fiber()
702 linkmode_and(phydev->advertising, phydev->advertising, in marvell_config_aneg_fiber()
703 phydev->supported); in marvell_config_aneg_fiber()
705 adv = linkmode_adv_to_fiber_adv_t(phydev->advertising); in marvell_config_aneg_fiber()
723 /* In 1000base-X and SGMII modes, the inband mode can be changed in m88e1111_inband_caps()
739 if (phydev->interface != PHY_INTERFACE_MODE_1000BASEX && in m88e1111_config_inband()
740 phydev->interface != PHY_INTERFACE_MODE_SGMII) in m88e1111_config_inband()
741 return -EINVAL; in m88e1111_config_inband()
773 if (phydev->interface != PHY_INTERFACE_MODE_SGMII && in m88e1111_config_aneg()
792 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1111_config_aneg()
793 /* Do not touch the fiber advertisement if we're in copper->sgmii mode. in m88e1111_config_aneg()
794 * Just ensure that SGMII-side autonegotiation is enabled. in m88e1111_config_aneg()
823 /* Do not touch the fiber page if we're in copper->sgmii mode */ in m88e1510_config_aneg()
824 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1510_config_aneg()
848 switch (MARVELL_PHY_FAMILY_ID(phydev->phy_id)) { in marvell_config_led()
860 if (phydev->dev_flags & MARVELL_PHY_LED0_LINK_LED1_ACTIVE) in marvell_config_led()
880 /* Set registers from marvell,reg-init DT property */ in marvell_config_init()
888 /* Enable Scrambler and Auto-Crossover */ in m88e3016_config_init()
916 switch (phydev->interface) { in m88e1111_config_init_rgmii_delays()
1008 /* If using copper mode, ensure 1000BaseX auto-negotiation is enabled. in m88e1111_config_init_1000basex()
1009 * FIXME: this does not actually enable 1000BaseX auto-negotiation if in m88e1111_config_init_1000basex()
1035 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1111_config_init()
1041 if (phydev->interface == PHY_INTERFACE_MODE_RTBI) { in m88e1111_config_init()
1047 if (phydev->interface == PHY_INTERFACE_MODE_1000BASEX) { in m88e1111_config_init()
1061 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1111_config_init()
1068 linkmode_or(phydev->advertising, phydev->advertising, in m88e1111_config_init()
1069 phydev->supported); in m88e1111_config_init()
1095 return -E2BIG; in m88e1111_set_downshift()
1102 val |= FIELD_PREP(MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK, cnt - 1); in m88e1111_set_downshift()
1119 switch (tuna->id) { in m88e1111_get_tunable()
1123 return -EOPNOTSUPP; in m88e1111_get_tunable()
1130 switch (tuna->id) { in m88e1111_set_tunable()
1134 return -EOPNOTSUPP; in m88e1111_set_tunable()
1159 return -E2BIG; in m88e1011_set_downshift()
1166 val |= FIELD_PREP(MII_M1011_PHY_SCR_DOWNSHIFT_MASK, cnt - 1); in m88e1011_set_downshift()
1183 switch (tuna->id) { in m88e1011_get_tunable()
1187 return -EOPNOTSUPP; in m88e1011_get_tunable()
1194 switch (tuna->id) { in m88e1011_set_tunable()
1198 return -EOPNOTSUPP; in m88e1011_set_tunable()
1248 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1116r_config_init()
1298 /* As per Marvell Release Notes - Alaska 88E1510/88E1518/88E1512/ in m88e1510_config_init()
1326 /* SGMII-to-Copper mode initialization */ in m88e1510_config_init()
1327 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1510_config_init()
1362 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1118_config_aneg()
1391 if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS) in m88e1118_config_init()
1446 if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) { in m88e1145_config_init_rgmii()
1494 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { in m88e1145_config_init()
1500 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1145_config_init()
1545 return -EINVAL; in m88e1540_get_fld()
1562 if (phydev->eee_cfg.eee_enabled) { in m88e1540_set_fld()
1564 return -EBUSY; in m88e1540_set_fld()
1590 switch (tuna->id) { in m88e1540_get_tunable()
1596 return -EOPNOTSUPP; in m88e1540_get_tunable()
1603 switch (tuna->id) { in m88e1540_set_tunable()
1609 return -EOPNOTSUPP; in m88e1540_set_tunable()
1671 phydev->link = 0; in marvell_read_status_page_an()
1676 phydev->duplex = DUPLEX_FULL; in marvell_read_status_page_an()
1678 phydev->duplex = DUPLEX_HALF; in marvell_read_status_page_an()
1682 phydev->speed = SPEED_1000; in marvell_read_status_page_an()
1686 phydev->speed = SPEED_100; in marvell_read_status_page_an()
1690 phydev->speed = SPEED_10; in marvell_read_status_page_an()
1706 fiber_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); in marvell_read_status_page_an()
1708 if (phydev->duplex == DUPLEX_FULL) { in marvell_read_status_page_an()
1710 phydev->pause = 0; in marvell_read_status_page_an()
1711 phydev->asym_pause = 0; in marvell_read_status_page_an()
1713 phydev->pause = 1; in marvell_read_status_page_an()
1714 phydev->asym_pause = 1; in marvell_read_status_page_an()
1716 phydev->pause = 1; in marvell_read_status_page_an()
1717 phydev->asym_pause = 0; in marvell_read_status_page_an()
1747 phydev->link = !!(status & MII_M1011_PHY_STATUS_LINK); in marvell_read_status_page()
1759 linkmode_zero(phydev->lp_advertising); in marvell_read_status_page()
1760 phydev->pause = 0; in marvell_read_status_page()
1761 phydev->asym_pause = 0; in marvell_read_status_page()
1762 phydev->speed = SPEED_UNKNOWN; in marvell_read_status_page()
1763 phydev->duplex = DUPLEX_UNKNOWN; in marvell_read_status_page()
1764 phydev->port = fiber ? PORT_FIBRE : PORT_TP; in marvell_read_status_page()
1767 phydev->mdix = ETH_TP_MDI_INVALID; in marvell_read_status_page()
1769 /* The MDI-X state is set regardless of Autoneg being enabled in marvell_read_status_page()
1770 * and reflects forced MDI-X state as well as auto resolution in marvell_read_status_page()
1773 phydev->mdix = status & MII_M1011_PHY_STATUS_MDIX ? in marvell_read_status_page()
1776 phydev->mdix = ETH_TP_MDI_INVALID; in marvell_read_status_page()
1779 if (phydev->autoneg == AUTONEG_ENABLE) in marvell_read_status_page()
1802 phydev->supported) && in marvell_read_status()
1803 phydev->interface != PHY_INTERFACE_MODE_SGMII) { in marvell_read_status()
1819 if (phydev->link) in marvell_read_status()
1846 phydev->supported)) { in marvell_suspend()
1881 phydev->supported)) { in marvell_resume()
1917 wol->supported = WAKE_MAGIC | WAKE_PHY; in m88e1318_get_wol()
1918 wol->wolopts = 0; in m88e1318_get_wol()
1926 wol->wolopts |= WAKE_MAGIC; in m88e1318_get_wol()
1929 wol->wolopts |= WAKE_PHY; in m88e1318_get_wol()
1941 if (wol->wolopts & (WAKE_MAGIC | WAKE_PHY)) { in m88e1318_set_wol()
1975 if (wol->wolopts & WAKE_MAGIC) { in m88e1318_set_wol()
1982 ((phydev->attached_dev->dev_addr[5] << 8) | in m88e1318_set_wol()
1983 phydev->attached_dev->dev_addr[4])); in m88e1318_set_wol()
1987 ((phydev->attached_dev->dev_addr[3] << 8) | in m88e1318_set_wol()
1988 phydev->attached_dev->dev_addr[2])); in m88e1318_set_wol()
1992 ((phydev->attached_dev->dev_addr[1] << 8) | in m88e1318_set_wol()
1993 phydev->attached_dev->dev_addr[0])); in m88e1318_set_wol()
2016 if (wol->wolopts & WAKE_PHY) { in m88e1318_set_wol()
2047 phydev->supported)) in marvell_get_sset_count()
2050 return ARRAY_SIZE(marvell_hw_stats) - NB_FIBER_STATS; in marvell_get_sset_count()
2079 struct marvell_priv *priv = phydev->priv; in marvell_get_stat()
2087 val = val & ((1 << stat.bits) - 1); in marvell_get_stat()
2088 priv->stats[i] += val; in marvell_get_stat()
2089 ret = priv->stats[i]; in marvell_get_stat()
2098 struct marvell_priv *priv = phydev->priv; in marvell_get_stat_simple()
2106 val = val & ((1 << stat.bits) - 1); in marvell_get_stat_simple()
2107 priv->stats[i] += val; in marvell_get_stat_simple()
2108 ret = priv->stats[i]; in marvell_get_stat_simple()
2141 bmcr_ctl = mii_bmcr_encode_fixed(phydev->speed, phydev->duplex); in m88e1510_loopback()
2147 if (phydev->speed == SPEED_1000) in m88e1510_loopback()
2149 else if (phydev->speed == SPEED_100) in m88e1510_loopback()
2168 * into/out-of loopback mode. in m88e1510_loopback()
2197 return -ETIMEDOUT; in marvell_vct5_wait_complete()
2216 amplitude = -amplitude; in marvell_vct5_amplitude()
2270 struct marvell_priv *priv = phydev->priv; in marvell_vct5_amplitude_graph()
2272 u16 width; in marvell_vct5_amplitude_graph() local
2277 if (priv->first <= TDR_SHORT_CABLE_LENGTH) in marvell_vct5_amplitude_graph()
2278 width = MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_32nS; in marvell_vct5_amplitude_graph()
2280 width = MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_128nS; in marvell_vct5_amplitude_graph()
2284 MII_VCT5_TX_PULSE_CTRL_MAX_AMP | width; in marvell_vct5_amplitude_graph()
2301 for (distance = priv->first; in marvell_vct5_amplitude_graph()
2302 distance <= priv->last; in marvell_vct5_amplitude_graph()
2303 distance += priv->step) { in marvell_vct5_amplitude_graph()
2305 priv->pair); in marvell_vct5_amplitude_graph()
2310 width == MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_32nS) { in marvell_vct5_amplitude_graph()
2311 width = MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_128nS; in marvell_vct5_amplitude_graph()
2314 MII_VCT5_TX_PULSE_CTRL_MAX_AMP | width; in marvell_vct5_amplitude_graph()
2329 /* If auto-negotiation is enabled, but not complete, the cable in marvell_cable_test_start_common()
2330 * test never completes. So disable auto-neg. in marvell_cable_test_start_common()
2359 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_start()
2366 priv->cable_test_tdr = false; in marvell_vct7_cable_test_start()
2394 struct marvell_priv *priv = phydev->priv; in marvell_vct5_cable_test_tdr_start()
2397 priv->cable_test_tdr = true; in marvell_vct5_cable_test_tdr_start()
2398 priv->first = marvell_vct5_cm2distance(cfg->first); in marvell_vct5_cable_test_tdr_start()
2399 priv->last = marvell_vct5_cm2distance(cfg->last); in marvell_vct5_cable_test_tdr_start()
2400 priv->step = marvell_vct5_cm2distance(cfg->step); in marvell_vct5_cable_test_tdr_start()
2401 priv->pair = cfg->pair; in marvell_vct5_cable_test_tdr_start()
2403 if (priv->first > MII_VCT5_SAMPLE_POINT_DISTANCE_MAX) in marvell_vct5_cable_test_tdr_start()
2404 return -EINVAL; in marvell_vct5_cable_test_tdr_start()
2406 if (priv->last > MII_VCT5_SAMPLE_POINT_DISTANCE_MAX) in marvell_vct5_cable_test_tdr_start()
2407 return -EINVAL; in marvell_vct5_cable_test_tdr_start()
2424 marvell_vct5_distance2cm(priv->first), in marvell_vct5_cable_test_tdr_start()
2425 marvell_vct5_distance2cm(priv->last), in marvell_vct5_cable_test_tdr_start()
2426 marvell_vct5_distance2cm(priv->step)); in marvell_vct5_cable_test_tdr_start()
2532 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_get_status()
2535 if (priv->cable_test_tdr) { in marvell_vct7_cable_test_get_status()
2560 struct marvell_priv *priv = phydev->priv; in m88e3082_vct_cable_test_start()
2573 if (priv->vct_phase == M88E3082_VCT_PHASE1) { in m88e3082_vct_cable_test_start()
2600 if (priv->vct_phase == M88E3082_VCT_OFF) { in m88e3082_vct_cable_test_start()
2601 priv->vct_phase = M88E3082_VCT_PHASE1; in m88e3082_vct_cable_test_start()
2602 priv->pair = 0; in m88e3082_vct_cable_test_start()
2615 priv->vct_phase = M88E3082_VCT_PHASE2; in m88e3082_vct_cable_test_start()
2641 /* Original function for meters: y = 0.7861x - 18.862 */ in m88e3082_vct_distrfln_2_cm()
2642 return (7861 * distrfln - 188620) / 100; in m88e3082_vct_distrfln_2_cm()
2649 struct marvell_priv *priv = phydev->priv; in m88e3082_vct_cable_test_get_status()
2675 switch (priv->vct_phase) { in m88e3082_vct_cable_test_get_status()
2689 priv->pair |= M88E3082_PAIR_A; in m88e3082_vct_cable_test_get_status()
2699 priv->pair |= M88E3082_PAIR_B; in m88e3082_vct_cable_test_get_status()
2709 if (priv->pair & M88E3082_PAIR_A && in m88e3082_vct_cable_test_get_status()
2717 if (priv->pair & M88E3082_PAIR_B && in m88e3082_vct_cable_test_get_status()
2728 return -EINVAL; in m88e3082_vct_cable_test_get_status()
2736 priv->vct_phase = M88E3082_VCT_OFF; in m88e3082_vct_cable_test_get_status()
2787 /* Original function for meters: y = 0.8018x - 28.751 */ in m88e1111_vct_distrfln_2_cm()
2788 return (8018 * distrfln - 287510) / 100; in m88e1111_vct_distrfln_2_cm()
2799 /* Each pair use one page: A-0, B-1, C-2, D-3 */ in m88e1111_vct_cable_test_get_status()
2838 return phydev->drv->driver_data; in to_marvell_hwmon_ops()
2878 *temp = ((val & MII_88E1121_MISC_TEST_TEMP_MASK) - 5) * 5000; in m88e1121_get_temp()
2895 *temp = ((ret & MII_88E1510_TEMP_SENSOR_MASK) - 25) * 1000; in m88e1510_get_temp()
2912 MII_88E1510_MISC_TEST_TEMP_THRESHOLD_SHIFT) * 5) - 25; in m88e1510_get_temp_critical()
2974 /* Reading the temperature sense has an errata. You need to read in m88e6390_get_temp()
2985 *temp = (sum - 75) * 1000; in m88e6390_get_temp()
3012 *temp -= 50000; in m88e6393_get_temp()
3029 MII_88E6393_TEMP_SENSOR_THRESHOLD_SHIFT) - 75) * 1000; in m88e6393_get_temp_critical()
3067 int err = -EOPNOTSUPP; in marvell_hwmon_read()
3071 if (ops->get_temp) in marvell_hwmon_read()
3072 err = ops->get_temp(phydev, temp); in marvell_hwmon_read()
3075 if (ops->get_temp_critical) in marvell_hwmon_read()
3076 err = ops->get_temp_critical(phydev, temp); in marvell_hwmon_read()
3079 if (ops->get_temp_alarm) in marvell_hwmon_read()
3080 err = ops->get_temp_alarm(phydev, temp); in marvell_hwmon_read()
3092 int err = -EOPNOTSUPP; in marvell_hwmon_write()
3096 if (ops->set_temp_critical) in marvell_hwmon_write()
3097 err = ops->set_temp_critical(phydev, temp); in marvell_hwmon_write()
3116 return ops->get_temp ? 0444 : 0; in marvell_hwmon_is_visible()
3118 return ops->get_temp_alarm ? 0444 : 0; in marvell_hwmon_is_visible()
3120 return (ops->get_temp_critical ? 0444 : 0) | in marvell_hwmon_is_visible()
3121 (ops->set_temp_critical ? 0200 : 0); in marvell_hwmon_is_visible()
3170 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_name()
3171 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_name()
3176 priv->hwmon_name = devm_kzalloc(dev, len, GFP_KERNEL); in marvell_hwmon_name()
3177 if (!priv->hwmon_name) in marvell_hwmon_name()
3178 return -ENOMEM; in marvell_hwmon_name()
3182 priv->hwmon_name[j++] = devname[i]; in marvell_hwmon_name()
3191 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_probe()
3192 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_probe()
3202 priv->hwmon_dev = devm_hwmon_device_register_with_info( in marvell_hwmon_probe()
3203 dev, priv->hwmon_name, phydev, &marvell_hwmon_chip_info, NULL); in marvell_hwmon_probe()
3204 if (IS_ERR(priv->hwmon_dev)) in marvell_hwmon_probe()
3205 return PTR_ERR(priv->hwmon_dev); in marvell_hwmon_probe()
3207 if (ops->config) in marvell_hwmon_probe()
3208 err = ops->config(phydev); in marvell_hwmon_probe()
3269 return -EINVAL; in m88e1318_led_brightness_set()
3298 return -EINVAL; in m88e1318_led_blink_set()
3439 return -EOPNOTSUPP; in marvell_find_led_mode()
3460 ret = -EINVAL; in marvell_get_led_mode()
3479 return -EOPNOTSUPP; in marvell_find_led_rules()
3500 ret = -EOPNOTSUPP; in marvell_get_led_rules()
3518 ret = -EINVAL; in m88e1318_led_hw_is_supported()
3536 ret = -EINVAL; in m88e1318_led_hw_control_set()
3559 return -EINVAL; in m88e1318_led_hw_control_get()
3575 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in marvell_probe()
3577 return -ENOMEM; in marvell_probe()
3579 phydev->priv = priv; in marvell_probe()
3596 dev = &phydev->mdio.dev; in m88e1510_sfp_insert()
3598 sfp_parse_support(phydev->sfp_bus, id, supported, interfaces); in m88e1510_sfp_insert()
3599 interface = sfp_select_interface(phydev->sfp_bus, supported); in m88e1510_sfp_insert()
3619 return -EINVAL; in m88e1510_sfp_insert()