Lines Matching refs:phydev

321 static int at803x_debug_reg_write(struct phy_device *phydev, u16 reg, u16 data)  in at803x_debug_reg_write()  argument
325 ret = phy_write(phydev, AT803X_DEBUG_ADDR, reg); in at803x_debug_reg_write()
329 return phy_write(phydev, AT803X_DEBUG_DATA, data); in at803x_debug_reg_write()
332 static int at803x_debug_reg_read(struct phy_device *phydev, u16 reg) in at803x_debug_reg_read() argument
336 ret = phy_write(phydev, AT803X_DEBUG_ADDR, reg); in at803x_debug_reg_read()
340 return phy_read(phydev, AT803X_DEBUG_DATA); in at803x_debug_reg_read()
343 static int at803x_debug_reg_mask(struct phy_device *phydev, u16 reg, in at803x_debug_reg_mask() argument
349 ret = at803x_debug_reg_read(phydev, reg); in at803x_debug_reg_mask()
357 return phy_write(phydev, AT803X_DEBUG_DATA, val); in at803x_debug_reg_mask()
360 static int at803x_write_page(struct phy_device *phydev, int page) in at803x_write_page() argument
373 return __phy_modify(phydev, AT803X_REG_CHIP_CONFIG, mask, set); in at803x_write_page()
376 static int at803x_read_page(struct phy_device *phydev) in at803x_read_page() argument
378 int ccr = __phy_read(phydev, AT803X_REG_CHIP_CONFIG); in at803x_read_page()
389 static int at803x_enable_rx_delay(struct phy_device *phydev) in at803x_enable_rx_delay() argument
391 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, 0, in at803x_enable_rx_delay()
395 static int at803x_enable_tx_delay(struct phy_device *phydev) in at803x_enable_tx_delay() argument
397 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_SYSTEM_CTRL_MODE, 0, in at803x_enable_tx_delay()
401 static int at803x_disable_rx_delay(struct phy_device *phydev) in at803x_disable_rx_delay() argument
403 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in at803x_disable_rx_delay()
407 static int at803x_disable_tx_delay(struct phy_device *phydev) in at803x_disable_tx_delay() argument
409 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_SYSTEM_CTRL_MODE, in at803x_disable_tx_delay()
414 static void at803x_context_save(struct phy_device *phydev, in at803x_context_save() argument
417 context->bmcr = phy_read(phydev, MII_BMCR); in at803x_context_save()
418 context->advertise = phy_read(phydev, MII_ADVERTISE); in at803x_context_save()
419 context->control1000 = phy_read(phydev, MII_CTRL1000); in at803x_context_save()
420 context->int_enable = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_context_save()
421 context->smart_speed = phy_read(phydev, AT803X_SMART_SPEED); in at803x_context_save()
422 context->led_control = phy_read(phydev, AT803X_LED_CONTROL); in at803x_context_save()
426 static void at803x_context_restore(struct phy_device *phydev, in at803x_context_restore() argument
429 phy_write(phydev, MII_BMCR, context->bmcr); in at803x_context_restore()
430 phy_write(phydev, MII_ADVERTISE, context->advertise); in at803x_context_restore()
431 phy_write(phydev, MII_CTRL1000, context->control1000); in at803x_context_restore()
432 phy_write(phydev, AT803X_INTR_ENABLE, context->int_enable); in at803x_context_restore()
433 phy_write(phydev, AT803X_SMART_SPEED, context->smart_speed); in at803x_context_restore()
434 phy_write(phydev, AT803X_LED_CONTROL, context->led_control); in at803x_context_restore()
437 static int at803x_set_wol(struct phy_device *phydev, in at803x_set_wol() argument
443 struct net_device *ndev = phydev->attached_dev; in at803x_set_wol()
461 phy_write_mmd(phydev, MDIO_MMD_PCS, offsets[i], in at803x_set_wol()
465 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL, in at803x_set_wol()
470 ret = phy_modify(phydev, AT803X_INTR_ENABLE, 0, AT803X_INTR_ENABLE_WOL); in at803x_set_wol()
475 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL, in at803x_set_wol()
480 ret = phy_modify(phydev, AT803X_INTR_ENABLE, AT803X_INTR_ENABLE_WOL, 0); in at803x_set_wol()
486 ret = phy_read(phydev, AT803X_INTR_STATUS); in at803x_set_wol()
494 irq_enabled = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_set_wol()
499 if (ret & irq_enabled && !phy_polling_mode(phydev)) in at803x_set_wol()
500 phy_trigger_machine(phydev); in at803x_set_wol()
505 static void at803x_get_wol(struct phy_device *phydev, in at803x_get_wol() argument
513 value = phy_read_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL); in at803x_get_wol()
521 static int at803x_get_sset_count(struct phy_device *phydev) in at803x_get_sset_count() argument
526 static void at803x_get_strings(struct phy_device *phydev, u8 *data) in at803x_get_strings() argument
536 static u64 at803x_get_stat(struct phy_device *phydev, int i) in at803x_get_stat() argument
539 struct at803x_priv *priv = phydev->priv; in at803x_get_stat()
544 val = phy_read_mmd(phydev, MDIO_MMD_PCS, stat.reg); in at803x_get_stat()
546 val = phy_read(phydev, stat.reg); in at803x_get_stat()
559 static void at803x_get_stats(struct phy_device *phydev, in at803x_get_stats() argument
565 data[i] = at803x_get_stat(phydev, i); in at803x_get_stats()
568 static int at803x_suspend(struct phy_device *phydev) in at803x_suspend() argument
573 value = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_suspend()
581 phy_modify(phydev, MII_BMCR, 0, value); in at803x_suspend()
586 static int at803x_resume(struct phy_device *phydev) in at803x_resume() argument
588 return phy_modify(phydev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 0); in at803x_resume()
594 struct phy_device *phydev = rdev_get_drvdata(rdev); in at803x_rgmii_reg_set_voltage_sel() local
597 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at803x_rgmii_reg_set_voltage_sel()
600 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at803x_rgmii_reg_set_voltage_sel()
606 struct phy_device *phydev = rdev_get_drvdata(rdev); in at803x_rgmii_reg_get_voltage_sel() local
609 val = at803x_debug_reg_read(phydev, AT803X_DEBUG_REG_1F); in at803x_rgmii_reg_get_voltage_sel()
650 static int at8031_register_regulators(struct phy_device *phydev) in at8031_register_regulators() argument
652 struct at803x_priv *priv = phydev->priv; in at8031_register_regulators()
653 struct device *dev = &phydev->mdio.dev; in at8031_register_regulators()
657 config.driver_data = phydev; in at8031_register_regulators()
661 phydev_err(phydev, "failed to register VDDIO regulator\n"); in at8031_register_regulators()
667 phydev_err(phydev, "failed to register VDDH regulator\n"); in at8031_register_regulators()
676 struct phy_device *phydev = upstream; in at803x_sfp_insert() local
690 sfp_parse_support(phydev->sfp_bus, id, sfp_support, interfaces); in at803x_sfp_insert()
697 dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n"); in at803x_sfp_insert()
701 iface = sfp_select_interface(phydev->sfp_bus, sfp_support); in at803x_sfp_insert()
711 dev_warn(&phydev->mdio.dev, "module may not function if 1000Base-X not supported\n"); in at803x_sfp_insert()
724 static int at803x_parse_dt(struct phy_device *phydev) in at803x_parse_dt() argument
726 struct device_node *node = phydev->mdio.dev.of_node; in at803x_parse_dt()
727 struct at803x_priv *priv = phydev->priv; in at803x_parse_dt()
743 phydev_err(phydev, "invalid qca,smarteee-tw-us-1g\n"); in at803x_parse_dt()
751 phydev_err(phydev, "invalid qca,smarteee-tw-us-100m\n"); in at803x_parse_dt()
773 phydev_err(phydev, "invalid qca,clk-out-frequency\n"); in at803x_parse_dt()
791 if (phydev->drv->phy_id == ATH8030_PHY_ID || in at803x_parse_dt()
792 phydev->drv->phy_id == ATH8035_PHY_ID) { in at803x_parse_dt()
812 phydev_err(phydev, "invalid qca,clk-out-strength\n"); in at803x_parse_dt()
820 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_parse_dt()
824 ret = at8031_register_regulators(phydev); in at803x_parse_dt()
828 priv->vddio = devm_regulator_get_optional(&phydev->mdio.dev, in at803x_parse_dt()
831 phydev_err(phydev, "failed to get VDDIO regulator\n"); in at803x_parse_dt()
836 ret = phy_sfp_probe(phydev, &at803x_sfp_ops); in at803x_parse_dt()
844 static int at803x_probe(struct phy_device *phydev) in at803x_probe() argument
846 struct device *dev = &phydev->mdio.dev; in at803x_probe()
854 phydev->priv = priv; in at803x_probe()
856 ret = at803x_parse_dt(phydev); in at803x_probe()
866 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_probe()
867 int ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG); in at803x_probe()
891 ret = at803x_set_wol(phydev, &wol); in at803x_probe()
893 phydev_err(phydev, "failed to disable WOL on probe: %d\n", ret); in at803x_probe()
907 static void at803x_remove(struct phy_device *phydev) in at803x_remove() argument
909 struct at803x_priv *priv = phydev->priv; in at803x_remove()
915 static int at803x_get_features(struct phy_device *phydev) in at803x_get_features() argument
917 struct at803x_priv *priv = phydev->priv; in at803x_get_features()
920 err = genphy_read_abilities(phydev); in at803x_get_features()
924 if (phydev->drv->phy_id == QCA8081_PHY_ID) { in at803x_get_features()
925 err = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_NG_EXTABLE); in at803x_get_features()
929 linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported, in at803x_get_features()
933 if (phydev->drv->phy_id != ATH8031_PHY_ID) in at803x_get_features()
949 phydev->supported); in at803x_get_features()
954 static int at803x_smarteee_config(struct phy_device *phydev) in at803x_smarteee_config() argument
956 struct at803x_priv *priv = phydev->priv; in at803x_smarteee_config()
961 return phy_modify_mmd(phydev, MDIO_MMD_PCS, in at803x_smarteee_config()
976 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL1, in at803x_smarteee_config()
981 return phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL3, in at803x_smarteee_config()
986 static int at803x_clk_out_config(struct phy_device *phydev) in at803x_clk_out_config() argument
988 struct at803x_priv *priv = phydev->priv; in at803x_clk_out_config()
993 return phy_modify_mmd(phydev, MDIO_MMD_AN, AT803X_MMD7_CLK25M, in at803x_clk_out_config()
997 static int at8031_pll_config(struct phy_device *phydev) in at8031_pll_config() argument
999 struct at803x_priv *priv = phydev->priv; in at8031_pll_config()
1005 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at8031_pll_config()
1008 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at8031_pll_config()
1012 static int at803x_hibernation_mode_config(struct phy_device *phydev) in at803x_hibernation_mode_config() argument
1014 struct at803x_priv *priv = phydev->priv; in at803x_hibernation_mode_config()
1022 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL, in at803x_hibernation_mode_config()
1026 static int at803x_config_init(struct phy_device *phydev) in at803x_config_init() argument
1028 struct at803x_priv *priv = phydev->priv; in at803x_config_init()
1031 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_config_init()
1036 phy_lock_mdio_bus(phydev); in at803x_config_init()
1037 ret = at803x_write_page(phydev, in at803x_config_init()
1040 phy_unlock_mdio_bus(phydev); in at803x_config_init()
1044 ret = at8031_pll_config(phydev); in at803x_config_init()
1054 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in at803x_config_init()
1055 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in at803x_config_init()
1056 ret = at803x_enable_rx_delay(phydev); in at803x_config_init()
1058 ret = at803x_disable_rx_delay(phydev); in at803x_config_init()
1062 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in at803x_config_init()
1063 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in at803x_config_init()
1064 ret = at803x_enable_tx_delay(phydev); in at803x_config_init()
1066 ret = at803x_disable_tx_delay(phydev); in at803x_config_init()
1070 ret = at803x_smarteee_config(phydev); in at803x_config_init()
1074 ret = at803x_clk_out_config(phydev); in at803x_config_init()
1078 ret = at803x_hibernation_mode_config(phydev); in at803x_config_init()
1088 return phy_modify(phydev, MII_ADVERTISE, MDIO_AN_CTRL1_XNP, 0); in at803x_config_init()
1091 static int at803x_ack_interrupt(struct phy_device *phydev) in at803x_ack_interrupt() argument
1095 err = phy_read(phydev, AT803X_INTR_STATUS); in at803x_ack_interrupt()
1100 static int at803x_config_intr(struct phy_device *phydev) in at803x_config_intr() argument
1102 struct at803x_priv *priv = phydev->priv; in at803x_config_intr()
1106 value = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_config_intr()
1108 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in at803x_config_intr()
1110 err = at803x_ack_interrupt(phydev); in at803x_config_intr()
1124 err = phy_write(phydev, AT803X_INTR_ENABLE, value); in at803x_config_intr()
1126 err = phy_write(phydev, AT803X_INTR_ENABLE, 0); in at803x_config_intr()
1131 err = at803x_ack_interrupt(phydev); in at803x_config_intr()
1137 static irqreturn_t at803x_handle_interrupt(struct phy_device *phydev) in at803x_handle_interrupt() argument
1141 irq_status = phy_read(phydev, AT803X_INTR_STATUS); in at803x_handle_interrupt()
1143 phy_error(phydev); in at803x_handle_interrupt()
1148 int_enabled = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_handle_interrupt()
1150 phy_error(phydev); in at803x_handle_interrupt()
1158 phy_trigger_machine(phydev); in at803x_handle_interrupt()
1163 static void at803x_link_change_notify(struct phy_device *phydev) in at803x_link_change_notify() argument
1172 if (phydev->state == PHY_NOLINK && phydev->mdio.reset_gpio) { in at803x_link_change_notify()
1175 at803x_context_save(phydev, &context); in at803x_link_change_notify()
1177 phy_device_reset(phydev, 1); in at803x_link_change_notify()
1179 phy_device_reset(phydev, 0); in at803x_link_change_notify()
1182 at803x_context_restore(phydev, &context); in at803x_link_change_notify()
1184 phydev_dbg(phydev, "%s(): phy was reset\n", __func__); in at803x_link_change_notify()
1188 static int at803x_read_specific_status(struct phy_device *phydev) in at803x_read_specific_status() argument
1196 ss = phy_read(phydev, AT803X_SPECIFIC_STATUS); in at803x_read_specific_status()
1203 sfc = phy_read(phydev, AT803X_SPECIFIC_FUNCTION_CONTROL); in at803x_read_specific_status()
1208 if (phydev->drv->phy_id == QCA8081_PHY_ID) in at803x_read_specific_status()
1215 phydev->speed = SPEED_10; in at803x_read_specific_status()
1218 phydev->speed = SPEED_100; in at803x_read_specific_status()
1221 phydev->speed = SPEED_1000; in at803x_read_specific_status()
1224 phydev->speed = SPEED_2500; in at803x_read_specific_status()
1228 phydev->duplex = DUPLEX_FULL; in at803x_read_specific_status()
1230 phydev->duplex = DUPLEX_HALF; in at803x_read_specific_status()
1233 phydev->mdix = ETH_TP_MDI_X; in at803x_read_specific_status()
1235 phydev->mdix = ETH_TP_MDI; in at803x_read_specific_status()
1239 phydev->mdix_ctrl = ETH_TP_MDI; in at803x_read_specific_status()
1242 phydev->mdix_ctrl = ETH_TP_MDI_X; in at803x_read_specific_status()
1245 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in at803x_read_specific_status()
1253 static int at803x_read_status(struct phy_device *phydev) in at803x_read_status() argument
1255 struct at803x_priv *priv = phydev->priv; in at803x_read_status()
1256 int err, old_link = phydev->link; in at803x_read_status()
1259 return genphy_c37_read_status(phydev); in at803x_read_status()
1262 err = genphy_update_link(phydev); in at803x_read_status()
1267 if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) in at803x_read_status()
1270 phydev->speed = SPEED_UNKNOWN; in at803x_read_status()
1271 phydev->duplex = DUPLEX_UNKNOWN; in at803x_read_status()
1272 phydev->pause = 0; in at803x_read_status()
1273 phydev->asym_pause = 0; in at803x_read_status()
1275 err = genphy_read_lpa(phydev); in at803x_read_status()
1279 err = at803x_read_specific_status(phydev); in at803x_read_status()
1283 if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) in at803x_read_status()
1284 phy_resolve_aneg_pause(phydev); in at803x_read_status()
1289 static int at803x_config_mdix(struct phy_device *phydev, u8 ctrl) in at803x_config_mdix() argument
1307 return phy_modify_changed(phydev, AT803X_SPECIFIC_FUNCTION_CONTROL, in at803x_config_mdix()
1312 static int at803x_config_aneg(struct phy_device *phydev) in at803x_config_aneg() argument
1314 struct at803x_priv *priv = phydev->priv; in at803x_config_aneg()
1317 ret = at803x_config_mdix(phydev, phydev->mdix_ctrl); in at803x_config_aneg()
1326 ret = genphy_soft_reset(phydev); in at803x_config_aneg()
1332 return genphy_c37_config_aneg(phydev); in at803x_config_aneg()
1339 if (phydev->drv->phy_id == QCA8081_PHY_ID) { in at803x_config_aneg()
1345 if (phydev->autoneg == AUTONEG_DISABLE) in at803x_config_aneg()
1346 genphy_c45_pma_setup_forced(phydev); in at803x_config_aneg()
1348 if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->advertising)) in at803x_config_aneg()
1351 ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL, in at803x_config_aneg()
1357 return __genphy_config_aneg(phydev, ret); in at803x_config_aneg()
1360 static int at803x_get_downshift(struct phy_device *phydev, u8 *d) in at803x_get_downshift() argument
1364 val = phy_read(phydev, AT803X_SMART_SPEED); in at803x_get_downshift()
1376 static int at803x_set_downshift(struct phy_device *phydev, u8 cnt) in at803x_set_downshift() argument
1400 ret = phy_modify_changed(phydev, AT803X_SMART_SPEED, mask, set); in at803x_set_downshift()
1407 ret = phy_init_hw(phydev); in at803x_set_downshift()
1412 static int at803x_get_tunable(struct phy_device *phydev, in at803x_get_tunable() argument
1417 return at803x_get_downshift(phydev, data); in at803x_get_tunable()
1423 static int at803x_set_tunable(struct phy_device *phydev, in at803x_set_tunable() argument
1428 return at803x_set_downshift(phydev, *(const u8 *)data); in at803x_set_tunable()
1489 static int at803x_cdt_start(struct phy_device *phydev, int pair) in at803x_cdt_start() argument
1494 if (phydev->drv->phy_id == QCA8081_PHY_ID) in at803x_cdt_start()
1502 return phy_write(phydev, AT803X_CDT, cdt); in at803x_cdt_start()
1505 static int at803x_cdt_wait_for_completion(struct phy_device *phydev) in at803x_cdt_wait_for_completion() argument
1510 if (phydev->drv->phy_id == QCA8081_PHY_ID) in at803x_cdt_wait_for_completion()
1516 ret = phy_read_poll_timeout(phydev, AT803X_CDT, val, in at803x_cdt_wait_for_completion()
1523 static int at803x_cable_test_one_pair(struct phy_device *phydev, int pair) in at803x_cable_test_one_pair() argument
1533 ret = at803x_cdt_start(phydev, pair); in at803x_cable_test_one_pair()
1537 ret = at803x_cdt_wait_for_completion(phydev); in at803x_cable_test_one_pair()
1541 val = phy_read(phydev, AT803X_CDT_STATUS); in at803x_cable_test_one_pair()
1548 ethnl_cable_test_result(phydev, ethtool_pair[pair], in at803x_cable_test_one_pair()
1552 ethnl_cable_test_fault_length(phydev, ethtool_pair[pair], in at803x_cable_test_one_pair()
1558 static int at803x_cable_test_get_status(struct phy_device *phydev, in at803x_cable_test_get_status() argument
1565 if (phydev->phy_id == ATH9331_PHY_ID || in at803x_cable_test_get_status()
1566 phydev->phy_id == ATH8032_PHY_ID || in at803x_cable_test_get_status()
1567 phydev->phy_id == QCA9561_PHY_ID) in at803x_cable_test_get_status()
1583 ret = at803x_cable_test_one_pair(phydev, pair); in at803x_cable_test_get_status()
1598 static int at803x_cable_test_start(struct phy_device *phydev) in at803x_cable_test_start() argument
1604 phy_write(phydev, MII_BMCR, BMCR_ANENABLE); in at803x_cable_test_start()
1605 phy_write(phydev, MII_ADVERTISE, ADVERTISE_CSMA); in at803x_cable_test_start()
1606 if (phydev->phy_id != ATH9331_PHY_ID && in at803x_cable_test_start()
1607 phydev->phy_id != ATH8032_PHY_ID && in at803x_cable_test_start()
1608 phydev->phy_id != QCA9561_PHY_ID) in at803x_cable_test_start()
1609 phy_write(phydev, MII_CTRL1000, 0); in at803x_cable_test_start()
1615 static int qca83xx_config_init(struct phy_device *phydev) in qca83xx_config_init() argument
1619 switch_revision = phydev->dev_flags & QCA8K_DEVFLAGS_REVISION_MASK; in qca83xx_config_init()
1624 at803x_debug_reg_write(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, 0x02ea); in qca83xx_config_init()
1626 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_GREEN, 0x68a0); in qca83xx_config_init()
1630 phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, 0x0); in qca83xx_config_init()
1633 phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_AZ_DEBUG, 0x803f); in qca83xx_config_init()
1634 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_GREEN, 0x6860); in qca83xx_config_init()
1635 at803x_debug_reg_write(phydev, AT803X_DEBUG_SYSTEM_CTRL_MODE, 0x2c46); in qca83xx_config_init()
1636 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_3C, 0x6000); in qca83xx_config_init()
1644 if (phydev->drv->phy_id == QCA8327_A_PHY_ID || in qca83xx_config_init()
1645 phydev->drv->phy_id == QCA8327_B_PHY_ID) in qca83xx_config_init()
1646 at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in qca83xx_config_init()
1650 phy_set_bits(phydev, MII_CTRL1000, CTL1000_PREFER_MASTER); in qca83xx_config_init()
1655 static void qca83xx_link_change_notify(struct phy_device *phydev) in qca83xx_link_change_notify() argument
1658 if (phydev->drv->phy_id == QCA8337_PHY_ID) in qca83xx_link_change_notify()
1662 if (phydev->state == PHY_RUNNING) { in qca83xx_link_change_notify()
1663 if (phydev->speed == SPEED_100) in qca83xx_link_change_notify()
1664 at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in qca83xx_link_change_notify()
1669 at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in qca83xx_link_change_notify()
1674 static int qca83xx_resume(struct phy_device *phydev) in qca83xx_resume() argument
1679 if (!phydev->suspended) in qca83xx_resume()
1683 qca83xx_config_init(phydev); in qca83xx_resume()
1686 phy_set_bits(phydev, MII_BMCR, BMCR_RESET | BMCR_ANENABLE); in qca83xx_resume()
1691 ret = phy_read_poll_timeout(phydev, MII_BMCR, val, !(val & BMCR_RESET), in qca83xx_resume()
1701 static int qca83xx_suspend(struct phy_device *phydev) in qca83xx_suspend() argument
1709 if (phydev->drv->phy_id == QCA8337_PHY_ID) { in qca83xx_suspend()
1710 genphy_suspend(phydev); in qca83xx_suspend()
1713 phy_modify(phydev, MII_BMCR, mask, 0); in qca83xx_suspend()
1716 at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_GREEN, in qca83xx_suspend()
1719 at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL, in qca83xx_suspend()
1726 static int qca808x_phy_fast_retrain_config(struct phy_device *phydev) in qca808x_phy_fast_retrain_config() argument
1731 ret = genphy_c45_fast_retrain(phydev, true); in qca808x_phy_fast_retrain_config()
1735 phy_write_mmd(phydev, MDIO_MMD_AN, QCA808X_PHY_MMD7_TOP_OPTION1, in qca808x_phy_fast_retrain_config()
1737 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_20DB, in qca808x_phy_fast_retrain_config()
1739 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_17DB, in qca808x_phy_fast_retrain_config()
1741 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_27DB, in qca808x_phy_fast_retrain_config()
1743 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_28DB, in qca808x_phy_fast_retrain_config()
1745 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_1, in qca808x_phy_fast_retrain_config()
1747 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_4, in qca808x_phy_fast_retrain_config()
1749 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_5, in qca808x_phy_fast_retrain_config()
1751 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_3, in qca808x_phy_fast_retrain_config()
1753 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_6, in qca808x_phy_fast_retrain_config()
1755 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_2, in qca808x_phy_fast_retrain_config()
1761 static int qca808x_phy_ms_random_seed_set(struct phy_device *phydev) in qca808x_phy_ms_random_seed_set() argument
1765 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED, in qca808x_phy_ms_random_seed_set()
1770 static int qca808x_phy_ms_seed_enable(struct phy_device *phydev, bool enable) in qca808x_phy_ms_seed_enable() argument
1777 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED, in qca808x_phy_ms_seed_enable()
1781 static int qca808x_config_init(struct phy_device *phydev) in qca808x_config_init() argument
1786 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_ADDR_CLD_CTRL7, in qca808x_config_init()
1792 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, in qca808x_config_init()
1798 ret = qca808x_phy_fast_retrain_config(phydev); in qca808x_config_init()
1803 ret = qca808x_phy_ms_random_seed_set(phydev); in qca808x_config_init()
1808 ret = qca808x_phy_ms_seed_enable(phydev, true); in qca808x_config_init()
1813 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_ADC_THRESHOLD, in qca808x_config_init()
1817 static int qca808x_read_status(struct phy_device *phydev) in qca808x_read_status() argument
1821 ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_STAT); in qca808x_read_status()
1825 linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->lp_advertising, in qca808x_read_status()
1828 ret = genphy_read_status(phydev); in qca808x_read_status()
1832 ret = at803x_read_specific_status(phydev); in qca808x_read_status()
1836 if (phydev->link) { in qca808x_read_status()
1837 if (phydev->speed == SPEED_2500) in qca808x_read_status()
1838 phydev->interface = PHY_INTERFACE_MODE_2500BASEX; in qca808x_read_status()
1840 phydev->interface = PHY_INTERFACE_MODE_SGMII; in qca808x_read_status()
1849 if (phydev->master_slave_state == MASTER_SLAVE_STATE_ERR) { in qca808x_read_status()
1850 qca808x_phy_ms_seed_enable(phydev, false); in qca808x_read_status()
1852 qca808x_phy_ms_random_seed_set(phydev); in qca808x_read_status()
1853 qca808x_phy_ms_seed_enable(phydev, true); in qca808x_read_status()
1860 static int qca808x_soft_reset(struct phy_device *phydev) in qca808x_soft_reset() argument
1864 ret = genphy_soft_reset(phydev); in qca808x_soft_reset()
1868 return qca808x_phy_ms_seed_enable(phydev, true); in qca808x_soft_reset()
1897 static int qca808x_cdt_fault_length(struct phy_device *phydev, int pair) in qca808x_cdt_fault_length() argument
1919 val = phy_read_mmd(phydev, MDIO_MMD_PCS, cdt_length_reg); in qca808x_cdt_fault_length()
1926 static int qca808x_cable_test_start(struct phy_device *phydev) in qca808x_cable_test_start() argument
1937 ret = at803x_debug_reg_mask(phydev, QCA808X_DBG_AN_TEST, QCA808X_HIBERNATION_EN, 0); in qca808x_cable_test_start()
1941 ret = at803x_config_mdix(phydev, ETH_TP_MDI); in qca808x_cable_test_start()
1946 phydev->duplex = DUPLEX_FULL; in qca808x_cable_test_start()
1947 phydev->speed = SPEED_1000; in qca808x_cable_test_start()
1948 ret = genphy_c45_pma_setup_forced(phydev); in qca808x_cable_test_start()
1952 ret = genphy_setup_forced(phydev); in qca808x_cable_test_start()
1957 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8074, 0xc040); in qca808x_cable_test_start()
1958 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8076, 0xc040); in qca808x_cable_test_start()
1959 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8077, 0xa060); in qca808x_cable_test_start()
1960 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8078, 0xc050); in qca808x_cable_test_start()
1961 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807a, 0xc060); in qca808x_cable_test_start()
1962 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807e, 0xb060); in qca808x_cable_test_start()
1967 static int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finished) in qca808x_cable_test_get_status() argument
1974 ret = at803x_cdt_start(phydev, 0); in qca808x_cable_test_get_status()
1978 ret = at803x_cdt_wait_for_completion(phydev); in qca808x_cable_test_get_status()
1982 val = phy_read_mmd(phydev, MDIO_MMD_PCS, QCA808X_MMD3_CDT_STATUS); in qca808x_cable_test_get_status()
1991 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, in qca808x_cable_test_get_status()
1993 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_B, in qca808x_cable_test_get_status()
1995 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_C, in qca808x_cable_test_get_status()
1997 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_D, in qca808x_cable_test_get_status()
2001 ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_A, in qca808x_cable_test_get_status()
2002 qca808x_cdt_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_A)); in qca808x_cable_test_get_status()
2004 ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_B, in qca808x_cable_test_get_status()
2005 qca808x_cdt_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_B)); in qca808x_cable_test_get_status()
2007 ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_C, in qca808x_cable_test_get_status()
2008 qca808x_cdt_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_C)); in qca808x_cable_test_get_status()
2010 ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_D, in qca808x_cable_test_get_status()
2011 qca808x_cdt_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_D)); in qca808x_cable_test_get_status()