Lines Matching refs:phydev

301 static int at803x_debug_reg_write(struct phy_device *phydev, u16 reg, u16 data)  in at803x_debug_reg_write()  argument
305 ret = phy_write(phydev, AT803X_DEBUG_ADDR, reg); in at803x_debug_reg_write()
309 return phy_write(phydev, AT803X_DEBUG_DATA, data); in at803x_debug_reg_write()
312 static int at803x_debug_reg_read(struct phy_device *phydev, u16 reg) in at803x_debug_reg_read() argument
316 ret = phy_write(phydev, AT803X_DEBUG_ADDR, reg); in at803x_debug_reg_read()
320 return phy_read(phydev, AT803X_DEBUG_DATA); in at803x_debug_reg_read()
323 static int at803x_debug_reg_mask(struct phy_device *phydev, u16 reg, in at803x_debug_reg_mask() argument
329 ret = at803x_debug_reg_read(phydev, reg); in at803x_debug_reg_mask()
337 return phy_write(phydev, AT803X_DEBUG_DATA, val); in at803x_debug_reg_mask()
340 static int at803x_write_page(struct phy_device *phydev, int page) in at803x_write_page() argument
353 return __phy_modify(phydev, AT803X_REG_CHIP_CONFIG, mask, set); in at803x_write_page()
356 static int at803x_read_page(struct phy_device *phydev) in at803x_read_page() argument
358 int ccr = __phy_read(phydev, AT803X_REG_CHIP_CONFIG); in at803x_read_page()
369 static int at803x_enable_rx_delay(struct phy_device *phydev) in at803x_enable_rx_delay() argument
371 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, 0, in at803x_enable_rx_delay()
375 static int at803x_enable_tx_delay(struct phy_device *phydev) in at803x_enable_tx_delay() argument
377 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_SYSTEM_CTRL_MODE, 0, in at803x_enable_tx_delay()
381 static int at803x_disable_rx_delay(struct phy_device *phydev) in at803x_disable_rx_delay() argument
383 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in at803x_disable_rx_delay()
387 static int at803x_disable_tx_delay(struct phy_device *phydev) in at803x_disable_tx_delay() argument
389 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_SYSTEM_CTRL_MODE, in at803x_disable_tx_delay()
394 static void at803x_context_save(struct phy_device *phydev, in at803x_context_save() argument
397 context->bmcr = phy_read(phydev, MII_BMCR); in at803x_context_save()
398 context->advertise = phy_read(phydev, MII_ADVERTISE); in at803x_context_save()
399 context->control1000 = phy_read(phydev, MII_CTRL1000); in at803x_context_save()
400 context->int_enable = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_context_save()
401 context->smart_speed = phy_read(phydev, AT803X_SMART_SPEED); in at803x_context_save()
402 context->led_control = phy_read(phydev, AT803X_LED_CONTROL); in at803x_context_save()
406 static void at803x_context_restore(struct phy_device *phydev, in at803x_context_restore() argument
409 phy_write(phydev, MII_BMCR, context->bmcr); in at803x_context_restore()
410 phy_write(phydev, MII_ADVERTISE, context->advertise); in at803x_context_restore()
411 phy_write(phydev, MII_CTRL1000, context->control1000); in at803x_context_restore()
412 phy_write(phydev, AT803X_INTR_ENABLE, context->int_enable); in at803x_context_restore()
413 phy_write(phydev, AT803X_SMART_SPEED, context->smart_speed); in at803x_context_restore()
414 phy_write(phydev, AT803X_LED_CONTROL, context->led_control); in at803x_context_restore()
417 static int at803x_set_wol(struct phy_device *phydev, in at803x_set_wol() argument
420 struct net_device *ndev = phydev->attached_dev; in at803x_set_wol()
440 phy_write_mmd(phydev, MDIO_MMD_PCS, offsets[i], in at803x_set_wol()
444 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL, in at803x_set_wol()
449 ret = phy_modify(phydev, AT803X_INTR_ENABLE, 0, AT803X_INTR_ENABLE_WOL); in at803x_set_wol()
454 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL, in at803x_set_wol()
459 ret = phy_modify(phydev, AT803X_INTR_ENABLE, AT803X_INTR_ENABLE_WOL, 0); in at803x_set_wol()
465 ret = phy_read(phydev, AT803X_INTR_STATUS); in at803x_set_wol()
473 irq_enabled = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_set_wol()
478 if (ret & irq_enabled && !phy_polling_mode(phydev)) in at803x_set_wol()
479 phy_trigger_machine(phydev); in at803x_set_wol()
484 static void at803x_get_wol(struct phy_device *phydev, in at803x_get_wol() argument
492 value = phy_read_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL); in at803x_get_wol()
500 static int at803x_get_sset_count(struct phy_device *phydev) in at803x_get_sset_count() argument
505 static void at803x_get_strings(struct phy_device *phydev, u8 *data) in at803x_get_strings() argument
515 static u64 at803x_get_stat(struct phy_device *phydev, int i) in at803x_get_stat() argument
518 struct at803x_priv *priv = phydev->priv; in at803x_get_stat()
523 val = phy_read_mmd(phydev, MDIO_MMD_PCS, stat.reg); in at803x_get_stat()
525 val = phy_read(phydev, stat.reg); in at803x_get_stat()
538 static void at803x_get_stats(struct phy_device *phydev, in at803x_get_stats() argument
544 data[i] = at803x_get_stat(phydev, i); in at803x_get_stats()
547 static int at803x_suspend(struct phy_device *phydev) in at803x_suspend() argument
552 value = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_suspend()
560 phy_modify(phydev, MII_BMCR, 0, value); in at803x_suspend()
565 static int at803x_resume(struct phy_device *phydev) in at803x_resume() argument
567 return phy_modify(phydev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 0); in at803x_resume()
573 struct phy_device *phydev = rdev_get_drvdata(rdev); in at803x_rgmii_reg_set_voltage_sel() local
576 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at803x_rgmii_reg_set_voltage_sel()
579 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at803x_rgmii_reg_set_voltage_sel()
585 struct phy_device *phydev = rdev_get_drvdata(rdev); in at803x_rgmii_reg_get_voltage_sel() local
588 val = at803x_debug_reg_read(phydev, AT803X_DEBUG_REG_1F); in at803x_rgmii_reg_get_voltage_sel()
629 static int at8031_register_regulators(struct phy_device *phydev) in at8031_register_regulators() argument
631 struct at803x_priv *priv = phydev->priv; in at8031_register_regulators()
632 struct device *dev = &phydev->mdio.dev; in at8031_register_regulators()
636 config.driver_data = phydev; in at8031_register_regulators()
640 phydev_err(phydev, "failed to register VDDIO regulator\n"); in at8031_register_regulators()
646 phydev_err(phydev, "failed to register VDDH regulator\n"); in at8031_register_regulators()
653 static int at803x_parse_dt(struct phy_device *phydev) in at803x_parse_dt() argument
655 struct device_node *node = phydev->mdio.dev.of_node; in at803x_parse_dt()
656 struct at803x_priv *priv = phydev->priv; in at803x_parse_dt()
669 phydev_err(phydev, "invalid qca,smarteee-tw-us-1g\n"); in at803x_parse_dt()
677 phydev_err(phydev, "invalid qca,smarteee-tw-us-100m\n"); in at803x_parse_dt()
699 phydev_err(phydev, "invalid qca,clk-out-frequency\n"); in at803x_parse_dt()
717 if (phydev->drv->phy_id == ATH8030_PHY_ID || in at803x_parse_dt()
718 phydev->drv->phy_id == ATH8035_PHY_ID) { in at803x_parse_dt()
738 phydev_err(phydev, "invalid qca,clk-out-strength\n"); in at803x_parse_dt()
746 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_parse_dt()
750 ret = at8031_register_regulators(phydev); in at803x_parse_dt()
754 priv->vddio = devm_regulator_get_optional(&phydev->mdio.dev, in at803x_parse_dt()
757 phydev_err(phydev, "failed to get VDDIO regulator\n"); in at803x_parse_dt()
765 static int at803x_probe(struct phy_device *phydev) in at803x_probe() argument
767 struct device *dev = &phydev->mdio.dev; in at803x_probe()
775 phydev->priv = priv; in at803x_probe()
777 ret = at803x_parse_dt(phydev); in at803x_probe()
791 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_probe()
792 phy_lock_mdio_bus(phydev); in at803x_probe()
793 ret = at803x_write_page(phydev, AT803X_PAGE_COPPER); in at803x_probe()
794 phy_unlock_mdio_bus(phydev); in at803x_probe()
808 static void at803x_remove(struct phy_device *phydev) in at803x_remove() argument
810 struct at803x_priv *priv = phydev->priv; in at803x_remove()
816 static int at803x_get_features(struct phy_device *phydev) in at803x_get_features() argument
820 err = genphy_read_abilities(phydev); in at803x_get_features()
824 if (phydev->drv->phy_id == QCA8081_PHY_ID) { in at803x_get_features()
825 err = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_NG_EXTABLE); in at803x_get_features()
829 linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported, in at803x_get_features()
833 if (phydev->drv->phy_id != ATH8031_PHY_ID) in at803x_get_features()
849 phydev->supported); in at803x_get_features()
853 static int at803x_smarteee_config(struct phy_device *phydev) in at803x_smarteee_config() argument
855 struct at803x_priv *priv = phydev->priv; in at803x_smarteee_config()
860 return phy_modify_mmd(phydev, MDIO_MMD_PCS, in at803x_smarteee_config()
875 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL1, in at803x_smarteee_config()
880 return phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL3, in at803x_smarteee_config()
885 static int at803x_clk_out_config(struct phy_device *phydev) in at803x_clk_out_config() argument
887 struct at803x_priv *priv = phydev->priv; in at803x_clk_out_config()
892 return phy_modify_mmd(phydev, MDIO_MMD_AN, AT803X_MMD7_CLK25M, in at803x_clk_out_config()
896 static int at8031_pll_config(struct phy_device *phydev) in at8031_pll_config() argument
898 struct at803x_priv *priv = phydev->priv; in at8031_pll_config()
904 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at8031_pll_config()
907 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at8031_pll_config()
911 static int at803x_config_init(struct phy_device *phydev) in at803x_config_init() argument
920 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in at803x_config_init()
921 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in at803x_config_init()
922 ret = at803x_enable_rx_delay(phydev); in at803x_config_init()
924 ret = at803x_disable_rx_delay(phydev); in at803x_config_init()
928 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in at803x_config_init()
929 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in at803x_config_init()
930 ret = at803x_enable_tx_delay(phydev); in at803x_config_init()
932 ret = at803x_disable_tx_delay(phydev); in at803x_config_init()
936 ret = at803x_smarteee_config(phydev); in at803x_config_init()
940 ret = at803x_clk_out_config(phydev); in at803x_config_init()
944 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_config_init()
945 ret = at8031_pll_config(phydev); in at803x_config_init()
956 return phy_modify(phydev, MII_ADVERTISE, MDIO_AN_CTRL1_XNP, 0); in at803x_config_init()
959 static int at803x_ack_interrupt(struct phy_device *phydev) in at803x_ack_interrupt() argument
963 err = phy_read(phydev, AT803X_INTR_STATUS); in at803x_ack_interrupt()
968 static int at803x_config_intr(struct phy_device *phydev) in at803x_config_intr() argument
973 value = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_config_intr()
975 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in at803x_config_intr()
977 err = at803x_ack_interrupt(phydev); in at803x_config_intr()
987 err = phy_write(phydev, AT803X_INTR_ENABLE, value); in at803x_config_intr()
989 err = phy_write(phydev, AT803X_INTR_ENABLE, 0); in at803x_config_intr()
994 err = at803x_ack_interrupt(phydev); in at803x_config_intr()
1000 static irqreturn_t at803x_handle_interrupt(struct phy_device *phydev) in at803x_handle_interrupt() argument
1004 irq_status = phy_read(phydev, AT803X_INTR_STATUS); in at803x_handle_interrupt()
1006 phy_error(phydev); in at803x_handle_interrupt()
1011 int_enabled = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_handle_interrupt()
1013 phy_error(phydev); in at803x_handle_interrupt()
1021 phy_trigger_machine(phydev); in at803x_handle_interrupt()
1026 static void at803x_link_change_notify(struct phy_device *phydev) in at803x_link_change_notify() argument
1035 if (phydev->state == PHY_NOLINK && phydev->mdio.reset_gpio) { in at803x_link_change_notify()
1038 at803x_context_save(phydev, &context); in at803x_link_change_notify()
1040 phy_device_reset(phydev, 1); in at803x_link_change_notify()
1042 phy_device_reset(phydev, 0); in at803x_link_change_notify()
1045 at803x_context_restore(phydev, &context); in at803x_link_change_notify()
1047 phydev_dbg(phydev, "%s(): phy was reset\n", __func__); in at803x_link_change_notify()
1051 static int at803x_read_specific_status(struct phy_device *phydev) in at803x_read_specific_status() argument
1059 ss = phy_read(phydev, AT803X_SPECIFIC_STATUS); in at803x_read_specific_status()
1066 sfc = phy_read(phydev, AT803X_SPECIFIC_FUNCTION_CONTROL); in at803x_read_specific_status()
1071 if (phydev->drv->phy_id == QCA8081_PHY_ID) in at803x_read_specific_status()
1078 phydev->speed = SPEED_10; in at803x_read_specific_status()
1081 phydev->speed = SPEED_100; in at803x_read_specific_status()
1084 phydev->speed = SPEED_1000; in at803x_read_specific_status()
1087 phydev->speed = SPEED_2500; in at803x_read_specific_status()
1091 phydev->duplex = DUPLEX_FULL; in at803x_read_specific_status()
1093 phydev->duplex = DUPLEX_HALF; in at803x_read_specific_status()
1096 phydev->mdix = ETH_TP_MDI_X; in at803x_read_specific_status()
1098 phydev->mdix = ETH_TP_MDI; in at803x_read_specific_status()
1102 phydev->mdix_ctrl = ETH_TP_MDI; in at803x_read_specific_status()
1105 phydev->mdix_ctrl = ETH_TP_MDI_X; in at803x_read_specific_status()
1108 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in at803x_read_specific_status()
1116 static int at803x_read_status(struct phy_device *phydev) in at803x_read_status() argument
1118 int err, old_link = phydev->link; in at803x_read_status()
1121 err = genphy_update_link(phydev); in at803x_read_status()
1126 if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) in at803x_read_status()
1129 phydev->speed = SPEED_UNKNOWN; in at803x_read_status()
1130 phydev->duplex = DUPLEX_UNKNOWN; in at803x_read_status()
1131 phydev->pause = 0; in at803x_read_status()
1132 phydev->asym_pause = 0; in at803x_read_status()
1134 err = genphy_read_lpa(phydev); in at803x_read_status()
1138 err = at803x_read_specific_status(phydev); in at803x_read_status()
1142 if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) in at803x_read_status()
1143 phy_resolve_aneg_pause(phydev); in at803x_read_status()
1148 static int at803x_config_mdix(struct phy_device *phydev, u8 ctrl) in at803x_config_mdix() argument
1166 return phy_modify_changed(phydev, AT803X_SPECIFIC_FUNCTION_CONTROL, in at803x_config_mdix()
1171 static int at803x_config_aneg(struct phy_device *phydev) in at803x_config_aneg() argument
1175 ret = at803x_config_mdix(phydev, phydev->mdix_ctrl); in at803x_config_aneg()
1184 ret = genphy_soft_reset(phydev); in at803x_config_aneg()
1194 if (phydev->drv->phy_id == QCA8081_PHY_ID) { in at803x_config_aneg()
1200 if (phydev->autoneg == AUTONEG_DISABLE) in at803x_config_aneg()
1201 genphy_c45_pma_setup_forced(phydev); in at803x_config_aneg()
1203 if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->advertising)) in at803x_config_aneg()
1206 ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL, in at803x_config_aneg()
1212 return __genphy_config_aneg(phydev, ret); in at803x_config_aneg()
1215 static int at803x_get_downshift(struct phy_device *phydev, u8 *d) in at803x_get_downshift() argument
1219 val = phy_read(phydev, AT803X_SMART_SPEED); in at803x_get_downshift()
1231 static int at803x_set_downshift(struct phy_device *phydev, u8 cnt) in at803x_set_downshift() argument
1255 ret = phy_modify_changed(phydev, AT803X_SMART_SPEED, mask, set); in at803x_set_downshift()
1262 ret = phy_init_hw(phydev); in at803x_set_downshift()
1267 static int at803x_get_tunable(struct phy_device *phydev, in at803x_get_tunable() argument
1272 return at803x_get_downshift(phydev, data); in at803x_get_tunable()
1278 static int at803x_set_tunable(struct phy_device *phydev, in at803x_set_tunable() argument
1283 return at803x_set_downshift(phydev, *(const u8 *)data); in at803x_set_tunable()
1344 static int at803x_cdt_start(struct phy_device *phydev, int pair) in at803x_cdt_start() argument
1349 if (phydev->drv->phy_id == QCA8081_PHY_ID) in at803x_cdt_start()
1357 return phy_write(phydev, AT803X_CDT, cdt); in at803x_cdt_start()
1360 static int at803x_cdt_wait_for_completion(struct phy_device *phydev) in at803x_cdt_wait_for_completion() argument
1365 if (phydev->drv->phy_id == QCA8081_PHY_ID) in at803x_cdt_wait_for_completion()
1371 ret = phy_read_poll_timeout(phydev, AT803X_CDT, val, in at803x_cdt_wait_for_completion()
1378 static int at803x_cable_test_one_pair(struct phy_device *phydev, int pair) in at803x_cable_test_one_pair() argument
1388 ret = at803x_cdt_start(phydev, pair); in at803x_cable_test_one_pair()
1392 ret = at803x_cdt_wait_for_completion(phydev); in at803x_cable_test_one_pair()
1396 val = phy_read(phydev, AT803X_CDT_STATUS); in at803x_cable_test_one_pair()
1403 ethnl_cable_test_result(phydev, ethtool_pair[pair], in at803x_cable_test_one_pair()
1407 ethnl_cable_test_fault_length(phydev, ethtool_pair[pair], in at803x_cable_test_one_pair()
1413 static int at803x_cable_test_get_status(struct phy_device *phydev, in at803x_cable_test_get_status() argument
1420 if (phydev->phy_id == ATH9331_PHY_ID || in at803x_cable_test_get_status()
1421 phydev->phy_id == ATH8032_PHY_ID || in at803x_cable_test_get_status()
1422 phydev->phy_id == QCA9561_PHY_ID) in at803x_cable_test_get_status()
1438 ret = at803x_cable_test_one_pair(phydev, pair); in at803x_cable_test_get_status()
1453 static int at803x_cable_test_start(struct phy_device *phydev) in at803x_cable_test_start() argument
1459 phy_write(phydev, MII_BMCR, BMCR_ANENABLE); in at803x_cable_test_start()
1460 phy_write(phydev, MII_ADVERTISE, ADVERTISE_CSMA); in at803x_cable_test_start()
1461 if (phydev->phy_id != ATH9331_PHY_ID && in at803x_cable_test_start()
1462 phydev->phy_id != ATH8032_PHY_ID && in at803x_cable_test_start()
1463 phydev->phy_id != QCA9561_PHY_ID) in at803x_cable_test_start()
1464 phy_write(phydev, MII_CTRL1000, 0); in at803x_cable_test_start()
1470 static int qca83xx_config_init(struct phy_device *phydev) in qca83xx_config_init() argument
1474 switch_revision = phydev->dev_flags & QCA8K_DEVFLAGS_REVISION_MASK; in qca83xx_config_init()
1479 at803x_debug_reg_write(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, 0x02ea); in qca83xx_config_init()
1481 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_GREEN, 0x68a0); in qca83xx_config_init()
1485 phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, 0x0); in qca83xx_config_init()
1488 phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_AZ_DEBUG, 0x803f); in qca83xx_config_init()
1489 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_GREEN, 0x6860); in qca83xx_config_init()
1490 at803x_debug_reg_write(phydev, AT803X_DEBUG_SYSTEM_CTRL_MODE, 0x2c46); in qca83xx_config_init()
1491 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_3C, 0x6000); in qca83xx_config_init()
1499 if (phydev->drv->phy_id == QCA8327_A_PHY_ID || in qca83xx_config_init()
1500 phydev->drv->phy_id == QCA8327_B_PHY_ID) in qca83xx_config_init()
1501 at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in qca83xx_config_init()
1505 phy_set_bits(phydev, MII_CTRL1000, CTL1000_PREFER_MASTER); in qca83xx_config_init()
1510 static void qca83xx_link_change_notify(struct phy_device *phydev) in qca83xx_link_change_notify() argument
1513 if (phydev->drv->phy_id == QCA8337_PHY_ID) in qca83xx_link_change_notify()
1517 if (phydev->state == PHY_RUNNING) { in qca83xx_link_change_notify()
1518 if (phydev->speed == SPEED_100) in qca83xx_link_change_notify()
1519 at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in qca83xx_link_change_notify()
1524 at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in qca83xx_link_change_notify()
1529 static int qca83xx_resume(struct phy_device *phydev) in qca83xx_resume() argument
1534 if (!phydev->suspended) in qca83xx_resume()
1538 qca83xx_config_init(phydev); in qca83xx_resume()
1541 phy_set_bits(phydev, MII_BMCR, BMCR_RESET | BMCR_ANENABLE); in qca83xx_resume()
1546 ret = phy_read_poll_timeout(phydev, MII_BMCR, val, !(val & BMCR_RESET), in qca83xx_resume()
1556 static int qca83xx_suspend(struct phy_device *phydev) in qca83xx_suspend() argument
1564 if (phydev->drv->phy_id == QCA8337_PHY_ID) { in qca83xx_suspend()
1565 genphy_suspend(phydev); in qca83xx_suspend()
1568 phy_modify(phydev, MII_BMCR, mask, 0); in qca83xx_suspend()
1571 at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_GREEN, in qca83xx_suspend()
1574 at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL, in qca83xx_suspend()
1581 static int qca808x_phy_fast_retrain_config(struct phy_device *phydev) in qca808x_phy_fast_retrain_config() argument
1586 ret = genphy_c45_fast_retrain(phydev, true); in qca808x_phy_fast_retrain_config()
1590 phy_write_mmd(phydev, MDIO_MMD_AN, QCA808X_PHY_MMD7_TOP_OPTION1, in qca808x_phy_fast_retrain_config()
1592 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_20DB, in qca808x_phy_fast_retrain_config()
1594 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_17DB, in qca808x_phy_fast_retrain_config()
1596 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_27DB, in qca808x_phy_fast_retrain_config()
1598 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_28DB, in qca808x_phy_fast_retrain_config()
1600 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_1, in qca808x_phy_fast_retrain_config()
1602 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_4, in qca808x_phy_fast_retrain_config()
1604 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_5, in qca808x_phy_fast_retrain_config()
1606 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_3, in qca808x_phy_fast_retrain_config()
1608 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_6, in qca808x_phy_fast_retrain_config()
1610 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_2, in qca808x_phy_fast_retrain_config()
1616 static int qca808x_phy_ms_random_seed_set(struct phy_device *phydev) in qca808x_phy_ms_random_seed_set() argument
1620 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED, in qca808x_phy_ms_random_seed_set()
1625 static int qca808x_phy_ms_seed_enable(struct phy_device *phydev, bool enable) in qca808x_phy_ms_seed_enable() argument
1632 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED, in qca808x_phy_ms_seed_enable()
1636 static int qca808x_config_init(struct phy_device *phydev) in qca808x_config_init() argument
1641 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_ADDR_CLD_CTRL7, in qca808x_config_init()
1647 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, in qca808x_config_init()
1653 ret = qca808x_phy_fast_retrain_config(phydev); in qca808x_config_init()
1658 ret = qca808x_phy_ms_random_seed_set(phydev); in qca808x_config_init()
1663 ret = qca808x_phy_ms_seed_enable(phydev, true); in qca808x_config_init()
1668 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_ADC_THRESHOLD, in qca808x_config_init()
1672 static int qca808x_read_status(struct phy_device *phydev) in qca808x_read_status() argument
1676 ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_STAT); in qca808x_read_status()
1680 linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->lp_advertising, in qca808x_read_status()
1683 ret = genphy_read_status(phydev); in qca808x_read_status()
1687 ret = at803x_read_specific_status(phydev); in qca808x_read_status()
1691 if (phydev->link && phydev->speed == SPEED_2500) in qca808x_read_status()
1692 phydev->interface = PHY_INTERFACE_MODE_2500BASEX; in qca808x_read_status()
1694 phydev->interface = PHY_INTERFACE_MODE_SMII; in qca808x_read_status()
1703 if (!phydev->link) { in qca808x_read_status()
1704 if (phydev->master_slave_state == MASTER_SLAVE_STATE_ERR) { in qca808x_read_status()
1705 qca808x_phy_ms_seed_enable(phydev, false); in qca808x_read_status()
1707 qca808x_phy_ms_random_seed_set(phydev); in qca808x_read_status()
1708 qca808x_phy_ms_seed_enable(phydev, true); in qca808x_read_status()
1715 static int qca808x_soft_reset(struct phy_device *phydev) in qca808x_soft_reset() argument
1719 ret = genphy_soft_reset(phydev); in qca808x_soft_reset()
1723 return qca808x_phy_ms_seed_enable(phydev, true); in qca808x_soft_reset()
1752 static int qca808x_cdt_fault_length(struct phy_device *phydev, int pair) in qca808x_cdt_fault_length() argument
1774 val = phy_read_mmd(phydev, MDIO_MMD_PCS, cdt_length_reg); in qca808x_cdt_fault_length()
1781 static int qca808x_cable_test_start(struct phy_device *phydev) in qca808x_cable_test_start() argument
1792 ret = at803x_debug_reg_mask(phydev, QCA808X_DBG_AN_TEST, QCA808X_HIBERNATION_EN, 0); in qca808x_cable_test_start()
1796 ret = at803x_config_mdix(phydev, ETH_TP_MDI); in qca808x_cable_test_start()
1801 phydev->duplex = DUPLEX_FULL; in qca808x_cable_test_start()
1802 phydev->speed = SPEED_1000; in qca808x_cable_test_start()
1803 ret = genphy_c45_pma_setup_forced(phydev); in qca808x_cable_test_start()
1807 ret = genphy_setup_forced(phydev); in qca808x_cable_test_start()
1812 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8074, 0xc040); in qca808x_cable_test_start()
1813 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8076, 0xc040); in qca808x_cable_test_start()
1814 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8077, 0xa060); in qca808x_cable_test_start()
1815 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8078, 0xc050); in qca808x_cable_test_start()
1816 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807a, 0xc060); in qca808x_cable_test_start()
1817 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807e, 0xb060); in qca808x_cable_test_start()
1822 static int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finished) in qca808x_cable_test_get_status() argument
1829 ret = at803x_cdt_start(phydev, 0); in qca808x_cable_test_get_status()
1833 ret = at803x_cdt_wait_for_completion(phydev); in qca808x_cable_test_get_status()
1837 val = phy_read_mmd(phydev, MDIO_MMD_PCS, QCA808X_MMD3_CDT_STATUS); in qca808x_cable_test_get_status()
1846 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, in qca808x_cable_test_get_status()
1848 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_B, in qca808x_cable_test_get_status()
1850 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_C, in qca808x_cable_test_get_status()
1852 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_D, in qca808x_cable_test_get_status()
1856 ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_A, in qca808x_cable_test_get_status()
1857 qca808x_cdt_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_A)); in qca808x_cable_test_get_status()
1859 ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_B, in qca808x_cable_test_get_status()
1860 qca808x_cdt_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_B)); in qca808x_cable_test_get_status()
1862 ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_C, in qca808x_cable_test_get_status()
1863 qca808x_cdt_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_C)); in qca808x_cable_test_get_status()
1865 ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_D, in qca808x_cable_test_get_status()
1866 qca808x_cdt_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_D)); in qca808x_cable_test_get_status()