Lines Matching full:phydev
359 static int marvell_read_page(struct phy_device *phydev) in marvell_read_page() argument
361 return __phy_read(phydev, MII_MARVELL_PHY_PAGE); in marvell_read_page()
364 static int marvell_write_page(struct phy_device *phydev, int page) in marvell_write_page() argument
366 return __phy_write(phydev, MII_MARVELL_PHY_PAGE, page); in marvell_write_page()
369 static int marvell_set_page(struct phy_device *phydev, int page) in marvell_set_page() argument
371 return phy_write(phydev, MII_MARVELL_PHY_PAGE, page); in marvell_set_page()
374 static int marvell_ack_interrupt(struct phy_device *phydev) in marvell_ack_interrupt() argument
379 err = phy_read(phydev, MII_M1011_IEVENT); in marvell_ack_interrupt()
387 static int marvell_config_intr(struct phy_device *phydev) in marvell_config_intr() argument
391 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in marvell_config_intr()
392 err = marvell_ack_interrupt(phydev); in marvell_config_intr()
396 err = phy_write(phydev, MII_M1011_IMASK, in marvell_config_intr()
399 err = phy_write(phydev, MII_M1011_IMASK, in marvell_config_intr()
404 err = marvell_ack_interrupt(phydev); in marvell_config_intr()
410 static irqreturn_t marvell_handle_interrupt(struct phy_device *phydev) in marvell_handle_interrupt() argument
414 irq_status = phy_read(phydev, MII_M1011_IEVENT); in marvell_handle_interrupt()
416 phy_error(phydev); in marvell_handle_interrupt()
423 phy_trigger_machine(phydev); in marvell_handle_interrupt()
428 static int marvell_set_polarity(struct phy_device *phydev, int polarity) in marvell_set_polarity() argument
446 return phy_modify_changed(phydev, MII_M1011_PHY_SCR, in marvell_set_polarity()
450 static int marvell_config_aneg(struct phy_device *phydev) in marvell_config_aneg() argument
455 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in marvell_config_aneg()
461 err = phy_write(phydev, MII_M1111_PHY_LED_CONTROL, in marvell_config_aneg()
466 err = genphy_config_aneg(phydev); in marvell_config_aneg()
470 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in marvell_config_aneg()
475 err = genphy_soft_reset(phydev); in marvell_config_aneg()
483 static int m88e1101_config_aneg(struct phy_device *phydev) in m88e1101_config_aneg() argument
491 err = genphy_soft_reset(phydev); in m88e1101_config_aneg()
495 err = phy_write(phydev, 0x1d, 0x1f); in m88e1101_config_aneg()
499 err = phy_write(phydev, 0x1e, 0x200c); in m88e1101_config_aneg()
503 err = phy_write(phydev, 0x1d, 0x5); in m88e1101_config_aneg()
507 err = phy_write(phydev, 0x1e, 0); in m88e1101_config_aneg()
511 err = phy_write(phydev, 0x1e, 0x100); in m88e1101_config_aneg()
515 return marvell_config_aneg(phydev); in m88e1101_config_aneg()
520 * marvell,reg-init property stored in the of_node for the phydev.
532 static int marvell_of_reg_init(struct phy_device *phydev) in marvell_of_reg_init() argument
537 if (!phydev->mdio.dev.of_node) in marvell_of_reg_init()
540 paddr = of_get_property(phydev->mdio.dev.of_node, in marvell_of_reg_init()
545 saved_page = phy_save_page(phydev); in marvell_of_reg_init()
560 ret = marvell_write_page(phydev, page); in marvell_of_reg_init()
567 val = __phy_read(phydev, reg); in marvell_of_reg_init()
576 ret = __phy_write(phydev, reg, val); in marvell_of_reg_init()
581 return phy_restore_page(phydev, saved_page, ret); in marvell_of_reg_init()
584 static int marvell_of_reg_init(struct phy_device *phydev) in marvell_of_reg_init() argument
590 static int m88e1121_config_aneg_rgmii_delays(struct phy_device *phydev) in m88e1121_config_aneg_rgmii_delays() argument
594 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) in m88e1121_config_aneg_rgmii_delays()
597 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in m88e1121_config_aneg_rgmii_delays()
599 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in m88e1121_config_aneg_rgmii_delays()
604 return phy_modify_paged_changed(phydev, MII_MARVELL_MSCR_PAGE, in m88e1121_config_aneg_rgmii_delays()
609 static int m88e1121_config_aneg(struct phy_device *phydev) in m88e1121_config_aneg() argument
614 if (phy_interface_is_rgmii(phydev)) { in m88e1121_config_aneg()
615 err = m88e1121_config_aneg_rgmii_delays(phydev); in m88e1121_config_aneg()
622 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1121_config_aneg()
628 err = genphy_config_aneg(phydev); in m88e1121_config_aneg()
632 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in m88e1121_config_aneg()
636 err = genphy_soft_reset(phydev); in m88e1121_config_aneg()
644 static int m88e1318_config_aneg(struct phy_device *phydev) in m88e1318_config_aneg() argument
648 err = phy_modify_paged(phydev, MII_MARVELL_MSCR_PAGE, in m88e1318_config_aneg()
654 return m88e1121_config_aneg(phydev); in m88e1318_config_aneg()
685 * @phydev: target phy_device struct
692 static int marvell_config_aneg_fiber(struct phy_device *phydev) in marvell_config_aneg_fiber() argument
698 if (phydev->autoneg != AUTONEG_ENABLE) in marvell_config_aneg_fiber()
699 return genphy_setup_forced(phydev); in marvell_config_aneg_fiber()
702 linkmode_and(phydev->advertising, phydev->advertising, in marvell_config_aneg_fiber()
703 phydev->supported); in marvell_config_aneg_fiber()
705 adv = linkmode_adv_to_fiber_adv_t(phydev->advertising); in marvell_config_aneg_fiber()
708 err = phy_modify_changed(phydev, MII_ADVERTISE, in marvell_config_aneg_fiber()
717 return genphy_check_and_restart_aneg(phydev, changed); in marvell_config_aneg_fiber()
720 static unsigned int m88e1111_inband_caps(struct phy_device *phydev, in m88e1111_inband_caps() argument
734 static int m88e1111_config_inband(struct phy_device *phydev, unsigned int modes) in m88e1111_config_inband() argument
739 if (phydev->interface != PHY_INTERFACE_MODE_1000BASEX && in m88e1111_config_inband()
740 phydev->interface != PHY_INTERFACE_MODE_SGMII) in m88e1111_config_inband()
753 err = phy_modify(phydev, MII_M1111_PHY_EXT_SR, in m88e1111_config_inband()
758 return phy_modify_paged(phydev, MII_MARVELL_FIBER_PAGE, MII_BMCR, in m88e1111_config_inband()
762 static int m88e1111_config_aneg(struct phy_device *phydev) in m88e1111_config_aneg() argument
764 int extsr = phy_read(phydev, MII_M1111_PHY_EXT_SR); in m88e1111_config_aneg()
773 if (phydev->interface != PHY_INTERFACE_MODE_SGMII && in m88e1111_config_aneg()
776 return marvell_config_aneg(phydev); in m88e1111_config_aneg()
778 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1111_config_aneg()
783 err = marvell_config_aneg(phydev); in m88e1111_config_aneg()
788 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in m88e1111_config_aneg()
792 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1111_config_aneg()
797 err = genphy_check_and_restart_aneg(phydev, false); in m88e1111_config_aneg()
799 err = marvell_config_aneg_fiber(phydev); in m88e1111_config_aneg()
803 return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1111_config_aneg()
806 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1111_config_aneg()
810 static int m88e1510_config_aneg(struct phy_device *phydev) in m88e1510_config_aneg() argument
814 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
819 err = m88e1318_config_aneg(phydev); in m88e1510_config_aneg()
824 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1510_config_aneg()
828 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in m88e1510_config_aneg()
832 err = marvell_config_aneg_fiber(phydev); in m88e1510_config_aneg()
836 return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
839 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
843 static void marvell_config_led(struct phy_device *phydev) in marvell_config_led() argument
848 switch (MARVELL_PHY_FAMILY_ID(phydev->phy_id)) { in marvell_config_led()
860 if (phydev->dev_flags & MARVELL_PHY_LED0_LINK_LED1_ACTIVE) in marvell_config_led()
869 err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE, MII_PHY_LED_CTRL, in marvell_config_led()
872 phydev_warn(phydev, "Fail to config marvell phy LED.\n"); in marvell_config_led()
875 static int marvell_config_init(struct phy_device *phydev) in marvell_config_init() argument
878 marvell_config_led(phydev); in marvell_config_init()
881 return marvell_of_reg_init(phydev); in marvell_config_init()
884 static int m88e3016_config_init(struct phy_device *phydev) in m88e3016_config_init() argument
889 ret = phy_modify(phydev, MII_88E3016_PHY_SPEC_CTRL, in m88e3016_config_init()
895 return marvell_config_init(phydev); in m88e3016_config_init()
898 static int m88e1111_config_init_hwcfg_mode(struct phy_device *phydev, in m88e1111_config_init_hwcfg_mode() argument
905 return phy_modify(phydev, MII_M1111_PHY_EXT_SR, in m88e1111_config_init_hwcfg_mode()
912 static int m88e1111_config_init_rgmii_delays(struct phy_device *phydev) in m88e1111_config_init_rgmii_delays() argument
916 switch (phydev->interface) { in m88e1111_config_init_rgmii_delays()
931 return phy_modify(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_config_init_rgmii_delays()
936 static int m88e1111_config_init_rgmii(struct phy_device *phydev) in m88e1111_config_init_rgmii() argument
941 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1111_config_init_rgmii()
945 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR); in m88e1111_config_init_rgmii()
956 return phy_write(phydev, MII_M1111_PHY_EXT_SR, temp); in m88e1111_config_init_rgmii()
959 static int m88e1111_config_init_sgmii(struct phy_device *phydev) in m88e1111_config_init_sgmii() argument
964 phydev, in m88e1111_config_init_sgmii()
971 return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1111_config_init_sgmii()
974 static int m88e1111_config_init_rtbi(struct phy_device *phydev) in m88e1111_config_init_rtbi() argument
978 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1111_config_init_rtbi()
983 phydev, in m88e1111_config_init_rtbi()
990 err = genphy_soft_reset(phydev); in m88e1111_config_init_rtbi()
995 phydev, in m88e1111_config_init_rtbi()
1000 static int m88e1111_config_init_1000basex(struct phy_device *phydev) in m88e1111_config_init_1000basex() argument
1002 int extsr = phy_read(phydev, MII_M1111_PHY_EXT_SR); in m88e1111_config_init_1000basex()
1014 err = phy_modify(phydev, MII_M1111_PHY_EXT_SR, in m88e1111_config_init_1000basex()
1025 static int m88e1111_config_init(struct phy_device *phydev) in m88e1111_config_init() argument
1029 if (phy_interface_is_rgmii(phydev)) { in m88e1111_config_init()
1030 err = m88e1111_config_init_rgmii(phydev); in m88e1111_config_init()
1035 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1111_config_init()
1036 err = m88e1111_config_init_sgmii(phydev); in m88e1111_config_init()
1041 if (phydev->interface == PHY_INTERFACE_MODE_RTBI) { in m88e1111_config_init()
1042 err = m88e1111_config_init_rtbi(phydev); in m88e1111_config_init()
1047 if (phydev->interface == PHY_INTERFACE_MODE_1000BASEX) { in m88e1111_config_init()
1048 err = m88e1111_config_init_1000basex(phydev); in m88e1111_config_init()
1053 err = marvell_of_reg_init(phydev); in m88e1111_config_init()
1057 err = genphy_soft_reset(phydev); in m88e1111_config_init()
1061 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1111_config_init()
1067 err = genphy_read_abilities(phydev); in m88e1111_config_init()
1068 linkmode_or(phydev->advertising, phydev->advertising, in m88e1111_config_init()
1069 phydev->supported); in m88e1111_config_init()
1074 static int m88e1111_get_downshift(struct phy_device *phydev, u8 *data) in m88e1111_get_downshift() argument
1078 val = phy_read(phydev, MII_M1111_PHY_EXT_CR); in m88e1111_get_downshift()
1090 static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt) in m88e1111_set_downshift() argument
1098 err = phy_clear_bits(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_set_downshift()
1104 err = phy_modify(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_set_downshift()
1113 return genphy_soft_reset(phydev); in m88e1111_set_downshift()
1116 static int m88e1111_get_tunable(struct phy_device *phydev, in m88e1111_get_tunable() argument
1121 return m88e1111_get_downshift(phydev, data); in m88e1111_get_tunable()
1127 static int m88e1111_set_tunable(struct phy_device *phydev, in m88e1111_set_tunable() argument
1132 return m88e1111_set_downshift(phydev, *(const u8 *)data); in m88e1111_set_tunable()
1138 static int m88e1011_get_downshift(struct phy_device *phydev, u8 *data) in m88e1011_get_downshift() argument
1142 val = phy_read(phydev, MII_M1011_PHY_SCR); in m88e1011_get_downshift()
1154 static int m88e1011_set_downshift(struct phy_device *phydev, u8 cnt) in m88e1011_set_downshift() argument
1162 err = phy_clear_bits(phydev, MII_M1011_PHY_SCR, in m88e1011_set_downshift()
1168 err = phy_modify(phydev, MII_M1011_PHY_SCR, in m88e1011_set_downshift()
1177 return genphy_soft_reset(phydev); in m88e1011_set_downshift()
1180 static int m88e1011_get_tunable(struct phy_device *phydev, in m88e1011_get_tunable() argument
1185 return m88e1011_get_downshift(phydev, data); in m88e1011_get_tunable()
1191 static int m88e1011_set_tunable(struct phy_device *phydev, in m88e1011_set_tunable() argument
1196 return m88e1011_set_downshift(phydev, *(const u8 *)data); in m88e1011_set_tunable()
1202 static int m88e1112_config_init(struct phy_device *phydev) in m88e1112_config_init() argument
1206 err = m88e1011_set_downshift(phydev, 3); in m88e1112_config_init()
1210 return m88e1111_config_init(phydev); in m88e1112_config_init()
1213 static int m88e1111gbe_config_init(struct phy_device *phydev) in m88e1111gbe_config_init() argument
1217 err = m88e1111_set_downshift(phydev, 3); in m88e1111gbe_config_init()
1221 return m88e1111_config_init(phydev); in m88e1111gbe_config_init()
1224 static int marvell_1011gbe_config_init(struct phy_device *phydev) in marvell_1011gbe_config_init() argument
1228 err = m88e1011_set_downshift(phydev, 3); in marvell_1011gbe_config_init()
1232 return marvell_config_init(phydev); in marvell_1011gbe_config_init()
1234 static int m88e1116r_config_init(struct phy_device *phydev) in m88e1116r_config_init() argument
1238 err = genphy_soft_reset(phydev); in m88e1116r_config_init()
1244 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1116r_config_init()
1248 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1116r_config_init()
1252 err = m88e1011_set_downshift(phydev, 8); in m88e1116r_config_init()
1256 if (phy_interface_is_rgmii(phydev)) { in m88e1116r_config_init()
1257 err = m88e1121_config_aneg_rgmii_delays(phydev); in m88e1116r_config_init()
1262 err = genphy_soft_reset(phydev); in m88e1116r_config_init()
1266 return marvell_config_init(phydev); in m88e1116r_config_init()
1269 static int m88e1318_config_init(struct phy_device *phydev) in m88e1318_config_init() argument
1271 if (phy_interrupt_is_valid(phydev)) { in m88e1318_config_init()
1273 phydev, MII_MARVELL_LED_PAGE, in m88e1318_config_init()
1282 return marvell_config_init(phydev); in m88e1318_config_init()
1285 static int m88e1510_config_init(struct phy_device *phydev) in m88e1510_config_init() argument
1303 err = marvell_set_page(phydev, 0x00FF); in m88e1510_config_init()
1308 err = phy_write(phydev, 17, errata_vals[i].reg17); in m88e1510_config_init()
1311 err = phy_write(phydev, 16, errata_vals[i].reg16); in m88e1510_config_init()
1316 err = marvell_set_page(phydev, 0x00FB); in m88e1510_config_init()
1319 err = phy_write(phydev, 07, 0xC00D); in m88e1510_config_init()
1322 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_init()
1327 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1510_config_init()
1329 err = marvell_set_page(phydev, 18); in m88e1510_config_init()
1334 err = phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_config_init()
1341 err = phy_set_bits(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_config_init()
1347 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_init()
1351 err = m88e1011_set_downshift(phydev, 3); in m88e1510_config_init()
1355 return m88e1318_config_init(phydev); in m88e1510_config_init()
1358 static int m88e1118_config_aneg(struct phy_device *phydev) in m88e1118_config_aneg() argument
1362 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1118_config_aneg()
1366 err = genphy_config_aneg(phydev); in m88e1118_config_aneg()
1370 return genphy_soft_reset(phydev); in m88e1118_config_aneg()
1373 static int m88e1118_config_init(struct phy_device *phydev) in m88e1118_config_init() argument
1379 err = phy_write_paged(phydev, MII_MARVELL_MSCR_PAGE, in m88e1118_config_init()
1384 if (phy_interface_is_rgmii(phydev)) { in m88e1118_config_init()
1385 err = m88e1121_config_aneg_rgmii_delays(phydev); in m88e1118_config_init()
1391 if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS) in m88e1118_config_init()
1396 err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE, 0x10, leds); in m88e1118_config_init()
1400 err = marvell_of_reg_init(phydev); in m88e1118_config_init()
1405 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1118_config_init()
1409 return genphy_soft_reset(phydev); in m88e1118_config_init()
1412 static int m88e1149_config_init(struct phy_device *phydev) in m88e1149_config_init() argument
1417 err = marvell_set_page(phydev, MII_MARVELL_MSCR_PAGE); in m88e1149_config_init()
1422 err = phy_write(phydev, 0x15, 0x1048); in m88e1149_config_init()
1426 err = marvell_of_reg_init(phydev); in m88e1149_config_init()
1431 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1149_config_init()
1435 return genphy_soft_reset(phydev); in m88e1149_config_init()
1438 static int m88e1145_config_init_rgmii(struct phy_device *phydev) in m88e1145_config_init_rgmii() argument
1442 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1145_config_init_rgmii()
1446 if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) { in m88e1145_config_init_rgmii()
1447 err = phy_write(phydev, 0x1d, 0x0012); in m88e1145_config_init_rgmii()
1451 err = phy_modify(phydev, 0x1e, 0x0fc0, in m88e1145_config_init_rgmii()
1457 err = phy_write(phydev, 0x1d, 0x3); in m88e1145_config_init_rgmii()
1461 err = phy_write(phydev, 0x1e, 0x8000); in m88e1145_config_init_rgmii()
1466 static int m88e1145_config_init_sgmii(struct phy_device *phydev) in m88e1145_config_init_sgmii() argument
1469 phydev, MII_M1111_HWCFG_MODE_SGMII_NO_CLK, in m88e1145_config_init_sgmii()
1473 static int m88e1145_config_init(struct phy_device *phydev) in m88e1145_config_init() argument
1478 err = phy_write(phydev, 0x1d, 0x001b); in m88e1145_config_init()
1482 err = phy_write(phydev, 0x1e, 0x418f); in m88e1145_config_init()
1486 err = phy_write(phydev, 0x1d, 0x0016); in m88e1145_config_init()
1490 err = phy_write(phydev, 0x1e, 0xa2da); in m88e1145_config_init()
1494 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { in m88e1145_config_init()
1495 err = m88e1145_config_init_rgmii(phydev); in m88e1145_config_init()
1500 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1145_config_init()
1501 err = m88e1145_config_init_sgmii(phydev); in m88e1145_config_init()
1505 err = m88e1111_set_downshift(phydev, 3); in m88e1145_config_init()
1509 err = marvell_of_reg_init(phydev); in m88e1145_config_init()
1516 static int m88e1540_get_fld(struct phy_device *phydev, u8 *msecs) in m88e1540_get_fld() argument
1520 val = phy_read(phydev, MII_88E1540_COPPER_CTRL3); in m88e1540_get_fld()
1551 static int m88e1540_set_fld(struct phy_device *phydev, const u8 *msecs) in m88e1540_set_fld() argument
1556 return phy_clear_bits(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1562 if (phydev->eee_cfg.eee_enabled) { in m88e1540_set_fld()
1563 phydev_warn(phydev, "Fast Link Down detection requires EEE to be disabled!\n"); in m88e1540_set_fld()
1578 ret = phy_modify(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1583 return phy_set_bits(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1587 static int m88e1540_get_tunable(struct phy_device *phydev, in m88e1540_get_tunable() argument
1592 return m88e1540_get_fld(phydev, data); in m88e1540_get_tunable()
1594 return m88e1011_get_downshift(phydev, data); in m88e1540_get_tunable()
1600 static int m88e1540_set_tunable(struct phy_device *phydev, in m88e1540_set_tunable() argument
1605 return m88e1540_set_fld(phydev, data); in m88e1540_set_tunable()
1607 return m88e1011_set_downshift(phydev, *(const u8 *)data); in m88e1540_set_tunable()
1617 static int m88e6390_errata(struct phy_device *phydev) in m88e6390_errata() argument
1621 err = phy_write(phydev, MII_BMCR, in m88e6390_errata()
1628 err = phy_write_paged(phydev, 0xf8, 0x08, 0x36); in m88e6390_errata()
1632 return genphy_soft_reset(phydev); in m88e6390_errata()
1635 static int m88e6390_config_aneg(struct phy_device *phydev) in m88e6390_config_aneg() argument
1639 err = m88e6390_errata(phydev); in m88e6390_config_aneg()
1643 return m88e1510_config_aneg(phydev); in m88e6390_config_aneg()
1664 static int marvell_read_status_page_an(struct phy_device *phydev, in marvell_read_status_page_an() argument
1671 phydev->link = 0; in marvell_read_status_page_an()
1676 phydev->duplex = DUPLEX_FULL; in marvell_read_status_page_an()
1678 phydev->duplex = DUPLEX_HALF; in marvell_read_status_page_an()
1682 phydev->speed = SPEED_1000; in marvell_read_status_page_an()
1686 phydev->speed = SPEED_100; in marvell_read_status_page_an()
1690 phydev->speed = SPEED_10; in marvell_read_status_page_an()
1695 err = genphy_read_lpa(phydev); in marvell_read_status_page_an()
1699 phy_resolve_aneg_pause(phydev); in marvell_read_status_page_an()
1701 lpa = phy_read(phydev, MII_LPA); in marvell_read_status_page_an()
1706 fiber_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); in marvell_read_status_page_an()
1708 if (phydev->duplex == DUPLEX_FULL) { in marvell_read_status_page_an()
1710 phydev->pause = 0; in marvell_read_status_page_an()
1711 phydev->asym_pause = 0; in marvell_read_status_page_an()
1713 phydev->pause = 1; in marvell_read_status_page_an()
1714 phydev->asym_pause = 1; in marvell_read_status_page_an()
1716 phydev->pause = 1; in marvell_read_status_page_an()
1717 phydev->asym_pause = 0; in marvell_read_status_page_an()
1733 static int marvell_read_status_page(struct phy_device *phydev, int page) in marvell_read_status_page() argument
1739 status = phy_read(phydev, MII_M1011_PHY_STATUS); in marvell_read_status_page()
1747 phydev->link = !!(status & MII_M1011_PHY_STATUS_LINK); in marvell_read_status_page()
1749 err = genphy_update_link(phydev); in marvell_read_status_page()
1759 linkmode_zero(phydev->lp_advertising); in marvell_read_status_page()
1760 phydev->pause = 0; in marvell_read_status_page()
1761 phydev->asym_pause = 0; in marvell_read_status_page()
1762 phydev->speed = SPEED_UNKNOWN; in marvell_read_status_page()
1763 phydev->duplex = DUPLEX_UNKNOWN; in marvell_read_status_page()
1764 phydev->port = fiber ? PORT_FIBRE : PORT_TP; in marvell_read_status_page()
1767 phydev->mdix = ETH_TP_MDI_INVALID; in marvell_read_status_page()
1773 phydev->mdix = status & MII_M1011_PHY_STATUS_MDIX ? in marvell_read_status_page()
1776 phydev->mdix = ETH_TP_MDI_INVALID; in marvell_read_status_page()
1779 if (phydev->autoneg == AUTONEG_ENABLE) in marvell_read_status_page()
1780 err = marvell_read_status_page_an(phydev, fiber, status); in marvell_read_status_page()
1782 err = genphy_read_status_fixed(phydev); in marvell_read_status_page()
1796 static int marvell_read_status(struct phy_device *phydev) in marvell_read_status() argument
1802 phydev->supported) && in marvell_read_status()
1803 phydev->interface != PHY_INTERFACE_MODE_SGMII) { in marvell_read_status()
1804 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_read_status()
1808 err = marvell_read_status_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_read_status()
1819 if (phydev->link) in marvell_read_status()
1823 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1828 return marvell_read_status_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1831 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1840 static int marvell_suspend(struct phy_device *phydev) in marvell_suspend() argument
1846 phydev->supported)) { in marvell_suspend()
1847 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_suspend()
1852 err = genphy_suspend(phydev); in marvell_suspend()
1857 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_suspend()
1863 return genphy_suspend(phydev); in marvell_suspend()
1866 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_suspend()
1875 static int marvell_resume(struct phy_device *phydev) in marvell_resume() argument
1881 phydev->supported)) { in marvell_resume()
1882 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_resume()
1887 err = genphy_resume(phydev); in marvell_resume()
1892 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_resume()
1898 return genphy_resume(phydev); in marvell_resume()
1901 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_resume()
1905 static int marvell_aneg_done(struct phy_device *phydev) in marvell_aneg_done() argument
1907 int retval = phy_read(phydev, MII_M1011_PHY_STATUS); in marvell_aneg_done()
1912 static void m88e1318_get_wol(struct phy_device *phydev, in m88e1318_get_wol() argument
1920 ret = phy_read_paged(phydev, MII_MARVELL_WOL_PAGE, in m88e1318_get_wol()
1932 static int m88e1318_set_wol(struct phy_device *phydev, in m88e1318_set_wol() argument
1937 oldpage = phy_save_page(phydev); in m88e1318_set_wol()
1943 err = marvell_write_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1318_set_wol()
1953 if (!phy_interrupt_is_valid(phydev)) in m88e1318_set_wol()
1954 __phy_read(phydev, MII_M1011_IEVENT); in m88e1318_set_wol()
1957 err = __phy_set_bits(phydev, MII_88E1318S_PHY_CSIER, in m88e1318_set_wol()
1962 err = marvell_write_page(phydev, MII_MARVELL_LED_PAGE); in m88e1318_set_wol()
1967 err = __phy_modify(phydev, MII_88E1318S_PHY_LED_TCR, in m88e1318_set_wol()
1976 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1981 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD2, in m88e1318_set_wol()
1982 ((phydev->attached_dev->dev_addr[5] << 8) | in m88e1318_set_wol()
1983 phydev->attached_dev->dev_addr[4])); in m88e1318_set_wol()
1986 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD1, in m88e1318_set_wol()
1987 ((phydev->attached_dev->dev_addr[3] << 8) | in m88e1318_set_wol()
1988 phydev->attached_dev->dev_addr[2])); in m88e1318_set_wol()
1991 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD0, in m88e1318_set_wol()
1992 ((phydev->attached_dev->dev_addr[1] << 8) | in m88e1318_set_wol()
1993 phydev->attached_dev->dev_addr[0])); in m88e1318_set_wol()
1998 err = __phy_set_bits(phydev, MII_88E1318S_PHY_WOL_CTRL, in m88e1318_set_wol()
2004 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
2009 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, in m88e1318_set_wol()
2017 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
2022 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, 0, in m88e1318_set_wol()
2028 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
2033 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, in m88e1318_set_wol()
2041 return phy_restore_page(phydev, oldpage, err); in m88e1318_set_wol()
2044 static int marvell_get_sset_count(struct phy_device *phydev) in marvell_get_sset_count() argument
2047 phydev->supported)) in marvell_get_sset_count()
2053 static int marvell_get_sset_count_simple(struct phy_device *phydev) in marvell_get_sset_count_simple() argument
2058 static void marvell_get_strings(struct phy_device *phydev, u8 *data) in marvell_get_strings() argument
2060 int count = marvell_get_sset_count(phydev); in marvell_get_strings()
2067 static void marvell_get_strings_simple(struct phy_device *phydev, u8 *data) in marvell_get_strings_simple() argument
2069 int count = marvell_get_sset_count_simple(phydev); in marvell_get_strings_simple()
2076 static u64 marvell_get_stat(struct phy_device *phydev, int i) in marvell_get_stat() argument
2079 struct marvell_priv *priv = phydev->priv; in marvell_get_stat()
2083 val = phy_read_paged(phydev, stat.page, stat.reg); in marvell_get_stat()
2095 static u64 marvell_get_stat_simple(struct phy_device *phydev, int i) in marvell_get_stat_simple() argument
2098 struct marvell_priv *priv = phydev->priv; in marvell_get_stat_simple()
2102 val = phy_read(phydev, stat.reg); in marvell_get_stat_simple()
2114 static void marvell_get_stats(struct phy_device *phydev, in marvell_get_stats() argument
2117 int count = marvell_get_sset_count(phydev); in marvell_get_stats()
2121 data[i] = marvell_get_stat(phydev, i); in marvell_get_stats()
2124 static void marvell_get_stats_simple(struct phy_device *phydev, in marvell_get_stats_simple() argument
2127 int count = marvell_get_sset_count_simple(phydev); in marvell_get_stats_simple()
2131 data[i] = marvell_get_stat_simple(phydev, i); in marvell_get_stats_simple()
2134 static int m88e1510_loopback(struct phy_device *phydev, bool enable) in m88e1510_loopback() argument
2141 bmcr_ctl = mii_bmcr_encode_fixed(phydev->speed, phydev->duplex); in m88e1510_loopback()
2143 err = phy_write(phydev, MII_BMCR, bmcr_ctl); in m88e1510_loopback()
2147 if (phydev->speed == SPEED_1000) in m88e1510_loopback()
2149 else if (phydev->speed == SPEED_100) in m88e1510_loopback()
2152 err = phy_modify_paged(phydev, MII_MARVELL_MSCR_PAGE, in m88e1510_loopback()
2159 err = genphy_soft_reset(phydev); in m88e1510_loopback()
2163 err = phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK, in m88e1510_loopback()
2174 err = phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK, 0); in m88e1510_loopback()
2178 return phy_config_aneg(phydev); in m88e1510_loopback()
2182 static int marvell_vct5_wait_complete(struct phy_device *phydev) in marvell_vct5_wait_complete() argument
2188 val = __phy_read(phydev, MII_VCT5_CTRL); in marvell_vct5_wait_complete()
2196 phydev_err(phydev, "Timeout while waiting for cable test to finish\n"); in marvell_vct5_wait_complete()
2200 static int marvell_vct5_amplitude(struct phy_device *phydev, int pair) in marvell_vct5_amplitude() argument
2207 val = __phy_read(phydev, reg); in marvell_vct5_amplitude()
2231 static int marvell_vct5_amplitude_distance(struct phy_device *phydev, in marvell_vct5_amplitude_distance() argument
2239 err = __phy_write(phydev, MII_VCT5_SAMPLE_POINT_DISTANCE, in marvell_vct5_amplitude_distance()
2249 err = __phy_write(phydev, MII_VCT5_CTRL, reg); in marvell_vct5_amplitude_distance()
2253 err = marvell_vct5_wait_complete(phydev); in marvell_vct5_amplitude_distance()
2261 mV = marvell_vct5_amplitude(phydev, i); in marvell_vct5_amplitude_distance()
2262 ethnl_cable_test_amplitude(phydev, i, mV); in marvell_vct5_amplitude_distance()
2268 static int marvell_vct5_amplitude_graph(struct phy_device *phydev) in marvell_vct5_amplitude_graph() argument
2270 struct marvell_priv *priv = phydev->priv; in marvell_vct5_amplitude_graph()
2286 err = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct5_amplitude_graph()
2297 page = phy_select_page(phydev, MII_MARVELL_VCT5_PAGE); in marvell_vct5_amplitude_graph()
2304 err = marvell_vct5_amplitude_distance(phydev, distance, in marvell_vct5_amplitude_graph()
2315 err = __phy_write(phydev, MII_VCT5_TX_PULSE_CTRL, reg); in marvell_vct5_amplitude_graph()
2322 return phy_restore_page(phydev, page, err); in marvell_vct5_amplitude_graph()
2325 static int marvell_cable_test_start_common(struct phy_device *phydev) in marvell_cable_test_start_common() argument
2332 bmcr = phy_read(phydev, MII_BMCR); in marvell_cable_test_start_common()
2336 bmsr = phy_read(phydev, MII_BMSR); in marvell_cable_test_start_common()
2342 ret = phy_clear_bits(phydev, MII_BMCR, BMCR_ANENABLE); in marvell_cable_test_start_common()
2345 ret = genphy_soft_reset(phydev); in marvell_cable_test_start_common()
2357 static int marvell_vct7_cable_test_start(struct phy_device *phydev) in marvell_vct7_cable_test_start() argument
2359 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_start()
2362 ret = marvell_cable_test_start_common(phydev); in marvell_vct7_cable_test_start()
2371 ret = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct7_cable_test_start()
2380 ret = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct7_cable_test_start()
2385 return phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_start()
2391 static int marvell_vct5_cable_test_tdr_start(struct phy_device *phydev, in marvell_vct5_cable_test_tdr_start() argument
2394 struct marvell_priv *priv = phydev->priv; in marvell_vct5_cable_test_tdr_start()
2410 ret = phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct5_cable_test_tdr_start()
2415 ret = marvell_cable_test_start_common(phydev); in marvell_vct5_cable_test_tdr_start()
2419 ret = ethnl_cable_test_pulse(phydev, 1000); in marvell_vct5_cable_test_tdr_start()
2423 return ethnl_cable_test_step(phydev, in marvell_vct5_cable_test_tdr_start()
2448 static int marvell_vct7_report_length(struct phy_device *phydev, in marvell_vct7_report_length() argument
2454 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_report_length()
2461 ethnl_cable_test_fault_length(phydev, pair, length); in marvell_vct7_report_length()
2482 static int marvell_vct7_cable_test_report(struct phy_device *phydev) in marvell_vct7_cable_test_report() argument
2488 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_report()
2502 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, in marvell_vct7_cable_test_report()
2504 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_B, in marvell_vct7_cable_test_report()
2506 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_C, in marvell_vct7_cable_test_report()
2508 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_D, in marvell_vct7_cable_test_report()
2511 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, MII_VCT7_CTRL); in marvell_vct7_cable_test_report()
2518 marvell_vct7_report_length(phydev, 0, meter); in marvell_vct7_cable_test_report()
2520 marvell_vct7_report_length(phydev, 1, meter); in marvell_vct7_cable_test_report()
2522 marvell_vct7_report_length(phydev, 2, meter); in marvell_vct7_cable_test_report()
2524 marvell_vct7_report_length(phydev, 3, meter); in marvell_vct7_cable_test_report()
2529 static int marvell_vct7_cable_test_get_status(struct phy_device *phydev, in marvell_vct7_cable_test_get_status() argument
2532 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_get_status()
2536 ret = marvell_vct5_amplitude_graph(phydev); in marvell_vct7_cable_test_get_status()
2543 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_get_status()
2552 return marvell_vct7_cable_test_report(phydev); in marvell_vct7_cable_test_get_status()
2558 static int m88e3082_vct_cable_test_start(struct phy_device *phydev) in m88e3082_vct_cable_test_start() argument
2560 struct marvell_priv *priv = phydev->priv; in m88e3082_vct_cable_test_start()
2565 ret = phy_write(phydev, 29, 0x0003); in m88e3082_vct_cable_test_start()
2569 ret = phy_write(phydev, 30, 0x6440); in m88e3082_vct_cable_test_start()
2574 ret = phy_write(phydev, 29, 0x000a); in m88e3082_vct_cable_test_start()
2578 ret = phy_write(phydev, 30, 0x0002); in m88e3082_vct_cable_test_start()
2583 ret = phy_write(phydev, MII_BMCR, in m88e3082_vct_cable_test_start()
2588 ret = phy_write(phydev, MII_VCT_TXPINS, MII_VCT_TXPINS_ENVCT); in m88e3082_vct_cable_test_start()
2592 ret = phy_write(phydev, 29, 0x0003); in m88e3082_vct_cable_test_start()
2596 ret = phy_write(phydev, 30, 0x0); in m88e3082_vct_cable_test_start()
2607 ret = phy_write(phydev, 29, 0x000a); in m88e3082_vct_cable_test_start()
2611 ret = phy_write(phydev, 30, 0x0); in m88e3082_vct_cable_test_start()
2645 static int m88e3082_vct_cable_test_get_status(struct phy_device *phydev, in m88e3082_vct_cable_test_get_status() argument
2649 struct marvell_priv *priv = phydev->priv; in m88e3082_vct_cable_test_get_status()
2655 ret = phy_read(phydev, MII_VCT_TXPINS); in m88e3082_vct_cable_test_get_status()
2665 ret = phy_read(phydev, MII_VCT_RXPINS); in m88e3082_vct_cable_test_get_status()
2682 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, in m88e3082_vct_cable_test_get_status()
2684 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_B, in m88e3082_vct_cable_test_get_status()
2694 ethnl_cable_test_fault_length(phydev, pair, cm); in m88e3082_vct_cable_test_get_status()
2704 ethnl_cable_test_fault_length(phydev, pair, cm); in m88e3082_vct_cable_test_get_status()
2715 ethnl_cable_test_fault_length(phydev, pair, cm); in m88e3082_vct_cable_test_get_status()
2723 ethnl_cable_test_fault_length(phydev, pair, cm); in m88e3082_vct_cable_test_get_status()
2733 return m88e3082_vct_cable_test_start(phydev); in m88e3082_vct_cable_test_get_status()
2740 static int m88e1111_vct_cable_test_start(struct phy_device *phydev) in m88e1111_vct_cable_test_start() argument
2744 ret = marvell_cable_test_start_common(phydev); in m88e1111_vct_cable_test_start()
2750 ret = phy_write(phydev, 29, 0x0018); in m88e1111_vct_cable_test_start()
2754 ret = phy_write(phydev, 30, 0x00c2); in m88e1111_vct_cable_test_start()
2758 ret = phy_write(phydev, 30, 0x00ca); in m88e1111_vct_cable_test_start()
2762 ret = phy_write(phydev, 30, 0x00c2); in m88e1111_vct_cable_test_start()
2766 ret = phy_write_paged(phydev, MII_MARVELL_COPPER_PAGE, MII_VCT_SR, in m88e1111_vct_cable_test_start()
2771 ret = phy_write(phydev, 29, 0x0018); in m88e1111_vct_cable_test_start()
2775 ret = phy_write(phydev, 30, 0x0042); in m88e1111_vct_cable_test_start()
2791 static int m88e1111_vct_cable_test_get_status(struct phy_device *phydev, in m88e1111_vct_cable_test_get_status() argument
2801 ret = phy_read_paged(phydev, i, MII_VCT_SR); in m88e1111_vct_cable_test_get_status()
2813 ethnl_cable_test_result(phydev, i, result); in m88e1111_vct_cable_test_get_status()
2818 ethnl_cable_test_fault_length(phydev, i, cm); in m88e1111_vct_cable_test_get_status()
2828 int (*config)(struct phy_device *phydev);
2829 int (*get_temp)(struct phy_device *phydev, long *temp);
2830 int (*get_temp_critical)(struct phy_device *phydev, long *temp);
2831 int (*set_temp_critical)(struct phy_device *phydev, long temp);
2832 int (*get_temp_alarm)(struct phy_device *phydev, long *alarm);
2836 to_marvell_hwmon_ops(const struct phy_device *phydev) in to_marvell_hwmon_ops() argument
2838 return phydev->drv->driver_data; in to_marvell_hwmon_ops()
2841 static int m88e1121_get_temp(struct phy_device *phydev, long *temp) in m88e1121_get_temp() argument
2849 oldpage = phy_select_page(phydev, MII_MARVELL_MISC_TEST_PAGE); in m88e1121_get_temp()
2854 ret = __phy_read(phydev, MII_88E1121_MISC_TEST); in m88e1121_get_temp()
2858 ret = __phy_write(phydev, MII_88E1121_MISC_TEST, in m88e1121_get_temp()
2866 val = __phy_read(phydev, MII_88E1121_MISC_TEST); in m88e1121_get_temp()
2873 ret = __phy_write(phydev, MII_88E1121_MISC_TEST, in m88e1121_get_temp()
2881 return phy_restore_page(phydev, oldpage, ret); in m88e1121_get_temp()
2884 static int m88e1510_get_temp(struct phy_device *phydev, long *temp) in m88e1510_get_temp() argument
2890 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp()
2900 static int m88e1510_get_temp_critical(struct phy_device *phydev, long *temp) in m88e1510_get_temp_critical() argument
2906 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp_critical()
2919 static int m88e1510_set_temp_critical(struct phy_device *phydev, long temp) in m88e1510_set_temp_critical() argument
2924 return phy_modify_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_set_temp_critical()
2930 static int m88e1510_get_temp_alarm(struct phy_device *phydev, long *alarm) in m88e1510_get_temp_alarm() argument
2936 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp_alarm()
2946 static int m88e6390_get_temp(struct phy_device *phydev, long *temp) in m88e6390_get_temp() argument
2955 oldpage = phy_select_page(phydev, MII_MARVELL_MISC_TEST_PAGE); in m88e6390_get_temp()
2960 ret = __phy_read(phydev, MII_88E6390_MISC_TEST); in m88e6390_get_temp()
2967 ret = __phy_write(phydev, MII_88E6390_MISC_TEST, ret); in m88e6390_get_temp()
2978 ret = __phy_read(phydev, MII_88E6390_TEMP_SENSOR); in m88e6390_get_temp()
2988 ret = __phy_read(phydev, MII_88E6390_MISC_TEST); in m88e6390_get_temp()
2995 ret = __phy_write(phydev, MII_88E6390_MISC_TEST, ret); in m88e6390_get_temp()
2998 phy_restore_page(phydev, oldpage, ret); in m88e6390_get_temp()
3003 static int m88e6393_get_temp(struct phy_device *phydev, long *temp) in m88e6393_get_temp() argument
3007 err = m88e1510_get_temp(phydev, temp); in m88e6393_get_temp()
3017 static int m88e6393_get_temp_critical(struct phy_device *phydev, long *temp) in m88e6393_get_temp_critical() argument
3023 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e6393_get_temp_critical()
3034 static int m88e6393_set_temp_critical(struct phy_device *phydev, long temp) in m88e6393_set_temp_critical() argument
3038 return phy_modify_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e6393_set_temp_critical()
3044 static int m88e6393_hwmon_config(struct phy_device *phydev) in m88e6393_hwmon_config() argument
3048 err = m88e6393_set_temp_critical(phydev, 100000); in m88e6393_hwmon_config()
3052 return phy_modify_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e6393_hwmon_config()
3065 struct phy_device *phydev = dev_get_drvdata(dev); in marvell_hwmon_read() local
3066 const struct marvell_hwmon_ops *ops = to_marvell_hwmon_ops(phydev); in marvell_hwmon_read()
3072 err = ops->get_temp(phydev, temp); in marvell_hwmon_read()
3076 err = ops->get_temp_critical(phydev, temp); in marvell_hwmon_read()
3080 err = ops->get_temp_alarm(phydev, temp); in marvell_hwmon_read()
3090 struct phy_device *phydev = dev_get_drvdata(dev); in marvell_hwmon_write() local
3091 const struct marvell_hwmon_ops *ops = to_marvell_hwmon_ops(phydev); in marvell_hwmon_write()
3097 err = ops->set_temp_critical(phydev, temp); in marvell_hwmon_write()
3108 const struct phy_device *phydev = data; in marvell_hwmon_is_visible() local
3109 const struct marvell_hwmon_ops *ops = to_marvell_hwmon_ops(phydev); in marvell_hwmon_is_visible()
3168 static int marvell_hwmon_name(struct phy_device *phydev) in marvell_hwmon_name() argument
3170 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_name()
3171 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_name()
3188 static int marvell_hwmon_probe(struct phy_device *phydev) in marvell_hwmon_probe() argument
3190 const struct marvell_hwmon_ops *ops = to_marvell_hwmon_ops(phydev); in marvell_hwmon_probe()
3191 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_probe()
3192 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_probe()
3198 err = marvell_hwmon_name(phydev); in marvell_hwmon_probe()
3203 dev, priv->hwmon_name, phydev, &marvell_hwmon_chip_info, NULL); in marvell_hwmon_probe()
3208 err = ops->config(phydev); in marvell_hwmon_probe()
3242 static int marvell_hwmon_probe(struct phy_device *phydev) in marvell_hwmon_probe() argument
3248 static int m88e1318_led_brightness_set(struct phy_device *phydev, in m88e1318_led_brightness_set() argument
3253 reg = phy_read_paged(phydev, MII_MARVELL_LED_PAGE, in m88e1318_led_brightness_set()
3272 return phy_write_paged(phydev, MII_MARVELL_LED_PAGE, in m88e1318_led_brightness_set()
3276 static int m88e1318_led_blink_set(struct phy_device *phydev, u8 index, in m88e1318_led_blink_set() argument
3282 reg = phy_read_paged(phydev, MII_MARVELL_LED_PAGE, in m88e1318_led_blink_set()
3301 return phy_write_paged(phydev, MII_MARVELL_LED_PAGE, in m88e1318_led_blink_set()
3506 static int m88e1318_led_hw_is_supported(struct phy_device *phydev, u8 index, in m88e1318_led_hw_is_supported() argument
3524 static int m88e1318_led_hw_control_set(struct phy_device *phydev, u8 index, in m88e1318_led_hw_control_set() argument
3542 reg = phy_read_paged(phydev, MII_MARVELL_LED_PAGE, in m88e1318_led_hw_control_set()
3549 return phy_write_paged(phydev, MII_MARVELL_LED_PAGE, in m88e1318_led_hw_control_set()
3553 static int m88e1318_led_hw_control_get(struct phy_device *phydev, u8 index, in m88e1318_led_hw_control_get() argument
3561 reg = phy_read_paged(phydev, MII_MARVELL_LED_PAGE, in m88e1318_led_hw_control_get()
3571 static int marvell_probe(struct phy_device *phydev) in marvell_probe() argument
3575 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in marvell_probe()
3579 phydev->priv = priv; in marvell_probe()
3581 return marvell_hwmon_probe(phydev); in marvell_probe()
3587 struct phy_device *phydev = upstream; in m88e1510_sfp_insert() local
3596 dev = &phydev->mdio.dev; in m88e1510_sfp_insert()
3598 sfp_parse_support(phydev->sfp_bus, id, supported, interfaces); in m88e1510_sfp_insert()
3599 interface = sfp_select_interface(phydev->sfp_bus, supported); in m88e1510_sfp_insert()
3622 oldpage = phy_select_page(phydev, MII_MARVELL_MODE_PAGE); in m88e1510_sfp_insert()
3626 ret = __phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_sfp_insert()
3631 ret = __phy_set_bits(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_sfp_insert()
3635 return phy_restore_page(phydev, oldpage, ret); in m88e1510_sfp_insert()
3640 struct phy_device *phydev = upstream; in m88e1510_sfp_remove() local
3644 oldpage = phy_select_page(phydev, MII_MARVELL_MODE_PAGE); in m88e1510_sfp_remove()
3648 ret = __phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_sfp_remove()
3654 ret = __phy_set_bits(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_sfp_remove()
3658 phy_restore_page(phydev, oldpage, ret); in m88e1510_sfp_remove()
3670 static int m88e1510_probe(struct phy_device *phydev) in m88e1510_probe() argument
3674 err = marvell_probe(phydev); in m88e1510_probe()
3678 return phy_sfp_probe(phydev, &m88e1510_sfp_ops); in m88e1510_probe()