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(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()
534 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1121_config_aneg()
540 err = genphy_config_aneg(phydev); in m88e1121_config_aneg()
544 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in m88e1121_config_aneg()
548 err = genphy_soft_reset(phydev); in m88e1121_config_aneg()
556 static int m88e1318_config_aneg(struct phy_device *phydev) in m88e1318_config_aneg() argument
560 err = phy_modify_paged(phydev, MII_MARVELL_MSCR_PAGE, in m88e1318_config_aneg()
566 return m88e1121_config_aneg(phydev); in m88e1318_config_aneg()
597 * @phydev: target phy_device struct
604 static int marvell_config_aneg_fiber(struct phy_device *phydev) in marvell_config_aneg_fiber() argument
610 if (phydev->autoneg != AUTONEG_ENABLE) in marvell_config_aneg_fiber()
611 return genphy_setup_forced(phydev); in marvell_config_aneg_fiber()
614 linkmode_and(phydev->advertising, phydev->advertising, in marvell_config_aneg_fiber()
615 phydev->supported); in marvell_config_aneg_fiber()
617 adv = linkmode_adv_to_fiber_adv_t(phydev->advertising); in marvell_config_aneg_fiber()
620 err = phy_modify_changed(phydev, MII_ADVERTISE, in marvell_config_aneg_fiber()
629 return genphy_check_and_restart_aneg(phydev, changed); in marvell_config_aneg_fiber()
632 static int m88e1510_config_aneg(struct phy_device *phydev) in m88e1510_config_aneg() argument
636 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
641 err = m88e1318_config_aneg(phydev); in m88e1510_config_aneg()
646 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1510_config_aneg()
650 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in m88e1510_config_aneg()
654 err = marvell_config_aneg_fiber(phydev); in m88e1510_config_aneg()
658 return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
661 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
665 static void marvell_config_led(struct phy_device *phydev) in marvell_config_led() argument
670 switch (MARVELL_PHY_FAMILY_ID(phydev->phy_id)) { in marvell_config_led()
682 if (phydev->dev_flags & MARVELL_PHY_LED0_LINK_LED1_ACTIVE) in marvell_config_led()
691 err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE, MII_PHY_LED_CTRL, in marvell_config_led()
694 phydev_warn(phydev, "Fail to config marvell phy LED.\n"); in marvell_config_led()
697 static int marvell_config_init(struct phy_device *phydev) in marvell_config_init() argument
700 marvell_config_led(phydev); in marvell_config_init()
703 return marvell_of_reg_init(phydev); in marvell_config_init()
706 static int m88e3016_config_init(struct phy_device *phydev) in m88e3016_config_init() argument
711 ret = phy_modify(phydev, MII_88E3016_PHY_SPEC_CTRL, in m88e3016_config_init()
717 return marvell_config_init(phydev); in m88e3016_config_init()
720 static int m88e1111_config_init_hwcfg_mode(struct phy_device *phydev, in m88e1111_config_init_hwcfg_mode() argument
727 return phy_modify(phydev, MII_M1111_PHY_EXT_SR, in m88e1111_config_init_hwcfg_mode()
734 static int m88e1111_config_init_rgmii_delays(struct phy_device *phydev) in m88e1111_config_init_rgmii_delays() argument
738 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { in m88e1111_config_init_rgmii_delays()
740 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) { in m88e1111_config_init_rgmii_delays()
742 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) { in m88e1111_config_init_rgmii_delays()
748 return phy_modify(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_config_init_rgmii_delays()
753 static int m88e1111_config_init_rgmii(struct phy_device *phydev) in m88e1111_config_init_rgmii() argument
758 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1111_config_init_rgmii()
762 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR); in m88e1111_config_init_rgmii()
773 return phy_write(phydev, MII_M1111_PHY_EXT_SR, temp); in m88e1111_config_init_rgmii()
776 static int m88e1111_config_init_sgmii(struct phy_device *phydev) in m88e1111_config_init_sgmii() argument
781 phydev, in m88e1111_config_init_sgmii()
788 return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1111_config_init_sgmii()
791 static int m88e1111_config_init_rtbi(struct phy_device *phydev) in m88e1111_config_init_rtbi() argument
795 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1111_config_init_rtbi()
800 phydev, in m88e1111_config_init_rtbi()
807 err = genphy_soft_reset(phydev); in m88e1111_config_init_rtbi()
812 phydev, in m88e1111_config_init_rtbi()
817 static int m88e1111_config_init(struct phy_device *phydev) in m88e1111_config_init() argument
821 if (phy_interface_is_rgmii(phydev)) { in m88e1111_config_init()
822 err = m88e1111_config_init_rgmii(phydev); in m88e1111_config_init()
827 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1111_config_init()
828 err = m88e1111_config_init_sgmii(phydev); in m88e1111_config_init()
833 if (phydev->interface == PHY_INTERFACE_MODE_RTBI) { in m88e1111_config_init()
834 err = m88e1111_config_init_rtbi(phydev); in m88e1111_config_init()
839 err = marvell_of_reg_init(phydev); in m88e1111_config_init()
843 return genphy_soft_reset(phydev); in m88e1111_config_init()
846 static int m88e1111_get_downshift(struct phy_device *phydev, u8 *data) in m88e1111_get_downshift() argument
850 val = phy_read(phydev, MII_M1111_PHY_EXT_CR); in m88e1111_get_downshift()
862 static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt) in m88e1111_set_downshift() argument
870 return phy_clear_bits(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_set_downshift()
876 return phy_modify(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_set_downshift()
882 static int m88e1111_get_tunable(struct phy_device *phydev, in m88e1111_get_tunable() argument
887 return m88e1111_get_downshift(phydev, data); in m88e1111_get_tunable()
893 static int m88e1111_set_tunable(struct phy_device *phydev, in m88e1111_set_tunable() argument
898 return m88e1111_set_downshift(phydev, *(const u8 *)data); in m88e1111_set_tunable()
904 static int m88e1011_get_downshift(struct phy_device *phydev, u8 *data) in m88e1011_get_downshift() argument
908 val = phy_read(phydev, MII_M1011_PHY_SCR); in m88e1011_get_downshift()
920 static int m88e1011_set_downshift(struct phy_device *phydev, u8 cnt) in m88e1011_set_downshift() argument
928 return phy_clear_bits(phydev, MII_M1011_PHY_SCR, in m88e1011_set_downshift()
934 return phy_modify(phydev, MII_M1011_PHY_SCR, in m88e1011_set_downshift()
940 static int m88e1011_get_tunable(struct phy_device *phydev, in m88e1011_get_tunable() argument
945 return m88e1011_get_downshift(phydev, data); in m88e1011_get_tunable()
951 static int m88e1011_set_tunable(struct phy_device *phydev, in m88e1011_set_tunable() argument
956 return m88e1011_set_downshift(phydev, *(const u8 *)data); in m88e1011_set_tunable()
962 static int m88e1116r_config_init(struct phy_device *phydev) in m88e1116r_config_init() argument
966 err = genphy_soft_reset(phydev); in m88e1116r_config_init()
972 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1116r_config_init()
976 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1116r_config_init()
980 err = m88e1011_set_downshift(phydev, 8); in m88e1116r_config_init()
984 if (phy_interface_is_rgmii(phydev)) { in m88e1116r_config_init()
985 err = m88e1121_config_aneg_rgmii_delays(phydev); in m88e1116r_config_init()
990 err = genphy_soft_reset(phydev); in m88e1116r_config_init()
994 return marvell_config_init(phydev); in m88e1116r_config_init()
997 static int m88e1318_config_init(struct phy_device *phydev) in m88e1318_config_init() argument
999 if (phy_interrupt_is_valid(phydev)) { in m88e1318_config_init()
1001 phydev, MII_MARVELL_LED_PAGE, in m88e1318_config_init()
1010 return marvell_config_init(phydev); in m88e1318_config_init()
1013 static int m88e1510_config_init(struct phy_device *phydev) in m88e1510_config_init() argument
1018 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1510_config_init()
1020 err = marvell_set_page(phydev, 18); in m88e1510_config_init()
1025 err = phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_config_init()
1032 err = phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, 0, in m88e1510_config_init()
1038 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_init()
1043 return m88e1318_config_init(phydev); in m88e1510_config_init()
1046 static int m88e1118_config_aneg(struct phy_device *phydev) in m88e1118_config_aneg() argument
1050 err = genphy_soft_reset(phydev); in m88e1118_config_aneg()
1054 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1118_config_aneg()
1058 err = genphy_config_aneg(phydev); in m88e1118_config_aneg()
1062 static int m88e1118_config_init(struct phy_device *phydev) in m88e1118_config_init() argument
1067 err = marvell_set_page(phydev, MII_MARVELL_MSCR_PAGE); in m88e1118_config_init()
1072 err = phy_write(phydev, 0x15, 0x1070); in m88e1118_config_init()
1077 err = marvell_set_page(phydev, MII_MARVELL_LED_PAGE); in m88e1118_config_init()
1082 if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS) in m88e1118_config_init()
1083 err = phy_write(phydev, 0x10, 0x1100); in m88e1118_config_init()
1085 err = phy_write(phydev, 0x10, 0x021e); in m88e1118_config_init()
1089 err = marvell_of_reg_init(phydev); in m88e1118_config_init()
1094 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1118_config_init()
1098 return genphy_soft_reset(phydev); in m88e1118_config_init()
1101 static int m88e1149_config_init(struct phy_device *phydev) in m88e1149_config_init() argument
1106 err = marvell_set_page(phydev, MII_MARVELL_MSCR_PAGE); in m88e1149_config_init()
1111 err = phy_write(phydev, 0x15, 0x1048); in m88e1149_config_init()
1115 err = marvell_of_reg_init(phydev); in m88e1149_config_init()
1120 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1149_config_init()
1124 return genphy_soft_reset(phydev); in m88e1149_config_init()
1127 static int m88e1145_config_init_rgmii(struct phy_device *phydev) in m88e1145_config_init_rgmii() argument
1131 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1145_config_init_rgmii()
1135 if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) { in m88e1145_config_init_rgmii()
1136 err = phy_write(phydev, 0x1d, 0x0012); in m88e1145_config_init_rgmii()
1140 err = phy_modify(phydev, 0x1e, 0x0fc0, in m88e1145_config_init_rgmii()
1146 err = phy_write(phydev, 0x1d, 0x3); in m88e1145_config_init_rgmii()
1150 err = phy_write(phydev, 0x1e, 0x8000); in m88e1145_config_init_rgmii()
1155 static int m88e1145_config_init_sgmii(struct phy_device *phydev) in m88e1145_config_init_sgmii() argument
1158 phydev, MII_M1111_HWCFG_MODE_SGMII_NO_CLK, in m88e1145_config_init_sgmii()
1162 static int m88e1145_config_init(struct phy_device *phydev) in m88e1145_config_init() argument
1167 err = phy_write(phydev, 0x1d, 0x001b); in m88e1145_config_init()
1171 err = phy_write(phydev, 0x1e, 0x418f); in m88e1145_config_init()
1175 err = phy_write(phydev, 0x1d, 0x0016); in m88e1145_config_init()
1179 err = phy_write(phydev, 0x1e, 0xa2da); in m88e1145_config_init()
1183 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { in m88e1145_config_init()
1184 err = m88e1145_config_init_rgmii(phydev); in m88e1145_config_init()
1189 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1145_config_init()
1190 err = m88e1145_config_init_sgmii(phydev); in m88e1145_config_init()
1195 err = marvell_of_reg_init(phydev); in m88e1145_config_init()
1202 static int m88e1540_get_fld(struct phy_device *phydev, u8 *msecs) in m88e1540_get_fld() argument
1206 val = phy_read(phydev, MII_88E1540_COPPER_CTRL3); in m88e1540_get_fld()
1237 static int m88e1540_set_fld(struct phy_device *phydev, const u8 *msecs) in m88e1540_set_fld() argument
1243 return phy_clear_bits(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1249 ret = phy_ethtool_get_eee(phydev, &eee); in m88e1540_set_fld()
1251 phydev_warn(phydev, "Fast Link Down detection requires EEE to be disabled!\n"); in m88e1540_set_fld()
1266 ret = phy_modify(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1271 return phy_set_bits(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1275 static int m88e1540_get_tunable(struct phy_device *phydev, in m88e1540_get_tunable() argument
1280 return m88e1540_get_fld(phydev, data); in m88e1540_get_tunable()
1282 return m88e1011_get_downshift(phydev, data); in m88e1540_get_tunable()
1288 static int m88e1540_set_tunable(struct phy_device *phydev, in m88e1540_set_tunable() argument
1293 return m88e1540_set_fld(phydev, data); in m88e1540_set_tunable()
1295 return m88e1011_set_downshift(phydev, *(const u8 *)data); in m88e1540_set_tunable()
1305 static int m88e6390_errata(struct phy_device *phydev) in m88e6390_errata() argument
1309 err = phy_write(phydev, MII_BMCR, in m88e6390_errata()
1316 err = phy_write_paged(phydev, 0xf8, 0x08, 0x36); in m88e6390_errata()
1320 return genphy_soft_reset(phydev); in m88e6390_errata()
1323 static int m88e6390_config_aneg(struct phy_device *phydev) in m88e6390_config_aneg() argument
1327 err = m88e6390_errata(phydev); in m88e6390_config_aneg()
1331 return m88e1510_config_aneg(phydev); in m88e6390_config_aneg()
1352 static int marvell_read_status_page_an(struct phy_device *phydev, in marvell_read_status_page_an() argument
1359 phydev->link = 0; in marvell_read_status_page_an()
1364 phydev->duplex = DUPLEX_FULL; in marvell_read_status_page_an()
1366 phydev->duplex = DUPLEX_HALF; in marvell_read_status_page_an()
1370 phydev->speed = SPEED_1000; in marvell_read_status_page_an()
1374 phydev->speed = SPEED_100; in marvell_read_status_page_an()
1378 phydev->speed = SPEED_10; in marvell_read_status_page_an()
1383 err = genphy_read_lpa(phydev); in marvell_read_status_page_an()
1387 phy_resolve_aneg_pause(phydev); in marvell_read_status_page_an()
1389 lpa = phy_read(phydev, MII_LPA); in marvell_read_status_page_an()
1394 fiber_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); in marvell_read_status_page_an()
1396 if (phydev->duplex == DUPLEX_FULL) { in marvell_read_status_page_an()
1398 phydev->pause = 0; in marvell_read_status_page_an()
1399 phydev->asym_pause = 0; in marvell_read_status_page_an()
1401 phydev->pause = 1; in marvell_read_status_page_an()
1402 phydev->asym_pause = 1; in marvell_read_status_page_an()
1404 phydev->pause = 1; in marvell_read_status_page_an()
1405 phydev->asym_pause = 0; in marvell_read_status_page_an()
1421 static int marvell_read_status_page(struct phy_device *phydev, int page) in marvell_read_status_page() argument
1427 status = phy_read(phydev, MII_M1011_PHY_STATUS); in marvell_read_status_page()
1435 phydev->link = !!(status & MII_M1011_PHY_STATUS_LINK); in marvell_read_status_page()
1437 err = genphy_update_link(phydev); in marvell_read_status_page()
1447 linkmode_zero(phydev->lp_advertising); in marvell_read_status_page()
1448 phydev->pause = 0; in marvell_read_status_page()
1449 phydev->asym_pause = 0; in marvell_read_status_page()
1450 phydev->speed = SPEED_UNKNOWN; in marvell_read_status_page()
1451 phydev->duplex = DUPLEX_UNKNOWN; in marvell_read_status_page()
1453 if (phydev->autoneg == AUTONEG_ENABLE) in marvell_read_status_page()
1454 err = marvell_read_status_page_an(phydev, fiber, status); in marvell_read_status_page()
1456 err = genphy_read_status_fixed(phydev); in marvell_read_status_page()
1470 static int marvell_read_status(struct phy_device *phydev) in marvell_read_status() argument
1476 phydev->supported) && in marvell_read_status()
1477 phydev->interface != PHY_INTERFACE_MODE_SGMII) { in marvell_read_status()
1478 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_read_status()
1482 err = marvell_read_status_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_read_status()
1493 if (phydev->link) in marvell_read_status()
1497 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1502 return marvell_read_status_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1505 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1514 static int marvell_suspend(struct phy_device *phydev) in marvell_suspend() argument
1520 phydev->supported)) { in marvell_suspend()
1521 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_suspend()
1526 err = genphy_suspend(phydev); in marvell_suspend()
1531 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_suspend()
1537 return genphy_suspend(phydev); in marvell_suspend()
1540 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_suspend()
1549 static int marvell_resume(struct phy_device *phydev) in marvell_resume() argument
1555 phydev->supported)) { in marvell_resume()
1556 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_resume()
1561 err = genphy_resume(phydev); in marvell_resume()
1566 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_resume()
1572 return genphy_resume(phydev); in marvell_resume()
1575 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_resume()
1579 static int marvell_aneg_done(struct phy_device *phydev) in marvell_aneg_done() argument
1581 int retval = phy_read(phydev, MII_M1011_PHY_STATUS); in marvell_aneg_done()
1586 static int m88e1121_did_interrupt(struct phy_device *phydev) in m88e1121_did_interrupt() argument
1590 imask = phy_read(phydev, MII_M1011_IEVENT); in m88e1121_did_interrupt()
1598 static void m88e1318_get_wol(struct phy_device *phydev, in m88e1318_get_wol() argument
1606 ret = phy_read_paged(phydev, MII_MARVELL_WOL_PAGE, in m88e1318_get_wol()
1612 static int m88e1318_set_wol(struct phy_device *phydev, in m88e1318_set_wol() argument
1617 oldpage = phy_save_page(phydev); in m88e1318_set_wol()
1623 err = marvell_write_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1318_set_wol()
1633 if (!phy_interrupt_is_valid(phydev)) in m88e1318_set_wol()
1634 __phy_read(phydev, MII_M1011_IEVENT); in m88e1318_set_wol()
1637 err = __phy_modify(phydev, MII_88E1318S_PHY_CSIER, 0, in m88e1318_set_wol()
1642 err = marvell_write_page(phydev, MII_MARVELL_LED_PAGE); in m88e1318_set_wol()
1647 err = __phy_modify(phydev, MII_88E1318S_PHY_LED_TCR, in m88e1318_set_wol()
1654 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1659 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD2, in m88e1318_set_wol()
1660 ((phydev->attached_dev->dev_addr[5] << 8) | in m88e1318_set_wol()
1661 phydev->attached_dev->dev_addr[4])); in m88e1318_set_wol()
1664 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD1, in m88e1318_set_wol()
1665 ((phydev->attached_dev->dev_addr[3] << 8) | in m88e1318_set_wol()
1666 phydev->attached_dev->dev_addr[2])); in m88e1318_set_wol()
1669 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD0, in m88e1318_set_wol()
1670 ((phydev->attached_dev->dev_addr[1] << 8) | in m88e1318_set_wol()
1671 phydev->attached_dev->dev_addr[0])); in m88e1318_set_wol()
1676 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, 0, in m88e1318_set_wol()
1682 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1687 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, in m88e1318_set_wol()
1695 return phy_restore_page(phydev, oldpage, err); in m88e1318_set_wol()
1698 static int marvell_get_sset_count(struct phy_device *phydev) in marvell_get_sset_count() argument
1701 phydev->supported)) in marvell_get_sset_count()
1707 static void marvell_get_strings(struct phy_device *phydev, u8 *data) in marvell_get_strings() argument
1709 int count = marvell_get_sset_count(phydev); in marvell_get_strings()
1718 static u64 marvell_get_stat(struct phy_device *phydev, int i) in marvell_get_stat() argument
1721 struct marvell_priv *priv = phydev->priv; in marvell_get_stat()
1725 val = phy_read_paged(phydev, stat.page, stat.reg); in marvell_get_stat()
1737 static void marvell_get_stats(struct phy_device *phydev, in marvell_get_stats() argument
1740 int count = marvell_get_sset_count(phydev); in marvell_get_stats()
1744 data[i] = marvell_get_stat(phydev, i); in marvell_get_stats()
1747 static int marvell_vct5_wait_complete(struct phy_device *phydev) in marvell_vct5_wait_complete() argument
1753 val = __phy_read(phydev, MII_VCT5_CTRL); in marvell_vct5_wait_complete()
1761 phydev_err(phydev, "Timeout while waiting for cable test to finish\n"); in marvell_vct5_wait_complete()
1765 static int marvell_vct5_amplitude(struct phy_device *phydev, int pair) in marvell_vct5_amplitude() argument
1772 val = __phy_read(phydev, reg); in marvell_vct5_amplitude()
1796 static int marvell_vct5_amplitude_distance(struct phy_device *phydev, in marvell_vct5_amplitude_distance() argument
1804 err = __phy_write(phydev, MII_VCT5_SAMPLE_POINT_DISTANCE, in marvell_vct5_amplitude_distance()
1814 err = __phy_write(phydev, MII_VCT5_CTRL, reg); in marvell_vct5_amplitude_distance()
1818 err = marvell_vct5_wait_complete(phydev); in marvell_vct5_amplitude_distance()
1826 mV = marvell_vct5_amplitude(phydev, i); in marvell_vct5_amplitude_distance()
1827 ethnl_cable_test_amplitude(phydev, i, mV); in marvell_vct5_amplitude_distance()
1833 static int marvell_vct5_amplitude_graph(struct phy_device *phydev) in marvell_vct5_amplitude_graph() argument
1835 struct marvell_priv *priv = phydev->priv; in marvell_vct5_amplitude_graph()
1851 err = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct5_amplitude_graph()
1862 page = phy_select_page(phydev, MII_MARVELL_VCT5_PAGE); in marvell_vct5_amplitude_graph()
1869 err = marvell_vct5_amplitude_distance(phydev, distance, in marvell_vct5_amplitude_graph()
1880 err = __phy_write(phydev, MII_VCT5_TX_PULSE_CTRL, reg); in marvell_vct5_amplitude_graph()
1887 return phy_restore_page(phydev, page, err); in marvell_vct5_amplitude_graph()
1890 static int marvell_cable_test_start_common(struct phy_device *phydev) in marvell_cable_test_start_common() argument
1897 bmcr = phy_read(phydev, MII_BMCR); in marvell_cable_test_start_common()
1901 bmsr = phy_read(phydev, MII_BMSR); in marvell_cable_test_start_common()
1907 ret = phy_modify(phydev, MII_BMCR, BMCR_ANENABLE, 0); in marvell_cable_test_start_common()
1910 ret = genphy_soft_reset(phydev); in marvell_cable_test_start_common()
1922 static int marvell_vct7_cable_test_start(struct phy_device *phydev) in marvell_vct7_cable_test_start() argument
1924 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_start()
1927 ret = marvell_cable_test_start_common(phydev); in marvell_vct7_cable_test_start()
1936 ret = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct7_cable_test_start()
1945 ret = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct7_cable_test_start()
1950 return phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_start()
1956 static int marvell_vct5_cable_test_tdr_start(struct phy_device *phydev, in marvell_vct5_cable_test_tdr_start() argument
1959 struct marvell_priv *priv = phydev->priv; in marvell_vct5_cable_test_tdr_start()
1975 ret = phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct5_cable_test_tdr_start()
1980 ret = marvell_cable_test_start_common(phydev); in marvell_vct5_cable_test_tdr_start()
1984 ret = ethnl_cable_test_pulse(phydev, 1000); in marvell_vct5_cable_test_tdr_start()
1988 return ethnl_cable_test_step(phydev, in marvell_vct5_cable_test_tdr_start()
2013 static int marvell_vct7_report_length(struct phy_device *phydev, in marvell_vct7_report_length() argument
2019 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_report_length()
2026 ethnl_cable_test_fault_length(phydev, pair, length); in marvell_vct7_report_length()
2047 static int marvell_vct7_cable_test_report(struct phy_device *phydev) in marvell_vct7_cable_test_report() argument
2053 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_report()
2067 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, in marvell_vct7_cable_test_report()
2069 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_B, in marvell_vct7_cable_test_report()
2071 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_C, in marvell_vct7_cable_test_report()
2073 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_D, in marvell_vct7_cable_test_report()
2076 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, MII_VCT7_CTRL); in marvell_vct7_cable_test_report()
2083 marvell_vct7_report_length(phydev, 0, meter); in marvell_vct7_cable_test_report()
2085 marvell_vct7_report_length(phydev, 1, meter); in marvell_vct7_cable_test_report()
2087 marvell_vct7_report_length(phydev, 2, meter); in marvell_vct7_cable_test_report()
2089 marvell_vct7_report_length(phydev, 3, meter); in marvell_vct7_cable_test_report()
2094 static int marvell_vct7_cable_test_get_status(struct phy_device *phydev, in marvell_vct7_cable_test_get_status() argument
2097 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_get_status()
2101 ret = marvell_vct5_amplitude_graph(phydev); in marvell_vct7_cable_test_get_status()
2108 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_get_status()
2117 return marvell_vct7_cable_test_report(phydev); in marvell_vct7_cable_test_get_status()
2124 static int m88e1121_get_temp(struct phy_device *phydev, long *temp) in m88e1121_get_temp() argument
2132 oldpage = phy_select_page(phydev, MII_MARVELL_MISC_TEST_PAGE); in m88e1121_get_temp()
2137 ret = __phy_read(phydev, MII_88E1121_MISC_TEST); in m88e1121_get_temp()
2141 ret = __phy_write(phydev, MII_88E1121_MISC_TEST, in m88e1121_get_temp()
2149 val = __phy_read(phydev, MII_88E1121_MISC_TEST); in m88e1121_get_temp()
2156 ret = __phy_write(phydev, MII_88E1121_MISC_TEST, in m88e1121_get_temp()
2164 return phy_restore_page(phydev, oldpage, ret); in m88e1121_get_temp()
2171 struct phy_device *phydev = dev_get_drvdata(dev); in m88e1121_hwmon_read() local
2176 err = m88e1121_get_temp(phydev, temp); in m88e1121_hwmon_read()
2236 static int m88e1510_get_temp(struct phy_device *phydev, long *temp) in m88e1510_get_temp() argument
2242 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp()
2252 static int m88e1510_get_temp_critical(struct phy_device *phydev, long *temp) in m88e1510_get_temp_critical() argument
2258 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp_critical()
2271 static int m88e1510_set_temp_critical(struct phy_device *phydev, long temp) in m88e1510_set_temp_critical() argument
2276 return phy_modify_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_set_temp_critical()
2282 static int m88e1510_get_temp_alarm(struct phy_device *phydev, long *alarm) in m88e1510_get_temp_alarm() argument
2288 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp_alarm()
2302 struct phy_device *phydev = dev_get_drvdata(dev); in m88e1510_hwmon_read() local
2307 err = m88e1510_get_temp(phydev, temp); in m88e1510_hwmon_read()
2310 err = m88e1510_get_temp_critical(phydev, temp); in m88e1510_hwmon_read()
2313 err = m88e1510_get_temp_alarm(phydev, temp); in m88e1510_hwmon_read()
2326 struct phy_device *phydev = dev_get_drvdata(dev); in m88e1510_hwmon_write() local
2331 err = m88e1510_set_temp_critical(phydev, temp); in m88e1510_hwmon_write()
2384 static int m88e6390_get_temp(struct phy_device *phydev, long *temp) in m88e6390_get_temp() argument
2393 oldpage = phy_select_page(phydev, MII_MARVELL_MISC_TEST_PAGE); in m88e6390_get_temp()
2398 ret = __phy_read(phydev, MII_88E6390_MISC_TEST); in m88e6390_get_temp()
2406 ret = __phy_write(phydev, MII_88E6390_MISC_TEST, ret); in m88e6390_get_temp()
2417 ret = __phy_read(phydev, MII_88E6390_TEMP_SENSOR); in m88e6390_get_temp()
2427 ret = __phy_read(phydev, MII_88E6390_MISC_TEST); in m88e6390_get_temp()
2434 ret = __phy_write(phydev, MII_88E6390_MISC_TEST, ret); in m88e6390_get_temp()
2437 phy_restore_page(phydev, oldpage, ret); in m88e6390_get_temp()
2446 struct phy_device *phydev = dev_get_drvdata(dev); in m88e6390_hwmon_read() local
2451 err = m88e6390_get_temp(phydev, temp); in m88e6390_hwmon_read()
2501 static int marvell_hwmon_name(struct phy_device *phydev) in marvell_hwmon_name() argument
2503 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_name()
2504 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_name()
2521 static int marvell_hwmon_probe(struct phy_device *phydev, in marvell_hwmon_probe() argument
2524 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_probe()
2525 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_probe()
2528 err = marvell_hwmon_name(phydev); in marvell_hwmon_probe()
2533 dev, priv->hwmon_name, phydev, chip, NULL); in marvell_hwmon_probe()
2538 static int m88e1121_hwmon_probe(struct phy_device *phydev) in m88e1121_hwmon_probe() argument
2540 return marvell_hwmon_probe(phydev, &m88e1121_hwmon_chip_info); in m88e1121_hwmon_probe()
2543 static int m88e1510_hwmon_probe(struct phy_device *phydev) in m88e1510_hwmon_probe() argument
2545 return marvell_hwmon_probe(phydev, &m88e1510_hwmon_chip_info); in m88e1510_hwmon_probe()
2548 static int m88e6390_hwmon_probe(struct phy_device *phydev) in m88e6390_hwmon_probe() argument
2550 return marvell_hwmon_probe(phydev, &m88e6390_hwmon_chip_info); in m88e6390_hwmon_probe()
2553 static int m88e1121_hwmon_probe(struct phy_device *phydev) in m88e1121_hwmon_probe() argument
2558 static int m88e1510_hwmon_probe(struct phy_device *phydev) in m88e1510_hwmon_probe() argument
2563 static int m88e6390_hwmon_probe(struct phy_device *phydev) in m88e6390_hwmon_probe() argument
2569 static int marvell_probe(struct phy_device *phydev) in marvell_probe() argument
2573 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in marvell_probe()
2577 phydev->priv = priv; in marvell_probe()
2582 static int m88e1121_probe(struct phy_device *phydev) in m88e1121_probe() argument
2586 err = marvell_probe(phydev); in m88e1121_probe()
2590 return m88e1121_hwmon_probe(phydev); in m88e1121_probe()
2593 static int m88e1510_probe(struct phy_device *phydev) in m88e1510_probe() argument
2597 err = marvell_probe(phydev); in m88e1510_probe()
2601 return m88e1510_hwmon_probe(phydev); in m88e1510_probe()
2604 static int m88e6390_probe(struct phy_device *phydev) in m88e6390_probe() argument
2608 err = marvell_probe(phydev); in m88e6390_probe()
2612 return m88e6390_hwmon_probe(phydev); in m88e6390_probe()