Lines Matching refs:phydev

326 static int at803x_debug_reg_write(struct phy_device *phydev, u16 reg, u16 data)  in at803x_debug_reg_write()  argument
330 ret = phy_write(phydev, AT803X_DEBUG_ADDR, reg); in at803x_debug_reg_write()
334 return phy_write(phydev, AT803X_DEBUG_DATA, data); in at803x_debug_reg_write()
337 static int at803x_debug_reg_read(struct phy_device *phydev, u16 reg) in at803x_debug_reg_read() argument
341 ret = phy_write(phydev, AT803X_DEBUG_ADDR, reg); in at803x_debug_reg_read()
345 return phy_read(phydev, AT803X_DEBUG_DATA); in at803x_debug_reg_read()
348 static int at803x_debug_reg_mask(struct phy_device *phydev, u16 reg, in at803x_debug_reg_mask() argument
354 ret = at803x_debug_reg_read(phydev, reg); in at803x_debug_reg_mask()
362 return phy_write(phydev, AT803X_DEBUG_DATA, val); in at803x_debug_reg_mask()
365 static int at803x_write_page(struct phy_device *phydev, int page) in at803x_write_page() argument
378 return __phy_modify(phydev, AT803X_REG_CHIP_CONFIG, mask, set); in at803x_write_page()
381 static int at803x_read_page(struct phy_device *phydev) in at803x_read_page() argument
383 int ccr = __phy_read(phydev, AT803X_REG_CHIP_CONFIG); in at803x_read_page()
394 static int at803x_enable_rx_delay(struct phy_device *phydev) in at803x_enable_rx_delay() argument
396 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, 0, in at803x_enable_rx_delay()
400 static int at803x_enable_tx_delay(struct phy_device *phydev) in at803x_enable_tx_delay() argument
402 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_SYSTEM_CTRL_MODE, 0, in at803x_enable_tx_delay()
406 static int at803x_disable_rx_delay(struct phy_device *phydev) in at803x_disable_rx_delay() argument
408 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in at803x_disable_rx_delay()
412 static int at803x_disable_tx_delay(struct phy_device *phydev) in at803x_disable_tx_delay() argument
414 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_SYSTEM_CTRL_MODE, in at803x_disable_tx_delay()
419 static void at803x_context_save(struct phy_device *phydev, in at803x_context_save() argument
422 context->bmcr = phy_read(phydev, MII_BMCR); in at803x_context_save()
423 context->advertise = phy_read(phydev, MII_ADVERTISE); in at803x_context_save()
424 context->control1000 = phy_read(phydev, MII_CTRL1000); in at803x_context_save()
425 context->int_enable = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_context_save()
426 context->smart_speed = phy_read(phydev, AT803X_SMART_SPEED); in at803x_context_save()
427 context->led_control = phy_read(phydev, AT803X_LED_CONTROL); in at803x_context_save()
431 static void at803x_context_restore(struct phy_device *phydev, in at803x_context_restore() argument
434 phy_write(phydev, MII_BMCR, context->bmcr); in at803x_context_restore()
435 phy_write(phydev, MII_ADVERTISE, context->advertise); in at803x_context_restore()
436 phy_write(phydev, MII_CTRL1000, context->control1000); in at803x_context_restore()
437 phy_write(phydev, AT803X_INTR_ENABLE, context->int_enable); in at803x_context_restore()
438 phy_write(phydev, AT803X_SMART_SPEED, context->smart_speed); in at803x_context_restore()
439 phy_write(phydev, AT803X_LED_CONTROL, context->led_control); in at803x_context_restore()
442 static int at803x_set_wol(struct phy_device *phydev, in at803x_set_wol() argument
448 struct net_device *ndev = phydev->attached_dev; in at803x_set_wol()
466 phy_write_mmd(phydev, MDIO_MMD_PCS, offsets[i], in at803x_set_wol()
470 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_set_wol()
471 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, in at803x_set_wol()
478 ret = phy_modify(phydev, AT803X_INTR_ENABLE, 0, AT803X_INTR_ENABLE_WOL); in at803x_set_wol()
483 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_set_wol()
484 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, in at803x_set_wol()
491 ret = phy_modify(phydev, AT803X_INTR_ENABLE, AT803X_INTR_ENABLE_WOL, 0); in at803x_set_wol()
497 ret = phy_read(phydev, AT803X_INTR_STATUS); in at803x_set_wol()
505 irq_enabled = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_set_wol()
510 if (ret & irq_enabled && !phy_polling_mode(phydev)) in at803x_set_wol()
511 phy_trigger_machine(phydev); in at803x_set_wol()
516 static void at803x_get_wol(struct phy_device *phydev, in at803x_get_wol() argument
524 value = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_get_wol()
532 static int at803x_get_sset_count(struct phy_device *phydev) in at803x_get_sset_count() argument
537 static void at803x_get_strings(struct phy_device *phydev, u8 *data) in at803x_get_strings() argument
547 static u64 at803x_get_stat(struct phy_device *phydev, int i) in at803x_get_stat() argument
550 struct at803x_priv *priv = phydev->priv; in at803x_get_stat()
555 val = phy_read_mmd(phydev, MDIO_MMD_PCS, stat.reg); in at803x_get_stat()
557 val = phy_read(phydev, stat.reg); in at803x_get_stat()
570 static void at803x_get_stats(struct phy_device *phydev, in at803x_get_stats() argument
576 data[i] = at803x_get_stat(phydev, i); in at803x_get_stats()
579 static int at803x_suspend(struct phy_device *phydev) in at803x_suspend() argument
584 value = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_suspend()
592 phy_modify(phydev, MII_BMCR, 0, value); in at803x_suspend()
597 static int at803x_resume(struct phy_device *phydev) in at803x_resume() argument
599 return phy_modify(phydev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 0); in at803x_resume()
605 struct phy_device *phydev = rdev_get_drvdata(rdev); in at803x_rgmii_reg_set_voltage_sel() local
608 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at803x_rgmii_reg_set_voltage_sel()
611 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at803x_rgmii_reg_set_voltage_sel()
617 struct phy_device *phydev = rdev_get_drvdata(rdev); in at803x_rgmii_reg_get_voltage_sel() local
620 val = at803x_debug_reg_read(phydev, AT803X_DEBUG_REG_1F); in at803x_rgmii_reg_get_voltage_sel()
661 static int at8031_register_regulators(struct phy_device *phydev) in at8031_register_regulators() argument
663 struct at803x_priv *priv = phydev->priv; in at8031_register_regulators()
664 struct device *dev = &phydev->mdio.dev; in at8031_register_regulators()
668 config.driver_data = phydev; in at8031_register_regulators()
672 phydev_err(phydev, "failed to register VDDIO regulator\n"); in at8031_register_regulators()
678 phydev_err(phydev, "failed to register VDDH regulator\n"); in at8031_register_regulators()
687 struct phy_device *phydev = upstream; in at803x_sfp_insert() local
701 sfp_parse_support(phydev->sfp_bus, id, sfp_support, interfaces); in at803x_sfp_insert()
708 dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n"); in at803x_sfp_insert()
712 iface = sfp_select_interface(phydev->sfp_bus, sfp_support); in at803x_sfp_insert()
722 dev_warn(&phydev->mdio.dev, "module may not function if 1000Base-X not supported\n"); in at803x_sfp_insert()
735 static int at803x_parse_dt(struct phy_device *phydev) in at803x_parse_dt() argument
737 struct device_node *node = phydev->mdio.dev.of_node; in at803x_parse_dt()
738 struct at803x_priv *priv = phydev->priv; in at803x_parse_dt()
754 phydev_err(phydev, "invalid qca,smarteee-tw-us-1g\n"); in at803x_parse_dt()
762 phydev_err(phydev, "invalid qca,smarteee-tw-us-100m\n"); in at803x_parse_dt()
784 phydev_err(phydev, "invalid qca,clk-out-frequency\n"); in at803x_parse_dt()
802 if (phydev->drv->phy_id == ATH8030_PHY_ID || in at803x_parse_dt()
803 phydev->drv->phy_id == ATH8035_PHY_ID) { in at803x_parse_dt()
823 phydev_err(phydev, "invalid qca,clk-out-strength\n"); in at803x_parse_dt()
831 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_parse_dt()
835 ret = at8031_register_regulators(phydev); in at803x_parse_dt()
839 ret = devm_regulator_get_enable_optional(&phydev->mdio.dev, in at803x_parse_dt()
842 phydev_err(phydev, "failed to get VDDIO regulator\n"); in at803x_parse_dt()
847 ret = phy_sfp_probe(phydev, &at803x_sfp_ops); in at803x_parse_dt()
855 static int at803x_probe(struct phy_device *phydev) in at803x_probe() argument
857 struct device *dev = &phydev->mdio.dev; in at803x_probe()
865 phydev->priv = priv; in at803x_probe()
867 ret = at803x_parse_dt(phydev); in at803x_probe()
871 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_probe()
872 int ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG); in at803x_probe()
893 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, in at803x_probe()
903 static int at803x_get_features(struct phy_device *phydev) in at803x_get_features() argument
905 struct at803x_priv *priv = phydev->priv; in at803x_get_features()
908 err = genphy_read_abilities(phydev); in at803x_get_features()
912 if (phydev->drv->phy_id != ATH8031_PHY_ID) in at803x_get_features()
928 phydev->supported); in at803x_get_features()
933 static int at803x_smarteee_config(struct phy_device *phydev) in at803x_smarteee_config() argument
935 struct at803x_priv *priv = phydev->priv; in at803x_smarteee_config()
940 return phy_modify_mmd(phydev, MDIO_MMD_PCS, in at803x_smarteee_config()
955 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL1, in at803x_smarteee_config()
960 return phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL3, in at803x_smarteee_config()
965 static int at803x_clk_out_config(struct phy_device *phydev) in at803x_clk_out_config() argument
967 struct at803x_priv *priv = phydev->priv; in at803x_clk_out_config()
972 return phy_modify_mmd(phydev, MDIO_MMD_AN, AT803X_MMD7_CLK25M, in at803x_clk_out_config()
976 static int at8031_pll_config(struct phy_device *phydev) in at8031_pll_config() argument
978 struct at803x_priv *priv = phydev->priv; in at8031_pll_config()
984 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at8031_pll_config()
987 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at8031_pll_config()
991 static int at803x_hibernation_mode_config(struct phy_device *phydev) in at803x_hibernation_mode_config() argument
993 struct at803x_priv *priv = phydev->priv; in at803x_hibernation_mode_config()
1001 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL, in at803x_hibernation_mode_config()
1005 static int at803x_config_init(struct phy_device *phydev) in at803x_config_init() argument
1007 struct at803x_priv *priv = phydev->priv; in at803x_config_init()
1010 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_config_init()
1015 phy_lock_mdio_bus(phydev); in at803x_config_init()
1016 ret = at803x_write_page(phydev, in at803x_config_init()
1019 phy_unlock_mdio_bus(phydev); in at803x_config_init()
1023 ret = at8031_pll_config(phydev); in at803x_config_init()
1033 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in at803x_config_init()
1034 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in at803x_config_init()
1035 ret = at803x_enable_rx_delay(phydev); in at803x_config_init()
1037 ret = at803x_disable_rx_delay(phydev); in at803x_config_init()
1041 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in at803x_config_init()
1042 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in at803x_config_init()
1043 ret = at803x_enable_tx_delay(phydev); in at803x_config_init()
1045 ret = at803x_disable_tx_delay(phydev); in at803x_config_init()
1049 ret = at803x_smarteee_config(phydev); in at803x_config_init()
1053 ret = at803x_clk_out_config(phydev); in at803x_config_init()
1057 ret = at803x_hibernation_mode_config(phydev); in at803x_config_init()
1067 return phy_modify(phydev, MII_ADVERTISE, MDIO_AN_CTRL1_XNP, 0); in at803x_config_init()
1070 static int at803x_ack_interrupt(struct phy_device *phydev) in at803x_ack_interrupt() argument
1074 err = phy_read(phydev, AT803X_INTR_STATUS); in at803x_ack_interrupt()
1079 static int at803x_config_intr(struct phy_device *phydev) in at803x_config_intr() argument
1081 struct at803x_priv *priv = phydev->priv; in at803x_config_intr()
1085 value = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_config_intr()
1087 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in at803x_config_intr()
1089 err = at803x_ack_interrupt(phydev); in at803x_config_intr()
1103 err = phy_write(phydev, AT803X_INTR_ENABLE, value); in at803x_config_intr()
1105 err = phy_write(phydev, AT803X_INTR_ENABLE, 0); in at803x_config_intr()
1110 err = at803x_ack_interrupt(phydev); in at803x_config_intr()
1116 static irqreturn_t at803x_handle_interrupt(struct phy_device *phydev) in at803x_handle_interrupt() argument
1120 irq_status = phy_read(phydev, AT803X_INTR_STATUS); in at803x_handle_interrupt()
1122 phy_error(phydev); in at803x_handle_interrupt()
1127 int_enabled = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_handle_interrupt()
1129 phy_error(phydev); in at803x_handle_interrupt()
1137 phy_trigger_machine(phydev); in at803x_handle_interrupt()
1142 static void at803x_link_change_notify(struct phy_device *phydev) in at803x_link_change_notify() argument
1151 if (phydev->state == PHY_NOLINK && phydev->mdio.reset_gpio) { in at803x_link_change_notify()
1154 at803x_context_save(phydev, &context); in at803x_link_change_notify()
1156 phy_device_reset(phydev, 1); in at803x_link_change_notify()
1158 phy_device_reset(phydev, 0); in at803x_link_change_notify()
1161 at803x_context_restore(phydev, &context); in at803x_link_change_notify()
1163 phydev_dbg(phydev, "%s(): phy was reset\n", __func__); in at803x_link_change_notify()
1167 static int at803x_read_specific_status(struct phy_device *phydev) in at803x_read_specific_status() argument
1175 ss = phy_read(phydev, AT803X_SPECIFIC_STATUS); in at803x_read_specific_status()
1182 sfc = phy_read(phydev, AT803X_SPECIFIC_FUNCTION_CONTROL); in at803x_read_specific_status()
1187 if (phydev->drv->phy_id == QCA8081_PHY_ID) in at803x_read_specific_status()
1194 phydev->speed = SPEED_10; in at803x_read_specific_status()
1197 phydev->speed = SPEED_100; in at803x_read_specific_status()
1200 phydev->speed = SPEED_1000; in at803x_read_specific_status()
1203 phydev->speed = SPEED_2500; in at803x_read_specific_status()
1207 phydev->duplex = DUPLEX_FULL; in at803x_read_specific_status()
1209 phydev->duplex = DUPLEX_HALF; in at803x_read_specific_status()
1212 phydev->mdix = ETH_TP_MDI_X; in at803x_read_specific_status()
1214 phydev->mdix = ETH_TP_MDI; in at803x_read_specific_status()
1218 phydev->mdix_ctrl = ETH_TP_MDI; in at803x_read_specific_status()
1221 phydev->mdix_ctrl = ETH_TP_MDI_X; in at803x_read_specific_status()
1224 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in at803x_read_specific_status()
1232 static int at803x_read_status(struct phy_device *phydev) in at803x_read_status() argument
1234 struct at803x_priv *priv = phydev->priv; in at803x_read_status()
1235 int err, old_link = phydev->link; in at803x_read_status()
1238 return genphy_c37_read_status(phydev); in at803x_read_status()
1241 err = genphy_update_link(phydev); in at803x_read_status()
1246 if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) in at803x_read_status()
1249 phydev->speed = SPEED_UNKNOWN; in at803x_read_status()
1250 phydev->duplex = DUPLEX_UNKNOWN; in at803x_read_status()
1251 phydev->pause = 0; in at803x_read_status()
1252 phydev->asym_pause = 0; in at803x_read_status()
1254 err = genphy_read_lpa(phydev); in at803x_read_status()
1258 err = at803x_read_specific_status(phydev); in at803x_read_status()
1262 if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) in at803x_read_status()
1263 phy_resolve_aneg_pause(phydev); in at803x_read_status()
1268 static int at803x_config_mdix(struct phy_device *phydev, u8 ctrl) in at803x_config_mdix() argument
1286 return phy_modify_changed(phydev, AT803X_SPECIFIC_FUNCTION_CONTROL, in at803x_config_mdix()
1291 static int at803x_config_aneg(struct phy_device *phydev) in at803x_config_aneg() argument
1293 struct at803x_priv *priv = phydev->priv; in at803x_config_aneg()
1296 ret = at803x_config_mdix(phydev, phydev->mdix_ctrl); in at803x_config_aneg()
1305 ret = genphy_soft_reset(phydev); in at803x_config_aneg()
1311 return genphy_c37_config_aneg(phydev); in at803x_config_aneg()
1318 if (phydev->drv->phy_id == QCA8081_PHY_ID) { in at803x_config_aneg()
1324 if (phydev->autoneg == AUTONEG_DISABLE) in at803x_config_aneg()
1325 genphy_c45_pma_setup_forced(phydev); in at803x_config_aneg()
1327 if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->advertising)) in at803x_config_aneg()
1330 ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL, in at803x_config_aneg()
1336 return __genphy_config_aneg(phydev, ret); in at803x_config_aneg()
1339 static int at803x_get_downshift(struct phy_device *phydev, u8 *d) in at803x_get_downshift() argument
1343 val = phy_read(phydev, AT803X_SMART_SPEED); in at803x_get_downshift()
1355 static int at803x_set_downshift(struct phy_device *phydev, u8 cnt) in at803x_set_downshift() argument
1379 ret = phy_modify_changed(phydev, AT803X_SMART_SPEED, mask, set); in at803x_set_downshift()
1386 ret = phy_init_hw(phydev); in at803x_set_downshift()
1391 static int at803x_get_tunable(struct phy_device *phydev, in at803x_get_tunable() argument
1396 return at803x_get_downshift(phydev, data); in at803x_get_tunable()
1402 static int at803x_set_tunable(struct phy_device *phydev, in at803x_set_tunable() argument
1407 return at803x_set_downshift(phydev, *(const u8 *)data); in at803x_set_tunable()
1468 static int at803x_cdt_start(struct phy_device *phydev, int pair) in at803x_cdt_start() argument
1473 if (phydev->drv->phy_id == QCA8081_PHY_ID) in at803x_cdt_start()
1481 return phy_write(phydev, AT803X_CDT, cdt); in at803x_cdt_start()
1484 static int at803x_cdt_wait_for_completion(struct phy_device *phydev) in at803x_cdt_wait_for_completion() argument
1489 if (phydev->drv->phy_id == QCA8081_PHY_ID) in at803x_cdt_wait_for_completion()
1495 ret = phy_read_poll_timeout(phydev, AT803X_CDT, val, in at803x_cdt_wait_for_completion()
1502 static int at803x_cable_test_one_pair(struct phy_device *phydev, int pair) in at803x_cable_test_one_pair() argument
1512 ret = at803x_cdt_start(phydev, pair); in at803x_cable_test_one_pair()
1516 ret = at803x_cdt_wait_for_completion(phydev); in at803x_cable_test_one_pair()
1520 val = phy_read(phydev, AT803X_CDT_STATUS); in at803x_cable_test_one_pair()
1527 ethnl_cable_test_result(phydev, ethtool_pair[pair], in at803x_cable_test_one_pair()
1531 ethnl_cable_test_fault_length(phydev, ethtool_pair[pair], in at803x_cable_test_one_pair()
1537 static int at803x_cable_test_get_status(struct phy_device *phydev, in at803x_cable_test_get_status() argument
1544 if (phydev->phy_id == ATH9331_PHY_ID || in at803x_cable_test_get_status()
1545 phydev->phy_id == ATH8032_PHY_ID || in at803x_cable_test_get_status()
1546 phydev->phy_id == QCA9561_PHY_ID) in at803x_cable_test_get_status()
1562 ret = at803x_cable_test_one_pair(phydev, pair); in at803x_cable_test_get_status()
1577 static int at803x_cable_test_start(struct phy_device *phydev) in at803x_cable_test_start() argument
1583 phy_write(phydev, MII_BMCR, BMCR_ANENABLE); in at803x_cable_test_start()
1584 phy_write(phydev, MII_ADVERTISE, ADVERTISE_CSMA); in at803x_cable_test_start()
1585 if (phydev->phy_id != ATH9331_PHY_ID && in at803x_cable_test_start()
1586 phydev->phy_id != ATH8032_PHY_ID && in at803x_cable_test_start()
1587 phydev->phy_id != QCA9561_PHY_ID) in at803x_cable_test_start()
1588 phy_write(phydev, MII_CTRL1000, 0); in at803x_cable_test_start()
1594 static int qca83xx_config_init(struct phy_device *phydev) in qca83xx_config_init() argument
1598 switch_revision = phydev->dev_flags & QCA8K_DEVFLAGS_REVISION_MASK; in qca83xx_config_init()
1603 at803x_debug_reg_write(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, 0x02ea); in qca83xx_config_init()
1605 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_GREEN, 0x68a0); in qca83xx_config_init()
1609 phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, 0x0); in qca83xx_config_init()
1612 phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_AZ_DEBUG, 0x803f); in qca83xx_config_init()
1613 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_GREEN, 0x6860); in qca83xx_config_init()
1614 at803x_debug_reg_write(phydev, AT803X_DEBUG_SYSTEM_CTRL_MODE, 0x2c46); in qca83xx_config_init()
1615 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_3C, 0x6000); in qca83xx_config_init()
1623 if (phydev->drv->phy_id == QCA8327_A_PHY_ID || in qca83xx_config_init()
1624 phydev->drv->phy_id == QCA8327_B_PHY_ID) in qca83xx_config_init()
1625 at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in qca83xx_config_init()
1629 phy_set_bits(phydev, MII_CTRL1000, CTL1000_PREFER_MASTER); in qca83xx_config_init()
1634 static void qca83xx_link_change_notify(struct phy_device *phydev) in qca83xx_link_change_notify() argument
1637 if (phydev->drv->phy_id == QCA8337_PHY_ID) in qca83xx_link_change_notify()
1641 if (phydev->state == PHY_RUNNING) { in qca83xx_link_change_notify()
1642 if (phydev->speed == SPEED_100) in qca83xx_link_change_notify()
1643 at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in qca83xx_link_change_notify()
1648 at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in qca83xx_link_change_notify()
1653 static int qca83xx_resume(struct phy_device *phydev) in qca83xx_resume() argument
1658 if (!phydev->suspended) in qca83xx_resume()
1662 qca83xx_config_init(phydev); in qca83xx_resume()
1665 phy_set_bits(phydev, MII_BMCR, BMCR_RESET | BMCR_ANENABLE); in qca83xx_resume()
1670 ret = phy_read_poll_timeout(phydev, MII_BMCR, val, !(val & BMCR_RESET), in qca83xx_resume()
1680 static int qca83xx_suspend(struct phy_device *phydev) in qca83xx_suspend() argument
1688 if (phydev->drv->phy_id == QCA8337_PHY_ID) { in qca83xx_suspend()
1689 genphy_suspend(phydev); in qca83xx_suspend()
1692 phy_modify(phydev, MII_BMCR, mask, 0); in qca83xx_suspend()
1695 at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_GREEN, in qca83xx_suspend()
1698 at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL, in qca83xx_suspend()
1705 static int qca808x_phy_fast_retrain_config(struct phy_device *phydev) in qca808x_phy_fast_retrain_config() argument
1710 ret = genphy_c45_fast_retrain(phydev, true); in qca808x_phy_fast_retrain_config()
1714 phy_write_mmd(phydev, MDIO_MMD_AN, QCA808X_PHY_MMD7_TOP_OPTION1, in qca808x_phy_fast_retrain_config()
1716 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_20DB, in qca808x_phy_fast_retrain_config()
1718 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_17DB, in qca808x_phy_fast_retrain_config()
1720 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_27DB, in qca808x_phy_fast_retrain_config()
1722 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_28DB, in qca808x_phy_fast_retrain_config()
1724 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_1, in qca808x_phy_fast_retrain_config()
1726 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_4, in qca808x_phy_fast_retrain_config()
1728 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_5, in qca808x_phy_fast_retrain_config()
1730 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_3, in qca808x_phy_fast_retrain_config()
1732 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_6, in qca808x_phy_fast_retrain_config()
1734 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_2, in qca808x_phy_fast_retrain_config()
1740 static int qca808x_phy_ms_seed_enable(struct phy_device *phydev, bool enable) in qca808x_phy_ms_seed_enable() argument
1745 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED, in qca808x_phy_ms_seed_enable()
1749 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED, in qca808x_phy_ms_seed_enable()
1755 static bool qca808x_is_prefer_master(struct phy_device *phydev) in qca808x_is_prefer_master() argument
1757 return (phydev->master_slave_get == MASTER_SLAVE_CFG_MASTER_FORCE) || in qca808x_is_prefer_master()
1758 (phydev->master_slave_get == MASTER_SLAVE_CFG_MASTER_PREFERRED); in qca808x_is_prefer_master()
1761 static bool qca808x_has_fast_retrain_or_slave_seed(struct phy_device *phydev) in qca808x_has_fast_retrain_or_slave_seed() argument
1763 return linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported); in qca808x_has_fast_retrain_or_slave_seed()
1766 static int qca808x_config_init(struct phy_device *phydev) in qca808x_config_init() argument
1771 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_ADDR_CLD_CTRL7, in qca808x_config_init()
1777 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, in qca808x_config_init()
1782 if (qca808x_has_fast_retrain_or_slave_seed(phydev)) { in qca808x_config_init()
1784 ret = qca808x_phy_fast_retrain_config(phydev); in qca808x_config_init()
1788 ret = genphy_read_master_slave(phydev); in qca808x_config_init()
1792 if (!qca808x_is_prefer_master(phydev)) { in qca808x_config_init()
1796 ret = qca808x_phy_ms_seed_enable(phydev, true); in qca808x_config_init()
1803 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_ADC_THRESHOLD, in qca808x_config_init()
1807 static int qca808x_read_status(struct phy_device *phydev) in qca808x_read_status() argument
1811 ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_STAT); in qca808x_read_status()
1815 linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->lp_advertising, in qca808x_read_status()
1818 ret = genphy_read_status(phydev); in qca808x_read_status()
1822 ret = at803x_read_specific_status(phydev); in qca808x_read_status()
1826 if (phydev->link) { in qca808x_read_status()
1827 if (phydev->speed == SPEED_2500) in qca808x_read_status()
1828 phydev->interface = PHY_INTERFACE_MODE_2500BASEX; in qca808x_read_status()
1830 phydev->interface = PHY_INTERFACE_MODE_SGMII; in qca808x_read_status()
1841 if (qca808x_has_fast_retrain_or_slave_seed(phydev)) { in qca808x_read_status()
1842 if (phydev->master_slave_state == MASTER_SLAVE_STATE_ERR || in qca808x_read_status()
1843 qca808x_is_prefer_master(phydev)) { in qca808x_read_status()
1844 qca808x_phy_ms_seed_enable(phydev, false); in qca808x_read_status()
1846 qca808x_phy_ms_seed_enable(phydev, true); in qca808x_read_status()
1854 static int qca808x_soft_reset(struct phy_device *phydev) in qca808x_soft_reset() argument
1858 ret = genphy_soft_reset(phydev); in qca808x_soft_reset()
1862 if (qca808x_has_fast_retrain_or_slave_seed(phydev)) in qca808x_soft_reset()
1863 ret = qca808x_phy_ms_seed_enable(phydev, true); in qca808x_soft_reset()
1894 static int qca808x_cdt_fault_length(struct phy_device *phydev, int pair) in qca808x_cdt_fault_length() argument
1916 val = phy_read_mmd(phydev, MDIO_MMD_PCS, cdt_length_reg); in qca808x_cdt_fault_length()
1923 static int qca808x_cable_test_start(struct phy_device *phydev) in qca808x_cable_test_start() argument
1934 ret = at803x_debug_reg_mask(phydev, QCA808X_DBG_AN_TEST, QCA808X_HIBERNATION_EN, 0); in qca808x_cable_test_start()
1938 ret = at803x_config_mdix(phydev, ETH_TP_MDI); in qca808x_cable_test_start()
1943 phydev->duplex = DUPLEX_FULL; in qca808x_cable_test_start()
1944 phydev->speed = SPEED_1000; in qca808x_cable_test_start()
1945 ret = genphy_c45_pma_setup_forced(phydev); in qca808x_cable_test_start()
1949 ret = genphy_setup_forced(phydev); in qca808x_cable_test_start()
1954 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8074, 0xc040); in qca808x_cable_test_start()
1955 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8076, 0xc040); in qca808x_cable_test_start()
1956 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8077, 0xa060); in qca808x_cable_test_start()
1957 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8078, 0xc050); in qca808x_cable_test_start()
1958 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807a, 0xc060); in qca808x_cable_test_start()
1959 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807e, 0xb060); in qca808x_cable_test_start()
1964 static int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finished) in qca808x_cable_test_get_status() argument
1971 ret = at803x_cdt_start(phydev, 0); in qca808x_cable_test_get_status()
1975 ret = at803x_cdt_wait_for_completion(phydev); in qca808x_cable_test_get_status()
1979 val = phy_read_mmd(phydev, MDIO_MMD_PCS, QCA808X_MMD3_CDT_STATUS); in qca808x_cable_test_get_status()
1988 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, in qca808x_cable_test_get_status()
1990 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_B, in qca808x_cable_test_get_status()
1992 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_C, in qca808x_cable_test_get_status()
1994 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_D, in qca808x_cable_test_get_status()
1998 ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_A, in qca808x_cable_test_get_status()
1999 qca808x_cdt_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_A)); in qca808x_cable_test_get_status()
2001 ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_B, in qca808x_cable_test_get_status()
2002 qca808x_cdt_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_B)); in qca808x_cable_test_get_status()
2004 ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_C, in qca808x_cable_test_get_status()
2005 qca808x_cdt_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_C)); in qca808x_cable_test_get_status()
2007 ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_D, in qca808x_cable_test_get_status()
2008 qca808x_cdt_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_D)); in qca808x_cable_test_get_status()
2015 static int qca808x_get_features(struct phy_device *phydev) in qca808x_get_features() argument
2019 ret = genphy_c45_pma_read_abilities(phydev); in qca808x_get_features()
2027 linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported); in qca808x_get_features()
2033 ret = phy_read_mmd(phydev, MDIO_MMD_AN, QCA808X_PHY_MMD7_CHIP_TYPE); in qca808x_get_features()
2038 linkmode_clear_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported); in qca808x_get_features()
2043 static void qca808x_link_change_notify(struct phy_device *phydev) in qca808x_link_change_notify() argument
2048 mdiobus_c45_modify_changed(phydev->mdio.bus, phydev->mdio.addr + 1, in qca808x_link_change_notify()
2050 QCA8081_PHY_FIFO_RSTN, phydev->link ? QCA8081_PHY_FIFO_RSTN : 0); in qca808x_link_change_notify()