Lines Matching +full:tx +full:- +full:clk +full:- +full:tap +full:- +full:delay

1 // SPDX-License-Identifier: GPL-2.0+
9 * Copyright (c) 2010-2013 Micrel, Inc.
29 #include <linux/clk.h>
30 #include <linux/delay.h>
119 * The value is calculated as following: (1/1000000)/((2^-32)/4)
260 /* Delay used to get the second part from the LTC */
429 const struct kszphy_type *type = phydev->drv->driver_data; in kszphy_config_intr()
433 if (type && type->interrupt_level_mask) in kszphy_config_intr()
434 mask = type->interrupt_level_mask; in kszphy_config_intr()
446 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in kszphy_config_intr()
509 return -EINVAL; in kszphy_setup_led()
529 * unique (non-broadcast) address on a shared bus.
570 struct kszphy_priv *priv = phydev->priv; in kszphy_config_reset()
573 if (priv->rmii_ref_clk_sel) { in kszphy_config_reset()
574 ret = kszphy_rmii_clk_sel(phydev, priv->rmii_ref_clk_sel_val); in kszphy_config_reset()
582 if (priv->type && priv->led_mode >= 0) in kszphy_config_reset()
583 kszphy_setup_led(phydev, priv->type->led_mode_reg, priv->led_mode); in kszphy_config_reset()
590 struct kszphy_priv *priv = phydev->priv; in kszphy_config_init()
596 type = priv->type; in kszphy_config_init()
598 if (type && type->has_broadcast_disable) in kszphy_config_init()
601 if (type && type->has_nand_tree_disable) in kszphy_config_init()
609 struct device_node *of_node = phydev->mdio.dev.of_node; in ksz8041_fiber_mode()
611 return of_property_read_bool(of_node, "micrel,fiber-mode"); in ksz8041_fiber_mode()
620 phydev->dev_flags |= MICREL_PHY_FXEN; in ksz8041_config_init()
624 linkmode_and(phydev->supported, phydev->supported, mask); in ksz8041_config_init()
626 phydev->supported); in ksz8041_config_init()
627 linkmode_and(phydev->advertising, phydev->advertising, mask); in ksz8041_config_init()
629 phydev->advertising); in ksz8041_config_init()
630 phydev->autoneg = AUTONEG_DISABLE; in ksz8041_config_init()
638 /* Skip auto-negotiation in fiber mode */ in ksz8041_config_aneg()
639 if (phydev->dev_flags & MICREL_PHY_FXEN) { in ksz8041_config_aneg()
640 phydev->speed = SPEED_100; in ksz8041_config_aneg()
652 if (!phy_id_compare(phydev->phy_id, PHY_ID_KSZ8051, MICREL_PHY_ID_MASK)) in ksz8051_ksz8795_match_phy_device()
678 /* KSZPHY_OMSO_FACTORY_TEST is set at de-assertion of the reset line in ksz8081_config_init()
680 * pull-down is missing, the factory test mode should be cleared by in ksz8081_config_init()
722 /* The MDI-X configuration is automatically changed by the PHY after in ksz8081_config_aneg()
723 * switching from autoneg off to on. So, take MDI-X configuration under in ksz8081_config_aneg()
726 return ksz8081_config_mdix(phydev, phydev->mdix_ctrl); in ksz8081_config_aneg()
739 phydev->mdix_ctrl = ETH_TP_MDI_X; in ksz8081_mdix_update()
741 phydev->mdix_ctrl = ETH_TP_MDI; in ksz8081_mdix_update()
743 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in ksz8081_mdix_update()
751 phydev->mdix = ETH_TP_MDI; in ksz8081_mdix_update()
753 phydev->mdix = ETH_TP_MDI_X; in ksz8081_mdix_update()
802 int val1 = -1; in ksz9021_load_values_from_of()
803 int val2 = -2; in ksz9021_load_values_from_of()
804 int val3 = -3; in ksz9021_load_values_from_of()
805 int val4 = -4; in ksz9021_load_values_from_of()
829 if (val1 != -1) in ksz9021_load_values_from_of()
832 if (val2 != -2) in ksz9021_load_values_from_of()
835 if (val3 != -3) in ksz9021_load_values_from_of()
838 if (val4 != -4) in ksz9021_load_values_from_of()
853 dev_walker = &phydev->mdio.dev; in ksz9021_config_init()
855 of_node = dev_walker->of_node; in ksz9021_config_init()
856 dev_walker = dev_walker->parent; in ksz9021_config_init()
863 "txen-skew-ps", "txc-skew-ps", in ksz9021_config_init()
864 "rxdv-skew-ps", "rxc-skew-ps"); in ksz9021_config_init()
867 "rxd0-skew-ps", "rxd1-skew-ps", in ksz9021_config_init()
868 "rxd2-skew-ps", "rxd3-skew-ps"); in ksz9021_config_init()
871 "txd0-skew-ps", "txd1-skew-ps", in ksz9021_config_init()
872 "txd2-skew-ps", "txd3-skew-ps"); in ksz9021_config_init()
906 * provide different RGMII options we need to configure delay offset
907 * for each pad relative to build in delay.
909 /* keep rx as "No delay adjustment" and set rx_clk to +0.60ns to get delays of
915 /* set rx to +0.30ns and rx_clk to -0.90ns to compensate the
916 * internal 1.2ns delay.
921 /* set tx to -0.42ns and tx_clk to +0.96ns to get 1.38ns delay */
925 /* set tx and tx_clk to "No delay adjustment" to keep 0ns
941 int val[4] = {-1, -2, -3, -4}; in ksz9031_of_load_skew_values()
964 if (val[i] != -(i + 1)) { in ksz9031_of_load_skew_values()
993 /* Enable energy-detect power-down mode */
1007 u16 rx, tx, rx_clk, tx_clk; in ksz9031_config_rgmii_delay() local
1010 switch (phydev->interface) { in ksz9031_config_rgmii_delay()
1012 tx = TX_ND; in ksz9031_config_rgmii_delay()
1018 tx = TX_ID; in ksz9031_config_rgmii_delay()
1024 tx = TX_ND; in ksz9031_config_rgmii_delay()
1030 tx = TX_ID; in ksz9031_config_rgmii_delay()
1041 FIELD_PREP(MII_KSZ9031RN_TX_CTL_M, tx)); in ksz9031_config_rgmii_delay()
1054 FIELD_PREP(MII_KSZ9031RN_TXD3, tx) | in ksz9031_config_rgmii_delay()
1055 FIELD_PREP(MII_KSZ9031RN_TXD2, tx) | in ksz9031_config_rgmii_delay()
1056 FIELD_PREP(MII_KSZ9031RN_TXD1, tx) | in ksz9031_config_rgmii_delay()
1057 FIELD_PREP(MII_KSZ9031RN_TXD0, tx)); in ksz9031_config_rgmii_delay()
1069 static const char *clk_skews[2] = {"rxc-skew-ps", "txc-skew-ps"}; in ksz9031_config_init()
1071 "rxd0-skew-ps", "rxd1-skew-ps", in ksz9031_config_init()
1072 "rxd2-skew-ps", "rxd3-skew-ps" in ksz9031_config_init()
1075 "txd0-skew-ps", "txd1-skew-ps", in ksz9031_config_init()
1076 "txd2-skew-ps", "txd3-skew-ps" in ksz9031_config_init()
1078 static const char *control_skews[2] = {"txen-skew-ps", "rxdv-skew-ps"}; in ksz9031_config_init()
1090 dev_walker = &phydev->mdio.dev; in ksz9031_config_init()
1092 of_node = dev_walker->of_node; in ksz9031_config_init()
1093 dev_walker = dev_walker->parent; in ksz9031_config_init()
1123 "*-skew-ps values should be used only with RGMII PHY modes\n"); in ksz9031_config_init()
1126 * When the device links in the 1000BASE-T slave mode only, in ksz9031_config_init()
1140 if (of_property_read_bool(of_node, "micrel,force-master")) { in ksz9031_config_init()
1170 int val[4] = {-(1 + KSZ9131_OFFSET), -(2 + KSZ9131_OFFSET), in ksz9131_of_load_skew_values()
1171 -(3 + KSZ9131_OFFSET), -(4 + KSZ9131_OFFSET)}; in ksz9131_of_load_skew_values()
1187 if (skewval < -KSZ9131_OFFSET) in ksz9131_of_load_skew_values()
1188 skewval = -KSZ9131_OFFSET; in ksz9131_of_load_skew_values()
1206 if (val[i] != -(i + 1 + KSZ9131_OFFSET)) { in ksz9131_of_load_skew_values()
1224 const struct kszphy_type *type = phydev->drv->driver_data; in ksz9131_config_rgmii_delay()
1228 switch (phydev->interface) { in ksz9131_config_rgmii_delay()
1230 rxcdll_val = type->disable_dll_rx_bit; in ksz9131_config_rgmii_delay()
1231 txcdll_val = type->disable_dll_tx_bit; in ksz9131_config_rgmii_delay()
1239 txcdll_val = type->disable_dll_tx_bit; in ksz9131_config_rgmii_delay()
1242 rxcdll_val = type->disable_dll_rx_bit; in ksz9131_config_rgmii_delay()
1250 KSZ9131RN_RXC_DLL_CTRL, type->disable_dll_mask, in ksz9131_config_rgmii_delay()
1256 KSZ9131RN_TXC_DLL_CTRL, type->disable_dll_mask, in ksz9131_config_rgmii_delay()
1262 * When LEDs are configured in Individual Mode, LED1 is ON in a no-link
1283 char *clk_skews[2] = {"rxc-skew-psec", "txc-skew-psec"}; in ksz9131_config_init()
1285 "rxd0-skew-psec", "rxd1-skew-psec", in ksz9131_config_init()
1286 "rxd2-skew-psec", "rxd3-skew-psec" in ksz9131_config_init()
1289 "txd0-skew-psec", "txd1-skew-psec", in ksz9131_config_init()
1290 "txd2-skew-psec", "txd3-skew-psec" in ksz9131_config_init()
1292 char *control_skews[2] = {"txen-skew-psec", "rxdv-skew-psec"}; in ksz9131_config_init()
1296 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in ksz9131_config_init()
1298 dev_walker = &phydev->mdio.dev; in ksz9131_config_init()
1300 of_node = dev_walker->of_node; in ksz9131_config_init()
1301 dev_walker = dev_walker->parent; in ksz9131_config_init()
1355 if (phydev->mdix_ctrl != ETH_TP_MDI_AUTO) { in ksz9131_mdix_update()
1356 phydev->mdix = phydev->mdix_ctrl; in ksz9131_mdix_update()
1364 phydev->mdix = ETH_TP_MDI; in ksz9131_mdix_update()
1366 phydev->mdix = ETH_TP_MDI_X; in ksz9131_mdix_update()
1368 phydev->mdix = ETH_TP_MDI_INVALID; in ksz9131_mdix_update()
1414 ret = ksz9131_config_mdix(phydev, phydev->mdix_ctrl); in ksz9131_config_aneg()
1435 linkmode_and(phydev->supported_eee, phydev->supported, in ksz9477_get_features()
1454 phydev->duplex = DUPLEX_HALF; in ksz8873mll_read_status()
1456 phydev->duplex = DUPLEX_FULL; in ksz8873mll_read_status()
1459 phydev->speed = SPEED_10; in ksz8873mll_read_status()
1461 phydev->speed = SPEED_100; in ksz8873mll_read_status()
1463 phydev->link = 1; in ksz8873mll_read_status()
1464 phydev->pause = phydev->asym_pause = 0; in ksz8873mll_read_status()
1479 * link-up may fail after a link-up to link-down transition. in ksz9031_get_features()
1486 linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydev->supported); in ksz9031_get_features()
1491 linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported); in ksz9031_get_features()
1511 phydev->link = 0; in ksz9031_read_status()
1512 if (phydev->drv->config_intr && phy_interrupt_is_valid(phydev)) in ksz9031_read_status()
1513 phydev->drv->config_intr(phydev); in ksz9031_read_status()
1522 struct kszphy_priv *priv = phydev->priv; in ksz9x31_cable_test_start()
1525 /* KSZ9131RNX, DS00002841B-page 38, 4.14 LinkMD (R) Cable Diagnostic in ksz9x31_cable_test_start()
1526 * Prior to running the cable diagnostics, Auto-negotiation should in ksz9x31_cable_test_start()
1537 /* KSZ9131RNX, DS00002841B-page 38, 4.14 LinkMD (R) Cable Diagnostic in ksz9x31_cable_test_start()
1538 * The Master-Slave configuration should be set to Slave by writing in ksz9x31_cable_test_start()
1539 * a value of 0x1000 to the Auto-Negotiation Master Slave Control in ksz9x31_cable_test_start()
1547 priv->vct_ctrl1000 = ret & (CTL1000_ENABLE_MASTER | CTL1000_AS_MASTER); in ksz9x31_cable_test_start()
1592 /* KSZ9131RNX, DS00002841B-page 38, 4.14 LinkMD (R) Cable Diagnostic in ksz9x31_cable_test_fault_length()
1594 * distance to fault = (VCT_DATA - 22) * 4 / cable propagation velocity in ksz9x31_cable_test_fault_length()
1597 dt = clamp(dt - 22, 0, 255); in ksz9x31_cable_test_fault_length()
1629 /* KSZ9131RNX, DS00002841B-page 38, 4.14 LinkMD (R) Cable Diagnostic in ksz9x31_cable_test_one_pair()
1650 return -EAGAIN; in ksz9x31_cable_test_one_pair()
1669 struct kszphy_priv *priv = phydev->priv; in ksz9x31_cable_test_get_status()
1677 while (pair_mask && retries--) { in ksz9x31_cable_test_get_status()
1680 if (ret == -EAGAIN) in ksz9x31_cable_test_get_status()
1706 priv->vct_ctrl1000); in ksz9x31_cable_test_get_status()
1728 * counter intuitive, the "-X" in "1 = Force MDI" in the data in ksz886x_config_mdix()
1730 * 1 = Force MDI (sic!) (transmit on RX+/RX- pins) in ksz886x_config_mdix()
1731 * 0 = Normal operation (transmit on TX+/TX- pins) in ksz886x_config_mdix()
1756 /* The MDI-X configuration is automatically changed by the PHY after in ksz886x_config_aneg()
1757 * switching from autoneg off to on. So, take MDI-X configuration under in ksz886x_config_aneg()
1760 return ksz886x_config_mdix(phydev, phydev->mdix_ctrl); in ksz886x_config_aneg()
1773 phydev->mdix_ctrl = ETH_TP_MDI_X; in ksz886x_mdix_update()
1775 phydev->mdix_ctrl = ETH_TP_MDI; in ksz886x_mdix_update()
1777 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in ksz886x_mdix_update()
1786 phydev->mdix = ETH_TP_MDI_X; in ksz886x_mdix_update()
1788 phydev->mdix = ETH_TP_MDI; in ksz886x_mdix_update()
1820 /* Transmit waveform amplitude can be improved (1000BASE-T, 100BASE-TX, 10BASE-Te) */
1849 * necessary to set the PHY to 100 Mbps speed with auto-negotiation in ksz9477_phy_errata()
1850 * disabled by writing to register 0xN100-0xN101. After writing the in ksz9477_phy_errata()
1852 * register settings, write register 0xN100-0xN101 again to enable in ksz9477_phy_errata()
1853 * and restart auto-negotiation. in ksz9477_phy_errata()
1862 err = phy_write_mmd(phydev, errata->dev_addr, errata->reg_addr, errata->val); in ksz9477_phy_errata()
1879 if ((phydev->phy_id & 0xf) == 1) { in ksz9477_config_init()
1888 if (phydev->dev_flags & MICREL_NO_EEE) in ksz9477_config_init()
1889 phydev->eee_broken_modes = -1; in ksz9477_config_init()
1912 struct kszphy_priv *priv = phydev->priv; in kszphy_get_stat()
1920 val = val & ((1 << stat.bits) - 1); in kszphy_get_stat()
1921 priv->stats[i] += val; in kszphy_get_stat()
1922 ret = priv->stats[i]; in kszphy_get_stat()
1941 phydev->interrupts = PHY_INTERRUPT_DISABLED; in kszphy_suspend()
1942 if (phydev->drv->config_intr) in kszphy_suspend()
1943 phydev->drv->config_intr(phydev); in kszphy_suspend()
1951 const struct kszphy_type *type = phydev->drv->driver_data; in kszphy_parse_led_mode()
1952 const struct device_node *np = phydev->mdio.dev.of_node; in kszphy_parse_led_mode()
1953 struct kszphy_priv *priv = phydev->priv; in kszphy_parse_led_mode()
1956 if (type && type->led_mode_reg) { in kszphy_parse_led_mode()
1957 ret = of_property_read_u32(np, "micrel,led-mode", in kszphy_parse_led_mode()
1958 &priv->led_mode); in kszphy_parse_led_mode()
1961 priv->led_mode = -1; in kszphy_parse_led_mode()
1963 if (priv->led_mode > 3) { in kszphy_parse_led_mode()
1965 priv->led_mode); in kszphy_parse_led_mode()
1966 priv->led_mode = -1; in kszphy_parse_led_mode()
1969 priv->led_mode = -1; in kszphy_parse_led_mode()
1979 /* After switching from power-down to normal mode, an internal global in kszphy_resume()
1991 phydev->interrupts = PHY_INTERRUPT_ENABLED; in kszphy_resume()
1992 if (phydev->drv->config_intr) in kszphy_resume()
1993 phydev->drv->config_intr(phydev); in kszphy_resume()
2012 /* After switching from power-down to normal mode, an internal global in ksz9477_resume()
2019 if ((phydev->phy_id & 0xf) == 1) { in ksz9477_resume()
2027 phydev->interrupts = PHY_INTERRUPT_ENABLED; in ksz9477_resume()
2028 if (phydev->drv->config_intr) in ksz9477_resume()
2029 phydev->drv->config_intr(phydev); in ksz9477_resume()
2049 /* Re-program the value after chip is reset. */ in ksz8061_resume()
2056 phydev->interrupts = PHY_INTERRUPT_ENABLED; in ksz8061_resume()
2057 if (phydev->drv->config_intr) in ksz8061_resume()
2058 phydev->drv->config_intr(phydev); in ksz8061_resume()
2066 const struct kszphy_type *type = phydev->drv->driver_data; in kszphy_probe()
2067 const struct device_node *np = phydev->mdio.dev.of_node; in kszphy_probe()
2069 struct clk *clk; in kszphy_probe() local
2071 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in kszphy_probe()
2073 return -ENOMEM; in kszphy_probe()
2075 phydev->priv = priv; in kszphy_probe()
2077 priv->type = type; in kszphy_probe()
2081 clk = devm_clk_get(&phydev->mdio.dev, "rmii-ref"); in kszphy_probe()
2082 /* NOTE: clk may be NULL if building without CONFIG_HAVE_CLK */ in kszphy_probe()
2083 if (!IS_ERR_OR_NULL(clk)) { in kszphy_probe()
2084 unsigned long rate = clk_get_rate(clk); in kszphy_probe()
2088 priv->rmii_ref_clk_sel = type->has_rmii_ref_clk_sel; in kszphy_probe()
2090 "micrel,rmii-reference-clock-select-25-mhz"); in kszphy_probe()
2093 priv->rmii_ref_clk_sel_val = rmii_ref_clk_sel_25_mhz; in kszphy_probe()
2095 priv->rmii_ref_clk_sel_val = !rmii_ref_clk_sel_25_mhz; in kszphy_probe()
2099 return -EINVAL; in kszphy_probe()
2104 phydev->port = PORT_FIBRE; in kszphy_probe()
2106 /* Support legacy board-file configuration */ in kszphy_probe()
2107 if (phydev->dev_flags & MICREL_PHY_50MHZ_CLK) { in kszphy_probe()
2108 priv->rmii_ref_clk_sel = true; in kszphy_probe()
2109 priv->rmii_ref_clk_sel_val = true; in kszphy_probe()
2119 * confuse the internal state machine - disable auto neg here. in lan8814_cable_test_start()
2128 if (phydev->dev_flags & MICREL_KSZ8_P1_ERRATA) in ksz886x_cable_test_start()
2129 return -EOPNOTSUPP; in ksz886x_cable_test_start()
2133 * confuse the internal state machine - disable auto neg here. in ksz886x_cable_test_start()
2179 * (DELTA_TIME - 22) * 0.8 for lan8814 phy. in ksz886x_cable_test_fault_length()
2184 return ((dt - 22) * 800) / 10; in ksz886x_cable_test_fault_length()
2191 const struct kszphy_type *type = phydev->drv->driver_data; in ksz886x_cable_test_wait_for_completion()
2194 ret = phy_read_poll_timeout(phydev, type->cable_diag_reg, val, in ksz886x_cable_test_wait_for_completion()
2228 return -EAGAIN; in lan8814_cable_test_one_pair()
2256 * We can workaround this limitation by using the MDI-X functionality. in ksz886x_cable_test_one_pair()
2263 switch (phydev->phy_id & MICREL_PHY_ID_MASK) { in ksz886x_cable_test_one_pair()
2271 ret = -ENODEV; in ksz886x_cable_test_one_pair()
2293 return -EAGAIN; in ksz886x_cable_test_one_pair()
2311 const struct kszphy_type *type = phydev->drv->driver_data; in ksz886x_cable_test_get_status()
2312 unsigned long pair_mask = type->pair_mask; in ksz886x_cable_test_get_status()
2320 while (pair_mask && retries--) { in ksz886x_cable_test_get_status()
2322 if (type->cable_diag_reg == LAN8814_CABLE_DIAG) in ksz886x_cable_test_get_status()
2326 if (ret == -EAGAIN) in ksz886x_cable_test_get_status()
2439 struct phy_device *phydev = ptp_priv->phydev; in lan8814_ts_info()
2440 struct lan8814_shared_priv *shared = phydev->shared->priv; in lan8814_ts_info()
2442 info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | in lan8814_ts_info()
2446 info->phc_index = ptp_clock_index(shared->ptp_clock); in lan8814_ts_info()
2448 info->tx_types = in lan8814_ts_info()
2453 info->rx_filters = in lan8814_ts_info()
2479 struct phy_device *phydev = ptp_priv->phydev; in lan8814_hwtstamp()
2480 struct lan8814_shared_priv *shared = phydev->shared->priv; in lan8814_hwtstamp()
2487 if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) in lan8814_hwtstamp()
2488 return -EFAULT; in lan8814_hwtstamp()
2490 ptp_priv->hwts_tx_type = config.tx_type; in lan8814_hwtstamp()
2491 ptp_priv->rx_filter = config.rx_filter; in lan8814_hwtstamp()
2495 ptp_priv->layer = 0; in lan8814_hwtstamp()
2496 ptp_priv->version = 0; in lan8814_hwtstamp()
2501 ptp_priv->layer = PTP_CLASS_L4; in lan8814_hwtstamp()
2502 ptp_priv->version = PTP_CLASS_V2; in lan8814_hwtstamp()
2507 ptp_priv->layer = PTP_CLASS_L2; in lan8814_hwtstamp()
2508 ptp_priv->version = PTP_CLASS_V2; in lan8814_hwtstamp()
2513 ptp_priv->layer = PTP_CLASS_L4 | PTP_CLASS_L2; in lan8814_hwtstamp()
2514 ptp_priv->version = PTP_CLASS_V2; in lan8814_hwtstamp()
2517 return -ERANGE; in lan8814_hwtstamp()
2520 if (ptp_priv->layer & PTP_CLASS_L2) { in lan8814_hwtstamp()
2523 } else if (ptp_priv->layer & PTP_CLASS_L4) { in lan8814_hwtstamp()
2527 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_RX_PARSE_CONFIG, rxcfg); in lan8814_hwtstamp()
2528 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_PARSE_CONFIG, txcfg); in lan8814_hwtstamp()
2532 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_RX_TIMESTAMP_EN, pkt_ts_enable); in lan8814_hwtstamp()
2533 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_TIMESTAMP_EN, pkt_ts_enable); in lan8814_hwtstamp()
2535 tx_mod = lanphy_read_page_reg(ptp_priv->phydev, 5, PTP_TX_MOD); in lan8814_hwtstamp()
2536 if (ptp_priv->hwts_tx_type == HWTSTAMP_TX_ONESTEP_SYNC) { in lan8814_hwtstamp()
2537 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_MOD, in lan8814_hwtstamp()
2539 } else if (ptp_priv->hwts_tx_type == HWTSTAMP_TX_ON) { in lan8814_hwtstamp()
2540 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_MOD, in lan8814_hwtstamp()
2545 lan8814_config_ts_intr(ptp_priv->phydev, true); in lan8814_hwtstamp()
2547 lan8814_config_ts_intr(ptp_priv->phydev, false); in lan8814_hwtstamp()
2549 mutex_lock(&shared->shared_lock); in lan8814_hwtstamp()
2551 shared->ref++; in lan8814_hwtstamp()
2553 shared->ref--; in lan8814_hwtstamp()
2555 if (shared->ref) in lan8814_hwtstamp()
2556 lanphy_write_page_reg(ptp_priv->phydev, 4, PTP_CMD_CTL, in lan8814_hwtstamp()
2559 lanphy_write_page_reg(ptp_priv->phydev, 4, PTP_CMD_CTL, in lan8814_hwtstamp()
2561 mutex_unlock(&shared->shared_lock); in lan8814_hwtstamp()
2564 list_for_each_entry_safe(rx_ts, tmp, &ptp_priv->rx_ts_list, list) { in lan8814_hwtstamp()
2565 list_del(&rx_ts->list); in lan8814_hwtstamp()
2568 skb_queue_purge(&ptp_priv->rx_queue); in lan8814_hwtstamp()
2569 skb_queue_purge(&ptp_priv->tx_queue); in lan8814_hwtstamp()
2571 lan8814_flush_fifo(ptp_priv->phydev, false); in lan8814_hwtstamp()
2572 lan8814_flush_fifo(ptp_priv->phydev, true); in lan8814_hwtstamp()
2574 return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? -EFAULT : 0; in lan8814_hwtstamp()
2582 switch (ptp_priv->hwts_tx_type) { in lan8814_txtstamp()
2590 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in lan8814_txtstamp()
2591 skb_queue_tail(&ptp_priv->tx_queue, skb); in lan8814_txtstamp()
2613 *sig = (__force u16)(ntohs(ptp_header->sequence_id)); in lan8814_get_sig_rx()
2630 spin_lock_irqsave(&ptp_priv->rx_ts_lock, flags); in lan8814_match_rx_skb()
2631 list_for_each_entry_safe(rx_ts, tmp, &ptp_priv->rx_ts_list, list) { in lan8814_match_rx_skb()
2633 if (memcmp(&skb_sig, &rx_ts->seq_id, sizeof(rx_ts->seq_id))) in lan8814_match_rx_skb()
2638 shhwtstamps->hwtstamp = ktime_set(rx_ts->seconds, in lan8814_match_rx_skb()
2639 rx_ts->nsec); in lan8814_match_rx_skb()
2640 list_del(&rx_ts->list); in lan8814_match_rx_skb()
2646 spin_unlock_irqrestore(&ptp_priv->rx_ts_lock, flags); in lan8814_match_rx_skb()
2658 if (ptp_priv->rx_filter == HWTSTAMP_FILTER_NONE || in lan8814_rxtstamp()
2662 if ((type & ptp_priv->version) == 0 || (type & ptp_priv->layer) == 0) in lan8814_rxtstamp()
2669 skb_queue_tail(&ptp_priv->rx_queue, skb); in lan8814_rxtstamp()
2711 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_gettime64()
2715 mutex_lock(&shared->shared_lock); in lan8814_ptpci_gettime64()
2717 mutex_unlock(&shared->shared_lock); in lan8814_ptpci_gettime64()
2718 ts->tv_sec = seconds; in lan8814_ptpci_gettime64()
2719 ts->tv_nsec = nano_seconds; in lan8814_ptpci_gettime64()
2729 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_settime64()
2731 mutex_lock(&shared->shared_lock); in lan8814_ptpci_settime64()
2732 lan8814_ptp_clock_set(phydev, ts->tv_sec, ts->tv_nsec); in lan8814_ptpci_settime64()
2733 mutex_unlock(&shared->shared_lock); in lan8814_ptpci_settime64()
2756 nano_seconds -= 1000000000; in lan8814_ptp_clock_step()
2760 } else if (time_step_ns < -15000000000LL) { in lan8814_ptp_clock_step()
2762 time_step_ns = -time_step_ns; in lan8814_ptp_clock_step()
2765 unsigned_seconds -= div_u64_rem(time_step_ns, 1000000000LL, in lan8814_ptp_clock_step()
2769 unsigned_seconds--; in lan8814_ptp_clock_step()
2772 nano_seconds -= nano_seconds_step; in lan8814_ptp_clock_step()
2785 abs_time_step_ns = (u64)(-time_step_ns); in lan8814_ptp_clock_step()
2786 seconds = -((s32)div_u64_rem(abs_time_step_ns, 1000000000, in lan8814_ptp_clock_step()
2794 seconds--; in lan8814_ptp_clock_step()
2795 nano_seconds = (1000000000 - nano_seconds); in lan8814_ptp_clock_step()
2807 nano_seconds -= 1000000000; in lan8814_ptp_clock_step()
2826 seconds -= ((s32)adjustment_value); in lan8814_ptp_clock_step()
2828 u32 adjustment_value = (u32)(-seconds); in lan8814_ptp_clock_step()
2867 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_adjtime()
2869 mutex_lock(&shared->shared_lock); in lan8814_ptpci_adjtime()
2871 mutex_unlock(&shared->shared_lock); in lan8814_ptpci_adjtime()
2880 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_adjfine()
2886 scaled_ppm = -scaled_ppm; in lan8814_ptpci_adjfine()
2899 mutex_lock(&shared->shared_lock); in lan8814_ptpci_adjfine()
2902 mutex_unlock(&shared->shared_lock); in lan8814_ptpci_adjfine()
2918 *sig = (__force u16)(ntohs(ptp_header->sequence_id)); in lan8814_get_sig_tx()
2931 spin_lock_irqsave(&ptp_priv->tx_queue.lock, flags); in lan8814_match_tx_skb()
2932 skb_queue_walk_safe(&ptp_priv->tx_queue, skb, skb_tmp) { in lan8814_match_tx_skb()
2939 __skb_unlink(skb, &ptp_priv->tx_queue); in lan8814_match_tx_skb()
2943 spin_unlock_irqrestore(&ptp_priv->tx_queue.lock, flags); in lan8814_match_tx_skb()
2954 struct phy_device *phydev = ptp_priv->phydev; in lan8814_dequeue_tx_skb()
2964 struct phy_device *phydev = ptp_priv->phydev; in lan8814_get_tx_ts()
2986 spin_lock_irqsave(&ptp_priv->rx_queue.lock, flags); in lan8814_match_skb()
2987 skb_queue_walk_safe(&ptp_priv->rx_queue, skb, skb_tmp) { in lan8814_match_skb()
2991 if (memcmp(&skb_sig, &rx_ts->seq_id, sizeof(rx_ts->seq_id))) in lan8814_match_skb()
2994 __skb_unlink(skb, &ptp_priv->rx_queue); in lan8814_match_skb()
2999 spin_unlock_irqrestore(&ptp_priv->rx_queue.lock, flags); in lan8814_match_skb()
3004 shhwtstamps->hwtstamp = ktime_set(rx_ts->seconds, rx_ts->nsec); in lan8814_match_skb()
3020 spin_lock_irqsave(&ptp_priv->rx_ts_lock, flags); in lan8814_match_rx_ts()
3021 list_add(&rx_ts->list, &ptp_priv->rx_ts_list); in lan8814_match_rx_ts()
3022 spin_unlock_irqrestore(&ptp_priv->rx_ts_lock, flags); in lan8814_match_rx_ts()
3030 struct phy_device *phydev = ptp_priv->phydev; in lan8814_get_rx_ts()
3039 lan8814_ptp_rx_ts_get(phydev, &rx_ts->seconds, &rx_ts->nsec, in lan8814_get_rx_ts()
3040 &rx_ts->seq_id); in lan8814_get_rx_ts()
3052 struct kszphy_priv *priv = phydev->priv; in lan8814_handle_ptp_interrupt()
3053 struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; in lan8814_handle_ptp_interrupt()
3063 skb_queue_purge(&ptp_priv->tx_queue); in lan8814_handle_ptp_interrupt()
3068 skb_queue_purge(&ptp_priv->rx_queue); in lan8814_handle_ptp_interrupt()
3076 /* MDI-X setting for swap A,B transmit */ in lan8804_config_init()
3123 /* By default interrupt buffer is open-drain in which case the interrupt in lan8804_config_intr()
3125 * push-pull to be able to change interrupt polarity in lan8804_config_intr()
3130 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in lan8804_config_intr()
3198 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in lan8814_config_intr()
3217 struct kszphy_priv *priv = phydev->priv; in lan8814_ptp_init()
3218 struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; in lan8814_ptp_init()
3250 skb_queue_head_init(&ptp_priv->tx_queue); in lan8814_ptp_init()
3251 skb_queue_head_init(&ptp_priv->rx_queue); in lan8814_ptp_init()
3252 INIT_LIST_HEAD(&ptp_priv->rx_ts_list); in lan8814_ptp_init()
3253 spin_lock_init(&ptp_priv->rx_ts_lock); in lan8814_ptp_init()
3255 ptp_priv->phydev = phydev; in lan8814_ptp_init()
3257 ptp_priv->mii_ts.rxtstamp = lan8814_rxtstamp; in lan8814_ptp_init()
3258 ptp_priv->mii_ts.txtstamp = lan8814_txtstamp; in lan8814_ptp_init()
3259 ptp_priv->mii_ts.hwtstamp = lan8814_hwtstamp; in lan8814_ptp_init()
3260 ptp_priv->mii_ts.ts_info = lan8814_ts_info; in lan8814_ptp_init()
3262 phydev->mii_ts = &ptp_priv->mii_ts; in lan8814_ptp_init()
3267 struct lan8814_shared_priv *shared = phydev->shared->priv; in lan8814_ptp_probe_once()
3270 mutex_init(&shared->shared_lock); in lan8814_ptp_probe_once()
3272 shared->ptp_clock_info.owner = THIS_MODULE; in lan8814_ptp_probe_once()
3273 snprintf(shared->ptp_clock_info.name, 30, "%s", phydev->drv->name); in lan8814_ptp_probe_once()
3274 shared->ptp_clock_info.max_adj = 31249999; in lan8814_ptp_probe_once()
3275 shared->ptp_clock_info.n_alarm = 0; in lan8814_ptp_probe_once()
3276 shared->ptp_clock_info.n_ext_ts = 0; in lan8814_ptp_probe_once()
3277 shared->ptp_clock_info.n_pins = 0; in lan8814_ptp_probe_once()
3278 shared->ptp_clock_info.pps = 0; in lan8814_ptp_probe_once()
3279 shared->ptp_clock_info.pin_config = NULL; in lan8814_ptp_probe_once()
3280 shared->ptp_clock_info.adjfine = lan8814_ptpci_adjfine; in lan8814_ptp_probe_once()
3281 shared->ptp_clock_info.adjtime = lan8814_ptpci_adjtime; in lan8814_ptp_probe_once()
3282 shared->ptp_clock_info.gettime64 = lan8814_ptpci_gettime64; in lan8814_ptp_probe_once()
3283 shared->ptp_clock_info.settime64 = lan8814_ptpci_settime64; in lan8814_ptp_probe_once()
3284 shared->ptp_clock_info.getcrosststamp = NULL; in lan8814_ptp_probe_once()
3286 shared->ptp_clock = ptp_clock_register(&shared->ptp_clock_info, in lan8814_ptp_probe_once()
3287 &phydev->mdio.dev); in lan8814_ptp_probe_once()
3288 if (IS_ERR(shared->ptp_clock)) { in lan8814_ptp_probe_once()
3290 PTR_ERR(shared->ptp_clock)); in lan8814_ptp_probe_once()
3291 return -EINVAL; in lan8814_ptp_probe_once()
3295 if (!shared->ptp_clock) in lan8814_ptp_probe_once()
3300 shared->phydev = phydev; in lan8814_ptp_probe_once()
3328 struct kszphy_priv *lan8814 = phydev->priv; in lan8814_config_init()
3341 /* MDI-X setting for swap A,B transmit */ in lan8814_config_init()
3347 if (lan8814->led_mode >= 0) in lan8814_config_init()
3348 lan8814_setup_led(phydev, lan8814->led_mode); in lan8814_config_init()
3362 gpiod = devm_gpiod_get_optional(&phydev->mdio.dev, "coma-mode", in lan8814_release_coma_mode()
3376 const struct kszphy_type *type = phydev->drv->driver_data; in lan8814_probe()
3381 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in lan8814_probe()
3383 return -ENOMEM; in lan8814_probe()
3385 phydev->priv = priv; in lan8814_probe()
3387 priv->type = type; in lan8814_probe()
3391 /* Strap-in value for PHY address, below register read gives starting in lan8814_probe()
3395 devm_phy_package_join(&phydev->mdio.dev, phydev, in lan8814_probe()
3499 /* 10M/100M Ethernet Signal Tuning Errata for Shorted-Center Tap in lan8841_config_init()
3545 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in lan8841_config_intr()
3586 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_get_tx_ts()
3620 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_flush_fifo()
3643 struct phy_device *phydev = ptp_priv->phydev; in lan8841_gpio_process_cap()
3648 pin = ptp_find_pin_unlocked(ptp_priv->ptp_clock, PTP_PF_EXTTS, 0); in lan8841_gpio_process_cap()
3649 if (pin == -1) in lan8841_gpio_process_cap()
3661 mutex_lock(&ptp_priv->ptp_lock); in lan8841_gpio_process_cap()
3679 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_gpio_process_cap()
3687 ptp_clock_event(ptp_priv->ptp_clock, &ptp_event); in lan8841_gpio_process_cap()
3692 struct kszphy_priv *priv = phydev->priv; in lan8841_handle_ptp_interrupt()
3693 struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; in lan8841_handle_ptp_interrupt()
3707 skb_queue_purge(&ptp_priv->tx_queue); in lan8841_handle_ptp_interrupt()
3748 info->phc_index = ptp_priv->ptp_clock ? in lan8841_ts_info()
3749 ptp_clock_index(ptp_priv->ptp_clock) : -1; in lan8841_ts_info()
3750 if (info->phc_index == -1) in lan8841_ts_info()
3753 info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | in lan8841_ts_info()
3757 info->tx_types = (1 << HWTSTAMP_TX_OFF) | in lan8841_ts_info()
3761 info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) | in lan8841_ts_info()
3776 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_enable_processing()
3779 /* Enable interrupts on the TX side */ in lan8841_ptp_enable_processing()
3797 ptp_schedule_worker(ptp_priv->ptp_clock, 0); in lan8841_ptp_enable_processing()
3799 /* Disable interrupts on the TX side */ in lan8841_ptp_enable_processing()
3810 ptp_cancel_worker_sync(ptp_priv->ptp_clock); in lan8841_ptp_enable_processing()
3821 struct phy_device *phydev = ptp_priv->phydev; in lan8841_hwtstamp()
3826 if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) in lan8841_hwtstamp()
3827 return -EFAULT; in lan8841_hwtstamp()
3829 ptp_priv->hwts_tx_type = config.tx_type; in lan8841_hwtstamp()
3830 ptp_priv->rx_filter = config.rx_filter; in lan8841_hwtstamp()
3834 ptp_priv->layer = 0; in lan8841_hwtstamp()
3835 ptp_priv->version = 0; in lan8841_hwtstamp()
3840 ptp_priv->layer = PTP_CLASS_L4; in lan8841_hwtstamp()
3841 ptp_priv->version = PTP_CLASS_V2; in lan8841_hwtstamp()
3846 ptp_priv->layer = PTP_CLASS_L2; in lan8841_hwtstamp()
3847 ptp_priv->version = PTP_CLASS_V2; in lan8841_hwtstamp()
3852 ptp_priv->layer = PTP_CLASS_L4 | PTP_CLASS_L2; in lan8841_hwtstamp()
3853 ptp_priv->version = PTP_CLASS_V2; in lan8841_hwtstamp()
3856 return -ERANGE; in lan8841_hwtstamp()
3862 if (ptp_priv->layer & PTP_CLASS_L2) { in lan8841_hwtstamp()
3865 } else if (ptp_priv->layer & PTP_CLASS_L4) { in lan8841_hwtstamp()
3878 /* Enable / disable of the TX timestamp in the SYNC frames */ in lan8841_hwtstamp()
3881 ptp_priv->hwts_tx_type == HWTSTAMP_TX_ONESTEP_SYNC ? in lan8841_hwtstamp()
3888 skb_queue_purge(&ptp_priv->tx_queue); in lan8841_hwtstamp()
3892 return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? -EFAULT : 0; in lan8841_hwtstamp()
3909 if (ptp_priv->rx_filter == HWTSTAMP_FILTER_NONE || in lan8841_rxtstamp()
3913 if ((type & ptp_priv->version) == 0 || (type & ptp_priv->layer) == 0) in lan8841_rxtstamp()
3916 spin_lock_irqsave(&ptp_priv->seconds_lock, flags); in lan8841_rxtstamp()
3917 ts.tv_sec = ptp_priv->seconds; in lan8841_rxtstamp()
3918 spin_unlock_irqrestore(&ptp_priv->seconds_lock, flags); in lan8841_rxtstamp()
3919 ts_header = __be32_to_cpu(header->reserved2); in lan8841_rxtstamp()
3926 ts.tv_sec -= GENMASK(1, 0) + 1; in lan8841_rxtstamp()
3930 shhwtstamps->hwtstamp = in lan8841_rxtstamp()
3933 header->reserved2 = 0; in lan8841_rxtstamp()
3950 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_set_target()
3978 ts->tv_sec + LAN8841_BUFFER_TIME, 0); in lan8841_ptp_update_target()
3989 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_set_reload()
4023 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_settime64()
4028 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_settime64()
4029 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_SEC_LO, lower_16_bits(ts->tv_sec)); in lan8841_ptp_settime64()
4030 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_SEC_MID, upper_16_bits(ts->tv_sec)); in lan8841_ptp_settime64()
4031 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_SEC_HI, upper_32_bits(ts->tv_sec) & 0xffff); in lan8841_ptp_settime64()
4032 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_NS_LO, lower_16_bits(ts->tv_nsec)); in lan8841_ptp_settime64()
4033 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_NS_HI, upper_16_bits(ts->tv_nsec) & 0x3fff); in lan8841_ptp_settime64()
4039 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_settime64()
4041 spin_lock_irqsave(&ptp_priv->seconds_lock, flags); in lan8841_ptp_settime64()
4042 ptp_priv->seconds = ts->tv_sec; in lan8841_ptp_settime64()
4043 spin_unlock_irqrestore(&ptp_priv->seconds_lock, flags); in lan8841_ptp_settime64()
4060 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_gettime64()
4064 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_gettime64()
4079 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_gettime64()
4090 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_getseconds()
4093 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_getseconds()
4104 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_getseconds()
4119 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_adjtime()
4132 if (delta > 10000000000LL || delta < -10000000000LL) { in lan8841_ptp_adjtime()
4136 ptp->gettime64(ptp, &ts); in lan8841_ptp_adjtime()
4141 ptp->settime64(ptp, &ts); in lan8841_ptp_adjtime()
4145 sec = div_u64_rem(delta < 0 ? -delta : delta, NSEC_PER_SEC, &nsec); in lan8841_ptp_adjtime()
4151 sec--; in lan8841_ptp_adjtime()
4152 nsec = NSEC_PER_SEC - nsec; in lan8841_ptp_adjtime()
4166 nsec -= NSEC_PER_SEC; in lan8841_ptp_adjtime()
4169 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_adjtime()
4186 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_adjtime()
4189 ptp->gettime64(ptp, &ts); in lan8841_ptp_adjtime()
4190 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_adjtime()
4192 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_adjtime()
4205 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_adjfine()
4213 scaled_ppm = -scaled_ppm; in lan8841_ptp_adjfine()
4220 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_adjfine()
4225 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_adjfine()
4239 return -1; in lan8841_ptp_verify()
4252 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_perout_off()
4268 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_perout_on()
4298 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_remove_event()
4303 * pins 0-4 while GPIO_DATA_SEL2 contains GPIO pins 5-9, therefore in lan8841_ptp_remove_event()
4310 tmp = LAN8841_GPIO_DATA_SEL_GPIO_DATA_SEL_EVENT_MASK << (3 * (pin - 5)); in lan8841_ptp_remove_event()
4329 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_enable_event()
4350 * pins 0-4 while GPIO_DATA_SEL2 contains GPIO pins 5-9, therefore in lan8841_ptp_enable_event()
4363 tmp << (3 * (pin - 5))); in lan8841_ptp_enable_event()
4388 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_perout()
4395 if (rq->perout.flags & ~PTP_PEROUT_DUTY_CYCLE) in lan8841_ptp_perout()
4396 return -EOPNOTSUPP; in lan8841_ptp_perout()
4398 pin = ptp_find_pin(ptp_priv->ptp_clock, PTP_PF_PEROUT, rq->perout.index); in lan8841_ptp_perout()
4399 if (pin == -1 || pin >= LAN8841_PTP_GPIO_NUM) in lan8841_ptp_perout()
4400 return -EINVAL; in lan8841_ptp_perout()
4410 ts_on.tv_sec = rq->perout.on.sec; in lan8841_ptp_perout()
4411 ts_on.tv_nsec = rq->perout.on.nsec; in lan8841_ptp_perout()
4414 ts_period.tv_sec = rq->perout.period.sec; in lan8841_ptp_perout()
4415 ts_period.tv_nsec = rq->perout.period.nsec; in lan8841_ptp_perout()
4421 return -EOPNOTSUPP; in lan8841_ptp_perout()
4427 return -EINVAL; in lan8841_ptp_perout()
4480 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_perout()
4481 ret = lan8841_ptp_set_target(ptp_priv, LAN8841_EVENT_A, rq->perout.start.sec, in lan8841_ptp_perout()
4482 rq->perout.start.nsec); in lan8841_ptp_perout()
4483 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_perout()
4487 ret = lan8841_ptp_set_reload(ptp_priv, LAN8841_EVENT_A, rq->perout.period.sec, in lan8841_ptp_perout()
4488 rq->perout.period.nsec); in lan8841_ptp_perout()
4512 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_extts_on()
4542 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_extts_off()
4577 if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | in lan8841_ptp_extts()
4580 return -EOPNOTSUPP; in lan8841_ptp_extts()
4582 pin = ptp_find_pin(ptp_priv->ptp_clock, PTP_PF_EXTTS, rq->extts.index); in lan8841_ptp_extts()
4583 if (pin == -1 || pin >= LAN8841_PTP_GPIO_NUM) in lan8841_ptp_extts()
4584 return -EINVAL; in lan8841_ptp_extts()
4586 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_extts()
4588 ret = lan8841_ptp_extts_on(ptp_priv, pin, rq->extts.flags); in lan8841_ptp_extts()
4591 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_extts()
4599 switch (rq->type) { in lan8841_ptp_enable()
4605 return -EOPNOTSUPP; in lan8841_ptp_enable()
4618 lan8841_ptp_getseconds(&ptp_priv->ptp_clock_info, &ts); in lan8841_ptp_do_aux_work()
4620 spin_lock_irqsave(&ptp_priv->seconds_lock, flags); in lan8841_ptp_do_aux_work()
4621 ptp_priv->seconds = ts.tv_sec; in lan8841_ptp_do_aux_work()
4622 spin_unlock_irqrestore(&ptp_priv->seconds_lock, flags); in lan8841_ptp_do_aux_work()
4659 phydev->interface = PHY_INTERFACE_MODE_RGMII_RXID; in lan8841_probe()
4665 priv = phydev->priv; in lan8841_probe()
4666 ptp_priv = &priv->ptp_priv; in lan8841_probe()
4668 ptp_priv->pin_config = devm_kcalloc(&phydev->mdio.dev, in lan8841_probe()
4670 sizeof(*ptp_priv->pin_config), in lan8841_probe()
4672 if (!ptp_priv->pin_config) in lan8841_probe()
4673 return -ENOMEM; in lan8841_probe()
4676 struct ptp_pin_desc *p = &ptp_priv->pin_config[i]; in lan8841_probe()
4678 snprintf(p->name, sizeof(p->name), "pin%d", i); in lan8841_probe()
4679 p->index = i; in lan8841_probe()
4680 p->func = PTP_PF_NONE; in lan8841_probe()
4683 ptp_priv->ptp_clock_info = lan8841_ptp_clock_info; in lan8841_probe()
4684 ptp_priv->ptp_clock_info.pin_config = ptp_priv->pin_config; in lan8841_probe()
4685 ptp_priv->ptp_clock = ptp_clock_register(&ptp_priv->ptp_clock_info, in lan8841_probe()
4686 &phydev->mdio.dev); in lan8841_probe()
4687 if (IS_ERR(ptp_priv->ptp_clock)) { in lan8841_probe()
4689 PTR_ERR(ptp_priv->ptp_clock)); in lan8841_probe()
4690 return -EINVAL; in lan8841_probe()
4693 if (!ptp_priv->ptp_clock) in lan8841_probe()
4697 skb_queue_head_init(&ptp_priv->tx_queue); in lan8841_probe()
4698 ptp_priv->phydev = phydev; in lan8841_probe()
4699 mutex_init(&ptp_priv->ptp_lock); in lan8841_probe()
4700 spin_lock_init(&ptp_priv->seconds_lock); in lan8841_probe()
4702 ptp_priv->mii_ts.rxtstamp = lan8841_rxtstamp; in lan8841_probe()
4703 ptp_priv->mii_ts.txtstamp = lan8814_txtstamp; in lan8841_probe()
4704 ptp_priv->mii_ts.hwtstamp = lan8841_hwtstamp; in lan8841_probe()
4705 ptp_priv->mii_ts.ts_info = lan8841_ts_info; in lan8841_probe()
4707 phydev->mii_ts = &ptp_priv->mii_ts; in lan8841_probe()
4714 struct kszphy_priv *priv = phydev->priv; in lan8841_suspend()
4715 struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; in lan8841_suspend()
4717 if (ptp_priv->ptp_clock) in lan8841_suspend()
4718 ptp_cancel_worker_sync(ptp_priv->ptp_clock); in lan8841_suspend()