Lines Matching +full:eee +full:- +full:broken +full:- +full:100 +full:tx
1 // SPDX-License-Identifier: GPL-2.0+
9 * Copyright (c) 2010-2013 Micrel, Inc.
14 * 100/10 Phys : ksz8001, ksz8721, ksz8737, ksz8041
126 * The value is calculated as following: (1/1000000)/((2^-32)/4)
132 * The value is calculated as following: (1/1000000)/((2^-32)/8)
525 const struct kszphy_type *type = phydev->drv->driver_data; in kszphy_config_intr()
529 if (type && type->interrupt_level_mask) in kszphy_config_intr()
530 mask = type->interrupt_level_mask; in kszphy_config_intr()
542 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in kszphy_config_intr()
605 return -EINVAL; in kszphy_setup_led()
625 * unique (non-broadcast) address on a shared bus.
666 struct kszphy_priv *priv = phydev->priv; in kszphy_config_reset()
669 if (priv->rmii_ref_clk_sel) { in kszphy_config_reset()
670 ret = kszphy_rmii_clk_sel(phydev, priv->rmii_ref_clk_sel_val); in kszphy_config_reset()
678 if (priv->type && priv->led_mode >= 0) in kszphy_config_reset()
679 kszphy_setup_led(phydev, priv->type->led_mode_reg, priv->led_mode); in kszphy_config_reset()
686 struct kszphy_priv *priv = phydev->priv; in kszphy_config_init()
692 type = priv->type; in kszphy_config_init()
694 if (type && type->has_broadcast_disable) in kszphy_config_init()
697 if (type && type->has_nand_tree_disable) in kszphy_config_init()
705 struct device_node *of_node = phydev->mdio.dev.of_node; in ksz8041_fiber_mode()
707 return of_property_read_bool(of_node, "micrel,fiber-mode"); in ksz8041_fiber_mode()
716 phydev->dev_flags |= MICREL_PHY_FXEN; in ksz8041_config_init()
720 linkmode_and(phydev->supported, phydev->supported, mask); in ksz8041_config_init()
722 phydev->supported); in ksz8041_config_init()
723 linkmode_and(phydev->advertising, phydev->advertising, mask); in ksz8041_config_init()
725 phydev->advertising); in ksz8041_config_init()
726 phydev->autoneg = AUTONEG_DISABLE; in ksz8041_config_init()
734 /* Skip auto-negotiation in fiber mode */ in ksz8041_config_aneg()
735 if (phydev->dev_flags & MICREL_PHY_FXEN) { in ksz8041_config_aneg()
736 phydev->speed = SPEED_100; in ksz8041_config_aneg()
748 if (!phy_id_compare(phydev->phy_id, PHY_ID_KSZ8051, MICREL_PHY_ID_MASK)) in ksz8051_ksz8795_match_phy_device()
774 /* KSZPHY_OMSO_FACTORY_TEST is set at de-assertion of the reset line in ksz8081_config_init()
776 * pull-down is missing, the factory test mode should be cleared by in ksz8081_config_init()
818 /* The MDI-X configuration is automatically changed by the PHY after in ksz8081_config_aneg()
819 * switching from autoneg off to on. So, take MDI-X configuration under in ksz8081_config_aneg()
822 return ksz8081_config_mdix(phydev, phydev->mdix_ctrl); in ksz8081_config_aneg()
835 phydev->mdix_ctrl = ETH_TP_MDI_X; in ksz8081_mdix_update()
837 phydev->mdix_ctrl = ETH_TP_MDI; in ksz8081_mdix_update()
839 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in ksz8081_mdix_update()
847 phydev->mdix = ETH_TP_MDI; in ksz8081_mdix_update()
849 phydev->mdix = ETH_TP_MDI_X; in ksz8081_mdix_update()
898 int val1 = -1; in ksz9021_load_values_from_of()
899 int val2 = -2; in ksz9021_load_values_from_of()
900 int val3 = -3; in ksz9021_load_values_from_of()
901 int val4 = -4; in ksz9021_load_values_from_of()
925 if (val1 != -1) in ksz9021_load_values_from_of()
928 if (val2 != -2) in ksz9021_load_values_from_of()
931 if (val3 != -3) in ksz9021_load_values_from_of()
934 if (val4 != -4) in ksz9021_load_values_from_of()
949 dev_walker = &phydev->mdio.dev; in ksz9021_config_init()
951 of_node = dev_walker->of_node; in ksz9021_config_init()
952 dev_walker = dev_walker->parent; in ksz9021_config_init()
959 "txen-skew-ps", "txc-skew-ps", in ksz9021_config_init()
960 "rxdv-skew-ps", "rxc-skew-ps"); in ksz9021_config_init()
963 "rxd0-skew-ps", "rxd1-skew-ps", in ksz9021_config_init()
964 "rxd2-skew-ps", "rxd3-skew-ps"); in ksz9021_config_init()
967 "txd0-skew-ps", "txd1-skew-ps", in ksz9021_config_init()
968 "txd2-skew-ps", "txd3-skew-ps"); in ksz9021_config_init()
1011 /* set rx to +0.30ns and rx_clk to -0.90ns to compensate the
1017 /* set tx to -0.42ns and tx_clk to +0.96ns to get 1.38ns delay */
1021 /* set tx and tx_clk to "No delay adjustment" to keep 0ns
1037 int val[4] = {-1, -2, -3, -4}; in ksz9031_of_load_skew_values()
1060 if (val[i] != -(i + 1)) { in ksz9031_of_load_skew_values()
1089 /* Enable energy-detect power-down mode */
1103 u16 rx, tx, rx_clk, tx_clk; in ksz9031_config_rgmii_delay() local
1106 switch (phydev->interface) { in ksz9031_config_rgmii_delay()
1108 tx = TX_ND; in ksz9031_config_rgmii_delay()
1114 tx = TX_ID; in ksz9031_config_rgmii_delay()
1120 tx = TX_ND; in ksz9031_config_rgmii_delay()
1126 tx = TX_ID; in ksz9031_config_rgmii_delay()
1137 FIELD_PREP(MII_KSZ9031RN_TX_CTL_M, tx)); in ksz9031_config_rgmii_delay()
1150 FIELD_PREP(MII_KSZ9031RN_TXD3, tx) | in ksz9031_config_rgmii_delay()
1151 FIELD_PREP(MII_KSZ9031RN_TXD2, tx) | in ksz9031_config_rgmii_delay()
1152 FIELD_PREP(MII_KSZ9031RN_TXD1, tx) | in ksz9031_config_rgmii_delay()
1153 FIELD_PREP(MII_KSZ9031RN_TXD0, tx)); in ksz9031_config_rgmii_delay()
1165 static const char *clk_skews[2] = {"rxc-skew-ps", "txc-skew-ps"}; in ksz9031_config_init()
1167 "rxd0-skew-ps", "rxd1-skew-ps", in ksz9031_config_init()
1168 "rxd2-skew-ps", "rxd3-skew-ps" in ksz9031_config_init()
1171 "txd0-skew-ps", "txd1-skew-ps", in ksz9031_config_init()
1172 "txd2-skew-ps", "txd3-skew-ps" in ksz9031_config_init()
1174 static const char *control_skews[2] = {"txen-skew-ps", "rxdv-skew-ps"}; in ksz9031_config_init()
1186 dev_walker = &phydev->mdio.dev; in ksz9031_config_init()
1188 of_node = dev_walker->of_node; in ksz9031_config_init()
1189 dev_walker = dev_walker->parent; in ksz9031_config_init()
1219 "*-skew-ps values should be used only with RGMII PHY modes\n"); in ksz9031_config_init()
1222 * When the device links in the 1000BASE-T slave mode only, in ksz9031_config_init()
1236 if (of_property_read_bool(of_node, "micrel,force-master")) { in ksz9031_config_init()
1259 #define KSZ9131_STEP 100
1266 int val[4] = {-(1 + KSZ9131_OFFSET), -(2 + KSZ9131_OFFSET), in ksz9131_of_load_skew_values()
1267 -(3 + KSZ9131_OFFSET), -(4 + KSZ9131_OFFSET)}; in ksz9131_of_load_skew_values()
1283 if (skewval < -KSZ9131_OFFSET) in ksz9131_of_load_skew_values()
1284 skewval = -KSZ9131_OFFSET; in ksz9131_of_load_skew_values()
1302 if (val[i] != -(i + 1 + KSZ9131_OFFSET)) { in ksz9131_of_load_skew_values()
1320 const struct kszphy_type *type = phydev->drv->driver_data; in ksz9131_config_rgmii_delay()
1324 switch (phydev->interface) { in ksz9131_config_rgmii_delay()
1326 rxcdll_val = type->disable_dll_rx_bit; in ksz9131_config_rgmii_delay()
1327 txcdll_val = type->disable_dll_tx_bit; in ksz9131_config_rgmii_delay()
1335 txcdll_val = type->disable_dll_tx_bit; in ksz9131_config_rgmii_delay()
1338 rxcdll_val = type->disable_dll_rx_bit; in ksz9131_config_rgmii_delay()
1346 KSZ9131RN_RXC_DLL_CTRL, type->disable_dll_mask, in ksz9131_config_rgmii_delay()
1352 KSZ9131RN_TXC_DLL_CTRL, type->disable_dll_mask, in ksz9131_config_rgmii_delay()
1358 * When LEDs are configured in Individual Mode, LED1 is ON in a no-link
1379 char *clk_skews[2] = {"rxc-skew-psec", "txc-skew-psec"}; in ksz9131_config_init()
1381 "rxd0-skew-psec", "rxd1-skew-psec", in ksz9131_config_init()
1382 "rxd2-skew-psec", "rxd3-skew-psec" in ksz9131_config_init()
1385 "txd0-skew-psec", "txd1-skew-psec", in ksz9131_config_init()
1386 "txd2-skew-psec", "txd3-skew-psec" in ksz9131_config_init()
1388 char *control_skews[2] = {"txen-skew-psec", "rxdv-skew-psec"}; in ksz9131_config_init()
1392 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in ksz9131_config_init()
1394 dev_walker = &phydev->mdio.dev; in ksz9131_config_init()
1396 of_node = dev_walker->of_node; in ksz9131_config_init()
1397 dev_walker = dev_walker->parent; in ksz9131_config_init()
1451 if (phydev->mdix_ctrl != ETH_TP_MDI_AUTO) { in ksz9131_mdix_update()
1452 phydev->mdix = phydev->mdix_ctrl; in ksz9131_mdix_update()
1460 phydev->mdix = ETH_TP_MDI; in ksz9131_mdix_update()
1462 phydev->mdix = ETH_TP_MDI_X; in ksz9131_mdix_update()
1464 phydev->mdix = ETH_TP_MDI_INVALID; in ksz9131_mdix_update()
1510 ret = ksz9131_config_mdix(phydev, phydev->mdix_ctrl); in ksz9131_config_aneg()
1525 /* The "EEE control and capability 1" (Register 3.20) seems to be in ksz9477_get_features()
1526 * influenced by the "EEE advertisement 1" (Register 7.60). Changes in ksz9477_get_features()
1529 * KSZ8563R should have 100BaseTX/Full only. in ksz9477_get_features()
1531 linkmode_and(phydev->supported_eee, phydev->supported, in ksz9477_get_features()
1550 phydev->duplex = DUPLEX_HALF; in ksz8873mll_read_status()
1552 phydev->duplex = DUPLEX_FULL; in ksz8873mll_read_status()
1555 phydev->speed = SPEED_10; in ksz8873mll_read_status()
1557 phydev->speed = SPEED_100; in ksz8873mll_read_status()
1559 phydev->link = 1; in ksz8873mll_read_status()
1560 phydev->pause = phydev->asym_pause = 0; in ksz8873mll_read_status()
1575 * link-up may fail after a link-up to link-down transition. in ksz9031_get_features()
1582 linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydev->supported); in ksz9031_get_features()
1587 linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported); in ksz9031_get_features()
1601 /* Make sure the PHY is not broken. Read idle error count, in ksz9031_read_status()
1607 phydev->link = 0; in ksz9031_read_status()
1608 if (phydev->drv->config_intr && phy_interrupt_is_valid(phydev)) in ksz9031_read_status()
1609 phydev->drv->config_intr(phydev); in ksz9031_read_status()
1618 struct kszphy_priv *priv = phydev->priv; in ksz9x31_cable_test_start()
1621 /* KSZ9131RNX, DS00002841B-page 38, 4.14 LinkMD (R) Cable Diagnostic in ksz9x31_cable_test_start()
1622 * Prior to running the cable diagnostics, Auto-negotiation should in ksz9x31_cable_test_start()
1633 /* KSZ9131RNX, DS00002841B-page 38, 4.14 LinkMD (R) Cable Diagnostic in ksz9x31_cable_test_start()
1634 * The Master-Slave configuration should be set to Slave by writing in ksz9x31_cable_test_start()
1635 * a value of 0x1000 to the Auto-Negotiation Master Slave Control in ksz9x31_cable_test_start()
1643 priv->vct_ctrl1000 = ret & (CTL1000_ENABLE_MASTER | CTL1000_AS_MASTER); in ksz9x31_cable_test_start()
1688 /* KSZ9131RNX, DS00002841B-page 38, 4.14 LinkMD (R) Cable Diagnostic in ksz9x31_cable_test_fault_length()
1690 * distance to fault = (VCT_DATA - 22) * 4 / cable propagation velocity in ksz9x31_cable_test_fault_length()
1693 dt = clamp(dt - 22, 0, 255); in ksz9x31_cable_test_fault_length()
1725 /* KSZ9131RNX, DS00002841B-page 38, 4.14 LinkMD (R) Cable Diagnostic in ksz9x31_cable_test_one_pair()
1746 return -EAGAIN; in ksz9x31_cable_test_one_pair()
1765 struct kszphy_priv *priv = phydev->priv; in ksz9x31_cable_test_get_status()
1773 while (pair_mask && retries--) { in ksz9x31_cable_test_get_status()
1776 if (ret == -EAGAIN) in ksz9x31_cable_test_get_status()
1802 priv->vct_ctrl1000); in ksz9x31_cable_test_get_status()
1824 * counter intuitive, the "-X" in "1 = Force MDI" in the data in ksz886x_config_mdix()
1826 * 1 = Force MDI (sic!) (transmit on RX+/RX- pins) in ksz886x_config_mdix()
1827 * 0 = Normal operation (transmit on TX+/TX- pins) in ksz886x_config_mdix()
1852 if (phydev->autoneg != AUTONEG_ENABLE) { in ksz886x_config_aneg()
1874 /* The MDI-X configuration is automatically changed by the PHY after in ksz886x_config_aneg()
1875 * switching from autoneg off to on. So, take MDI-X configuration under in ksz886x_config_aneg()
1878 return ksz886x_config_mdix(phydev, phydev->mdix_ctrl); in ksz886x_config_aneg()
1891 phydev->mdix_ctrl = ETH_TP_MDI_X; in ksz886x_mdix_update()
1893 phydev->mdix_ctrl = ETH_TP_MDI; in ksz886x_mdix_update()
1895 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in ksz886x_mdix_update()
1904 phydev->mdix = ETH_TP_MDI_X; in ksz886x_mdix_update()
1906 phydev->mdix = ETH_TP_MDI; in ksz886x_mdix_update()
1938 /* Transmit waveform amplitude can be improved (1000BASE-T, 100BASE-TX, 10BASE-Te) */
1967 * necessary to set the PHY to 100 Mbps speed with auto-negotiation in ksz9477_phy_errata()
1968 * disabled by writing to register 0xN100-0xN101. After writing the in ksz9477_phy_errata()
1970 * register settings, write register 0xN100-0xN101 again to enable in ksz9477_phy_errata()
1971 * and restart auto-negotiation. in ksz9477_phy_errata()
1980 err = phy_write_mmd(phydev, errata->dev_addr, errata->reg_addr, errata->val); in ksz9477_phy_errata()
1997 if ((phydev->phy_id & 0xf) == 1) { in ksz9477_config_init()
2003 /* According to KSZ9477 Errata DS80000754C (Module 4) all EEE modes in ksz9477_config_init()
2004 * in this switch shall be regarded as broken. in ksz9477_config_init()
2006 if (phydev->dev_flags & MICREL_NO_EEE) in ksz9477_config_init()
2007 phydev->eee_broken_modes = -1; in ksz9477_config_init()
2030 struct kszphy_priv *priv = phydev->priv; in kszphy_get_stat()
2038 val = val & ((1 << stat.bits) - 1); in kszphy_get_stat()
2039 priv->stats[i] += val; in kszphy_get_stat()
2040 ret = priv->stats[i]; in kszphy_get_stat()
2059 phydev->interrupts = PHY_INTERRUPT_DISABLED; in kszphy_suspend()
2060 if (phydev->drv->config_intr) in kszphy_suspend()
2061 phydev->drv->config_intr(phydev); in kszphy_suspend()
2069 const struct kszphy_type *type = phydev->drv->driver_data; in kszphy_parse_led_mode()
2070 const struct device_node *np = phydev->mdio.dev.of_node; in kszphy_parse_led_mode()
2071 struct kszphy_priv *priv = phydev->priv; in kszphy_parse_led_mode()
2074 if (type && type->led_mode_reg) { in kszphy_parse_led_mode()
2075 ret = of_property_read_u32(np, "micrel,led-mode", in kszphy_parse_led_mode()
2076 &priv->led_mode); in kszphy_parse_led_mode()
2079 priv->led_mode = -1; in kszphy_parse_led_mode()
2081 if (priv->led_mode > 3) { in kszphy_parse_led_mode()
2083 priv->led_mode); in kszphy_parse_led_mode()
2084 priv->led_mode = -1; in kszphy_parse_led_mode()
2087 priv->led_mode = -1; in kszphy_parse_led_mode()
2097 /* After switching from power-down to normal mode, an internal global in kszphy_resume()
2109 phydev->interrupts = PHY_INTERRUPT_ENABLED; in kszphy_resume()
2110 if (phydev->drv->config_intr) in kszphy_resume()
2111 phydev->drv->config_intr(phydev); in kszphy_resume()
2130 /* After switching from power-down to normal mode, an internal global in ksz9477_resume()
2137 if ((phydev->phy_id & 0xf) == 1) { in ksz9477_resume()
2145 phydev->interrupts = PHY_INTERRUPT_ENABLED; in ksz9477_resume()
2146 if (phydev->drv->config_intr) in ksz9477_resume()
2147 phydev->drv->config_intr(phydev); in ksz9477_resume()
2167 /* Re-program the value after chip is reset. */ in ksz8061_resume()
2174 phydev->interrupts = PHY_INTERRUPT_ENABLED; in ksz8061_resume()
2175 if (phydev->drv->config_intr) in ksz8061_resume()
2176 phydev->drv->config_intr(phydev); in ksz8061_resume()
2184 const struct kszphy_type *type = phydev->drv->driver_data; in kszphy_probe()
2185 const struct device_node *np = phydev->mdio.dev.of_node; in kszphy_probe()
2189 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in kszphy_probe()
2191 return -ENOMEM; in kszphy_probe()
2193 phydev->priv = priv; in kszphy_probe()
2195 priv->type = type; in kszphy_probe()
2199 clk = devm_clk_get_optional_enabled(&phydev->mdio.dev, "rmii-ref"); in kszphy_probe()
2206 priv->rmii_ref_clk_sel = type->has_rmii_ref_clk_sel; in kszphy_probe()
2208 "micrel,rmii-reference-clock-select-25-mhz"); in kszphy_probe()
2211 priv->rmii_ref_clk_sel_val = rmii_ref_clk_sel_25_mhz; in kszphy_probe()
2213 priv->rmii_ref_clk_sel_val = !rmii_ref_clk_sel_25_mhz; in kszphy_probe()
2217 return -EINVAL; in kszphy_probe()
2220 /* unnamed clock from the generic ethernet-phy binding */ in kszphy_probe()
2221 clk = devm_clk_get_optional_enabled(&phydev->mdio.dev, NULL); in kszphy_probe()
2227 phydev->port = PORT_FIBRE; in kszphy_probe()
2229 /* Support legacy board-file configuration */ in kszphy_probe()
2230 if (phydev->dev_flags & MICREL_PHY_50MHZ_CLK) { in kszphy_probe()
2231 priv->rmii_ref_clk_sel = true; in kszphy_probe()
2232 priv->rmii_ref_clk_sel_val = true; in kszphy_probe()
2242 * confuse the internal state machine - disable auto neg here. in lan8814_cable_test_start()
2251 if (phydev->dev_flags & MICREL_KSZ8_P1_ERRATA) in ksz886x_cable_test_start()
2252 return -EOPNOTSUPP; in ksz886x_cable_test_start()
2256 * confuse the internal state machine - disable auto neg here. in ksz886x_cable_test_start()
2302 * (DELTA_TIME - 22) * 0.8 for lan8814 phy. in ksz886x_cable_test_fault_length()
2307 return ((dt - 22) * 800) / 10; in ksz886x_cable_test_fault_length()
2314 const struct kszphy_type *type = phydev->drv->driver_data; in ksz886x_cable_test_wait_for_completion()
2317 ret = phy_read_poll_timeout(phydev, type->cable_diag_reg, val, in ksz886x_cable_test_wait_for_completion()
2351 return -EAGAIN; in lan8814_cable_test_one_pair()
2379 * We can workaround this limitation by using the MDI-X functionality. in ksz886x_cable_test_one_pair()
2386 switch (phydev->phy_id & MICREL_PHY_ID_MASK) { in ksz886x_cable_test_one_pair()
2394 ret = -ENODEV; in ksz886x_cable_test_one_pair()
2400 /* Now we are ready to fire. This command will send a 100ns pulse in ksz886x_cable_test_one_pair()
2416 return -EAGAIN; in ksz886x_cable_test_one_pair()
2434 const struct kszphy_type *type = phydev->drv->driver_data; in ksz886x_cable_test_get_status()
2435 unsigned long pair_mask = type->pair_mask; in ksz886x_cable_test_get_status()
2443 while (pair_mask && retries--) { in ksz886x_cable_test_get_status()
2445 if (type->cable_diag_reg == LAN8814_CABLE_DIAG) in ksz886x_cable_test_get_status()
2449 if (ret == -EAGAIN) in ksz886x_cable_test_get_status()
2562 struct phy_device *phydev = ptp_priv->phydev; in lan8814_ts_info()
2563 struct lan8814_shared_priv *shared = phydev->shared->priv; in lan8814_ts_info()
2565 info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | in lan8814_ts_info()
2569 info->phc_index = ptp_clock_index(shared->ptp_clock); in lan8814_ts_info()
2571 info->tx_types = in lan8814_ts_info()
2576 info->rx_filters = in lan8814_ts_info()
2609 ptp_priv->hwts_tx_type = config->tx_type; in lan8814_hwtstamp()
2610 ptp_priv->rx_filter = config->rx_filter; in lan8814_hwtstamp()
2612 switch (config->rx_filter) { in lan8814_hwtstamp()
2614 ptp_priv->layer = 0; in lan8814_hwtstamp()
2615 ptp_priv->version = 0; in lan8814_hwtstamp()
2620 ptp_priv->layer = PTP_CLASS_L4; in lan8814_hwtstamp()
2621 ptp_priv->version = PTP_CLASS_V2; in lan8814_hwtstamp()
2626 ptp_priv->layer = PTP_CLASS_L2; in lan8814_hwtstamp()
2627 ptp_priv->version = PTP_CLASS_V2; in lan8814_hwtstamp()
2632 ptp_priv->layer = PTP_CLASS_L4 | PTP_CLASS_L2; in lan8814_hwtstamp()
2633 ptp_priv->version = PTP_CLASS_V2; in lan8814_hwtstamp()
2636 return -ERANGE; in lan8814_hwtstamp()
2639 if (ptp_priv->layer & PTP_CLASS_L2) { in lan8814_hwtstamp()
2642 } else if (ptp_priv->layer & PTP_CLASS_L4) { in lan8814_hwtstamp()
2646 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_RX_PARSE_CONFIG, rxcfg); in lan8814_hwtstamp()
2647 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_PARSE_CONFIG, txcfg); in lan8814_hwtstamp()
2651 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_RX_TIMESTAMP_EN, pkt_ts_enable); in lan8814_hwtstamp()
2652 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_TIMESTAMP_EN, pkt_ts_enable); in lan8814_hwtstamp()
2654 tx_mod = lanphy_read_page_reg(ptp_priv->phydev, 5, PTP_TX_MOD); in lan8814_hwtstamp()
2655 if (ptp_priv->hwts_tx_type == HWTSTAMP_TX_ONESTEP_SYNC) { in lan8814_hwtstamp()
2656 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_MOD, in lan8814_hwtstamp()
2658 } else if (ptp_priv->hwts_tx_type == HWTSTAMP_TX_ON) { in lan8814_hwtstamp()
2659 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_MOD, in lan8814_hwtstamp()
2663 if (config->rx_filter != HWTSTAMP_FILTER_NONE) in lan8814_hwtstamp()
2664 lan8814_config_ts_intr(ptp_priv->phydev, true); in lan8814_hwtstamp()
2666 lan8814_config_ts_intr(ptp_priv->phydev, false); in lan8814_hwtstamp()
2669 list_for_each_entry_safe(rx_ts, tmp, &ptp_priv->rx_ts_list, list) { in lan8814_hwtstamp()
2670 list_del(&rx_ts->list); in lan8814_hwtstamp()
2673 skb_queue_purge(&ptp_priv->rx_queue); in lan8814_hwtstamp()
2674 skb_queue_purge(&ptp_priv->tx_queue); in lan8814_hwtstamp()
2676 lan8814_flush_fifo(ptp_priv->phydev, false); in lan8814_hwtstamp()
2677 lan8814_flush_fifo(ptp_priv->phydev, true); in lan8814_hwtstamp()
2687 switch (ptp_priv->hwts_tx_type) { in lan8814_txtstamp()
2695 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in lan8814_txtstamp()
2696 skb_queue_tail(&ptp_priv->tx_queue, skb); in lan8814_txtstamp()
2718 *sig = (__force u16)(ntohs(ptp_header->sequence_id)); in lan8814_get_sig_rx()
2735 spin_lock_irqsave(&ptp_priv->rx_ts_lock, flags); in lan8814_match_rx_skb()
2736 list_for_each_entry_safe(rx_ts, tmp, &ptp_priv->rx_ts_list, list) { in lan8814_match_rx_skb()
2738 if (memcmp(&skb_sig, &rx_ts->seq_id, sizeof(rx_ts->seq_id))) in lan8814_match_rx_skb()
2743 shhwtstamps->hwtstamp = ktime_set(rx_ts->seconds, in lan8814_match_rx_skb()
2744 rx_ts->nsec); in lan8814_match_rx_skb()
2745 list_del(&rx_ts->list); in lan8814_match_rx_skb()
2751 spin_unlock_irqrestore(&ptp_priv->rx_ts_lock, flags); in lan8814_match_rx_skb()
2763 if (ptp_priv->rx_filter == HWTSTAMP_FILTER_NONE || in lan8814_rxtstamp()
2767 if ((type & ptp_priv->version) == 0 || (type & ptp_priv->layer) == 0) in lan8814_rxtstamp()
2774 skb_queue_tail(&ptp_priv->rx_queue, skb); in lan8814_rxtstamp()
2812 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_gettime64()
2816 mutex_lock(&shared->shared_lock); in lan8814_ptpci_gettime64()
2818 mutex_unlock(&shared->shared_lock); in lan8814_ptpci_gettime64()
2819 ts->tv_sec = seconds; in lan8814_ptpci_gettime64()
2820 ts->tv_nsec = nano_seconds; in lan8814_ptpci_gettime64()
2830 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_settime64()
2832 mutex_lock(&shared->shared_lock); in lan8814_ptpci_settime64()
2833 lan8814_ptp_clock_set(phydev, ts->tv_sec, ts->tv_nsec); in lan8814_ptpci_settime64()
2834 mutex_unlock(&shared->shared_lock); in lan8814_ptpci_settime64()
2880 nano_seconds -= 1000000000; in lan8814_ptp_clock_step()
2885 } else if (time_step_ns < -15000000000LL) { in lan8814_ptp_clock_step()
2887 time_step_ns = -time_step_ns; in lan8814_ptp_clock_step()
2890 set_seconds -= div_u64_rem(time_step_ns, 1000000000LL, in lan8814_ptp_clock_step()
2894 set_seconds--; in lan8814_ptp_clock_step()
2897 nano_seconds -= nano_seconds_step; in lan8814_ptp_clock_step()
2910 abs_time_step_ns = (u64)(-time_step_ns); in lan8814_ptp_clock_step()
2911 seconds = -((s32)div_u64_rem(abs_time_step_ns, 1000000000, in lan8814_ptp_clock_step()
2919 seconds--; in lan8814_ptp_clock_step()
2920 nano_seconds = (1000000000 - nano_seconds); in lan8814_ptp_clock_step()
2932 nano_seconds -= 1000000000; in lan8814_ptp_clock_step()
2953 seconds -= ((s32)adjustment_value); in lan8814_ptp_clock_step()
2956 set_seconds -= adjustment_value; in lan8814_ptp_clock_step()
2959 u32 adjustment_value = (u32)(-seconds); in lan8814_ptp_clock_step()
3002 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_adjtime()
3004 mutex_lock(&shared->shared_lock); in lan8814_ptpci_adjtime()
3006 mutex_unlock(&shared->shared_lock); in lan8814_ptpci_adjtime()
3015 struct phy_device *phydev = shared->phydev; in lan8814_ptpci_adjfine()
3021 scaled_ppm = -scaled_ppm; in lan8814_ptpci_adjfine()
3034 mutex_lock(&shared->shared_lock); in lan8814_ptpci_adjfine()
3037 mutex_unlock(&shared->shared_lock); in lan8814_ptpci_adjfine()
3137 struct phy_device *phydev = shared->phydev; in lan8814_ptp_perout()
3144 if (rq->perout.flags & ~PTP_PEROUT_DUTY_CYCLE) in lan8814_ptp_perout()
3145 return -EOPNOTSUPP; in lan8814_ptp_perout()
3147 mutex_lock(&shared->shared_lock); in lan8814_ptp_perout()
3148 event = rq->perout.index; in lan8814_ptp_perout()
3149 pin = ptp_find_pin(shared->ptp_clock, PTP_PF_PEROUT, event); in lan8814_ptp_perout()
3151 mutex_unlock(&shared->shared_lock); in lan8814_ptp_perout()
3152 return -EBUSY; in lan8814_ptp_perout()
3158 mutex_unlock(&shared->shared_lock); in lan8814_ptp_perout()
3162 ts_on.tv_sec = rq->perout.on.sec; in lan8814_ptp_perout()
3163 ts_on.tv_nsec = rq->perout.on.nsec; in lan8814_ptp_perout()
3166 ts_period.tv_sec = rq->perout.period.sec; in lan8814_ptp_perout()
3167 ts_period.tv_nsec = rq->perout.period.nsec; in lan8814_ptp_perout()
3173 mutex_unlock(&shared->shared_lock); in lan8814_ptp_perout()
3174 return -EOPNOTSUPP; in lan8814_ptp_perout()
3180 mutex_unlock(&shared->shared_lock); in lan8814_ptp_perout()
3181 return -EINVAL; in lan8814_ptp_perout()
3224 case 100: in lan8814_ptp_perout()
3228 pr_warn_ratelimited("%s: Use default duty cycle of 100ns\n", in lan8814_ptp_perout()
3236 lan8814_ptp_set_target(phydev, event, rq->perout.start.sec, in lan8814_ptp_perout()
3237 rq->perout.start.nsec); in lan8814_ptp_perout()
3238 lan8814_ptp_set_reload(phydev, event, rq->perout.period.sec, in lan8814_ptp_perout()
3239 rq->perout.period.nsec); in lan8814_ptp_perout()
3241 mutex_unlock(&shared->shared_lock); in lan8814_ptp_perout()
3310 struct phy_device *phydev = shared->phydev; in lan8814_ptp_extts()
3313 if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | in lan8814_ptp_extts()
3316 return -EOPNOTSUPP; in lan8814_ptp_extts()
3318 pin = ptp_find_pin(shared->ptp_clock, PTP_PF_EXTTS, in lan8814_ptp_extts()
3319 rq->extts.index); in lan8814_ptp_extts()
3320 if (pin == -1 || pin != LAN8814_PTP_EXTTS_NUM) in lan8814_ptp_extts()
3321 return -EINVAL; in lan8814_ptp_extts()
3323 mutex_lock(&shared->shared_lock); in lan8814_ptp_extts()
3325 lan8814_ptp_extts_on(phydev, pin, rq->extts.flags); in lan8814_ptp_extts()
3329 mutex_unlock(&shared->shared_lock); in lan8814_ptp_extts()
3337 switch (rq->type) { in lan8814_ptpci_enable()
3343 return -EINVAL; in lan8814_ptpci_enable()
3358 return -1; in lan8814_ptpci_verify()
3362 return -1; in lan8814_ptpci_verify()
3365 return -1; in lan8814_ptpci_verify()
3382 *sig = (__force u16)(ntohs(ptp_header->sequence_id)); in lan8814_get_sig_tx()
3395 spin_lock_irqsave(&ptp_priv->tx_queue.lock, flags); in lan8814_match_tx_skb()
3396 skb_queue_walk_safe(&ptp_priv->tx_queue, skb, skb_tmp) { in lan8814_match_tx_skb()
3403 __skb_unlink(skb, &ptp_priv->tx_queue); in lan8814_match_tx_skb()
3407 spin_unlock_irqrestore(&ptp_priv->tx_queue.lock, flags); in lan8814_match_tx_skb()
3418 struct phy_device *phydev = ptp_priv->phydev; in lan8814_dequeue_tx_skb()
3428 struct phy_device *phydev = ptp_priv->phydev; in lan8814_get_tx_ts()
3450 spin_lock_irqsave(&ptp_priv->rx_queue.lock, flags); in lan8814_match_skb()
3451 skb_queue_walk_safe(&ptp_priv->rx_queue, skb, skb_tmp) { in lan8814_match_skb()
3455 if (memcmp(&skb_sig, &rx_ts->seq_id, sizeof(rx_ts->seq_id))) in lan8814_match_skb()
3458 __skb_unlink(skb, &ptp_priv->rx_queue); in lan8814_match_skb()
3463 spin_unlock_irqrestore(&ptp_priv->rx_queue.lock, flags); in lan8814_match_skb()
3468 shhwtstamps->hwtstamp = ktime_set(rx_ts->seconds, rx_ts->nsec); in lan8814_match_skb()
3484 spin_lock_irqsave(&ptp_priv->rx_ts_lock, flags); in lan8814_match_rx_ts()
3485 list_add(&rx_ts->list, &ptp_priv->rx_ts_list); in lan8814_match_rx_ts()
3486 spin_unlock_irqrestore(&ptp_priv->rx_ts_lock, flags); in lan8814_match_rx_ts()
3494 struct phy_device *phydev = ptp_priv->phydev; in lan8814_get_rx_ts()
3503 lan8814_ptp_rx_ts_get(phydev, &rx_ts->seconds, &rx_ts->nsec, in lan8814_get_rx_ts()
3504 &rx_ts->seq_id); in lan8814_get_rx_ts()
3516 struct kszphy_priv *priv = phydev->priv; in lan8814_handle_ptp_interrupt()
3517 struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; in lan8814_handle_ptp_interrupt()
3527 skb_queue_purge(&ptp_priv->tx_queue); in lan8814_handle_ptp_interrupt()
3532 skb_queue_purge(&ptp_priv->rx_queue); in lan8814_handle_ptp_interrupt()
3538 struct phy_device *phydev = shared->phydev; in lan8814_gpio_process_cap()
3554 return -1; in lan8814_gpio_process_cap()
3577 ptp_clock_event(shared->ptp_clock, &ptp_event); in lan8814_gpio_process_cap()
3584 struct lan8814_shared_priv *shared = phydev->shared->priv; in lan8814_handle_gpio_interrupt()
3587 mutex_lock(&shared->shared_lock); in lan8814_handle_gpio_interrupt()
3589 mutex_unlock(&shared->shared_lock); in lan8814_handle_gpio_interrupt()
3598 /* MDI-X setting for swap A,B transmit */ in lan8804_config_init()
3645 /* By default interrupt buffer is open-drain in which case the interrupt in lan8804_config_intr()
3647 * push-pull to be able to change interrupt polarity in lan8804_config_intr()
3652 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in lan8804_config_intr()
3723 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in lan8814_config_intr()
3742 struct kszphy_priv *priv = phydev->priv; in lan8814_ptp_init()
3743 struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; in lan8814_ptp_init()
3775 skb_queue_head_init(&ptp_priv->tx_queue); in lan8814_ptp_init()
3776 skb_queue_head_init(&ptp_priv->rx_queue); in lan8814_ptp_init()
3777 INIT_LIST_HEAD(&ptp_priv->rx_ts_list); in lan8814_ptp_init()
3778 spin_lock_init(&ptp_priv->rx_ts_lock); in lan8814_ptp_init()
3780 ptp_priv->phydev = phydev; in lan8814_ptp_init()
3782 ptp_priv->mii_ts.rxtstamp = lan8814_rxtstamp; in lan8814_ptp_init()
3783 ptp_priv->mii_ts.txtstamp = lan8814_txtstamp; in lan8814_ptp_init()
3784 ptp_priv->mii_ts.hwtstamp = lan8814_hwtstamp; in lan8814_ptp_init()
3785 ptp_priv->mii_ts.ts_info = lan8814_ts_info; in lan8814_ptp_init()
3787 phydev->mii_ts = &ptp_priv->mii_ts; in lan8814_ptp_init()
3790 phydev->default_timestamp = true; in lan8814_ptp_init()
3795 struct lan8814_shared_priv *shared = phydev->shared->priv; in lan8814_ptp_probe_once()
3798 mutex_init(&shared->shared_lock); in lan8814_ptp_probe_once()
3800 shared->pin_config = devm_kmalloc_array(&phydev->mdio.dev, in lan8814_ptp_probe_once()
3802 sizeof(*shared->pin_config), in lan8814_ptp_probe_once()
3804 if (!shared->pin_config) in lan8814_ptp_probe_once()
3805 return -ENOMEM; in lan8814_ptp_probe_once()
3808 struct ptp_pin_desc *ptp_pin = &shared->pin_config[i]; in lan8814_ptp_probe_once()
3811 snprintf(ptp_pin->name, in lan8814_ptp_probe_once()
3812 sizeof(ptp_pin->name), "lan8814_ptp_pin_%02d", i); in lan8814_ptp_probe_once()
3813 ptp_pin->index = i; in lan8814_ptp_probe_once()
3814 ptp_pin->func = PTP_PF_NONE; in lan8814_ptp_probe_once()
3817 shared->ptp_clock_info.owner = THIS_MODULE; in lan8814_ptp_probe_once()
3818 snprintf(shared->ptp_clock_info.name, 30, "%s", phydev->drv->name); in lan8814_ptp_probe_once()
3819 shared->ptp_clock_info.max_adj = 31249999; in lan8814_ptp_probe_once()
3820 shared->ptp_clock_info.n_alarm = 0; in lan8814_ptp_probe_once()
3821 shared->ptp_clock_info.n_ext_ts = LAN8814_PTP_EXTTS_NUM; in lan8814_ptp_probe_once()
3822 shared->ptp_clock_info.n_pins = LAN8814_PTP_GPIO_NUM; in lan8814_ptp_probe_once()
3823 shared->ptp_clock_info.pps = 0; in lan8814_ptp_probe_once()
3824 shared->ptp_clock_info.pin_config = shared->pin_config; in lan8814_ptp_probe_once()
3825 shared->ptp_clock_info.n_per_out = LAN8814_PTP_PEROUT_NUM; in lan8814_ptp_probe_once()
3826 shared->ptp_clock_info.adjfine = lan8814_ptpci_adjfine; in lan8814_ptp_probe_once()
3827 shared->ptp_clock_info.adjtime = lan8814_ptpci_adjtime; in lan8814_ptp_probe_once()
3828 shared->ptp_clock_info.gettime64 = lan8814_ptpci_gettime64; in lan8814_ptp_probe_once()
3829 shared->ptp_clock_info.settime64 = lan8814_ptpci_settime64; in lan8814_ptp_probe_once()
3830 shared->ptp_clock_info.getcrosststamp = NULL; in lan8814_ptp_probe_once()
3831 shared->ptp_clock_info.enable = lan8814_ptpci_enable; in lan8814_ptp_probe_once()
3832 shared->ptp_clock_info.verify = lan8814_ptpci_verify; in lan8814_ptp_probe_once()
3834 shared->ptp_clock = ptp_clock_register(&shared->ptp_clock_info, in lan8814_ptp_probe_once()
3835 &phydev->mdio.dev); in lan8814_ptp_probe_once()
3836 if (IS_ERR(shared->ptp_clock)) { in lan8814_ptp_probe_once()
3838 PTR_ERR(shared->ptp_clock)); in lan8814_ptp_probe_once()
3839 return -EINVAL; in lan8814_ptp_probe_once()
3843 if (!shared->ptp_clock) in lan8814_ptp_probe_once()
3848 shared->phydev = phydev; in lan8814_ptp_probe_once()
3879 struct kszphy_priv *lan8814 = phydev->priv; in lan8814_config_init()
3892 /* MDI-X setting for swap A,B transmit */ in lan8814_config_init()
3898 if (lan8814->led_mode >= 0) in lan8814_config_init()
3899 lan8814_setup_led(phydev, lan8814->led_mode); in lan8814_config_init()
3913 gpiod = devm_gpiod_get_optional(&phydev->mdio.dev, "coma-mode", in lan8814_release_coma_mode()
3943 * longer than 100m to be used. This configuration can be used in lan8814_update_meas_time()
3954 const struct kszphy_type *type = phydev->drv->driver_data; in lan8814_probe()
3959 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in lan8814_probe()
3961 return -ENOMEM; in lan8814_probe()
3963 phydev->priv = priv; in lan8814_probe()
3965 priv->type = type; in lan8814_probe()
3969 /* Strap-in value for PHY address, below register read gives starting in lan8814_probe()
3973 devm_phy_package_join(&phydev->mdio.dev, phydev, in lan8814_probe()
4073 /* 100BT Clause 40 improvenent errata */ in lan8841_config_init()
4081 /* 10M/100M Ethernet Signal Tuning Errata for Shorted-Center Tap in lan8841_config_init()
4105 /* 100BT RGMII latency tuning errata */ in lan8841_config_init()
4127 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in lan8841_config_intr()
4168 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_get_tx_ts()
4202 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_flush_fifo()
4225 struct phy_device *phydev = ptp_priv->phydev; in lan8841_gpio_process_cap()
4230 pin = ptp_find_pin_unlocked(ptp_priv->ptp_clock, PTP_PF_EXTTS, 0); in lan8841_gpio_process_cap()
4231 if (pin == -1) in lan8841_gpio_process_cap()
4243 mutex_lock(&ptp_priv->ptp_lock); in lan8841_gpio_process_cap()
4261 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_gpio_process_cap()
4269 ptp_clock_event(ptp_priv->ptp_clock, &ptp_event); in lan8841_gpio_process_cap()
4274 struct kszphy_priv *priv = phydev->priv; in lan8841_handle_ptp_interrupt()
4275 struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; in lan8841_handle_ptp_interrupt()
4289 skb_queue_purge(&ptp_priv->tx_queue); in lan8841_handle_ptp_interrupt()
4330 info->phc_index = ptp_priv->ptp_clock ? in lan8841_ts_info()
4331 ptp_clock_index(ptp_priv->ptp_clock) : -1; in lan8841_ts_info()
4332 if (info->phc_index == -1) in lan8841_ts_info()
4335 info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | in lan8841_ts_info()
4339 info->tx_types = (1 << HWTSTAMP_TX_OFF) | in lan8841_ts_info()
4343 info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) | in lan8841_ts_info()
4358 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_enable_processing()
4361 /* Enable interrupts on the TX side */ in lan8841_ptp_enable_processing()
4379 ptp_schedule_worker(ptp_priv->ptp_clock, 0); in lan8841_ptp_enable_processing()
4381 /* Disable interrupts on the TX side */ in lan8841_ptp_enable_processing()
4392 ptp_cancel_worker_sync(ptp_priv->ptp_clock); in lan8841_ptp_enable_processing()
4405 struct phy_device *phydev = ptp_priv->phydev; in lan8841_hwtstamp()
4409 ptp_priv->hwts_tx_type = config->tx_type; in lan8841_hwtstamp()
4410 ptp_priv->rx_filter = config->rx_filter; in lan8841_hwtstamp()
4412 switch (config->rx_filter) { in lan8841_hwtstamp()
4414 ptp_priv->layer = 0; in lan8841_hwtstamp()
4415 ptp_priv->version = 0; in lan8841_hwtstamp()
4420 ptp_priv->layer = PTP_CLASS_L4; in lan8841_hwtstamp()
4421 ptp_priv->version = PTP_CLASS_V2; in lan8841_hwtstamp()
4426 ptp_priv->layer = PTP_CLASS_L2; in lan8841_hwtstamp()
4427 ptp_priv->version = PTP_CLASS_V2; in lan8841_hwtstamp()
4432 ptp_priv->layer = PTP_CLASS_L4 | PTP_CLASS_L2; in lan8841_hwtstamp()
4433 ptp_priv->version = PTP_CLASS_V2; in lan8841_hwtstamp()
4436 return -ERANGE; in lan8841_hwtstamp()
4442 if (ptp_priv->layer & PTP_CLASS_L2) { in lan8841_hwtstamp()
4445 } else if (ptp_priv->layer & PTP_CLASS_L4) { in lan8841_hwtstamp()
4458 /* Enable / disable of the TX timestamp in the SYNC frames */ in lan8841_hwtstamp()
4461 ptp_priv->hwts_tx_type == HWTSTAMP_TX_ONESTEP_SYNC ? in lan8841_hwtstamp()
4466 config->rx_filter != HWTSTAMP_FILTER_NONE); in lan8841_hwtstamp()
4468 skb_queue_purge(&ptp_priv->tx_queue); in lan8841_hwtstamp()
4489 if (ptp_priv->rx_filter == HWTSTAMP_FILTER_NONE || in lan8841_rxtstamp()
4493 if ((type & ptp_priv->version) == 0 || (type & ptp_priv->layer) == 0) in lan8841_rxtstamp()
4496 spin_lock_irqsave(&ptp_priv->seconds_lock, flags); in lan8841_rxtstamp()
4497 ts.tv_sec = ptp_priv->seconds; in lan8841_rxtstamp()
4498 spin_unlock_irqrestore(&ptp_priv->seconds_lock, flags); in lan8841_rxtstamp()
4499 ts_header = __be32_to_cpu(header->reserved2); in lan8841_rxtstamp()
4506 ts.tv_sec -= GENMASK(1, 0) + 1; in lan8841_rxtstamp()
4510 shhwtstamps->hwtstamp = in lan8841_rxtstamp()
4513 header->reserved2 = 0; in lan8841_rxtstamp()
4530 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_set_target()
4558 ts->tv_sec + LAN8841_BUFFER_TIME, 0); in lan8841_ptp_update_target()
4569 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_set_reload()
4603 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_settime64()
4608 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_settime64()
4609 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_SEC_LO, lower_16_bits(ts->tv_sec)); in lan8841_ptp_settime64()
4610 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_SEC_MID, upper_16_bits(ts->tv_sec)); in lan8841_ptp_settime64()
4611 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_SEC_HI, upper_32_bits(ts->tv_sec) & 0xffff); in lan8841_ptp_settime64()
4612 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_NS_LO, lower_16_bits(ts->tv_nsec)); in lan8841_ptp_settime64()
4613 phy_write_mmd(phydev, 2, LAN8841_PTP_LTC_SET_NS_HI, upper_16_bits(ts->tv_nsec) & 0x3fff); in lan8841_ptp_settime64()
4619 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_settime64()
4621 spin_lock_irqsave(&ptp_priv->seconds_lock, flags); in lan8841_ptp_settime64()
4622 ptp_priv->seconds = ts->tv_sec; in lan8841_ptp_settime64()
4623 spin_unlock_irqrestore(&ptp_priv->seconds_lock, flags); in lan8841_ptp_settime64()
4640 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_gettime64()
4644 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_gettime64()
4659 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_gettime64()
4670 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_getseconds()
4673 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_getseconds()
4684 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_getseconds()
4699 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_adjtime()
4712 if (delta > 10000000000LL || delta < -10000000000LL) { in lan8841_ptp_adjtime()
4716 ptp->gettime64(ptp, &ts); in lan8841_ptp_adjtime()
4721 ptp->settime64(ptp, &ts); in lan8841_ptp_adjtime()
4725 sec = div_u64_rem(delta < 0 ? -delta : delta, NSEC_PER_SEC, &nsec); in lan8841_ptp_adjtime()
4731 sec--; in lan8841_ptp_adjtime()
4732 nsec = NSEC_PER_SEC - nsec; in lan8841_ptp_adjtime()
4746 nsec -= NSEC_PER_SEC; in lan8841_ptp_adjtime()
4749 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_adjtime()
4766 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_adjtime()
4769 ptp->gettime64(ptp, &ts); in lan8841_ptp_adjtime()
4770 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_adjtime()
4772 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_adjtime()
4785 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_adjfine()
4793 scaled_ppm = -scaled_ppm; in lan8841_ptp_adjfine()
4800 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_adjfine()
4805 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_adjfine()
4819 return -1; in lan8841_ptp_verify()
4832 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_perout_off()
4848 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_perout_on()
4878 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_remove_event()
4883 * pins 0-4 while GPIO_DATA_SEL2 contains GPIO pins 5-9, therefore in lan8841_ptp_remove_event()
4890 tmp = LAN8841_GPIO_DATA_SEL_GPIO_DATA_SEL_EVENT_MASK << (3 * (pin - 5)); in lan8841_ptp_remove_event()
4909 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_enable_event()
4930 * pins 0-4 while GPIO_DATA_SEL2 contains GPIO pins 5-9, therefore in lan8841_ptp_enable_event()
4943 tmp << (3 * (pin - 5))); in lan8841_ptp_enable_event()
4968 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_perout()
4975 if (rq->perout.flags & ~PTP_PEROUT_DUTY_CYCLE) in lan8841_ptp_perout()
4976 return -EOPNOTSUPP; in lan8841_ptp_perout()
4978 pin = ptp_find_pin(ptp_priv->ptp_clock, PTP_PF_PEROUT, rq->perout.index); in lan8841_ptp_perout()
4979 if (pin == -1 || pin >= LAN8841_PTP_GPIO_NUM) in lan8841_ptp_perout()
4980 return -EINVAL; in lan8841_ptp_perout()
4990 ts_on.tv_sec = rq->perout.on.sec; in lan8841_ptp_perout()
4991 ts_on.tv_nsec = rq->perout.on.nsec; in lan8841_ptp_perout()
4994 ts_period.tv_sec = rq->perout.period.sec; in lan8841_ptp_perout()
4995 ts_period.tv_nsec = rq->perout.period.nsec; in lan8841_ptp_perout()
5001 return -EOPNOTSUPP; in lan8841_ptp_perout()
5007 return -EINVAL; in lan8841_ptp_perout()
5050 case 100: in lan8841_ptp_perout()
5054 pr_warn_ratelimited("%s: Use default duty cycle of 100ns\n", in lan8841_ptp_perout()
5060 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_perout()
5061 ret = lan8841_ptp_set_target(ptp_priv, LAN8841_EVENT_A, rq->perout.start.sec, in lan8841_ptp_perout()
5062 rq->perout.start.nsec); in lan8841_ptp_perout()
5063 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_perout()
5067 ret = lan8841_ptp_set_reload(ptp_priv, LAN8841_EVENT_A, rq->perout.period.sec, in lan8841_ptp_perout()
5068 rq->perout.period.nsec); in lan8841_ptp_perout()
5092 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_extts_on()
5122 struct phy_device *phydev = ptp_priv->phydev; in lan8841_ptp_extts_off()
5157 if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | in lan8841_ptp_extts()
5160 return -EOPNOTSUPP; in lan8841_ptp_extts()
5162 pin = ptp_find_pin(ptp_priv->ptp_clock, PTP_PF_EXTTS, rq->extts.index); in lan8841_ptp_extts()
5163 if (pin == -1 || pin >= LAN8841_PTP_GPIO_NUM) in lan8841_ptp_extts()
5164 return -EINVAL; in lan8841_ptp_extts()
5166 mutex_lock(&ptp_priv->ptp_lock); in lan8841_ptp_extts()
5168 ret = lan8841_ptp_extts_on(ptp_priv, pin, rq->extts.flags); in lan8841_ptp_extts()
5171 mutex_unlock(&ptp_priv->ptp_lock); in lan8841_ptp_extts()
5179 switch (rq->type) { in lan8841_ptp_enable()
5185 return -EOPNOTSUPP; in lan8841_ptp_enable()
5198 lan8841_ptp_getseconds(&ptp_priv->ptp_clock_info, &ts); in lan8841_ptp_do_aux_work()
5200 spin_lock_irqsave(&ptp_priv->seconds_lock, flags); in lan8841_ptp_do_aux_work()
5201 ptp_priv->seconds = ts.tv_sec; in lan8841_ptp_do_aux_work()
5202 spin_unlock_irqrestore(&ptp_priv->seconds_lock, flags); in lan8841_ptp_do_aux_work()
5239 phydev->interface = PHY_INTERFACE_MODE_RGMII_RXID; in lan8841_probe()
5245 priv = phydev->priv; in lan8841_probe()
5246 ptp_priv = &priv->ptp_priv; in lan8841_probe()
5248 ptp_priv->pin_config = devm_kcalloc(&phydev->mdio.dev, in lan8841_probe()
5250 sizeof(*ptp_priv->pin_config), in lan8841_probe()
5252 if (!ptp_priv->pin_config) in lan8841_probe()
5253 return -ENOMEM; in lan8841_probe()
5256 struct ptp_pin_desc *p = &ptp_priv->pin_config[i]; in lan8841_probe()
5258 snprintf(p->name, sizeof(p->name), "pin%d", i); in lan8841_probe()
5259 p->index = i; in lan8841_probe()
5260 p->func = PTP_PF_NONE; in lan8841_probe()
5263 ptp_priv->ptp_clock_info = lan8841_ptp_clock_info; in lan8841_probe()
5264 ptp_priv->ptp_clock_info.pin_config = ptp_priv->pin_config; in lan8841_probe()
5265 ptp_priv->ptp_clock = ptp_clock_register(&ptp_priv->ptp_clock_info, in lan8841_probe()
5266 &phydev->mdio.dev); in lan8841_probe()
5267 if (IS_ERR(ptp_priv->ptp_clock)) { in lan8841_probe()
5269 PTR_ERR(ptp_priv->ptp_clock)); in lan8841_probe()
5270 return -EINVAL; in lan8841_probe()
5273 if (!ptp_priv->ptp_clock) in lan8841_probe()
5277 skb_queue_head_init(&ptp_priv->tx_queue); in lan8841_probe()
5278 ptp_priv->phydev = phydev; in lan8841_probe()
5279 mutex_init(&ptp_priv->ptp_lock); in lan8841_probe()
5280 spin_lock_init(&ptp_priv->seconds_lock); in lan8841_probe()
5282 ptp_priv->mii_ts.rxtstamp = lan8841_rxtstamp; in lan8841_probe()
5283 ptp_priv->mii_ts.txtstamp = lan8814_txtstamp; in lan8841_probe()
5284 ptp_priv->mii_ts.hwtstamp = lan8841_hwtstamp; in lan8841_probe()
5285 ptp_priv->mii_ts.ts_info = lan8841_ts_info; in lan8841_probe()
5287 phydev->mii_ts = &ptp_priv->mii_ts; in lan8841_probe()
5290 phydev->default_timestamp = true; in lan8841_probe()
5297 struct kszphy_priv *priv = phydev->priv; in lan8841_suspend()
5298 struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; in lan8841_suspend()
5300 if (ptp_priv->ptp_clock) in lan8841_suspend()
5301 ptp_cancel_worker_sync(ptp_priv->ptp_clock); in lan8841_suspend()