Lines Matching refs:phydev
136 static int at803x_write_page(struct phy_device *phydev, int page) in at803x_write_page() argument
149 return __phy_modify(phydev, AT803X_REG_CHIP_CONFIG, mask, set); in at803x_write_page()
152 static int at803x_read_page(struct phy_device *phydev) in at803x_read_page() argument
154 int ccr = __phy_read(phydev, AT803X_REG_CHIP_CONFIG); in at803x_read_page()
165 static int at803x_enable_rx_delay(struct phy_device *phydev) in at803x_enable_rx_delay() argument
167 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, 0, in at803x_enable_rx_delay()
171 static int at803x_enable_tx_delay(struct phy_device *phydev) in at803x_enable_tx_delay() argument
173 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_SYSTEM_CTRL_MODE, 0, in at803x_enable_tx_delay()
177 static int at803x_disable_rx_delay(struct phy_device *phydev) in at803x_disable_rx_delay() argument
179 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, in at803x_disable_rx_delay()
183 static int at803x_disable_tx_delay(struct phy_device *phydev) in at803x_disable_tx_delay() argument
185 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_SYSTEM_CTRL_MODE, in at803x_disable_tx_delay()
190 static void at803x_context_save(struct phy_device *phydev, in at803x_context_save() argument
193 context->bmcr = phy_read(phydev, MII_BMCR); in at803x_context_save()
194 context->advertise = phy_read(phydev, MII_ADVERTISE); in at803x_context_save()
195 context->control1000 = phy_read(phydev, MII_CTRL1000); in at803x_context_save()
196 context->int_enable = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_context_save()
197 context->smart_speed = phy_read(phydev, AT803X_SMART_SPEED); in at803x_context_save()
198 context->led_control = phy_read(phydev, AT803X_LED_CONTROL); in at803x_context_save()
202 static void at803x_context_restore(struct phy_device *phydev, in at803x_context_restore() argument
205 phy_write(phydev, MII_BMCR, context->bmcr); in at803x_context_restore()
206 phy_write(phydev, MII_ADVERTISE, context->advertise); in at803x_context_restore()
207 phy_write(phydev, MII_CTRL1000, context->control1000); in at803x_context_restore()
208 phy_write(phydev, AT803X_INTR_ENABLE, context->int_enable); in at803x_context_restore()
209 phy_write(phydev, AT803X_SMART_SPEED, context->smart_speed); in at803x_context_restore()
210 phy_write(phydev, AT803X_LED_CONTROL, context->led_control); in at803x_context_restore()
213 static int at803x_suspend(struct phy_device *phydev) in at803x_suspend() argument
218 value = phy_read(phydev, AT803X_INTR_ENABLE); in at803x_suspend()
226 phy_modify(phydev, MII_BMCR, 0, value); in at803x_suspend()
231 static int at803x_resume(struct phy_device *phydev) in at803x_resume() argument
233 return phy_modify(phydev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 0); in at803x_resume()
236 static int at803x_parse_dt(struct phy_device *phydev) in at803x_parse_dt() argument
238 struct device_node *node = phydev->mdio.dev.of_node; in at803x_parse_dt()
239 struct at803x_priv *priv = phydev->priv; in at803x_parse_dt()
255 phydev_err(phydev, "invalid qca,smarteee-tw-us-1g\n"); in at803x_parse_dt()
263 phydev_err(phydev, "invalid qca,smarteee-tw-us-100m\n"); in at803x_parse_dt()
285 phydev_err(phydev, "invalid qca,clk-out-frequency\n"); in at803x_parse_dt()
307 phydev_err(phydev, "invalid qca,clk-out-strength\n"); in at803x_parse_dt()
315 static int at803x_probe(struct phy_device *phydev) in at803x_probe() argument
317 struct device *dev = &phydev->mdio.dev; in at803x_probe()
325 phydev->priv = priv; in at803x_probe()
327 ret = at803x_parse_dt(phydev); in at803x_probe()
334 static int at803x_get_features(struct phy_device *phydev) in at803x_get_features() argument
336 struct at803x_priv *priv = phydev->priv; in at803x_get_features()
339 err = genphy_read_abilities(phydev); in at803x_get_features()
343 if (phydev->drv->phy_id != ATH8031_PHY_ID) in at803x_get_features()
359 phydev->supported); in at803x_get_features()
364 static int at803x_smarteee_config(struct phy_device *phydev) in at803x_smarteee_config() argument
366 struct at803x_priv *priv = phydev->priv; in at803x_smarteee_config()
371 return phy_modify_mmd(phydev, MDIO_MMD_PCS, in at803x_smarteee_config()
386 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL1, in at803x_smarteee_config()
391 return phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL3, in at803x_smarteee_config()
396 static int at803x_clk_out_config(struct phy_device *phydev) in at803x_clk_out_config() argument
398 struct at803x_priv *priv = phydev->priv; in at803x_clk_out_config()
403 return phy_modify_mmd(phydev, MDIO_MMD_AN, AT803X_MMD7_CLK25M, in at803x_clk_out_config()
407 static int at8031_pll_config(struct phy_device *phydev) in at8031_pll_config() argument
409 struct at803x_priv *priv = phydev->priv; in at8031_pll_config()
415 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at8031_pll_config()
418 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at8031_pll_config()
422 static int at803x_hibernation_mode_config(struct phy_device *phydev) in at803x_hibernation_mode_config() argument
424 struct at803x_priv *priv = phydev->priv; in at803x_hibernation_mode_config()
430 !(phydev->dev_flags & PHY_F_RXC_ALWAYS_ON)) in at803x_hibernation_mode_config()
433 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL, in at803x_hibernation_mode_config()
437 static int at803x_config_init(struct phy_device *phydev) in at803x_config_init() argument
446 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in at803x_config_init()
447 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in at803x_config_init()
448 ret = at803x_enable_rx_delay(phydev); in at803x_config_init()
450 ret = at803x_disable_rx_delay(phydev); in at803x_config_init()
454 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in at803x_config_init()
455 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in at803x_config_init()
456 ret = at803x_enable_tx_delay(phydev); in at803x_config_init()
458 ret = at803x_disable_tx_delay(phydev); in at803x_config_init()
462 ret = at803x_smarteee_config(phydev); in at803x_config_init()
466 ret = at803x_clk_out_config(phydev); in at803x_config_init()
470 ret = at803x_hibernation_mode_config(phydev); in at803x_config_init()
480 return phy_modify(phydev, MII_ADVERTISE, MDIO_AN_CTRL1_XNP, 0); in at803x_config_init()
483 static void at803x_link_change_notify(struct phy_device *phydev) in at803x_link_change_notify() argument
492 if (phydev->state == PHY_NOLINK && phydev->mdio.reset_gpio) { in at803x_link_change_notify()
495 at803x_context_save(phydev, &context); in at803x_link_change_notify()
497 phy_device_reset(phydev, 1); in at803x_link_change_notify()
499 phy_device_reset(phydev, 0); in at803x_link_change_notify()
502 at803x_context_restore(phydev, &context); in at803x_link_change_notify()
504 phydev_dbg(phydev, "%s(): phy was reset\n", __func__); in at803x_link_change_notify()
508 static int at803x_config_aneg(struct phy_device *phydev) in at803x_config_aneg() argument
510 struct at803x_priv *priv = phydev->priv; in at803x_config_aneg()
513 ret = at803x_prepare_config_aneg(phydev); in at803x_config_aneg()
518 return genphy_c37_config_aneg(phydev); in at803x_config_aneg()
520 return genphy_config_aneg(phydev); in at803x_config_aneg()
554 static int at803x_cable_test_one_pair(struct phy_device *phydev, int pair) in at803x_cable_test_one_pair() argument
566 ret = at803x_cdt_start(phydev, val); in at803x_cable_test_one_pair()
570 ret = at803x_cdt_wait_for_completion(phydev, AT803X_CDT_ENABLE_TEST); in at803x_cable_test_one_pair()
574 val = phy_read(phydev, AT803X_CDT_STATUS); in at803x_cable_test_one_pair()
581 ethnl_cable_test_result(phydev, ethtool_pair[pair], in at803x_cable_test_one_pair()
586 ethnl_cable_test_fault_length(phydev, ethtool_pair[pair], in at803x_cable_test_one_pair()
593 static int at803x_cable_test_get_status(struct phy_device *phydev, in at803x_cable_test_get_status() argument
610 ret = at803x_cable_test_one_pair(phydev, pair); in at803x_cable_test_get_status()
625 static void at803x_cable_test_autoneg(struct phy_device *phydev) in at803x_cable_test_autoneg() argument
631 phy_write(phydev, MII_BMCR, BMCR_ANENABLE); in at803x_cable_test_autoneg()
632 phy_write(phydev, MII_ADVERTISE, ADVERTISE_CSMA); in at803x_cable_test_autoneg()
635 static int at803x_cable_test_start(struct phy_device *phydev) in at803x_cable_test_start() argument
637 at803x_cable_test_autoneg(phydev); in at803x_cable_test_start()
645 struct phy_device *phydev = rdev_get_drvdata(rdev); in at8031_rgmii_reg_set_voltage_sel() local
648 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at8031_rgmii_reg_set_voltage_sel()
651 return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, in at8031_rgmii_reg_set_voltage_sel()
657 struct phy_device *phydev = rdev_get_drvdata(rdev); in at8031_rgmii_reg_get_voltage_sel() local
660 val = at803x_debug_reg_read(phydev, AT803X_DEBUG_REG_1F); in at8031_rgmii_reg_get_voltage_sel()
701 static int at8031_register_regulators(struct phy_device *phydev) in at8031_register_regulators() argument
703 struct at803x_priv *priv = phydev->priv; in at8031_register_regulators()
704 struct device *dev = &phydev->mdio.dev; in at8031_register_regulators()
708 config.driver_data = phydev; in at8031_register_regulators()
712 phydev_err(phydev, "failed to register VDDIO regulator\n"); in at8031_register_regulators()
718 phydev_err(phydev, "failed to register VDDH regulator\n"); in at8031_register_regulators()
727 struct phy_device *phydev = upstream; in at8031_sfp_insert() local
741 sfp_parse_support(phydev->sfp_bus, id, sfp_support, interfaces); in at8031_sfp_insert()
748 dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n"); in at8031_sfp_insert()
752 iface = sfp_select_interface(phydev->sfp_bus, sfp_support); in at8031_sfp_insert()
762 dev_warn(&phydev->mdio.dev, "module may not function if 1000Base-X not supported\n"); in at8031_sfp_insert()
777 static int at8031_parse_dt(struct phy_device *phydev) in at8031_parse_dt() argument
779 struct device_node *node = phydev->mdio.dev.of_node; in at8031_parse_dt()
780 struct at803x_priv *priv = phydev->priv; in at8031_parse_dt()
786 ret = at8031_register_regulators(phydev); in at8031_parse_dt()
790 ret = devm_regulator_get_enable_optional(&phydev->mdio.dev, in at8031_parse_dt()
793 phydev_err(phydev, "failed to get VDDIO regulator\n"); in at8031_parse_dt()
798 return phy_sfp_probe(phydev, &at8031_sfp_ops); in at8031_parse_dt()
801 static int at8031_probe(struct phy_device *phydev) in at8031_probe() argument
808 ret = at803x_probe(phydev); in at8031_probe()
812 priv = phydev->priv; in at8031_probe()
817 ret = at8031_parse_dt(phydev); in at8031_probe()
821 ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG); in at8031_probe()
840 return phy_modify_mmd(phydev, MDIO_MMD_PCS, in at8031_probe()
845 static int at8031_config_init(struct phy_device *phydev) in at8031_config_init() argument
847 struct at803x_priv *priv = phydev->priv; in at8031_config_init()
854 phy_lock_mdio_bus(phydev); in at8031_config_init()
855 ret = at803x_write_page(phydev, in at8031_config_init()
858 phy_unlock_mdio_bus(phydev); in at8031_config_init()
862 ret = at8031_pll_config(phydev); in at8031_config_init()
866 return at803x_config_init(phydev); in at8031_config_init()
869 static int at8031_set_wol(struct phy_device *phydev, in at8031_set_wol() argument
875 ret = at803x_set_wol(phydev, wol); in at8031_set_wol()
881 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, in at8031_set_wol()
886 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, in at8031_set_wol()
893 static int at8031_config_intr(struct phy_device *phydev) in at8031_config_intr() argument
895 struct at803x_priv *priv = phydev->priv; in at8031_config_intr()
898 if (phydev->interrupts == PHY_INTERRUPT_ENABLED && in at8031_config_intr()
901 err = at803x_ack_interrupt(phydev); in at8031_config_intr()
908 err = phy_set_bits(phydev, AT803X_INTR_ENABLE, value); in at8031_config_intr()
913 return at803x_config_intr(phydev); in at8031_config_intr()
917 static int at8031_read_status(struct phy_device *phydev) in at8031_read_status() argument
919 struct at803x_priv *priv = phydev->priv; in at8031_read_status()
923 return genphy_c37_read_status(phydev, &changed); in at8031_read_status()
925 return at803x_read_status(phydev); in at8031_read_status()
929 static int at8031_cable_test_get_status(struct phy_device *phydev, in at8031_cable_test_get_status() argument
932 return at803x_cable_test_get_status(phydev, finished, 0xf); in at8031_cable_test_get_status()
936 static int at8031_cable_test_start(struct phy_device *phydev) in at8031_cable_test_start() argument
938 at803x_cable_test_autoneg(phydev); in at8031_cable_test_start()
939 phy_write(phydev, MII_CTRL1000, 0); in at8031_cable_test_start()
945 static int at8032_cable_test_get_status(struct phy_device *phydev, in at8032_cable_test_get_status() argument
948 return at803x_cable_test_get_status(phydev, finished, 0x3); in at8032_cable_test_get_status()
951 static int at8035_parse_dt(struct phy_device *phydev) in at8035_parse_dt() argument
953 struct at803x_priv *priv = phydev->priv; in at8035_parse_dt()
979 static int at8035_probe(struct phy_device *phydev) in at8035_probe() argument
983 ret = at803x_probe(phydev); in at8035_probe()
987 return at8035_parse_dt(phydev); in at8035_probe()