Lines Matching +full:sense +full:- +full:bitfield +full:- +full:width
1 // SPDX-License-Identifier: GPL-2.0+
33 #include <linux/bitfield.h>
184 /* RGMII to 1000BASE-X */
186 /* RGMII to 100BASE-FX */
343 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in marvell_config_intr()
407 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in marvell_config_aneg()
422 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in marvell_config_aneg()
472 * marvell,reg-init property stored in the of_node for the phydev.
474 * marvell,reg-init = <reg-page reg mask value>,...;
476 * There may be one or more sets of <reg-page reg mask value>:
478 * reg-page: which register bank to use.
480 * mask: if non-zero, ANDed with existing register value.
489 if (!phydev->mdio.dev.of_node) in marvell_of_reg_init()
492 paddr = of_get_property(phydev->mdio.dev.of_node, in marvell_of_reg_init()
493 "marvell,reg-init", &len); in marvell_of_reg_init()
503 for (i = 0; i < len - 3; i += 4) { in marvell_of_reg_init()
546 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) in m88e1121_config_aneg_rgmii_delays()
549 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in m88e1121_config_aneg_rgmii_delays()
551 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in m88e1121_config_aneg_rgmii_delays()
574 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1121_config_aneg()
584 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in m88e1121_config_aneg()
636 * marvell_config_aneg_fiber - restart auto-negotiation or write BMCR
639 * Description: If auto-negotiation is enabled, we configure the
640 * advertising, and then restart auto-negotiation. If it is not
650 if (phydev->autoneg != AUTONEG_ENABLE) in marvell_config_aneg_fiber()
654 linkmode_and(phydev->advertising, phydev->advertising, in marvell_config_aneg_fiber()
655 phydev->supported); in marvell_config_aneg_fiber()
657 adv = linkmode_adv_to_fiber_adv_t(phydev->advertising); in marvell_config_aneg_fiber()
683 if (phydev->interface != PHY_INTERFACE_MODE_SGMII && in m88e1111_config_aneg()
702 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1111_config_aneg()
703 /* Do not touch the fiber advertisement if we're in copper->sgmii mode. in m88e1111_config_aneg()
704 * Just ensure that SGMII-side autonegotiation is enabled. in m88e1111_config_aneg()
733 /* Do not touch the fiber page if we're in copper->sgmii mode */ in m88e1510_config_aneg()
734 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1510_config_aneg()
758 switch (MARVELL_PHY_FAMILY_ID(phydev->phy_id)) { in marvell_config_led()
770 if (phydev->dev_flags & MARVELL_PHY_LED0_LINK_LED1_ACTIVE) in marvell_config_led()
790 /* Set registers from marvell,reg-init DT property */ in marvell_config_init()
798 /* Enable Scrambler and Auto-Crossover */ in m88e3016_config_init()
826 switch (phydev->interface) { in m88e1111_config_init_rgmii_delays()
918 /* If using copper mode, ensure 1000BaseX auto-negotiation is enabled */ in m88e1111_config_init_1000basex()
942 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1111_config_init()
948 if (phydev->interface == PHY_INTERFACE_MODE_RTBI) { in m88e1111_config_init()
954 if (phydev->interface == PHY_INTERFACE_MODE_1000BASEX) { in m88e1111_config_init()
968 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1111_config_init()
975 linkmode_or(phydev->advertising, phydev->advertising, in m88e1111_config_init()
976 phydev->supported); in m88e1111_config_init()
1002 return -E2BIG; in m88e1111_set_downshift()
1009 val |= FIELD_PREP(MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK, cnt - 1); in m88e1111_set_downshift()
1026 switch (tuna->id) { in m88e1111_get_tunable()
1030 return -EOPNOTSUPP; in m88e1111_get_tunable()
1037 switch (tuna->id) { in m88e1111_set_tunable()
1041 return -EOPNOTSUPP; in m88e1111_set_tunable()
1066 return -E2BIG; in m88e1011_set_downshift()
1073 val |= FIELD_PREP(MII_M1011_PHY_SCR_DOWNSHIFT_MASK, cnt - 1); in m88e1011_set_downshift()
1090 switch (tuna->id) { in m88e1011_get_tunable()
1094 return -EOPNOTSUPP; in m88e1011_get_tunable()
1101 switch (tuna->id) { in m88e1011_set_tunable()
1105 return -EOPNOTSUPP; in m88e1011_set_tunable()
1155 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1116r_config_init()
1205 /* As per Marvell Release Notes - Alaska 88E1510/88E1518/88E1512/ in m88e1510_config_init()
1233 /* SGMII-to-Copper mode initialization */ in m88e1510_config_init()
1234 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1510_config_init()
1269 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1118_config_aneg()
1298 if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS) in m88e1118_config_init()
1353 if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) { in m88e1145_config_init_rgmii()
1401 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { in m88e1145_config_init()
1407 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1145_config_init()
1452 return -EINVAL; in m88e1540_get_fld()
1473 return -EBUSY; in m88e1540_set_fld()
1499 switch (tuna->id) { in m88e1540_get_tunable()
1505 return -EOPNOTSUPP; in m88e1540_get_tunable()
1512 switch (tuna->id) { in m88e1540_set_tunable()
1518 return -EOPNOTSUPP; in m88e1540_set_tunable()
1580 phydev->link = 0; in marvell_read_status_page_an()
1585 phydev->duplex = DUPLEX_FULL; in marvell_read_status_page_an()
1587 phydev->duplex = DUPLEX_HALF; in marvell_read_status_page_an()
1591 phydev->speed = SPEED_1000; in marvell_read_status_page_an()
1595 phydev->speed = SPEED_100; in marvell_read_status_page_an()
1599 phydev->speed = SPEED_10; in marvell_read_status_page_an()
1615 fiber_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); in marvell_read_status_page_an()
1617 if (phydev->duplex == DUPLEX_FULL) { in marvell_read_status_page_an()
1619 phydev->pause = 0; in marvell_read_status_page_an()
1620 phydev->asym_pause = 0; in marvell_read_status_page_an()
1622 phydev->pause = 1; in marvell_read_status_page_an()
1623 phydev->asym_pause = 1; in marvell_read_status_page_an()
1625 phydev->pause = 1; in marvell_read_status_page_an()
1626 phydev->asym_pause = 0; in marvell_read_status_page_an()
1656 phydev->link = !!(status & MII_M1011_PHY_STATUS_LINK); in marvell_read_status_page()
1668 linkmode_zero(phydev->lp_advertising); in marvell_read_status_page()
1669 phydev->pause = 0; in marvell_read_status_page()
1670 phydev->asym_pause = 0; in marvell_read_status_page()
1671 phydev->speed = SPEED_UNKNOWN; in marvell_read_status_page()
1672 phydev->duplex = DUPLEX_UNKNOWN; in marvell_read_status_page()
1673 phydev->port = fiber ? PORT_FIBRE : PORT_TP; in marvell_read_status_page()
1675 if (phydev->autoneg == AUTONEG_ENABLE) in marvell_read_status_page()
1698 phydev->supported) && in marvell_read_status()
1699 phydev->interface != PHY_INTERFACE_MODE_SGMII) { in marvell_read_status()
1715 if (phydev->link) in marvell_read_status()
1742 phydev->supported)) { in marvell_suspend()
1777 phydev->supported)) { in marvell_resume()
1813 wol->supported = WAKE_MAGIC | WAKE_PHY; in m88e1318_get_wol()
1814 wol->wolopts = 0; in m88e1318_get_wol()
1822 wol->wolopts |= WAKE_MAGIC; in m88e1318_get_wol()
1825 wol->wolopts |= WAKE_PHY; in m88e1318_get_wol()
1837 if (wol->wolopts & (WAKE_MAGIC | WAKE_PHY)) { in m88e1318_set_wol()
1871 if (wol->wolopts & WAKE_MAGIC) { in m88e1318_set_wol()
1878 ((phydev->attached_dev->dev_addr[5] << 8) | in m88e1318_set_wol()
1879 phydev->attached_dev->dev_addr[4])); in m88e1318_set_wol()
1883 ((phydev->attached_dev->dev_addr[3] << 8) | in m88e1318_set_wol()
1884 phydev->attached_dev->dev_addr[2])); in m88e1318_set_wol()
1888 ((phydev->attached_dev->dev_addr[1] << 8) | in m88e1318_set_wol()
1889 phydev->attached_dev->dev_addr[0])); in m88e1318_set_wol()
1912 if (wol->wolopts & WAKE_PHY) { in m88e1318_set_wol()
1943 phydev->supported)) in marvell_get_sset_count()
1946 return ARRAY_SIZE(marvell_hw_stats) - NB_FIBER_STATS; in marvell_get_sset_count()
1963 struct marvell_priv *priv = phydev->priv; in marvell_get_stat()
1971 val = val & ((1 << stat.bits) - 1); in marvell_get_stat()
1972 priv->stats[i] += val; in marvell_get_stat()
1973 ret = priv->stats[i]; in marvell_get_stat()
1996 bmcr_ctl = mii_bmcr_encode_fixed(phydev->speed, phydev->duplex); in m88e1510_loopback()
2002 if (phydev->speed == SPEED_1000) in m88e1510_loopback()
2004 else if (phydev->speed == SPEED_100) in m88e1510_loopback()
2023 * into/out-of loopback mode. in m88e1510_loopback()
2052 return -ETIMEDOUT; in marvell_vct5_wait_complete()
2071 amplitude = -amplitude; in marvell_vct5_amplitude()
2125 struct marvell_priv *priv = phydev->priv; in marvell_vct5_amplitude_graph()
2127 u16 width; in marvell_vct5_amplitude_graph() local
2132 if (priv->first <= TDR_SHORT_CABLE_LENGTH) in marvell_vct5_amplitude_graph()
2133 width = MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_32nS; in marvell_vct5_amplitude_graph()
2135 width = MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_128nS; in marvell_vct5_amplitude_graph()
2139 MII_VCT5_TX_PULSE_CTRL_MAX_AMP | width; in marvell_vct5_amplitude_graph()
2156 for (distance = priv->first; in marvell_vct5_amplitude_graph()
2157 distance <= priv->last; in marvell_vct5_amplitude_graph()
2158 distance += priv->step) { in marvell_vct5_amplitude_graph()
2160 priv->pair); in marvell_vct5_amplitude_graph()
2165 width == MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_32nS) { in marvell_vct5_amplitude_graph()
2166 width = MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_128nS; in marvell_vct5_amplitude_graph()
2169 MII_VCT5_TX_PULSE_CTRL_MAX_AMP | width; in marvell_vct5_amplitude_graph()
2184 /* If auto-negotiation is enabled, but not complete, the cable in marvell_cable_test_start_common()
2185 * test never completes. So disable auto-neg. in marvell_cable_test_start_common()
2214 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_start()
2221 priv->cable_test_tdr = false; in marvell_vct7_cable_test_start()
2249 struct marvell_priv *priv = phydev->priv; in marvell_vct5_cable_test_tdr_start()
2252 priv->cable_test_tdr = true; in marvell_vct5_cable_test_tdr_start()
2253 priv->first = marvell_vct5_cm2distance(cfg->first); in marvell_vct5_cable_test_tdr_start()
2254 priv->last = marvell_vct5_cm2distance(cfg->last); in marvell_vct5_cable_test_tdr_start()
2255 priv->step = marvell_vct5_cm2distance(cfg->step); in marvell_vct5_cable_test_tdr_start()
2256 priv->pair = cfg->pair; in marvell_vct5_cable_test_tdr_start()
2258 if (priv->first > MII_VCT5_SAMPLE_POINT_DISTANCE_MAX) in marvell_vct5_cable_test_tdr_start()
2259 return -EINVAL; in marvell_vct5_cable_test_tdr_start()
2261 if (priv->last > MII_VCT5_SAMPLE_POINT_DISTANCE_MAX) in marvell_vct5_cable_test_tdr_start()
2262 return -EINVAL; in marvell_vct5_cable_test_tdr_start()
2279 marvell_vct5_distance2cm(priv->first), in marvell_vct5_cable_test_tdr_start()
2280 marvell_vct5_distance2cm(priv->last), in marvell_vct5_cable_test_tdr_start()
2281 marvell_vct5_distance2cm(priv->step)); in marvell_vct5_cable_test_tdr_start()
2387 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_get_status()
2390 if (priv->cable_test_tdr) { in marvell_vct7_cable_test_get_status()
2425 return phydev->drv->driver_data; in to_marvell_hwmon_ops()
2465 *temp = ((val & MII_88E1121_MISC_TEST_TEMP_MASK) - 5) * 5000; in m88e1121_get_temp()
2482 *temp = ((ret & MII_88E1510_TEMP_SENSOR_MASK) - 25) * 1000; in m88e1510_get_temp()
2499 MII_88E1510_MISC_TEST_TEMP_THRESHOLD_SHIFT) * 5) - 25; in m88e1510_get_temp_critical()
2561 /* Reading the temperature sense has an errata. You need to read in m88e6390_get_temp()
2572 *temp = (sum - 75) * 1000; in m88e6390_get_temp()
2599 *temp -= 50000; in m88e6393_get_temp()
2616 MII_88E6393_TEMP_SENSOR_THRESHOLD_SHIFT) - 75) * 1000; in m88e6393_get_temp_critical()
2654 int err = -EOPNOTSUPP; in marvell_hwmon_read()
2658 if (ops->get_temp) in marvell_hwmon_read()
2659 err = ops->get_temp(phydev, temp); in marvell_hwmon_read()
2662 if (ops->get_temp_critical) in marvell_hwmon_read()
2663 err = ops->get_temp_critical(phydev, temp); in marvell_hwmon_read()
2666 if (ops->get_temp_alarm) in marvell_hwmon_read()
2667 err = ops->get_temp_alarm(phydev, temp); in marvell_hwmon_read()
2679 int err = -EOPNOTSUPP; in marvell_hwmon_write()
2683 if (ops->set_temp_critical) in marvell_hwmon_write()
2684 err = ops->set_temp_critical(phydev, temp); in marvell_hwmon_write()
2703 return ops->get_temp ? 0444 : 0; in marvell_hwmon_is_visible()
2705 return ops->get_temp_alarm ? 0444 : 0; in marvell_hwmon_is_visible()
2707 return (ops->get_temp_critical ? 0444 : 0) | in marvell_hwmon_is_visible()
2708 (ops->set_temp_critical ? 0200 : 0); in marvell_hwmon_is_visible()
2757 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_name()
2758 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_name()
2763 priv->hwmon_name = devm_kzalloc(dev, len, GFP_KERNEL); in marvell_hwmon_name()
2764 if (!priv->hwmon_name) in marvell_hwmon_name()
2765 return -ENOMEM; in marvell_hwmon_name()
2769 priv->hwmon_name[j++] = devname[i]; in marvell_hwmon_name()
2778 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_probe()
2779 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_probe()
2789 priv->hwmon_dev = devm_hwmon_device_register_with_info( in marvell_hwmon_probe()
2790 dev, priv->hwmon_name, phydev, &marvell_hwmon_chip_info, NULL); in marvell_hwmon_probe()
2791 if (IS_ERR(priv->hwmon_dev)) in marvell_hwmon_probe()
2792 return PTR_ERR(priv->hwmon_dev); in marvell_hwmon_probe()
2794 if (ops->config) in marvell_hwmon_probe()
2795 err = ops->config(phydev); in marvell_hwmon_probe()
2839 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in marvell_probe()
2841 return -ENOMEM; in marvell_probe()
2843 phydev->priv = priv; in marvell_probe()
2860 dev = &phydev->mdio.dev; in m88e1510_sfp_insert()
2862 sfp_parse_support(phydev->sfp_bus, id, supported, interfaces); in m88e1510_sfp_insert()
2863 interface = sfp_select_interface(phydev->sfp_bus, supported); in m88e1510_sfp_insert()
2883 return -EINVAL; in m88e1510_sfp_insert()