• Home
  • Raw
  • Download

Lines Matching +full:shared +full:- +full:pin

1 // SPDX-License-Identifier: GPL-2.0+
9 * Copyright (c) 2010-2013 Micrel, Inc.
119 * The value is calculated as following: (1/1000000)/((2^-32)/4)
287 /* Shared structure between the PHYs of the same package. */
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()
438 /* set the interrupt pin active low */ 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()
679 * based on the RXER (KSZ8081RNA/RND) or TXC (KSZ8081MNX/RNB) pin. If a 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()
791 int val1 = -1; in ksz9021_load_values_from_of()
792 int val2 = -2; in ksz9021_load_values_from_of()
793 int val3 = -3; in ksz9021_load_values_from_of()
794 int val4 = -4; in ksz9021_load_values_from_of()
818 if (val1 != -1) in ksz9021_load_values_from_of()
821 if (val2 != -2) in ksz9021_load_values_from_of()
824 if (val3 != -3) in ksz9021_load_values_from_of()
827 if (val4 != -4) in ksz9021_load_values_from_of()
842 dev_walker = &phydev->mdio.dev; in ksz9021_config_init()
844 of_node = dev_walker->of_node; in ksz9021_config_init()
845 dev_walker = dev_walker->parent; in ksz9021_config_init()
852 "txen-skew-ps", "txc-skew-ps", in ksz9021_config_init()
853 "rxdv-skew-ps", "rxc-skew-ps"); in ksz9021_config_init()
856 "rxd0-skew-ps", "rxd1-skew-ps", in ksz9021_config_init()
857 "rxd2-skew-ps", "rxd3-skew-ps"); in ksz9021_config_init()
860 "txd0-skew-ps", "txd1-skew-ps", in ksz9021_config_init()
861 "txd2-skew-ps", "txd3-skew-ps"); in ksz9021_config_init()
904 /* set rx to +0.30ns and rx_clk to -0.90ns to compensate the
910 /* set tx to -0.42ns and tx_clk to +0.96ns to get 1.38ns delay */
930 int val[4] = {-1, -2, -3, -4}; in ksz9031_of_load_skew_values()
953 if (val[i] != -(i + 1)) { in ksz9031_of_load_skew_values()
982 /* Enable energy-detect power-down mode */
999 switch (phydev->interface) { in ksz9031_config_rgmii_delay()
1058 static const char *clk_skews[2] = {"rxc-skew-ps", "txc-skew-ps"}; in ksz9031_config_init()
1060 "rxd0-skew-ps", "rxd1-skew-ps", in ksz9031_config_init()
1061 "rxd2-skew-ps", "rxd3-skew-ps" in ksz9031_config_init()
1064 "txd0-skew-ps", "txd1-skew-ps", in ksz9031_config_init()
1065 "txd2-skew-ps", "txd3-skew-ps" in ksz9031_config_init()
1067 static const char *control_skews[2] = {"txen-skew-ps", "rxdv-skew-ps"}; in ksz9031_config_init()
1079 dev_walker = &phydev->mdio.dev; in ksz9031_config_init()
1081 of_node = dev_walker->of_node; in ksz9031_config_init()
1082 dev_walker = dev_walker->parent; in ksz9031_config_init()
1112 "*-skew-ps values should be used only with RGMII PHY modes\n"); in ksz9031_config_init()
1115 * When the device links in the 1000BASE-T slave mode only, in ksz9031_config_init()
1129 if (of_property_read_bool(of_node, "micrel,force-master")) { in ksz9031_config_init()
1159 int val[4] = {-(1 + KSZ9131_OFFSET), -(2 + KSZ9131_OFFSET), in ksz9131_of_load_skew_values()
1160 -(3 + KSZ9131_OFFSET), -(4 + KSZ9131_OFFSET)}; in ksz9131_of_load_skew_values()
1176 if (skewval < -KSZ9131_OFFSET) in ksz9131_of_load_skew_values()
1177 skewval = -KSZ9131_OFFSET; in ksz9131_of_load_skew_values()
1195 if (val[i] != -(i + 1 + KSZ9131_OFFSET)) { in ksz9131_of_load_skew_values()
1213 const struct kszphy_type *type = phydev->drv->driver_data; in ksz9131_config_rgmii_delay()
1217 switch (phydev->interface) { in ksz9131_config_rgmii_delay()
1219 rxcdll_val = type->disable_dll_rx_bit; in ksz9131_config_rgmii_delay()
1220 txcdll_val = type->disable_dll_tx_bit; in ksz9131_config_rgmii_delay()
1228 txcdll_val = type->disable_dll_tx_bit; in ksz9131_config_rgmii_delay()
1231 rxcdll_val = type->disable_dll_rx_bit; in ksz9131_config_rgmii_delay()
1239 KSZ9131RN_RXC_DLL_CTRL, type->disable_dll_mask, in ksz9131_config_rgmii_delay()
1245 KSZ9131RN_TXC_DLL_CTRL, type->disable_dll_mask, in ksz9131_config_rgmii_delay()
1251 * When LEDs are configured in Individual Mode, LED1 is ON in a no-link
1272 char *clk_skews[2] = {"rxc-skew-psec", "txc-skew-psec"}; in ksz9131_config_init()
1274 "rxd0-skew-psec", "rxd1-skew-psec", in ksz9131_config_init()
1275 "rxd2-skew-psec", "rxd3-skew-psec" in ksz9131_config_init()
1278 "txd0-skew-psec", "txd1-skew-psec", in ksz9131_config_init()
1279 "txd2-skew-psec", "txd3-skew-psec" in ksz9131_config_init()
1281 char *control_skews[2] = {"txen-skew-psec", "rxdv-skew-psec"}; in ksz9131_config_init()
1285 dev_walker = &phydev->mdio.dev; in ksz9131_config_init()
1287 of_node = dev_walker->of_node; in ksz9131_config_init()
1288 dev_walker = dev_walker->parent; in ksz9131_config_init()
1345 phydev->mdix_ctrl = ETH_TP_MDI; in ksz9131_mdix_update()
1347 phydev->mdix_ctrl = ETH_TP_MDI_X; in ksz9131_mdix_update()
1349 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in ksz9131_mdix_update()
1353 phydev->mdix = ETH_TP_MDI; in ksz9131_mdix_update()
1355 phydev->mdix = ETH_TP_MDI_X; in ksz9131_mdix_update()
1399 ret = ksz9131_config_mdix(phydev, phydev->mdix_ctrl); in ksz9131_config_aneg()
1420 linkmode_and(phydev->supported_eee, phydev->supported, in ksz9477_get_features()
1439 phydev->duplex = DUPLEX_HALF; in ksz8873mll_read_status()
1441 phydev->duplex = DUPLEX_FULL; in ksz8873mll_read_status()
1444 phydev->speed = SPEED_10; in ksz8873mll_read_status()
1446 phydev->speed = SPEED_100; in ksz8873mll_read_status()
1448 phydev->link = 1; in ksz8873mll_read_status()
1449 phydev->pause = phydev->asym_pause = 0; in ksz8873mll_read_status()
1464 * link-up may fail after a link-up to link-down transition. in ksz9031_get_features()
1471 linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydev->supported); in ksz9031_get_features()
1476 linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported); in ksz9031_get_features()
1496 phydev->link = 0; in ksz9031_read_status()
1497 if (phydev->drv->config_intr && phy_interrupt_is_valid(phydev)) in ksz9031_read_status()
1498 phydev->drv->config_intr(phydev); in ksz9031_read_status()
1507 struct kszphy_priv *priv = phydev->priv; in ksz9x31_cable_test_start()
1510 /* KSZ9131RNX, DS00002841B-page 38, 4.14 LinkMD (R) Cable Diagnostic in ksz9x31_cable_test_start()
1511 * Prior to running the cable diagnostics, Auto-negotiation should in ksz9x31_cable_test_start()
1522 /* KSZ9131RNX, DS00002841B-page 38, 4.14 LinkMD (R) Cable Diagnostic in ksz9x31_cable_test_start()
1523 * The Master-Slave configuration should be set to Slave by writing in ksz9x31_cable_test_start()
1524 * a value of 0x1000 to the Auto-Negotiation Master Slave Control in ksz9x31_cable_test_start()
1532 priv->vct_ctrl1000 = ret & (CTL1000_ENABLE_MASTER | CTL1000_AS_MASTER); in ksz9x31_cable_test_start()
1577 /* KSZ9131RNX, DS00002841B-page 38, 4.14 LinkMD (R) Cable Diagnostic in ksz9x31_cable_test_fault_length()
1579 * distance to fault = (VCT_DATA - 22) * 4 / cable propagation velocity in ksz9x31_cable_test_fault_length()
1582 dt = clamp(dt - 22, 0, 255); in ksz9x31_cable_test_fault_length()
1614 /* KSZ9131RNX, DS00002841B-page 38, 4.14 LinkMD (R) Cable Diagnostic in ksz9x31_cable_test_one_pair()
1635 return -EAGAIN; in ksz9x31_cable_test_one_pair()
1654 struct kszphy_priv *priv = phydev->priv; in ksz9x31_cable_test_get_status()
1662 while (pair_mask && retries--) { in ksz9x31_cable_test_get_status()
1665 if (ret == -EAGAIN) in ksz9x31_cable_test_get_status()
1691 priv->vct_ctrl1000); in ksz9x31_cable_test_get_status()
1713 * counter intuitive, the "-X" in "1 = Force MDI" in the data in ksz886x_config_mdix()
1715 * 1 = Force MDI (sic!) (transmit on RX+/RX- pins) in ksz886x_config_mdix()
1716 * 0 = Normal operation (transmit on TX+/TX- pins) in ksz886x_config_mdix()
1741 /* The MDI-X configuration is automatically changed by the PHY after in ksz886x_config_aneg()
1742 * switching from autoneg off to on. So, take MDI-X configuration under in ksz886x_config_aneg()
1745 return ksz886x_config_mdix(phydev, phydev->mdix_ctrl); in ksz886x_config_aneg()
1758 phydev->mdix_ctrl = ETH_TP_MDI_X; in ksz886x_mdix_update()
1760 phydev->mdix_ctrl = ETH_TP_MDI; in ksz886x_mdix_update()
1762 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in ksz886x_mdix_update()
1771 phydev->mdix = ETH_TP_MDI_X; in ksz886x_mdix_update()
1773 phydev->mdix = ETH_TP_MDI; in ksz886x_mdix_update()
1805 /* Transmit waveform amplitude can be improved (1000BASE-T, 100BASE-TX, 10BASE-Te) */
1834 * necessary to set the PHY to 100 Mbps speed with auto-negotiation in ksz9477_config_init()
1835 * disabled by writing to register 0xN100-0xN101. After writing the in ksz9477_config_init()
1837 * register settings, write register 0xN100-0xN101 again to enable in ksz9477_config_init()
1838 * and restart auto-negotiation. in ksz9477_config_init()
1847 err = phy_write_mmd(phydev, errata->dev_addr, errata->reg_addr, errata->val); in ksz9477_config_init()
1855 if (phydev->dev_flags & MICREL_NO_EEE) in ksz9477_config_init()
1856 phydev->eee_broken_modes = -1; in ksz9477_config_init()
1883 struct kszphy_priv *priv = phydev->priv; in kszphy_get_stat()
1891 val = val & ((1 << stat.bits) - 1); in kszphy_get_stat()
1892 priv->stats[i] += val; in kszphy_get_stat()
1893 ret = priv->stats[i]; in kszphy_get_stat()
1912 phydev->interrupts = PHY_INTERRUPT_DISABLED; in kszphy_suspend()
1913 if (phydev->drv->config_intr) in kszphy_suspend()
1914 phydev->drv->config_intr(phydev); in kszphy_suspend()
1922 const struct kszphy_type *type = phydev->drv->driver_data; in kszphy_parse_led_mode()
1923 const struct device_node *np = phydev->mdio.dev.of_node; in kszphy_parse_led_mode()
1924 struct kszphy_priv *priv = phydev->priv; in kszphy_parse_led_mode()
1927 if (type && type->led_mode_reg) { in kszphy_parse_led_mode()
1928 ret = of_property_read_u32(np, "micrel,led-mode", in kszphy_parse_led_mode()
1929 &priv->led_mode); in kszphy_parse_led_mode()
1932 priv->led_mode = -1; in kszphy_parse_led_mode()
1934 if (priv->led_mode > 3) { in kszphy_parse_led_mode()
1936 priv->led_mode); in kszphy_parse_led_mode()
1937 priv->led_mode = -1; in kszphy_parse_led_mode()
1940 priv->led_mode = -1; in kszphy_parse_led_mode()
1950 /* After switching from power-down to normal mode, an internal global in kszphy_resume()
1962 phydev->interrupts = PHY_INTERRUPT_ENABLED; in kszphy_resume()
1963 if (phydev->drv->config_intr) in kszphy_resume()
1964 phydev->drv->config_intr(phydev); in kszphy_resume()
1972 const struct kszphy_type *type = phydev->drv->driver_data; in kszphy_probe()
1973 const struct device_node *np = phydev->mdio.dev.of_node; in kszphy_probe()
1977 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in kszphy_probe()
1979 return -ENOMEM; in kszphy_probe()
1981 phydev->priv = priv; in kszphy_probe()
1983 priv->type = type; in kszphy_probe()
1987 clk = devm_clk_get(&phydev->mdio.dev, "rmii-ref"); in kszphy_probe()
1994 priv->rmii_ref_clk_sel = type->has_rmii_ref_clk_sel; in kszphy_probe()
1996 "micrel,rmii-reference-clock-select-25-mhz"); in kszphy_probe()
1999 priv->rmii_ref_clk_sel_val = rmii_ref_clk_sel_25_mhz; in kszphy_probe()
2001 priv->rmii_ref_clk_sel_val = !rmii_ref_clk_sel_25_mhz; in kszphy_probe()
2005 return -EINVAL; in kszphy_probe()
2010 phydev->port = PORT_FIBRE; in kszphy_probe()
2012 /* Support legacy board-file configuration */ in kszphy_probe()
2013 if (phydev->dev_flags & MICREL_PHY_50MHZ_CLK) { in kszphy_probe()
2014 priv->rmii_ref_clk_sel = true; in kszphy_probe()
2015 priv->rmii_ref_clk_sel_val = true; in kszphy_probe()
2025 * confuse the internal state machine - disable auto neg here. in lan8814_cable_test_start()
2034 if (phydev->dev_flags & MICREL_KSZ8_P1_ERRATA) in ksz886x_cable_test_start()
2035 return -EOPNOTSUPP; in ksz886x_cable_test_start()
2039 * confuse the internal state machine - disable auto neg here. in ksz886x_cable_test_start()
2085 * (DELTA_TIME - 22) * 0.8 for lan8814 phy. in ksz886x_cable_test_fault_length()
2090 return ((dt - 22) * 800) / 10; in ksz886x_cable_test_fault_length()
2097 const struct kszphy_type *type = phydev->drv->driver_data; in ksz886x_cable_test_wait_for_completion()
2100 ret = phy_read_poll_timeout(phydev, type->cable_diag_reg, val, in ksz886x_cable_test_wait_for_completion()
2134 return -EAGAIN; in lan8814_cable_test_one_pair()
2162 * We can workaround this limitation by using the MDI-X functionality. in ksz886x_cable_test_one_pair()
2169 switch (phydev->phy_id & MICREL_PHY_ID_MASK) { in ksz886x_cable_test_one_pair()
2177 ret = -ENODEV; in ksz886x_cable_test_one_pair()
2199 return -EAGAIN; in ksz886x_cable_test_one_pair()
2217 const struct kszphy_type *type = phydev->drv->driver_data; in ksz886x_cable_test_get_status()
2218 unsigned long pair_mask = type->pair_mask; in ksz886x_cable_test_get_status()
2226 while (pair_mask && retries--) { in ksz886x_cable_test_get_status()
2228 if (type->cable_diag_reg == LAN8814_CABLE_DIAG) in ksz886x_cable_test_get_status()
2232 if (ret == -EAGAIN) in ksz886x_cable_test_get_status()
2345 struct phy_device *phydev = ptp_priv->phydev; in lan8814_ts_info()
2346 struct lan8814_shared_priv *shared = phydev->shared->priv; in lan8814_ts_info() local
2348 info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | in lan8814_ts_info()
2352 info->phc_index = ptp_clock_index(shared->ptp_clock); in lan8814_ts_info()
2354 info->tx_types = in lan8814_ts_info()
2359 info->rx_filters = in lan8814_ts_info()
2385 struct phy_device *phydev = ptp_priv->phydev; in lan8814_hwtstamp()
2386 struct lan8814_shared_priv *shared = phydev->shared->priv; in lan8814_hwtstamp() local
2392 if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) in lan8814_hwtstamp()
2393 return -EFAULT; in lan8814_hwtstamp()
2395 ptp_priv->hwts_tx_type = config.tx_type; in lan8814_hwtstamp()
2396 ptp_priv->rx_filter = config.rx_filter; in lan8814_hwtstamp()
2400 ptp_priv->layer = 0; in lan8814_hwtstamp()
2401 ptp_priv->version = 0; in lan8814_hwtstamp()
2406 ptp_priv->layer = PTP_CLASS_L4; in lan8814_hwtstamp()
2407 ptp_priv->version = PTP_CLASS_V2; in lan8814_hwtstamp()
2412 ptp_priv->layer = PTP_CLASS_L2; in lan8814_hwtstamp()
2413 ptp_priv->version = PTP_CLASS_V2; in lan8814_hwtstamp()
2418 ptp_priv->layer = PTP_CLASS_L4 | PTP_CLASS_L2; in lan8814_hwtstamp()
2419 ptp_priv->version = PTP_CLASS_V2; in lan8814_hwtstamp()
2422 return -ERANGE; in lan8814_hwtstamp()
2425 if (ptp_priv->layer & PTP_CLASS_L2) { in lan8814_hwtstamp()
2428 } else if (ptp_priv->layer & PTP_CLASS_L4) { in lan8814_hwtstamp()
2432 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_RX_PARSE_CONFIG, rxcfg); in lan8814_hwtstamp()
2433 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_PARSE_CONFIG, txcfg); in lan8814_hwtstamp()
2437 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_RX_TIMESTAMP_EN, pkt_ts_enable); in lan8814_hwtstamp()
2438 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_TIMESTAMP_EN, pkt_ts_enable); in lan8814_hwtstamp()
2440 if (ptp_priv->hwts_tx_type == HWTSTAMP_TX_ONESTEP_SYNC) in lan8814_hwtstamp()
2441 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_MOD, in lan8814_hwtstamp()
2445 lan8814_config_ts_intr(ptp_priv->phydev, true); in lan8814_hwtstamp()
2447 lan8814_config_ts_intr(ptp_priv->phydev, false); in lan8814_hwtstamp()
2449 mutex_lock(&shared->shared_lock); in lan8814_hwtstamp()
2451 shared->ref++; in lan8814_hwtstamp()
2453 shared->ref--; in lan8814_hwtstamp()
2455 if (shared->ref) in lan8814_hwtstamp()
2456 lanphy_write_page_reg(ptp_priv->phydev, 4, PTP_CMD_CTL, in lan8814_hwtstamp()
2459 lanphy_write_page_reg(ptp_priv->phydev, 4, PTP_CMD_CTL, in lan8814_hwtstamp()
2461 mutex_unlock(&shared->shared_lock); in lan8814_hwtstamp()
2464 list_for_each_entry_safe(rx_ts, tmp, &ptp_priv->rx_ts_list, list) { in lan8814_hwtstamp()
2465 list_del(&rx_ts->list); in lan8814_hwtstamp()
2468 skb_queue_purge(&ptp_priv->rx_queue); in lan8814_hwtstamp()
2469 skb_queue_purge(&ptp_priv->tx_queue); in lan8814_hwtstamp()
2471 lan8814_flush_fifo(ptp_priv->phydev, false); in lan8814_hwtstamp()
2472 lan8814_flush_fifo(ptp_priv->phydev, true); in lan8814_hwtstamp()
2474 return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? -EFAULT : 0; in lan8814_hwtstamp()
2482 switch (ptp_priv->hwts_tx_type) { in lan8814_txtstamp()
2490 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in lan8814_txtstamp()
2491 skb_queue_tail(&ptp_priv->tx_queue, skb); in lan8814_txtstamp()
2510 *sig = (__force u16)(ntohs(ptp_header->sequence_id)); in lan8814_get_sig_rx()
2525 spin_lock_irqsave(&ptp_priv->rx_ts_lock, flags); in lan8814_match_rx_skb()
2526 list_for_each_entry_safe(rx_ts, tmp, &ptp_priv->rx_ts_list, list) { in lan8814_match_rx_skb()
2528 if (memcmp(&skb_sig, &rx_ts->seq_id, sizeof(rx_ts->seq_id))) in lan8814_match_rx_skb()
2533 shhwtstamps->hwtstamp = ktime_set(rx_ts->seconds, in lan8814_match_rx_skb()
2534 rx_ts->nsec); in lan8814_match_rx_skb()
2535 list_del(&rx_ts->list); in lan8814_match_rx_skb()
2541 spin_unlock_irqrestore(&ptp_priv->rx_ts_lock, flags); in lan8814_match_rx_skb()
2553 if (ptp_priv->rx_filter == HWTSTAMP_FILTER_NONE || in lan8814_rxtstamp()
2557 if ((type & ptp_priv->version) == 0 || (type & ptp_priv->layer) == 0) in lan8814_rxtstamp()
2564 skb_queue_tail(&ptp_priv->rx_queue, skb); in lan8814_rxtstamp()
2604 struct lan8814_shared_priv *shared = container_of(ptpci, struct lan8814_shared_priv, in lan8814_ptpci_gettime64() local
2606 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_gettime64()
2610 mutex_lock(&shared->shared_lock); in lan8814_ptpci_gettime64()
2612 mutex_unlock(&shared->shared_lock); in lan8814_ptpci_gettime64()
2613 ts->tv_sec = seconds; in lan8814_ptpci_gettime64()
2614 ts->tv_nsec = nano_seconds; in lan8814_ptpci_gettime64()
2622 struct lan8814_shared_priv *shared = container_of(ptpci, struct lan8814_shared_priv, in lan8814_ptpci_settime64() local
2624 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_settime64()
2626 mutex_lock(&shared->shared_lock); in lan8814_ptpci_settime64()
2627 lan8814_ptp_clock_set(phydev, ts->tv_sec, ts->tv_nsec); in lan8814_ptpci_settime64()
2628 mutex_unlock(&shared->shared_lock); in lan8814_ptpci_settime64()
2651 nano_seconds -= 1000000000; in lan8814_ptp_clock_step()
2655 } else if (time_step_ns < -15000000000LL) { in lan8814_ptp_clock_step()
2657 time_step_ns = -time_step_ns; in lan8814_ptp_clock_step()
2660 unsigned_seconds -= div_u64_rem(time_step_ns, 1000000000LL, in lan8814_ptp_clock_step()
2664 unsigned_seconds--; in lan8814_ptp_clock_step()
2667 nano_seconds -= nano_seconds_step; in lan8814_ptp_clock_step()
2680 abs_time_step_ns = (u64)(-time_step_ns); in lan8814_ptp_clock_step()
2681 seconds = -((s32)div_u64_rem(abs_time_step_ns, 1000000000, in lan8814_ptp_clock_step()
2689 seconds--; in lan8814_ptp_clock_step()
2690 nano_seconds = (1000000000 - nano_seconds); in lan8814_ptp_clock_step()
2702 nano_seconds -= 1000000000; in lan8814_ptp_clock_step()
2721 seconds -= ((s32)adjustment_value); in lan8814_ptp_clock_step()
2723 u32 adjustment_value = (u32)(-seconds); in lan8814_ptp_clock_step()
2760 struct lan8814_shared_priv *shared = container_of(ptpci, struct lan8814_shared_priv, in lan8814_ptpci_adjtime() local
2762 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_adjtime()
2764 mutex_lock(&shared->shared_lock); in lan8814_ptpci_adjtime()
2766 mutex_unlock(&shared->shared_lock); in lan8814_ptpci_adjtime()
2773 struct lan8814_shared_priv *shared = container_of(ptpci, struct lan8814_shared_priv, in lan8814_ptpci_adjfine() local
2775 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_adjfine()
2781 scaled_ppm = -scaled_ppm; in lan8814_ptpci_adjfine()
2794 mutex_lock(&shared->shared_lock); in lan8814_ptpci_adjfine()
2797 mutex_unlock(&shared->shared_lock); in lan8814_ptpci_adjfine()
2810 *sig = (__force u16)(ntohs(ptp_header->sequence_id)); in lan8814_get_sig_tx()
2822 spin_lock_irqsave(&ptp_priv->tx_queue.lock, flags); in lan8814_match_tx_skb()
2823 skb_queue_walk_safe(&ptp_priv->tx_queue, skb, skb_tmp) { in lan8814_match_tx_skb()
2829 __skb_unlink(skb, &ptp_priv->tx_queue); in lan8814_match_tx_skb()
2833 spin_unlock_irqrestore(&ptp_priv->tx_queue.lock, flags); in lan8814_match_tx_skb()
2844 struct phy_device *phydev = ptp_priv->phydev; in lan8814_dequeue_tx_skb()
2854 struct phy_device *phydev = ptp_priv->phydev; in lan8814_get_tx_ts()
2876 spin_lock_irqsave(&ptp_priv->rx_queue.lock, flags); in lan8814_match_skb()
2877 skb_queue_walk_safe(&ptp_priv->rx_queue, skb, skb_tmp) { in lan8814_match_skb()
2880 if (memcmp(&skb_sig, &rx_ts->seq_id, sizeof(rx_ts->seq_id))) in lan8814_match_skb()
2883 __skb_unlink(skb, &ptp_priv->rx_queue); in lan8814_match_skb()
2888 spin_unlock_irqrestore(&ptp_priv->rx_queue.lock, flags); in lan8814_match_skb()
2893 shhwtstamps->hwtstamp = ktime_set(rx_ts->seconds, rx_ts->nsec); in lan8814_match_skb()
2909 spin_lock_irqsave(&ptp_priv->rx_ts_lock, flags); in lan8814_match_rx_ts()
2910 list_add(&rx_ts->list, &ptp_priv->rx_ts_list); in lan8814_match_rx_ts()
2911 spin_unlock_irqrestore(&ptp_priv->rx_ts_lock, flags); in lan8814_match_rx_ts()
2919 struct phy_device *phydev = ptp_priv->phydev; in lan8814_get_rx_ts()
2928 lan8814_ptp_rx_ts_get(phydev, &rx_ts->seconds, &rx_ts->nsec, in lan8814_get_rx_ts()
2929 &rx_ts->seq_id); in lan8814_get_rx_ts()
2941 struct kszphy_priv *priv = phydev->priv; in lan8814_handle_ptp_interrupt()
2942 struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; in lan8814_handle_ptp_interrupt()
2952 skb_queue_purge(&ptp_priv->tx_queue); in lan8814_handle_ptp_interrupt()
2957 skb_queue_purge(&ptp_priv->rx_queue); in lan8814_handle_ptp_interrupt()
2965 /* MDI-X setting for swap A,B transmit */ in lan8804_config_init()
3012 /* By default interrupt buffer is open-drain in which case the interrupt in lan8804_config_intr()
3014 * push-pull to be able to change interrupt polarity in lan8804_config_intr()
3019 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in lan8804_config_intr()
3087 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in lan8814_config_intr()
3106 struct kszphy_priv *priv = phydev->priv; in lan8814_ptp_init()
3107 struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; in lan8814_ptp_init()
3139 skb_queue_head_init(&ptp_priv->tx_queue); in lan8814_ptp_init()
3140 skb_queue_head_init(&ptp_priv->rx_queue); in lan8814_ptp_init()
3141 INIT_LIST_HEAD(&ptp_priv->rx_ts_list); in lan8814_ptp_init()
3142 spin_lock_init(&ptp_priv->rx_ts_lock); in lan8814_ptp_init()
3144 ptp_priv->phydev = phydev; in lan8814_ptp_init()
3146 ptp_priv->mii_ts.rxtstamp = lan8814_rxtstamp; in lan8814_ptp_init()
3147 ptp_priv->mii_ts.txtstamp = lan8814_txtstamp; in lan8814_ptp_init()
3148 ptp_priv->mii_ts.hwtstamp = lan8814_hwtstamp; in lan8814_ptp_init()
3149 ptp_priv->mii_ts.ts_info = lan8814_ts_info; in lan8814_ptp_init()
3151 phydev->mii_ts = &ptp_priv->mii_ts; in lan8814_ptp_init()
3156 struct lan8814_shared_priv *shared = phydev->shared->priv; in lan8814_ptp_probe_once() local
3158 /* Initialise shared lock for clock*/ in lan8814_ptp_probe_once()
3159 mutex_init(&shared->shared_lock); in lan8814_ptp_probe_once()
3161 shared->ptp_clock_info.owner = THIS_MODULE; in lan8814_ptp_probe_once()
3162 snprintf(shared->ptp_clock_info.name, 30, "%s", phydev->drv->name); in lan8814_ptp_probe_once()
3163 shared->ptp_clock_info.max_adj = 31249999; in lan8814_ptp_probe_once()
3164 shared->ptp_clock_info.n_alarm = 0; in lan8814_ptp_probe_once()
3165 shared->ptp_clock_info.n_ext_ts = 0; in lan8814_ptp_probe_once()
3166 shared->ptp_clock_info.n_pins = 0; in lan8814_ptp_probe_once()
3167 shared->ptp_clock_info.pps = 0; in lan8814_ptp_probe_once()
3168 shared->ptp_clock_info.pin_config = NULL; in lan8814_ptp_probe_once()
3169 shared->ptp_clock_info.adjfine = lan8814_ptpci_adjfine; in lan8814_ptp_probe_once()
3170 shared->ptp_clock_info.adjtime = lan8814_ptpci_adjtime; in lan8814_ptp_probe_once()
3171 shared->ptp_clock_info.gettime64 = lan8814_ptpci_gettime64; in lan8814_ptp_probe_once()
3172 shared->ptp_clock_info.settime64 = lan8814_ptpci_settime64; in lan8814_ptp_probe_once()
3173 shared->ptp_clock_info.getcrosststamp = NULL; in lan8814_ptp_probe_once()
3175 shared->ptp_clock = ptp_clock_register(&shared->ptp_clock_info, in lan8814_ptp_probe_once()
3176 &phydev->mdio.dev); in lan8814_ptp_probe_once()
3177 if (IS_ERR(shared->ptp_clock)) { in lan8814_ptp_probe_once()
3179 PTR_ERR(shared->ptp_clock)); in lan8814_ptp_probe_once()
3180 return -EINVAL; in lan8814_ptp_probe_once()
3184 if (!shared->ptp_clock) in lan8814_ptp_probe_once()
3189 shared->phydev = phydev; in lan8814_ptp_probe_once()
3191 /* The EP.4 is shared between all the PHYs in the package and also it in lan8814_ptp_probe_once()
3217 struct kszphy_priv *lan8814 = phydev->priv; in lan8814_config_init()
3230 /* MDI-X setting for swap A,B transmit */ in lan8814_config_init()
3236 if (lan8814->led_mode >= 0) in lan8814_config_init()
3237 lan8814_setup_led(phydev, lan8814->led_mode); in lan8814_config_init()
3243 * function called in suspend. Because the GPIO line can be shared, so if one of
3251 gpiod = devm_gpiod_get_optional(&phydev->mdio.dev, "coma-mode", in lan8814_release_coma_mode()
3265 const struct kszphy_type *type = phydev->drv->driver_data; in lan8814_probe()
3270 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in lan8814_probe()
3272 return -ENOMEM; in lan8814_probe()
3274 phydev->priv = priv; in lan8814_probe()
3276 priv->type = type; in lan8814_probe()
3280 /* Strap-in value for PHY address, below register read gives starting in lan8814_probe()
3284 devm_phy_package_join(&phydev->mdio.dev, phydev, in lan8814_probe()
3388 /* 10M/100M Ethernet Signal Tuning Errata for Shorted-Center Tap in lan8841_config_init()
3434 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in lan8841_config_intr()
3467 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_get_tx_ts()
3501 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_flush_fifo()
3524 struct phy_device *phydev = ptp_priv->phydev; in lan8841_gpio_process_cap()
3526 int pin, ret, tmp; in lan8841_gpio_process_cap() local
3529 pin = ptp_find_pin_unlocked(ptp_priv->ptp_clock, PTP_PF_EXTTS, 0); in lan8841_gpio_process_cap()
3530 if (pin == -1) in lan8841_gpio_process_cap()
3538 LAN8841_PTP_GPIO_SEL_GPIO_SEL(pin)); in lan8841_gpio_process_cap()
3542 mutex_lock(&ptp_priv->ptp_lock); in lan8841_gpio_process_cap()
3543 if (tmp & BIT(pin)) { in lan8841_gpio_process_cap()
3560 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_gpio_process_cap()
3568 ptp_clock_event(ptp_priv->ptp_clock, &ptp_event); in lan8841_gpio_process_cap()
3573 struct kszphy_priv *priv = phydev->priv; in lan8841_handle_ptp_interrupt()
3574 struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; in lan8841_handle_ptp_interrupt()
3588 skb_queue_purge(&ptp_priv->tx_queue); in lan8841_handle_ptp_interrupt()
3629 info->phc_index = ptp_priv->ptp_clock ? in lan8841_ts_info()
3630 ptp_clock_index(ptp_priv->ptp_clock) : -1; in lan8841_ts_info()
3631 if (info->phc_index == -1) in lan8841_ts_info()
3634 info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | in lan8841_ts_info()
3638 info->tx_types = (1 << HWTSTAMP_TX_OFF) | in lan8841_ts_info()
3642 info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) | in lan8841_ts_info()
3657 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_enable_processing()
3678 ptp_schedule_worker(ptp_priv->ptp_clock, 0); in lan8841_ptp_enable_processing()
3691 ptp_cancel_worker_sync(ptp_priv->ptp_clock); in lan8841_ptp_enable_processing()
3702 struct phy_device *phydev = ptp_priv->phydev; in lan8841_hwtstamp()
3707 if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) in lan8841_hwtstamp()
3708 return -EFAULT; in lan8841_hwtstamp()
3710 ptp_priv->hwts_tx_type = config.tx_type; in lan8841_hwtstamp()
3711 ptp_priv->rx_filter = config.rx_filter; in lan8841_hwtstamp()
3715 ptp_priv->layer = 0; in lan8841_hwtstamp()
3716 ptp_priv->version = 0; in lan8841_hwtstamp()
3721 ptp_priv->layer = PTP_CLASS_L4; in lan8841_hwtstamp()
3722 ptp_priv->version = PTP_CLASS_V2; in lan8841_hwtstamp()
3727 ptp_priv->layer = PTP_CLASS_L2; in lan8841_hwtstamp()
3728 ptp_priv->version = PTP_CLASS_V2; in lan8841_hwtstamp()
3733 ptp_priv->layer = PTP_CLASS_L4 | PTP_CLASS_L2; in lan8841_hwtstamp()
3734 ptp_priv->version = PTP_CLASS_V2; in lan8841_hwtstamp()
3737 return -ERANGE; in lan8841_hwtstamp()
3743 if (ptp_priv->layer & PTP_CLASS_L2) { in lan8841_hwtstamp()
3746 } else if (ptp_priv->layer & PTP_CLASS_L4) { in lan8841_hwtstamp()
3762 ptp_priv->hwts_tx_type == HWTSTAMP_TX_ONESTEP_SYNC ? in lan8841_hwtstamp()
3769 skb_queue_purge(&ptp_priv->tx_queue); in lan8841_hwtstamp()
3773 return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? -EFAULT : 0; in lan8841_hwtstamp()
3790 if (ptp_priv->rx_filter == HWTSTAMP_FILTER_NONE || in lan8841_rxtstamp()
3794 if ((type & ptp_priv->version) == 0 || (type & ptp_priv->layer) == 0) in lan8841_rxtstamp()
3797 spin_lock_irqsave(&ptp_priv->seconds_lock, flags); in lan8841_rxtstamp()
3798 ts.tv_sec = ptp_priv->seconds; in lan8841_rxtstamp()
3799 spin_unlock_irqrestore(&ptp_priv->seconds_lock, flags); in lan8841_rxtstamp()
3800 ts_header = __be32_to_cpu(header->reserved2); in lan8841_rxtstamp()
3807 ts.tv_sec -= GENMASK(1, 0) + 1; in lan8841_rxtstamp()
3811 shhwtstamps->hwtstamp = in lan8841_rxtstamp()
3814 header->reserved2 = 0; in lan8841_rxtstamp()
3831 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_set_target()
3859 ts->tv_sec + LAN8841_BUFFER_TIME, 0); in lan8841_ptp_update_target()
3870 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_set_reload()
3904 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_settime64()
3909 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_settime64()
3910 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_SEC_LO, lower_16_bits(ts->tv_sec)); in lan8841_ptp_settime64()
3911 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_SEC_MID, upper_16_bits(ts->tv_sec)); in lan8841_ptp_settime64()
3912 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_SEC_HI, upper_32_bits(ts->tv_sec) & 0xffff); in lan8841_ptp_settime64()
3913 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_NS_LO, lower_16_bits(ts->tv_nsec)); in lan8841_ptp_settime64()
3914 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_NS_HI, upper_16_bits(ts->tv_nsec) & 0x3fff); in lan8841_ptp_settime64()
3920 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_settime64()
3922 spin_lock_irqsave(&ptp_priv->seconds_lock, flags); in lan8841_ptp_settime64()
3923 ptp_priv->seconds = ts->tv_sec; in lan8841_ptp_settime64()
3924 spin_unlock_irqrestore(&ptp_priv->seconds_lock, flags); in lan8841_ptp_settime64()
3941 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_gettime64()
3945 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_gettime64()
3960 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_gettime64()
3971 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_getseconds()
3974 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_getseconds()
3985 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_getseconds()
4000 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_adjtime()
4013 if (delta > 10000000000LL || delta < -10000000000LL) { in lan8841_ptp_adjtime()
4017 ptp->gettime64(ptp, &ts); in lan8841_ptp_adjtime()
4022 ptp->settime64(ptp, &ts); in lan8841_ptp_adjtime()
4026 sec = div_u64_rem(delta < 0 ? -delta : delta, NSEC_PER_SEC, &nsec); in lan8841_ptp_adjtime()
4032 sec--; in lan8841_ptp_adjtime()
4033 nsec = NSEC_PER_SEC - nsec; in lan8841_ptp_adjtime()
4047 nsec -= NSEC_PER_SEC; in lan8841_ptp_adjtime()
4050 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_adjtime()
4067 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_adjtime()
4070 ptp->gettime64(ptp, &ts); in lan8841_ptp_adjtime()
4071 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_adjtime()
4073 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_adjtime()
4086 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_adjfine()
4094 scaled_ppm = -scaled_ppm; in lan8841_ptp_adjfine()
4101 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_adjfine()
4106 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_adjfine()
4111 static int lan8841_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin, in lan8841_ptp_verify() argument
4120 return -1; in lan8841_ptp_verify()
4131 static int lan8841_ptp_perout_off(struct kszphy_ptp_priv *ptp_priv, int pin) in lan8841_ptp_perout_off() argument
4133 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_perout_off()
4136 ret = phy_clear_bits_mmd(phydev, 2, LAN8841_GPIO_EN, BIT(pin)); in lan8841_ptp_perout_off()
4140 ret = phy_clear_bits_mmd(phydev, 2, LAN8841_GPIO_DIR, BIT(pin)); in lan8841_ptp_perout_off()
4144 return phy_clear_bits_mmd(phydev, 2, LAN8841_GPIO_BUF, BIT(pin)); in lan8841_ptp_perout_off()
4147 static int lan8841_ptp_perout_on(struct kszphy_ptp_priv *ptp_priv, int pin) in lan8841_ptp_perout_on() argument
4149 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_perout_on()
4152 ret = phy_set_bits_mmd(phydev, 2, LAN8841_GPIO_EN, BIT(pin)); in lan8841_ptp_perout_on()
4156 ret = phy_set_bits_mmd(phydev, 2, LAN8841_GPIO_DIR, BIT(pin)); in lan8841_ptp_perout_on()
4160 return phy_set_bits_mmd(phydev, 2, LAN8841_GPIO_BUF, BIT(pin)); in lan8841_ptp_perout_on()
4176 static int lan8841_ptp_remove_event(struct kszphy_ptp_priv *ptp_priv, int pin, in lan8841_ptp_remove_event() argument
4179 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_remove_event()
4183 /* Now remove pin from the event. GPIO_DATA_SEL1 contains the GPIO in lan8841_ptp_remove_event()
4184 * pins 0-4 while GPIO_DATA_SEL2 contains GPIO pins 5-9, therefore in lan8841_ptp_remove_event()
4185 * depending on the pin, it requires to read a different register in lan8841_ptp_remove_event()
4187 if (pin < 5) { in lan8841_ptp_remove_event()
4188 tmp = LAN8841_GPIO_DATA_SEL_GPIO_DATA_SEL_EVENT_MASK << (3 * pin); in lan8841_ptp_remove_event()
4191 tmp = LAN8841_GPIO_DATA_SEL_GPIO_DATA_SEL_EVENT_MASK << (3 * (pin - 5)); in lan8841_ptp_remove_event()
4207 static int lan8841_ptp_enable_event(struct kszphy_ptp_priv *ptp_priv, int pin, in lan8841_ptp_enable_event() argument
4210 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_enable_event()
4230 /* Now connect the pin to the event. GPIO_DATA_SEL1 contains the GPIO in lan8841_ptp_enable_event()
4231 * pins 0-4 while GPIO_DATA_SEL2 contains GPIO pins 5-9, therefore in lan8841_ptp_enable_event()
4232 * depending on the pin, it requires to read a different register in lan8841_ptp_enable_event()
4239 if (pin < 5) in lan8841_ptp_enable_event()
4241 tmp << (3 * pin)); in lan8841_ptp_enable_event()
4244 tmp << (3 * (pin - 5))); in lan8841_ptp_enable_event()
4269 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_perout()
4273 int pin; in lan8841_ptp_perout() local
4276 if (rq->perout.flags & ~PTP_PEROUT_DUTY_CYCLE) in lan8841_ptp_perout()
4277 return -EOPNOTSUPP; in lan8841_ptp_perout()
4279 pin = ptp_find_pin(ptp_priv->ptp_clock, PTP_PF_PEROUT, rq->perout.index); in lan8841_ptp_perout()
4280 if (pin == -1 || pin >= LAN8841_PTP_GPIO_NUM) in lan8841_ptp_perout()
4281 return -EINVAL; in lan8841_ptp_perout()
4284 ret = lan8841_ptp_perout_off(ptp_priv, pin); in lan8841_ptp_perout()
4288 return lan8841_ptp_remove_event(ptp_priv, LAN8841_EVENT_A, pin); in lan8841_ptp_perout()
4291 ts_on.tv_sec = rq->perout.on.sec; in lan8841_ptp_perout()
4292 ts_on.tv_nsec = rq->perout.on.nsec; in lan8841_ptp_perout()
4295 ts_period.tv_sec = rq->perout.period.sec; in lan8841_ptp_perout()
4296 ts_period.tv_nsec = rq->perout.period.nsec; in lan8841_ptp_perout()
4302 return -EOPNOTSUPP; in lan8841_ptp_perout()
4308 return -EINVAL; in lan8841_ptp_perout()
4361 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_perout()
4362 ret = lan8841_ptp_set_target(ptp_priv, LAN8841_EVENT_A, rq->perout.start.sec, in lan8841_ptp_perout()
4363 rq->perout.start.nsec); in lan8841_ptp_perout()
4364 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_perout()
4368 ret = lan8841_ptp_set_reload(ptp_priv, LAN8841_EVENT_A, rq->perout.period.sec, in lan8841_ptp_perout()
4369 rq->perout.period.nsec); in lan8841_ptp_perout()
4373 ret = lan8841_ptp_enable_event(ptp_priv, pin, LAN8841_EVENT_A, in lan8841_ptp_perout()
4378 ret = lan8841_ptp_perout_on(ptp_priv, pin); in lan8841_ptp_perout()
4380 lan8841_ptp_remove_event(ptp_priv, pin, LAN8841_EVENT_A); in lan8841_ptp_perout()
4390 static int lan8841_ptp_extts_on(struct kszphy_ptp_priv *ptp_priv, int pin, in lan8841_ptp_extts_on() argument
4393 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_extts_on()
4398 ret = phy_set_bits_mmd(phydev, 2, LAN8841_GPIO_EN, BIT(pin)); in lan8841_ptp_extts_on()
4402 ret = phy_clear_bits_mmd(phydev, 2, LAN8841_GPIO_BUF, BIT(pin)); in lan8841_ptp_extts_on()
4406 /* Enable capture on the edges of the pin */ in lan8841_ptp_extts_on()
4408 tmp |= LAN8841_PTP_GPIO_CAP_EN_GPIO_RE_CAPTURE_ENABLE(pin); in lan8841_ptp_extts_on()
4410 tmp |= LAN8841_PTP_GPIO_CAP_EN_GPIO_FE_CAPTURE_ENABLE(pin); in lan8841_ptp_extts_on()
4421 static int lan8841_ptp_extts_off(struct kszphy_ptp_priv *ptp_priv, int pin) in lan8841_ptp_extts_off() argument
4423 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_extts_off()
4427 ret = phy_clear_bits_mmd(phydev, 2, LAN8841_GPIO_EN, BIT(pin)); in lan8841_ptp_extts_off()
4431 ret = phy_clear_bits_mmd(phydev, 2, LAN8841_GPIO_BUF, BIT(pin)); in lan8841_ptp_extts_off()
4437 LAN8841_PTP_GPIO_CAP_EN_GPIO_RE_CAPTURE_ENABLE(pin) | in lan8841_ptp_extts_off()
4438 LAN8841_PTP_GPIO_CAP_EN_GPIO_FE_CAPTURE_ENABLE(pin), in lan8841_ptp_extts_off()
4454 int pin; in lan8841_ptp_extts() local
4458 if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | in lan8841_ptp_extts()
4461 return -EOPNOTSUPP; in lan8841_ptp_extts()
4463 pin = ptp_find_pin(ptp_priv->ptp_clock, PTP_PF_EXTTS, rq->extts.index); in lan8841_ptp_extts()
4464 if (pin == -1 || pin >= LAN8841_PTP_GPIO_NUM) in lan8841_ptp_extts()
4465 return -EINVAL; in lan8841_ptp_extts()
4467 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_extts()
4469 ret = lan8841_ptp_extts_on(ptp_priv, pin, rq->extts.flags); in lan8841_ptp_extts()
4471 ret = lan8841_ptp_extts_off(ptp_priv, pin); in lan8841_ptp_extts()
4472 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_extts()
4480 switch (rq->type) { in lan8841_ptp_enable()
4486 return -EOPNOTSUPP; in lan8841_ptp_enable()
4499 lan8841_ptp_getseconds(&ptp_priv->ptp_clock_info, &ts); in lan8841_ptp_do_aux_work()
4501 spin_lock_irqsave(&ptp_priv->seconds_lock, flags); in lan8841_ptp_do_aux_work()
4502 ptp_priv->seconds = ts.tv_sec; in lan8841_ptp_do_aux_work()
4503 spin_unlock_irqrestore(&ptp_priv->seconds_lock, flags); in lan8841_ptp_do_aux_work()
4540 phydev->interface = PHY_INTERFACE_MODE_RGMII_RXID; in lan8841_probe()
4546 priv = phydev->priv; in lan8841_probe()
4547 ptp_priv = &priv->ptp_priv; in lan8841_probe()
4549 ptp_priv->pin_config = devm_kcalloc(&phydev->mdio.dev, in lan8841_probe()
4551 sizeof(*ptp_priv->pin_config), in lan8841_probe()
4553 if (!ptp_priv->pin_config) in lan8841_probe()
4554 return -ENOMEM; in lan8841_probe()
4557 struct ptp_pin_desc *p = &ptp_priv->pin_config[i]; in lan8841_probe()
4559 snprintf(p->name, sizeof(p->name), "pin%d", i); in lan8841_probe()
4560 p->index = i; in lan8841_probe()
4561 p->func = PTP_PF_NONE; in lan8841_probe()
4564 ptp_priv->ptp_clock_info = lan8841_ptp_clock_info; in lan8841_probe()
4565 ptp_priv->ptp_clock_info.pin_config = ptp_priv->pin_config; in lan8841_probe()
4566 ptp_priv->ptp_clock = ptp_clock_register(&ptp_priv->ptp_clock_info, in lan8841_probe()
4567 &phydev->mdio.dev); in lan8841_probe()
4568 if (IS_ERR(ptp_priv->ptp_clock)) { in lan8841_probe()
4570 PTR_ERR(ptp_priv->ptp_clock)); in lan8841_probe()
4571 return -EINVAL; in lan8841_probe()
4574 if (!ptp_priv->ptp_clock) in lan8841_probe()
4578 skb_queue_head_init(&ptp_priv->tx_queue); in lan8841_probe()
4579 ptp_priv->phydev = phydev; in lan8841_probe()
4580 mutex_init(&ptp_priv->ptp_lock); in lan8841_probe()
4581 spin_lock_init(&ptp_priv->seconds_lock); in lan8841_probe()
4583 ptp_priv->mii_ts.rxtstamp = lan8841_rxtstamp; in lan8841_probe()
4584 ptp_priv->mii_ts.txtstamp = lan8814_txtstamp; in lan8841_probe()
4585 ptp_priv->mii_ts.hwtstamp = lan8841_hwtstamp; in lan8841_probe()
4586 ptp_priv->mii_ts.ts_info = lan8841_ts_info; in lan8841_probe()
4588 phydev->mii_ts = &ptp_priv->mii_ts; in lan8841_probe()
4595 struct kszphy_priv *priv = phydev->priv; in lan8841_suspend()
4596 struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; in lan8841_suspend()
4598 ptp_cancel_worker_sync(ptp_priv->ptp_clock); in lan8841_suspend()