Lines Matching +full:skew +full:- +full:delay

1 // SPDX-License-Identifier: GPL-2.0+
9 * Copyright (c) 2010-2013 Micrel, Inc.
30 #include <linux/delay.h>
119 * The value is calculated as following: (1/1000000)/((2^-32)/4)
393 const struct kszphy_type *type = phydev->drv->driver_data; in kszphy_config_intr()
397 if (type && type->interrupt_level_mask) in kszphy_config_intr()
398 mask = type->interrupt_level_mask; in kszphy_config_intr()
410 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in kszphy_config_intr()
475 return -EINVAL; in kszphy_setup_led()
495 * unique (non-broadcast) address on a shared bus.
536 struct kszphy_priv *priv = phydev->priv; in kszphy_config_reset()
539 if (priv->rmii_ref_clk_sel) { in kszphy_config_reset()
540 ret = kszphy_rmii_clk_sel(phydev, priv->rmii_ref_clk_sel_val); in kszphy_config_reset()
548 if (priv->type && priv->led_mode >= 0) in kszphy_config_reset()
549 kszphy_setup_led(phydev, priv->type->led_mode_reg, priv->led_mode); in kszphy_config_reset()
556 struct kszphy_priv *priv = phydev->priv; in kszphy_config_init()
562 type = priv->type; in kszphy_config_init()
564 if (type && type->has_broadcast_disable) in kszphy_config_init()
567 if (type && type->has_nand_tree_disable) in kszphy_config_init()
575 struct device_node *of_node = phydev->mdio.dev.of_node; in ksz8041_fiber_mode()
577 return of_property_read_bool(of_node, "micrel,fiber-mode"); in ksz8041_fiber_mode()
586 phydev->dev_flags |= MICREL_PHY_FXEN; in ksz8041_config_init()
590 linkmode_and(phydev->supported, phydev->supported, mask); in ksz8041_config_init()
592 phydev->supported); in ksz8041_config_init()
593 linkmode_and(phydev->advertising, phydev->advertising, mask); in ksz8041_config_init()
595 phydev->advertising); in ksz8041_config_init()
596 phydev->autoneg = AUTONEG_DISABLE; in ksz8041_config_init()
604 /* Skip auto-negotiation in fiber mode */ in ksz8041_config_aneg()
605 if (phydev->dev_flags & MICREL_PHY_FXEN) { in ksz8041_config_aneg()
606 phydev->speed = SPEED_100; in ksz8041_config_aneg()
618 if ((phydev->phy_id & MICREL_PHY_ID_MASK) != PHY_ID_KSZ8051) in ksz8051_ksz8795_match_phy_device()
644 /* KSZPHY_OMSO_FACTORY_TEST is set at de-assertion of the reset line in ksz8081_config_init()
646 * pull-down is missing, the factory test mode should be cleared by in ksz8081_config_init()
688 /* The MDI-X configuration is automatically changed by the PHY after in ksz8081_config_aneg()
689 * switching from autoneg off to on. So, take MDI-X configuration under in ksz8081_config_aneg()
692 return ksz8081_config_mdix(phydev, phydev->mdix_ctrl); in ksz8081_config_aneg()
705 phydev->mdix_ctrl = ETH_TP_MDI_X; in ksz8081_mdix_update()
707 phydev->mdix_ctrl = ETH_TP_MDI; in ksz8081_mdix_update()
709 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in ksz8081_mdix_update()
717 phydev->mdix = ETH_TP_MDI; in ksz8081_mdix_update()
719 phydev->mdix = ETH_TP_MDI_X; in ksz8081_mdix_update()
757 int val1 = -1; in ksz9021_load_values_from_of()
758 int val2 = -2; in ksz9021_load_values_from_of()
759 int val3 = -3; in ksz9021_load_values_from_of()
760 int val4 = -4; in ksz9021_load_values_from_of()
784 if (val1 != -1) in ksz9021_load_values_from_of()
787 if (val2 != -2) in ksz9021_load_values_from_of()
790 if (val3 != -3) in ksz9021_load_values_from_of()
793 if (val4 != -4) in ksz9021_load_values_from_of()
808 dev_walker = &phydev->mdio.dev; in ksz9021_config_init()
810 of_node = dev_walker->of_node; in ksz9021_config_init()
811 dev_walker = dev_walker->parent; in ksz9021_config_init()
818 "txen-skew-ps", "txc-skew-ps", in ksz9021_config_init()
819 "rxdv-skew-ps", "rxc-skew-ps"); in ksz9021_config_init()
822 "rxd0-skew-ps", "rxd1-skew-ps", in ksz9021_config_init()
823 "rxd2-skew-ps", "rxd3-skew-ps"); in ksz9021_config_init()
826 "txd0-skew-ps", "txd1-skew-ps", in ksz9021_config_init()
827 "txd2-skew-ps", "txd3-skew-ps"); in ksz9021_config_init()
861 * provide different RGMII options we need to configure delay offset
862 * for each pad relative to build in delay.
864 /* keep rx as "No delay adjustment" and set rx_clk to +0.60ns to get delays of
870 /* set rx to +0.30ns and rx_clk to -0.90ns to compensate the
871 * internal 1.2ns delay.
876 /* set tx to -0.42ns and tx_clk to +0.96ns to get 1.38ns delay */
880 /* set tx and tx_clk to "No delay adjustment" to keep 0ns
896 int val[4] = {-1, -2, -3, -4}; in ksz9031_of_load_skew_values()
919 if (val[i] != -(i + 1)) { in ksz9031_of_load_skew_values()
948 /* Enable energy-detect power-down mode */
965 switch (phydev->interface) { in ksz9031_config_rgmii_delay()
1024 static const char *clk_skews[2] = {"rxc-skew-ps", "txc-skew-ps"}; in ksz9031_config_init()
1026 "rxd0-skew-ps", "rxd1-skew-ps", in ksz9031_config_init()
1027 "rxd2-skew-ps", "rxd3-skew-ps" in ksz9031_config_init()
1030 "txd0-skew-ps", "txd1-skew-ps", in ksz9031_config_init()
1031 "txd2-skew-ps", "txd3-skew-ps" in ksz9031_config_init()
1033 static const char *control_skews[2] = {"txen-skew-ps", "rxdv-skew-ps"}; in ksz9031_config_init()
1045 dev_walker = &phydev->mdio.dev; in ksz9031_config_init()
1047 of_node = dev_walker->of_node; in ksz9031_config_init()
1048 dev_walker = dev_walker->parent; in ksz9031_config_init()
1078 "*-skew-ps values should be used only with RGMII PHY modes\n"); in ksz9031_config_init()
1081 * When the device links in the 1000BASE-T slave mode only, in ksz9031_config_init()
1095 if (of_property_read_bool(of_node, "micrel,force-master")) { in ksz9031_config_init()
1125 int val[4] = {-(1 + KSZ9131_OFFSET), -(2 + KSZ9131_OFFSET), in ksz9131_of_load_skew_values()
1126 -(3 + KSZ9131_OFFSET), -(4 + KSZ9131_OFFSET)}; in ksz9131_of_load_skew_values()
1142 if (skewval < -KSZ9131_OFFSET) in ksz9131_of_load_skew_values()
1143 skewval = -KSZ9131_OFFSET; in ksz9131_of_load_skew_values()
1161 if (val[i] != -(i + 1 + KSZ9131_OFFSET)) { in ksz9131_of_load_skew_values()
1184 switch (phydev->interface) { in ksz9131_config_rgmii_delay()
1218 * When LEDs are configured in Individual Mode, LED1 is ON in a no-link
1239 char *clk_skews[2] = {"rxc-skew-psec", "txc-skew-psec"}; in ksz9131_config_init()
1241 "rxd0-skew-psec", "rxd1-skew-psec", in ksz9131_config_init()
1242 "rxd2-skew-psec", "rxd3-skew-psec" in ksz9131_config_init()
1245 "txd0-skew-psec", "txd1-skew-psec", in ksz9131_config_init()
1246 "txd2-skew-psec", "txd3-skew-psec" in ksz9131_config_init()
1248 char *control_skews[2] = {"txen-skew-psec", "rxdv-skew-psec"}; in ksz9131_config_init()
1252 dev_walker = &phydev->mdio.dev; in ksz9131_config_init()
1254 of_node = dev_walker->of_node; in ksz9131_config_init()
1255 dev_walker = dev_walker->parent; in ksz9131_config_init()
1311 phydev->duplex = DUPLEX_HALF; in ksz8873mll_read_status()
1313 phydev->duplex = DUPLEX_FULL; in ksz8873mll_read_status()
1316 phydev->speed = SPEED_10; in ksz8873mll_read_status()
1318 phydev->speed = SPEED_100; in ksz8873mll_read_status()
1320 phydev->link = 1; in ksz8873mll_read_status()
1321 phydev->pause = phydev->asym_pause = 0; in ksz8873mll_read_status()
1336 * link-up may fail after a link-up to link-down transition. in ksz9031_get_features()
1343 linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydev->supported); in ksz9031_get_features()
1348 linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported); in ksz9031_get_features()
1368 phydev->link = 0; in ksz9031_read_status()
1369 if (phydev->drv->config_intr && phy_interrupt_is_valid(phydev)) in ksz9031_read_status()
1370 phydev->drv->config_intr(phydev); in ksz9031_read_status()
1379 struct kszphy_priv *priv = phydev->priv; in ksz9x31_cable_test_start()
1382 /* KSZ9131RNX, DS00002841B-page 38, 4.14 LinkMD (R) Cable Diagnostic in ksz9x31_cable_test_start()
1383 * Prior to running the cable diagnostics, Auto-negotiation should in ksz9x31_cable_test_start()
1394 /* KSZ9131RNX, DS00002841B-page 38, 4.14 LinkMD (R) Cable Diagnostic in ksz9x31_cable_test_start()
1395 * The Master-Slave configuration should be set to Slave by writing in ksz9x31_cable_test_start()
1396 * a value of 0x1000 to the Auto-Negotiation Master Slave Control in ksz9x31_cable_test_start()
1404 priv->vct_ctrl1000 = ret & (CTL1000_ENABLE_MASTER | CTL1000_AS_MASTER); in ksz9x31_cable_test_start()
1449 /* KSZ9131RNX, DS00002841B-page 38, 4.14 LinkMD (R) Cable Diagnostic in ksz9x31_cable_test_fault_length()
1451 * distance to fault = (VCT_DATA - 22) * 4 / cable propagation velocity in ksz9x31_cable_test_fault_length()
1453 if ((phydev->phy_id & MICREL_PHY_ID_MASK) == PHY_ID_KSZ9131) in ksz9x31_cable_test_fault_length()
1454 dt = clamp(dt - 22, 0, 255); in ksz9x31_cable_test_fault_length()
1486 /* KSZ9131RNX, DS00002841B-page 38, 4.14 LinkMD (R) Cable Diagnostic in ksz9x31_cable_test_one_pair()
1507 return -EAGAIN; in ksz9x31_cable_test_one_pair()
1526 struct kszphy_priv *priv = phydev->priv; in ksz9x31_cable_test_get_status()
1534 while (pair_mask && retries--) { in ksz9x31_cable_test_get_status()
1537 if (ret == -EAGAIN) in ksz9x31_cable_test_get_status()
1563 priv->vct_ctrl1000); in ksz9x31_cable_test_get_status()
1585 * counter intuitive, the "-X" in "1 = Force MDI" in the data in ksz886x_config_mdix()
1587 * 1 = Force MDI (sic!) (transmit on RX+/RX- pins) in ksz886x_config_mdix()
1588 * 0 = Normal operation (transmit on TX+/TX- pins) in ksz886x_config_mdix()
1613 /* The MDI-X configuration is automatically changed by the PHY after in ksz886x_config_aneg()
1614 * switching from autoneg off to on. So, take MDI-X configuration under in ksz886x_config_aneg()
1617 return ksz886x_config_mdix(phydev, phydev->mdix_ctrl); in ksz886x_config_aneg()
1630 phydev->mdix_ctrl = ETH_TP_MDI_X; in ksz886x_mdix_update()
1632 phydev->mdix_ctrl = ETH_TP_MDI; in ksz886x_mdix_update()
1634 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in ksz886x_mdix_update()
1643 phydev->mdix = ETH_TP_MDI_X; in ksz886x_mdix_update()
1645 phydev->mdix = ETH_TP_MDI; in ksz886x_mdix_update()
1679 struct kszphy_priv *priv = phydev->priv; in kszphy_get_stat()
1687 val = val & ((1 << stat.bits) - 1); in kszphy_get_stat()
1688 priv->stats[i] += val; in kszphy_get_stat()
1689 ret = priv->stats[i]; in kszphy_get_stat()
1708 phydev->interrupts = PHY_INTERRUPT_DISABLED; in kszphy_suspend()
1709 if (phydev->drv->config_intr) in kszphy_suspend()
1710 phydev->drv->config_intr(phydev); in kszphy_suspend()
1718 const struct kszphy_type *type = phydev->drv->driver_data; in kszphy_parse_led_mode()
1719 const struct device_node *np = phydev->mdio.dev.of_node; in kszphy_parse_led_mode()
1720 struct kszphy_priv *priv = phydev->priv; in kszphy_parse_led_mode()
1723 if (type && type->led_mode_reg) { in kszphy_parse_led_mode()
1724 ret = of_property_read_u32(np, "micrel,led-mode", in kszphy_parse_led_mode()
1725 &priv->led_mode); in kszphy_parse_led_mode()
1728 priv->led_mode = -1; in kszphy_parse_led_mode()
1730 if (priv->led_mode > 3) { in kszphy_parse_led_mode()
1732 priv->led_mode); in kszphy_parse_led_mode()
1733 priv->led_mode = -1; in kszphy_parse_led_mode()
1736 priv->led_mode = -1; in kszphy_parse_led_mode()
1746 /* After switching from power-down to normal mode, an internal global in kszphy_resume()
1758 phydev->interrupts = PHY_INTERRUPT_ENABLED; in kszphy_resume()
1759 if (phydev->drv->config_intr) in kszphy_resume()
1760 phydev->drv->config_intr(phydev); in kszphy_resume()
1768 const struct kszphy_type *type = phydev->drv->driver_data; in kszphy_probe()
1769 const struct device_node *np = phydev->mdio.dev.of_node; in kszphy_probe()
1773 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in kszphy_probe()
1775 return -ENOMEM; in kszphy_probe()
1777 phydev->priv = priv; in kszphy_probe()
1779 priv->type = type; in kszphy_probe()
1783 clk = devm_clk_get(&phydev->mdio.dev, "rmii-ref"); in kszphy_probe()
1790 priv->rmii_ref_clk_sel = type->has_rmii_ref_clk_sel; in kszphy_probe()
1792 "micrel,rmii-reference-clock-select-25-mhz"); in kszphy_probe()
1795 priv->rmii_ref_clk_sel_val = rmii_ref_clk_sel_25_mhz; in kszphy_probe()
1797 priv->rmii_ref_clk_sel_val = !rmii_ref_clk_sel_25_mhz; in kszphy_probe()
1801 return -EINVAL; in kszphy_probe()
1806 phydev->port = PORT_FIBRE; in kszphy_probe()
1808 /* Support legacy board-file configuration */ in kszphy_probe()
1809 if (phydev->dev_flags & MICREL_PHY_50MHZ_CLK) { in kszphy_probe()
1810 priv->rmii_ref_clk_sel = true; in kszphy_probe()
1811 priv->rmii_ref_clk_sel_val = true; in kszphy_probe()
1821 * confuse the internal state machine - disable auto neg here. in lan8814_cable_test_start()
1830 if (phydev->dev_flags & MICREL_KSZ8_P1_ERRATA) in ksz886x_cable_test_start()
1831 return -EOPNOTSUPP; in ksz886x_cable_test_start()
1835 * confuse the internal state machine - disable auto neg here. in ksz886x_cable_test_start()
1881 * (DELTA_TIME - 22) * 0.8 for lan8814 phy. in ksz886x_cable_test_fault_length()
1885 if ((phydev->phy_id & MICREL_PHY_ID_MASK) == PHY_ID_LAN8814) in ksz886x_cable_test_fault_length()
1886 return ((dt - 22) * 800) / 10; in ksz886x_cable_test_fault_length()
1893 const struct kszphy_type *type = phydev->drv->driver_data; in ksz886x_cable_test_wait_for_completion()
1896 ret = phy_read_poll_timeout(phydev, type->cable_diag_reg, val, in ksz886x_cable_test_wait_for_completion()
1930 return -EAGAIN; in lan8814_cable_test_one_pair()
1958 * We can workaround this limitation by using the MDI-X functionality. in ksz886x_cable_test_one_pair()
1965 switch (phydev->phy_id & MICREL_PHY_ID_MASK) { in ksz886x_cable_test_one_pair()
1973 ret = -ENODEV; in ksz886x_cable_test_one_pair()
1995 return -EAGAIN; in ksz886x_cable_test_one_pair()
2013 const struct kszphy_type *type = phydev->drv->driver_data; in ksz886x_cable_test_get_status()
2014 unsigned long pair_mask = type->pair_mask; in ksz886x_cable_test_get_status()
2021 while (pair_mask && retries--) { in ksz886x_cable_test_get_status()
2023 if (type->cable_diag_reg == LAN8814_CABLE_DIAG) in ksz886x_cable_test_get_status()
2027 if (ret == -EAGAIN) in ksz886x_cable_test_get_status()
2140 struct phy_device *phydev = ptp_priv->phydev; in lan8814_ts_info()
2141 struct lan8814_shared_priv *shared = phydev->shared->priv; in lan8814_ts_info()
2143 info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | in lan8814_ts_info()
2147 info->phc_index = ptp_clock_index(shared->ptp_clock); in lan8814_ts_info()
2149 info->tx_types = in lan8814_ts_info()
2154 info->rx_filters = in lan8814_ts_info()
2180 struct phy_device *phydev = ptp_priv->phydev; in lan8814_hwtstamp()
2181 struct lan8814_shared_priv *shared = phydev->shared->priv; in lan8814_hwtstamp()
2187 if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) in lan8814_hwtstamp()
2188 return -EFAULT; in lan8814_hwtstamp()
2190 ptp_priv->hwts_tx_type = config.tx_type; in lan8814_hwtstamp()
2191 ptp_priv->rx_filter = config.rx_filter; in lan8814_hwtstamp()
2195 ptp_priv->layer = 0; in lan8814_hwtstamp()
2196 ptp_priv->version = 0; in lan8814_hwtstamp()
2201 ptp_priv->layer = PTP_CLASS_L4; in lan8814_hwtstamp()
2202 ptp_priv->version = PTP_CLASS_V2; in lan8814_hwtstamp()
2207 ptp_priv->layer = PTP_CLASS_L2; in lan8814_hwtstamp()
2208 ptp_priv->version = PTP_CLASS_V2; in lan8814_hwtstamp()
2213 ptp_priv->layer = PTP_CLASS_L4 | PTP_CLASS_L2; in lan8814_hwtstamp()
2214 ptp_priv->version = PTP_CLASS_V2; in lan8814_hwtstamp()
2217 return -ERANGE; in lan8814_hwtstamp()
2220 if (ptp_priv->layer & PTP_CLASS_L2) { in lan8814_hwtstamp()
2223 } else if (ptp_priv->layer & PTP_CLASS_L4) { in lan8814_hwtstamp()
2227 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_RX_PARSE_CONFIG, rxcfg); in lan8814_hwtstamp()
2228 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_PARSE_CONFIG, txcfg); in lan8814_hwtstamp()
2232 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_RX_TIMESTAMP_EN, pkt_ts_enable); in lan8814_hwtstamp()
2233 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_TIMESTAMP_EN, pkt_ts_enable); in lan8814_hwtstamp()
2235 if (ptp_priv->hwts_tx_type == HWTSTAMP_TX_ONESTEP_SYNC) in lan8814_hwtstamp()
2236 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_MOD, in lan8814_hwtstamp()
2240 lan8814_config_ts_intr(ptp_priv->phydev, true); in lan8814_hwtstamp()
2242 lan8814_config_ts_intr(ptp_priv->phydev, false); in lan8814_hwtstamp()
2244 mutex_lock(&shared->shared_lock); in lan8814_hwtstamp()
2246 shared->ref++; in lan8814_hwtstamp()
2248 shared->ref--; in lan8814_hwtstamp()
2250 if (shared->ref) in lan8814_hwtstamp()
2251 lanphy_write_page_reg(ptp_priv->phydev, 4, PTP_CMD_CTL, in lan8814_hwtstamp()
2254 lanphy_write_page_reg(ptp_priv->phydev, 4, PTP_CMD_CTL, in lan8814_hwtstamp()
2256 mutex_unlock(&shared->shared_lock); in lan8814_hwtstamp()
2259 list_for_each_entry_safe(rx_ts, tmp, &ptp_priv->rx_ts_list, list) { in lan8814_hwtstamp()
2260 list_del(&rx_ts->list); in lan8814_hwtstamp()
2263 skb_queue_purge(&ptp_priv->rx_queue); in lan8814_hwtstamp()
2264 skb_queue_purge(&ptp_priv->tx_queue); in lan8814_hwtstamp()
2266 lan8814_flush_fifo(ptp_priv->phydev, false); in lan8814_hwtstamp()
2267 lan8814_flush_fifo(ptp_priv->phydev, true); in lan8814_hwtstamp()
2269 return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? -EFAULT : 0; in lan8814_hwtstamp()
2277 switch (ptp_priv->hwts_tx_type) { in lan8814_txtstamp()
2285 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in lan8814_txtstamp()
2286 skb_queue_tail(&ptp_priv->tx_queue, skb); in lan8814_txtstamp()
2305 *sig = (__force u16)(ntohs(ptp_header->sequence_id)); in lan8814_get_sig_rx()
2320 spin_lock_irqsave(&ptp_priv->rx_ts_lock, flags); in lan8814_match_rx_ts()
2321 list_for_each_entry_safe(rx_ts, tmp, &ptp_priv->rx_ts_list, list) { in lan8814_match_rx_ts()
2323 if (memcmp(&skb_sig, &rx_ts->seq_id, sizeof(rx_ts->seq_id))) in lan8814_match_rx_ts()
2328 shhwtstamps->hwtstamp = ktime_set(rx_ts->seconds, in lan8814_match_rx_ts()
2329 rx_ts->nsec); in lan8814_match_rx_ts()
2330 list_del(&rx_ts->list); in lan8814_match_rx_ts()
2336 spin_unlock_irqrestore(&ptp_priv->rx_ts_lock, flags); in lan8814_match_rx_ts()
2348 if (ptp_priv->rx_filter == HWTSTAMP_FILTER_NONE || in lan8814_rxtstamp()
2352 if ((type & ptp_priv->version) == 0 || (type & ptp_priv->layer) == 0) in lan8814_rxtstamp()
2359 skb_queue_tail(&ptp_priv->rx_queue, skb); in lan8814_rxtstamp()
2401 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_gettime64()
2405 mutex_lock(&shared->shared_lock); in lan8814_ptpci_gettime64()
2407 mutex_unlock(&shared->shared_lock); in lan8814_ptpci_gettime64()
2408 ts->tv_sec = seconds; in lan8814_ptpci_gettime64()
2409 ts->tv_nsec = nano_seconds; in lan8814_ptpci_gettime64()
2419 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_settime64()
2421 mutex_lock(&shared->shared_lock); in lan8814_ptpci_settime64()
2422 lan8814_ptp_clock_set(phydev, ts->tv_sec, ts->tv_nsec); in lan8814_ptpci_settime64()
2423 mutex_unlock(&shared->shared_lock); in lan8814_ptpci_settime64()
2446 nano_seconds -= 1000000000; in lan8814_ptp_clock_step()
2450 } else if (time_step_ns < -15000000000LL) { in lan8814_ptp_clock_step()
2452 time_step_ns = -time_step_ns; in lan8814_ptp_clock_step()
2455 unsigned_seconds -= div_u64_rem(time_step_ns, 1000000000LL, in lan8814_ptp_clock_step()
2459 unsigned_seconds--; in lan8814_ptp_clock_step()
2462 nano_seconds -= nano_seconds_step; in lan8814_ptp_clock_step()
2475 abs_time_step_ns = (u64)(-time_step_ns); in lan8814_ptp_clock_step()
2476 seconds = -((s32)div_u64_rem(abs_time_step_ns, 1000000000, in lan8814_ptp_clock_step()
2484 seconds--; in lan8814_ptp_clock_step()
2485 nano_seconds = (1000000000 - nano_seconds); in lan8814_ptp_clock_step()
2497 nano_seconds -= 1000000000; in lan8814_ptp_clock_step()
2516 seconds -= ((s32)adjustment_value); in lan8814_ptp_clock_step()
2518 u32 adjustment_value = (u32)(-seconds); in lan8814_ptp_clock_step()
2557 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_adjtime()
2559 mutex_lock(&shared->shared_lock); in lan8814_ptpci_adjtime()
2561 mutex_unlock(&shared->shared_lock); in lan8814_ptpci_adjtime()
2570 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_adjfine()
2576 scaled_ppm = -scaled_ppm; in lan8814_ptpci_adjfine()
2589 mutex_lock(&shared->shared_lock); in lan8814_ptpci_adjfine()
2592 mutex_unlock(&shared->shared_lock); in lan8814_ptpci_adjfine()
2605 *sig = (__force u16)(ntohs(ptp_header->sequence_id)); in lan8814_get_sig_tx()
2610 struct phy_device *phydev = ptp_priv->phydev; in lan8814_dequeue_tx_skb()
2621 spin_lock_irqsave(&ptp_priv->tx_queue.lock, flags); in lan8814_dequeue_tx_skb()
2622 skb_queue_walk_safe(&ptp_priv->tx_queue, skb, skb_tmp) { in lan8814_dequeue_tx_skb()
2628 __skb_unlink(skb, &ptp_priv->tx_queue); in lan8814_dequeue_tx_skb()
2632 spin_unlock_irqrestore(&ptp_priv->tx_queue.lock, flags); in lan8814_dequeue_tx_skb()
2643 struct phy_device *phydev = ptp_priv->phydev; in lan8814_get_tx_ts()
2665 spin_lock_irqsave(&ptp_priv->rx_queue.lock, flags); in lan8814_match_skb()
2666 skb_queue_walk_safe(&ptp_priv->rx_queue, skb, skb_tmp) { in lan8814_match_skb()
2669 if (memcmp(&skb_sig, &rx_ts->seq_id, sizeof(rx_ts->seq_id))) in lan8814_match_skb()
2672 __skb_unlink(skb, &ptp_priv->rx_queue); in lan8814_match_skb()
2677 spin_unlock_irqrestore(&ptp_priv->rx_queue.lock, flags); in lan8814_match_skb()
2682 shhwtstamps->hwtstamp = ktime_set(rx_ts->seconds, rx_ts->nsec); in lan8814_match_skb()
2691 struct phy_device *phydev = ptp_priv->phydev; in lan8814_get_rx_ts()
2701 lan8814_ptp_rx_ts_get(phydev, &rx_ts->seconds, &rx_ts->nsec, in lan8814_get_rx_ts()
2702 &rx_ts->seq_id); in lan8814_get_rx_ts()
2708 spin_lock_irqsave(&ptp_priv->rx_ts_lock, flags); in lan8814_get_rx_ts()
2709 list_add(&rx_ts->list, &ptp_priv->rx_ts_list); in lan8814_get_rx_ts()
2710 spin_unlock_irqrestore(&ptp_priv->rx_ts_lock, flags); in lan8814_get_rx_ts()
2724 struct kszphy_priv *priv = phydev->priv; in lan8814_handle_ptp_interrupt()
2725 struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; in lan8814_handle_ptp_interrupt()
2737 skb_queue_purge(&ptp_priv->tx_queue); in lan8814_handle_ptp_interrupt()
2742 skb_queue_purge(&ptp_priv->rx_queue); in lan8814_handle_ptp_interrupt()
2750 /* MDI-X setting for swap A,B transmit */ in lan8804_config_init()
2797 /* By default interrupt buffer is open-drain in which case the interrupt in lan8804_config_intr()
2799 * push-pull to be able to change interrupt polarity in lan8804_config_intr()
2804 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in lan8804_config_intr()
2879 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in lan8814_config_intr()
2898 struct kszphy_priv *priv = phydev->priv; in lan8814_ptp_init()
2899 struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; in lan8814_ptp_init()
2925 skb_queue_head_init(&ptp_priv->tx_queue); in lan8814_ptp_init()
2926 skb_queue_head_init(&ptp_priv->rx_queue); in lan8814_ptp_init()
2927 INIT_LIST_HEAD(&ptp_priv->rx_ts_list); in lan8814_ptp_init()
2928 spin_lock_init(&ptp_priv->rx_ts_lock); in lan8814_ptp_init()
2930 ptp_priv->phydev = phydev; in lan8814_ptp_init()
2932 ptp_priv->mii_ts.rxtstamp = lan8814_rxtstamp; in lan8814_ptp_init()
2933 ptp_priv->mii_ts.txtstamp = lan8814_txtstamp; in lan8814_ptp_init()
2934 ptp_priv->mii_ts.hwtstamp = lan8814_hwtstamp; in lan8814_ptp_init()
2935 ptp_priv->mii_ts.ts_info = lan8814_ts_info; in lan8814_ptp_init()
2937 phydev->mii_ts = &ptp_priv->mii_ts; in lan8814_ptp_init()
2942 struct lan8814_shared_priv *shared = phydev->shared->priv; in lan8814_ptp_probe_once()
2949 mutex_init(&shared->shared_lock); in lan8814_ptp_probe_once()
2951 shared->ptp_clock_info.owner = THIS_MODULE; in lan8814_ptp_probe_once()
2952 snprintf(shared->ptp_clock_info.name, 30, "%s", phydev->drv->name); in lan8814_ptp_probe_once()
2953 shared->ptp_clock_info.max_adj = 31249999; in lan8814_ptp_probe_once()
2954 shared->ptp_clock_info.n_alarm = 0; in lan8814_ptp_probe_once()
2955 shared->ptp_clock_info.n_ext_ts = 0; in lan8814_ptp_probe_once()
2956 shared->ptp_clock_info.n_pins = 0; in lan8814_ptp_probe_once()
2957 shared->ptp_clock_info.pps = 0; in lan8814_ptp_probe_once()
2958 shared->ptp_clock_info.pin_config = NULL; in lan8814_ptp_probe_once()
2959 shared->ptp_clock_info.adjfine = lan8814_ptpci_adjfine; in lan8814_ptp_probe_once()
2960 shared->ptp_clock_info.adjtime = lan8814_ptpci_adjtime; in lan8814_ptp_probe_once()
2961 shared->ptp_clock_info.gettime64 = lan8814_ptpci_gettime64; in lan8814_ptp_probe_once()
2962 shared->ptp_clock_info.settime64 = lan8814_ptpci_settime64; in lan8814_ptp_probe_once()
2963 shared->ptp_clock_info.getcrosststamp = NULL; in lan8814_ptp_probe_once()
2965 shared->ptp_clock = ptp_clock_register(&shared->ptp_clock_info, in lan8814_ptp_probe_once()
2966 &phydev->mdio.dev); in lan8814_ptp_probe_once()
2967 if (IS_ERR_OR_NULL(shared->ptp_clock)) { in lan8814_ptp_probe_once()
2969 PTR_ERR(shared->ptp_clock)); in lan8814_ptp_probe_once()
2970 return -EINVAL; in lan8814_ptp_probe_once()
2975 shared->phydev = phydev; in lan8814_ptp_probe_once()
3003 struct kszphy_priv *lan8814 = phydev->priv; in lan8814_config_init()
3016 /* MDI-X setting for swap A,B transmit */ in lan8814_config_init()
3022 if (lan8814->led_mode >= 0) in lan8814_config_init()
3023 lan8814_setup_led(phydev, lan8814->led_mode); in lan8814_config_init()
3037 gpiod = devm_gpiod_get_optional(&phydev->mdio.dev, "coma-mode", in lan8814_release_coma_mode()
3051 const struct kszphy_type *type = phydev->drv->driver_data; in lan8814_probe()
3056 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in lan8814_probe()
3058 return -ENOMEM; in lan8814_probe()
3060 phydev->priv = priv; in lan8814_probe()
3062 priv->type = type; in lan8814_probe()
3066 /* Strap-in value for PHY address, below register read gives starting in lan8814_probe()
3070 devm_phy_package_join(&phydev->mdio.dev, phydev, in lan8814_probe()