• Home
  • Raw
  • Download

Lines Matching full:phydev

285 static int marvell_read_page(struct phy_device *phydev)  in marvell_read_page()  argument
287 return __phy_read(phydev, MII_MARVELL_PHY_PAGE); in marvell_read_page()
290 static int marvell_write_page(struct phy_device *phydev, int page) in marvell_write_page() argument
292 return __phy_write(phydev, MII_MARVELL_PHY_PAGE, page); in marvell_write_page()
295 static int marvell_set_page(struct phy_device *phydev, int page) in marvell_set_page() argument
297 return phy_write(phydev, MII_MARVELL_PHY_PAGE, page); in marvell_set_page()
300 static int marvell_ack_interrupt(struct phy_device *phydev) in marvell_ack_interrupt() argument
305 err = phy_read(phydev, MII_M1011_IEVENT); in marvell_ack_interrupt()
313 static int marvell_config_intr(struct phy_device *phydev) in marvell_config_intr() argument
317 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) in marvell_config_intr()
318 err = phy_write(phydev, MII_M1011_IMASK, in marvell_config_intr()
321 err = phy_write(phydev, MII_M1011_IMASK, in marvell_config_intr()
327 static int marvell_set_polarity(struct phy_device *phydev, int polarity) in marvell_set_polarity() argument
334 reg = phy_read(phydev, MII_M1011_PHY_SCR); in marvell_set_polarity()
356 err = phy_write(phydev, MII_M1011_PHY_SCR, val); in marvell_set_polarity()
364 static int marvell_config_aneg(struct phy_device *phydev) in marvell_config_aneg() argument
369 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in marvell_config_aneg()
375 err = phy_write(phydev, MII_M1111_PHY_LED_CONTROL, in marvell_config_aneg()
380 err = genphy_config_aneg(phydev); in marvell_config_aneg()
384 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in marvell_config_aneg()
389 err = genphy_soft_reset(phydev); in marvell_config_aneg()
397 static int m88e1101_config_aneg(struct phy_device *phydev) in m88e1101_config_aneg() argument
405 err = genphy_soft_reset(phydev); in m88e1101_config_aneg()
409 err = phy_write(phydev, 0x1d, 0x1f); in m88e1101_config_aneg()
413 err = phy_write(phydev, 0x1e, 0x200c); in m88e1101_config_aneg()
417 err = phy_write(phydev, 0x1d, 0x5); in m88e1101_config_aneg()
421 err = phy_write(phydev, 0x1e, 0); in m88e1101_config_aneg()
425 err = phy_write(phydev, 0x1e, 0x100); in m88e1101_config_aneg()
429 return marvell_config_aneg(phydev); in m88e1101_config_aneg()
434 * marvell,reg-init property stored in the of_node for the phydev.
446 static int marvell_of_reg_init(struct phy_device *phydev) in marvell_of_reg_init() argument
451 if (!phydev->mdio.dev.of_node) in marvell_of_reg_init()
454 paddr = of_get_property(phydev->mdio.dev.of_node, in marvell_of_reg_init()
459 saved_page = phy_save_page(phydev); in marvell_of_reg_init()
474 ret = marvell_write_page(phydev, page); in marvell_of_reg_init()
481 val = __phy_read(phydev, reg); in marvell_of_reg_init()
490 ret = __phy_write(phydev, reg, val); in marvell_of_reg_init()
495 return phy_restore_page(phydev, saved_page, ret); in marvell_of_reg_init()
498 static int marvell_of_reg_init(struct phy_device *phydev) in marvell_of_reg_init() argument
504 static int m88e1121_config_aneg_rgmii_delays(struct phy_device *phydev) in m88e1121_config_aneg_rgmii_delays() argument
508 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) in m88e1121_config_aneg_rgmii_delays()
511 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in m88e1121_config_aneg_rgmii_delays()
513 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in m88e1121_config_aneg_rgmii_delays()
518 return phy_modify_paged_changed(phydev, MII_MARVELL_MSCR_PAGE, in m88e1121_config_aneg_rgmii_delays()
523 static int m88e1121_config_aneg(struct phy_device *phydev) in m88e1121_config_aneg() argument
528 if (phy_interface_is_rgmii(phydev)) { in m88e1121_config_aneg()
529 err = m88e1121_config_aneg_rgmii_delays(phydev); in m88e1121_config_aneg()
536 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1121_config_aneg()
542 err = genphy_config_aneg(phydev); in m88e1121_config_aneg()
546 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in m88e1121_config_aneg()
550 err = genphy_soft_reset(phydev); in m88e1121_config_aneg()
558 static int m88e1318_config_aneg(struct phy_device *phydev) in m88e1318_config_aneg() argument
562 err = phy_modify_paged(phydev, MII_MARVELL_MSCR_PAGE, in m88e1318_config_aneg()
568 return m88e1121_config_aneg(phydev); in m88e1318_config_aneg()
599 * @phydev: target phy_device struct
606 static int marvell_config_aneg_fiber(struct phy_device *phydev) in marvell_config_aneg_fiber() argument
612 if (phydev->autoneg != AUTONEG_ENABLE) in marvell_config_aneg_fiber()
613 return genphy_setup_forced(phydev); in marvell_config_aneg_fiber()
616 linkmode_and(phydev->advertising, phydev->advertising, in marvell_config_aneg_fiber()
617 phydev->supported); in marvell_config_aneg_fiber()
619 adv = linkmode_adv_to_fiber_adv_t(phydev->advertising); in marvell_config_aneg_fiber()
622 err = phy_modify_changed(phydev, MII_ADVERTISE, in marvell_config_aneg_fiber()
631 return genphy_check_and_restart_aneg(phydev, changed); in marvell_config_aneg_fiber()
634 static int m88e1510_config_aneg(struct phy_device *phydev) in m88e1510_config_aneg() argument
638 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
643 err = m88e1318_config_aneg(phydev); in m88e1510_config_aneg()
648 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1510_config_aneg()
652 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in m88e1510_config_aneg()
656 err = marvell_config_aneg_fiber(phydev); in m88e1510_config_aneg()
660 return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
663 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
667 static void marvell_config_led(struct phy_device *phydev) in marvell_config_led() argument
672 switch (MARVELL_PHY_FAMILY_ID(phydev->phy_id)) { in marvell_config_led()
684 if (phydev->dev_flags & MARVELL_PHY_LED0_LINK_LED1_ACTIVE) in marvell_config_led()
693 err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE, MII_PHY_LED_CTRL, in marvell_config_led()
696 phydev_warn(phydev, "Fail to config marvell phy LED.\n"); in marvell_config_led()
699 static int marvell_config_init(struct phy_device *phydev) in marvell_config_init() argument
702 marvell_config_led(phydev); in marvell_config_init()
705 return marvell_of_reg_init(phydev); in marvell_config_init()
708 static int m88e3016_config_init(struct phy_device *phydev) in m88e3016_config_init() argument
713 ret = phy_modify(phydev, MII_88E3016_PHY_SPEC_CTRL, in m88e3016_config_init()
719 return marvell_config_init(phydev); in m88e3016_config_init()
722 static int m88e1111_config_init_hwcfg_mode(struct phy_device *phydev, in m88e1111_config_init_hwcfg_mode() argument
729 return phy_modify(phydev, MII_M1111_PHY_EXT_SR, in m88e1111_config_init_hwcfg_mode()
736 static int m88e1111_config_init_rgmii_delays(struct phy_device *phydev) in m88e1111_config_init_rgmii_delays() argument
740 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { in m88e1111_config_init_rgmii_delays()
742 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) { in m88e1111_config_init_rgmii_delays()
744 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) { in m88e1111_config_init_rgmii_delays()
750 return phy_modify(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_config_init_rgmii_delays()
755 static int m88e1111_config_init_rgmii(struct phy_device *phydev) in m88e1111_config_init_rgmii() argument
760 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1111_config_init_rgmii()
764 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR); in m88e1111_config_init_rgmii()
775 return phy_write(phydev, MII_M1111_PHY_EXT_SR, temp); in m88e1111_config_init_rgmii()
778 static int m88e1111_config_init_sgmii(struct phy_device *phydev) in m88e1111_config_init_sgmii() argument
783 phydev, in m88e1111_config_init_sgmii()
790 return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1111_config_init_sgmii()
793 static int m88e1111_config_init_rtbi(struct phy_device *phydev) in m88e1111_config_init_rtbi() argument
797 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1111_config_init_rtbi()
802 phydev, in m88e1111_config_init_rtbi()
809 err = genphy_soft_reset(phydev); in m88e1111_config_init_rtbi()
814 phydev, in m88e1111_config_init_rtbi()
819 static int m88e1111_config_init(struct phy_device *phydev) in m88e1111_config_init() argument
823 if (phy_interface_is_rgmii(phydev)) { in m88e1111_config_init()
824 err = m88e1111_config_init_rgmii(phydev); in m88e1111_config_init()
829 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1111_config_init()
830 err = m88e1111_config_init_sgmii(phydev); in m88e1111_config_init()
835 if (phydev->interface == PHY_INTERFACE_MODE_RTBI) { in m88e1111_config_init()
836 err = m88e1111_config_init_rtbi(phydev); in m88e1111_config_init()
841 err = marvell_of_reg_init(phydev); in m88e1111_config_init()
845 return genphy_soft_reset(phydev); in m88e1111_config_init()
848 static int m88e1111_get_downshift(struct phy_device *phydev, u8 *data) in m88e1111_get_downshift() argument
852 val = phy_read(phydev, MII_M1111_PHY_EXT_CR); in m88e1111_get_downshift()
864 static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt) in m88e1111_set_downshift() argument
872 err = phy_clear_bits(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_set_downshift()
878 err = phy_modify(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_set_downshift()
887 return genphy_soft_reset(phydev); in m88e1111_set_downshift()
890 static int m88e1111_get_tunable(struct phy_device *phydev, in m88e1111_get_tunable() argument
895 return m88e1111_get_downshift(phydev, data); in m88e1111_get_tunable()
901 static int m88e1111_set_tunable(struct phy_device *phydev, in m88e1111_set_tunable() argument
906 return m88e1111_set_downshift(phydev, *(const u8 *)data); in m88e1111_set_tunable()
912 static int m88e1011_get_downshift(struct phy_device *phydev, u8 *data) in m88e1011_get_downshift() argument
916 val = phy_read(phydev, MII_M1011_PHY_SCR); in m88e1011_get_downshift()
928 static int m88e1011_set_downshift(struct phy_device *phydev, u8 cnt) in m88e1011_set_downshift() argument
936 err = phy_clear_bits(phydev, MII_M1011_PHY_SCR, in m88e1011_set_downshift()
942 err = phy_modify(phydev, MII_M1011_PHY_SCR, in m88e1011_set_downshift()
951 return genphy_soft_reset(phydev); in m88e1011_set_downshift()
954 static int m88e1011_get_tunable(struct phy_device *phydev, in m88e1011_get_tunable() argument
959 return m88e1011_get_downshift(phydev, data); in m88e1011_get_tunable()
965 static int m88e1011_set_tunable(struct phy_device *phydev, in m88e1011_set_tunable() argument
970 return m88e1011_set_downshift(phydev, *(const u8 *)data); in m88e1011_set_tunable()
976 static int m88e1116r_config_init(struct phy_device *phydev) in m88e1116r_config_init() argument
980 err = genphy_soft_reset(phydev); in m88e1116r_config_init()
986 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1116r_config_init()
990 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1116r_config_init()
994 err = m88e1011_set_downshift(phydev, 8); in m88e1116r_config_init()
998 if (phy_interface_is_rgmii(phydev)) { in m88e1116r_config_init()
999 err = m88e1121_config_aneg_rgmii_delays(phydev); in m88e1116r_config_init()
1004 err = genphy_soft_reset(phydev); in m88e1116r_config_init()
1008 return marvell_config_init(phydev); in m88e1116r_config_init()
1011 static int m88e1318_config_init(struct phy_device *phydev) in m88e1318_config_init() argument
1013 if (phy_interrupt_is_valid(phydev)) { in m88e1318_config_init()
1015 phydev, MII_MARVELL_LED_PAGE, in m88e1318_config_init()
1024 return marvell_config_init(phydev); in m88e1318_config_init()
1027 static int m88e1510_config_init(struct phy_device *phydev) in m88e1510_config_init() argument
1032 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1510_config_init()
1034 err = marvell_set_page(phydev, 18); in m88e1510_config_init()
1039 err = phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_config_init()
1046 err = phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, 0, in m88e1510_config_init()
1052 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_init()
1057 return m88e1318_config_init(phydev); in m88e1510_config_init()
1060 static int m88e1118_config_aneg(struct phy_device *phydev) in m88e1118_config_aneg() argument
1064 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1118_config_aneg()
1068 err = genphy_config_aneg(phydev); in m88e1118_config_aneg()
1072 return genphy_soft_reset(phydev); in m88e1118_config_aneg()
1075 static int m88e1118_config_init(struct phy_device *phydev) in m88e1118_config_init() argument
1080 err = marvell_set_page(phydev, MII_MARVELL_MSCR_PAGE); in m88e1118_config_init()
1085 err = phy_write(phydev, 0x15, 0x1070); in m88e1118_config_init()
1090 err = marvell_set_page(phydev, MII_MARVELL_LED_PAGE); in m88e1118_config_init()
1094 if (phy_interface_is_rgmii(phydev)) { in m88e1118_config_init()
1095 err = m88e1121_config_aneg_rgmii_delays(phydev); in m88e1118_config_init()
1101 if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS) in m88e1118_config_init()
1102 err = phy_write(phydev, 0x10, 0x1100); in m88e1118_config_init()
1104 err = phy_write(phydev, 0x10, 0x021e); in m88e1118_config_init()
1108 err = marvell_of_reg_init(phydev); in m88e1118_config_init()
1113 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1118_config_init()
1117 return genphy_soft_reset(phydev); in m88e1118_config_init()
1120 static int m88e1149_config_init(struct phy_device *phydev) in m88e1149_config_init() argument
1125 err = marvell_set_page(phydev, MII_MARVELL_MSCR_PAGE); in m88e1149_config_init()
1130 err = phy_write(phydev, 0x15, 0x1048); in m88e1149_config_init()
1134 err = marvell_of_reg_init(phydev); in m88e1149_config_init()
1139 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1149_config_init()
1143 return genphy_soft_reset(phydev); in m88e1149_config_init()
1146 static int m88e1145_config_init_rgmii(struct phy_device *phydev) in m88e1145_config_init_rgmii() argument
1150 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1145_config_init_rgmii()
1154 if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) { in m88e1145_config_init_rgmii()
1155 err = phy_write(phydev, 0x1d, 0x0012); in m88e1145_config_init_rgmii()
1159 err = phy_modify(phydev, 0x1e, 0x0fc0, in m88e1145_config_init_rgmii()
1165 err = phy_write(phydev, 0x1d, 0x3); in m88e1145_config_init_rgmii()
1169 err = phy_write(phydev, 0x1e, 0x8000); in m88e1145_config_init_rgmii()
1174 static int m88e1145_config_init_sgmii(struct phy_device *phydev) in m88e1145_config_init_sgmii() argument
1177 phydev, MII_M1111_HWCFG_MODE_SGMII_NO_CLK, in m88e1145_config_init_sgmii()
1181 static int m88e1145_config_init(struct phy_device *phydev) in m88e1145_config_init() argument
1186 err = phy_write(phydev, 0x1d, 0x001b); in m88e1145_config_init()
1190 err = phy_write(phydev, 0x1e, 0x418f); in m88e1145_config_init()
1194 err = phy_write(phydev, 0x1d, 0x0016); in m88e1145_config_init()
1198 err = phy_write(phydev, 0x1e, 0xa2da); in m88e1145_config_init()
1202 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { in m88e1145_config_init()
1203 err = m88e1145_config_init_rgmii(phydev); in m88e1145_config_init()
1208 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1145_config_init()
1209 err = m88e1145_config_init_sgmii(phydev); in m88e1145_config_init()
1214 err = marvell_of_reg_init(phydev); in m88e1145_config_init()
1221 static int m88e1540_get_fld(struct phy_device *phydev, u8 *msecs) in m88e1540_get_fld() argument
1225 val = phy_read(phydev, MII_88E1540_COPPER_CTRL3); in m88e1540_get_fld()
1256 static int m88e1540_set_fld(struct phy_device *phydev, const u8 *msecs) in m88e1540_set_fld() argument
1262 return phy_clear_bits(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1268 ret = phy_ethtool_get_eee(phydev, &eee); in m88e1540_set_fld()
1270 phydev_warn(phydev, "Fast Link Down detection requires EEE to be disabled!\n"); in m88e1540_set_fld()
1285 ret = phy_modify(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1290 return phy_set_bits(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1294 static int m88e1540_get_tunable(struct phy_device *phydev, in m88e1540_get_tunable() argument
1299 return m88e1540_get_fld(phydev, data); in m88e1540_get_tunable()
1301 return m88e1011_get_downshift(phydev, data); in m88e1540_get_tunable()
1307 static int m88e1540_set_tunable(struct phy_device *phydev, in m88e1540_set_tunable() argument
1312 return m88e1540_set_fld(phydev, data); in m88e1540_set_tunable()
1314 return m88e1011_set_downshift(phydev, *(const u8 *)data); in m88e1540_set_tunable()
1324 static int m88e6390_errata(struct phy_device *phydev) in m88e6390_errata() argument
1328 err = phy_write(phydev, MII_BMCR, in m88e6390_errata()
1335 err = phy_write_paged(phydev, 0xf8, 0x08, 0x36); in m88e6390_errata()
1339 return genphy_soft_reset(phydev); in m88e6390_errata()
1342 static int m88e6390_config_aneg(struct phy_device *phydev) in m88e6390_config_aneg() argument
1346 err = m88e6390_errata(phydev); in m88e6390_config_aneg()
1350 return m88e1510_config_aneg(phydev); in m88e6390_config_aneg()
1371 static int marvell_read_status_page_an(struct phy_device *phydev, in marvell_read_status_page_an() argument
1378 phydev->link = 0; in marvell_read_status_page_an()
1383 phydev->duplex = DUPLEX_FULL; in marvell_read_status_page_an()
1385 phydev->duplex = DUPLEX_HALF; in marvell_read_status_page_an()
1389 phydev->speed = SPEED_1000; in marvell_read_status_page_an()
1393 phydev->speed = SPEED_100; in marvell_read_status_page_an()
1397 phydev->speed = SPEED_10; in marvell_read_status_page_an()
1402 err = genphy_read_lpa(phydev); in marvell_read_status_page_an()
1406 phy_resolve_aneg_pause(phydev); in marvell_read_status_page_an()
1408 lpa = phy_read(phydev, MII_LPA); in marvell_read_status_page_an()
1413 fiber_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); in marvell_read_status_page_an()
1415 if (phydev->duplex == DUPLEX_FULL) { in marvell_read_status_page_an()
1417 phydev->pause = 0; in marvell_read_status_page_an()
1418 phydev->asym_pause = 0; in marvell_read_status_page_an()
1420 phydev->pause = 1; in marvell_read_status_page_an()
1421 phydev->asym_pause = 1; in marvell_read_status_page_an()
1423 phydev->pause = 1; in marvell_read_status_page_an()
1424 phydev->asym_pause = 0; in marvell_read_status_page_an()
1440 static int marvell_read_status_page(struct phy_device *phydev, int page) in marvell_read_status_page() argument
1446 status = phy_read(phydev, MII_M1011_PHY_STATUS); in marvell_read_status_page()
1454 phydev->link = !!(status & MII_M1011_PHY_STATUS_LINK); in marvell_read_status_page()
1456 err = genphy_update_link(phydev); in marvell_read_status_page()
1466 linkmode_zero(phydev->lp_advertising); in marvell_read_status_page()
1467 phydev->pause = 0; in marvell_read_status_page()
1468 phydev->asym_pause = 0; in marvell_read_status_page()
1469 phydev->speed = SPEED_UNKNOWN; in marvell_read_status_page()
1470 phydev->duplex = DUPLEX_UNKNOWN; in marvell_read_status_page()
1471 phydev->port = fiber ? PORT_FIBRE : PORT_TP; in marvell_read_status_page()
1473 if (phydev->autoneg == AUTONEG_ENABLE) in marvell_read_status_page()
1474 err = marvell_read_status_page_an(phydev, fiber, status); in marvell_read_status_page()
1476 err = genphy_read_status_fixed(phydev); in marvell_read_status_page()
1490 static int marvell_read_status(struct phy_device *phydev) in marvell_read_status() argument
1496 phydev->supported) && in marvell_read_status()
1497 phydev->interface != PHY_INTERFACE_MODE_SGMII) { in marvell_read_status()
1498 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_read_status()
1502 err = marvell_read_status_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_read_status()
1513 if (phydev->link) in marvell_read_status()
1517 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1522 return marvell_read_status_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1525 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1534 static int marvell_suspend(struct phy_device *phydev) in marvell_suspend() argument
1540 phydev->supported)) { in marvell_suspend()
1541 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_suspend()
1546 err = genphy_suspend(phydev); in marvell_suspend()
1551 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_suspend()
1557 return genphy_suspend(phydev); in marvell_suspend()
1560 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_suspend()
1569 static int marvell_resume(struct phy_device *phydev) in marvell_resume() argument
1575 phydev->supported)) { in marvell_resume()
1576 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_resume()
1581 err = genphy_resume(phydev); in marvell_resume()
1586 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_resume()
1592 return genphy_resume(phydev); in marvell_resume()
1595 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_resume()
1599 static int marvell_aneg_done(struct phy_device *phydev) in marvell_aneg_done() argument
1601 int retval = phy_read(phydev, MII_M1011_PHY_STATUS); in marvell_aneg_done()
1606 static int m88e1121_did_interrupt(struct phy_device *phydev) in m88e1121_did_interrupt() argument
1610 imask = phy_read(phydev, MII_M1011_IEVENT); in m88e1121_did_interrupt()
1618 static void m88e1318_get_wol(struct phy_device *phydev, in m88e1318_get_wol() argument
1626 ret = phy_read_paged(phydev, MII_MARVELL_WOL_PAGE, in m88e1318_get_wol()
1632 static int m88e1318_set_wol(struct phy_device *phydev, in m88e1318_set_wol() argument
1637 oldpage = phy_save_page(phydev); in m88e1318_set_wol()
1643 err = marvell_write_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1318_set_wol()
1653 if (!phy_interrupt_is_valid(phydev)) in m88e1318_set_wol()
1654 __phy_read(phydev, MII_M1011_IEVENT); in m88e1318_set_wol()
1657 err = __phy_modify(phydev, MII_88E1318S_PHY_CSIER, 0, in m88e1318_set_wol()
1662 err = marvell_write_page(phydev, MII_MARVELL_LED_PAGE); in m88e1318_set_wol()
1667 err = __phy_modify(phydev, MII_88E1318S_PHY_LED_TCR, in m88e1318_set_wol()
1674 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1679 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD2, in m88e1318_set_wol()
1680 ((phydev->attached_dev->dev_addr[5] << 8) | in m88e1318_set_wol()
1681 phydev->attached_dev->dev_addr[4])); in m88e1318_set_wol()
1684 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD1, in m88e1318_set_wol()
1685 ((phydev->attached_dev->dev_addr[3] << 8) | in m88e1318_set_wol()
1686 phydev->attached_dev->dev_addr[2])); in m88e1318_set_wol()
1689 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD0, in m88e1318_set_wol()
1690 ((phydev->attached_dev->dev_addr[1] << 8) | in m88e1318_set_wol()
1691 phydev->attached_dev->dev_addr[0])); in m88e1318_set_wol()
1696 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, 0, in m88e1318_set_wol()
1702 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1707 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, in m88e1318_set_wol()
1715 return phy_restore_page(phydev, oldpage, err); in m88e1318_set_wol()
1718 static int marvell_get_sset_count(struct phy_device *phydev) in marvell_get_sset_count() argument
1721 phydev->supported)) in marvell_get_sset_count()
1727 static void marvell_get_strings(struct phy_device *phydev, u8 *data) in marvell_get_strings() argument
1729 int count = marvell_get_sset_count(phydev); in marvell_get_strings()
1738 static u64 marvell_get_stat(struct phy_device *phydev, int i) in marvell_get_stat() argument
1741 struct marvell_priv *priv = phydev->priv; in marvell_get_stat()
1745 val = phy_read_paged(phydev, stat.page, stat.reg); in marvell_get_stat()
1757 static void marvell_get_stats(struct phy_device *phydev, in marvell_get_stats() argument
1760 int count = marvell_get_sset_count(phydev); in marvell_get_stats()
1764 data[i] = marvell_get_stat(phydev, i); in marvell_get_stats()
1767 static int marvell_vct5_wait_complete(struct phy_device *phydev) in marvell_vct5_wait_complete() argument
1773 val = __phy_read(phydev, MII_VCT5_CTRL); in marvell_vct5_wait_complete()
1781 phydev_err(phydev, "Timeout while waiting for cable test to finish\n"); in marvell_vct5_wait_complete()
1785 static int marvell_vct5_amplitude(struct phy_device *phydev, int pair) in marvell_vct5_amplitude() argument
1792 val = __phy_read(phydev, reg); in marvell_vct5_amplitude()
1816 static int marvell_vct5_amplitude_distance(struct phy_device *phydev, in marvell_vct5_amplitude_distance() argument
1824 err = __phy_write(phydev, MII_VCT5_SAMPLE_POINT_DISTANCE, in marvell_vct5_amplitude_distance()
1834 err = __phy_write(phydev, MII_VCT5_CTRL, reg); in marvell_vct5_amplitude_distance()
1838 err = marvell_vct5_wait_complete(phydev); in marvell_vct5_amplitude_distance()
1846 mV = marvell_vct5_amplitude(phydev, i); in marvell_vct5_amplitude_distance()
1847 ethnl_cable_test_amplitude(phydev, i, mV); in marvell_vct5_amplitude_distance()
1853 static int marvell_vct5_amplitude_graph(struct phy_device *phydev) in marvell_vct5_amplitude_graph() argument
1855 struct marvell_priv *priv = phydev->priv; in marvell_vct5_amplitude_graph()
1871 err = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct5_amplitude_graph()
1882 page = phy_select_page(phydev, MII_MARVELL_VCT5_PAGE); in marvell_vct5_amplitude_graph()
1889 err = marvell_vct5_amplitude_distance(phydev, distance, in marvell_vct5_amplitude_graph()
1900 err = __phy_write(phydev, MII_VCT5_TX_PULSE_CTRL, reg); in marvell_vct5_amplitude_graph()
1907 return phy_restore_page(phydev, page, err); in marvell_vct5_amplitude_graph()
1910 static int marvell_cable_test_start_common(struct phy_device *phydev) in marvell_cable_test_start_common() argument
1917 bmcr = phy_read(phydev, MII_BMCR); in marvell_cable_test_start_common()
1921 bmsr = phy_read(phydev, MII_BMSR); in marvell_cable_test_start_common()
1927 ret = phy_modify(phydev, MII_BMCR, BMCR_ANENABLE, 0); in marvell_cable_test_start_common()
1930 ret = genphy_soft_reset(phydev); in marvell_cable_test_start_common()
1942 static int marvell_vct7_cable_test_start(struct phy_device *phydev) in marvell_vct7_cable_test_start() argument
1944 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_start()
1947 ret = marvell_cable_test_start_common(phydev); in marvell_vct7_cable_test_start()
1956 ret = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct7_cable_test_start()
1965 ret = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct7_cable_test_start()
1970 return phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_start()
1976 static int marvell_vct5_cable_test_tdr_start(struct phy_device *phydev, in marvell_vct5_cable_test_tdr_start() argument
1979 struct marvell_priv *priv = phydev->priv; in marvell_vct5_cable_test_tdr_start()
1995 ret = phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct5_cable_test_tdr_start()
2000 ret = marvell_cable_test_start_common(phydev); in marvell_vct5_cable_test_tdr_start()
2004 ret = ethnl_cable_test_pulse(phydev, 1000); in marvell_vct5_cable_test_tdr_start()
2008 return ethnl_cable_test_step(phydev, in marvell_vct5_cable_test_tdr_start()
2033 static int marvell_vct7_report_length(struct phy_device *phydev, in marvell_vct7_report_length() argument
2039 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_report_length()
2046 ethnl_cable_test_fault_length(phydev, pair, length); in marvell_vct7_report_length()
2067 static int marvell_vct7_cable_test_report(struct phy_device *phydev) in marvell_vct7_cable_test_report() argument
2073 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_report()
2087 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, in marvell_vct7_cable_test_report()
2089 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_B, in marvell_vct7_cable_test_report()
2091 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_C, in marvell_vct7_cable_test_report()
2093 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_D, in marvell_vct7_cable_test_report()
2096 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, MII_VCT7_CTRL); in marvell_vct7_cable_test_report()
2103 marvell_vct7_report_length(phydev, 0, meter); in marvell_vct7_cable_test_report()
2105 marvell_vct7_report_length(phydev, 1, meter); in marvell_vct7_cable_test_report()
2107 marvell_vct7_report_length(phydev, 2, meter); in marvell_vct7_cable_test_report()
2109 marvell_vct7_report_length(phydev, 3, meter); in marvell_vct7_cable_test_report()
2114 static int marvell_vct7_cable_test_get_status(struct phy_device *phydev, in marvell_vct7_cable_test_get_status() argument
2117 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_get_status()
2121 ret = marvell_vct5_amplitude_graph(phydev); in marvell_vct7_cable_test_get_status()
2128 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_get_status()
2137 return marvell_vct7_cable_test_report(phydev); in marvell_vct7_cable_test_get_status()
2144 static int m88e1121_get_temp(struct phy_device *phydev, long *temp) in m88e1121_get_temp() argument
2152 oldpage = phy_select_page(phydev, MII_MARVELL_MISC_TEST_PAGE); in m88e1121_get_temp()
2157 ret = __phy_read(phydev, MII_88E1121_MISC_TEST); in m88e1121_get_temp()
2161 ret = __phy_write(phydev, MII_88E1121_MISC_TEST, in m88e1121_get_temp()
2169 val = __phy_read(phydev, MII_88E1121_MISC_TEST); in m88e1121_get_temp()
2176 ret = __phy_write(phydev, MII_88E1121_MISC_TEST, in m88e1121_get_temp()
2184 return phy_restore_page(phydev, oldpage, ret); in m88e1121_get_temp()
2191 struct phy_device *phydev = dev_get_drvdata(dev); in m88e1121_hwmon_read() local
2196 err = m88e1121_get_temp(phydev, temp); in m88e1121_hwmon_read()
2256 static int m88e1510_get_temp(struct phy_device *phydev, long *temp) in m88e1510_get_temp() argument
2262 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp()
2272 static int m88e1510_get_temp_critical(struct phy_device *phydev, long *temp) in m88e1510_get_temp_critical() argument
2278 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp_critical()
2291 static int m88e1510_set_temp_critical(struct phy_device *phydev, long temp) in m88e1510_set_temp_critical() argument
2296 return phy_modify_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_set_temp_critical()
2302 static int m88e1510_get_temp_alarm(struct phy_device *phydev, long *alarm) in m88e1510_get_temp_alarm() argument
2308 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp_alarm()
2322 struct phy_device *phydev = dev_get_drvdata(dev); in m88e1510_hwmon_read() local
2327 err = m88e1510_get_temp(phydev, temp); in m88e1510_hwmon_read()
2330 err = m88e1510_get_temp_critical(phydev, temp); in m88e1510_hwmon_read()
2333 err = m88e1510_get_temp_alarm(phydev, temp); in m88e1510_hwmon_read()
2346 struct phy_device *phydev = dev_get_drvdata(dev); in m88e1510_hwmon_write() local
2351 err = m88e1510_set_temp_critical(phydev, temp); in m88e1510_hwmon_write()
2404 static int m88e6390_get_temp(struct phy_device *phydev, long *temp) in m88e6390_get_temp() argument
2413 oldpage = phy_select_page(phydev, MII_MARVELL_MISC_TEST_PAGE); in m88e6390_get_temp()
2418 ret = __phy_read(phydev, MII_88E6390_MISC_TEST); in m88e6390_get_temp()
2426 ret = __phy_write(phydev, MII_88E6390_MISC_TEST, ret); in m88e6390_get_temp()
2437 ret = __phy_read(phydev, MII_88E6390_TEMP_SENSOR); in m88e6390_get_temp()
2447 ret = __phy_read(phydev, MII_88E6390_MISC_TEST); in m88e6390_get_temp()
2454 ret = __phy_write(phydev, MII_88E6390_MISC_TEST, ret); in m88e6390_get_temp()
2457 phy_restore_page(phydev, oldpage, ret); in m88e6390_get_temp()
2466 struct phy_device *phydev = dev_get_drvdata(dev); in m88e6390_hwmon_read() local
2471 err = m88e6390_get_temp(phydev, temp); in m88e6390_hwmon_read()
2521 static int marvell_hwmon_name(struct phy_device *phydev) in marvell_hwmon_name() argument
2523 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_name()
2524 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_name()
2541 static int marvell_hwmon_probe(struct phy_device *phydev, in marvell_hwmon_probe() argument
2544 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_probe()
2545 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_probe()
2548 err = marvell_hwmon_name(phydev); in marvell_hwmon_probe()
2553 dev, priv->hwmon_name, phydev, chip, NULL); in marvell_hwmon_probe()
2558 static int m88e1121_hwmon_probe(struct phy_device *phydev) in m88e1121_hwmon_probe() argument
2560 return marvell_hwmon_probe(phydev, &m88e1121_hwmon_chip_info); in m88e1121_hwmon_probe()
2563 static int m88e1510_hwmon_probe(struct phy_device *phydev) in m88e1510_hwmon_probe() argument
2565 return marvell_hwmon_probe(phydev, &m88e1510_hwmon_chip_info); in m88e1510_hwmon_probe()
2568 static int m88e6390_hwmon_probe(struct phy_device *phydev) in m88e6390_hwmon_probe() argument
2570 return marvell_hwmon_probe(phydev, &m88e6390_hwmon_chip_info); in m88e6390_hwmon_probe()
2573 static int m88e1121_hwmon_probe(struct phy_device *phydev) in m88e1121_hwmon_probe() argument
2578 static int m88e1510_hwmon_probe(struct phy_device *phydev) in m88e1510_hwmon_probe() argument
2583 static int m88e6390_hwmon_probe(struct phy_device *phydev) in m88e6390_hwmon_probe() argument
2589 static int marvell_probe(struct phy_device *phydev) in marvell_probe() argument
2593 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in marvell_probe()
2597 phydev->priv = priv; in marvell_probe()
2602 static int m88e1121_probe(struct phy_device *phydev) in m88e1121_probe() argument
2606 err = marvell_probe(phydev); in m88e1121_probe()
2610 return m88e1121_hwmon_probe(phydev); in m88e1121_probe()
2613 static int m88e1510_probe(struct phy_device *phydev) in m88e1510_probe() argument
2617 err = marvell_probe(phydev); in m88e1510_probe()
2621 return m88e1510_hwmon_probe(phydev); in m88e1510_probe()
2624 static int m88e6390_probe(struct phy_device *phydev) in m88e6390_probe() argument
2628 err = marvell_probe(phydev); in m88e6390_probe()
2632 return m88e6390_hwmon_probe(phydev); in m88e6390_probe()