• 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(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 err = phy_clear_bits(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_set_downshift()
876 err = phy_modify(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_set_downshift()
885 return genphy_soft_reset(phydev); in m88e1111_set_downshift()
888 static int m88e1111_get_tunable(struct phy_device *phydev, in m88e1111_get_tunable() argument
893 return m88e1111_get_downshift(phydev, data); in m88e1111_get_tunable()
899 static int m88e1111_set_tunable(struct phy_device *phydev, in m88e1111_set_tunable() argument
904 return m88e1111_set_downshift(phydev, *(const u8 *)data); in m88e1111_set_tunable()
910 static int m88e1011_get_downshift(struct phy_device *phydev, u8 *data) in m88e1011_get_downshift() argument
914 val = phy_read(phydev, MII_M1011_PHY_SCR); in m88e1011_get_downshift()
926 static int m88e1011_set_downshift(struct phy_device *phydev, u8 cnt) in m88e1011_set_downshift() argument
934 err = phy_clear_bits(phydev, MII_M1011_PHY_SCR, in m88e1011_set_downshift()
940 err = phy_modify(phydev, MII_M1011_PHY_SCR, in m88e1011_set_downshift()
949 return genphy_soft_reset(phydev); in m88e1011_set_downshift()
952 static int m88e1011_get_tunable(struct phy_device *phydev, in m88e1011_get_tunable() argument
957 return m88e1011_get_downshift(phydev, data); in m88e1011_get_tunable()
963 static int m88e1011_set_tunable(struct phy_device *phydev, in m88e1011_set_tunable() argument
968 return m88e1011_set_downshift(phydev, *(const u8 *)data); in m88e1011_set_tunable()
974 static int m88e1116r_config_init(struct phy_device *phydev) in m88e1116r_config_init() argument
978 err = genphy_soft_reset(phydev); in m88e1116r_config_init()
984 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1116r_config_init()
988 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1116r_config_init()
992 err = m88e1011_set_downshift(phydev, 8); in m88e1116r_config_init()
996 if (phy_interface_is_rgmii(phydev)) { in m88e1116r_config_init()
997 err = m88e1121_config_aneg_rgmii_delays(phydev); in m88e1116r_config_init()
1002 err = genphy_soft_reset(phydev); in m88e1116r_config_init()
1006 return marvell_config_init(phydev); in m88e1116r_config_init()
1009 static int m88e1318_config_init(struct phy_device *phydev) in m88e1318_config_init() argument
1011 if (phy_interrupt_is_valid(phydev)) { in m88e1318_config_init()
1013 phydev, MII_MARVELL_LED_PAGE, in m88e1318_config_init()
1022 return marvell_config_init(phydev); in m88e1318_config_init()
1025 static int m88e1510_config_init(struct phy_device *phydev) in m88e1510_config_init() argument
1030 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1510_config_init()
1032 err = marvell_set_page(phydev, 18); in m88e1510_config_init()
1037 err = phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_config_init()
1044 err = phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, 0, in m88e1510_config_init()
1050 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_init()
1055 return m88e1318_config_init(phydev); in m88e1510_config_init()
1058 static int m88e1118_config_aneg(struct phy_device *phydev) in m88e1118_config_aneg() argument
1062 err = genphy_soft_reset(phydev); in m88e1118_config_aneg()
1066 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1118_config_aneg()
1070 err = genphy_config_aneg(phydev); in m88e1118_config_aneg()
1074 static int m88e1118_config_init(struct phy_device *phydev) in m88e1118_config_init() argument
1079 err = marvell_set_page(phydev, MII_MARVELL_MSCR_PAGE); in m88e1118_config_init()
1084 err = phy_write(phydev, 0x15, 0x1070); in m88e1118_config_init()
1089 err = marvell_set_page(phydev, MII_MARVELL_LED_PAGE); in m88e1118_config_init()
1094 if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS) in m88e1118_config_init()
1095 err = phy_write(phydev, 0x10, 0x1100); in m88e1118_config_init()
1097 err = phy_write(phydev, 0x10, 0x021e); in m88e1118_config_init()
1101 err = marvell_of_reg_init(phydev); in m88e1118_config_init()
1106 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1118_config_init()
1110 return genphy_soft_reset(phydev); in m88e1118_config_init()
1113 static int m88e1149_config_init(struct phy_device *phydev) in m88e1149_config_init() argument
1118 err = marvell_set_page(phydev, MII_MARVELL_MSCR_PAGE); in m88e1149_config_init()
1123 err = phy_write(phydev, 0x15, 0x1048); in m88e1149_config_init()
1127 err = marvell_of_reg_init(phydev); in m88e1149_config_init()
1132 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1149_config_init()
1136 return genphy_soft_reset(phydev); in m88e1149_config_init()
1139 static int m88e1145_config_init_rgmii(struct phy_device *phydev) in m88e1145_config_init_rgmii() argument
1143 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1145_config_init_rgmii()
1147 if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) { in m88e1145_config_init_rgmii()
1148 err = phy_write(phydev, 0x1d, 0x0012); in m88e1145_config_init_rgmii()
1152 err = phy_modify(phydev, 0x1e, 0x0fc0, in m88e1145_config_init_rgmii()
1158 err = phy_write(phydev, 0x1d, 0x3); in m88e1145_config_init_rgmii()
1162 err = phy_write(phydev, 0x1e, 0x8000); in m88e1145_config_init_rgmii()
1167 static int m88e1145_config_init_sgmii(struct phy_device *phydev) in m88e1145_config_init_sgmii() argument
1170 phydev, MII_M1111_HWCFG_MODE_SGMII_NO_CLK, in m88e1145_config_init_sgmii()
1174 static int m88e1145_config_init(struct phy_device *phydev) in m88e1145_config_init() argument
1179 err = phy_write(phydev, 0x1d, 0x001b); in m88e1145_config_init()
1183 err = phy_write(phydev, 0x1e, 0x418f); in m88e1145_config_init()
1187 err = phy_write(phydev, 0x1d, 0x0016); in m88e1145_config_init()
1191 err = phy_write(phydev, 0x1e, 0xa2da); in m88e1145_config_init()
1195 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { in m88e1145_config_init()
1196 err = m88e1145_config_init_rgmii(phydev); in m88e1145_config_init()
1201 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1145_config_init()
1202 err = m88e1145_config_init_sgmii(phydev); in m88e1145_config_init()
1207 err = marvell_of_reg_init(phydev); in m88e1145_config_init()
1214 static int m88e1540_get_fld(struct phy_device *phydev, u8 *msecs) in m88e1540_get_fld() argument
1218 val = phy_read(phydev, MII_88E1540_COPPER_CTRL3); in m88e1540_get_fld()
1249 static int m88e1540_set_fld(struct phy_device *phydev, const u8 *msecs) in m88e1540_set_fld() argument
1255 return phy_clear_bits(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1261 ret = phy_ethtool_get_eee(phydev, &eee); in m88e1540_set_fld()
1263 phydev_warn(phydev, "Fast Link Down detection requires EEE to be disabled!\n"); in m88e1540_set_fld()
1278 ret = phy_modify(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1283 return phy_set_bits(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1287 static int m88e1540_get_tunable(struct phy_device *phydev, in m88e1540_get_tunable() argument
1292 return m88e1540_get_fld(phydev, data); in m88e1540_get_tunable()
1294 return m88e1011_get_downshift(phydev, data); in m88e1540_get_tunable()
1300 static int m88e1540_set_tunable(struct phy_device *phydev, in m88e1540_set_tunable() argument
1305 return m88e1540_set_fld(phydev, data); in m88e1540_set_tunable()
1307 return m88e1011_set_downshift(phydev, *(const u8 *)data); in m88e1540_set_tunable()
1317 static int m88e6390_errata(struct phy_device *phydev) in m88e6390_errata() argument
1321 err = phy_write(phydev, MII_BMCR, in m88e6390_errata()
1328 err = phy_write_paged(phydev, 0xf8, 0x08, 0x36); in m88e6390_errata()
1332 return genphy_soft_reset(phydev); in m88e6390_errata()
1335 static int m88e6390_config_aneg(struct phy_device *phydev) in m88e6390_config_aneg() argument
1339 err = m88e6390_errata(phydev); in m88e6390_config_aneg()
1343 return m88e1510_config_aneg(phydev); in m88e6390_config_aneg()
1364 static int marvell_read_status_page_an(struct phy_device *phydev, in marvell_read_status_page_an() argument
1371 phydev->link = 0; in marvell_read_status_page_an()
1376 phydev->duplex = DUPLEX_FULL; in marvell_read_status_page_an()
1378 phydev->duplex = DUPLEX_HALF; in marvell_read_status_page_an()
1382 phydev->speed = SPEED_1000; in marvell_read_status_page_an()
1386 phydev->speed = SPEED_100; in marvell_read_status_page_an()
1390 phydev->speed = SPEED_10; in marvell_read_status_page_an()
1395 err = genphy_read_lpa(phydev); in marvell_read_status_page_an()
1399 phy_resolve_aneg_pause(phydev); in marvell_read_status_page_an()
1401 lpa = phy_read(phydev, MII_LPA); in marvell_read_status_page_an()
1406 fiber_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); in marvell_read_status_page_an()
1408 if (phydev->duplex == DUPLEX_FULL) { in marvell_read_status_page_an()
1410 phydev->pause = 0; in marvell_read_status_page_an()
1411 phydev->asym_pause = 0; in marvell_read_status_page_an()
1413 phydev->pause = 1; in marvell_read_status_page_an()
1414 phydev->asym_pause = 1; in marvell_read_status_page_an()
1416 phydev->pause = 1; in marvell_read_status_page_an()
1417 phydev->asym_pause = 0; in marvell_read_status_page_an()
1433 static int marvell_read_status_page(struct phy_device *phydev, int page) in marvell_read_status_page() argument
1439 status = phy_read(phydev, MII_M1011_PHY_STATUS); in marvell_read_status_page()
1447 phydev->link = !!(status & MII_M1011_PHY_STATUS_LINK); in marvell_read_status_page()
1449 err = genphy_update_link(phydev); in marvell_read_status_page()
1459 linkmode_zero(phydev->lp_advertising); in marvell_read_status_page()
1460 phydev->pause = 0; in marvell_read_status_page()
1461 phydev->asym_pause = 0; in marvell_read_status_page()
1462 phydev->speed = SPEED_UNKNOWN; in marvell_read_status_page()
1463 phydev->duplex = DUPLEX_UNKNOWN; in marvell_read_status_page()
1464 phydev->port = fiber ? PORT_FIBRE : PORT_TP; in marvell_read_status_page()
1466 if (phydev->autoneg == AUTONEG_ENABLE) in marvell_read_status_page()
1467 err = marvell_read_status_page_an(phydev, fiber, status); in marvell_read_status_page()
1469 err = genphy_read_status_fixed(phydev); in marvell_read_status_page()
1483 static int marvell_read_status(struct phy_device *phydev) in marvell_read_status() argument
1489 phydev->supported) && in marvell_read_status()
1490 phydev->interface != PHY_INTERFACE_MODE_SGMII) { in marvell_read_status()
1491 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_read_status()
1495 err = marvell_read_status_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_read_status()
1506 if (phydev->link) in marvell_read_status()
1510 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1515 return marvell_read_status_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1518 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1527 static int marvell_suspend(struct phy_device *phydev) in marvell_suspend() argument
1533 phydev->supported)) { in marvell_suspend()
1534 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_suspend()
1539 err = genphy_suspend(phydev); in marvell_suspend()
1544 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_suspend()
1550 return genphy_suspend(phydev); in marvell_suspend()
1553 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_suspend()
1562 static int marvell_resume(struct phy_device *phydev) in marvell_resume() argument
1568 phydev->supported)) { in marvell_resume()
1569 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_resume()
1574 err = genphy_resume(phydev); in marvell_resume()
1579 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_resume()
1585 return genphy_resume(phydev); in marvell_resume()
1588 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_resume()
1592 static int marvell_aneg_done(struct phy_device *phydev) in marvell_aneg_done() argument
1594 int retval = phy_read(phydev, MII_M1011_PHY_STATUS); in marvell_aneg_done()
1599 static int m88e1121_did_interrupt(struct phy_device *phydev) in m88e1121_did_interrupt() argument
1603 imask = phy_read(phydev, MII_M1011_IEVENT); in m88e1121_did_interrupt()
1611 static void m88e1318_get_wol(struct phy_device *phydev, in m88e1318_get_wol() argument
1619 ret = phy_read_paged(phydev, MII_MARVELL_WOL_PAGE, in m88e1318_get_wol()
1625 static int m88e1318_set_wol(struct phy_device *phydev, in m88e1318_set_wol() argument
1630 oldpage = phy_save_page(phydev); in m88e1318_set_wol()
1636 err = marvell_write_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1318_set_wol()
1646 if (!phy_interrupt_is_valid(phydev)) in m88e1318_set_wol()
1647 __phy_read(phydev, MII_M1011_IEVENT); in m88e1318_set_wol()
1650 err = __phy_modify(phydev, MII_88E1318S_PHY_CSIER, 0, in m88e1318_set_wol()
1655 err = marvell_write_page(phydev, MII_MARVELL_LED_PAGE); in m88e1318_set_wol()
1660 err = __phy_modify(phydev, MII_88E1318S_PHY_LED_TCR, in m88e1318_set_wol()
1667 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1672 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD2, in m88e1318_set_wol()
1673 ((phydev->attached_dev->dev_addr[5] << 8) | in m88e1318_set_wol()
1674 phydev->attached_dev->dev_addr[4])); in m88e1318_set_wol()
1677 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD1, in m88e1318_set_wol()
1678 ((phydev->attached_dev->dev_addr[3] << 8) | in m88e1318_set_wol()
1679 phydev->attached_dev->dev_addr[2])); in m88e1318_set_wol()
1682 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD0, in m88e1318_set_wol()
1683 ((phydev->attached_dev->dev_addr[1] << 8) | in m88e1318_set_wol()
1684 phydev->attached_dev->dev_addr[0])); in m88e1318_set_wol()
1689 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, 0, in m88e1318_set_wol()
1695 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1700 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, in m88e1318_set_wol()
1708 return phy_restore_page(phydev, oldpage, err); in m88e1318_set_wol()
1711 static int marvell_get_sset_count(struct phy_device *phydev) in marvell_get_sset_count() argument
1714 phydev->supported)) in marvell_get_sset_count()
1720 static void marvell_get_strings(struct phy_device *phydev, u8 *data) in marvell_get_strings() argument
1722 int count = marvell_get_sset_count(phydev); in marvell_get_strings()
1731 static u64 marvell_get_stat(struct phy_device *phydev, int i) in marvell_get_stat() argument
1734 struct marvell_priv *priv = phydev->priv; in marvell_get_stat()
1738 val = phy_read_paged(phydev, stat.page, stat.reg); in marvell_get_stat()
1750 static void marvell_get_stats(struct phy_device *phydev, in marvell_get_stats() argument
1753 int count = marvell_get_sset_count(phydev); in marvell_get_stats()
1757 data[i] = marvell_get_stat(phydev, i); in marvell_get_stats()
1760 static int marvell_vct5_wait_complete(struct phy_device *phydev) in marvell_vct5_wait_complete() argument
1766 val = __phy_read(phydev, MII_VCT5_CTRL); in marvell_vct5_wait_complete()
1774 phydev_err(phydev, "Timeout while waiting for cable test to finish\n"); in marvell_vct5_wait_complete()
1778 static int marvell_vct5_amplitude(struct phy_device *phydev, int pair) in marvell_vct5_amplitude() argument
1785 val = __phy_read(phydev, reg); in marvell_vct5_amplitude()
1809 static int marvell_vct5_amplitude_distance(struct phy_device *phydev, in marvell_vct5_amplitude_distance() argument
1817 err = __phy_write(phydev, MII_VCT5_SAMPLE_POINT_DISTANCE, in marvell_vct5_amplitude_distance()
1827 err = __phy_write(phydev, MII_VCT5_CTRL, reg); in marvell_vct5_amplitude_distance()
1831 err = marvell_vct5_wait_complete(phydev); in marvell_vct5_amplitude_distance()
1839 mV = marvell_vct5_amplitude(phydev, i); in marvell_vct5_amplitude_distance()
1840 ethnl_cable_test_amplitude(phydev, i, mV); in marvell_vct5_amplitude_distance()
1846 static int marvell_vct5_amplitude_graph(struct phy_device *phydev) in marvell_vct5_amplitude_graph() argument
1848 struct marvell_priv *priv = phydev->priv; in marvell_vct5_amplitude_graph()
1864 err = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct5_amplitude_graph()
1875 page = phy_select_page(phydev, MII_MARVELL_VCT5_PAGE); in marvell_vct5_amplitude_graph()
1882 err = marvell_vct5_amplitude_distance(phydev, distance, in marvell_vct5_amplitude_graph()
1893 err = __phy_write(phydev, MII_VCT5_TX_PULSE_CTRL, reg); in marvell_vct5_amplitude_graph()
1900 return phy_restore_page(phydev, page, err); in marvell_vct5_amplitude_graph()
1903 static int marvell_cable_test_start_common(struct phy_device *phydev) in marvell_cable_test_start_common() argument
1910 bmcr = phy_read(phydev, MII_BMCR); in marvell_cable_test_start_common()
1914 bmsr = phy_read(phydev, MII_BMSR); in marvell_cable_test_start_common()
1920 ret = phy_modify(phydev, MII_BMCR, BMCR_ANENABLE, 0); in marvell_cable_test_start_common()
1923 ret = genphy_soft_reset(phydev); in marvell_cable_test_start_common()
1935 static int marvell_vct7_cable_test_start(struct phy_device *phydev) in marvell_vct7_cable_test_start() argument
1937 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_start()
1940 ret = marvell_cable_test_start_common(phydev); in marvell_vct7_cable_test_start()
1949 ret = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct7_cable_test_start()
1958 ret = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct7_cable_test_start()
1963 return phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_start()
1969 static int marvell_vct5_cable_test_tdr_start(struct phy_device *phydev, in marvell_vct5_cable_test_tdr_start() argument
1972 struct marvell_priv *priv = phydev->priv; in marvell_vct5_cable_test_tdr_start()
1988 ret = phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct5_cable_test_tdr_start()
1993 ret = marvell_cable_test_start_common(phydev); in marvell_vct5_cable_test_tdr_start()
1997 ret = ethnl_cable_test_pulse(phydev, 1000); in marvell_vct5_cable_test_tdr_start()
2001 return ethnl_cable_test_step(phydev, in marvell_vct5_cable_test_tdr_start()
2026 static int marvell_vct7_report_length(struct phy_device *phydev, in marvell_vct7_report_length() argument
2032 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_report_length()
2039 ethnl_cable_test_fault_length(phydev, pair, length); in marvell_vct7_report_length()
2060 static int marvell_vct7_cable_test_report(struct phy_device *phydev) in marvell_vct7_cable_test_report() argument
2066 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_report()
2080 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, in marvell_vct7_cable_test_report()
2082 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_B, in marvell_vct7_cable_test_report()
2084 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_C, in marvell_vct7_cable_test_report()
2086 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_D, in marvell_vct7_cable_test_report()
2089 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, MII_VCT7_CTRL); in marvell_vct7_cable_test_report()
2096 marvell_vct7_report_length(phydev, 0, meter); in marvell_vct7_cable_test_report()
2098 marvell_vct7_report_length(phydev, 1, meter); in marvell_vct7_cable_test_report()
2100 marvell_vct7_report_length(phydev, 2, meter); in marvell_vct7_cable_test_report()
2102 marvell_vct7_report_length(phydev, 3, meter); in marvell_vct7_cable_test_report()
2107 static int marvell_vct7_cable_test_get_status(struct phy_device *phydev, in marvell_vct7_cable_test_get_status() argument
2110 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_get_status()
2114 ret = marvell_vct5_amplitude_graph(phydev); in marvell_vct7_cable_test_get_status()
2121 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_get_status()
2130 return marvell_vct7_cable_test_report(phydev); in marvell_vct7_cable_test_get_status()
2137 static int m88e1121_get_temp(struct phy_device *phydev, long *temp) in m88e1121_get_temp() argument
2145 oldpage = phy_select_page(phydev, MII_MARVELL_MISC_TEST_PAGE); in m88e1121_get_temp()
2150 ret = __phy_read(phydev, MII_88E1121_MISC_TEST); in m88e1121_get_temp()
2154 ret = __phy_write(phydev, MII_88E1121_MISC_TEST, in m88e1121_get_temp()
2162 val = __phy_read(phydev, MII_88E1121_MISC_TEST); in m88e1121_get_temp()
2169 ret = __phy_write(phydev, MII_88E1121_MISC_TEST, in m88e1121_get_temp()
2177 return phy_restore_page(phydev, oldpage, ret); in m88e1121_get_temp()
2184 struct phy_device *phydev = dev_get_drvdata(dev); in m88e1121_hwmon_read() local
2189 err = m88e1121_get_temp(phydev, temp); in m88e1121_hwmon_read()
2249 static int m88e1510_get_temp(struct phy_device *phydev, long *temp) in m88e1510_get_temp() argument
2255 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp()
2265 static int m88e1510_get_temp_critical(struct phy_device *phydev, long *temp) in m88e1510_get_temp_critical() argument
2271 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp_critical()
2284 static int m88e1510_set_temp_critical(struct phy_device *phydev, long temp) in m88e1510_set_temp_critical() argument
2289 return phy_modify_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_set_temp_critical()
2295 static int m88e1510_get_temp_alarm(struct phy_device *phydev, long *alarm) in m88e1510_get_temp_alarm() argument
2301 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp_alarm()
2315 struct phy_device *phydev = dev_get_drvdata(dev); in m88e1510_hwmon_read() local
2320 err = m88e1510_get_temp(phydev, temp); in m88e1510_hwmon_read()
2323 err = m88e1510_get_temp_critical(phydev, temp); in m88e1510_hwmon_read()
2326 err = m88e1510_get_temp_alarm(phydev, temp); in m88e1510_hwmon_read()
2339 struct phy_device *phydev = dev_get_drvdata(dev); in m88e1510_hwmon_write() local
2344 err = m88e1510_set_temp_critical(phydev, temp); in m88e1510_hwmon_write()
2397 static int m88e6390_get_temp(struct phy_device *phydev, long *temp) in m88e6390_get_temp() argument
2406 oldpage = phy_select_page(phydev, MII_MARVELL_MISC_TEST_PAGE); in m88e6390_get_temp()
2411 ret = __phy_read(phydev, MII_88E6390_MISC_TEST); in m88e6390_get_temp()
2419 ret = __phy_write(phydev, MII_88E6390_MISC_TEST, ret); in m88e6390_get_temp()
2430 ret = __phy_read(phydev, MII_88E6390_TEMP_SENSOR); in m88e6390_get_temp()
2440 ret = __phy_read(phydev, MII_88E6390_MISC_TEST); in m88e6390_get_temp()
2447 ret = __phy_write(phydev, MII_88E6390_MISC_TEST, ret); in m88e6390_get_temp()
2450 phy_restore_page(phydev, oldpage, ret); in m88e6390_get_temp()
2459 struct phy_device *phydev = dev_get_drvdata(dev); in m88e6390_hwmon_read() local
2464 err = m88e6390_get_temp(phydev, temp); in m88e6390_hwmon_read()
2514 static int marvell_hwmon_name(struct phy_device *phydev) in marvell_hwmon_name() argument
2516 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_name()
2517 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_name()
2534 static int marvell_hwmon_probe(struct phy_device *phydev, in marvell_hwmon_probe() argument
2537 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_probe()
2538 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_probe()
2541 err = marvell_hwmon_name(phydev); in marvell_hwmon_probe()
2546 dev, priv->hwmon_name, phydev, chip, NULL); in marvell_hwmon_probe()
2551 static int m88e1121_hwmon_probe(struct phy_device *phydev) in m88e1121_hwmon_probe() argument
2553 return marvell_hwmon_probe(phydev, &m88e1121_hwmon_chip_info); in m88e1121_hwmon_probe()
2556 static int m88e1510_hwmon_probe(struct phy_device *phydev) in m88e1510_hwmon_probe() argument
2558 return marvell_hwmon_probe(phydev, &m88e1510_hwmon_chip_info); in m88e1510_hwmon_probe()
2561 static int m88e6390_hwmon_probe(struct phy_device *phydev) in m88e6390_hwmon_probe() argument
2563 return marvell_hwmon_probe(phydev, &m88e6390_hwmon_chip_info); in m88e6390_hwmon_probe()
2566 static int m88e1121_hwmon_probe(struct phy_device *phydev) in m88e1121_hwmon_probe() argument
2571 static int m88e1510_hwmon_probe(struct phy_device *phydev) in m88e1510_hwmon_probe() argument
2576 static int m88e6390_hwmon_probe(struct phy_device *phydev) in m88e6390_hwmon_probe() argument
2582 static int marvell_probe(struct phy_device *phydev) in marvell_probe() argument
2586 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in marvell_probe()
2590 phydev->priv = priv; in marvell_probe()
2595 static int m88e1121_probe(struct phy_device *phydev) in m88e1121_probe() argument
2599 err = marvell_probe(phydev); in m88e1121_probe()
2603 return m88e1121_hwmon_probe(phydev); in m88e1121_probe()
2606 static int m88e1510_probe(struct phy_device *phydev) in m88e1510_probe() argument
2610 err = marvell_probe(phydev); in m88e1510_probe()
2614 return m88e1510_hwmon_probe(phydev); in m88e1510_probe()
2617 static int m88e6390_probe(struct phy_device *phydev) in m88e6390_probe() argument
2621 err = marvell_probe(phydev); in m88e6390_probe()
2625 return m88e6390_hwmon_probe(phydev); in m88e6390_probe()