Lines Matching full:phydev
389 struct phy_device *phydev; member
407 struct phy_device *phydev; member
499 static int kszphy_extended_write(struct phy_device *phydev, in kszphy_extended_write() argument
502 phy_write(phydev, MII_KSZPHY_EXTREG, KSZPHY_EXTREG_WRITE | regnum); in kszphy_extended_write()
503 return phy_write(phydev, MII_KSZPHY_EXTREG_WRITE, val); in kszphy_extended_write()
506 static int kszphy_extended_read(struct phy_device *phydev, in kszphy_extended_read() argument
509 phy_write(phydev, MII_KSZPHY_EXTREG, regnum); in kszphy_extended_read()
510 return phy_read(phydev, MII_KSZPHY_EXTREG_READ); in kszphy_extended_read()
513 static int kszphy_ack_interrupt(struct phy_device *phydev) in kszphy_ack_interrupt() argument
518 rc = phy_read(phydev, MII_KSZPHY_INTCS); in kszphy_ack_interrupt()
523 static int kszphy_config_intr(struct phy_device *phydev) in kszphy_config_intr() argument
525 const struct kszphy_type *type = phydev->drv->driver_data; in kszphy_config_intr()
535 temp = phy_read(phydev, MII_KSZPHY_CTRL); in kszphy_config_intr()
539 phy_write(phydev, MII_KSZPHY_CTRL, temp); in kszphy_config_intr()
542 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in kszphy_config_intr()
543 err = kszphy_ack_interrupt(phydev); in kszphy_config_intr()
547 err = phy_write(phydev, MII_KSZPHY_INTCS, KSZPHY_INTCS_ALL); in kszphy_config_intr()
549 err = phy_write(phydev, MII_KSZPHY_INTCS, 0); in kszphy_config_intr()
553 err = kszphy_ack_interrupt(phydev); in kszphy_config_intr()
559 static irqreturn_t kszphy_handle_interrupt(struct phy_device *phydev) in kszphy_handle_interrupt() argument
563 irq_status = phy_read(phydev, MII_KSZPHY_INTCS); in kszphy_handle_interrupt()
565 phy_error(phydev); in kszphy_handle_interrupt()
572 phy_trigger_machine(phydev); in kszphy_handle_interrupt()
577 static int kszphy_rmii_clk_sel(struct phy_device *phydev, bool val) in kszphy_rmii_clk_sel() argument
581 ctrl = phy_read(phydev, MII_KSZPHY_CTRL); in kszphy_rmii_clk_sel()
590 return phy_write(phydev, MII_KSZPHY_CTRL, ctrl); in kszphy_rmii_clk_sel()
593 static int kszphy_setup_led(struct phy_device *phydev, u32 reg, int val) in kszphy_setup_led() argument
608 temp = phy_read(phydev, reg); in kszphy_setup_led()
616 rc = phy_write(phydev, reg, temp); in kszphy_setup_led()
619 phydev_err(phydev, "failed to set led mode\n"); in kszphy_setup_led()
627 static int kszphy_broadcast_disable(struct phy_device *phydev) in kszphy_broadcast_disable() argument
631 ret = phy_read(phydev, MII_KSZPHY_OMSO); in kszphy_broadcast_disable()
635 ret = phy_write(phydev, MII_KSZPHY_OMSO, ret | KSZPHY_OMSO_B_CAST_OFF); in kszphy_broadcast_disable()
638 phydev_err(phydev, "failed to disable broadcast address\n"); in kszphy_broadcast_disable()
643 static int kszphy_nand_tree_disable(struct phy_device *phydev) in kszphy_nand_tree_disable() argument
647 ret = phy_read(phydev, MII_KSZPHY_OMSO); in kszphy_nand_tree_disable()
654 ret = phy_write(phydev, MII_KSZPHY_OMSO, in kszphy_nand_tree_disable()
658 phydev_err(phydev, "failed to disable NAND tree mode\n"); in kszphy_nand_tree_disable()
664 static int kszphy_config_reset(struct phy_device *phydev) in kszphy_config_reset() argument
666 struct kszphy_priv *priv = phydev->priv; in kszphy_config_reset()
670 ret = kszphy_rmii_clk_sel(phydev, priv->rmii_ref_clk_sel_val); in kszphy_config_reset()
672 phydev_err(phydev, in kszphy_config_reset()
679 kszphy_setup_led(phydev, priv->type->led_mode_reg, priv->led_mode); in kszphy_config_reset()
684 static int kszphy_config_init(struct phy_device *phydev) in kszphy_config_init() argument
686 struct kszphy_priv *priv = phydev->priv; in kszphy_config_init()
695 kszphy_broadcast_disable(phydev); in kszphy_config_init()
698 kszphy_nand_tree_disable(phydev); in kszphy_config_init()
700 return kszphy_config_reset(phydev); in kszphy_config_init()
703 static int ksz8041_fiber_mode(struct phy_device *phydev) in ksz8041_fiber_mode() argument
705 struct device_node *of_node = phydev->mdio.dev.of_node; in ksz8041_fiber_mode()
710 static int ksz8041_config_init(struct phy_device *phydev) in ksz8041_config_init() argument
715 if (ksz8041_fiber_mode(phydev)) { in ksz8041_config_init()
716 phydev->dev_flags |= MICREL_PHY_FXEN; in ksz8041_config_init()
720 linkmode_and(phydev->supported, phydev->supported, mask); in ksz8041_config_init()
722 phydev->supported); in ksz8041_config_init()
723 linkmode_and(phydev->advertising, phydev->advertising, mask); in ksz8041_config_init()
725 phydev->advertising); in ksz8041_config_init()
726 phydev->autoneg = AUTONEG_DISABLE; in ksz8041_config_init()
729 return kszphy_config_init(phydev); in ksz8041_config_init()
732 static int ksz8041_config_aneg(struct phy_device *phydev) in ksz8041_config_aneg() argument
735 if (phydev->dev_flags & MICREL_PHY_FXEN) { in ksz8041_config_aneg()
736 phydev->speed = SPEED_100; in ksz8041_config_aneg()
740 return genphy_config_aneg(phydev); in ksz8041_config_aneg()
743 static int ksz8051_ksz8795_match_phy_device(struct phy_device *phydev, in ksz8051_ksz8795_match_phy_device() argument
748 if (!phy_id_compare(phydev->phy_id, PHY_ID_KSZ8051, MICREL_PHY_ID_MASK)) in ksz8051_ksz8795_match_phy_device()
751 ret = phy_read(phydev, MII_BMSR); in ksz8051_ksz8795_match_phy_device()
767 static int ksz8051_match_phy_device(struct phy_device *phydev) in ksz8051_match_phy_device() argument
769 return ksz8051_ksz8795_match_phy_device(phydev, true); in ksz8051_match_phy_device()
772 static int ksz8081_config_init(struct phy_device *phydev) in ksz8081_config_init() argument
779 phy_clear_bits(phydev, MII_KSZPHY_OMSO, KSZPHY_OMSO_FACTORY_TEST); in ksz8081_config_init()
781 return kszphy_config_init(phydev); in ksz8081_config_init()
784 static int ksz8081_config_mdix(struct phy_device *phydev, u8 ctrl) in ksz8081_config_mdix() argument
803 return phy_modify(phydev, MII_KSZPHY_CTRL_2, in ksz8081_config_mdix()
810 static int ksz8081_config_aneg(struct phy_device *phydev) in ksz8081_config_aneg() argument
814 ret = genphy_config_aneg(phydev); in ksz8081_config_aneg()
822 return ksz8081_config_mdix(phydev, phydev->mdix_ctrl); in ksz8081_config_aneg()
825 static int ksz8081_mdix_update(struct phy_device *phydev) in ksz8081_mdix_update() argument
829 ret = phy_read(phydev, MII_KSZPHY_CTRL_2); in ksz8081_mdix_update()
835 phydev->mdix_ctrl = ETH_TP_MDI_X; in ksz8081_mdix_update()
837 phydev->mdix_ctrl = ETH_TP_MDI; in ksz8081_mdix_update()
839 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in ksz8081_mdix_update()
842 ret = phy_read(phydev, MII_KSZPHY_CTRL_1); in ksz8081_mdix_update()
847 phydev->mdix = ETH_TP_MDI; in ksz8081_mdix_update()
849 phydev->mdix = ETH_TP_MDI_X; in ksz8081_mdix_update()
854 static int ksz8081_read_status(struct phy_device *phydev) in ksz8081_read_status() argument
858 ret = ksz8081_mdix_update(phydev); in ksz8081_read_status()
862 return genphy_read_status(phydev); in ksz8081_read_status()
865 static int ksz8061_config_init(struct phy_device *phydev) in ksz8061_config_init() argument
870 ret = phy_read(phydev, MII_BMCR); in ksz8061_config_init()
874 ret = phy_write(phydev, MII_BMCR, ret & ~BMCR_PDOWN); in ksz8061_config_init()
880 ret = phy_write_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_DEVID1, 0xB61A); in ksz8061_config_init()
884 return kszphy_config_init(phydev); in ksz8061_config_init()
887 static int ksz8795_match_phy_device(struct phy_device *phydev) in ksz8795_match_phy_device() argument
889 return ksz8051_ksz8795_match_phy_device(phydev, false); in ksz8795_match_phy_device()
892 static int ksz9021_load_values_from_of(struct phy_device *phydev, in ksz9021_load_values_from_of() argument
921 newval = kszphy_extended_read(phydev, reg); in ksz9021_load_values_from_of()
937 return kszphy_extended_write(phydev, reg, newval); in ksz9021_load_values_from_of()
940 static int ksz9021_config_init(struct phy_device *phydev) in ksz9021_config_init() argument
949 dev_walker = &phydev->mdio.dev; in ksz9021_config_init()
957 ksz9021_load_values_from_of(phydev, of_node, in ksz9021_config_init()
961 ksz9021_load_values_from_of(phydev, of_node, in ksz9021_config_init()
965 ksz9021_load_values_from_of(phydev, of_node, in ksz9021_config_init()
1031 static int ksz9031_of_load_skew_values(struct phy_device *phydev, in ksz9031_of_load_skew_values() argument
1054 newval = phy_read_mmd(phydev, 2, reg); in ksz9031_of_load_skew_values()
1068 return phy_write_mmd(phydev, 2, reg, newval); in ksz9031_of_load_skew_values()
1072 static int ksz9031_center_flp_timing(struct phy_device *phydev) in ksz9031_center_flp_timing() argument
1076 result = phy_write_mmd(phydev, 0, MII_KSZ9031RN_FLP_BURST_TX_HI, in ksz9031_center_flp_timing()
1081 result = phy_write_mmd(phydev, 0, MII_KSZ9031RN_FLP_BURST_TX_LO, in ksz9031_center_flp_timing()
1086 return genphy_restart_aneg(phydev); in ksz9031_center_flp_timing()
1090 static int ksz9031_enable_edpd(struct phy_device *phydev) in ksz9031_enable_edpd() argument
1094 reg = phy_read_mmd(phydev, 0x1C, MII_KSZ9031RN_EDPD); in ksz9031_enable_edpd()
1097 return phy_write_mmd(phydev, 0x1C, MII_KSZ9031RN_EDPD, in ksz9031_enable_edpd()
1101 static int ksz9031_config_rgmii_delay(struct phy_device *phydev) in ksz9031_config_rgmii_delay() argument
1106 switch (phydev->interface) { in ksz9031_config_rgmii_delay()
1135 ret = phy_write_mmd(phydev, 2, MII_KSZ9031RN_CONTROL_PAD_SKEW, in ksz9031_config_rgmii_delay()
1141 ret = phy_write_mmd(phydev, 2, MII_KSZ9031RN_RX_DATA_PAD_SKEW, in ksz9031_config_rgmii_delay()
1149 ret = phy_write_mmd(phydev, 2, MII_KSZ9031RN_TX_DATA_PAD_SKEW, in ksz9031_config_rgmii_delay()
1157 return phy_write_mmd(phydev, 2, MII_KSZ9031RN_CLK_PAD_SKEW, in ksz9031_config_rgmii_delay()
1162 static int ksz9031_config_init(struct phy_device *phydev) in ksz9031_config_init() argument
1178 result = ksz9031_enable_edpd(phydev); in ksz9031_config_init()
1186 dev_walker = &phydev->mdio.dev; in ksz9031_config_init()
1195 if (phy_interface_is_rgmii(phydev)) { in ksz9031_config_init()
1196 result = ksz9031_config_rgmii_delay(phydev); in ksz9031_config_init()
1201 ksz9031_of_load_skew_values(phydev, of_node, in ksz9031_config_init()
1205 ksz9031_of_load_skew_values(phydev, of_node, in ksz9031_config_init()
1209 ksz9031_of_load_skew_values(phydev, of_node, in ksz9031_config_init()
1213 ksz9031_of_load_skew_values(phydev, of_node, in ksz9031_config_init()
1217 if (update && !phy_interface_is_rgmii(phydev)) in ksz9031_config_init()
1218 phydev_warn(phydev, in ksz9031_config_init()
1237 result = phy_read(phydev, MII_CTRL1000); in ksz9031_config_init()
1243 result = phy_write(phydev, MII_CTRL1000, result); in ksz9031_config_init()
1249 return ksz9031_center_flp_timing(phydev); in ksz9031_config_init()
1252 phydev_err(phydev, "failed to force the phy to master mode\n"); in ksz9031_config_init()
1261 static int ksz9131_of_load_skew_values(struct phy_device *phydev, in ksz9131_of_load_skew_values() argument
1296 newval = phy_read_mmd(phydev, 2, reg); in ksz9131_of_load_skew_values()
1310 return phy_write_mmd(phydev, 2, reg, newval); in ksz9131_of_load_skew_values()
1318 static int ksz9131_config_rgmii_delay(struct phy_device *phydev) in ksz9131_config_rgmii_delay() argument
1320 const struct kszphy_type *type = phydev->drv->driver_data; in ksz9131_config_rgmii_delay()
1324 switch (phydev->interface) { in ksz9131_config_rgmii_delay()
1345 ret = phy_modify_mmd(phydev, KSZ9131RN_MMD_COMMON_CTRL_REG, in ksz9131_config_rgmii_delay()
1351 return phy_modify_mmd(phydev, KSZ9131RN_MMD_COMMON_CTRL_REG, in ksz9131_config_rgmii_delay()
1362 static int ksz9131_led_errata(struct phy_device *phydev) in ksz9131_led_errata() argument
1366 reg = phy_read_mmd(phydev, 2, 0); in ksz9131_led_errata()
1373 return phy_set_bits(phydev, 0x1e, BIT(9)); in ksz9131_led_errata()
1376 static int ksz9131_config_init(struct phy_device *phydev) in ksz9131_config_init() argument
1392 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in ksz9131_config_init()
1394 dev_walker = &phydev->mdio.dev; in ksz9131_config_init()
1403 if (phy_interface_is_rgmii(phydev)) { in ksz9131_config_init()
1404 ret = ksz9131_config_rgmii_delay(phydev); in ksz9131_config_init()
1409 ret = ksz9131_of_load_skew_values(phydev, of_node, in ksz9131_config_init()
1415 ret = ksz9131_of_load_skew_values(phydev, of_node, in ksz9131_config_init()
1421 ret = ksz9131_of_load_skew_values(phydev, of_node, in ksz9131_config_init()
1427 ret = ksz9131_of_load_skew_values(phydev, of_node, in ksz9131_config_init()
1433 ret = ksz9131_led_errata(phydev); in ksz9131_config_init()
1447 static int ksz9131_mdix_update(struct phy_device *phydev) in ksz9131_mdix_update() argument
1451 if (phydev->mdix_ctrl != ETH_TP_MDI_AUTO) { in ksz9131_mdix_update()
1452 phydev->mdix = phydev->mdix_ctrl; in ksz9131_mdix_update()
1454 ret = phy_read(phydev, MII_KSZ9131_DIG_AXAN_STS); in ksz9131_mdix_update()
1460 phydev->mdix = ETH_TP_MDI; in ksz9131_mdix_update()
1462 phydev->mdix = ETH_TP_MDI_X; in ksz9131_mdix_update()
1464 phydev->mdix = ETH_TP_MDI_INVALID; in ksz9131_mdix_update()
1471 static int ksz9131_config_mdix(struct phy_device *phydev, u8 ctrl) in ksz9131_config_mdix() argument
1490 return phy_modify(phydev, MII_KSZ9131_AUTO_MDIX, in ksz9131_config_mdix()
1495 static int ksz9131_read_status(struct phy_device *phydev) in ksz9131_read_status() argument
1499 ret = ksz9131_mdix_update(phydev); in ksz9131_read_status()
1503 return genphy_read_status(phydev); in ksz9131_read_status()
1506 static int ksz9131_config_aneg(struct phy_device *phydev) in ksz9131_config_aneg() argument
1510 ret = ksz9131_config_mdix(phydev, phydev->mdix_ctrl); in ksz9131_config_aneg()
1514 return genphy_config_aneg(phydev); in ksz9131_config_aneg()
1517 static int ksz9477_get_features(struct phy_device *phydev) in ksz9477_get_features() argument
1521 ret = genphy_read_abilities(phydev); in ksz9477_get_features()
1531 linkmode_and(phydev->supported_eee, phydev->supported, in ksz9477_get_features()
1540 static int ksz8873mll_read_status(struct phy_device *phydev) in ksz8873mll_read_status() argument
1545 regval = phy_read(phydev, KSZ8873MLL_GLOBAL_CONTROL_4); in ksz8873mll_read_status()
1547 regval = phy_read(phydev, KSZ8873MLL_GLOBAL_CONTROL_4); in ksz8873mll_read_status()
1550 phydev->duplex = DUPLEX_HALF; in ksz8873mll_read_status()
1552 phydev->duplex = DUPLEX_FULL; in ksz8873mll_read_status()
1555 phydev->speed = SPEED_10; in ksz8873mll_read_status()
1557 phydev->speed = SPEED_100; in ksz8873mll_read_status()
1559 phydev->link = 1; in ksz8873mll_read_status()
1560 phydev->pause = phydev->asym_pause = 0; in ksz8873mll_read_status()
1565 static int ksz9031_get_features(struct phy_device *phydev) in ksz9031_get_features() argument
1569 ret = genphy_read_abilities(phydev); in ksz9031_get_features()
1582 linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydev->supported); in ksz9031_get_features()
1587 linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported); in ksz9031_get_features()
1592 static int ksz9031_read_status(struct phy_device *phydev) in ksz9031_read_status() argument
1597 err = genphy_read_status(phydev); in ksz9031_read_status()
1604 regval = phy_read(phydev, MII_STAT1000); in ksz9031_read_status()
1606 phy_init_hw(phydev); in ksz9031_read_status()
1607 phydev->link = 0; in ksz9031_read_status()
1608 if (phydev->drv->config_intr && phy_interrupt_is_valid(phydev)) in ksz9031_read_status()
1609 phydev->drv->config_intr(phydev); in ksz9031_read_status()
1610 return genphy_config_aneg(phydev); in ksz9031_read_status()
1616 static int ksz9x31_cable_test_start(struct phy_device *phydev) in ksz9x31_cable_test_start() argument
1618 struct kszphy_priv *priv = phydev->priv; in ksz9x31_cable_test_start()
1626 ret = phy_modify(phydev, MII_BMCR, in ksz9x31_cable_test_start()
1638 ret = phy_read(phydev, MII_CTRL1000); in ksz9x31_cable_test_start()
1647 return phy_write(phydev, MII_CTRL1000, ret); in ksz9x31_cable_test_start()
1684 static int ksz9x31_cable_test_fault_length(struct phy_device *phydev, u16 stat) in ksz9x31_cable_test_fault_length() argument
1692 if (phydev_id_compare(phydev, PHY_ID_KSZ9131)) in ksz9x31_cable_test_fault_length()
1698 static int ksz9x31_cable_test_wait_for_completion(struct phy_device *phydev) in ksz9x31_cable_test_wait_for_completion() argument
1702 ret = phy_read_poll_timeout(phydev, KSZ9x31_LMD, val, in ksz9x31_cable_test_wait_for_completion()
1721 static int ksz9x31_cable_test_one_pair(struct phy_device *phydev, int pair) in ksz9x31_cable_test_one_pair() argument
1732 ret = phy_write(phydev, KSZ9x31_LMD, in ksz9x31_cable_test_one_pair()
1737 ret = ksz9x31_cable_test_wait_for_completion(phydev); in ksz9x31_cable_test_one_pair()
1741 val = phy_read(phydev, KSZ9x31_LMD); in ksz9x31_cable_test_one_pair()
1748 ret = ethnl_cable_test_result(phydev, in ksz9x31_cable_test_one_pair()
1757 return ethnl_cable_test_fault_length(phydev, in ksz9x31_cable_test_one_pair()
1759 ksz9x31_cable_test_fault_length(phydev, val)); in ksz9x31_cable_test_one_pair()
1762 static int ksz9x31_cable_test_get_status(struct phy_device *phydev, in ksz9x31_cable_test_get_status() argument
1765 struct kszphy_priv *priv = phydev->priv; in ksz9x31_cable_test_get_status()
1775 ret = ksz9x31_cable_test_one_pair(phydev, pair); in ksz9x31_cable_test_get_status()
1792 ret = ethnl_cable_test_result(phydev, in ksz9x31_cable_test_get_status()
1800 rv = phy_modify(phydev, MII_CTRL1000, in ksz9x31_cable_test_get_status()
1809 static int ksz8873mll_config_aneg(struct phy_device *phydev) in ksz8873mll_config_aneg() argument
1814 static int ksz886x_config_mdix(struct phy_device *phydev, u8 ctrl) in ksz886x_config_mdix() argument
1838 return phy_modify(phydev, MII_BMCR, in ksz886x_config_mdix()
1844 static int ksz886x_config_aneg(struct phy_device *phydev) in ksz886x_config_aneg() argument
1848 ret = genphy_config_aneg(phydev); in ksz886x_config_aneg()
1852 if (phydev->autoneg != AUTONEG_ENABLE) { in ksz886x_config_aneg()
1859 ret = phy_set_bits(phydev, MII_KSZPHY_CTRL, in ksz886x_config_aneg()
1868 ret = phy_clear_bits(phydev, MII_KSZPHY_CTRL, in ksz886x_config_aneg()
1878 return ksz886x_config_mdix(phydev, phydev->mdix_ctrl); in ksz886x_config_aneg()
1881 static int ksz886x_mdix_update(struct phy_device *phydev) in ksz886x_mdix_update() argument
1885 ret = phy_read(phydev, MII_BMCR); in ksz886x_mdix_update()
1891 phydev->mdix_ctrl = ETH_TP_MDI_X; in ksz886x_mdix_update()
1893 phydev->mdix_ctrl = ETH_TP_MDI; in ksz886x_mdix_update()
1895 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in ksz886x_mdix_update()
1898 ret = phy_read(phydev, MII_KSZPHY_CTRL); in ksz886x_mdix_update()
1904 phydev->mdix = ETH_TP_MDI_X; in ksz886x_mdix_update()
1906 phydev->mdix = ETH_TP_MDI; in ksz886x_mdix_update()
1911 static int ksz886x_read_status(struct phy_device *phydev) in ksz886x_read_status() argument
1915 ret = ksz886x_mdix_update(phydev); in ksz886x_read_status()
1919 return genphy_read_status(phydev); in ksz886x_read_status()
1957 static int ksz9477_phy_errata(struct phy_device *phydev) in ksz9477_phy_errata() argument
1973 err = phy_write(phydev, MII_BMCR, BMCR_SPEED100 | BMCR_FULLDPLX); in ksz9477_phy_errata()
1980 err = phy_write_mmd(phydev, errata->dev_addr, errata->reg_addr, errata->val); in ksz9477_phy_errata()
1985 err = genphy_restart_aneg(phydev); in ksz9477_phy_errata()
1992 static int ksz9477_config_init(struct phy_device *phydev) in ksz9477_config_init() argument
1997 if ((phydev->phy_id & 0xf) == 1) { in ksz9477_config_init()
1998 err = ksz9477_phy_errata(phydev); in ksz9477_config_init()
2006 if (phydev->dev_flags & MICREL_NO_EEE) in ksz9477_config_init()
2007 phydev->eee_broken_modes = -1; in ksz9477_config_init()
2009 return kszphy_config_init(phydev); in ksz9477_config_init()
2012 static int kszphy_get_sset_count(struct phy_device *phydev) in kszphy_get_sset_count() argument
2017 static void kszphy_get_strings(struct phy_device *phydev, u8 *data) in kszphy_get_strings() argument
2027 static u64 kszphy_get_stat(struct phy_device *phydev, int i) in kszphy_get_stat() argument
2030 struct kszphy_priv *priv = phydev->priv; in kszphy_get_stat()
2034 val = phy_read(phydev, stat.reg); in kszphy_get_stat()
2046 static void kszphy_get_stats(struct phy_device *phydev, in kszphy_get_stats() argument
2052 data[i] = kszphy_get_stat(phydev, i); in kszphy_get_stats()
2055 static int kszphy_suspend(struct phy_device *phydev) in kszphy_suspend() argument
2058 if (phy_interrupt_is_valid(phydev)) { in kszphy_suspend()
2059 phydev->interrupts = PHY_INTERRUPT_DISABLED; in kszphy_suspend()
2060 if (phydev->drv->config_intr) in kszphy_suspend()
2061 phydev->drv->config_intr(phydev); in kszphy_suspend()
2064 return genphy_suspend(phydev); in kszphy_suspend()
2067 static void kszphy_parse_led_mode(struct phy_device *phydev) in kszphy_parse_led_mode() argument
2069 const struct kszphy_type *type = phydev->drv->driver_data; in kszphy_parse_led_mode()
2070 const struct device_node *np = phydev->mdio.dev.of_node; in kszphy_parse_led_mode()
2071 struct kszphy_priv *priv = phydev->priv; in kszphy_parse_led_mode()
2082 phydev_err(phydev, "invalid led mode: 0x%02x\n", in kszphy_parse_led_mode()
2091 static int kszphy_resume(struct phy_device *phydev) in kszphy_resume() argument
2095 genphy_resume(phydev); in kszphy_resume()
2103 ret = kszphy_config_reset(phydev); in kszphy_resume()
2108 if (phy_interrupt_is_valid(phydev)) { in kszphy_resume()
2109 phydev->interrupts = PHY_INTERRUPT_ENABLED; in kszphy_resume()
2110 if (phydev->drv->config_intr) in kszphy_resume()
2111 phydev->drv->config_intr(phydev); in kszphy_resume()
2117 static int ksz9477_resume(struct phy_device *phydev) in ksz9477_resume() argument
2122 ret = phy_read(phydev, MII_BMCR); in ksz9477_resume()
2128 genphy_resume(phydev); in ksz9477_resume()
2137 if ((phydev->phy_id & 0xf) == 1) { in ksz9477_resume()
2138 ret = ksz9477_phy_errata(phydev); in ksz9477_resume()
2144 if (phy_interrupt_is_valid(phydev)) { in ksz9477_resume()
2145 phydev->interrupts = PHY_INTERRUPT_ENABLED; in ksz9477_resume()
2146 if (phydev->drv->config_intr) in ksz9477_resume()
2147 phydev->drv->config_intr(phydev); in ksz9477_resume()
2153 static int ksz8061_resume(struct phy_device *phydev) in ksz8061_resume() argument
2158 ret = phy_read(phydev, MII_BMCR); in ksz8061_resume()
2164 genphy_resume(phydev); in ksz8061_resume()
2168 ret = phy_write_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_DEVID1, 0xB61A); in ksz8061_resume()
2173 if (phy_interrupt_is_valid(phydev)) { in ksz8061_resume()
2174 phydev->interrupts = PHY_INTERRUPT_ENABLED; in ksz8061_resume()
2175 if (phydev->drv->config_intr) in ksz8061_resume()
2176 phydev->drv->config_intr(phydev); in ksz8061_resume()
2182 static int kszphy_probe(struct phy_device *phydev) in kszphy_probe() argument
2184 const struct kszphy_type *type = phydev->drv->driver_data; in kszphy_probe()
2185 const struct device_node *np = phydev->mdio.dev.of_node; in kszphy_probe()
2189 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in kszphy_probe()
2193 phydev->priv = priv; in kszphy_probe()
2197 kszphy_parse_led_mode(phydev); in kszphy_probe()
2199 clk = devm_clk_get_optional_enabled(&phydev->mdio.dev, "rmii-ref"); in kszphy_probe()
2215 phydev_err(phydev, "Clock rate out of range: %ld\n", in kszphy_probe()
2221 clk = devm_clk_get_optional_enabled(&phydev->mdio.dev, NULL); in kszphy_probe()
2226 if (ksz8041_fiber_mode(phydev)) in kszphy_probe()
2227 phydev->port = PORT_FIBRE; in kszphy_probe()
2230 if (phydev->dev_flags & MICREL_PHY_50MHZ_CLK) { in kszphy_probe()
2238 static int lan8814_cable_test_start(struct phy_device *phydev) in lan8814_cable_test_start() argument
2245 return phy_modify(phydev, MII_BMCR, BMCR_ANENABLE | BMCR_SPEED100, in lan8814_cable_test_start()
2249 static int ksz886x_cable_test_start(struct phy_device *phydev) in ksz886x_cable_test_start() argument
2251 if (phydev->dev_flags & MICREL_KSZ8_P1_ERRATA) in ksz886x_cable_test_start()
2259 return phy_clear_bits(phydev, MII_BMCR, BMCR_ANENABLE | BMCR_SPEED100); in ksz886x_cable_test_start()
2295 static __always_inline int ksz886x_cable_test_fault_length(struct phy_device *phydev, in ksz886x_cable_test_fault_length() argument
2306 if (phydev_id_compare(phydev, PHY_ID_LAN8814)) in ksz886x_cable_test_fault_length()
2312 static int ksz886x_cable_test_wait_for_completion(struct phy_device *phydev) in ksz886x_cable_test_wait_for_completion() argument
2314 const struct kszphy_type *type = phydev->drv->driver_data; in ksz886x_cable_test_wait_for_completion()
2317 ret = phy_read_poll_timeout(phydev, type->cable_diag_reg, val, in ksz886x_cable_test_wait_for_completion()
2324 static int lan8814_cable_test_one_pair(struct phy_device *phydev, int pair) in lan8814_cable_test_one_pair() argument
2338 ret = phy_write(phydev, LAN8814_CABLE_DIAG, val); in lan8814_cable_test_one_pair()
2342 ret = ksz886x_cable_test_wait_for_completion(phydev); in lan8814_cable_test_one_pair()
2346 val = phy_read(phydev, LAN8814_CABLE_DIAG); in lan8814_cable_test_one_pair()
2353 ret = ethnl_cable_test_result(phydev, ethtool_pair[pair], in lan8814_cable_test_one_pair()
2363 fault_length = ksz886x_cable_test_fault_length(phydev, val, in lan8814_cable_test_one_pair()
2366 return ethnl_cable_test_fault_length(phydev, ethtool_pair[pair], fault_length); in lan8814_cable_test_one_pair()
2369 static int ksz886x_cable_test_one_pair(struct phy_device *phydev, int pair) in ksz886x_cable_test_one_pair() argument
2386 switch (phydev->phy_id & MICREL_PHY_ID_MASK) { in ksz886x_cable_test_one_pair()
2388 ret = ksz8081_config_mdix(phydev, mdix); in ksz886x_cable_test_one_pair()
2391 ret = ksz886x_config_mdix(phydev, mdix); in ksz886x_cable_test_one_pair()
2403 ret = phy_write(phydev, KSZ8081_LMD, KSZ8081_LMD_ENABLE_TEST); in ksz886x_cable_test_one_pair()
2407 ret = ksz886x_cable_test_wait_for_completion(phydev); in ksz886x_cable_test_one_pair()
2411 val = phy_read(phydev, KSZ8081_LMD); in ksz886x_cable_test_one_pair()
2418 ret = ethnl_cable_test_result(phydev, ethtool_pair[pair], in ksz886x_cable_test_one_pair()
2426 fault_length = ksz886x_cable_test_fault_length(phydev, val, KSZ8081_LMD_DELTA_TIME_MASK); in ksz886x_cable_test_one_pair()
2428 return ethnl_cable_test_fault_length(phydev, ethtool_pair[pair], fault_length); in ksz886x_cable_test_one_pair()
2431 static int ksz886x_cable_test_get_status(struct phy_device *phydev, in ksz886x_cable_test_get_status() argument
2434 const struct kszphy_type *type = phydev->drv->driver_data; in ksz886x_cable_test_get_status()
2446 ret = lan8814_cable_test_one_pair(phydev, pair); in ksz886x_cable_test_get_status()
2448 ret = ksz886x_cable_test_one_pair(phydev, pair); in ksz886x_cable_test_get_status()
2486 static int lanphy_read_page_reg(struct phy_device *phydev, int page, u32 addr) in lanphy_read_page_reg() argument
2490 phy_lock_mdio_bus(phydev); in lanphy_read_page_reg()
2491 __phy_write(phydev, LAN_EXT_PAGE_ACCESS_CONTROL, page); in lanphy_read_page_reg()
2492 __phy_write(phydev, LAN_EXT_PAGE_ACCESS_ADDRESS_DATA, addr); in lanphy_read_page_reg()
2493 __phy_write(phydev, LAN_EXT_PAGE_ACCESS_CONTROL, in lanphy_read_page_reg()
2495 data = __phy_read(phydev, LAN_EXT_PAGE_ACCESS_ADDRESS_DATA); in lanphy_read_page_reg()
2496 phy_unlock_mdio_bus(phydev); in lanphy_read_page_reg()
2501 static int lanphy_write_page_reg(struct phy_device *phydev, int page, u16 addr, in lanphy_write_page_reg() argument
2504 phy_lock_mdio_bus(phydev); in lanphy_write_page_reg()
2505 __phy_write(phydev, LAN_EXT_PAGE_ACCESS_CONTROL, page); in lanphy_write_page_reg()
2506 __phy_write(phydev, LAN_EXT_PAGE_ACCESS_ADDRESS_DATA, addr); in lanphy_write_page_reg()
2507 __phy_write(phydev, LAN_EXT_PAGE_ACCESS_CONTROL, in lanphy_write_page_reg()
2510 val = __phy_write(phydev, LAN_EXT_PAGE_ACCESS_ADDRESS_DATA, val); in lanphy_write_page_reg()
2512 phydev_err(phydev, "Error: phy_write has returned error %d\n", in lanphy_write_page_reg()
2514 phy_unlock_mdio_bus(phydev); in lanphy_write_page_reg()
2518 static int lan8814_config_ts_intr(struct phy_device *phydev, bool enable) in lan8814_config_ts_intr() argument
2528 return lanphy_write_page_reg(phydev, 5, PTP_TSU_INT_EN, val); in lan8814_config_ts_intr()
2531 static void lan8814_ptp_rx_ts_get(struct phy_device *phydev, in lan8814_ptp_rx_ts_get() argument
2534 *seconds = lanphy_read_page_reg(phydev, 5, PTP_RX_INGRESS_SEC_HI); in lan8814_ptp_rx_ts_get()
2536 lanphy_read_page_reg(phydev, 5, PTP_RX_INGRESS_SEC_LO); in lan8814_ptp_rx_ts_get()
2538 *nano_seconds = lanphy_read_page_reg(phydev, 5, PTP_RX_INGRESS_NS_HI); in lan8814_ptp_rx_ts_get()
2540 lanphy_read_page_reg(phydev, 5, PTP_RX_INGRESS_NS_LO); in lan8814_ptp_rx_ts_get()
2542 *seq_id = lanphy_read_page_reg(phydev, 5, PTP_RX_MSG_HEADER2); in lan8814_ptp_rx_ts_get()
2545 static void lan8814_ptp_tx_ts_get(struct phy_device *phydev, in lan8814_ptp_tx_ts_get() argument
2548 *seconds = lanphy_read_page_reg(phydev, 5, PTP_TX_EGRESS_SEC_HI); in lan8814_ptp_tx_ts_get()
2550 lanphy_read_page_reg(phydev, 5, PTP_TX_EGRESS_SEC_LO); in lan8814_ptp_tx_ts_get()
2552 *nano_seconds = lanphy_read_page_reg(phydev, 5, PTP_TX_EGRESS_NS_HI); in lan8814_ptp_tx_ts_get()
2554 lanphy_read_page_reg(phydev, 5, PTP_TX_EGRESS_NS_LO); in lan8814_ptp_tx_ts_get()
2556 *seq_id = lanphy_read_page_reg(phydev, 5, PTP_TX_MSG_HEADER2); in lan8814_ptp_tx_ts_get()
2562 struct phy_device *phydev = ptp_priv->phydev; in lan8814_ts_info() local
2563 struct lan8814_shared_priv *shared = phydev->shared->priv; in lan8814_ts_info()
2586 static void lan8814_flush_fifo(struct phy_device *phydev, bool egress) in lan8814_flush_fifo() argument
2591 lanphy_read_page_reg(phydev, 5, in lan8814_flush_fifo()
2595 lanphy_read_page_reg(phydev, 5, PTP_TSU_INT_STS); in lan8814_flush_fifo()
2646 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_RX_PARSE_CONFIG, rxcfg); in lan8814_hwtstamp()
2647 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_PARSE_CONFIG, txcfg); in lan8814_hwtstamp()
2651 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_RX_TIMESTAMP_EN, pkt_ts_enable); in lan8814_hwtstamp()
2652 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_TIMESTAMP_EN, pkt_ts_enable); in lan8814_hwtstamp()
2654 tx_mod = lanphy_read_page_reg(ptp_priv->phydev, 5, PTP_TX_MOD); in lan8814_hwtstamp()
2656 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_MOD, in lan8814_hwtstamp()
2659 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_MOD, in lan8814_hwtstamp()
2664 lan8814_config_ts_intr(ptp_priv->phydev, true); in lan8814_hwtstamp()
2666 lan8814_config_ts_intr(ptp_priv->phydev, false); in lan8814_hwtstamp()
2676 lan8814_flush_fifo(ptp_priv->phydev, false); in lan8814_hwtstamp()
2677 lan8814_flush_fifo(ptp_priv->phydev, true); in lan8814_hwtstamp()
2779 static void lan8814_ptp_clock_set(struct phy_device *phydev, in lan8814_ptp_clock_set() argument
2782 lanphy_write_page_reg(phydev, 4, PTP_CLOCK_SET_SEC_LO, lower_16_bits(sec)); in lan8814_ptp_clock_set()
2783 lanphy_write_page_reg(phydev, 4, PTP_CLOCK_SET_SEC_MID, upper_16_bits(sec)); in lan8814_ptp_clock_set()
2784 lanphy_write_page_reg(phydev, 4, PTP_CLOCK_SET_SEC_HI, upper_32_bits(sec)); in lan8814_ptp_clock_set()
2785 lanphy_write_page_reg(phydev, 4, PTP_CLOCK_SET_NS_LO, lower_16_bits(nsec)); in lan8814_ptp_clock_set()
2786 lanphy_write_page_reg(phydev, 4, PTP_CLOCK_SET_NS_HI, upper_16_bits(nsec)); in lan8814_ptp_clock_set()
2788 lanphy_write_page_reg(phydev, 4, PTP_CMD_CTL, PTP_CMD_CTL_PTP_CLOCK_LOAD_); in lan8814_ptp_clock_set()
2791 static void lan8814_ptp_clock_get(struct phy_device *phydev, in lan8814_ptp_clock_get() argument
2794 lanphy_write_page_reg(phydev, 4, PTP_CMD_CTL, PTP_CMD_CTL_PTP_CLOCK_READ_); in lan8814_ptp_clock_get()
2796 *sec = lanphy_read_page_reg(phydev, 4, PTP_CLOCK_READ_SEC_HI); in lan8814_ptp_clock_get()
2798 *sec |= lanphy_read_page_reg(phydev, 4, PTP_CLOCK_READ_SEC_MID); in lan8814_ptp_clock_get()
2800 *sec |= lanphy_read_page_reg(phydev, 4, PTP_CLOCK_READ_SEC_LO); in lan8814_ptp_clock_get()
2802 *nsec = lanphy_read_page_reg(phydev, 4, PTP_CLOCK_READ_NS_HI); in lan8814_ptp_clock_get()
2804 *nsec |= lanphy_read_page_reg(phydev, 4, PTP_CLOCK_READ_NS_LO); in lan8814_ptp_clock_get()
2812 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_gettime64() local
2817 lan8814_ptp_clock_get(phydev, &seconds, &nano_seconds); in lan8814_ptpci_gettime64()
2830 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_settime64() local
2833 lan8814_ptp_clock_set(phydev, ts->tv_sec, ts->tv_nsec); in lan8814_ptpci_settime64()
2839 static void lan8814_ptp_set_target(struct phy_device *phydev, int event, in lan8814_ptp_set_target() argument
2843 lanphy_write_page_reg(phydev, 4, LAN8814_PTP_CLOCK_TARGET_SEC_LO(event), in lan8814_ptp_set_target()
2845 lanphy_write_page_reg(phydev, 4, LAN8814_PTP_CLOCK_TARGET_SEC_HI(event), in lan8814_ptp_set_target()
2848 lanphy_write_page_reg(phydev, 4, LAN8814_PTP_CLOCK_TARGET_NS_LO(event), in lan8814_ptp_set_target()
2850 lanphy_write_page_reg(phydev, 4, LAN8814_PTP_CLOCK_TARGET_NS_HI(event), in lan8814_ptp_set_target()
2854 static void lan8814_ptp_update_target(struct phy_device *phydev, time64_t sec) in lan8814_ptp_update_target() argument
2856 lan8814_ptp_set_target(phydev, LAN8814_EVENT_A, in lan8814_ptp_update_target()
2858 lan8814_ptp_set_target(phydev, LAN8814_EVENT_B, in lan8814_ptp_update_target()
2862 static void lan8814_ptp_clock_step(struct phy_device *phydev, in lan8814_ptp_clock_step() argument
2874 lan8814_ptp_clock_get(phydev, &set_seconds, &nano_seconds); in lan8814_ptp_clock_step()
2882 lan8814_ptp_clock_set(phydev, set_seconds, nano_seconds); in lan8814_ptp_clock_step()
2883 lan8814_ptp_update_target(phydev, set_seconds); in lan8814_ptp_clock_step()
2889 lan8814_ptp_clock_get(phydev, &set_seconds, &nano_seconds); in lan8814_ptp_clock_step()
2898 lan8814_ptp_clock_set(phydev, set_seconds, nano_seconds); in lan8814_ptp_clock_step()
2899 lan8814_ptp_update_target(phydev, set_seconds); in lan8814_ptp_clock_step()
2948 lanphy_write_page_reg(phydev, 4, PTP_LTC_STEP_ADJ_LO, in lan8814_ptp_clock_step()
2950 lanphy_write_page_reg(phydev, 4, PTP_LTC_STEP_ADJ_HI, in lan8814_ptp_clock_step()
2955 lan8814_ptp_clock_get(phydev, &set_seconds, &nsec); in lan8814_ptp_clock_step()
2957 lan8814_ptp_update_target(phydev, set_seconds); in lan8814_ptp_clock_step()
2968 lanphy_write_page_reg(phydev, 4, PTP_LTC_STEP_ADJ_LO, in lan8814_ptp_clock_step()
2970 lanphy_write_page_reg(phydev, 4, PTP_LTC_STEP_ADJ_HI, in lan8814_ptp_clock_step()
2974 lan8814_ptp_clock_get(phydev, &set_seconds, &nsec); in lan8814_ptp_clock_step()
2976 lan8814_ptp_update_target(phydev, set_seconds); in lan8814_ptp_clock_step()
2978 lanphy_write_page_reg(phydev, 4, PTP_CMD_CTL, in lan8814_ptp_clock_step()
2988 lanphy_write_page_reg(phydev, 4, PTP_LTC_STEP_ADJ_LO, in lan8814_ptp_clock_step()
2990 lanphy_write_page_reg(phydev, 4, PTP_LTC_STEP_ADJ_HI, in lan8814_ptp_clock_step()
2993 lanphy_write_page_reg(phydev, 4, PTP_CMD_CTL, in lan8814_ptp_clock_step()
3002 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_adjtime() local
3005 lan8814_ptp_clock_step(phydev, delta); in lan8814_ptpci_adjtime()
3015 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_adjfine() local
3035 lanphy_write_page_reg(phydev, 4, PTP_CLOCK_RATE_ADJ_HI, kszphy_rate_adj_hi); in lan8814_ptpci_adjfine()
3036 lanphy_write_page_reg(phydev, 4, PTP_CLOCK_RATE_ADJ_LO, kszphy_rate_adj_lo); in lan8814_ptpci_adjfine()
3042 static void lan8814_ptp_set_reload(struct phy_device *phydev, int event, in lan8814_ptp_set_reload() argument
3045 lanphy_write_page_reg(phydev, 4, in lan8814_ptp_set_reload()
3048 lanphy_write_page_reg(phydev, 4, in lan8814_ptp_set_reload()
3052 lanphy_write_page_reg(phydev, 4, in lan8814_ptp_set_reload()
3055 lanphy_write_page_reg(phydev, 4, in lan8814_ptp_set_reload()
3060 static void lan8814_ptp_enable_event(struct phy_device *phydev, int event, in lan8814_ptp_enable_event() argument
3065 val = lanphy_read_page_reg(phydev, 4, LAN8814_PTP_GENERAL_CONFIG); in lan8814_ptp_enable_event()
3075 lanphy_write_page_reg(phydev, 4, LAN8814_PTP_GENERAL_CONFIG, val); in lan8814_ptp_enable_event()
3078 static void lan8814_ptp_disable_event(struct phy_device *phydev, int event) in lan8814_ptp_disable_event() argument
3083 lan8814_ptp_set_target(phydev, event, 0xFFFFFFFF, 0); in lan8814_ptp_disable_event()
3086 val = lanphy_read_page_reg(phydev, 4, LAN8814_PTP_GENERAL_CONFIG); in lan8814_ptp_disable_event()
3088 lanphy_write_page_reg(phydev, 4, LAN8814_PTP_GENERAL_CONFIG, val); in lan8814_ptp_disable_event()
3091 static void lan8814_ptp_perout_off(struct phy_device *phydev, int pin) in lan8814_ptp_perout_off() argument
3099 val = lanphy_read_page_reg(phydev, 4, LAN8814_GPIO_EN_ADDR(pin)); in lan8814_ptp_perout_off()
3101 lanphy_write_page_reg(phydev, 4, LAN8814_GPIO_EN_ADDR(pin), val); in lan8814_ptp_perout_off()
3103 val = lanphy_read_page_reg(phydev, 4, LAN8814_GPIO_DIR_ADDR(pin)); in lan8814_ptp_perout_off()
3105 lanphy_write_page_reg(phydev, 4, LAN8814_GPIO_DIR_ADDR(pin), val); in lan8814_ptp_perout_off()
3107 val = lanphy_read_page_reg(phydev, 4, LAN8814_GPIO_BUF_ADDR(pin)); in lan8814_ptp_perout_off()
3109 lanphy_write_page_reg(phydev, 4, LAN8814_GPIO_BUF_ADDR(pin), val); in lan8814_ptp_perout_off()
3112 static void lan8814_ptp_perout_on(struct phy_device *phydev, int pin) in lan8814_ptp_perout_on() argument
3117 val = lanphy_read_page_reg(phydev, 4, LAN8814_GPIO_DIR_ADDR(pin)); in lan8814_ptp_perout_on()
3119 lanphy_write_page_reg(phydev, 4, LAN8814_GPIO_DIR_ADDR(pin), val); in lan8814_ptp_perout_on()
3122 val = lanphy_read_page_reg(phydev, 4, LAN8814_GPIO_EN_ADDR(pin)); in lan8814_ptp_perout_on()
3124 lanphy_write_page_reg(phydev, 4, LAN8814_GPIO_EN_ADDR(pin), val); in lan8814_ptp_perout_on()
3127 val = lanphy_read_page_reg(phydev, 4, LAN8814_GPIO_BUF_ADDR(pin)); in lan8814_ptp_perout_on()
3129 lanphy_write_page_reg(phydev, 4, LAN8814_GPIO_BUF_ADDR(pin), val); in lan8814_ptp_perout_on()
3137 struct phy_device *phydev = shared->phydev; in lan8814_ptp_perout() local
3156 lan8814_ptp_perout_off(phydev, pin); in lan8814_ptp_perout()
3157 lan8814_ptp_disable_event(phydev, event); in lan8814_ptp_perout()
3172 phydev_name(phydev)); in lan8814_ptp_perout()
3179 phydev_name(phydev)); in lan8814_ptp_perout()
3229 phydev_name(phydev)); in lan8814_ptp_perout()
3235 lan8814_ptp_enable_event(phydev, event, pulse_width); in lan8814_ptp_perout()
3236 lan8814_ptp_set_target(phydev, event, rq->perout.start.sec, in lan8814_ptp_perout()
3238 lan8814_ptp_set_reload(phydev, event, rq->perout.period.sec, in lan8814_ptp_perout()
3240 lan8814_ptp_perout_on(phydev, pin); in lan8814_ptp_perout()
3246 static void lan8814_ptp_extts_on(struct phy_device *phydev, int pin, u32 flags) in lan8814_ptp_extts_on() argument
3251 tmp = lanphy_read_page_reg(phydev, 4, LAN8814_GPIO_DIR_ADDR(pin)); in lan8814_ptp_extts_on()
3253 lanphy_write_page_reg(phydev, 4, LAN8814_GPIO_DIR_ADDR(pin), tmp); in lan8814_ptp_extts_on()
3256 tmp = lanphy_read_page_reg(phydev, 4, PTP_GPIO_CAP_MAP_LO); in lan8814_ptp_extts_on()
3258 lanphy_write_page_reg(phydev, 4, PTP_GPIO_CAP_MAP_LO, tmp); in lan8814_ptp_extts_on()
3261 tmp = lanphy_read_page_reg(phydev, 4, PTP_GPIO_CAP_EN); in lan8814_ptp_extts_on()
3266 lanphy_write_page_reg(phydev, 4, PTP_GPIO_CAP_EN, tmp); in lan8814_ptp_extts_on()
3269 tmp = lanphy_read_page_reg(phydev, 4, PTP_COMMON_INT_ENA); in lan8814_ptp_extts_on()
3271 lanphy_write_page_reg(phydev, 4, PTP_COMMON_INT_ENA, tmp); in lan8814_ptp_extts_on()
3274 static void lan8814_ptp_extts_off(struct phy_device *phydev, int pin) in lan8814_ptp_extts_off() argument
3279 tmp = lanphy_read_page_reg(phydev, 4, LAN8814_GPIO_DIR_ADDR(pin)); in lan8814_ptp_extts_off()
3281 lanphy_write_page_reg(phydev, 4, LAN8814_GPIO_DIR_ADDR(pin), tmp); in lan8814_ptp_extts_off()
3284 tmp = lanphy_read_page_reg(phydev, 4, LAN8814_GPIO_EN_ADDR(pin)); in lan8814_ptp_extts_off()
3286 lanphy_write_page_reg(phydev, 4, LAN8814_GPIO_EN_ADDR(pin), tmp); in lan8814_ptp_extts_off()
3289 tmp = lanphy_read_page_reg(phydev, 4, PTP_GPIO_CAP_MAP_LO); in lan8814_ptp_extts_off()
3291 lanphy_write_page_reg(phydev, 4, PTP_GPIO_CAP_MAP_LO, tmp); in lan8814_ptp_extts_off()
3294 tmp = lanphy_read_page_reg(phydev, 4, PTP_GPIO_CAP_EN); in lan8814_ptp_extts_off()
3297 lanphy_write_page_reg(phydev, 4, PTP_GPIO_CAP_EN, tmp); in lan8814_ptp_extts_off()
3300 tmp = lanphy_read_page_reg(phydev, 4, PTP_COMMON_INT_ENA); in lan8814_ptp_extts_off()
3302 lanphy_write_page_reg(phydev, 4, PTP_COMMON_INT_ENA, tmp); in lan8814_ptp_extts_off()
3310 struct phy_device *phydev = shared->phydev; in lan8814_ptp_extts() local
3325 lan8814_ptp_extts_on(phydev, pin, rq->extts.flags); in lan8814_ptp_extts()
3327 lan8814_ptp_extts_off(phydev, pin); in lan8814_ptp_extts()
3418 struct phy_device *phydev = ptp_priv->phydev; in lan8814_dequeue_tx_skb() local
3422 lan8814_ptp_tx_ts_get(phydev, &seconds, &nsec, &seq_id); in lan8814_dequeue_tx_skb()
3428 struct phy_device *phydev = ptp_priv->phydev; in lan8814_get_tx_ts() local
3437 reg = lanphy_read_page_reg(phydev, 5, PTP_CAP_INFO); in lan8814_get_tx_ts()
3494 struct phy_device *phydev = ptp_priv->phydev; in lan8814_get_rx_ts() local
3503 lan8814_ptp_rx_ts_get(phydev, &rx_ts->seconds, &rx_ts->nsec, in lan8814_get_rx_ts()
3510 reg = lanphy_read_page_reg(phydev, 5, PTP_CAP_INFO); in lan8814_get_rx_ts()
3514 static void lan8814_handle_ptp_interrupt(struct phy_device *phydev, u16 status) in lan8814_handle_ptp_interrupt() argument
3516 struct kszphy_priv *priv = phydev->priv; in lan8814_handle_ptp_interrupt()
3526 lan8814_flush_fifo(phydev, true); in lan8814_handle_ptp_interrupt()
3531 lan8814_flush_fifo(phydev, false); in lan8814_handle_ptp_interrupt()
3538 struct phy_device *phydev = shared->phydev; in lan8814_gpio_process_cap() local
3547 tmp = lanphy_read_page_reg(phydev, 4, PTP_GPIO_SEL); in lan8814_gpio_process_cap()
3549 lanphy_write_page_reg(phydev, 4, PTP_GPIO_SEL, tmp); in lan8814_gpio_process_cap()
3551 tmp = lanphy_read_page_reg(phydev, 4, PTP_GPIO_CAP_STS); in lan8814_gpio_process_cap()
3557 sec = lanphy_read_page_reg(phydev, 4, PTP_GPIO_RE_LTC_SEC_HI_CAP); in lan8814_gpio_process_cap()
3559 sec |= lanphy_read_page_reg(phydev, 4, PTP_GPIO_RE_LTC_SEC_LO_CAP); in lan8814_gpio_process_cap()
3561 nsec = lanphy_read_page_reg(phydev, 4, PTP_GPIO_RE_LTC_NS_HI_CAP) & 0x3fff; in lan8814_gpio_process_cap()
3563 nsec |= lanphy_read_page_reg(phydev, 4, PTP_GPIO_RE_LTC_NS_LO_CAP); in lan8814_gpio_process_cap()
3565 sec = lanphy_read_page_reg(phydev, 4, PTP_GPIO_FE_LTC_SEC_HI_CAP); in lan8814_gpio_process_cap()
3567 sec |= lanphy_read_page_reg(phydev, 4, PTP_GPIO_FE_LTC_SEC_LO_CAP); in lan8814_gpio_process_cap()
3569 nsec = lanphy_read_page_reg(phydev, 4, PTP_GPIO_FE_LTC_NS_HI_CAP) & 0x3fff; in lan8814_gpio_process_cap()
3571 nsec |= lanphy_read_page_reg(phydev, 4, PTP_GPIO_RE_LTC_NS_LO_CAP); in lan8814_gpio_process_cap()
3582 static int lan8814_handle_gpio_interrupt(struct phy_device *phydev, u16 status) in lan8814_handle_gpio_interrupt() argument
3584 struct lan8814_shared_priv *shared = phydev->shared->priv; in lan8814_handle_gpio_interrupt()
3594 static int lan8804_config_init(struct phy_device *phydev) in lan8804_config_init() argument
3599 val = lanphy_read_page_reg(phydev, 2, LAN8804_ALIGN_SWAP); in lan8804_config_init()
3602 lanphy_write_page_reg(phydev, 2, LAN8804_ALIGN_SWAP, val); in lan8804_config_init()
3607 lanphy_write_page_reg(phydev, 31, LAN8814_CLOCK_MANAGEMENT, 0x27e); in lan8804_config_init()
3608 lanphy_read_page_reg(phydev, 1, LAN8814_LINK_QUALITY); in lan8804_config_init()
3613 static irqreturn_t lan8804_handle_interrupt(struct phy_device *phydev) in lan8804_handle_interrupt() argument
3617 status = phy_read(phydev, LAN8814_INTS); in lan8804_handle_interrupt()
3619 phy_error(phydev); in lan8804_handle_interrupt()
3624 phy_trigger_machine(phydev); in lan8804_handle_interrupt()
3634 static int lan8804_config_intr(struct phy_device *phydev) in lan8804_config_intr() argument
3643 phy_write(phydev, LAN8804_CONTROL, LAN8804_CONTROL_INTR_POLARITY); in lan8804_config_intr()
3649 phy_write(phydev, LAN8804_OUTPUT_CONTROL, in lan8804_config_intr()
3652 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in lan8804_config_intr()
3653 err = phy_read(phydev, LAN8814_INTS); in lan8804_config_intr()
3657 err = phy_write(phydev, LAN8814_INTC, LAN8814_INT_LINK); in lan8804_config_intr()
3661 err = phy_write(phydev, LAN8814_INTC, 0); in lan8804_config_intr()
3665 err = phy_read(phydev, LAN8814_INTS); in lan8804_config_intr()
3673 static irqreturn_t lan8814_handle_interrupt(struct phy_device *phydev) in lan8814_handle_interrupt() argument
3678 irq_status = phy_read(phydev, LAN8814_INTS); in lan8814_handle_interrupt()
3680 phy_error(phydev); in lan8814_handle_interrupt()
3685 phy_trigger_machine(phydev); in lan8814_handle_interrupt()
3690 irq_status = lanphy_read_page_reg(phydev, 5, PTP_TSU_INT_STS); in lan8814_handle_interrupt()
3694 lan8814_handle_ptp_interrupt(phydev, irq_status); in lan8814_handle_interrupt()
3698 if (!lan8814_handle_gpio_interrupt(phydev, irq_status)) in lan8814_handle_interrupt()
3704 static int lan8814_ack_interrupt(struct phy_device *phydev) in lan8814_ack_interrupt() argument
3709 rc = phy_read(phydev, LAN8814_INTS); in lan8814_ack_interrupt()
3714 static int lan8814_config_intr(struct phy_device *phydev) in lan8814_config_intr() argument
3718 lanphy_write_page_reg(phydev, 4, LAN8814_INTR_CTRL_REG, in lan8814_config_intr()
3723 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in lan8814_config_intr()
3724 err = lan8814_ack_interrupt(phydev); in lan8814_config_intr()
3728 err = phy_write(phydev, LAN8814_INTC, LAN8814_INT_LINK); in lan8814_config_intr()
3730 err = phy_write(phydev, LAN8814_INTC, 0); in lan8814_config_intr()
3734 err = lan8814_ack_interrupt(phydev); in lan8814_config_intr()
3740 static void lan8814_ptp_init(struct phy_device *phydev) in lan8814_ptp_init() argument
3742 struct kszphy_priv *priv = phydev->priv; in lan8814_ptp_init()
3750 lanphy_write_page_reg(phydev, 5, TSU_HARD_RESET, TSU_HARD_RESET_); in lan8814_ptp_init()
3752 temp = lanphy_read_page_reg(phydev, 5, PTP_TX_MOD); in lan8814_ptp_init()
3754 lanphy_write_page_reg(phydev, 5, PTP_TX_MOD, temp); in lan8814_ptp_init()
3756 temp = lanphy_read_page_reg(phydev, 5, PTP_RX_MOD); in lan8814_ptp_init()
3758 lanphy_write_page_reg(phydev, 5, PTP_RX_MOD, temp); in lan8814_ptp_init()
3760 lanphy_write_page_reg(phydev, 5, PTP_RX_PARSE_CONFIG, 0); in lan8814_ptp_init()
3761 lanphy_write_page_reg(phydev, 5, PTP_TX_PARSE_CONFIG, 0); in lan8814_ptp_init()
3764 lanphy_write_page_reg(phydev, 5, PTP_TX_PARSE_L2_ADDR_EN, 0); in lan8814_ptp_init()
3765 lanphy_write_page_reg(phydev, 5, PTP_RX_PARSE_L2_ADDR_EN, 0); in lan8814_ptp_init()
3766 lanphy_write_page_reg(phydev, 5, PTP_TX_PARSE_IP_ADDR_EN, 0); in lan8814_ptp_init()
3767 lanphy_write_page_reg(phydev, 5, PTP_RX_PARSE_IP_ADDR_EN, 0); in lan8814_ptp_init()
3770 lanphy_write_page_reg(phydev, 5, PTP_RX_VERSION, in lan8814_ptp_init()
3772 lanphy_write_page_reg(phydev, 5, PTP_TX_VERSION, in lan8814_ptp_init()
3780 ptp_priv->phydev = phydev; in lan8814_ptp_init()
3787 phydev->mii_ts = &ptp_priv->mii_ts; in lan8814_ptp_init()
3790 phydev->default_timestamp = true; in lan8814_ptp_init()
3793 static int lan8814_ptp_probe_once(struct phy_device *phydev) in lan8814_ptp_probe_once() argument
3795 struct lan8814_shared_priv *shared = phydev->shared->priv; in lan8814_ptp_probe_once()
3800 shared->pin_config = devm_kmalloc_array(&phydev->mdio.dev, in lan8814_ptp_probe_once()
3818 snprintf(shared->ptp_clock_info.name, 30, "%s", phydev->drv->name); in lan8814_ptp_probe_once()
3835 &phydev->mdio.dev); in lan8814_ptp_probe_once()
3837 phydev_err(phydev, "ptp_clock_register failed %lu\n", in lan8814_ptp_probe_once()
3846 phydev_dbg(phydev, "successfully registered ptp clock\n"); in lan8814_ptp_probe_once()
3848 shared->phydev = phydev; in lan8814_ptp_probe_once()
3853 lanphy_write_page_reg(phydev, 4, LTC_HARD_RESET, LTC_HARD_RESET_); in lan8814_ptp_probe_once()
3854 lanphy_write_page_reg(phydev, 4, PTP_OPERATING_MODE, in lan8814_ptp_probe_once()
3858 lanphy_write_page_reg(phydev, 4, PTP_CMD_CTL, PTP_CMD_CTL_PTP_ENABLE_); in lan8814_ptp_probe_once()
3863 static void lan8814_setup_led(struct phy_device *phydev, int val) in lan8814_setup_led() argument
3867 temp = lanphy_read_page_reg(phydev, 5, LAN8814_LED_CTRL_1); in lan8814_setup_led()
3874 lanphy_write_page_reg(phydev, 5, LAN8814_LED_CTRL_1, temp); in lan8814_setup_led()
3877 static int lan8814_config_init(struct phy_device *phydev) in lan8814_config_init() argument
3879 struct kszphy_priv *lan8814 = phydev->priv; in lan8814_config_init()
3883 val = lanphy_read_page_reg(phydev, 4, LAN8814_QSGMII_SOFT_RESET); in lan8814_config_init()
3885 lanphy_write_page_reg(phydev, 4, LAN8814_QSGMII_SOFT_RESET, val); in lan8814_config_init()
3888 val = lanphy_read_page_reg(phydev, 5, LAN8814_QSGMII_PCS1G_ANEG_CONFIG); in lan8814_config_init()
3890 lanphy_write_page_reg(phydev, 5, LAN8814_QSGMII_PCS1G_ANEG_CONFIG, val); in lan8814_config_init()
3893 val = lanphy_read_page_reg(phydev, 2, LAN8814_ALIGN_SWAP); in lan8814_config_init()
3896 lanphy_write_page_reg(phydev, 2, LAN8814_ALIGN_SWAP, val); in lan8814_config_init()
3899 lan8814_setup_led(phydev, lan8814->led_mode); in lan8814_config_init()
3909 static int lan8814_release_coma_mode(struct phy_device *phydev) in lan8814_release_coma_mode() argument
3913 gpiod = devm_gpiod_get_optional(&phydev->mdio.dev, "coma-mode", in lan8814_release_coma_mode()
3925 static void lan8814_clear_2psp_bit(struct phy_device *phydev) in lan8814_clear_2psp_bit() argument
3933 val = lanphy_read_page_reg(phydev, 2, LAN8814_EEE_STATE); in lan8814_clear_2psp_bit()
3935 lanphy_write_page_reg(phydev, 2, LAN8814_EEE_STATE, val); in lan8814_clear_2psp_bit()
3938 static void lan8814_update_meas_time(struct phy_device *phydev) in lan8814_update_meas_time() argument
3946 val = lanphy_read_page_reg(phydev, 1, LAN8814_PD_CONTROLS); in lan8814_update_meas_time()
3949 lanphy_write_page_reg(phydev, 1, LAN8814_PD_CONTROLS, val); in lan8814_update_meas_time()
3952 static int lan8814_probe(struct phy_device *phydev) in lan8814_probe() argument
3954 const struct kszphy_type *type = phydev->drv->driver_data; in lan8814_probe()
3959 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in lan8814_probe()
3963 phydev->priv = priv; in lan8814_probe()
3967 kszphy_parse_led_mode(phydev); in lan8814_probe()
3972 addr = lanphy_read_page_reg(phydev, 4, 0) & 0x1F; in lan8814_probe()
3973 devm_phy_package_join(&phydev->mdio.dev, phydev, in lan8814_probe()
3976 if (phy_package_init_once(phydev)) { in lan8814_probe()
3977 err = lan8814_release_coma_mode(phydev); in lan8814_probe()
3981 err = lan8814_ptp_probe_once(phydev); in lan8814_probe()
3986 lan8814_ptp_init(phydev); in lan8814_probe()
3989 lan8814_clear_2psp_bit(phydev); in lan8814_probe()
3990 lan8814_update_meas_time(phydev); in lan8814_probe()
4034 static int lan8841_config_init(struct phy_device *phydev) in lan8841_config_init() argument
4038 ret = ksz9131_config_init(phydev); in lan8841_config_init()
4043 phy_modify_mmd(phydev, KSZ9131RN_MMD_COMMON_CTRL_REG, in lan8841_config_init()
4048 phy_modify_mmd(phydev, KSZ9131RN_MMD_COMMON_CTRL_REG, in lan8841_config_init()
4054 phy_write_mmd(phydev, KSZ9131RN_MMD_COMMON_CTRL_REG, in lan8841_config_init()
4056 phy_write_mmd(phydev, KSZ9131RN_MMD_COMMON_CTRL_REG, in lan8841_config_init()
4058 phy_write_mmd(phydev, KSZ9131RN_MMD_COMMON_CTRL_REG, in lan8841_config_init()
4060 phy_write_mmd(phydev, KSZ9131RN_MMD_COMMON_CTRL_REG, in lan8841_config_init()
4062 phy_write_mmd(phydev, KSZ9131RN_MMD_COMMON_CTRL_REG, in lan8841_config_init()
4064 phy_write_mmd(phydev, KSZ9131RN_MMD_COMMON_CTRL_REG, in lan8841_config_init()
4068 phy_write_mmd(phydev, KSZ9131RN_MMD_COMMON_CTRL_REG, in lan8841_config_init()
4070 phy_write_mmd(phydev, KSZ9131RN_MMD_COMMON_CTRL_REG, in lan8841_config_init()
4074 phy_write_mmd(phydev, LAN8841_MMD_ANALOG_REG, in lan8841_config_init()
4077 phy_write_mmd(phydev, LAN8841_MMD_ANALOG_REG, in lan8841_config_init()
4084 ret = phy_read_mmd(phydev, KSZ9131RN_MMD_COMMON_CTRL_REG, in lan8841_config_init()
4087 phy_write_mmd(phydev, LAN8841_MMD_ANALOG_REG, in lan8841_config_init()
4090 phy_write_mmd(phydev, LAN8841_MMD_ANALOG_REG, in lan8841_config_init()
4101 phy_write_mmd(phydev, LAN8841_MMD_ANALOG_REG, in lan8841_config_init()
4106 phy_write_mmd(phydev, MDIO_MMD_PMAPMD, in lan8841_config_init()
4108 phy_write_mmd(phydev, LAN8841_MMD_TIMER_REG, in lan8841_config_init()
4120 static int lan8841_config_intr(struct phy_device *phydev) in lan8841_config_intr() argument
4124 phy_modify(phydev, LAN8841_OUTPUT_CTRL, in lan8841_config_intr()
4127 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in lan8841_config_intr()
4128 err = phy_read(phydev, LAN8814_INTS); in lan8841_config_intr()
4137 err = phy_write(phydev, LAN8814_INTC, in lan8841_config_intr()
4140 err = phy_write(phydev, LAN8814_INTC, 0); in lan8841_config_intr()
4144 err = phy_read(phydev, LAN8814_INTS); in lan8841_config_intr()
4168 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_get_tx_ts() local
4170 *nsec = phy_read_mmd(phydev, 2, LAN8841_PTP_TX_EGRESS_NS_HI); in lan8841_ptp_get_tx_ts()
4175 *nsec = *nsec | phy_read_mmd(phydev, 2, LAN8841_PTP_TX_EGRESS_NS_LO); in lan8841_ptp_get_tx_ts()
4177 *sec = phy_read_mmd(phydev, 2, LAN8841_PTP_TX_EGRESS_SEC_HI); in lan8841_ptp_get_tx_ts()
4179 *sec = *sec | phy_read_mmd(phydev, 2, LAN8841_PTP_TX_EGRESS_SEC_LO); in lan8841_ptp_get_tx_ts()
4181 *seq = phy_read_mmd(phydev, 2, LAN8841_PTP_TX_MSG_HEADER2); in lan8841_ptp_get_tx_ts()
4202 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_flush_fifo() local
4206 phy_read_mmd(phydev, 2, LAN8841_PTP_TX_MSG_HEADER2); in lan8841_ptp_flush_fifo()
4208 phy_read_mmd(phydev, 2, LAN8841_PTP_INT_STS); in lan8841_ptp_flush_fifo()
4225 struct phy_device *phydev = ptp_priv->phydev; in lan8841_gpio_process_cap() local
4234 tmp = phy_read_mmd(phydev, 2, LAN8841_PTP_GPIO_CAP_STS); in lan8841_gpio_process_cap()
4238 ret = phy_write_mmd(phydev, 2, LAN8841_PTP_GPIO_SEL, in lan8841_gpio_process_cap()
4245 sec = phy_read_mmd(phydev, 2, LAN8841_PTP_GPIO_RE_LTC_SEC_HI_CAP); in lan8841_gpio_process_cap()
4247 sec |= phy_read_mmd(phydev, 2, LAN8841_PTP_GPIO_RE_LTC_SEC_LO_CAP); in lan8841_gpio_process_cap()
4249 nsec = phy_read_mmd(phydev, 2, LAN8841_PTP_GPIO_RE_LTC_NS_HI_CAP) & 0x3fff; in lan8841_gpio_process_cap()
4251 nsec |= phy_read_mmd(phydev, 2, LAN8841_PTP_GPIO_RE_LTC_NS_LO_CAP); in lan8841_gpio_process_cap()
4253 sec = phy_read_mmd(phydev, 2, LAN8841_PTP_GPIO_FE_LTC_SEC_HI_CAP); in lan8841_gpio_process_cap()
4255 sec |= phy_read_mmd(phydev, 2, LAN8841_PTP_GPIO_FE_LTC_SEC_LO_CAP); in lan8841_gpio_process_cap()
4257 nsec = phy_read_mmd(phydev, 2, LAN8841_PTP_GPIO_FE_LTC_NS_HI_CAP) & 0x3fff; in lan8841_gpio_process_cap()
4259 nsec |= phy_read_mmd(phydev, 2, LAN8841_PTP_GPIO_FE_LTC_NS_LO_CAP); in lan8841_gpio_process_cap()
4262 ret = phy_write_mmd(phydev, 2, LAN8841_PTP_GPIO_SEL, 0); in lan8841_gpio_process_cap()
4272 static void lan8841_handle_ptp_interrupt(struct phy_device *phydev) in lan8841_handle_ptp_interrupt() argument
4274 struct kszphy_priv *priv = phydev->priv; in lan8841_handle_ptp_interrupt()
4279 status = phy_read_mmd(phydev, 2, LAN8841_PTP_INT_STS); in lan8841_handle_ptp_interrupt()
4299 static irqreturn_t lan8841_handle_interrupt(struct phy_device *phydev) in lan8841_handle_interrupt() argument
4304 irq_status = phy_read(phydev, LAN8814_INTS); in lan8841_handle_interrupt()
4306 phy_error(phydev); in lan8841_handle_interrupt()
4311 phy_trigger_machine(phydev); in lan8841_handle_interrupt()
4316 lan8841_handle_ptp_interrupt(phydev); in lan8841_handle_interrupt()
4358 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_enable_processing() local
4362 phy_modify_mmd(phydev, 2, LAN8841_PTP_INT_EN, in lan8841_ptp_enable_processing()
4372 phy_modify_mmd(phydev, KSZ9131RN_MMD_COMMON_CTRL_REG, in lan8841_ptp_enable_processing()
4382 phy_modify_mmd(phydev, 2, LAN8841_PTP_INT_EN, in lan8841_ptp_enable_processing()
4387 phy_modify_mmd(phydev, KSZ9131RN_MMD_COMMON_CTRL_REG, in lan8841_ptp_enable_processing()
4405 struct phy_device *phydev = ptp_priv->phydev; in lan8841_hwtstamp() local
4450 phy_write_mmd(phydev, 2, LAN8841_PTP_RX_PARSE_CONFIG, rxcfg); in lan8841_hwtstamp()
4451 phy_write_mmd(phydev, 2, LAN8841_PTP_TX_PARSE_CONFIG, txcfg); in lan8841_hwtstamp()
4455 phy_write_mmd(phydev, 2, LAN8841_PTP_RX_TIMESTAMP_EN, pkt_ts_enable); in lan8841_hwtstamp()
4456 phy_write_mmd(phydev, 2, LAN8841_PTP_TX_TIMESTAMP_EN, pkt_ts_enable); in lan8841_hwtstamp()
4459 phy_modify_mmd(phydev, 2, LAN8841_PTP_TX_MOD, in lan8841_hwtstamp()
4530 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_set_target() local
4533 ret = phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_TARGET_SEC_HI(event), in lan8841_ptp_set_target()
4538 ret = phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_TARGET_SEC_LO(event), in lan8841_ptp_set_target()
4543 ret = phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_TARGET_NS_HI(event) & 0x3fff, in lan8841_ptp_set_target()
4548 return phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_TARGET_NS_LO(event), in lan8841_ptp_set_target()
4569 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_set_reload() local
4572 ret = phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_TARGET_RELOAD_SEC_HI(event), in lan8841_ptp_set_reload()
4577 ret = phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_TARGET_RELOAD_SEC_LO(event), in lan8841_ptp_set_reload()
4582 ret = phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_TARGET_RELOAD_NS_HI(event) & 0x3fff, in lan8841_ptp_set_reload()
4587 return phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_TARGET_RELOAD_NS_LO(event), in lan8841_ptp_set_reload()
4603 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_settime64() local
4609 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_SEC_LO, lower_16_bits(ts->tv_sec)); in lan8841_ptp_settime64()
4610 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_SEC_MID, upper_16_bits(ts->tv_sec)); in lan8841_ptp_settime64()
4611 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_SEC_HI, upper_32_bits(ts->tv_sec) & 0xffff); in lan8841_ptp_settime64()
4612 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_NS_LO, lower_16_bits(ts->tv_nsec)); in lan8841_ptp_settime64()
4613 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_NS_HI, upper_16_bits(ts->tv_nsec) & 0x3fff); in lan8841_ptp_settime64()
4616 phy_write_mmd(phydev, 2, LAN8841_PTP_CMD_CTL, in lan8841_ptp_settime64()
4640 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_gettime64() local
4646 phy_write_mmd(phydev, 2, LAN8841_PTP_CMD_CTL, in lan8841_ptp_gettime64()
4650 s = phy_read_mmd(phydev, 2, LAN8841_PTP_LTC_RD_SEC_HI); in lan8841_ptp_gettime64()
4652 s |= phy_read_mmd(phydev, 2, LAN8841_PTP_LTC_RD_SEC_MID); in lan8841_ptp_gettime64()
4654 s |= phy_read_mmd(phydev, 2, LAN8841_PTP_LTC_RD_SEC_LO); in lan8841_ptp_gettime64()
4656 ns = phy_read_mmd(phydev, 2, LAN8841_PTP_LTC_RD_NS_HI) & 0x3fff; in lan8841_ptp_gettime64()
4658 ns |= phy_read_mmd(phydev, 2, LAN8841_PTP_LTC_RD_NS_LO); in lan8841_ptp_gettime64()
4670 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_getseconds() local
4675 phy_write_mmd(phydev, 2, LAN8841_PTP_CMD_CTL, in lan8841_ptp_getseconds()
4679 s = phy_read_mmd(phydev, 2, LAN8841_PTP_LTC_RD_SEC_HI); in lan8841_ptp_getseconds()
4681 s |= phy_read_mmd(phydev, 2, LAN8841_PTP_LTC_RD_SEC_MID); in lan8841_ptp_getseconds()
4683 s |= phy_read_mmd(phydev, 2, LAN8841_PTP_LTC_RD_SEC_LO); in lan8841_ptp_getseconds()
4699 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_adjtime() local
4751 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_STEP_ADJ_LO, sec); in lan8841_ptp_adjtime()
4752 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_STEP_ADJ_HI, in lan8841_ptp_adjtime()
4754 phy_write_mmd(phydev, 2, LAN8841_PTP_CMD_CTL, in lan8841_ptp_adjtime()
4759 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_STEP_ADJ_LO, in lan8841_ptp_adjtime()
4761 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_STEP_ADJ_HI, in lan8841_ptp_adjtime()
4763 phy_write_mmd(phydev, 2, LAN8841_PTP_CMD_CTL, in lan8841_ptp_adjtime()
4785 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_adjfine() local
4801 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_RATE_ADJ_HI, in lan8841_ptp_adjfine()
4804 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_RATE_ADJ_LO, lower_16_bits(rate)); in lan8841_ptp_adjfine()
4832 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_perout_off() local
4835 ret = phy_clear_bits_mmd(phydev, 2, LAN8841_GPIO_EN, BIT(pin)); in lan8841_ptp_perout_off()
4839 ret = phy_clear_bits_mmd(phydev, 2, LAN8841_GPIO_DIR, BIT(pin)); in lan8841_ptp_perout_off()
4843 return phy_clear_bits_mmd(phydev, 2, LAN8841_GPIO_BUF, BIT(pin)); in lan8841_ptp_perout_off()
4848 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_perout_on() local
4851 ret = phy_set_bits_mmd(phydev, 2, LAN8841_GPIO_EN, BIT(pin)); in lan8841_ptp_perout_on()
4855 ret = phy_set_bits_mmd(phydev, 2, LAN8841_GPIO_DIR, BIT(pin)); in lan8841_ptp_perout_on()
4859 return phy_set_bits_mmd(phydev, 2, LAN8841_GPIO_BUF, BIT(pin)); in lan8841_ptp_perout_on()
4878 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_remove_event() local
4888 ret = phy_clear_bits_mmd(phydev, 2, LAN8841_GPIO_DATA_SEL1, tmp); in lan8841_ptp_remove_event()
4891 ret = phy_clear_bits_mmd(phydev, 2, LAN8841_GPIO_DATA_SEL2, tmp); in lan8841_ptp_remove_event()
4903 return phy_clear_bits_mmd(phydev, 2, LAN8841_GPIO_EN, tmp); in lan8841_ptp_remove_event()
4909 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_enable_event() local
4915 ret = phy_modify_mmd(phydev, 2, LAN8841_PTP_GENERAL_CONFIG, in lan8841_ptp_enable_event()
4921 ret = phy_modify_mmd(phydev, 2, LAN8841_PTP_GENERAL_CONFIG, in lan8841_ptp_enable_event()
4939 ret = phy_set_bits_mmd(phydev, 2, LAN8841_GPIO_DATA_SEL1, in lan8841_ptp_enable_event()
4942 ret = phy_set_bits_mmd(phydev, 2, LAN8841_GPIO_DATA_SEL2, in lan8841_ptp_enable_event()
4968 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_perout() local
5000 phydev_name(phydev)); in lan8841_ptp_perout()
5006 phydev_name(phydev)); in lan8841_ptp_perout()
5055 phydev_name(phydev)); in lan8841_ptp_perout()
5092 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_extts_on() local
5097 ret = phy_set_bits_mmd(phydev, 2, LAN8841_GPIO_EN, BIT(pin)); in lan8841_ptp_extts_on()
5101 ret = phy_clear_bits_mmd(phydev, 2, LAN8841_GPIO_BUF, BIT(pin)); in lan8841_ptp_extts_on()
5110 ret = phy_write_mmd(phydev, 2, LAN8841_PTP_GPIO_CAP_EN, tmp); in lan8841_ptp_extts_on()
5115 return phy_modify_mmd(phydev, 2, LAN8841_PTP_INT_EN, in lan8841_ptp_extts_on()
5122 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_extts_off() local
5126 ret = phy_clear_bits_mmd(phydev, 2, LAN8841_GPIO_EN, BIT(pin)); in lan8841_ptp_extts_off()
5130 ret = phy_clear_bits_mmd(phydev, 2, LAN8841_GPIO_BUF, BIT(pin)); in lan8841_ptp_extts_off()
5135 ret = phy_modify_mmd(phydev, 2, LAN8841_PTP_GPIO_CAP_EN, in lan8841_ptp_extts_off()
5143 return phy_modify_mmd(phydev, 2, LAN8841_PTP_INT_EN, in lan8841_ptp_extts_off()
5226 static int lan8841_probe(struct phy_device *phydev) in lan8841_probe() argument
5232 err = kszphy_probe(phydev); in lan8841_probe()
5236 if (phy_read_mmd(phydev, KSZ9131RN_MMD_COMMON_CTRL_REG, in lan8841_probe()
5239 phydev->interface = PHY_INTERFACE_MODE_RGMII_RXID; in lan8841_probe()
5245 priv = phydev->priv; in lan8841_probe()
5248 ptp_priv->pin_config = devm_kcalloc(&phydev->mdio.dev, in lan8841_probe()
5266 &phydev->mdio.dev); in lan8841_probe()
5268 phydev_err(phydev, "ptp_clock_register failed: %lu\n", in lan8841_probe()
5278 ptp_priv->phydev = phydev; in lan8841_probe()
5287 phydev->mii_ts = &ptp_priv->mii_ts; in lan8841_probe()
5290 phydev->default_timestamp = true; in lan8841_probe()
5295 static int lan8841_suspend(struct phy_device *phydev) in lan8841_suspend() argument
5297 struct kszphy_priv *priv = phydev->priv; in lan8841_suspend()
5303 return genphy_suspend(phydev); in lan8841_suspend()