Lines Matching refs:phydev
309 static int marvell_read_page(struct phy_device *phydev) in marvell_read_page() argument
311 return __phy_read(phydev, MII_MARVELL_PHY_PAGE); in marvell_read_page()
314 static int marvell_write_page(struct phy_device *phydev, int page) in marvell_write_page() argument
316 return __phy_write(phydev, MII_MARVELL_PHY_PAGE, page); in marvell_write_page()
319 static int marvell_set_page(struct phy_device *phydev, int page) in marvell_set_page() argument
321 return phy_write(phydev, MII_MARVELL_PHY_PAGE, page); in marvell_set_page()
324 static int marvell_ack_interrupt(struct phy_device *phydev) in marvell_ack_interrupt() argument
329 err = phy_read(phydev, MII_M1011_IEVENT); in marvell_ack_interrupt()
337 static int marvell_config_intr(struct phy_device *phydev) in marvell_config_intr() argument
341 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in marvell_config_intr()
342 err = marvell_ack_interrupt(phydev); in marvell_config_intr()
346 err = phy_write(phydev, MII_M1011_IMASK, in marvell_config_intr()
349 err = phy_write(phydev, MII_M1011_IMASK, in marvell_config_intr()
354 err = marvell_ack_interrupt(phydev); in marvell_config_intr()
360 static irqreturn_t marvell_handle_interrupt(struct phy_device *phydev) in marvell_handle_interrupt() argument
364 irq_status = phy_read(phydev, MII_M1011_IEVENT); in marvell_handle_interrupt()
366 phy_error(phydev); in marvell_handle_interrupt()
373 phy_trigger_machine(phydev); in marvell_handle_interrupt()
378 static int marvell_set_polarity(struct phy_device *phydev, int polarity) in marvell_set_polarity() argument
396 return phy_modify_changed(phydev, MII_M1011_PHY_SCR, in marvell_set_polarity()
400 static int marvell_config_aneg(struct phy_device *phydev) in marvell_config_aneg() argument
405 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in marvell_config_aneg()
411 err = phy_write(phydev, MII_M1111_PHY_LED_CONTROL, in marvell_config_aneg()
416 err = genphy_config_aneg(phydev); in marvell_config_aneg()
420 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in marvell_config_aneg()
425 err = genphy_soft_reset(phydev); in marvell_config_aneg()
433 static int m88e1101_config_aneg(struct phy_device *phydev) in m88e1101_config_aneg() argument
441 err = genphy_soft_reset(phydev); in m88e1101_config_aneg()
445 err = phy_write(phydev, 0x1d, 0x1f); in m88e1101_config_aneg()
449 err = phy_write(phydev, 0x1e, 0x200c); in m88e1101_config_aneg()
453 err = phy_write(phydev, 0x1d, 0x5); in m88e1101_config_aneg()
457 err = phy_write(phydev, 0x1e, 0); in m88e1101_config_aneg()
461 err = phy_write(phydev, 0x1e, 0x100); in m88e1101_config_aneg()
465 return marvell_config_aneg(phydev); in m88e1101_config_aneg()
482 static int marvell_of_reg_init(struct phy_device *phydev) in marvell_of_reg_init() argument
487 if (!phydev->mdio.dev.of_node) in marvell_of_reg_init()
490 paddr = of_get_property(phydev->mdio.dev.of_node, in marvell_of_reg_init()
495 saved_page = phy_save_page(phydev); in marvell_of_reg_init()
510 ret = marvell_write_page(phydev, page); in marvell_of_reg_init()
517 val = __phy_read(phydev, reg); in marvell_of_reg_init()
526 ret = __phy_write(phydev, reg, val); in marvell_of_reg_init()
531 return phy_restore_page(phydev, saved_page, ret); in marvell_of_reg_init()
534 static int marvell_of_reg_init(struct phy_device *phydev) in marvell_of_reg_init() argument
540 static int m88e1121_config_aneg_rgmii_delays(struct phy_device *phydev) in m88e1121_config_aneg_rgmii_delays() argument
544 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) in m88e1121_config_aneg_rgmii_delays()
547 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in m88e1121_config_aneg_rgmii_delays()
549 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in m88e1121_config_aneg_rgmii_delays()
554 return phy_modify_paged(phydev, MII_MARVELL_MSCR_PAGE, in m88e1121_config_aneg_rgmii_delays()
559 static int m88e1121_config_aneg(struct phy_device *phydev) in m88e1121_config_aneg() argument
564 if (phy_interface_is_rgmii(phydev)) { in m88e1121_config_aneg()
565 err = m88e1121_config_aneg_rgmii_delays(phydev); in m88e1121_config_aneg()
570 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1121_config_aneg()
576 err = genphy_config_aneg(phydev); in m88e1121_config_aneg()
580 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in m88e1121_config_aneg()
584 err = genphy_soft_reset(phydev); in m88e1121_config_aneg()
592 static int m88e1318_config_aneg(struct phy_device *phydev) in m88e1318_config_aneg() argument
596 err = phy_modify_paged(phydev, MII_MARVELL_MSCR_PAGE, in m88e1318_config_aneg()
602 return m88e1121_config_aneg(phydev); in m88e1318_config_aneg()
640 static int marvell_config_aneg_fiber(struct phy_device *phydev) in marvell_config_aneg_fiber() argument
646 if (phydev->autoneg != AUTONEG_ENABLE) in marvell_config_aneg_fiber()
647 return genphy_setup_forced(phydev); in marvell_config_aneg_fiber()
650 linkmode_and(phydev->advertising, phydev->advertising, in marvell_config_aneg_fiber()
651 phydev->supported); in marvell_config_aneg_fiber()
653 adv = linkmode_adv_to_fiber_adv_t(phydev->advertising); in marvell_config_aneg_fiber()
656 err = phy_modify_changed(phydev, MII_ADVERTISE, in marvell_config_aneg_fiber()
665 return genphy_check_and_restart_aneg(phydev, changed); in marvell_config_aneg_fiber()
668 static int m88e1111_config_aneg(struct phy_device *phydev) in m88e1111_config_aneg() argument
670 int extsr = phy_read(phydev, MII_M1111_PHY_EXT_SR); in m88e1111_config_aneg()
679 if (phydev->interface != PHY_INTERFACE_MODE_SGMII && in m88e1111_config_aneg()
682 return marvell_config_aneg(phydev); in m88e1111_config_aneg()
684 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1111_config_aneg()
689 err = marvell_config_aneg(phydev); in m88e1111_config_aneg()
694 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in m88e1111_config_aneg()
698 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1111_config_aneg()
703 err = genphy_check_and_restart_aneg(phydev, false); in m88e1111_config_aneg()
705 err = marvell_config_aneg_fiber(phydev); in m88e1111_config_aneg()
709 return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1111_config_aneg()
712 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1111_config_aneg()
716 static int m88e1510_config_aneg(struct phy_device *phydev) in m88e1510_config_aneg() argument
720 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
725 err = m88e1318_config_aneg(phydev); in m88e1510_config_aneg()
730 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1510_config_aneg()
734 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in m88e1510_config_aneg()
738 err = marvell_config_aneg_fiber(phydev); in m88e1510_config_aneg()
742 return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
745 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
749 static void marvell_config_led(struct phy_device *phydev) in marvell_config_led() argument
754 switch (MARVELL_PHY_FAMILY_ID(phydev->phy_id)) { in marvell_config_led()
766 if (phydev->dev_flags & MARVELL_PHY_LED0_LINK_LED1_ACTIVE) in marvell_config_led()
775 err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE, MII_PHY_LED_CTRL, in marvell_config_led()
778 phydev_warn(phydev, "Fail to config marvell phy LED.\n"); in marvell_config_led()
781 static int marvell_config_init(struct phy_device *phydev) in marvell_config_init() argument
784 marvell_config_led(phydev); in marvell_config_init()
787 return marvell_of_reg_init(phydev); in marvell_config_init()
790 static int m88e3016_config_init(struct phy_device *phydev) in m88e3016_config_init() argument
795 ret = phy_modify(phydev, MII_88E3016_PHY_SPEC_CTRL, in m88e3016_config_init()
801 return marvell_config_init(phydev); in m88e3016_config_init()
804 static int m88e1111_config_init_hwcfg_mode(struct phy_device *phydev, in m88e1111_config_init_hwcfg_mode() argument
811 return phy_modify(phydev, MII_M1111_PHY_EXT_SR, in m88e1111_config_init_hwcfg_mode()
818 static int m88e1111_config_init_rgmii_delays(struct phy_device *phydev) in m88e1111_config_init_rgmii_delays() argument
822 switch (phydev->interface) { in m88e1111_config_init_rgmii_delays()
837 return phy_modify(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_config_init_rgmii_delays()
842 static int m88e1111_config_init_rgmii(struct phy_device *phydev) in m88e1111_config_init_rgmii() argument
847 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1111_config_init_rgmii()
851 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR); in m88e1111_config_init_rgmii()
862 return phy_write(phydev, MII_M1111_PHY_EXT_SR, temp); in m88e1111_config_init_rgmii()
865 static int m88e1111_config_init_sgmii(struct phy_device *phydev) in m88e1111_config_init_sgmii() argument
870 phydev, in m88e1111_config_init_sgmii()
877 return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1111_config_init_sgmii()
880 static int m88e1111_config_init_rtbi(struct phy_device *phydev) in m88e1111_config_init_rtbi() argument
884 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1111_config_init_rtbi()
889 phydev, in m88e1111_config_init_rtbi()
896 err = genphy_soft_reset(phydev); in m88e1111_config_init_rtbi()
901 phydev, in m88e1111_config_init_rtbi()
906 static int m88e1111_config_init_1000basex(struct phy_device *phydev) in m88e1111_config_init_1000basex() argument
908 int extsr = phy_read(phydev, MII_M1111_PHY_EXT_SR); in m88e1111_config_init_1000basex()
917 err = phy_modify(phydev, MII_M1111_PHY_EXT_SR, in m88e1111_config_init_1000basex()
928 static int m88e1111_config_init(struct phy_device *phydev) in m88e1111_config_init() argument
932 if (phy_interface_is_rgmii(phydev)) { in m88e1111_config_init()
933 err = m88e1111_config_init_rgmii(phydev); in m88e1111_config_init()
938 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1111_config_init()
939 err = m88e1111_config_init_sgmii(phydev); in m88e1111_config_init()
944 if (phydev->interface == PHY_INTERFACE_MODE_RTBI) { in m88e1111_config_init()
945 err = m88e1111_config_init_rtbi(phydev); in m88e1111_config_init()
950 if (phydev->interface == PHY_INTERFACE_MODE_1000BASEX) { in m88e1111_config_init()
951 err = m88e1111_config_init_1000basex(phydev); in m88e1111_config_init()
956 err = marvell_of_reg_init(phydev); in m88e1111_config_init()
960 return genphy_soft_reset(phydev); in m88e1111_config_init()
963 static int m88e1111_get_downshift(struct phy_device *phydev, u8 *data) in m88e1111_get_downshift() argument
967 val = phy_read(phydev, MII_M1111_PHY_EXT_CR); in m88e1111_get_downshift()
979 static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt) in m88e1111_set_downshift() argument
987 err = phy_clear_bits(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_set_downshift()
993 err = phy_modify(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_set_downshift()
1002 return genphy_soft_reset(phydev); in m88e1111_set_downshift()
1005 static int m88e1111_get_tunable(struct phy_device *phydev, in m88e1111_get_tunable() argument
1010 return m88e1111_get_downshift(phydev, data); in m88e1111_get_tunable()
1016 static int m88e1111_set_tunable(struct phy_device *phydev, in m88e1111_set_tunable() argument
1021 return m88e1111_set_downshift(phydev, *(const u8 *)data); in m88e1111_set_tunable()
1027 static int m88e1011_get_downshift(struct phy_device *phydev, u8 *data) in m88e1011_get_downshift() argument
1031 val = phy_read(phydev, MII_M1011_PHY_SCR); in m88e1011_get_downshift()
1043 static int m88e1011_set_downshift(struct phy_device *phydev, u8 cnt) in m88e1011_set_downshift() argument
1051 err = phy_clear_bits(phydev, MII_M1011_PHY_SCR, in m88e1011_set_downshift()
1057 err = phy_modify(phydev, MII_M1011_PHY_SCR, in m88e1011_set_downshift()
1066 return genphy_soft_reset(phydev); in m88e1011_set_downshift()
1069 static int m88e1011_get_tunable(struct phy_device *phydev, in m88e1011_get_tunable() argument
1074 return m88e1011_get_downshift(phydev, data); in m88e1011_get_tunable()
1080 static int m88e1011_set_tunable(struct phy_device *phydev, in m88e1011_set_tunable() argument
1085 return m88e1011_set_downshift(phydev, *(const u8 *)data); in m88e1011_set_tunable()
1091 static int m88e1112_config_init(struct phy_device *phydev) in m88e1112_config_init() argument
1095 err = m88e1011_set_downshift(phydev, 3); in m88e1112_config_init()
1099 return m88e1111_config_init(phydev); in m88e1112_config_init()
1102 static int m88e1111gbe_config_init(struct phy_device *phydev) in m88e1111gbe_config_init() argument
1106 err = m88e1111_set_downshift(phydev, 3); in m88e1111gbe_config_init()
1110 return m88e1111_config_init(phydev); in m88e1111gbe_config_init()
1113 static int marvell_1011gbe_config_init(struct phy_device *phydev) in marvell_1011gbe_config_init() argument
1117 err = m88e1011_set_downshift(phydev, 3); in marvell_1011gbe_config_init()
1121 return marvell_config_init(phydev); in marvell_1011gbe_config_init()
1123 static int m88e1116r_config_init(struct phy_device *phydev) in m88e1116r_config_init() argument
1127 err = genphy_soft_reset(phydev); in m88e1116r_config_init()
1133 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1116r_config_init()
1137 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1116r_config_init()
1141 err = m88e1011_set_downshift(phydev, 8); in m88e1116r_config_init()
1145 if (phy_interface_is_rgmii(phydev)) { in m88e1116r_config_init()
1146 err = m88e1121_config_aneg_rgmii_delays(phydev); in m88e1116r_config_init()
1151 err = genphy_soft_reset(phydev); in m88e1116r_config_init()
1155 return marvell_config_init(phydev); in m88e1116r_config_init()
1158 static int m88e1318_config_init(struct phy_device *phydev) in m88e1318_config_init() argument
1160 if (phy_interrupt_is_valid(phydev)) { in m88e1318_config_init()
1162 phydev, MII_MARVELL_LED_PAGE, in m88e1318_config_init()
1171 return marvell_config_init(phydev); in m88e1318_config_init()
1174 static int m88e1510_config_init(struct phy_device *phydev) in m88e1510_config_init() argument
1179 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1510_config_init()
1181 err = marvell_set_page(phydev, 18); in m88e1510_config_init()
1186 err = phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_config_init()
1193 err = phy_set_bits(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_config_init()
1199 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_init()
1203 err = m88e1011_set_downshift(phydev, 3); in m88e1510_config_init()
1207 return m88e1318_config_init(phydev); in m88e1510_config_init()
1210 static int m88e1118_config_aneg(struct phy_device *phydev) in m88e1118_config_aneg() argument
1214 err = genphy_soft_reset(phydev); in m88e1118_config_aneg()
1218 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1118_config_aneg()
1222 err = genphy_config_aneg(phydev); in m88e1118_config_aneg()
1226 static int m88e1118_config_init(struct phy_device *phydev) in m88e1118_config_init() argument
1231 err = marvell_set_page(phydev, MII_MARVELL_MSCR_PAGE); in m88e1118_config_init()
1236 err = phy_write(phydev, 0x15, 0x1070); in m88e1118_config_init()
1241 err = marvell_set_page(phydev, MII_MARVELL_LED_PAGE); in m88e1118_config_init()
1246 if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS) in m88e1118_config_init()
1247 err = phy_write(phydev, 0x10, 0x1100); in m88e1118_config_init()
1249 err = phy_write(phydev, 0x10, 0x021e); in m88e1118_config_init()
1253 err = marvell_of_reg_init(phydev); in m88e1118_config_init()
1258 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1118_config_init()
1262 return genphy_soft_reset(phydev); in m88e1118_config_init()
1265 static int m88e1149_config_init(struct phy_device *phydev) in m88e1149_config_init() argument
1270 err = marvell_set_page(phydev, MII_MARVELL_MSCR_PAGE); in m88e1149_config_init()
1275 err = phy_write(phydev, 0x15, 0x1048); in m88e1149_config_init()
1279 err = marvell_of_reg_init(phydev); in m88e1149_config_init()
1284 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1149_config_init()
1288 return genphy_soft_reset(phydev); in m88e1149_config_init()
1291 static int m88e1145_config_init_rgmii(struct phy_device *phydev) in m88e1145_config_init_rgmii() argument
1295 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1145_config_init_rgmii()
1299 if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) { in m88e1145_config_init_rgmii()
1300 err = phy_write(phydev, 0x1d, 0x0012); in m88e1145_config_init_rgmii()
1304 err = phy_modify(phydev, 0x1e, 0x0fc0, in m88e1145_config_init_rgmii()
1310 err = phy_write(phydev, 0x1d, 0x3); in m88e1145_config_init_rgmii()
1314 err = phy_write(phydev, 0x1e, 0x8000); in m88e1145_config_init_rgmii()
1319 static int m88e1145_config_init_sgmii(struct phy_device *phydev) in m88e1145_config_init_sgmii() argument
1322 phydev, MII_M1111_HWCFG_MODE_SGMII_NO_CLK, in m88e1145_config_init_sgmii()
1326 static int m88e1145_config_init(struct phy_device *phydev) in m88e1145_config_init() argument
1331 err = phy_write(phydev, 0x1d, 0x001b); in m88e1145_config_init()
1335 err = phy_write(phydev, 0x1e, 0x418f); in m88e1145_config_init()
1339 err = phy_write(phydev, 0x1d, 0x0016); in m88e1145_config_init()
1343 err = phy_write(phydev, 0x1e, 0xa2da); in m88e1145_config_init()
1347 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { in m88e1145_config_init()
1348 err = m88e1145_config_init_rgmii(phydev); in m88e1145_config_init()
1353 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1145_config_init()
1354 err = m88e1145_config_init_sgmii(phydev); in m88e1145_config_init()
1358 err = m88e1111_set_downshift(phydev, 3); in m88e1145_config_init()
1362 err = marvell_of_reg_init(phydev); in m88e1145_config_init()
1369 static int m88e1540_get_fld(struct phy_device *phydev, u8 *msecs) in m88e1540_get_fld() argument
1373 val = phy_read(phydev, MII_88E1540_COPPER_CTRL3); in m88e1540_get_fld()
1404 static int m88e1540_set_fld(struct phy_device *phydev, const u8 *msecs) in m88e1540_set_fld() argument
1410 return phy_clear_bits(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1416 ret = phy_ethtool_get_eee(phydev, &eee); in m88e1540_set_fld()
1418 phydev_warn(phydev, "Fast Link Down detection requires EEE to be disabled!\n"); in m88e1540_set_fld()
1433 ret = phy_modify(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1438 return phy_set_bits(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1442 static int m88e1540_get_tunable(struct phy_device *phydev, in m88e1540_get_tunable() argument
1447 return m88e1540_get_fld(phydev, data); in m88e1540_get_tunable()
1449 return m88e1011_get_downshift(phydev, data); in m88e1540_get_tunable()
1455 static int m88e1540_set_tunable(struct phy_device *phydev, in m88e1540_set_tunable() argument
1460 return m88e1540_set_fld(phydev, data); in m88e1540_set_tunable()
1462 return m88e1011_set_downshift(phydev, *(const u8 *)data); in m88e1540_set_tunable()
1472 static int m88e6390_errata(struct phy_device *phydev) in m88e6390_errata() argument
1476 err = phy_write(phydev, MII_BMCR, in m88e6390_errata()
1483 err = phy_write_paged(phydev, 0xf8, 0x08, 0x36); in m88e6390_errata()
1487 return genphy_soft_reset(phydev); in m88e6390_errata()
1490 static int m88e6390_config_aneg(struct phy_device *phydev) in m88e6390_config_aneg() argument
1494 err = m88e6390_errata(phydev); in m88e6390_config_aneg()
1498 return m88e1510_config_aneg(phydev); in m88e6390_config_aneg()
1519 static int marvell_read_status_page_an(struct phy_device *phydev, in marvell_read_status_page_an() argument
1526 phydev->link = 0; in marvell_read_status_page_an()
1531 phydev->duplex = DUPLEX_FULL; in marvell_read_status_page_an()
1533 phydev->duplex = DUPLEX_HALF; in marvell_read_status_page_an()
1537 phydev->speed = SPEED_1000; in marvell_read_status_page_an()
1541 phydev->speed = SPEED_100; in marvell_read_status_page_an()
1545 phydev->speed = SPEED_10; in marvell_read_status_page_an()
1550 err = genphy_read_lpa(phydev); in marvell_read_status_page_an()
1554 phy_resolve_aneg_pause(phydev); in marvell_read_status_page_an()
1556 lpa = phy_read(phydev, MII_LPA); in marvell_read_status_page_an()
1561 fiber_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); in marvell_read_status_page_an()
1563 if (phydev->duplex == DUPLEX_FULL) { in marvell_read_status_page_an()
1565 phydev->pause = 0; in marvell_read_status_page_an()
1566 phydev->asym_pause = 0; in marvell_read_status_page_an()
1568 phydev->pause = 1; in marvell_read_status_page_an()
1569 phydev->asym_pause = 1; in marvell_read_status_page_an()
1571 phydev->pause = 1; in marvell_read_status_page_an()
1572 phydev->asym_pause = 0; in marvell_read_status_page_an()
1588 static int marvell_read_status_page(struct phy_device *phydev, int page) in marvell_read_status_page() argument
1594 status = phy_read(phydev, MII_M1011_PHY_STATUS); in marvell_read_status_page()
1602 phydev->link = !!(status & MII_M1011_PHY_STATUS_LINK); in marvell_read_status_page()
1604 err = genphy_update_link(phydev); in marvell_read_status_page()
1614 linkmode_zero(phydev->lp_advertising); in marvell_read_status_page()
1615 phydev->pause = 0; in marvell_read_status_page()
1616 phydev->asym_pause = 0; in marvell_read_status_page()
1617 phydev->speed = SPEED_UNKNOWN; in marvell_read_status_page()
1618 phydev->duplex = DUPLEX_UNKNOWN; in marvell_read_status_page()
1619 phydev->port = fiber ? PORT_FIBRE : PORT_TP; in marvell_read_status_page()
1621 if (phydev->autoneg == AUTONEG_ENABLE) in marvell_read_status_page()
1622 err = marvell_read_status_page_an(phydev, fiber, status); in marvell_read_status_page()
1624 err = genphy_read_status_fixed(phydev); in marvell_read_status_page()
1638 static int marvell_read_status(struct phy_device *phydev) in marvell_read_status() argument
1644 phydev->supported) && in marvell_read_status()
1645 phydev->interface != PHY_INTERFACE_MODE_SGMII) { in marvell_read_status()
1646 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_read_status()
1650 err = marvell_read_status_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_read_status()
1661 if (phydev->link) in marvell_read_status()
1665 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1670 return marvell_read_status_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1673 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1682 static int marvell_suspend(struct phy_device *phydev) in marvell_suspend() argument
1688 phydev->supported)) { in marvell_suspend()
1689 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_suspend()
1694 err = genphy_suspend(phydev); in marvell_suspend()
1699 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_suspend()
1705 return genphy_suspend(phydev); in marvell_suspend()
1708 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_suspend()
1717 static int marvell_resume(struct phy_device *phydev) in marvell_resume() argument
1723 phydev->supported)) { in marvell_resume()
1724 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_resume()
1729 err = genphy_resume(phydev); in marvell_resume()
1734 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_resume()
1740 return genphy_resume(phydev); in marvell_resume()
1743 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_resume()
1747 static int marvell_aneg_done(struct phy_device *phydev) in marvell_aneg_done() argument
1749 int retval = phy_read(phydev, MII_M1011_PHY_STATUS); in marvell_aneg_done()
1754 static void m88e1318_get_wol(struct phy_device *phydev, in m88e1318_get_wol() argument
1762 ret = phy_read_paged(phydev, MII_MARVELL_WOL_PAGE, in m88e1318_get_wol()
1774 static int m88e1318_set_wol(struct phy_device *phydev, in m88e1318_set_wol() argument
1779 oldpage = phy_save_page(phydev); in m88e1318_set_wol()
1785 err = marvell_write_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1318_set_wol()
1795 if (!phy_interrupt_is_valid(phydev)) in m88e1318_set_wol()
1796 __phy_read(phydev, MII_M1011_IEVENT); in m88e1318_set_wol()
1799 err = __phy_set_bits(phydev, MII_88E1318S_PHY_CSIER, in m88e1318_set_wol()
1804 err = marvell_write_page(phydev, MII_MARVELL_LED_PAGE); in m88e1318_set_wol()
1809 err = __phy_modify(phydev, MII_88E1318S_PHY_LED_TCR, in m88e1318_set_wol()
1818 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1823 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD2, in m88e1318_set_wol()
1824 ((phydev->attached_dev->dev_addr[5] << 8) | in m88e1318_set_wol()
1825 phydev->attached_dev->dev_addr[4])); in m88e1318_set_wol()
1828 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD1, in m88e1318_set_wol()
1829 ((phydev->attached_dev->dev_addr[3] << 8) | in m88e1318_set_wol()
1830 phydev->attached_dev->dev_addr[2])); in m88e1318_set_wol()
1833 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD0, in m88e1318_set_wol()
1834 ((phydev->attached_dev->dev_addr[1] << 8) | in m88e1318_set_wol()
1835 phydev->attached_dev->dev_addr[0])); in m88e1318_set_wol()
1840 err = __phy_set_bits(phydev, MII_88E1318S_PHY_WOL_CTRL, in m88e1318_set_wol()
1846 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1851 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, in m88e1318_set_wol()
1859 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1864 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, 0, in m88e1318_set_wol()
1870 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1875 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, in m88e1318_set_wol()
1883 return phy_restore_page(phydev, oldpage, err); in m88e1318_set_wol()
1886 static int marvell_get_sset_count(struct phy_device *phydev) in marvell_get_sset_count() argument
1889 phydev->supported)) in marvell_get_sset_count()
1895 static void marvell_get_strings(struct phy_device *phydev, u8 *data) in marvell_get_strings() argument
1897 int count = marvell_get_sset_count(phydev); in marvell_get_strings()
1906 static u64 marvell_get_stat(struct phy_device *phydev, int i) in marvell_get_stat() argument
1909 struct marvell_priv *priv = phydev->priv; in marvell_get_stat()
1913 val = phy_read_paged(phydev, stat.page, stat.reg); in marvell_get_stat()
1925 static void marvell_get_stats(struct phy_device *phydev, in marvell_get_stats() argument
1928 int count = marvell_get_sset_count(phydev); in marvell_get_stats()
1932 data[i] = marvell_get_stat(phydev, i); in marvell_get_stats()
1935 static int marvell_vct5_wait_complete(struct phy_device *phydev) in marvell_vct5_wait_complete() argument
1941 val = __phy_read(phydev, MII_VCT5_CTRL); in marvell_vct5_wait_complete()
1949 phydev_err(phydev, "Timeout while waiting for cable test to finish\n"); in marvell_vct5_wait_complete()
1953 static int marvell_vct5_amplitude(struct phy_device *phydev, int pair) in marvell_vct5_amplitude() argument
1960 val = __phy_read(phydev, reg); in marvell_vct5_amplitude()
1984 static int marvell_vct5_amplitude_distance(struct phy_device *phydev, in marvell_vct5_amplitude_distance() argument
1992 err = __phy_write(phydev, MII_VCT5_SAMPLE_POINT_DISTANCE, in marvell_vct5_amplitude_distance()
2002 err = __phy_write(phydev, MII_VCT5_CTRL, reg); in marvell_vct5_amplitude_distance()
2006 err = marvell_vct5_wait_complete(phydev); in marvell_vct5_amplitude_distance()
2014 mV = marvell_vct5_amplitude(phydev, i); in marvell_vct5_amplitude_distance()
2015 ethnl_cable_test_amplitude(phydev, i, mV); in marvell_vct5_amplitude_distance()
2021 static int marvell_vct5_amplitude_graph(struct phy_device *phydev) in marvell_vct5_amplitude_graph() argument
2023 struct marvell_priv *priv = phydev->priv; in marvell_vct5_amplitude_graph()
2039 err = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct5_amplitude_graph()
2050 page = phy_select_page(phydev, MII_MARVELL_VCT5_PAGE); in marvell_vct5_amplitude_graph()
2057 err = marvell_vct5_amplitude_distance(phydev, distance, in marvell_vct5_amplitude_graph()
2068 err = __phy_write(phydev, MII_VCT5_TX_PULSE_CTRL, reg); in marvell_vct5_amplitude_graph()
2075 return phy_restore_page(phydev, page, err); in marvell_vct5_amplitude_graph()
2078 static int marvell_cable_test_start_common(struct phy_device *phydev) in marvell_cable_test_start_common() argument
2085 bmcr = phy_read(phydev, MII_BMCR); in marvell_cable_test_start_common()
2089 bmsr = phy_read(phydev, MII_BMSR); in marvell_cable_test_start_common()
2095 ret = phy_clear_bits(phydev, MII_BMCR, BMCR_ANENABLE); in marvell_cable_test_start_common()
2098 ret = genphy_soft_reset(phydev); in marvell_cable_test_start_common()
2110 static int marvell_vct7_cable_test_start(struct phy_device *phydev) in marvell_vct7_cable_test_start() argument
2112 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_start()
2115 ret = marvell_cable_test_start_common(phydev); in marvell_vct7_cable_test_start()
2124 ret = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct7_cable_test_start()
2133 ret = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct7_cable_test_start()
2138 return phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_start()
2144 static int marvell_vct5_cable_test_tdr_start(struct phy_device *phydev, in marvell_vct5_cable_test_tdr_start() argument
2147 struct marvell_priv *priv = phydev->priv; in marvell_vct5_cable_test_tdr_start()
2163 ret = phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct5_cable_test_tdr_start()
2168 ret = marvell_cable_test_start_common(phydev); in marvell_vct5_cable_test_tdr_start()
2172 ret = ethnl_cable_test_pulse(phydev, 1000); in marvell_vct5_cable_test_tdr_start()
2176 return ethnl_cable_test_step(phydev, in marvell_vct5_cable_test_tdr_start()
2201 static int marvell_vct7_report_length(struct phy_device *phydev, in marvell_vct7_report_length() argument
2207 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_report_length()
2214 ethnl_cable_test_fault_length(phydev, pair, length); in marvell_vct7_report_length()
2235 static int marvell_vct7_cable_test_report(struct phy_device *phydev) in marvell_vct7_cable_test_report() argument
2241 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_report()
2255 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, in marvell_vct7_cable_test_report()
2257 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_B, in marvell_vct7_cable_test_report()
2259 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_C, in marvell_vct7_cable_test_report()
2261 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_D, in marvell_vct7_cable_test_report()
2264 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, MII_VCT7_CTRL); in marvell_vct7_cable_test_report()
2271 marvell_vct7_report_length(phydev, 0, meter); in marvell_vct7_cable_test_report()
2273 marvell_vct7_report_length(phydev, 1, meter); in marvell_vct7_cable_test_report()
2275 marvell_vct7_report_length(phydev, 2, meter); in marvell_vct7_cable_test_report()
2277 marvell_vct7_report_length(phydev, 3, meter); in marvell_vct7_cable_test_report()
2282 static int marvell_vct7_cable_test_get_status(struct phy_device *phydev, in marvell_vct7_cable_test_get_status() argument
2285 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_get_status()
2289 ret = marvell_vct5_amplitude_graph(phydev); in marvell_vct7_cable_test_get_status()
2296 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_get_status()
2305 return marvell_vct7_cable_test_report(phydev); in marvell_vct7_cable_test_get_status()
2313 int (*config)(struct phy_device *phydev);
2314 int (*get_temp)(struct phy_device *phydev, long *temp);
2315 int (*get_temp_critical)(struct phy_device *phydev, long *temp);
2316 int (*set_temp_critical)(struct phy_device *phydev, long temp);
2317 int (*get_temp_alarm)(struct phy_device *phydev, long *alarm);
2321 to_marvell_hwmon_ops(const struct phy_device *phydev) in to_marvell_hwmon_ops() argument
2323 return phydev->drv->driver_data; in to_marvell_hwmon_ops()
2326 static int m88e1121_get_temp(struct phy_device *phydev, long *temp) in m88e1121_get_temp() argument
2334 oldpage = phy_select_page(phydev, MII_MARVELL_MISC_TEST_PAGE); in m88e1121_get_temp()
2339 ret = __phy_read(phydev, MII_88E1121_MISC_TEST); in m88e1121_get_temp()
2343 ret = __phy_write(phydev, MII_88E1121_MISC_TEST, in m88e1121_get_temp()
2351 val = __phy_read(phydev, MII_88E1121_MISC_TEST); in m88e1121_get_temp()
2358 ret = __phy_write(phydev, MII_88E1121_MISC_TEST, in m88e1121_get_temp()
2366 return phy_restore_page(phydev, oldpage, ret); in m88e1121_get_temp()
2369 static int m88e1510_get_temp(struct phy_device *phydev, long *temp) in m88e1510_get_temp() argument
2375 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp()
2385 static int m88e1510_get_temp_critical(struct phy_device *phydev, long *temp) in m88e1510_get_temp_critical() argument
2391 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp_critical()
2404 static int m88e1510_set_temp_critical(struct phy_device *phydev, long temp) in m88e1510_set_temp_critical() argument
2409 return phy_modify_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_set_temp_critical()
2415 static int m88e1510_get_temp_alarm(struct phy_device *phydev, long *alarm) in m88e1510_get_temp_alarm() argument
2421 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp_alarm()
2431 static int m88e6390_get_temp(struct phy_device *phydev, long *temp) in m88e6390_get_temp() argument
2440 oldpage = phy_select_page(phydev, MII_MARVELL_MISC_TEST_PAGE); in m88e6390_get_temp()
2445 ret = __phy_read(phydev, MII_88E6390_MISC_TEST); in m88e6390_get_temp()
2452 ret = __phy_write(phydev, MII_88E6390_MISC_TEST, ret); in m88e6390_get_temp()
2463 ret = __phy_read(phydev, MII_88E6390_TEMP_SENSOR); in m88e6390_get_temp()
2473 ret = __phy_read(phydev, MII_88E6390_MISC_TEST); in m88e6390_get_temp()
2480 ret = __phy_write(phydev, MII_88E6390_MISC_TEST, ret); in m88e6390_get_temp()
2483 phy_restore_page(phydev, oldpage, ret); in m88e6390_get_temp()
2488 static int m88e6393_get_temp(struct phy_device *phydev, long *temp) in m88e6393_get_temp() argument
2492 err = m88e1510_get_temp(phydev, temp); in m88e6393_get_temp()
2502 static int m88e6393_get_temp_critical(struct phy_device *phydev, long *temp) in m88e6393_get_temp_critical() argument
2508 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e6393_get_temp_critical()
2519 static int m88e6393_set_temp_critical(struct phy_device *phydev, long temp) in m88e6393_set_temp_critical() argument
2523 return phy_modify_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e6393_set_temp_critical()
2529 static int m88e6393_hwmon_config(struct phy_device *phydev) in m88e6393_hwmon_config() argument
2533 err = m88e6393_set_temp_critical(phydev, 100000); in m88e6393_hwmon_config()
2537 return phy_modify_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e6393_hwmon_config()
2550 struct phy_device *phydev = dev_get_drvdata(dev); in marvell_hwmon_read() local
2551 const struct marvell_hwmon_ops *ops = to_marvell_hwmon_ops(phydev); in marvell_hwmon_read()
2557 err = ops->get_temp(phydev, temp); in marvell_hwmon_read()
2561 err = ops->get_temp_critical(phydev, temp); in marvell_hwmon_read()
2565 err = ops->get_temp_alarm(phydev, temp); in marvell_hwmon_read()
2575 struct phy_device *phydev = dev_get_drvdata(dev); in marvell_hwmon_write() local
2576 const struct marvell_hwmon_ops *ops = to_marvell_hwmon_ops(phydev); in marvell_hwmon_write()
2582 err = ops->set_temp_critical(phydev, temp); in marvell_hwmon_write()
2593 const struct phy_device *phydev = data; in marvell_hwmon_is_visible() local
2594 const struct marvell_hwmon_ops *ops = to_marvell_hwmon_ops(phydev); in marvell_hwmon_is_visible()
2653 static int marvell_hwmon_name(struct phy_device *phydev) in marvell_hwmon_name() argument
2655 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_name()
2656 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_name()
2673 static int marvell_hwmon_probe(struct phy_device *phydev) in marvell_hwmon_probe() argument
2675 const struct marvell_hwmon_ops *ops = to_marvell_hwmon_ops(phydev); in marvell_hwmon_probe()
2676 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_probe()
2677 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_probe()
2683 err = marvell_hwmon_name(phydev); in marvell_hwmon_probe()
2688 dev, priv->hwmon_name, phydev, &marvell_hwmon_chip_info, NULL); in marvell_hwmon_probe()
2693 err = ops->config(phydev); in marvell_hwmon_probe()
2727 static int marvell_hwmon_probe(struct phy_device *phydev) in marvell_hwmon_probe() argument
2733 static int marvell_probe(struct phy_device *phydev) in marvell_probe() argument
2737 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in marvell_probe()
2741 phydev->priv = priv; in marvell_probe()
2743 return marvell_hwmon_probe(phydev); in marvell_probe()
2748 struct phy_device *phydev = upstream; in m88e1510_sfp_insert() local
2757 dev = &phydev->mdio.dev; in m88e1510_sfp_insert()
2759 sfp_parse_support(phydev->sfp_bus, id, supported); in m88e1510_sfp_insert()
2760 interface = sfp_select_interface(phydev->sfp_bus, supported); in m88e1510_sfp_insert()
2783 oldpage = phy_select_page(phydev, MII_MARVELL_MODE_PAGE); in m88e1510_sfp_insert()
2787 ret = __phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_sfp_insert()
2792 ret = __phy_set_bits(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_sfp_insert()
2796 return phy_restore_page(phydev, oldpage, ret); in m88e1510_sfp_insert()
2801 struct phy_device *phydev = upstream; in m88e1510_sfp_remove() local
2805 oldpage = phy_select_page(phydev, MII_MARVELL_MODE_PAGE); in m88e1510_sfp_remove()
2809 ret = __phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_sfp_remove()
2815 ret = __phy_set_bits(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_sfp_remove()
2819 phy_restore_page(phydev, oldpage, ret); in m88e1510_sfp_remove()
2829 static int m88e1510_probe(struct phy_device *phydev) in m88e1510_probe() argument
2833 err = marvell_probe(phydev); in m88e1510_probe()
2837 return phy_sfp_probe(phydev, &m88e1510_sfp_ops); in m88e1510_probe()