Lines Matching full:phydev

209 static int at803x_debug_reg_write(struct phy_device *phydev, u16 reg, u16 data)  in at803x_debug_reg_write()  argument
213 ret = phy_write(phydev, AT803X_DEBUG_ADDR, reg); in at803x_debug_reg_write()
217 return phy_write(phydev, AT803X_DEBUG_DATA, data); in at803x_debug_reg_write()
220 static int at803x_debug_reg_read(struct phy_device *phydev, u16 reg) in at803x_debug_reg_read() argument
224 ret = phy_write(phydev, AT803X_DEBUG_ADDR, reg); in at803x_debug_reg_read()
228 return phy_read(phydev, AT803X_DEBUG_DATA); in at803x_debug_reg_read()
231 static int at803x_debug_reg_mask(struct phy_device *phydev, u16 reg, in at803x_debug_reg_mask() argument
237 ret = at803x_debug_reg_read(phydev, reg); in at803x_debug_reg_mask()
245 return phy_write(phydev, AT803X_DEBUG_DATA, val); in at803x_debug_reg_mask()
248 static int at803x_write_page(struct phy_device *phydev, int page) in at803x_write_page() argument
261 return __phy_modify(phydev, AT803X_REG_CHIP_CONFIG, mask, set); in at803x_write_page()
264 static int at803x_read_page(struct phy_device *phydev) in at803x_read_page() argument
266 int ccr = __phy_read(phydev, AT803X_REG_CHIP_CONFIG); in at803x_read_page()
277 static int at803x_enable_rx_delay(struct phy_device *phydev) in at803x_enable_rx_delay() argument
279 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0, 0, in at803x_enable_rx_delay()
283 static int at803x_enable_tx_delay(struct phy_device *phydev) in at803x_enable_tx_delay() argument
285 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5, 0, in at803x_enable_tx_delay()
289 static int at803x_disable_rx_delay(struct phy_device *phydev) in at803x_disable_rx_delay() argument
291 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0, in at803x_disable_rx_delay()
295 static int at803x_disable_tx_delay(struct phy_device *phydev) in at803x_disable_tx_delay() argument
297 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5, in at803x_disable_tx_delay()
302 static void at803x_context_save(struct phy_device *phydev, in at803x_context_save() argument
305 context->bmcr = phy_read(phydev, MII_BMCR); in at803x_context_save()
306 context->advertise = phy_read(phydev, MII_ADVERTISE); in at803x_context_save()
307 context->control1000 = phy_read(phydev, MII_CTRL1000); in at803x_context_save()
308 context->int_enable = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_context_save()
309 context->smart_speed = phy_read(phydev, AT803X_SMART_SPEED); in at803x_context_save()
310 context->led_control = phy_read(phydev, AT803X_LED_CONTROL); in at803x_context_save()
314 static void at803x_context_restore(struct phy_device *phydev, in at803x_context_restore() argument
317 phy_write(phydev, MII_BMCR, context->bmcr); in at803x_context_restore()
318 phy_write(phydev, MII_ADVERTISE, context->advertise); in at803x_context_restore()
319 phy_write(phydev, MII_CTRL1000, context->control1000); in at803x_context_restore()
320 phy_write(phydev, AT803X_INTR_ENABLE, context->int_enable); in at803x_context_restore()
321 phy_write(phydev, AT803X_SMART_SPEED, context->smart_speed); in at803x_context_restore()
322 phy_write(phydev, AT803X_LED_CONTROL, context->led_control); in at803x_context_restore()
325 static int at803x_set_wol(struct phy_device *phydev, in at803x_set_wol() argument
328 struct net_device *ndev = phydev->attached_dev; in at803x_set_wol()
348 phy_write_mmd(phydev, AT803X_DEVICE_ADDR, offsets[i], in at803x_set_wol()
351 value = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_set_wol()
353 ret = phy_write(phydev, AT803X_INTR_ENABLE, value); in at803x_set_wol()
356 value = phy_read(phydev, AT803X_INTR_STATUS); in at803x_set_wol()
358 value = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_set_wol()
360 ret = phy_write(phydev, AT803X_INTR_ENABLE, value); in at803x_set_wol()
363 value = phy_read(phydev, AT803X_INTR_STATUS); in at803x_set_wol()
369 static void at803x_get_wol(struct phy_device *phydev, in at803x_get_wol() argument
377 value = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_get_wol()
382 static int at803x_get_sset_count(struct phy_device *phydev) in at803x_get_sset_count() argument
387 static void at803x_get_strings(struct phy_device *phydev, u8 *data) in at803x_get_strings() argument
397 static u64 at803x_get_stat(struct phy_device *phydev, int i) in at803x_get_stat() argument
400 struct at803x_priv *priv = phydev->priv; in at803x_get_stat()
405 val = phy_read_mmd(phydev, MDIO_MMD_PCS, stat.reg); in at803x_get_stat()
407 val = phy_read(phydev, stat.reg); in at803x_get_stat()
420 static void at803x_get_stats(struct phy_device *phydev, in at803x_get_stats() argument
426 data[i] = at803x_get_stat(phydev, i); in at803x_get_stats()
429 static int at803x_suspend(struct phy_device *phydev) in at803x_suspend() argument
434 value = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_suspend()
442 phy_modify(phydev, MII_BMCR, 0, value); in at803x_suspend()
447 static int at803x_resume(struct phy_device *phydev) in at803x_resume() argument
449 return phy_modify(phydev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 0); in at803x_resume()
455 struct phy_device *phydev = rdev_get_drvdata(rdev); in at803x_rgmii_reg_set_voltage_sel() local
458 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at803x_rgmii_reg_set_voltage_sel()
461 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at803x_rgmii_reg_set_voltage_sel()
467 struct phy_device *phydev = rdev_get_drvdata(rdev); in at803x_rgmii_reg_get_voltage_sel() local
470 val = at803x_debug_reg_read(phydev, AT803X_DEBUG_REG_1F); in at803x_rgmii_reg_get_voltage_sel()
511 static int at8031_register_regulators(struct phy_device *phydev) in at8031_register_regulators() argument
513 struct at803x_priv *priv = phydev->priv; in at8031_register_regulators()
514 struct device *dev = &phydev->mdio.dev; in at8031_register_regulators()
518 config.driver_data = phydev; in at8031_register_regulators()
522 phydev_err(phydev, "failed to register VDDIO regulator\n"); in at8031_register_regulators()
528 phydev_err(phydev, "failed to register VDDH regulator\n"); in at8031_register_regulators()
535 static int at803x_parse_dt(struct phy_device *phydev) in at803x_parse_dt() argument
537 struct device_node *node = phydev->mdio.dev.of_node; in at803x_parse_dt()
538 struct at803x_priv *priv = phydev->priv; in at803x_parse_dt()
551 phydev_err(phydev, "invalid qca,smarteee-tw-us-1g\n"); in at803x_parse_dt()
559 phydev_err(phydev, "invalid qca,smarteee-tw-us-100m\n"); in at803x_parse_dt()
581 phydev_err(phydev, "invalid qca,clk-out-frequency\n"); in at803x_parse_dt()
599 if (phydev->drv->phy_id == ATH8030_PHY_ID || in at803x_parse_dt()
600 phydev->drv->phy_id == ATH8035_PHY_ID) { in at803x_parse_dt()
620 phydev_err(phydev, "invalid qca,clk-out-strength\n"); in at803x_parse_dt()
628 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_parse_dt()
632 ret = at8031_register_regulators(phydev); in at803x_parse_dt()
636 priv->vddio = devm_regulator_get_optional(&phydev->mdio.dev, in at803x_parse_dt()
639 phydev_err(phydev, "failed to get VDDIO regulator\n"); in at803x_parse_dt()
647 static int at803x_probe(struct phy_device *phydev) in at803x_probe() argument
649 struct device *dev = &phydev->mdio.dev; in at803x_probe()
657 phydev->priv = priv; in at803x_probe()
659 ret = at803x_parse_dt(phydev); in at803x_probe()
673 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_probe()
674 phy_lock_mdio_bus(phydev); in at803x_probe()
675 ret = at803x_write_page(phydev, AT803X_PAGE_COPPER); in at803x_probe()
676 phy_unlock_mdio_bus(phydev); in at803x_probe()
690 static void at803x_remove(struct phy_device *phydev) in at803x_remove() argument
692 struct at803x_priv *priv = phydev->priv; in at803x_remove()
698 static int at803x_get_features(struct phy_device *phydev) in at803x_get_features() argument
702 err = genphy_read_abilities(phydev); in at803x_get_features()
706 if (phydev->drv->phy_id != ATH8031_PHY_ID) in at803x_get_features()
722 phydev->supported); in at803x_get_features()
726 static int at803x_smarteee_config(struct phy_device *phydev) in at803x_smarteee_config() argument
728 struct at803x_priv *priv = phydev->priv; in at803x_smarteee_config()
733 return phy_modify_mmd(phydev, MDIO_MMD_PCS, in at803x_smarteee_config()
748 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL1, in at803x_smarteee_config()
753 return phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL3, in at803x_smarteee_config()
758 static int at803x_clk_out_config(struct phy_device *phydev) in at803x_clk_out_config() argument
760 struct at803x_priv *priv = phydev->priv; in at803x_clk_out_config()
765 return phy_modify_mmd(phydev, MDIO_MMD_AN, AT803X_MMD7_CLK25M, in at803x_clk_out_config()
769 static int at8031_pll_config(struct phy_device *phydev) in at8031_pll_config() argument
771 struct at803x_priv *priv = phydev->priv; in at8031_pll_config()
777 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at8031_pll_config()
780 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at8031_pll_config()
784 static int at803x_config_init(struct phy_device *phydev) in at803x_config_init() argument
793 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in at803x_config_init()
794 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in at803x_config_init()
795 ret = at803x_enable_rx_delay(phydev); in at803x_config_init()
797 ret = at803x_disable_rx_delay(phydev); in at803x_config_init()
801 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in at803x_config_init()
802 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in at803x_config_init()
803 ret = at803x_enable_tx_delay(phydev); in at803x_config_init()
805 ret = at803x_disable_tx_delay(phydev); in at803x_config_init()
809 ret = at803x_smarteee_config(phydev); in at803x_config_init()
813 ret = at803x_clk_out_config(phydev); in at803x_config_init()
817 if (phydev->drv->phy_id == ATH8031_PHY_ID) { in at803x_config_init()
818 ret = at8031_pll_config(phydev); in at803x_config_init()
829 return phy_modify(phydev, MII_ADVERTISE, MDIO_AN_CTRL1_XNP, 0); in at803x_config_init()
832 static int at803x_ack_interrupt(struct phy_device *phydev) in at803x_ack_interrupt() argument
836 err = phy_read(phydev, AT803X_INTR_STATUS); in at803x_ack_interrupt()
841 static int at803x_config_intr(struct phy_device *phydev) in at803x_config_intr() argument
846 value = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_config_intr()
848 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in at803x_config_intr()
850 err = at803x_ack_interrupt(phydev); in at803x_config_intr()
860 err = phy_write(phydev, AT803X_INTR_ENABLE, value); in at803x_config_intr()
862 err = phy_write(phydev, AT803X_INTR_ENABLE, 0); in at803x_config_intr()
867 err = at803x_ack_interrupt(phydev); in at803x_config_intr()
873 static irqreturn_t at803x_handle_interrupt(struct phy_device *phydev) in at803x_handle_interrupt() argument
877 irq_status = phy_read(phydev, AT803X_INTR_STATUS); in at803x_handle_interrupt()
879 phy_error(phydev); in at803x_handle_interrupt()
884 int_enabled = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_handle_interrupt()
886 phy_error(phydev); in at803x_handle_interrupt()
894 phy_trigger_machine(phydev); in at803x_handle_interrupt()
899 static void at803x_link_change_notify(struct phy_device *phydev) in at803x_link_change_notify() argument
908 if (phydev->state == PHY_NOLINK && phydev->mdio.reset_gpio) { in at803x_link_change_notify()
911 at803x_context_save(phydev, &context); in at803x_link_change_notify()
913 phy_device_reset(phydev, 1); in at803x_link_change_notify()
915 phy_device_reset(phydev, 0); in at803x_link_change_notify()
918 at803x_context_restore(phydev, &context); in at803x_link_change_notify()
920 phydev_dbg(phydev, "%s(): phy was reset\n", __func__); in at803x_link_change_notify()
924 static int at803x_read_status(struct phy_device *phydev) in at803x_read_status() argument
926 int ss, err, old_link = phydev->link; in at803x_read_status()
929 err = genphy_update_link(phydev); in at803x_read_status()
934 if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) in at803x_read_status()
937 phydev->speed = SPEED_UNKNOWN; in at803x_read_status()
938 phydev->duplex = DUPLEX_UNKNOWN; in at803x_read_status()
939 phydev->pause = 0; in at803x_read_status()
940 phydev->asym_pause = 0; in at803x_read_status()
942 err = genphy_read_lpa(phydev); in at803x_read_status()
950 ss = phy_read(phydev, AT803X_SPECIFIC_STATUS); in at803x_read_status()
957 sfc = phy_read(phydev, AT803X_SPECIFIC_FUNCTION_CONTROL); in at803x_read_status()
963 phydev->speed = SPEED_10; in at803x_read_status()
966 phydev->speed = SPEED_100; in at803x_read_status()
969 phydev->speed = SPEED_1000; in at803x_read_status()
973 phydev->duplex = DUPLEX_FULL; in at803x_read_status()
975 phydev->duplex = DUPLEX_HALF; in at803x_read_status()
978 phydev->mdix = ETH_TP_MDI_X; in at803x_read_status()
980 phydev->mdix = ETH_TP_MDI; in at803x_read_status()
984 phydev->mdix_ctrl = ETH_TP_MDI; in at803x_read_status()
987 phydev->mdix_ctrl = ETH_TP_MDI_X; in at803x_read_status()
990 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in at803x_read_status()
995 if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) in at803x_read_status()
996 phy_resolve_aneg_pause(phydev); in at803x_read_status()
1001 static int at803x_config_mdix(struct phy_device *phydev, u8 ctrl) in at803x_config_mdix() argument
1019 return phy_modify_changed(phydev, AT803X_SPECIFIC_FUNCTION_CONTROL, in at803x_config_mdix()
1024 static int at803x_config_aneg(struct phy_device *phydev) in at803x_config_aneg() argument
1028 ret = at803x_config_mdix(phydev, phydev->mdix_ctrl); in at803x_config_aneg()
1037 ret = genphy_soft_reset(phydev); in at803x_config_aneg()
1042 return genphy_config_aneg(phydev); in at803x_config_aneg()
1045 static int at803x_get_downshift(struct phy_device *phydev, u8 *d) in at803x_get_downshift() argument
1049 val = phy_read(phydev, AT803X_SMART_SPEED); in at803x_get_downshift()
1061 static int at803x_set_downshift(struct phy_device *phydev, u8 cnt) in at803x_set_downshift() argument
1085 ret = phy_modify_changed(phydev, AT803X_SMART_SPEED, mask, set); in at803x_set_downshift()
1092 ret = phy_init_hw(phydev); in at803x_set_downshift()
1097 static int at803x_get_tunable(struct phy_device *phydev, in at803x_get_tunable() argument
1102 return at803x_get_downshift(phydev, data); in at803x_get_tunable()
1108 static int at803x_set_tunable(struct phy_device *phydev, in at803x_set_tunable() argument
1113 return at803x_set_downshift(phydev, *(const u8 *)data); in at803x_set_tunable()
1174 static int at803x_cdt_start(struct phy_device *phydev, int pair) in at803x_cdt_start() argument
1181 return phy_write(phydev, AT803X_CDT, cdt); in at803x_cdt_start()
1184 static int at803x_cdt_wait_for_completion(struct phy_device *phydev) in at803x_cdt_wait_for_completion() argument
1189 ret = phy_read_poll_timeout(phydev, AT803X_CDT, val, in at803x_cdt_wait_for_completion()
1196 static int at803x_cable_test_one_pair(struct phy_device *phydev, int pair) in at803x_cable_test_one_pair() argument
1206 ret = at803x_cdt_start(phydev, pair); in at803x_cable_test_one_pair()
1210 ret = at803x_cdt_wait_for_completion(phydev); in at803x_cable_test_one_pair()
1214 val = phy_read(phydev, AT803X_CDT_STATUS); in at803x_cable_test_one_pair()
1221 ethnl_cable_test_result(phydev, ethtool_pair[pair], in at803x_cable_test_one_pair()
1225 ethnl_cable_test_fault_length(phydev, ethtool_pair[pair], in at803x_cable_test_one_pair()
1231 static int at803x_cable_test_get_status(struct phy_device *phydev, in at803x_cable_test_get_status() argument
1238 if (phydev->phy_id == ATH9331_PHY_ID || in at803x_cable_test_get_status()
1239 phydev->phy_id == ATH8032_PHY_ID) in at803x_cable_test_get_status()
1255 ret = at803x_cable_test_one_pair(phydev, pair); in at803x_cable_test_get_status()
1270 static int at803x_cable_test_start(struct phy_device *phydev) in at803x_cable_test_start() argument
1276 phy_write(phydev, MII_BMCR, BMCR_ANENABLE); in at803x_cable_test_start()
1277 phy_write(phydev, MII_ADVERTISE, ADVERTISE_CSMA); in at803x_cable_test_start()
1278 if (phydev->phy_id != ATH9331_PHY_ID && in at803x_cable_test_start()
1279 phydev->phy_id != ATH8032_PHY_ID) in at803x_cable_test_start()
1280 phy_write(phydev, MII_CTRL1000, 0); in at803x_cable_test_start()
1286 static int qca83xx_config_init(struct phy_device *phydev) in qca83xx_config_init() argument
1290 switch_revision = phydev->dev_flags & QCA8K_DEVFLAGS_REVISION_MASK; in qca83xx_config_init()
1295 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_0, 0x02ea); in qca83xx_config_init()
1297 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_3D, 0x68a0); in qca83xx_config_init()
1301 phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, 0x0); in qca83xx_config_init()
1304 phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_AZ_DEBUG, 0x803f); in qca83xx_config_init()
1305 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_3D, 0x6860); in qca83xx_config_init()
1306 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_5, 0x2c46); in qca83xx_config_init()
1307 at803x_debug_reg_write(phydev, AT803X_DEBUG_REG_3C, 0x6000); in qca83xx_config_init()