Lines Matching full:phydev

360 static int at803x_debug_reg_write(struct phy_device *phydev, u16 reg, u16 data)  in at803x_debug_reg_write()  argument
364 ret = phy_write(phydev, AT803X_DEBUG_ADDR, reg); in at803x_debug_reg_write()
368 return phy_write(phydev, AT803X_DEBUG_DATA, data); in at803x_debug_reg_write()
371 static int at803x_debug_reg_read(struct phy_device *phydev, u16 reg) in at803x_debug_reg_read() argument
375 ret = phy_write(phydev, AT803X_DEBUG_ADDR, reg); in at803x_debug_reg_read()
379 return phy_read(phydev, AT803X_DEBUG_DATA); in at803x_debug_reg_read()
382 static int at803x_debug_reg_mask(struct phy_device *phydev, u16 reg, in at803x_debug_reg_mask() argument
388 ret = at803x_debug_reg_read(phydev, reg); in at803x_debug_reg_mask()
396 return phy_write(phydev, AT803X_DEBUG_DATA, val); in at803x_debug_reg_mask()
399 static int at803x_write_page(struct phy_device *phydev, int page) in at803x_write_page() argument
412 return __phy_modify(phydev, AT803X_REG_CHIP_CONFIG, mask, set); in at803x_write_page()
415 static int at803x_read_page(struct phy_device *phydev) in at803x_read_page() argument
417 int ccr = __phy_read(phydev, AT803X_REG_CHIP_CONFIG); in at803x_read_page()
428 static int at803x_enable_rx_delay(struct phy_device *phydev) in at803x_enable_rx_delay() argument
430 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, 0, in at803x_enable_rx_delay()
434 static int at803x_enable_tx_delay(struct phy_device *phydev) in at803x_enable_tx_delay() argument
436 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_SYSTEM_CTRL_MODE, 0, in at803x_enable_tx_delay()
440 static int at803x_disable_rx_delay(struct phy_device *phydev) in at803x_disable_rx_delay() argument
442 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in at803x_disable_rx_delay()
446 static int at803x_disable_tx_delay(struct phy_device *phydev) in at803x_disable_tx_delay() argument
448 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_SYSTEM_CTRL_MODE, in at803x_disable_tx_delay()
453 static void at803x_context_save(struct phy_device *phydev, in at803x_context_save() argument
456 context->bmcr = phy_read(phydev, MII_BMCR); in at803x_context_save()
457 context->advertise = phy_read(phydev, MII_ADVERTISE); in at803x_context_save()
458 context->control1000 = phy_read(phydev, MII_CTRL1000); in at803x_context_save()
459 context->int_enable = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_context_save()
460 context->smart_speed = phy_read(phydev, AT803X_SMART_SPEED); in at803x_context_save()
461 context->led_control = phy_read(phydev, AT803X_LED_CONTROL); in at803x_context_save()
465 static void at803x_context_restore(struct phy_device *phydev, in at803x_context_restore() argument
468 phy_write(phydev, MII_BMCR, context->bmcr); in at803x_context_restore()
469 phy_write(phydev, MII_ADVERTISE, context->advertise); in at803x_context_restore()
470 phy_write(phydev, MII_CTRL1000, context->control1000); in at803x_context_restore()
471 phy_write(phydev, AT803X_INTR_ENABLE, context->int_enable); in at803x_context_restore()
472 phy_write(phydev, AT803X_SMART_SPEED, context->smart_speed); in at803x_context_restore()
473 phy_write(phydev, AT803X_LED_CONTROL, context->led_control); in at803x_context_restore()
476 static int at803x_set_wol(struct phy_device *phydev, in at803x_set_wol() argument
482 struct net_device *ndev = phydev->attached_dev; in at803x_set_wol()
500 phy_write_mmd(phydev, MDIO_MMD_PCS, offsets[i], in at803x_set_wol()
504 ret = phy_modify(phydev, AT803X_INTR_ENABLE, 0, AT803X_INTR_ENABLE_WOL); in at803x_set_wol()
509 ret = phy_modify(phydev, AT803X_INTR_ENABLE, AT803X_INTR_ENABLE_WOL, 0); in at803x_set_wol()
515 ret = phy_read(phydev, AT803X_INTR_STATUS); in at803x_set_wol()
523 irq_enabled = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_set_wol()
528 if (ret & irq_enabled && !phy_polling_mode(phydev)) in at803x_set_wol()
529 phy_trigger_machine(phydev); in at803x_set_wol()
534 static void at803x_get_wol(struct phy_device *phydev, in at803x_get_wol() argument
542 value = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_get_wol()
550 static int qca83xx_get_sset_count(struct phy_device *phydev) in qca83xx_get_sset_count() argument
555 static void qca83xx_get_strings(struct phy_device *phydev, u8 *data) in qca83xx_get_strings() argument
565 static u64 qca83xx_get_stat(struct phy_device *phydev, int i) in qca83xx_get_stat() argument
568 struct at803x_priv *priv = phydev->priv; in qca83xx_get_stat()
573 val = phy_read_mmd(phydev, MDIO_MMD_PCS, stat.reg); in qca83xx_get_stat()
575 val = phy_read(phydev, stat.reg); in qca83xx_get_stat()
588 static void qca83xx_get_stats(struct phy_device *phydev, in qca83xx_get_stats() argument
594 data[i] = qca83xx_get_stat(phydev, i); in qca83xx_get_stats()
597 static int at803x_suspend(struct phy_device *phydev) in at803x_suspend() argument
602 value = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_suspend()
610 phy_modify(phydev, MII_BMCR, 0, value); in at803x_suspend()
615 static int at803x_resume(struct phy_device *phydev) in at803x_resume() argument
617 return phy_modify(phydev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 0); in at803x_resume()
620 static int at803x_parse_dt(struct phy_device *phydev) in at803x_parse_dt() argument
622 struct device_node *node = phydev->mdio.dev.of_node; in at803x_parse_dt()
623 struct at803x_priv *priv = phydev->priv; in at803x_parse_dt()
639 phydev_err(phydev, "invalid qca,smarteee-tw-us-1g\n"); in at803x_parse_dt()
647 phydev_err(phydev, "invalid qca,smarteee-tw-us-100m\n"); in at803x_parse_dt()
669 phydev_err(phydev, "invalid qca,clk-out-frequency\n"); in at803x_parse_dt()
691 phydev_err(phydev, "invalid qca,clk-out-strength\n"); in at803x_parse_dt()
699 static int at803x_probe(struct phy_device *phydev) in at803x_probe() argument
701 struct device *dev = &phydev->mdio.dev; in at803x_probe()
709 phydev->priv = priv; in at803x_probe()
711 ret = at803x_parse_dt(phydev); in at803x_probe()
718 static int at803x_get_features(struct phy_device *phydev) in at803x_get_features() argument
720 struct at803x_priv *priv = phydev->priv; in at803x_get_features()
723 err = genphy_read_abilities(phydev); in at803x_get_features()
727 if (phydev->drv->phy_id != ATH8031_PHY_ID) in at803x_get_features()
743 phydev->supported); in at803x_get_features()
748 static int at803x_smarteee_config(struct phy_device *phydev) in at803x_smarteee_config() argument
750 struct at803x_priv *priv = phydev->priv; in at803x_smarteee_config()
755 return phy_modify_mmd(phydev, MDIO_MMD_PCS, in at803x_smarteee_config()
770 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL1, in at803x_smarteee_config()
775 return phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL3, in at803x_smarteee_config()
780 static int at803x_clk_out_config(struct phy_device *phydev) in at803x_clk_out_config() argument
782 struct at803x_priv *priv = phydev->priv; in at803x_clk_out_config()
787 return phy_modify_mmd(phydev, MDIO_MMD_AN, AT803X_MMD7_CLK25M, in at803x_clk_out_config()
791 static int at8031_pll_config(struct phy_device *phydev) in at8031_pll_config() argument
793 struct at803x_priv *priv = phydev->priv; in at8031_pll_config()
799 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at8031_pll_config()
802 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at8031_pll_config()
806 static int at803x_hibernation_mode_config(struct phy_device *phydev) in at803x_hibernation_mode_config() argument
808 struct at803x_priv *priv = phydev->priv; in at803x_hibernation_mode_config()
816 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL, in at803x_hibernation_mode_config()
820 static int at803x_config_init(struct phy_device *phydev) in at803x_config_init() argument
829 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in at803x_config_init()
830 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in at803x_config_init()
831 ret = at803x_enable_rx_delay(phydev); in at803x_config_init()
833 ret = at803x_disable_rx_delay(phydev); in at803x_config_init()
837 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in at803x_config_init()
838 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in at803x_config_init()
839 ret = at803x_enable_tx_delay(phydev); in at803x_config_init()
841 ret = at803x_disable_tx_delay(phydev); in at803x_config_init()
845 ret = at803x_smarteee_config(phydev); in at803x_config_init()
849 ret = at803x_clk_out_config(phydev); in at803x_config_init()
853 ret = at803x_hibernation_mode_config(phydev); in at803x_config_init()
863 return phy_modify(phydev, MII_ADVERTISE, MDIO_AN_CTRL1_XNP, 0); in at803x_config_init()
866 static int at803x_ack_interrupt(struct phy_device *phydev) in at803x_ack_interrupt() argument
870 err = phy_read(phydev, AT803X_INTR_STATUS); in at803x_ack_interrupt()
875 static int at803x_config_intr(struct phy_device *phydev) in at803x_config_intr() argument
880 value = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_config_intr()
882 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in at803x_config_intr()
884 err = at803x_ack_interrupt(phydev); in at803x_config_intr()
894 err = phy_write(phydev, AT803X_INTR_ENABLE, value); in at803x_config_intr()
896 err = phy_write(phydev, AT803X_INTR_ENABLE, 0); in at803x_config_intr()
901 err = at803x_ack_interrupt(phydev); in at803x_config_intr()
907 static irqreturn_t at803x_handle_interrupt(struct phy_device *phydev) in at803x_handle_interrupt() argument
911 irq_status = phy_read(phydev, AT803X_INTR_STATUS); in at803x_handle_interrupt()
913 phy_error(phydev); in at803x_handle_interrupt()
918 int_enabled = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_handle_interrupt()
920 phy_error(phydev); in at803x_handle_interrupt()
928 phy_trigger_machine(phydev); in at803x_handle_interrupt()
933 static void at803x_link_change_notify(struct phy_device *phydev) in at803x_link_change_notify() argument
942 if (phydev->state == PHY_NOLINK && phydev->mdio.reset_gpio) { in at803x_link_change_notify()
945 at803x_context_save(phydev, &context); in at803x_link_change_notify()
947 phy_device_reset(phydev, 1); in at803x_link_change_notify()
949 phy_device_reset(phydev, 0); in at803x_link_change_notify()
952 at803x_context_restore(phydev, &context); in at803x_link_change_notify()
954 phydev_dbg(phydev, "%s(): phy was reset\n", __func__); in at803x_link_change_notify()
958 static int at803x_read_specific_status(struct phy_device *phydev, in at803x_read_specific_status() argument
967 ss = phy_read(phydev, AT803X_SPECIFIC_STATUS); in at803x_read_specific_status()
974 sfc = phy_read(phydev, AT803X_SPECIFIC_FUNCTION_CONTROL); in at803x_read_specific_status()
983 phydev->speed = SPEED_10; in at803x_read_specific_status()
986 phydev->speed = SPEED_100; in at803x_read_specific_status()
989 phydev->speed = SPEED_1000; in at803x_read_specific_status()
992 phydev->speed = SPEED_2500; in at803x_read_specific_status()
996 phydev->duplex = DUPLEX_FULL; in at803x_read_specific_status()
998 phydev->duplex = DUPLEX_HALF; in at803x_read_specific_status()
1001 phydev->mdix = ETH_TP_MDI_X; in at803x_read_specific_status()
1003 phydev->mdix = ETH_TP_MDI; in at803x_read_specific_status()
1007 phydev->mdix_ctrl = ETH_TP_MDI; in at803x_read_specific_status()
1010 phydev->mdix_ctrl = ETH_TP_MDI_X; in at803x_read_specific_status()
1013 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in at803x_read_specific_status()
1021 static int at803x_read_status(struct phy_device *phydev) in at803x_read_status() argument
1024 int err, old_link = phydev->link; in at803x_read_status()
1027 err = genphy_update_link(phydev); in at803x_read_status()
1032 if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) in at803x_read_status()
1035 phydev->speed = SPEED_UNKNOWN; in at803x_read_status()
1036 phydev->duplex = DUPLEX_UNKNOWN; in at803x_read_status()
1037 phydev->pause = 0; in at803x_read_status()
1038 phydev->asym_pause = 0; in at803x_read_status()
1040 err = genphy_read_lpa(phydev); in at803x_read_status()
1046 err = at803x_read_specific_status(phydev, ss_mask); in at803x_read_status()
1050 if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) in at803x_read_status()
1051 phy_resolve_aneg_pause(phydev); in at803x_read_status()
1056 static int at803x_config_mdix(struct phy_device *phydev, u8 ctrl) in at803x_config_mdix() argument
1074 return phy_modify_changed(phydev, AT803X_SPECIFIC_FUNCTION_CONTROL, in at803x_config_mdix()
1079 static int at803x_prepare_config_aneg(struct phy_device *phydev) in at803x_prepare_config_aneg() argument
1083 ret = at803x_config_mdix(phydev, phydev->mdix_ctrl); in at803x_prepare_config_aneg()
1092 ret = genphy_soft_reset(phydev); in at803x_prepare_config_aneg()
1100 static int at803x_config_aneg(struct phy_device *phydev) in at803x_config_aneg() argument
1102 struct at803x_priv *priv = phydev->priv; in at803x_config_aneg()
1105 ret = at803x_prepare_config_aneg(phydev); in at803x_config_aneg()
1110 return genphy_c37_config_aneg(phydev); in at803x_config_aneg()
1112 return genphy_config_aneg(phydev); in at803x_config_aneg()
1115 static int at803x_get_downshift(struct phy_device *phydev, u8 *d) in at803x_get_downshift() argument
1119 val = phy_read(phydev, AT803X_SMART_SPEED); in at803x_get_downshift()
1131 static int at803x_set_downshift(struct phy_device *phydev, u8 cnt) in at803x_set_downshift() argument
1155 ret = phy_modify_changed(phydev, AT803X_SMART_SPEED, mask, set); in at803x_set_downshift()
1162 ret = phy_init_hw(phydev); in at803x_set_downshift()
1167 static int at803x_get_tunable(struct phy_device *phydev, in at803x_get_tunable() argument
1172 return at803x_get_downshift(phydev, data); in at803x_get_tunable()
1178 static int at803x_set_tunable(struct phy_device *phydev, in at803x_set_tunable() argument
1183 return at803x_set_downshift(phydev, *(const u8 *)data); in at803x_set_tunable()
1240 static int at803x_cdt_start(struct phy_device *phydev, in at803x_cdt_start() argument
1243 return phy_write(phydev, AT803X_CDT, cdt_start); in at803x_cdt_start()
1246 static int at803x_cdt_wait_for_completion(struct phy_device *phydev, in at803x_cdt_wait_for_completion() argument
1252 ret = phy_read_poll_timeout(phydev, AT803X_CDT, val, in at803x_cdt_wait_for_completion()
1259 static int at803x_cable_test_one_pair(struct phy_device *phydev, int pair) in at803x_cable_test_one_pair() argument
1271 ret = at803x_cdt_start(phydev, val); in at803x_cable_test_one_pair()
1275 ret = at803x_cdt_wait_for_completion(phydev, AT803X_CDT_ENABLE_TEST); in at803x_cable_test_one_pair()
1279 val = phy_read(phydev, AT803X_CDT_STATUS); in at803x_cable_test_one_pair()
1286 ethnl_cable_test_result(phydev, ethtool_pair[pair], in at803x_cable_test_one_pair()
1291 ethnl_cable_test_fault_length(phydev, ethtool_pair[pair], in at803x_cable_test_one_pair()
1298 static int at803x_cable_test_get_status(struct phy_device *phydev, in at803x_cable_test_get_status() argument
1315 ret = at803x_cable_test_one_pair(phydev, pair); in at803x_cable_test_get_status()
1330 static void at803x_cable_test_autoneg(struct phy_device *phydev) in at803x_cable_test_autoneg() argument
1336 phy_write(phydev, MII_BMCR, BMCR_ANENABLE); in at803x_cable_test_autoneg()
1337 phy_write(phydev, MII_ADVERTISE, ADVERTISE_CSMA); in at803x_cable_test_autoneg()
1340 static int at803x_cable_test_start(struct phy_device *phydev) in at803x_cable_test_start() argument
1342 at803x_cable_test_autoneg(phydev); in at803x_cable_test_start()
1350 struct phy_device *phydev = rdev_get_drvdata(rdev); in at8031_rgmii_reg_set_voltage_sel() local
1353 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at8031_rgmii_reg_set_voltage_sel()
1356 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at8031_rgmii_reg_set_voltage_sel()
1362 struct phy_device *phydev = rdev_get_drvdata(rdev); in at8031_rgmii_reg_get_voltage_sel() local
1365 val = at803x_debug_reg_read(phydev, AT803X_DEBUG_REG_1F); in at8031_rgmii_reg_get_voltage_sel()
1406 static int at8031_register_regulators(struct phy_device *phydev) in at8031_register_regulators() argument
1408 struct at803x_priv *priv = phydev->priv; in at8031_register_regulators()
1409 struct device *dev = &phydev->mdio.dev; in at8031_register_regulators()
1413 config.driver_data = phydev; in at8031_register_regulators()
1417 phydev_err(phydev, "failed to register VDDIO regulator\n"); in at8031_register_regulators()
1423 phydev_err(phydev, "failed to register VDDH regulator\n"); in at8031_register_regulators()
1432 struct phy_device *phydev = upstream; in at8031_sfp_insert() local
1446 sfp_parse_support(phydev->sfp_bus, id, sfp_support, interfaces); in at8031_sfp_insert()
1453 dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n"); in at8031_sfp_insert()
1457 iface = sfp_select_interface(phydev->sfp_bus, sfp_support); in at8031_sfp_insert()
1467 dev_warn(&phydev->mdio.dev, "module may not function if 1000Base-X not supported\n"); in at8031_sfp_insert()
1480 static int at8031_parse_dt(struct phy_device *phydev) in at8031_parse_dt() argument
1482 struct device_node *node = phydev->mdio.dev.of_node; in at8031_parse_dt()
1483 struct at803x_priv *priv = phydev->priv; in at8031_parse_dt()
1489 ret = at8031_register_regulators(phydev); in at8031_parse_dt()
1493 ret = devm_regulator_get_enable_optional(&phydev->mdio.dev, in at8031_parse_dt()
1496 phydev_err(phydev, "failed to get VDDIO regulator\n"); in at8031_parse_dt()
1501 return phy_sfp_probe(phydev, &at8031_sfp_ops); in at8031_parse_dt()
1504 static int at8031_probe(struct phy_device *phydev) in at8031_probe() argument
1506 struct at803x_priv *priv = phydev->priv; in at8031_probe()
1511 ret = at803x_probe(phydev); in at8031_probe()
1518 ret = at8031_parse_dt(phydev); in at8031_probe()
1522 ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG); in at8031_probe()
1541 return phy_modify_mmd(phydev, MDIO_MMD_PCS, in at8031_probe()
1546 static int at8031_config_init(struct phy_device *phydev) in at8031_config_init() argument
1548 struct at803x_priv *priv = phydev->priv; in at8031_config_init()
1555 phy_lock_mdio_bus(phydev); in at8031_config_init()
1556 ret = at803x_write_page(phydev, in at8031_config_init()
1559 phy_unlock_mdio_bus(phydev); in at8031_config_init()
1563 ret = at8031_pll_config(phydev); in at8031_config_init()
1567 return at803x_config_init(phydev); in at8031_config_init()
1570 static int at8031_set_wol(struct phy_device *phydev, in at8031_set_wol() argument
1576 ret = at803x_set_wol(phydev, wol); in at8031_set_wol()
1582 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, in at8031_set_wol()
1587 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, in at8031_set_wol()
1594 static int at8031_config_intr(struct phy_device *phydev) in at8031_config_intr() argument
1596 struct at803x_priv *priv = phydev->priv; in at8031_config_intr()
1599 if (phydev->interrupts == PHY_INTERRUPT_ENABLED && in at8031_config_intr()
1602 err = at803x_ack_interrupt(phydev); in at8031_config_intr()
1609 err = phy_set_bits(phydev, AT803X_INTR_ENABLE, value); in at8031_config_intr()
1614 return at803x_config_intr(phydev); in at8031_config_intr()
1618 static int at8031_read_status(struct phy_device *phydev) in at8031_read_status() argument
1620 struct at803x_priv *priv = phydev->priv; in at8031_read_status()
1623 return genphy_c37_read_status(phydev); in at8031_read_status()
1625 return at803x_read_status(phydev); in at8031_read_status()
1629 static int at8031_cable_test_get_status(struct phy_device *phydev, in at8031_cable_test_get_status() argument
1632 return at803x_cable_test_get_status(phydev, finished, 0xf); in at8031_cable_test_get_status()
1636 static int at8031_cable_test_start(struct phy_device *phydev) in at8031_cable_test_start() argument
1638 at803x_cable_test_autoneg(phydev); in at8031_cable_test_start()
1639 phy_write(phydev, MII_CTRL1000, 0); in at8031_cable_test_start()
1645 static int at8032_cable_test_get_status(struct phy_device *phydev, in at8032_cable_test_get_status() argument
1648 return at803x_cable_test_get_status(phydev, finished, 0x3); in at8032_cable_test_get_status()
1651 static int at8035_parse_dt(struct phy_device *phydev) in at8035_parse_dt() argument
1653 struct at803x_priv *priv = phydev->priv; in at8035_parse_dt()
1679 static int at8035_probe(struct phy_device *phydev) in at8035_probe() argument
1683 ret = at803x_probe(phydev); in at8035_probe()
1687 return at8035_parse_dt(phydev); in at8035_probe()
1690 static int qca83xx_config_init(struct phy_device *phydev) in qca83xx_config_init() argument
1694 switch_revision = phydev->dev_flags & QCA8K_DEVFLAGS_REVISION_MASK; in qca83xx_config_init()
1699 at803x_debug_reg_write(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, 0x02ea); in qca83xx_config_init()
1701 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_GREEN, 0x68a0); in qca83xx_config_init()
1705 phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, 0x0); in qca83xx_config_init()
1708 phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_AZ_DEBUG, 0x803f); in qca83xx_config_init()
1709 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_GREEN, 0x6860); in qca83xx_config_init()
1710 at803x_debug_reg_write(phydev, AT803X_DEBUG_SYSTEM_CTRL_MODE, 0x2c46); in qca83xx_config_init()
1711 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_3C, 0x6000); in qca83xx_config_init()
1716 phy_set_bits(phydev, MII_CTRL1000, CTL1000_PREFER_MASTER); in qca83xx_config_init()
1721 static int qca8327_config_init(struct phy_device *phydev) in qca8327_config_init() argument
1727 at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in qca8327_config_init()
1730 return qca83xx_config_init(phydev); in qca8327_config_init()
1733 static void qca83xx_link_change_notify(struct phy_device *phydev) in qca83xx_link_change_notify() argument
1736 if (phydev->state == PHY_RUNNING) { in qca83xx_link_change_notify()
1737 if (phydev->speed == SPEED_100) in qca83xx_link_change_notify()
1738 at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in qca83xx_link_change_notify()
1743 at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in qca83xx_link_change_notify()
1748 static int qca83xx_resume(struct phy_device *phydev) in qca83xx_resume() argument
1753 if (!phydev->suspended) in qca83xx_resume()
1757 qca83xx_config_init(phydev); in qca83xx_resume()
1760 phy_set_bits(phydev, MII_BMCR, BMCR_RESET | BMCR_ANENABLE); in qca83xx_resume()
1765 ret = phy_read_poll_timeout(phydev, MII_BMCR, val, !(val & BMCR_RESET), in qca83xx_resume()
1775 static int qca83xx_suspend(struct phy_device *phydev) in qca83xx_suspend() argument
1777 at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_GREEN, in qca83xx_suspend()
1780 at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL, in qca83xx_suspend()
1787 static int qca8337_suspend(struct phy_device *phydev) in qca8337_suspend() argument
1790 genphy_suspend(phydev); in qca8337_suspend()
1792 return qca83xx_suspend(phydev); in qca8337_suspend()
1795 static int qca8327_suspend(struct phy_device *phydev) in qca8327_suspend() argument
1803 phy_modify(phydev, MII_BMCR, mask, 0); in qca8327_suspend()
1805 return qca83xx_suspend(phydev); in qca8327_suspend()
1808 static int qca808x_phy_fast_retrain_config(struct phy_device *phydev) in qca808x_phy_fast_retrain_config() argument
1813 ret = genphy_c45_fast_retrain(phydev, true); in qca808x_phy_fast_retrain_config()
1817 phy_write_mmd(phydev, MDIO_MMD_AN, QCA808X_PHY_MMD7_TOP_OPTION1, in qca808x_phy_fast_retrain_config()
1819 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_20DB, in qca808x_phy_fast_retrain_config()
1821 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_17DB, in qca808x_phy_fast_retrain_config()
1823 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_27DB, in qca808x_phy_fast_retrain_config()
1825 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, QCA808X_PHY_MMD1_MSE_THRESHOLD_28DB, in qca808x_phy_fast_retrain_config()
1827 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_1, in qca808x_phy_fast_retrain_config()
1829 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_4, in qca808x_phy_fast_retrain_config()
1831 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_5, in qca808x_phy_fast_retrain_config()
1833 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_3, in qca808x_phy_fast_retrain_config()
1835 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_6, in qca808x_phy_fast_retrain_config()
1837 phy_write_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_DEBUG_2, in qca808x_phy_fast_retrain_config()
1843 static int qca808x_phy_ms_seed_enable(struct phy_device *phydev, bool enable) in qca808x_phy_ms_seed_enable() argument
1848 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED, in qca808x_phy_ms_seed_enable()
1852 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED, in qca808x_phy_ms_seed_enable()
1858 static bool qca808x_is_prefer_master(struct phy_device *phydev) in qca808x_is_prefer_master() argument
1860 return (phydev->master_slave_get == MASTER_SLAVE_CFG_MASTER_FORCE) || in qca808x_is_prefer_master()
1861 (phydev->master_slave_get == MASTER_SLAVE_CFG_MASTER_PREFERRED); in qca808x_is_prefer_master()
1864 static bool qca808x_has_fast_retrain_or_slave_seed(struct phy_device *phydev) in qca808x_has_fast_retrain_or_slave_seed() argument
1866 return linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported); in qca808x_has_fast_retrain_or_slave_seed()
1869 static int qca808x_config_init(struct phy_device *phydev) in qca808x_config_init() argument
1874 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_ADDR_CLD_CTRL7, in qca808x_config_init()
1880 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, in qca808x_config_init()
1886 if (qca808x_has_fast_retrain_or_slave_seed(phydev)) { in qca808x_config_init()
1888 ret = qca808x_phy_fast_retrain_config(phydev); in qca808x_config_init()
1892 ret = genphy_read_master_slave(phydev); in qca808x_config_init()
1896 if (!qca808x_is_prefer_master(phydev)) { in qca808x_config_init()
1900 ret = qca808x_phy_ms_seed_enable(phydev, true); in qca808x_config_init()
1907 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_ADC_THRESHOLD, in qca808x_config_init()
1912 static int qca808x_read_status(struct phy_device *phydev) in qca808x_read_status() argument
1917 ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_STAT); in qca808x_read_status()
1921 linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->lp_advertising, in qca808x_read_status()
1924 ret = genphy_read_status(phydev); in qca808x_read_status()
1931 ret = at803x_read_specific_status(phydev, ss_mask); in qca808x_read_status()
1935 if (phydev->link) { in qca808x_read_status()
1936 if (phydev->speed == SPEED_2500) in qca808x_read_status()
1937 phydev->interface = PHY_INTERFACE_MODE_2500BASEX; in qca808x_read_status()
1939 phydev->interface = PHY_INTERFACE_MODE_SGMII; in qca808x_read_status()
1950 if (qca808x_has_fast_retrain_or_slave_seed(phydev)) { in qca808x_read_status()
1951 if (phydev->master_slave_state == MASTER_SLAVE_STATE_ERR || in qca808x_read_status()
1952 qca808x_is_prefer_master(phydev)) { in qca808x_read_status()
1953 qca808x_phy_ms_seed_enable(phydev, false); in qca808x_read_status()
1955 qca808x_phy_ms_seed_enable(phydev, true); in qca808x_read_status()
1963 static int qca808x_soft_reset(struct phy_device *phydev) in qca808x_soft_reset() argument
1967 ret = genphy_soft_reset(phydev); in qca808x_soft_reset()
1971 if (qca808x_has_fast_retrain_or_slave_seed(phydev)) in qca808x_soft_reset()
1972 ret = qca808x_phy_ms_seed_enable(phydev, true); in qca808x_soft_reset()
2022 static int qca808x_cdt_fault_length(struct phy_device *phydev, int pair, in qca808x_cdt_fault_length() argument
2045 val = phy_read_mmd(phydev, MDIO_MMD_PCS, cdt_length_reg); in qca808x_cdt_fault_length()
2057 static int qca808x_cable_test_start(struct phy_device *phydev) in qca808x_cable_test_start() argument
2068 ret = at803x_debug_reg_mask(phydev, QCA808X_DBG_AN_TEST, QCA808X_HIBERNATION_EN, 0); in qca808x_cable_test_start()
2072 ret = at803x_config_mdix(phydev, ETH_TP_MDI); in qca808x_cable_test_start()
2077 phydev->duplex = DUPLEX_FULL; in qca808x_cable_test_start()
2078 phydev->speed = SPEED_1000; in qca808x_cable_test_start()
2079 ret = genphy_c45_pma_setup_forced(phydev); in qca808x_cable_test_start()
2083 ret = genphy_setup_forced(phydev); in qca808x_cable_test_start()
2088 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8074, 0xc040); in qca808x_cable_test_start()
2089 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8076, 0xc040); in qca808x_cable_test_start()
2090 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8077, 0xa060); in qca808x_cable_test_start()
2091 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8078, 0xc050); in qca808x_cable_test_start()
2092 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807a, 0xc060); in qca808x_cable_test_start()
2093 phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807e, 0xb060); in qca808x_cable_test_start()
2098 static int qca808x_cable_test_get_pair_status(struct phy_device *phydev, u8 pair, in qca808x_cable_test_get_pair_status() argument
2122 ethnl_cable_test_result(phydev, pair, result); in qca808x_cable_test_get_pair_status()
2125 length = qca808x_cdt_fault_length(phydev, pair, result); in qca808x_cable_test_get_pair_status()
2126 ethnl_cable_test_fault_length(phydev, pair, length); in qca808x_cable_test_get_pair_status()
2132 static int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finished) in qca808x_cable_test_get_status() argument
2140 ret = at803x_cdt_start(phydev, val); in qca808x_cable_test_get_status()
2144 ret = at803x_cdt_wait_for_completion(phydev, QCA808X_CDT_ENABLE_TEST); in qca808x_cable_test_get_status()
2148 val = phy_read_mmd(phydev, MDIO_MMD_PCS, QCA808X_MMD3_CDT_STATUS); in qca808x_cable_test_get_status()
2152 ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_A, val); in qca808x_cable_test_get_status()
2156 ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_B, val); in qca808x_cable_test_get_status()
2160 ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_C, val); in qca808x_cable_test_get_status()
2164 ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_D, val); in qca808x_cable_test_get_status()
2173 static int qca808x_get_features(struct phy_device *phydev) in qca808x_get_features() argument
2177 ret = genphy_c45_pma_read_abilities(phydev); in qca808x_get_features()
2185 linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported); in qca808x_get_features()
2191 ret = phy_read_mmd(phydev, MDIO_MMD_AN, QCA808X_PHY_MMD7_CHIP_TYPE); in qca808x_get_features()
2196 linkmode_clear_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported); in qca808x_get_features()
2201 static int qca808x_config_aneg(struct phy_device *phydev) in qca808x_config_aneg() argument
2206 ret = at803x_prepare_config_aneg(phydev); in qca808x_config_aneg()
2213 if (phydev->autoneg == AUTONEG_DISABLE) in qca808x_config_aneg()
2214 genphy_c45_pma_setup_forced(phydev); in qca808x_config_aneg()
2216 if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->advertising)) in qca808x_config_aneg()
2219 ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL, in qca808x_config_aneg()
2224 return __genphy_config_aneg(phydev, ret); in qca808x_config_aneg()
2227 static void qca808x_link_change_notify(struct phy_device *phydev) in qca808x_link_change_notify() argument
2232 mdiobus_c45_modify_changed(phydev->mdio.bus, phydev->mdio.addr + 1, in qca808x_link_change_notify()
2235 phydev->link ? QCA8081_PHY_FIFO_RSTN : 0); in qca808x_link_change_notify()