Lines Matching refs:phydev
150 static int aqr107_get_sset_count(struct phy_device *phydev) in aqr107_get_sset_count() argument
155 static void aqr107_get_strings(struct phy_device *phydev, u8 *data) in aqr107_get_strings() argument
164 static u64 aqr107_get_stat(struct phy_device *phydev, int index) in aqr107_get_stat() argument
172 val = phy_read_mmd(phydev, MDIO_MMD_C22EXT, stat->reg); in aqr107_get_stat()
178 val = phy_read_mmd(phydev, MDIO_MMD_C22EXT, stat->reg + 1); in aqr107_get_stat()
188 static void aqr107_get_stats(struct phy_device *phydev, in aqr107_get_stats() argument
191 struct aqr107_priv *priv = phydev->priv; in aqr107_get_stats()
196 val = aqr107_get_stat(phydev, i); in aqr107_get_stats()
198 phydev_err(phydev, "Reading HW Statistics failed for %s\n", in aqr107_get_stats()
207 static int aqr_config_aneg(struct phy_device *phydev) in aqr_config_aneg() argument
213 if (phydev->autoneg == AUTONEG_DISABLE) in aqr_config_aneg()
214 return genphy_c45_pma_setup_forced(phydev); in aqr_config_aneg()
216 ret = genphy_c45_an_config_aneg(phydev); in aqr_config_aneg()
227 phydev->advertising)) in aqr_config_aneg()
231 phydev->advertising)) in aqr_config_aneg()
234 ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_VEND_PROV, in aqr_config_aneg()
242 return genphy_c45_check_and_restart_aneg(phydev, changed); in aqr_config_aneg()
245 static int aqr_config_intr(struct phy_device *phydev) in aqr_config_intr() argument
247 bool en = phydev->interrupts == PHY_INTERRUPT_ENABLED; in aqr_config_intr()
252 err = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_TX_VEND_INT_STATUS2); in aqr_config_intr()
257 err = phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_TX_VEND_INT_MASK2, in aqr_config_intr()
262 err = phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_GLOBAL_INT_STD_MASK, in aqr_config_intr()
267 err = phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_GLOBAL_INT_VEND_MASK, in aqr_config_intr()
275 err = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_TX_VEND_INT_STATUS2); in aqr_config_intr()
283 static irqreturn_t aqr_handle_interrupt(struct phy_device *phydev) in aqr_handle_interrupt() argument
287 irq_status = phy_read_mmd(phydev, MDIO_MMD_AN, in aqr_handle_interrupt()
290 phy_error(phydev); in aqr_handle_interrupt()
297 phy_trigger_machine(phydev); in aqr_handle_interrupt()
302 static int aqr_read_status(struct phy_device *phydev) in aqr_read_status() argument
306 if (phydev->autoneg == AUTONEG_ENABLE) { in aqr_read_status()
307 val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_RX_LP_STAT1); in aqr_read_status()
312 phydev->lp_advertising, in aqr_read_status()
315 phydev->lp_advertising, in aqr_read_status()
319 return genphy_c45_read_status(phydev); in aqr_read_status()
322 static int aqr107_read_rate(struct phy_device *phydev) in aqr107_read_rate() argument
326 val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_TX_VEND_STATUS1); in aqr107_read_rate()
332 phydev->speed = SPEED_10; in aqr107_read_rate()
335 phydev->speed = SPEED_100; in aqr107_read_rate()
338 phydev->speed = SPEED_1000; in aqr107_read_rate()
341 phydev->speed = SPEED_2500; in aqr107_read_rate()
344 phydev->speed = SPEED_5000; in aqr107_read_rate()
347 phydev->speed = SPEED_10000; in aqr107_read_rate()
350 phydev->speed = SPEED_UNKNOWN; in aqr107_read_rate()
355 phydev->duplex = DUPLEX_FULL; in aqr107_read_rate()
357 phydev->duplex = DUPLEX_HALF; in aqr107_read_rate()
362 static int aqr107_read_status(struct phy_device *phydev) in aqr107_read_status() argument
366 ret = aqr_read_status(phydev); in aqr107_read_status()
370 if (!phydev->link || phydev->autoneg == AUTONEG_DISABLE) in aqr107_read_status()
373 val = phy_read_mmd(phydev, MDIO_MMD_PHYXS, MDIO_PHYXS_VEND_IF_STATUS); in aqr107_read_status()
379 phydev->interface = PHY_INTERFACE_MODE_10GKR; in aqr107_read_status()
382 phydev->interface = PHY_INTERFACE_MODE_10GBASER; in aqr107_read_status()
385 phydev->interface = PHY_INTERFACE_MODE_USXGMII; in aqr107_read_status()
388 phydev->interface = PHY_INTERFACE_MODE_SGMII; in aqr107_read_status()
391 phydev->interface = PHY_INTERFACE_MODE_2500BASEX; in aqr107_read_status()
394 phydev->interface = PHY_INTERFACE_MODE_NA; in aqr107_read_status()
399 return aqr107_read_rate(phydev); in aqr107_read_status()
402 static int aqr107_get_downshift(struct phy_device *phydev, u8 *data) in aqr107_get_downshift() argument
406 val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_VEND_PROV); in aqr107_get_downshift()
418 static int aqr107_set_downshift(struct phy_device *phydev, u8 cnt) in aqr107_set_downshift() argument
430 return phy_modify_mmd(phydev, MDIO_MMD_AN, MDIO_AN_VEND_PROV, in aqr107_set_downshift()
435 static int aqr107_get_tunable(struct phy_device *phydev, in aqr107_get_tunable() argument
440 return aqr107_get_downshift(phydev, data); in aqr107_get_tunable()
446 static int aqr107_set_tunable(struct phy_device *phydev, in aqr107_set_tunable() argument
451 return aqr107_set_downshift(phydev, *(const u8 *)data); in aqr107_set_tunable()
464 static int aqr107_wait_reset_complete(struct phy_device *phydev) in aqr107_wait_reset_complete() argument
468 return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, in aqr107_wait_reset_complete()
473 static void aqr107_chip_info(struct phy_device *phydev) in aqr107_chip_info() argument
478 val = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_GLOBAL_FW_ID); in aqr107_chip_info()
485 val = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_GLOBAL_RSVD_STAT1); in aqr107_chip_info()
492 phydev_dbg(phydev, "FW %u.%u, Build %u, Provisioning %u\n", in aqr107_chip_info()
496 static int aqr107_config_init(struct phy_device *phydev) in aqr107_config_init() argument
501 if (phydev->interface != PHY_INTERFACE_MODE_SGMII && in aqr107_config_init()
502 phydev->interface != PHY_INTERFACE_MODE_2500BASEX && in aqr107_config_init()
503 phydev->interface != PHY_INTERFACE_MODE_XGMII && in aqr107_config_init()
504 phydev->interface != PHY_INTERFACE_MODE_USXGMII && in aqr107_config_init()
505 phydev->interface != PHY_INTERFACE_MODE_10GKR && in aqr107_config_init()
506 phydev->interface != PHY_INTERFACE_MODE_10GBASER) in aqr107_config_init()
509 WARN(phydev->interface == PHY_INTERFACE_MODE_XGMII, in aqr107_config_init()
512 ret = aqr107_wait_reset_complete(phydev); in aqr107_config_init()
514 aqr107_chip_info(phydev); in aqr107_config_init()
516 return aqr107_set_downshift(phydev, MDIO_AN_VEND_PROV_DOWNSHIFT_DFLT); in aqr107_config_init()
519 static int aqcs109_config_init(struct phy_device *phydev) in aqcs109_config_init() argument
524 if (phydev->interface != PHY_INTERFACE_MODE_SGMII && in aqcs109_config_init()
525 phydev->interface != PHY_INTERFACE_MODE_2500BASEX) in aqcs109_config_init()
528 ret = aqr107_wait_reset_complete(phydev); in aqcs109_config_init()
530 aqr107_chip_info(phydev); in aqcs109_config_init()
536 ret = phy_set_max_speed(phydev, SPEED_2500); in aqcs109_config_init()
540 return aqr107_set_downshift(phydev, MDIO_AN_VEND_PROV_DOWNSHIFT_DFLT); in aqcs109_config_init()
543 static void aqr107_link_change_notify(struct phy_device *phydev) in aqr107_link_change_notify() argument
549 if (phydev->state != PHY_RUNNING || phydev->autoneg == AUTONEG_DISABLE) in aqr107_link_change_notify()
552 val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_RX_LP_STAT1); in aqr107_link_change_notify()
560 val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_RX_LP_STAT4); in aqr107_link_change_notify()
567 val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_RX_VEND_STAT3); in aqr107_link_change_notify()
573 phydev_dbg(phydev, "Link partner is Aquantia PHY, FW %u.%u%s%s%s\n", in aqr107_link_change_notify()
579 val = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_GLOBAL_RSVD_STAT9); in aqr107_link_change_notify()
585 phydev_info(phydev, "Aquantia 1000Base-T2 mode active\n"); in aqr107_link_change_notify()
588 static int aqr107_suspend(struct phy_device *phydev) in aqr107_suspend() argument
590 return phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MDIO_CTRL1, in aqr107_suspend()
594 static int aqr107_resume(struct phy_device *phydev) in aqr107_resume() argument
596 return phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MDIO_CTRL1, in aqr107_resume()
600 static int aqr107_probe(struct phy_device *phydev) in aqr107_probe() argument
602 phydev->priv = devm_kzalloc(&phydev->mdio.dev, in aqr107_probe()
604 if (!phydev->priv) in aqr107_probe()
607 return aqr_hwmon_probe(phydev); in aqr107_probe()