Lines Matching refs:phydev

311 static int marvell_read_page(struct phy_device *phydev)  in marvell_read_page()  argument
313 return __phy_read(phydev, MII_MARVELL_PHY_PAGE); in marvell_read_page()
316 static int marvell_write_page(struct phy_device *phydev, int page) in marvell_write_page() argument
318 return __phy_write(phydev, MII_MARVELL_PHY_PAGE, page); in marvell_write_page()
321 static int marvell_set_page(struct phy_device *phydev, int page) in marvell_set_page() argument
323 return phy_write(phydev, MII_MARVELL_PHY_PAGE, page); in marvell_set_page()
326 static int marvell_ack_interrupt(struct phy_device *phydev) in marvell_ack_interrupt() argument
331 err = phy_read(phydev, MII_M1011_IEVENT); in marvell_ack_interrupt()
339 static int marvell_config_intr(struct phy_device *phydev) in marvell_config_intr() argument
343 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in marvell_config_intr()
344 err = marvell_ack_interrupt(phydev); in marvell_config_intr()
348 err = phy_write(phydev, MII_M1011_IMASK, in marvell_config_intr()
351 err = phy_write(phydev, MII_M1011_IMASK, in marvell_config_intr()
356 err = marvell_ack_interrupt(phydev); in marvell_config_intr()
362 static irqreturn_t marvell_handle_interrupt(struct phy_device *phydev) in marvell_handle_interrupt() argument
366 irq_status = phy_read(phydev, MII_M1011_IEVENT); in marvell_handle_interrupt()
368 phy_error(phydev); in marvell_handle_interrupt()
375 phy_trigger_machine(phydev); in marvell_handle_interrupt()
380 static int marvell_set_polarity(struct phy_device *phydev, int polarity) in marvell_set_polarity() argument
398 return phy_modify_changed(phydev, MII_M1011_PHY_SCR, in marvell_set_polarity()
402 static int marvell_config_aneg(struct phy_device *phydev) in marvell_config_aneg() argument
407 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in marvell_config_aneg()
413 err = phy_write(phydev, MII_M1111_PHY_LED_CONTROL, in marvell_config_aneg()
418 err = genphy_config_aneg(phydev); in marvell_config_aneg()
422 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in marvell_config_aneg()
427 err = genphy_soft_reset(phydev); in marvell_config_aneg()
435 static int m88e1101_config_aneg(struct phy_device *phydev) in m88e1101_config_aneg() argument
443 err = genphy_soft_reset(phydev); in m88e1101_config_aneg()
447 err = phy_write(phydev, 0x1d, 0x1f); in m88e1101_config_aneg()
451 err = phy_write(phydev, 0x1e, 0x200c); in m88e1101_config_aneg()
455 err = phy_write(phydev, 0x1d, 0x5); in m88e1101_config_aneg()
459 err = phy_write(phydev, 0x1e, 0); in m88e1101_config_aneg()
463 err = phy_write(phydev, 0x1e, 0x100); in m88e1101_config_aneg()
467 return marvell_config_aneg(phydev); in m88e1101_config_aneg()
484 static int marvell_of_reg_init(struct phy_device *phydev) in marvell_of_reg_init() argument
489 if (!phydev->mdio.dev.of_node) in marvell_of_reg_init()
492 paddr = of_get_property(phydev->mdio.dev.of_node, in marvell_of_reg_init()
497 saved_page = phy_save_page(phydev); in marvell_of_reg_init()
512 ret = marvell_write_page(phydev, page); in marvell_of_reg_init()
519 val = __phy_read(phydev, reg); in marvell_of_reg_init()
528 ret = __phy_write(phydev, reg, val); in marvell_of_reg_init()
533 return phy_restore_page(phydev, saved_page, ret); in marvell_of_reg_init()
536 static int marvell_of_reg_init(struct phy_device *phydev) in marvell_of_reg_init() argument
542 static int m88e1121_config_aneg_rgmii_delays(struct phy_device *phydev) in m88e1121_config_aneg_rgmii_delays() argument
546 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) in m88e1121_config_aneg_rgmii_delays()
549 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in m88e1121_config_aneg_rgmii_delays()
551 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in m88e1121_config_aneg_rgmii_delays()
556 return phy_modify_paged_changed(phydev, MII_MARVELL_MSCR_PAGE, in m88e1121_config_aneg_rgmii_delays()
561 static int m88e1121_config_aneg(struct phy_device *phydev) in m88e1121_config_aneg() argument
566 if (phy_interface_is_rgmii(phydev)) { in m88e1121_config_aneg()
567 err = m88e1121_config_aneg_rgmii_delays(phydev); in m88e1121_config_aneg()
574 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1121_config_aneg()
580 err = genphy_config_aneg(phydev); in m88e1121_config_aneg()
584 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in m88e1121_config_aneg()
588 err = genphy_soft_reset(phydev); in m88e1121_config_aneg()
596 static int m88e1318_config_aneg(struct phy_device *phydev) in m88e1318_config_aneg() argument
600 err = phy_modify_paged(phydev, MII_MARVELL_MSCR_PAGE, in m88e1318_config_aneg()
606 return m88e1121_config_aneg(phydev); in m88e1318_config_aneg()
644 static int marvell_config_aneg_fiber(struct phy_device *phydev) in marvell_config_aneg_fiber() argument
650 if (phydev->autoneg != AUTONEG_ENABLE) in marvell_config_aneg_fiber()
651 return genphy_setup_forced(phydev); in marvell_config_aneg_fiber()
654 linkmode_and(phydev->advertising, phydev->advertising, in marvell_config_aneg_fiber()
655 phydev->supported); in marvell_config_aneg_fiber()
657 adv = linkmode_adv_to_fiber_adv_t(phydev->advertising); in marvell_config_aneg_fiber()
660 err = phy_modify_changed(phydev, MII_ADVERTISE, in marvell_config_aneg_fiber()
669 return genphy_check_and_restart_aneg(phydev, changed); in marvell_config_aneg_fiber()
672 static int m88e1111_config_aneg(struct phy_device *phydev) in m88e1111_config_aneg() argument
674 int extsr = phy_read(phydev, MII_M1111_PHY_EXT_SR); in m88e1111_config_aneg()
683 if (phydev->interface != PHY_INTERFACE_MODE_SGMII && in m88e1111_config_aneg()
686 return marvell_config_aneg(phydev); in m88e1111_config_aneg()
688 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1111_config_aneg()
693 err = marvell_config_aneg(phydev); in m88e1111_config_aneg()
698 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in m88e1111_config_aneg()
702 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1111_config_aneg()
707 err = genphy_check_and_restart_aneg(phydev, false); in m88e1111_config_aneg()
709 err = marvell_config_aneg_fiber(phydev); in m88e1111_config_aneg()
713 return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1111_config_aneg()
716 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1111_config_aneg()
720 static int m88e1510_config_aneg(struct phy_device *phydev) in m88e1510_config_aneg() argument
724 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
729 err = m88e1318_config_aneg(phydev); in m88e1510_config_aneg()
734 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1510_config_aneg()
738 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in m88e1510_config_aneg()
742 err = marvell_config_aneg_fiber(phydev); in m88e1510_config_aneg()
746 return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
749 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
753 static void marvell_config_led(struct phy_device *phydev) in marvell_config_led() argument
758 switch (MARVELL_PHY_FAMILY_ID(phydev->phy_id)) { in marvell_config_led()
770 if (phydev->dev_flags & MARVELL_PHY_LED0_LINK_LED1_ACTIVE) in marvell_config_led()
779 err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE, MII_PHY_LED_CTRL, in marvell_config_led()
782 phydev_warn(phydev, "Fail to config marvell phy LED.\n"); in marvell_config_led()
785 static int marvell_config_init(struct phy_device *phydev) in marvell_config_init() argument
788 marvell_config_led(phydev); in marvell_config_init()
791 return marvell_of_reg_init(phydev); in marvell_config_init()
794 static int m88e3016_config_init(struct phy_device *phydev) in m88e3016_config_init() argument
799 ret = phy_modify(phydev, MII_88E3016_PHY_SPEC_CTRL, in m88e3016_config_init()
805 return marvell_config_init(phydev); in m88e3016_config_init()
808 static int m88e1111_config_init_hwcfg_mode(struct phy_device *phydev, in m88e1111_config_init_hwcfg_mode() argument
815 return phy_modify(phydev, MII_M1111_PHY_EXT_SR, in m88e1111_config_init_hwcfg_mode()
822 static int m88e1111_config_init_rgmii_delays(struct phy_device *phydev) in m88e1111_config_init_rgmii_delays() argument
826 switch (phydev->interface) { in m88e1111_config_init_rgmii_delays()
841 return phy_modify(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_config_init_rgmii_delays()
846 static int m88e1111_config_init_rgmii(struct phy_device *phydev) in m88e1111_config_init_rgmii() argument
851 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1111_config_init_rgmii()
855 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR); in m88e1111_config_init_rgmii()
866 return phy_write(phydev, MII_M1111_PHY_EXT_SR, temp); in m88e1111_config_init_rgmii()
869 static int m88e1111_config_init_sgmii(struct phy_device *phydev) in m88e1111_config_init_sgmii() argument
874 phydev, in m88e1111_config_init_sgmii()
881 return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1111_config_init_sgmii()
884 static int m88e1111_config_init_rtbi(struct phy_device *phydev) in m88e1111_config_init_rtbi() argument
888 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1111_config_init_rtbi()
893 phydev, in m88e1111_config_init_rtbi()
900 err = genphy_soft_reset(phydev); in m88e1111_config_init_rtbi()
905 phydev, in m88e1111_config_init_rtbi()
910 static int m88e1111_config_init_1000basex(struct phy_device *phydev) in m88e1111_config_init_1000basex() argument
912 int extsr = phy_read(phydev, MII_M1111_PHY_EXT_SR); in m88e1111_config_init_1000basex()
921 err = phy_modify(phydev, MII_M1111_PHY_EXT_SR, in m88e1111_config_init_1000basex()
932 static int m88e1111_config_init(struct phy_device *phydev) in m88e1111_config_init() argument
936 if (phy_interface_is_rgmii(phydev)) { in m88e1111_config_init()
937 err = m88e1111_config_init_rgmii(phydev); in m88e1111_config_init()
942 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1111_config_init()
943 err = m88e1111_config_init_sgmii(phydev); in m88e1111_config_init()
948 if (phydev->interface == PHY_INTERFACE_MODE_RTBI) { in m88e1111_config_init()
949 err = m88e1111_config_init_rtbi(phydev); in m88e1111_config_init()
954 if (phydev->interface == PHY_INTERFACE_MODE_1000BASEX) { in m88e1111_config_init()
955 err = m88e1111_config_init_1000basex(phydev); in m88e1111_config_init()
960 err = marvell_of_reg_init(phydev); in m88e1111_config_init()
964 err = genphy_soft_reset(phydev); in m88e1111_config_init()
968 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1111_config_init()
974 err = genphy_read_abilities(phydev); in m88e1111_config_init()
975 linkmode_or(phydev->advertising, phydev->advertising, in m88e1111_config_init()
976 phydev->supported); in m88e1111_config_init()
981 static int m88e1111_get_downshift(struct phy_device *phydev, u8 *data) in m88e1111_get_downshift() argument
985 val = phy_read(phydev, MII_M1111_PHY_EXT_CR); in m88e1111_get_downshift()
997 static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt) in m88e1111_set_downshift() argument
1005 err = phy_clear_bits(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_set_downshift()
1011 err = phy_modify(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_set_downshift()
1020 return genphy_soft_reset(phydev); in m88e1111_set_downshift()
1023 static int m88e1111_get_tunable(struct phy_device *phydev, in m88e1111_get_tunable() argument
1028 return m88e1111_get_downshift(phydev, data); in m88e1111_get_tunable()
1034 static int m88e1111_set_tunable(struct phy_device *phydev, in m88e1111_set_tunable() argument
1039 return m88e1111_set_downshift(phydev, *(const u8 *)data); in m88e1111_set_tunable()
1045 static int m88e1011_get_downshift(struct phy_device *phydev, u8 *data) in m88e1011_get_downshift() argument
1049 val = phy_read(phydev, MII_M1011_PHY_SCR); in m88e1011_get_downshift()
1061 static int m88e1011_set_downshift(struct phy_device *phydev, u8 cnt) in m88e1011_set_downshift() argument
1069 err = phy_clear_bits(phydev, MII_M1011_PHY_SCR, in m88e1011_set_downshift()
1075 err = phy_modify(phydev, MII_M1011_PHY_SCR, in m88e1011_set_downshift()
1084 return genphy_soft_reset(phydev); in m88e1011_set_downshift()
1087 static int m88e1011_get_tunable(struct phy_device *phydev, in m88e1011_get_tunable() argument
1092 return m88e1011_get_downshift(phydev, data); in m88e1011_get_tunable()
1098 static int m88e1011_set_tunable(struct phy_device *phydev, in m88e1011_set_tunable() argument
1103 return m88e1011_set_downshift(phydev, *(const u8 *)data); in m88e1011_set_tunable()
1109 static int m88e1112_config_init(struct phy_device *phydev) in m88e1112_config_init() argument
1113 err = m88e1011_set_downshift(phydev, 3); in m88e1112_config_init()
1117 return m88e1111_config_init(phydev); in m88e1112_config_init()
1120 static int m88e1111gbe_config_init(struct phy_device *phydev) in m88e1111gbe_config_init() argument
1124 err = m88e1111_set_downshift(phydev, 3); in m88e1111gbe_config_init()
1128 return m88e1111_config_init(phydev); in m88e1111gbe_config_init()
1131 static int marvell_1011gbe_config_init(struct phy_device *phydev) in marvell_1011gbe_config_init() argument
1135 err = m88e1011_set_downshift(phydev, 3); in marvell_1011gbe_config_init()
1139 return marvell_config_init(phydev); in marvell_1011gbe_config_init()
1141 static int m88e1116r_config_init(struct phy_device *phydev) in m88e1116r_config_init() argument
1145 err = genphy_soft_reset(phydev); in m88e1116r_config_init()
1151 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1116r_config_init()
1155 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1116r_config_init()
1159 err = m88e1011_set_downshift(phydev, 8); in m88e1116r_config_init()
1163 if (phy_interface_is_rgmii(phydev)) { in m88e1116r_config_init()
1164 err = m88e1121_config_aneg_rgmii_delays(phydev); in m88e1116r_config_init()
1169 err = genphy_soft_reset(phydev); in m88e1116r_config_init()
1173 return marvell_config_init(phydev); in m88e1116r_config_init()
1176 static int m88e1318_config_init(struct phy_device *phydev) in m88e1318_config_init() argument
1178 if (phy_interrupt_is_valid(phydev)) { in m88e1318_config_init()
1180 phydev, MII_MARVELL_LED_PAGE, in m88e1318_config_init()
1189 return marvell_config_init(phydev); in m88e1318_config_init()
1192 static int m88e1510_config_init(struct phy_device *phydev) in m88e1510_config_init() argument
1210 err = marvell_set_page(phydev, 0x00FF); in m88e1510_config_init()
1215 err = phy_write(phydev, 17, errata_vals[i].reg17); in m88e1510_config_init()
1218 err = phy_write(phydev, 16, errata_vals[i].reg16); in m88e1510_config_init()
1223 err = marvell_set_page(phydev, 0x00FB); in m88e1510_config_init()
1226 err = phy_write(phydev, 07, 0xC00D); in m88e1510_config_init()
1229 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_init()
1234 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1510_config_init()
1236 err = marvell_set_page(phydev, 18); in m88e1510_config_init()
1241 err = phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_config_init()
1248 err = phy_set_bits(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_config_init()
1254 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_init()
1258 err = m88e1011_set_downshift(phydev, 3); in m88e1510_config_init()
1262 return m88e1318_config_init(phydev); in m88e1510_config_init()
1265 static int m88e1118_config_aneg(struct phy_device *phydev) in m88e1118_config_aneg() argument
1269 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1118_config_aneg()
1273 err = genphy_config_aneg(phydev); in m88e1118_config_aneg()
1277 return genphy_soft_reset(phydev); in m88e1118_config_aneg()
1280 static int m88e1118_config_init(struct phy_device *phydev) in m88e1118_config_init() argument
1286 err = phy_write_paged(phydev, MII_MARVELL_MSCR_PAGE, in m88e1118_config_init()
1291 if (phy_interface_is_rgmii(phydev)) { in m88e1118_config_init()
1292 err = m88e1121_config_aneg_rgmii_delays(phydev); in m88e1118_config_init()
1298 if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS) in m88e1118_config_init()
1303 err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE, 0x10, leds); in m88e1118_config_init()
1307 err = marvell_of_reg_init(phydev); in m88e1118_config_init()
1312 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1118_config_init()
1316 return genphy_soft_reset(phydev); in m88e1118_config_init()
1319 static int m88e1149_config_init(struct phy_device *phydev) in m88e1149_config_init() argument
1324 err = marvell_set_page(phydev, MII_MARVELL_MSCR_PAGE); in m88e1149_config_init()
1329 err = phy_write(phydev, 0x15, 0x1048); in m88e1149_config_init()
1333 err = marvell_of_reg_init(phydev); in m88e1149_config_init()
1338 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1149_config_init()
1342 return genphy_soft_reset(phydev); in m88e1149_config_init()
1345 static int m88e1145_config_init_rgmii(struct phy_device *phydev) in m88e1145_config_init_rgmii() argument
1349 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1145_config_init_rgmii()
1353 if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) { in m88e1145_config_init_rgmii()
1354 err = phy_write(phydev, 0x1d, 0x0012); in m88e1145_config_init_rgmii()
1358 err = phy_modify(phydev, 0x1e, 0x0fc0, in m88e1145_config_init_rgmii()
1364 err = phy_write(phydev, 0x1d, 0x3); in m88e1145_config_init_rgmii()
1368 err = phy_write(phydev, 0x1e, 0x8000); in m88e1145_config_init_rgmii()
1373 static int m88e1145_config_init_sgmii(struct phy_device *phydev) in m88e1145_config_init_sgmii() argument
1376 phydev, MII_M1111_HWCFG_MODE_SGMII_NO_CLK, in m88e1145_config_init_sgmii()
1380 static int m88e1145_config_init(struct phy_device *phydev) in m88e1145_config_init() argument
1385 err = phy_write(phydev, 0x1d, 0x001b); in m88e1145_config_init()
1389 err = phy_write(phydev, 0x1e, 0x418f); in m88e1145_config_init()
1393 err = phy_write(phydev, 0x1d, 0x0016); in m88e1145_config_init()
1397 err = phy_write(phydev, 0x1e, 0xa2da); in m88e1145_config_init()
1401 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { in m88e1145_config_init()
1402 err = m88e1145_config_init_rgmii(phydev); in m88e1145_config_init()
1407 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1145_config_init()
1408 err = m88e1145_config_init_sgmii(phydev); in m88e1145_config_init()
1412 err = m88e1111_set_downshift(phydev, 3); in m88e1145_config_init()
1416 err = marvell_of_reg_init(phydev); in m88e1145_config_init()
1423 static int m88e1540_get_fld(struct phy_device *phydev, u8 *msecs) in m88e1540_get_fld() argument
1427 val = phy_read(phydev, MII_88E1540_COPPER_CTRL3); in m88e1540_get_fld()
1458 static int m88e1540_set_fld(struct phy_device *phydev, const u8 *msecs) in m88e1540_set_fld() argument
1464 return phy_clear_bits(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1470 ret = phy_ethtool_get_eee(phydev, &eee); in m88e1540_set_fld()
1472 phydev_warn(phydev, "Fast Link Down detection requires EEE to be disabled!\n"); in m88e1540_set_fld()
1487 ret = phy_modify(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1492 return phy_set_bits(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1496 static int m88e1540_get_tunable(struct phy_device *phydev, in m88e1540_get_tunable() argument
1501 return m88e1540_get_fld(phydev, data); in m88e1540_get_tunable()
1503 return m88e1011_get_downshift(phydev, data); in m88e1540_get_tunable()
1509 static int m88e1540_set_tunable(struct phy_device *phydev, in m88e1540_set_tunable() argument
1514 return m88e1540_set_fld(phydev, data); in m88e1540_set_tunable()
1516 return m88e1011_set_downshift(phydev, *(const u8 *)data); in m88e1540_set_tunable()
1526 static int m88e6390_errata(struct phy_device *phydev) in m88e6390_errata() argument
1530 err = phy_write(phydev, MII_BMCR, in m88e6390_errata()
1537 err = phy_write_paged(phydev, 0xf8, 0x08, 0x36); in m88e6390_errata()
1541 return genphy_soft_reset(phydev); in m88e6390_errata()
1544 static int m88e6390_config_aneg(struct phy_device *phydev) in m88e6390_config_aneg() argument
1548 err = m88e6390_errata(phydev); in m88e6390_config_aneg()
1552 return m88e1510_config_aneg(phydev); in m88e6390_config_aneg()
1573 static int marvell_read_status_page_an(struct phy_device *phydev, in marvell_read_status_page_an() argument
1580 phydev->link = 0; in marvell_read_status_page_an()
1585 phydev->duplex = DUPLEX_FULL; in marvell_read_status_page_an()
1587 phydev->duplex = DUPLEX_HALF; in marvell_read_status_page_an()
1591 phydev->speed = SPEED_1000; in marvell_read_status_page_an()
1595 phydev->speed = SPEED_100; in marvell_read_status_page_an()
1599 phydev->speed = SPEED_10; in marvell_read_status_page_an()
1604 err = genphy_read_lpa(phydev); in marvell_read_status_page_an()
1608 phy_resolve_aneg_pause(phydev); in marvell_read_status_page_an()
1610 lpa = phy_read(phydev, MII_LPA); in marvell_read_status_page_an()
1615 fiber_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); in marvell_read_status_page_an()
1617 if (phydev->duplex == DUPLEX_FULL) { in marvell_read_status_page_an()
1619 phydev->pause = 0; in marvell_read_status_page_an()
1620 phydev->asym_pause = 0; in marvell_read_status_page_an()
1622 phydev->pause = 1; in marvell_read_status_page_an()
1623 phydev->asym_pause = 1; in marvell_read_status_page_an()
1625 phydev->pause = 1; in marvell_read_status_page_an()
1626 phydev->asym_pause = 0; in marvell_read_status_page_an()
1642 static int marvell_read_status_page(struct phy_device *phydev, int page) in marvell_read_status_page() argument
1648 status = phy_read(phydev, MII_M1011_PHY_STATUS); in marvell_read_status_page()
1656 phydev->link = !!(status & MII_M1011_PHY_STATUS_LINK); in marvell_read_status_page()
1658 err = genphy_update_link(phydev); in marvell_read_status_page()
1668 linkmode_zero(phydev->lp_advertising); in marvell_read_status_page()
1669 phydev->pause = 0; in marvell_read_status_page()
1670 phydev->asym_pause = 0; in marvell_read_status_page()
1671 phydev->speed = SPEED_UNKNOWN; in marvell_read_status_page()
1672 phydev->duplex = DUPLEX_UNKNOWN; in marvell_read_status_page()
1673 phydev->port = fiber ? PORT_FIBRE : PORT_TP; in marvell_read_status_page()
1675 if (phydev->autoneg == AUTONEG_ENABLE) in marvell_read_status_page()
1676 err = marvell_read_status_page_an(phydev, fiber, status); in marvell_read_status_page()
1678 err = genphy_read_status_fixed(phydev); in marvell_read_status_page()
1692 static int marvell_read_status(struct phy_device *phydev) in marvell_read_status() argument
1698 phydev->supported) && in marvell_read_status()
1699 phydev->interface != PHY_INTERFACE_MODE_SGMII) { in marvell_read_status()
1700 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_read_status()
1704 err = marvell_read_status_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_read_status()
1715 if (phydev->link) in marvell_read_status()
1719 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1724 return marvell_read_status_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1727 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1736 static int marvell_suspend(struct phy_device *phydev) in marvell_suspend() argument
1742 phydev->supported)) { in marvell_suspend()
1743 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_suspend()
1748 err = genphy_suspend(phydev); in marvell_suspend()
1753 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_suspend()
1759 return genphy_suspend(phydev); in marvell_suspend()
1762 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_suspend()
1771 static int marvell_resume(struct phy_device *phydev) in marvell_resume() argument
1777 phydev->supported)) { in marvell_resume()
1778 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_resume()
1783 err = genphy_resume(phydev); in marvell_resume()
1788 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_resume()
1794 return genphy_resume(phydev); in marvell_resume()
1797 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_resume()
1801 static int marvell_aneg_done(struct phy_device *phydev) in marvell_aneg_done() argument
1803 int retval = phy_read(phydev, MII_M1011_PHY_STATUS); in marvell_aneg_done()
1808 static void m88e1318_get_wol(struct phy_device *phydev, in m88e1318_get_wol() argument
1816 ret = phy_read_paged(phydev, MII_MARVELL_WOL_PAGE, in m88e1318_get_wol()
1828 static int m88e1318_set_wol(struct phy_device *phydev, in m88e1318_set_wol() argument
1833 oldpage = phy_save_page(phydev); in m88e1318_set_wol()
1839 err = marvell_write_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1318_set_wol()
1849 if (!phy_interrupt_is_valid(phydev)) in m88e1318_set_wol()
1850 __phy_read(phydev, MII_M1011_IEVENT); in m88e1318_set_wol()
1853 err = __phy_set_bits(phydev, MII_88E1318S_PHY_CSIER, in m88e1318_set_wol()
1858 err = marvell_write_page(phydev, MII_MARVELL_LED_PAGE); in m88e1318_set_wol()
1863 err = __phy_modify(phydev, MII_88E1318S_PHY_LED_TCR, in m88e1318_set_wol()
1872 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1877 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD2, in m88e1318_set_wol()
1878 ((phydev->attached_dev->dev_addr[5] << 8) | in m88e1318_set_wol()
1879 phydev->attached_dev->dev_addr[4])); in m88e1318_set_wol()
1882 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD1, in m88e1318_set_wol()
1883 ((phydev->attached_dev->dev_addr[3] << 8) | in m88e1318_set_wol()
1884 phydev->attached_dev->dev_addr[2])); in m88e1318_set_wol()
1887 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD0, in m88e1318_set_wol()
1888 ((phydev->attached_dev->dev_addr[1] << 8) | in m88e1318_set_wol()
1889 phydev->attached_dev->dev_addr[0])); in m88e1318_set_wol()
1894 err = __phy_set_bits(phydev, MII_88E1318S_PHY_WOL_CTRL, in m88e1318_set_wol()
1900 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1905 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, in m88e1318_set_wol()
1913 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1918 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, 0, in m88e1318_set_wol()
1924 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1929 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, in m88e1318_set_wol()
1937 return phy_restore_page(phydev, oldpage, err); in m88e1318_set_wol()
1940 static int marvell_get_sset_count(struct phy_device *phydev) in marvell_get_sset_count() argument
1943 phydev->supported)) in marvell_get_sset_count()
1949 static void marvell_get_strings(struct phy_device *phydev, u8 *data) in marvell_get_strings() argument
1951 int count = marvell_get_sset_count(phydev); in marvell_get_strings()
1960 static u64 marvell_get_stat(struct phy_device *phydev, int i) in marvell_get_stat() argument
1963 struct marvell_priv *priv = phydev->priv; in marvell_get_stat()
1967 val = phy_read_paged(phydev, stat.page, stat.reg); in marvell_get_stat()
1979 static void marvell_get_stats(struct phy_device *phydev, in marvell_get_stats() argument
1982 int count = marvell_get_sset_count(phydev); in marvell_get_stats()
1986 data[i] = marvell_get_stat(phydev, i); in marvell_get_stats()
1989 static int m88e1510_loopback(struct phy_device *phydev, bool enable) in m88e1510_loopback() argument
1996 bmcr_ctl = mii_bmcr_encode_fixed(phydev->speed, phydev->duplex); in m88e1510_loopback()
1998 err = phy_write(phydev, MII_BMCR, bmcr_ctl); in m88e1510_loopback()
2002 if (phydev->speed == SPEED_1000) in m88e1510_loopback()
2004 else if (phydev->speed == SPEED_100) in m88e1510_loopback()
2007 err = phy_modify_paged(phydev, MII_MARVELL_MSCR_PAGE, in m88e1510_loopback()
2014 err = genphy_soft_reset(phydev); in m88e1510_loopback()
2018 err = phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK, in m88e1510_loopback()
2029 err = phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK, 0); in m88e1510_loopback()
2033 return phy_config_aneg(phydev); in m88e1510_loopback()
2037 static int marvell_vct5_wait_complete(struct phy_device *phydev) in marvell_vct5_wait_complete() argument
2043 val = __phy_read(phydev, MII_VCT5_CTRL); in marvell_vct5_wait_complete()
2051 phydev_err(phydev, "Timeout while waiting for cable test to finish\n"); in marvell_vct5_wait_complete()
2055 static int marvell_vct5_amplitude(struct phy_device *phydev, int pair) in marvell_vct5_amplitude() argument
2062 val = __phy_read(phydev, reg); in marvell_vct5_amplitude()
2086 static int marvell_vct5_amplitude_distance(struct phy_device *phydev, in marvell_vct5_amplitude_distance() argument
2094 err = __phy_write(phydev, MII_VCT5_SAMPLE_POINT_DISTANCE, in marvell_vct5_amplitude_distance()
2104 err = __phy_write(phydev, MII_VCT5_CTRL, reg); in marvell_vct5_amplitude_distance()
2108 err = marvell_vct5_wait_complete(phydev); in marvell_vct5_amplitude_distance()
2116 mV = marvell_vct5_amplitude(phydev, i); in marvell_vct5_amplitude_distance()
2117 ethnl_cable_test_amplitude(phydev, i, mV); in marvell_vct5_amplitude_distance()
2123 static int marvell_vct5_amplitude_graph(struct phy_device *phydev) in marvell_vct5_amplitude_graph() argument
2125 struct marvell_priv *priv = phydev->priv; in marvell_vct5_amplitude_graph()
2141 err = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct5_amplitude_graph()
2152 page = phy_select_page(phydev, MII_MARVELL_VCT5_PAGE); in marvell_vct5_amplitude_graph()
2159 err = marvell_vct5_amplitude_distance(phydev, distance, in marvell_vct5_amplitude_graph()
2170 err = __phy_write(phydev, MII_VCT5_TX_PULSE_CTRL, reg); in marvell_vct5_amplitude_graph()
2177 return phy_restore_page(phydev, page, err); in marvell_vct5_amplitude_graph()
2180 static int marvell_cable_test_start_common(struct phy_device *phydev) in marvell_cable_test_start_common() argument
2187 bmcr = phy_read(phydev, MII_BMCR); in marvell_cable_test_start_common()
2191 bmsr = phy_read(phydev, MII_BMSR); in marvell_cable_test_start_common()
2197 ret = phy_clear_bits(phydev, MII_BMCR, BMCR_ANENABLE); in marvell_cable_test_start_common()
2200 ret = genphy_soft_reset(phydev); in marvell_cable_test_start_common()
2212 static int marvell_vct7_cable_test_start(struct phy_device *phydev) in marvell_vct7_cable_test_start() argument
2214 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_start()
2217 ret = marvell_cable_test_start_common(phydev); in marvell_vct7_cable_test_start()
2226 ret = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct7_cable_test_start()
2235 ret = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct7_cable_test_start()
2240 return phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_start()
2246 static int marvell_vct5_cable_test_tdr_start(struct phy_device *phydev, in marvell_vct5_cable_test_tdr_start() argument
2249 struct marvell_priv *priv = phydev->priv; in marvell_vct5_cable_test_tdr_start()
2265 ret = phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct5_cable_test_tdr_start()
2270 ret = marvell_cable_test_start_common(phydev); in marvell_vct5_cable_test_tdr_start()
2274 ret = ethnl_cable_test_pulse(phydev, 1000); in marvell_vct5_cable_test_tdr_start()
2278 return ethnl_cable_test_step(phydev, in marvell_vct5_cable_test_tdr_start()
2303 static int marvell_vct7_report_length(struct phy_device *phydev, in marvell_vct7_report_length() argument
2309 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_report_length()
2316 ethnl_cable_test_fault_length(phydev, pair, length); in marvell_vct7_report_length()
2337 static int marvell_vct7_cable_test_report(struct phy_device *phydev) in marvell_vct7_cable_test_report() argument
2343 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_report()
2357 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, in marvell_vct7_cable_test_report()
2359 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_B, in marvell_vct7_cable_test_report()
2361 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_C, in marvell_vct7_cable_test_report()
2363 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_D, in marvell_vct7_cable_test_report()
2366 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, MII_VCT7_CTRL); in marvell_vct7_cable_test_report()
2373 marvell_vct7_report_length(phydev, 0, meter); in marvell_vct7_cable_test_report()
2375 marvell_vct7_report_length(phydev, 1, meter); in marvell_vct7_cable_test_report()
2377 marvell_vct7_report_length(phydev, 2, meter); in marvell_vct7_cable_test_report()
2379 marvell_vct7_report_length(phydev, 3, meter); in marvell_vct7_cable_test_report()
2384 static int marvell_vct7_cable_test_get_status(struct phy_device *phydev, in marvell_vct7_cable_test_get_status() argument
2387 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_get_status()
2391 ret = marvell_vct5_amplitude_graph(phydev); in marvell_vct7_cable_test_get_status()
2398 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_get_status()
2407 return marvell_vct7_cable_test_report(phydev); in marvell_vct7_cable_test_get_status()
2415 int (*config)(struct phy_device *phydev);
2416 int (*get_temp)(struct phy_device *phydev, long *temp);
2417 int (*get_temp_critical)(struct phy_device *phydev, long *temp);
2418 int (*set_temp_critical)(struct phy_device *phydev, long temp);
2419 int (*get_temp_alarm)(struct phy_device *phydev, long *alarm);
2423 to_marvell_hwmon_ops(const struct phy_device *phydev) in to_marvell_hwmon_ops() argument
2425 return phydev->drv->driver_data; in to_marvell_hwmon_ops()
2428 static int m88e1121_get_temp(struct phy_device *phydev, long *temp) in m88e1121_get_temp() argument
2436 oldpage = phy_select_page(phydev, MII_MARVELL_MISC_TEST_PAGE); in m88e1121_get_temp()
2441 ret = __phy_read(phydev, MII_88E1121_MISC_TEST); in m88e1121_get_temp()
2445 ret = __phy_write(phydev, MII_88E1121_MISC_TEST, in m88e1121_get_temp()
2453 val = __phy_read(phydev, MII_88E1121_MISC_TEST); in m88e1121_get_temp()
2460 ret = __phy_write(phydev, MII_88E1121_MISC_TEST, in m88e1121_get_temp()
2468 return phy_restore_page(phydev, oldpage, ret); in m88e1121_get_temp()
2471 static int m88e1510_get_temp(struct phy_device *phydev, long *temp) in m88e1510_get_temp() argument
2477 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp()
2487 static int m88e1510_get_temp_critical(struct phy_device *phydev, long *temp) in m88e1510_get_temp_critical() argument
2493 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp_critical()
2506 static int m88e1510_set_temp_critical(struct phy_device *phydev, long temp) in m88e1510_set_temp_critical() argument
2511 return phy_modify_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_set_temp_critical()
2517 static int m88e1510_get_temp_alarm(struct phy_device *phydev, long *alarm) in m88e1510_get_temp_alarm() argument
2523 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp_alarm()
2533 static int m88e6390_get_temp(struct phy_device *phydev, long *temp) in m88e6390_get_temp() argument
2542 oldpage = phy_select_page(phydev, MII_MARVELL_MISC_TEST_PAGE); in m88e6390_get_temp()
2547 ret = __phy_read(phydev, MII_88E6390_MISC_TEST); in m88e6390_get_temp()
2554 ret = __phy_write(phydev, MII_88E6390_MISC_TEST, ret); in m88e6390_get_temp()
2565 ret = __phy_read(phydev, MII_88E6390_TEMP_SENSOR); in m88e6390_get_temp()
2575 ret = __phy_read(phydev, MII_88E6390_MISC_TEST); in m88e6390_get_temp()
2582 ret = __phy_write(phydev, MII_88E6390_MISC_TEST, ret); in m88e6390_get_temp()
2585 phy_restore_page(phydev, oldpage, ret); in m88e6390_get_temp()
2590 static int m88e6393_get_temp(struct phy_device *phydev, long *temp) in m88e6393_get_temp() argument
2594 err = m88e1510_get_temp(phydev, temp); in m88e6393_get_temp()
2604 static int m88e6393_get_temp_critical(struct phy_device *phydev, long *temp) in m88e6393_get_temp_critical() argument
2610 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e6393_get_temp_critical()
2621 static int m88e6393_set_temp_critical(struct phy_device *phydev, long temp) in m88e6393_set_temp_critical() argument
2625 return phy_modify_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e6393_set_temp_critical()
2631 static int m88e6393_hwmon_config(struct phy_device *phydev) in m88e6393_hwmon_config() argument
2635 err = m88e6393_set_temp_critical(phydev, 100000); in m88e6393_hwmon_config()
2639 return phy_modify_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e6393_hwmon_config()
2652 struct phy_device *phydev = dev_get_drvdata(dev); in marvell_hwmon_read() local
2653 const struct marvell_hwmon_ops *ops = to_marvell_hwmon_ops(phydev); in marvell_hwmon_read()
2659 err = ops->get_temp(phydev, temp); in marvell_hwmon_read()
2663 err = ops->get_temp_critical(phydev, temp); in marvell_hwmon_read()
2667 err = ops->get_temp_alarm(phydev, temp); in marvell_hwmon_read()
2677 struct phy_device *phydev = dev_get_drvdata(dev); in marvell_hwmon_write() local
2678 const struct marvell_hwmon_ops *ops = to_marvell_hwmon_ops(phydev); in marvell_hwmon_write()
2684 err = ops->set_temp_critical(phydev, temp); in marvell_hwmon_write()
2695 const struct phy_device *phydev = data; in marvell_hwmon_is_visible() local
2696 const struct marvell_hwmon_ops *ops = to_marvell_hwmon_ops(phydev); in marvell_hwmon_is_visible()
2755 static int marvell_hwmon_name(struct phy_device *phydev) in marvell_hwmon_name() argument
2757 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_name()
2758 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_name()
2775 static int marvell_hwmon_probe(struct phy_device *phydev) in marvell_hwmon_probe() argument
2777 const struct marvell_hwmon_ops *ops = to_marvell_hwmon_ops(phydev); in marvell_hwmon_probe()
2778 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_probe()
2779 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_probe()
2785 err = marvell_hwmon_name(phydev); in marvell_hwmon_probe()
2790 dev, priv->hwmon_name, phydev, &marvell_hwmon_chip_info, NULL); in marvell_hwmon_probe()
2795 err = ops->config(phydev); in marvell_hwmon_probe()
2829 static int marvell_hwmon_probe(struct phy_device *phydev) in marvell_hwmon_probe() argument
2835 static int marvell_probe(struct phy_device *phydev) in marvell_probe() argument
2839 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in marvell_probe()
2843 phydev->priv = priv; in marvell_probe()
2845 return marvell_hwmon_probe(phydev); in marvell_probe()
2851 struct phy_device *phydev = upstream; in m88e1510_sfp_insert() local
2860 dev = &phydev->mdio.dev; in m88e1510_sfp_insert()
2862 sfp_parse_support(phydev->sfp_bus, id, supported, interfaces); in m88e1510_sfp_insert()
2863 interface = sfp_select_interface(phydev->sfp_bus, supported); in m88e1510_sfp_insert()
2886 oldpage = phy_select_page(phydev, MII_MARVELL_MODE_PAGE); in m88e1510_sfp_insert()
2890 ret = __phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_sfp_insert()
2895 ret = __phy_set_bits(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_sfp_insert()
2899 return phy_restore_page(phydev, oldpage, ret); in m88e1510_sfp_insert()
2904 struct phy_device *phydev = upstream; in m88e1510_sfp_remove() local
2908 oldpage = phy_select_page(phydev, MII_MARVELL_MODE_PAGE); in m88e1510_sfp_remove()
2912 ret = __phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_sfp_remove()
2918 ret = __phy_set_bits(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_sfp_remove()
2922 phy_restore_page(phydev, oldpage, ret); in m88e1510_sfp_remove()
2932 static int m88e1510_probe(struct phy_device *phydev) in m88e1510_probe() argument
2936 err = marvell_probe(phydev); in m88e1510_probe()
2940 return phy_sfp_probe(phydev, &m88e1510_sfp_ops); in m88e1510_probe()