Lines Matching full:phydev
98 static int qca808x_phy_fast_retrain_config(struct phy_device *phydev) in qca808x_phy_fast_retrain_config() argument
103 ret = genphy_c45_fast_retrain(phydev, true); in qca808x_phy_fast_retrain_config()
107 phy_write_mmd(phydev, MDIO_MMD_AN, QCA808X_PHY_MMD7_TOP_OPTION1, in qca808x_phy_fast_retrain_config()
109 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_20DB, in qca808x_phy_fast_retrain_config()
111 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_17DB, in qca808x_phy_fast_retrain_config()
113 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_27DB, in qca808x_phy_fast_retrain_config()
115 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_28DB, in qca808x_phy_fast_retrain_config()
117 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_1, in qca808x_phy_fast_retrain_config()
119 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_4, in qca808x_phy_fast_retrain_config()
121 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_5, in qca808x_phy_fast_retrain_config()
123 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_3, in qca808x_phy_fast_retrain_config()
125 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_6, in qca808x_phy_fast_retrain_config()
127 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_2, in qca808x_phy_fast_retrain_config()
133 static int qca808x_phy_ms_seed_enable(struct phy_device *phydev, bool enable) in qca808x_phy_ms_seed_enable() argument
138 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED, in qca808x_phy_ms_seed_enable()
142 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED, in qca808x_phy_ms_seed_enable()
148 static bool qca808x_is_prefer_master(struct phy_device *phydev) in qca808x_is_prefer_master() argument
150 return (phydev->master_slave_get == MASTER_SLAVE_CFG_MASTER_FORCE) || in qca808x_is_prefer_master()
151 (phydev->master_slave_get == MASTER_SLAVE_CFG_MASTER_PREFERRED); in qca808x_is_prefer_master()
154 static bool qca808x_has_fast_retrain_or_slave_seed(struct phy_device *phydev) in qca808x_has_fast_retrain_or_slave_seed() argument
156 return linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported); in qca808x_has_fast_retrain_or_slave_seed()
159 static bool qca808x_is_1g_only(struct phy_device *phydev) in qca808x_is_1g_only() argument
163 ret = phy_read_mmd(phydev, MDIO_MMD_AN, QCA808X_PHY_MMD7_CHIP_TYPE); in qca808x_is_1g_only()
170 static void qca808x_fill_possible_interfaces(struct phy_device *phydev) in qca808x_fill_possible_interfaces() argument
172 unsigned long *possible = phydev->possible_interfaces; in qca808x_fill_possible_interfaces()
176 if (!qca808x_is_1g_only(phydev)) in qca808x_fill_possible_interfaces()
180 static int qca808x_probe(struct phy_device *phydev) in qca808x_probe() argument
182 struct device *dev = &phydev->mdio.dev; in qca808x_probe()
192 phydev->priv = priv; in qca808x_probe()
197 static int qca808x_config_init(struct phy_device *phydev) in qca808x_config_init() argument
199 struct qca808x_priv *priv = phydev->priv; in qca808x_config_init()
204 ret = phy_set_bits_mmd(phydev, MDIO_MMD_AN, in qca808x_config_init()
212 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_ADDR_CLD_CTRL7, in qca808x_config_init()
218 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, in qca808x_config_init()
224 if (qca808x_has_fast_retrain_or_slave_seed(phydev)) { in qca808x_config_init()
226 ret = qca808x_phy_fast_retrain_config(phydev); in qca808x_config_init()
230 ret = genphy_read_master_slave(phydev); in qca808x_config_init()
234 if (!qca808x_is_prefer_master(phydev)) { in qca808x_config_init()
238 ret = qca808x_phy_ms_seed_enable(phydev, true); in qca808x_config_init()
244 qca808x_fill_possible_interfaces(phydev); in qca808x_config_init()
247 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_ADC_THRESHOLD, in qca808x_config_init()
252 static int qca808x_read_status(struct phy_device *phydev) in qca808x_read_status() argument
257 ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_STAT); in qca808x_read_status()
261 linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->lp_advertising, in qca808x_read_status()
264 ret = genphy_read_status(phydev); in qca808x_read_status()
271 ret = at803x_read_specific_status(phydev, ss_mask); in qca808x_read_status()
275 if (phydev->link) { in qca808x_read_status()
276 if (phydev->speed == SPEED_2500) in qca808x_read_status()
277 phydev->interface = PHY_INTERFACE_MODE_2500BASEX; in qca808x_read_status()
279 phydev->interface = PHY_INTERFACE_MODE_SGMII; in qca808x_read_status()
290 if (qca808x_has_fast_retrain_or_slave_seed(phydev)) { in qca808x_read_status()
291 if (phydev->master_slave_state == MASTER_SLAVE_STATE_ERR || in qca808x_read_status()
292 qca808x_is_prefer_master(phydev)) { in qca808x_read_status()
293 qca808x_phy_ms_seed_enable(phydev, false); in qca808x_read_status()
295 qca808x_phy_ms_seed_enable(phydev, true); in qca808x_read_status()
303 static int qca808x_soft_reset(struct phy_device *phydev) in qca808x_soft_reset() argument
307 ret = genphy_soft_reset(phydev); in qca808x_soft_reset()
311 if (qca808x_has_fast_retrain_or_slave_seed(phydev)) in qca808x_soft_reset()
312 ret = qca808x_phy_ms_seed_enable(phydev, true); in qca808x_soft_reset()
317 static int qca808x_cable_test_start(struct phy_device *phydev) in qca808x_cable_test_start() argument
328 ret = at803x_debug_reg_mask(phydev, QCA808X_DBG_AN_TEST, QCA808X_HIBERNATION_EN, 0); in qca808x_cable_test_start()
332 ret = at803x_config_mdix(phydev, ETH_TP_MDI); in qca808x_cable_test_start()
337 phydev->duplex = DUPLEX_FULL; in qca808x_cable_test_start()
338 phydev->speed = SPEED_1000; in qca808x_cable_test_start()
339 ret = genphy_c45_pma_setup_forced(phydev); in qca808x_cable_test_start()
343 ret = genphy_setup_forced(phydev); in qca808x_cable_test_start()
348 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8074, 0xc040); in qca808x_cable_test_start()
349 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8076, 0xc040); in qca808x_cable_test_start()
350 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8077, 0xa060); in qca808x_cable_test_start()
351 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8078, 0xc050); in qca808x_cable_test_start()
352 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807a, 0xc060); in qca808x_cable_test_start()
353 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807e, 0xb060); in qca808x_cable_test_start()
358 static int qca808x_get_features(struct phy_device *phydev) in qca808x_get_features() argument
362 ret = genphy_c45_pma_read_abilities(phydev); in qca808x_get_features()
370 linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported); in qca808x_get_features()
376 if (qca808x_is_1g_only(phydev)) in qca808x_get_features()
377 linkmode_clear_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported); in qca808x_get_features()
382 static int qca808x_config_aneg(struct phy_device *phydev) in qca808x_config_aneg() argument
387 ret = at803x_prepare_config_aneg(phydev); in qca808x_config_aneg()
394 if (phydev->autoneg == AUTONEG_DISABLE) in qca808x_config_aneg()
395 genphy_c45_pma_setup_forced(phydev); in qca808x_config_aneg()
397 if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->advertising)) in qca808x_config_aneg()
400 ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL, in qca808x_config_aneg()
405 return __genphy_config_aneg(phydev, ret); in qca808x_config_aneg()
408 static void qca808x_link_change_notify(struct phy_device *phydev) in qca808x_link_change_notify() argument
413 mdiobus_c45_modify_changed(phydev->mdio.bus, phydev->mdio.addr + 1, in qca808x_link_change_notify()
416 phydev->link ? QCA8081_PHY_FIFO_RSTN : 0); in qca808x_link_change_notify()
419 static int qca808x_led_parse_netdev(struct phy_device *phydev, unsigned long rules, in qca808x_led_parse_netdev() argument
451 static int qca808x_led_hw_control_enable(struct phy_device *phydev, u8 index) in qca808x_led_hw_control_enable() argument
459 return qca808x_led_reg_hw_control_enable(phydev, reg); in qca808x_led_hw_control_enable()
462 static int qca808x_led_hw_is_supported(struct phy_device *phydev, u8 index, in qca808x_led_hw_is_supported() argument
470 return qca808x_led_parse_netdev(phydev, rules, &offload_trigger); in qca808x_led_hw_is_supported()
473 static int qca808x_led_hw_control_set(struct phy_device *phydev, u8 index, in qca808x_led_hw_control_set() argument
484 ret = qca808x_led_parse_netdev(phydev, rules, &offload_trigger); in qca808x_led_hw_control_set()
488 ret = qca808x_led_hw_control_enable(phydev, index); in qca808x_led_hw_control_set()
492 return phy_modify_mmd(phydev, MDIO_MMD_AN, reg, in qca808x_led_hw_control_set()
497 static bool qca808x_led_hw_control_status(struct phy_device *phydev, u8 index) in qca808x_led_hw_control_status() argument
505 return qca808x_led_reg_hw_control_status(phydev, reg); in qca808x_led_hw_control_status()
508 static int qca808x_led_hw_control_get(struct phy_device *phydev, u8 index, in qca808x_led_hw_control_get() argument
518 if (qca808x_led_hw_control_status(phydev, index)) in qca808x_led_hw_control_get()
523 val = phy_read_mmd(phydev, MDIO_MMD_AN, reg); in qca808x_led_hw_control_get()
544 static int qca808x_led_hw_control_reset(struct phy_device *phydev, u8 index) in qca808x_led_hw_control_reset() argument
553 return phy_clear_bits_mmd(phydev, MDIO_MMD_AN, reg, in qca808x_led_hw_control_reset()
557 static int qca808x_led_brightness_set(struct phy_device *phydev, in qca808x_led_brightness_set() argument
567 ret = qca808x_led_hw_control_reset(phydev, index); in qca808x_led_brightness_set()
573 return qca808x_led_reg_brightness_set(phydev, reg, value); in qca808x_led_brightness_set()
576 static int qca808x_led_blink_set(struct phy_device *phydev, u8 index, in qca808x_led_blink_set() argument
586 return qca808x_led_reg_blink_set(phydev, reg, delay_on, delay_off); in qca808x_led_blink_set()
589 static int qca808x_led_polarity_set(struct phy_device *phydev, int index, in qca808x_led_polarity_set() argument
592 struct qca808x_priv *priv = phydev->priv; in qca808x_led_polarity_set()
612 phydev_err(phydev, "PHY polarity is global. Mismatched polarity on different LED\n"); in qca808x_led_polarity_set()
619 return phy_modify_mmd(phydev, MDIO_MMD_AN, in qca808x_led_polarity_set()