• Home
  • Raw
  • Download

Lines Matching full:phydev

285 static int marvell_read_page(struct phy_device *phydev)  in marvell_read_page()  argument
287 return __phy_read(phydev, MII_MARVELL_PHY_PAGE); in marvell_read_page()
290 static int marvell_write_page(struct phy_device *phydev, int page) in marvell_write_page() argument
292 return __phy_write(phydev, MII_MARVELL_PHY_PAGE, page); in marvell_write_page()
295 static int marvell_set_page(struct phy_device *phydev, int page) in marvell_set_page() argument
297 return phy_write(phydev, MII_MARVELL_PHY_PAGE, page); in marvell_set_page()
300 static int marvell_ack_interrupt(struct phy_device *phydev) in marvell_ack_interrupt() argument
305 err = phy_read(phydev, MII_M1011_IEVENT); in marvell_ack_interrupt()
313 static int marvell_config_intr(struct phy_device *phydev) in marvell_config_intr() argument
317 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) in marvell_config_intr()
318 err = phy_write(phydev, MII_M1011_IMASK, in marvell_config_intr()
321 err = phy_write(phydev, MII_M1011_IMASK, in marvell_config_intr()
327 static int marvell_set_polarity(struct phy_device *phydev, int polarity) in marvell_set_polarity() argument
334 reg = phy_read(phydev, MII_M1011_PHY_SCR); in marvell_set_polarity()
356 err = phy_write(phydev, MII_M1011_PHY_SCR, val); in marvell_set_polarity()
364 static int marvell_config_aneg(struct phy_device *phydev) in marvell_config_aneg() argument
369 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in marvell_config_aneg()
375 err = phy_write(phydev, MII_M1111_PHY_LED_CONTROL, in marvell_config_aneg()
380 err = genphy_config_aneg(phydev); in marvell_config_aneg()
384 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in marvell_config_aneg()
389 err = genphy_soft_reset(phydev); in marvell_config_aneg()
397 static int m88e1101_config_aneg(struct phy_device *phydev) in m88e1101_config_aneg() argument
405 err = genphy_soft_reset(phydev); in m88e1101_config_aneg()
409 err = phy_write(phydev, 0x1d, 0x1f); in m88e1101_config_aneg()
413 err = phy_write(phydev, 0x1e, 0x200c); in m88e1101_config_aneg()
417 err = phy_write(phydev, 0x1d, 0x5); in m88e1101_config_aneg()
421 err = phy_write(phydev, 0x1e, 0); in m88e1101_config_aneg()
425 err = phy_write(phydev, 0x1e, 0x100); in m88e1101_config_aneg()
429 return marvell_config_aneg(phydev); in m88e1101_config_aneg()
434 * marvell,reg-init property stored in the of_node for the phydev.
446 static int marvell_of_reg_init(struct phy_device *phydev) in marvell_of_reg_init() argument
451 if (!phydev->mdio.dev.of_node) in marvell_of_reg_init()
454 paddr = of_get_property(phydev->mdio.dev.of_node, in marvell_of_reg_init()
459 saved_page = phy_save_page(phydev); in marvell_of_reg_init()
474 ret = marvell_write_page(phydev, page); in marvell_of_reg_init()
481 val = __phy_read(phydev, reg); in marvell_of_reg_init()
490 ret = __phy_write(phydev, reg, val); in marvell_of_reg_init()
495 return phy_restore_page(phydev, saved_page, ret); in marvell_of_reg_init()
498 static int marvell_of_reg_init(struct phy_device *phydev) in marvell_of_reg_init() argument
504 static int m88e1121_config_aneg_rgmii_delays(struct phy_device *phydev) in m88e1121_config_aneg_rgmii_delays() argument
508 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) in m88e1121_config_aneg_rgmii_delays()
511 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in m88e1121_config_aneg_rgmii_delays()
513 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in m88e1121_config_aneg_rgmii_delays()
518 return phy_modify_paged(phydev, MII_MARVELL_MSCR_PAGE, in m88e1121_config_aneg_rgmii_delays()
523 static int m88e1121_config_aneg(struct phy_device *phydev) in m88e1121_config_aneg() argument
528 if (phy_interface_is_rgmii(phydev)) { in m88e1121_config_aneg()
529 err = m88e1121_config_aneg_rgmii_delays(phydev); in m88e1121_config_aneg()
534 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1121_config_aneg()
540 err = genphy_config_aneg(phydev); in m88e1121_config_aneg()
544 if (phydev->autoneg != AUTONEG_ENABLE || changed) { in m88e1121_config_aneg()
548 err = genphy_soft_reset(phydev); in m88e1121_config_aneg()
556 static int m88e1318_config_aneg(struct phy_device *phydev) in m88e1318_config_aneg() argument
560 err = phy_modify_paged(phydev, MII_MARVELL_MSCR_PAGE, in m88e1318_config_aneg()
566 return m88e1121_config_aneg(phydev); in m88e1318_config_aneg()
597 * @phydev: target phy_device struct
604 static int marvell_config_aneg_fiber(struct phy_device *phydev) in marvell_config_aneg_fiber() argument
610 if (phydev->autoneg != AUTONEG_ENABLE) in marvell_config_aneg_fiber()
611 return genphy_setup_forced(phydev); in marvell_config_aneg_fiber()
614 linkmode_and(phydev->advertising, phydev->advertising, in marvell_config_aneg_fiber()
615 phydev->supported); in marvell_config_aneg_fiber()
617 adv = linkmode_adv_to_fiber_adv_t(phydev->advertising); in marvell_config_aneg_fiber()
620 err = phy_modify_changed(phydev, MII_ADVERTISE, in marvell_config_aneg_fiber()
629 return genphy_check_and_restart_aneg(phydev, changed); in marvell_config_aneg_fiber()
632 static int m88e1510_config_aneg(struct phy_device *phydev) in m88e1510_config_aneg() argument
636 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
641 err = m88e1318_config_aneg(phydev); in m88e1510_config_aneg()
646 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) in m88e1510_config_aneg()
650 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in m88e1510_config_aneg()
654 err = marvell_config_aneg_fiber(phydev); in m88e1510_config_aneg()
658 return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
661 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_aneg()
665 static void marvell_config_led(struct phy_device *phydev) in marvell_config_led() argument
670 switch (MARVELL_PHY_FAMILY_ID(phydev->phy_id)) { in marvell_config_led()
682 if (phydev->dev_flags & MARVELL_PHY_LED0_LINK_LED1_ACTIVE) in marvell_config_led()
691 err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE, MII_PHY_LED_CTRL, in marvell_config_led()
694 phydev_warn(phydev, "Fail to config marvell phy LED.\n"); in marvell_config_led()
697 static int marvell_config_init(struct phy_device *phydev) in marvell_config_init() argument
700 marvell_config_led(phydev); in marvell_config_init()
703 return marvell_of_reg_init(phydev); in marvell_config_init()
706 static int m88e3016_config_init(struct phy_device *phydev) in m88e3016_config_init() argument
711 ret = phy_modify(phydev, MII_88E3016_PHY_SPEC_CTRL, in m88e3016_config_init()
717 return marvell_config_init(phydev); in m88e3016_config_init()
720 static int m88e1111_config_init_hwcfg_mode(struct phy_device *phydev, in m88e1111_config_init_hwcfg_mode() argument
727 return phy_modify(phydev, MII_M1111_PHY_EXT_SR, in m88e1111_config_init_hwcfg_mode()
734 static int m88e1111_config_init_rgmii_delays(struct phy_device *phydev) in m88e1111_config_init_rgmii_delays() argument
738 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { in m88e1111_config_init_rgmii_delays()
740 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) { in m88e1111_config_init_rgmii_delays()
742 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) { in m88e1111_config_init_rgmii_delays()
748 return phy_modify(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_config_init_rgmii_delays()
753 static int m88e1111_config_init_rgmii(struct phy_device *phydev) in m88e1111_config_init_rgmii() argument
758 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1111_config_init_rgmii()
762 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR); in m88e1111_config_init_rgmii()
773 return phy_write(phydev, MII_M1111_PHY_EXT_SR, temp); in m88e1111_config_init_rgmii()
776 static int m88e1111_config_init_sgmii(struct phy_device *phydev) in m88e1111_config_init_sgmii() argument
781 phydev, in m88e1111_config_init_sgmii()
788 return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1111_config_init_sgmii()
791 static int m88e1111_config_init_rtbi(struct phy_device *phydev) in m88e1111_config_init_rtbi() argument
795 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1111_config_init_rtbi()
800 phydev, in m88e1111_config_init_rtbi()
807 err = genphy_soft_reset(phydev); in m88e1111_config_init_rtbi()
812 phydev, in m88e1111_config_init_rtbi()
817 static int m88e1111_config_init(struct phy_device *phydev) in m88e1111_config_init() argument
821 if (phy_interface_is_rgmii(phydev)) { in m88e1111_config_init()
822 err = m88e1111_config_init_rgmii(phydev); in m88e1111_config_init()
827 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1111_config_init()
828 err = m88e1111_config_init_sgmii(phydev); in m88e1111_config_init()
833 if (phydev->interface == PHY_INTERFACE_MODE_RTBI) { in m88e1111_config_init()
834 err = m88e1111_config_init_rtbi(phydev); in m88e1111_config_init()
839 err = marvell_of_reg_init(phydev); in m88e1111_config_init()
843 return genphy_soft_reset(phydev); in m88e1111_config_init()
846 static int m88e1111_get_downshift(struct phy_device *phydev, u8 *data) in m88e1111_get_downshift() argument
850 val = phy_read(phydev, MII_M1111_PHY_EXT_CR); in m88e1111_get_downshift()
862 static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt) in m88e1111_set_downshift() argument
870 err = phy_clear_bits(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_set_downshift()
876 err = phy_modify(phydev, MII_M1111_PHY_EXT_CR, in m88e1111_set_downshift()
885 return genphy_soft_reset(phydev); in m88e1111_set_downshift()
888 static int m88e1111_get_tunable(struct phy_device *phydev, in m88e1111_get_tunable() argument
893 return m88e1111_get_downshift(phydev, data); in m88e1111_get_tunable()
899 static int m88e1111_set_tunable(struct phy_device *phydev, in m88e1111_set_tunable() argument
904 return m88e1111_set_downshift(phydev, *(const u8 *)data); in m88e1111_set_tunable()
910 static int m88e1011_get_downshift(struct phy_device *phydev, u8 *data) in m88e1011_get_downshift() argument
914 val = phy_read(phydev, MII_M1011_PHY_SCR); in m88e1011_get_downshift()
926 static int m88e1011_set_downshift(struct phy_device *phydev, u8 cnt) in m88e1011_set_downshift() argument
934 err = phy_clear_bits(phydev, MII_M1011_PHY_SCR, in m88e1011_set_downshift()
940 err = phy_modify(phydev, MII_M1011_PHY_SCR, in m88e1011_set_downshift()
949 return genphy_soft_reset(phydev); in m88e1011_set_downshift()
952 static int m88e1011_get_tunable(struct phy_device *phydev, in m88e1011_get_tunable() argument
957 return m88e1011_get_downshift(phydev, data); in m88e1011_get_tunable()
963 static int m88e1011_set_tunable(struct phy_device *phydev, in m88e1011_set_tunable() argument
968 return m88e1011_set_downshift(phydev, *(const u8 *)data); in m88e1011_set_tunable()
974 static int m88e1116r_config_init(struct phy_device *phydev) in m88e1116r_config_init() argument
978 err = genphy_soft_reset(phydev); in m88e1116r_config_init()
984 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1116r_config_init()
988 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1116r_config_init()
992 err = m88e1011_set_downshift(phydev, 8); in m88e1116r_config_init()
996 if (phy_interface_is_rgmii(phydev)) { in m88e1116r_config_init()
997 err = m88e1121_config_aneg_rgmii_delays(phydev); in m88e1116r_config_init()
1002 err = genphy_soft_reset(phydev); in m88e1116r_config_init()
1006 return marvell_config_init(phydev); in m88e1116r_config_init()
1009 static int m88e1318_config_init(struct phy_device *phydev) in m88e1318_config_init() argument
1011 if (phy_interrupt_is_valid(phydev)) { in m88e1318_config_init()
1013 phydev, MII_MARVELL_LED_PAGE, in m88e1318_config_init()
1022 return marvell_config_init(phydev); in m88e1318_config_init()
1025 static int m88e1510_config_init(struct phy_device *phydev) in m88e1510_config_init() argument
1030 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1510_config_init()
1032 err = marvell_set_page(phydev, 18); in m88e1510_config_init()
1037 err = phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, in m88e1510_config_init()
1044 err = phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, 0, in m88e1510_config_init()
1050 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1510_config_init()
1055 return m88e1318_config_init(phydev); in m88e1510_config_init()
1058 static int m88e1118_config_aneg(struct phy_device *phydev) in m88e1118_config_aneg() argument
1062 err = genphy_soft_reset(phydev); in m88e1118_config_aneg()
1066 err = marvell_set_polarity(phydev, phydev->mdix_ctrl); in m88e1118_config_aneg()
1070 err = genphy_config_aneg(phydev); in m88e1118_config_aneg()
1074 static int m88e1118_config_init(struct phy_device *phydev) in m88e1118_config_init() argument
1079 err = marvell_set_page(phydev, MII_MARVELL_MSCR_PAGE); in m88e1118_config_init()
1084 err = phy_write(phydev, 0x15, 0x1070); in m88e1118_config_init()
1089 err = marvell_set_page(phydev, MII_MARVELL_LED_PAGE); in m88e1118_config_init()
1093 if (phy_interface_is_rgmii(phydev)) { in m88e1118_config_init()
1094 err = m88e1121_config_aneg_rgmii_delays(phydev); in m88e1118_config_init()
1100 if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS) in m88e1118_config_init()
1101 err = phy_write(phydev, 0x10, 0x1100); in m88e1118_config_init()
1103 err = phy_write(phydev, 0x10, 0x021e); in m88e1118_config_init()
1107 err = marvell_of_reg_init(phydev); in m88e1118_config_init()
1112 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1118_config_init()
1116 return genphy_soft_reset(phydev); in m88e1118_config_init()
1119 static int m88e1149_config_init(struct phy_device *phydev) in m88e1149_config_init() argument
1124 err = marvell_set_page(phydev, MII_MARVELL_MSCR_PAGE); in m88e1149_config_init()
1129 err = phy_write(phydev, 0x15, 0x1048); in m88e1149_config_init()
1133 err = marvell_of_reg_init(phydev); in m88e1149_config_init()
1138 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1149_config_init()
1142 return genphy_soft_reset(phydev); in m88e1149_config_init()
1145 static int m88e1145_config_init_rgmii(struct phy_device *phydev) in m88e1145_config_init_rgmii() argument
1149 err = m88e1111_config_init_rgmii_delays(phydev); in m88e1145_config_init_rgmii()
1153 if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) { in m88e1145_config_init_rgmii()
1154 err = phy_write(phydev, 0x1d, 0x0012); in m88e1145_config_init_rgmii()
1158 err = phy_modify(phydev, 0x1e, 0x0fc0, in m88e1145_config_init_rgmii()
1164 err = phy_write(phydev, 0x1d, 0x3); in m88e1145_config_init_rgmii()
1168 err = phy_write(phydev, 0x1e, 0x8000); in m88e1145_config_init_rgmii()
1173 static int m88e1145_config_init_sgmii(struct phy_device *phydev) in m88e1145_config_init_sgmii() argument
1176 phydev, MII_M1111_HWCFG_MODE_SGMII_NO_CLK, in m88e1145_config_init_sgmii()
1180 static int m88e1145_config_init(struct phy_device *phydev) in m88e1145_config_init() argument
1185 err = phy_write(phydev, 0x1d, 0x001b); in m88e1145_config_init()
1189 err = phy_write(phydev, 0x1e, 0x418f); in m88e1145_config_init()
1193 err = phy_write(phydev, 0x1d, 0x0016); in m88e1145_config_init()
1197 err = phy_write(phydev, 0x1e, 0xa2da); in m88e1145_config_init()
1201 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { in m88e1145_config_init()
1202 err = m88e1145_config_init_rgmii(phydev); in m88e1145_config_init()
1207 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in m88e1145_config_init()
1208 err = m88e1145_config_init_sgmii(phydev); in m88e1145_config_init()
1213 err = marvell_of_reg_init(phydev); in m88e1145_config_init()
1220 static int m88e1540_get_fld(struct phy_device *phydev, u8 *msecs) in m88e1540_get_fld() argument
1224 val = phy_read(phydev, MII_88E1540_COPPER_CTRL3); in m88e1540_get_fld()
1255 static int m88e1540_set_fld(struct phy_device *phydev, const u8 *msecs) in m88e1540_set_fld() argument
1261 return phy_clear_bits(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1267 ret = phy_ethtool_get_eee(phydev, &eee); in m88e1540_set_fld()
1269 phydev_warn(phydev, "Fast Link Down detection requires EEE to be disabled!\n"); in m88e1540_set_fld()
1284 ret = phy_modify(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1289 return phy_set_bits(phydev, MII_88E1540_COPPER_CTRL3, in m88e1540_set_fld()
1293 static int m88e1540_get_tunable(struct phy_device *phydev, in m88e1540_get_tunable() argument
1298 return m88e1540_get_fld(phydev, data); in m88e1540_get_tunable()
1300 return m88e1011_get_downshift(phydev, data); in m88e1540_get_tunable()
1306 static int m88e1540_set_tunable(struct phy_device *phydev, in m88e1540_set_tunable() argument
1311 return m88e1540_set_fld(phydev, data); in m88e1540_set_tunable()
1313 return m88e1011_set_downshift(phydev, *(const u8 *)data); in m88e1540_set_tunable()
1323 static int m88e6390_errata(struct phy_device *phydev) in m88e6390_errata() argument
1327 err = phy_write(phydev, MII_BMCR, in m88e6390_errata()
1334 err = phy_write_paged(phydev, 0xf8, 0x08, 0x36); in m88e6390_errata()
1338 return genphy_soft_reset(phydev); in m88e6390_errata()
1341 static int m88e6390_config_aneg(struct phy_device *phydev) in m88e6390_config_aneg() argument
1345 err = m88e6390_errata(phydev); in m88e6390_config_aneg()
1349 return m88e1510_config_aneg(phydev); in m88e6390_config_aneg()
1370 static int marvell_read_status_page_an(struct phy_device *phydev, in marvell_read_status_page_an() argument
1377 phydev->link = 0; in marvell_read_status_page_an()
1382 phydev->duplex = DUPLEX_FULL; in marvell_read_status_page_an()
1384 phydev->duplex = DUPLEX_HALF; in marvell_read_status_page_an()
1388 phydev->speed = SPEED_1000; in marvell_read_status_page_an()
1392 phydev->speed = SPEED_100; in marvell_read_status_page_an()
1396 phydev->speed = SPEED_10; in marvell_read_status_page_an()
1401 err = genphy_read_lpa(phydev); in marvell_read_status_page_an()
1405 phy_resolve_aneg_pause(phydev); in marvell_read_status_page_an()
1407 lpa = phy_read(phydev, MII_LPA); in marvell_read_status_page_an()
1412 fiber_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); in marvell_read_status_page_an()
1414 if (phydev->duplex == DUPLEX_FULL) { in marvell_read_status_page_an()
1416 phydev->pause = 0; in marvell_read_status_page_an()
1417 phydev->asym_pause = 0; in marvell_read_status_page_an()
1419 phydev->pause = 1; in marvell_read_status_page_an()
1420 phydev->asym_pause = 1; in marvell_read_status_page_an()
1422 phydev->pause = 1; in marvell_read_status_page_an()
1423 phydev->asym_pause = 0; in marvell_read_status_page_an()
1439 static int marvell_read_status_page(struct phy_device *phydev, int page) in marvell_read_status_page() argument
1445 status = phy_read(phydev, MII_M1011_PHY_STATUS); in marvell_read_status_page()
1453 phydev->link = !!(status & MII_M1011_PHY_STATUS_LINK); in marvell_read_status_page()
1455 err = genphy_update_link(phydev); in marvell_read_status_page()
1465 linkmode_zero(phydev->lp_advertising); in marvell_read_status_page()
1466 phydev->pause = 0; in marvell_read_status_page()
1467 phydev->asym_pause = 0; in marvell_read_status_page()
1468 phydev->speed = SPEED_UNKNOWN; in marvell_read_status_page()
1469 phydev->duplex = DUPLEX_UNKNOWN; in marvell_read_status_page()
1470 phydev->port = fiber ? PORT_FIBRE : PORT_TP; in marvell_read_status_page()
1472 if (phydev->autoneg == AUTONEG_ENABLE) in marvell_read_status_page()
1473 err = marvell_read_status_page_an(phydev, fiber, status); in marvell_read_status_page()
1475 err = genphy_read_status_fixed(phydev); in marvell_read_status_page()
1489 static int marvell_read_status(struct phy_device *phydev) in marvell_read_status() argument
1495 phydev->supported) && in marvell_read_status()
1496 phydev->interface != PHY_INTERFACE_MODE_SGMII) { in marvell_read_status()
1497 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_read_status()
1501 err = marvell_read_status_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_read_status()
1512 if (phydev->link) in marvell_read_status()
1516 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1521 return marvell_read_status_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1524 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_read_status()
1533 static int marvell_suspend(struct phy_device *phydev) in marvell_suspend() argument
1539 phydev->supported)) { in marvell_suspend()
1540 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_suspend()
1545 err = genphy_suspend(phydev); in marvell_suspend()
1550 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_suspend()
1556 return genphy_suspend(phydev); in marvell_suspend()
1559 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_suspend()
1568 static int marvell_resume(struct phy_device *phydev) in marvell_resume() argument
1574 phydev->supported)) { in marvell_resume()
1575 err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); in marvell_resume()
1580 err = genphy_resume(phydev); in marvell_resume()
1585 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_resume()
1591 return genphy_resume(phydev); in marvell_resume()
1594 marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); in marvell_resume()
1598 static int marvell_aneg_done(struct phy_device *phydev) in marvell_aneg_done() argument
1600 int retval = phy_read(phydev, MII_M1011_PHY_STATUS); in marvell_aneg_done()
1605 static int m88e1121_did_interrupt(struct phy_device *phydev) in m88e1121_did_interrupt() argument
1609 imask = phy_read(phydev, MII_M1011_IEVENT); in m88e1121_did_interrupt()
1617 static void m88e1318_get_wol(struct phy_device *phydev, in m88e1318_get_wol() argument
1625 ret = phy_read_paged(phydev, MII_MARVELL_WOL_PAGE, in m88e1318_get_wol()
1631 static int m88e1318_set_wol(struct phy_device *phydev, in m88e1318_set_wol() argument
1636 oldpage = phy_save_page(phydev); in m88e1318_set_wol()
1642 err = marvell_write_page(phydev, MII_MARVELL_COPPER_PAGE); in m88e1318_set_wol()
1652 if (!phy_interrupt_is_valid(phydev)) in m88e1318_set_wol()
1653 __phy_read(phydev, MII_M1011_IEVENT); in m88e1318_set_wol()
1656 err = __phy_modify(phydev, MII_88E1318S_PHY_CSIER, 0, in m88e1318_set_wol()
1661 err = marvell_write_page(phydev, MII_MARVELL_LED_PAGE); in m88e1318_set_wol()
1666 err = __phy_modify(phydev, MII_88E1318S_PHY_LED_TCR, in m88e1318_set_wol()
1673 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1678 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD2, in m88e1318_set_wol()
1679 ((phydev->attached_dev->dev_addr[5] << 8) | in m88e1318_set_wol()
1680 phydev->attached_dev->dev_addr[4])); in m88e1318_set_wol()
1683 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD1, in m88e1318_set_wol()
1684 ((phydev->attached_dev->dev_addr[3] << 8) | in m88e1318_set_wol()
1685 phydev->attached_dev->dev_addr[2])); in m88e1318_set_wol()
1688 err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD0, in m88e1318_set_wol()
1689 ((phydev->attached_dev->dev_addr[1] << 8) | in m88e1318_set_wol()
1690 phydev->attached_dev->dev_addr[0])); in m88e1318_set_wol()
1695 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, 0, in m88e1318_set_wol()
1701 err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); in m88e1318_set_wol()
1706 err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, in m88e1318_set_wol()
1714 return phy_restore_page(phydev, oldpage, err); in m88e1318_set_wol()
1717 static int marvell_get_sset_count(struct phy_device *phydev) in marvell_get_sset_count() argument
1720 phydev->supported)) in marvell_get_sset_count()
1726 static void marvell_get_strings(struct phy_device *phydev, u8 *data) in marvell_get_strings() argument
1728 int count = marvell_get_sset_count(phydev); in marvell_get_strings()
1737 static u64 marvell_get_stat(struct phy_device *phydev, int i) in marvell_get_stat() argument
1740 struct marvell_priv *priv = phydev->priv; in marvell_get_stat()
1744 val = phy_read_paged(phydev, stat.page, stat.reg); in marvell_get_stat()
1756 static void marvell_get_stats(struct phy_device *phydev, in marvell_get_stats() argument
1759 int count = marvell_get_sset_count(phydev); in marvell_get_stats()
1763 data[i] = marvell_get_stat(phydev, i); in marvell_get_stats()
1766 static int marvell_vct5_wait_complete(struct phy_device *phydev) in marvell_vct5_wait_complete() argument
1772 val = __phy_read(phydev, MII_VCT5_CTRL); in marvell_vct5_wait_complete()
1780 phydev_err(phydev, "Timeout while waiting for cable test to finish\n"); in marvell_vct5_wait_complete()
1784 static int marvell_vct5_amplitude(struct phy_device *phydev, int pair) in marvell_vct5_amplitude() argument
1791 val = __phy_read(phydev, reg); in marvell_vct5_amplitude()
1815 static int marvell_vct5_amplitude_distance(struct phy_device *phydev, in marvell_vct5_amplitude_distance() argument
1823 err = __phy_write(phydev, MII_VCT5_SAMPLE_POINT_DISTANCE, in marvell_vct5_amplitude_distance()
1833 err = __phy_write(phydev, MII_VCT5_CTRL, reg); in marvell_vct5_amplitude_distance()
1837 err = marvell_vct5_wait_complete(phydev); in marvell_vct5_amplitude_distance()
1845 mV = marvell_vct5_amplitude(phydev, i); in marvell_vct5_amplitude_distance()
1846 ethnl_cable_test_amplitude(phydev, i, mV); in marvell_vct5_amplitude_distance()
1852 static int marvell_vct5_amplitude_graph(struct phy_device *phydev) in marvell_vct5_amplitude_graph() argument
1854 struct marvell_priv *priv = phydev->priv; in marvell_vct5_amplitude_graph()
1870 err = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct5_amplitude_graph()
1881 page = phy_select_page(phydev, MII_MARVELL_VCT5_PAGE); in marvell_vct5_amplitude_graph()
1888 err = marvell_vct5_amplitude_distance(phydev, distance, in marvell_vct5_amplitude_graph()
1899 err = __phy_write(phydev, MII_VCT5_TX_PULSE_CTRL, reg); in marvell_vct5_amplitude_graph()
1906 return phy_restore_page(phydev, page, err); in marvell_vct5_amplitude_graph()
1909 static int marvell_cable_test_start_common(struct phy_device *phydev) in marvell_cable_test_start_common() argument
1916 bmcr = phy_read(phydev, MII_BMCR); in marvell_cable_test_start_common()
1920 bmsr = phy_read(phydev, MII_BMSR); in marvell_cable_test_start_common()
1926 ret = phy_modify(phydev, MII_BMCR, BMCR_ANENABLE, 0); in marvell_cable_test_start_common()
1929 ret = genphy_soft_reset(phydev); in marvell_cable_test_start_common()
1941 static int marvell_vct7_cable_test_start(struct phy_device *phydev) in marvell_vct7_cable_test_start() argument
1943 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_start()
1946 ret = marvell_cable_test_start_common(phydev); in marvell_vct7_cable_test_start()
1955 ret = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct7_cable_test_start()
1964 ret = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, in marvell_vct7_cable_test_start()
1969 return phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_start()
1975 static int marvell_vct5_cable_test_tdr_start(struct phy_device *phydev, in marvell_vct5_cable_test_tdr_start() argument
1978 struct marvell_priv *priv = phydev->priv; in marvell_vct5_cable_test_tdr_start()
1994 ret = phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct5_cable_test_tdr_start()
1999 ret = marvell_cable_test_start_common(phydev); in marvell_vct5_cable_test_tdr_start()
2003 ret = ethnl_cable_test_pulse(phydev, 1000); in marvell_vct5_cable_test_tdr_start()
2007 return ethnl_cable_test_step(phydev, in marvell_vct5_cable_test_tdr_start()
2032 static int marvell_vct7_report_length(struct phy_device *phydev, in marvell_vct7_report_length() argument
2038 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_report_length()
2045 ethnl_cable_test_fault_length(phydev, pair, length); in marvell_vct7_report_length()
2066 static int marvell_vct7_cable_test_report(struct phy_device *phydev) in marvell_vct7_cable_test_report() argument
2072 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_report()
2086 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, in marvell_vct7_cable_test_report()
2088 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_B, in marvell_vct7_cable_test_report()
2090 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_C, in marvell_vct7_cable_test_report()
2092 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_D, in marvell_vct7_cable_test_report()
2095 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, MII_VCT7_CTRL); in marvell_vct7_cable_test_report()
2102 marvell_vct7_report_length(phydev, 0, meter); in marvell_vct7_cable_test_report()
2104 marvell_vct7_report_length(phydev, 1, meter); in marvell_vct7_cable_test_report()
2106 marvell_vct7_report_length(phydev, 2, meter); in marvell_vct7_cable_test_report()
2108 marvell_vct7_report_length(phydev, 3, meter); in marvell_vct7_cable_test_report()
2113 static int marvell_vct7_cable_test_get_status(struct phy_device *phydev, in marvell_vct7_cable_test_get_status() argument
2116 struct marvell_priv *priv = phydev->priv; in marvell_vct7_cable_test_get_status()
2120 ret = marvell_vct5_amplitude_graph(phydev); in marvell_vct7_cable_test_get_status()
2127 ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, in marvell_vct7_cable_test_get_status()
2136 return marvell_vct7_cable_test_report(phydev); in marvell_vct7_cable_test_get_status()
2143 static int m88e1121_get_temp(struct phy_device *phydev, long *temp) in m88e1121_get_temp() argument
2151 oldpage = phy_select_page(phydev, MII_MARVELL_MISC_TEST_PAGE); in m88e1121_get_temp()
2156 ret = __phy_read(phydev, MII_88E1121_MISC_TEST); in m88e1121_get_temp()
2160 ret = __phy_write(phydev, MII_88E1121_MISC_TEST, in m88e1121_get_temp()
2168 val = __phy_read(phydev, MII_88E1121_MISC_TEST); in m88e1121_get_temp()
2175 ret = __phy_write(phydev, MII_88E1121_MISC_TEST, in m88e1121_get_temp()
2183 return phy_restore_page(phydev, oldpage, ret); in m88e1121_get_temp()
2190 struct phy_device *phydev = dev_get_drvdata(dev); in m88e1121_hwmon_read() local
2195 err = m88e1121_get_temp(phydev, temp); in m88e1121_hwmon_read()
2255 static int m88e1510_get_temp(struct phy_device *phydev, long *temp) in m88e1510_get_temp() argument
2261 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp()
2271 static int m88e1510_get_temp_critical(struct phy_device *phydev, long *temp) in m88e1510_get_temp_critical() argument
2277 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp_critical()
2290 static int m88e1510_set_temp_critical(struct phy_device *phydev, long temp) in m88e1510_set_temp_critical() argument
2295 return phy_modify_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_set_temp_critical()
2301 static int m88e1510_get_temp_alarm(struct phy_device *phydev, long *alarm) in m88e1510_get_temp_alarm() argument
2307 ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, in m88e1510_get_temp_alarm()
2321 struct phy_device *phydev = dev_get_drvdata(dev); in m88e1510_hwmon_read() local
2326 err = m88e1510_get_temp(phydev, temp); in m88e1510_hwmon_read()
2329 err = m88e1510_get_temp_critical(phydev, temp); in m88e1510_hwmon_read()
2332 err = m88e1510_get_temp_alarm(phydev, temp); in m88e1510_hwmon_read()
2345 struct phy_device *phydev = dev_get_drvdata(dev); in m88e1510_hwmon_write() local
2350 err = m88e1510_set_temp_critical(phydev, temp); in m88e1510_hwmon_write()
2403 static int m88e6390_get_temp(struct phy_device *phydev, long *temp) in m88e6390_get_temp() argument
2412 oldpage = phy_select_page(phydev, MII_MARVELL_MISC_TEST_PAGE); in m88e6390_get_temp()
2417 ret = __phy_read(phydev, MII_88E6390_MISC_TEST); in m88e6390_get_temp()
2425 ret = __phy_write(phydev, MII_88E6390_MISC_TEST, ret); in m88e6390_get_temp()
2436 ret = __phy_read(phydev, MII_88E6390_TEMP_SENSOR); in m88e6390_get_temp()
2446 ret = __phy_read(phydev, MII_88E6390_MISC_TEST); in m88e6390_get_temp()
2453 ret = __phy_write(phydev, MII_88E6390_MISC_TEST, ret); in m88e6390_get_temp()
2456 phy_restore_page(phydev, oldpage, ret); in m88e6390_get_temp()
2465 struct phy_device *phydev = dev_get_drvdata(dev); in m88e6390_hwmon_read() local
2470 err = m88e6390_get_temp(phydev, temp); in m88e6390_hwmon_read()
2520 static int marvell_hwmon_name(struct phy_device *phydev) in marvell_hwmon_name() argument
2522 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_name()
2523 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_name()
2540 static int marvell_hwmon_probe(struct phy_device *phydev, in marvell_hwmon_probe() argument
2543 struct marvell_priv *priv = phydev->priv; in marvell_hwmon_probe()
2544 struct device *dev = &phydev->mdio.dev; in marvell_hwmon_probe()
2547 err = marvell_hwmon_name(phydev); in marvell_hwmon_probe()
2552 dev, priv->hwmon_name, phydev, chip, NULL); in marvell_hwmon_probe()
2557 static int m88e1121_hwmon_probe(struct phy_device *phydev) in m88e1121_hwmon_probe() argument
2559 return marvell_hwmon_probe(phydev, &m88e1121_hwmon_chip_info); in m88e1121_hwmon_probe()
2562 static int m88e1510_hwmon_probe(struct phy_device *phydev) in m88e1510_hwmon_probe() argument
2564 return marvell_hwmon_probe(phydev, &m88e1510_hwmon_chip_info); in m88e1510_hwmon_probe()
2567 static int m88e6390_hwmon_probe(struct phy_device *phydev) in m88e6390_hwmon_probe() argument
2569 return marvell_hwmon_probe(phydev, &m88e6390_hwmon_chip_info); in m88e6390_hwmon_probe()
2572 static int m88e1121_hwmon_probe(struct phy_device *phydev) in m88e1121_hwmon_probe() argument
2577 static int m88e1510_hwmon_probe(struct phy_device *phydev) in m88e1510_hwmon_probe() argument
2582 static int m88e6390_hwmon_probe(struct phy_device *phydev) in m88e6390_hwmon_probe() argument
2588 static int marvell_probe(struct phy_device *phydev) in marvell_probe() argument
2592 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in marvell_probe()
2596 phydev->priv = priv; in marvell_probe()
2601 static int m88e1121_probe(struct phy_device *phydev) in m88e1121_probe() argument
2605 err = marvell_probe(phydev); in m88e1121_probe()
2609 return m88e1121_hwmon_probe(phydev); in m88e1121_probe()
2612 static int m88e1510_probe(struct phy_device *phydev) in m88e1510_probe() argument
2616 err = marvell_probe(phydev); in m88e1510_probe()
2620 return m88e1510_hwmon_probe(phydev); in m88e1510_probe()
2623 static int m88e6390_probe(struct phy_device *phydev) in m88e6390_probe() argument
2627 err = marvell_probe(phydev); in m88e6390_probe()
2631 return m88e6390_hwmon_probe(phydev); in m88e6390_probe()