Lines Matching full:phydev

177 static int mv88q2xxx_soft_reset(struct phy_device *phydev)  in mv88q2xxx_soft_reset()  argument
182 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, in mv88q2xxx_soft_reset()
187 return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_PCS, in mv88q2xxx_soft_reset()
193 static int mv88q2xxx_read_link_gbit(struct phy_device *phydev) in mv88q2xxx_read_link_gbit() argument
203 ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_MMD_AN_MV_STAT); in mv88q2xxx_read_link_gbit()
208 !phy_polling_mode(phydev)) { in mv88q2xxx_read_link_gbit()
214 if (!phy_polling_mode(phydev) || !phydev->link) { in mv88q2xxx_read_link_gbit()
215 ret = phy_read_mmd(phydev, MDIO_MMD_PCS, in mv88q2xxx_read_link_gbit()
224 ret = phy_read_mmd(phydev, MDIO_MMD_PCS, in mv88q2xxx_read_link_gbit()
233 phydev->link = link; in mv88q2xxx_read_link_gbit()
238 static int mv88q2xxx_read_link_100m(struct phy_device *phydev) in mv88q2xxx_read_link_100m() argument
248 if (!phy_polling_mode(phydev)) { in mv88q2xxx_read_link_100m()
249 phydev->link = false; in mv88q2xxx_read_link_100m()
250 ret = phy_read_mmd(phydev, MDIO_MMD_PCS, in mv88q2xxx_read_link_100m()
256 phydev->link = true; in mv88q2xxx_read_link_100m()
259 } else if (!phydev->link) { in mv88q2xxx_read_link_100m()
260 ret = phy_read_mmd(phydev, MDIO_MMD_PCS, in mv88q2xxx_read_link_100m()
268 ret = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_MMD_PCS_MV_100BT1_STAT1); in mv88q2xxx_read_link_100m()
277 phydev->link = true; in mv88q2xxx_read_link_100m()
279 phydev->link = false; in mv88q2xxx_read_link_100m()
284 static int mv88q2xxx_read_link(struct phy_device *phydev) in mv88q2xxx_read_link() argument
291 if (phydev->speed == SPEED_1000) in mv88q2xxx_read_link()
292 return mv88q2xxx_read_link_gbit(phydev); in mv88q2xxx_read_link()
293 else if (phydev->speed == SPEED_100) in mv88q2xxx_read_link()
294 return mv88q2xxx_read_link_100m(phydev); in mv88q2xxx_read_link()
296 phydev->link = false; in mv88q2xxx_read_link()
300 static int mv88q2xxx_read_master_slave_state(struct phy_device *phydev) in mv88q2xxx_read_master_slave_state() argument
304 phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; in mv88q2xxx_read_master_slave_state()
305 ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_MMD_AN_MV_STAT); in mv88q2xxx_read_master_slave_state()
310 phydev->master_slave_state = MASTER_SLAVE_STATE_MASTER; in mv88q2xxx_read_master_slave_state()
312 phydev->master_slave_state = MASTER_SLAVE_STATE_SLAVE; in mv88q2xxx_read_master_slave_state()
317 static int mv88q2xxx_read_aneg_speed(struct phy_device *phydev) in mv88q2xxx_read_aneg_speed() argument
321 phydev->speed = SPEED_UNKNOWN; in mv88q2xxx_read_aneg_speed()
322 ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_MMD_AN_MV_STAT2); in mv88q2xxx_read_aneg_speed()
330 phydev->speed = SPEED_100; in mv88q2xxx_read_aneg_speed()
332 phydev->speed = SPEED_1000; in mv88q2xxx_read_aneg_speed()
337 static int mv88q2xxx_read_status(struct phy_device *phydev) in mv88q2xxx_read_status() argument
341 if (phydev->autoneg == AUTONEG_ENABLE) { in mv88q2xxx_read_status()
345 ret = mv88q2xxx_read_aneg_speed(phydev); in mv88q2xxx_read_status()
349 ret = mv88q2xxx_read_link(phydev); in mv88q2xxx_read_status()
353 ret = genphy_c45_read_lpa(phydev); in mv88q2xxx_read_status()
357 ret = genphy_c45_baset1_read_status(phydev); in mv88q2xxx_read_status()
361 ret = mv88q2xxx_read_master_slave_state(phydev); in mv88q2xxx_read_status()
365 phy_resolve_aneg_linkmode(phydev); in mv88q2xxx_read_status()
370 ret = mv88q2xxx_read_link(phydev); in mv88q2xxx_read_status()
374 return genphy_c45_read_pma(phydev); in mv88q2xxx_read_status()
377 static int mv88q2xxx_get_features(struct phy_device *phydev) in mv88q2xxx_get_features() argument
381 ret = genphy_c45_pma_read_abilities(phydev); in mv88q2xxx_get_features()
389 ret = genphy_c45_pma_baset1_read_abilities(phydev); in mv88q2xxx_get_features()
398 if (phydev->drv->phy_id == MARVELL_PHY_ID_88Q2110) in mv88q2xxx_get_features()
400 phydev->supported); in mv88q2xxx_get_features()
405 static int mv88q2xxx_config_aneg(struct phy_device *phydev) in mv88q2xxx_config_aneg() argument
409 ret = genphy_c45_config_aneg(phydev); in mv88q2xxx_config_aneg()
413 return phydev->drv->soft_reset(phydev); in mv88q2xxx_config_aneg()
416 static int mv88q2xxx_config_init(struct phy_device *phydev) in mv88q2xxx_config_init() argument
422 phydev->pma_extable = MDIO_PMA_EXTABLE_BT1; in mv88q2xxx_config_init()
427 if (phy_interrupt_is_valid(phydev)) in mv88q2xxx_config_init()
428 return phy_set_bits_mmd(phydev, MDIO_MMD_PCS, in mv88q2xxx_config_init()
435 static int mv88q2xxx_get_sqi(struct phy_device *phydev) in mv88q2xxx_get_sqi() argument
439 if (phydev->speed == SPEED_100) { in mv88q2xxx_get_sqi()
443 ret = phy_read_mmd(phydev, MDIO_MMD_PCS, in mv88q2xxx_get_sqi()
454 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, 0xfc5d, 0xff, 0xac); in mv88q2xxx_get_sqi()
458 ret = phy_read_mmd(phydev, MDIO_MMD_PCS, 0xfc88); in mv88q2xxx_get_sqi()
466 static int mv88q2xxx_get_sqi_max(struct phy_device *phydev) in mv88q2xxx_get_sqi_max() argument
471 static int mv88q2xxx_config_intr(struct phy_device *phydev) in mv88q2xxx_config_intr() argument
475 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in mv88q2xxx_config_intr()
479 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, in mv88q2xxx_config_intr()
488 return phy_write_mmd(phydev, MDIO_MMD_PCS, in mv88q2xxx_config_intr()
492 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, in mv88q2xxx_config_intr()
497 return phy_write_mmd(phydev, MDIO_MMD_PCS, in mv88q2xxx_config_intr()
502 static irqreturn_t mv88q2xxx_handle_interrupt(struct phy_device *phydev) in mv88q2xxx_handle_interrupt() argument
514 irq = phy_read_mmd(phydev, MDIO_MMD_PCS, in mv88q2xxx_handle_interrupt()
517 phy_error(phydev); in mv88q2xxx_handle_interrupt()
525 irq = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_MMD_PCS_MV_GPIO_INT_STAT); in mv88q2xxx_handle_interrupt()
527 phy_error(phydev); in mv88q2xxx_handle_interrupt()
539 phy_trigger_machine(phydev); in mv88q2xxx_handle_interrupt()
544 static int mv88q2xxx_suspend(struct phy_device *phydev) in mv88q2xxx_suspend() argument
549 if (phy_interrupt_is_valid(phydev)) { in mv88q2xxx_suspend()
550 phydev->interrupts = PHY_INTERRUPT_DISABLED; in mv88q2xxx_suspend()
551 ret = mv88q2xxx_config_intr(phydev); in mv88q2xxx_suspend()
556 return phy_set_bits_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1, in mv88q2xxx_suspend()
560 static int mv88q2xxx_resume(struct phy_device *phydev) in mv88q2xxx_resume() argument
565 if (phy_interrupt_is_valid(phydev)) { in mv88q2xxx_resume()
566 phydev->interrupts = PHY_INTERRUPT_ENABLED; in mv88q2xxx_resume()
567 ret = mv88q2xxx_config_intr(phydev); in mv88q2xxx_resume()
572 return phy_clear_bits_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1, in mv88q2xxx_resume()
602 struct phy_device *phydev = dev_get_drvdata(dev); in mv88q2xxx_hwmon_read() local
607 ret = phy_read_mmd(phydev, MDIO_MMD_PCS, in mv88q2xxx_hwmon_read()
616 ret = phy_read_mmd(phydev, MDIO_MMD_PCS, in mv88q2xxx_hwmon_read()
626 ret = phy_read_mmd(phydev, MDIO_MMD_PCS, in mv88q2xxx_hwmon_read()
642 struct phy_device *phydev = dev_get_drvdata(dev); in mv88q2xxx_hwmon_write() local
650 return phy_modify_mmd(phydev, MDIO_MMD_PCS, in mv88q2xxx_hwmon_write()
670 static int mv88q2xxx_hwmon_probe(struct phy_device *phydev) in mv88q2xxx_hwmon_probe() argument
672 struct device *dev = &phydev->mdio.dev; in mv88q2xxx_hwmon_probe()
678 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, MDIO_MMD_PCS_MV_TEMP_SENSOR2, in mv88q2xxx_hwmon_probe()
689 phydev, in mv88q2xxx_hwmon_probe()
697 static int mv88q2xxx_hwmon_probe(struct phy_device *phydev) in mv88q2xxx_hwmon_probe() argument
703 static int mv88q2xxx_probe(struct phy_device *phydev) in mv88q2xxx_probe() argument
705 return mv88q2xxx_hwmon_probe(phydev); in mv88q2xxx_probe()
708 static int mv88q222x_soft_reset(struct phy_device *phydev) in mv88q222x_soft_reset() argument
713 if (phydev->autoneg == AUTONEG_ENABLE || phydev->speed == SPEED_1000) { in mv88q222x_soft_reset()
714 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfe1b, 0x48); in mv88q222x_soft_reset()
719 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_1000BT1_CTRL, in mv88q222x_soft_reset()
724 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0xffe4, 0xc); in mv88q222x_soft_reset()
729 if (phydev->autoneg == AUTONEG_ENABLE || phydev->speed == SPEED_1000) in mv88q222x_soft_reset()
730 return phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfe1b, 0x58); in mv88q222x_soft_reset()
735 static int mv88q222x_write_mmd_vals(struct phy_device *phydev, in mv88q222x_write_mmd_vals() argument
741 ret = phy_write_mmd(phydev, vals->devad, vals->regnum, in mv88q222x_write_mmd_vals()
750 static int mv88q222x_revb0_config_init(struct phy_device *phydev) in mv88q222x_revb0_config_init() argument
754 ret = mv88q222x_write_mmd_vals(phydev, mv88q222x_revb0_init_seq0, in mv88q222x_revb0_config_init()
761 ret = mv88q222x_write_mmd_vals(phydev, mv88q222x_revb0_init_seq1, in mv88q222x_revb0_config_init()
766 return mv88q2xxx_config_init(phydev); in mv88q222x_revb0_config_init()
769 static int mv88q222x_revb1_revb2_config_init(struct phy_device *phydev) in mv88q222x_revb1_revb2_config_init() argument
771 bool is_rev_b1 = phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD] == PHY_ID_88Q2220_REVB1; in mv88q222x_revb1_revb2_config_init()
775 ret = mv88q222x_write_mmd_vals(phydev, mv88q222x_revb1_init_seq0, in mv88q222x_revb1_revb2_config_init()
778 ret = mv88q222x_write_mmd_vals(phydev, mv88q222x_revb2_init_seq0, in mv88q222x_revb1_revb2_config_init()
785 ret = mv88q222x_write_mmd_vals(phydev, mv88q222x_revb1_revb2_init_seq1, in mv88q222x_revb1_revb2_config_init()
790 return mv88q2xxx_config_init(phydev); in mv88q222x_revb1_revb2_config_init()
793 static int mv88q222x_config_init(struct phy_device *phydev) in mv88q222x_config_init() argument
795 if (phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD] == PHY_ID_88Q2220_REVB0) in mv88q222x_config_init()
796 return mv88q222x_revb0_config_init(phydev); in mv88q222x_config_init()
798 return mv88q222x_revb1_revb2_config_init(phydev); in mv88q222x_config_init()
801 static int mv88q222x_cable_test_start(struct phy_device *phydev) in mv88q222x_cable_test_start() argument
805 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, in mv88q222x_cable_test_start()
810 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, in mv88q222x_cable_test_start()
815 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, in mv88q222x_cable_test_start()
820 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_MMD_PCS_MV_TDR_RESET, in mv88q222x_cable_test_start()
825 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_MMD_PCS_MV_TDR_STATUS, in mv88q222x_cable_test_start()
836 static int mv88q222x_cable_test_get_status(struct phy_device *phydev, in mv88q222x_cable_test_get_status() argument
842 status = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_MMD_PCS_MV_TDR_STATUS); in mv88q222x_cable_test_get_status()
846 ret = phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_MMD_PCS_MV_TDR_RESET, in mv88q222x_cable_test_get_status()
861 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, in mv88q222x_cable_test_get_status()
863 ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_A, in mv88q222x_cable_test_get_status()
867 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, in mv88q222x_cable_test_get_status()
869 ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_A, in mv88q222x_cable_test_get_status()
873 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, in mv88q222x_cable_test_get_status()
877 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, in mv88q222x_cable_test_get_status()