Lines Matching +full:100 +full:base +full:- +full:fx
1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
19 #include <dt-bindings/net/mscc-phy-vsc8531.h>
122 struct vsc8531_private *priv = phydev->priv; in vsc85xx_get_sset_count()
127 return priv->nstats; in vsc85xx_get_sset_count()
132 struct vsc8531_private *priv = phydev->priv; in vsc85xx_get_strings()
138 for (i = 0; i < priv->nstats; i++) in vsc85xx_get_strings()
139 strscpy(data + i * ETH_GSTRING_LEN, priv->hw_stats[i].string, in vsc85xx_get_strings()
145 struct vsc8531_private *priv = phydev->priv; in vsc85xx_get_stat()
148 val = phy_read_paged(phydev, priv->hw_stats[i].page, in vsc85xx_get_stat()
149 priv->hw_stats[i].reg); in vsc85xx_get_stat()
153 val = val & priv->hw_stats[i].mask; in vsc85xx_get_stat()
154 priv->stats[i] += val; in vsc85xx_get_stat()
156 return priv->stats[i]; in vsc85xx_get_stat()
162 struct vsc8531_private *priv = phydev->priv; in vsc85xx_get_stats()
168 for (i = 0; i < priv->nstats; i++) in vsc85xx_get_stats()
179 mutex_lock(&phydev->lock); in vsc85xx_led_cntl_set()
184 mutex_unlock(&phydev->lock); in vsc85xx_led_cntl_set()
262 return -ERANGE; in vsc85xx_downshift_set()
265 count = (((count - 2) << DOWNSHIFT_CNTL_POS) | DOWNSHIFT_EN); in vsc85xx_downshift_set()
276 const u8 *mac_addr = phydev->attached_dev->dev_addr; in vsc85xx_wol_set()
283 mutex_lock(&phydev->lock); in vsc85xx_wol_set()
290 if (wol->wolopts & WAKE_MAGIC) { in vsc85xx_wol_set()
293 pwd[i] = mac_addr[5 - (i * 2 + 1)] << 8 | in vsc85xx_wol_set()
294 mac_addr[5 - i * 2]; in vsc85xx_wol_set()
304 if (wol_conf->wolopts & WAKE_MAGICSECURE) { in vsc85xx_wol_set()
306 pwd[i] = wol_conf->sopass[5 - (i * 2 + 1)] << 8 | in vsc85xx_wol_set()
307 wol_conf->sopass[5 - i * 2]; in vsc85xx_wol_set()
318 if (wol_conf->wolopts & WAKE_MAGICSECURE) in vsc85xx_wol_set()
328 if (wol->wolopts & WAKE_MAGIC) { in vsc85xx_wol_set()
347 mutex_unlock(&phydev->lock); in vsc85xx_wol_set()
361 mutex_lock(&phydev->lock); in vsc85xx_wol_get()
368 wol_conf->wolopts |= WAKE_MAGICSECURE; in vsc85xx_wol_get()
369 if (wol_conf->wolopts & WAKE_MAGICSECURE) { in vsc85xx_wol_get()
374 wol_conf->sopass[5 - i * 2] = pwd[i] & 0x00ff; in vsc85xx_wol_get()
375 wol_conf->sopass[5 - (i * 2 + 1)] = (pwd[i] & 0xff00) in vsc85xx_wol_get()
382 mutex_unlock(&phydev->lock); in vsc85xx_wol_get()
390 struct device *dev = &phydev->mdio.dev; in vsc85xx_edge_rate_magic_get()
391 struct device_node *of_node = dev->of_node; in vsc85xx_edge_rate_magic_get()
395 return -ENODEV; in vsc85xx_edge_rate_magic_get()
400 if (of_property_read_u32(of_node, "vsc8531,edge-slowdown", &sd)) in vsc85xx_edge_rate_magic_get()
407 return (sd_array_size - j - 1); in vsc85xx_edge_rate_magic_get()
409 return -EINVAL; in vsc85xx_edge_rate_magic_get()
416 struct vsc8531_private *priv = phydev->priv; in vsc85xx_dt_led_mode_get()
417 struct device *dev = &phydev->mdio.dev; in vsc85xx_dt_led_mode_get()
418 struct device_node *of_node = dev->of_node; in vsc85xx_dt_led_mode_get()
423 return -ENODEV; in vsc85xx_dt_led_mode_get()
427 if (!err && !(BIT(led_mode) & priv->supp_led_modes)) { in vsc85xx_dt_led_mode_get()
429 return -EINVAL; in vsc85xx_dt_led_mode_get()
452 struct vsc8531_private *priv = phydev->priv; in vsc85xx_dt_led_modes_get()
456 for (i = 0; i < priv->nleds; i++) { in vsc85xx_dt_led_modes_get()
457 ret = sprintf(led_dt_prop, "vsc8531,led-%d-mode", i); in vsc85xx_dt_led_modes_get()
465 priv->leds_mode[i] = ret; in vsc85xx_dt_led_modes_get()
475 mutex_lock(&phydev->lock); in vsc85xx_edge_rate_cntl_set()
479 mutex_unlock(&phydev->lock); in vsc85xx_edge_rate_cntl_set()
490 mutex_lock(&phydev->lock); in vsc85xx_mac_if_set()
508 rc = -EINVAL; in vsc85xx_mac_if_set()
518 mutex_unlock(&phydev->lock); in vsc85xx_mac_if_set()
534 u16 rgmii_rx_delay_pos = ffs(rgmii_rx_delay_mask) - 1; in vsc85xx_rgmii_set_skews()
535 u16 rgmii_tx_delay_pos = ffs(rgmii_tx_delay_mask) - 1; in vsc85xx_rgmii_set_skews()
539 mutex_lock(&phydev->lock); in vsc85xx_rgmii_set_skews()
541 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID || in vsc85xx_rgmii_set_skews()
542 phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) in vsc85xx_rgmii_set_skews()
544 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID || in vsc85xx_rgmii_set_skews()
545 phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) in vsc85xx_rgmii_set_skews()
553 mutex_unlock(&phydev->lock); in vsc85xx_rgmii_set_skews()
562 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in vsc85xx_default_config()
564 if (phy_interface_mode_is_rgmii(phydev->interface)) { in vsc85xx_default_config()
578 switch (tuna->id) { in vsc85xx_get_tunable()
582 return -EINVAL; in vsc85xx_get_tunable()
590 switch (tuna->id) { in vsc85xx_set_tunable()
594 return -EINVAL; in vsc85xx_set_tunable()
636 mutex_lock(&phydev->lock); in vsc8531_pre_init_seq_set()
646 mutex_unlock(&phydev->lock); in vsc8531_pre_init_seq_set()
676 mutex_lock(&phydev->lock); in vsc85xx_eee_init_seq_set()
686 mutex_unlock(&phydev->lock); in vsc85xx_eee_init_seq_set()
691 /* phydev->bus->mdio_lock should be locked when using this function */
694 if (unlikely(!mutex_is_locked(&phydev->mdio.bus->mdio_lock))) { in phy_base_write()
695 dev_err(&phydev->mdio.dev, "MDIO bus lock not held!\n"); in phy_base_write()
702 /* phydev->bus->mdio_lock should be locked when using this function */
705 if (unlikely(!mutex_is_locked(&phydev->mdio.bus->mdio_lock))) { in phy_base_read()
706 dev_err(&phydev->mdio.dev, "MDIO bus lock not held!\n"); in phy_base_read()
722 * 6-bit Target_ID is split between MSCC_EXT_PAGE_CSR_CNTL_20 and in vsc85xx_csr_read()
733 /* non-MACsec access */ in vsc85xx_csr_read()
738 /* Trigger CSR Action - Read into the CSR's */ in vsc85xx_csr_read()
775 * 6-bit Target_ID is split between MSCC_EXT_PAGE_CSR_CNTL_20 and in vsc85xx_csr_write()
792 /* non-MACsec access */ in vsc85xx_csr_write()
797 /* Trigger CSR Action - Write into the CSR's */ in vsc85xx_csr_write()
812 return -ETIMEDOUT; in vsc85xx_csr_write()
820 /* bus->mdio_lock should be locked when using this function */
828 /* bus->mdio_lock should be locked when using this function */
849 return -EIO; in vsc8584_cmd()
852 return -ETIMEDOUT; in vsc8584_cmd()
857 /* bus->mdio_lock should be locked when using this function */
879 * override and addr. auto-incr; operate at 125 MHz in vsc8584_micro_deassert_reset()
890 /* bus->mdio_lock should be locked when using this function */
933 /* bus->mdio_lock should be locked when using this function */
959 /* bus->mdio_lock should be locked when using this function */
967 dev_err(&phydev->mdio.dev, in vsc8584_patch_fw()
985 for (i = 0; i < fw->size; i++) in vsc8584_patch_fw()
987 INT_MEM_WRITE_EN | fw->data[i]); in vsc8584_patch_fw()
997 /* bus->mdio_lock should be locked when using this function */
1038 /* bus->mdio_lock should be locked when using this function */
1105 struct device *dev = &phydev->mdio.dev; in vsc8574_config_pre_init()
1176 fw->size + 1, &crc); in vsc8574_config_pre_init()
1199 "failed to patch FW, expect non-optimal device\n"); in vsc8574_config_pre_init()
1218 fw->size + 1, &crc); in vsc8574_config_pre_init()
1224 "FW CRC after patching is not the expected one, expect non-optimal device\n"); in vsc8574_config_pre_init()
1327 /* bus->mdio_lock should be locked when using this function */
1360 struct device *dev = &phydev->mdio.dev; in vsc8584_config_pre_init()
1447 fw->size + 1, &crc); in vsc8584_config_pre_init()
1455 "failed to patch FW, expect non-optimal device\n"); in vsc8584_config_pre_init()
1463 fw->size + 1, &crc); in vsc8584_config_pre_init()
1469 "FW CRC after patching is not the expected one, expect non-optimal device\n"); in vsc8584_config_pre_init()
1505 struct vsc8531_private *vsc8531 = phydev->priv; in vsc8584_get_base_addr()
1521 * the base PHY for timestamping operations. in vsc8584_get_base_addr()
1523 vsc8531->ts_base_addr = phydev->mdio.addr; in vsc8584_get_base_addr()
1524 vsc8531->ts_base_phy = addr; in vsc8584_get_base_addr()
1527 vsc8531->base_addr = phydev->mdio.addr + addr; in vsc8584_get_base_addr()
1529 vsc8531->ts_base_addr += 2; in vsc8584_get_base_addr()
1530 vsc8531->ts_base_phy += 2; in vsc8584_get_base_addr()
1533 vsc8531->base_addr = phydev->mdio.addr - addr; in vsc8584_get_base_addr()
1535 vsc8531->ts_base_addr -= 2; in vsc8584_get_base_addr()
1536 vsc8531->ts_base_phy -= 2; in vsc8584_get_base_addr()
1540 vsc8531->addr = addr; in vsc8584_get_base_addr()
1560 struct vsc8531_private *vsc8531 = phydev->priv; in vsc8584_config_host_serdes()
1571 if (phydev->interface == PHY_INTERFACE_MODE_QSGMII) { in vsc8584_config_host_serdes()
1573 } else if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in vsc8584_config_host_serdes()
1576 ret = -EINVAL; in vsc8584_config_host_serdes()
1591 if (phydev->interface == PHY_INTERFACE_MODE_QSGMII) in vsc8584_config_host_serdes()
1602 /* Disable SerDes for 100Base-FX */ in vsc8584_config_host_serdes()
1604 PROC_CMD_FIBER_PORT(vsc8531->addr) | in vsc8584_config_host_serdes()
1611 /* Disable SerDes for 1000Base-X */ in vsc8584_config_host_serdes()
1613 PROC_CMD_FIBER_PORT(vsc8531->addr) | in vsc8584_config_host_serdes()
1625 struct vsc8531_private *vsc8531 = phydev->priv; in vsc8574_config_host_serdes()
1636 if (phydev->interface == PHY_INTERFACE_MODE_QSGMII) { in vsc8574_config_host_serdes()
1638 } else if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { in vsc8574_config_host_serdes()
1643 ret = -EINVAL; in vsc8574_config_host_serdes()
1659 if (phydev->interface == PHY_INTERFACE_MODE_QSGMII) in vsc8574_config_host_serdes()
1671 /* Disable SerDes for 100Base-FX */ in vsc8574_config_host_serdes()
1673 PROC_CMD_FIBER_PORT(vsc8531->addr) | in vsc8574_config_host_serdes()
1680 /* Disable SerDes for 1000Base-X */ in vsc8574_config_host_serdes()
1682 PROC_CMD_FIBER_PORT(vsc8531->addr) | in vsc8574_config_host_serdes()
1690 struct vsc8531_private *vsc8531 = phydev->priv; in vsc8584_config_init()
1694 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in vsc8584_config_init()
1708 * do the correct init sequence for all PHYs that are package-critical in vsc8584_config_init()
1709 * in this pre-init function. in vsc8584_config_init()
1716 WARN_ON(phydev->drv->phy_id_mask & 0xf); in vsc8584_config_init()
1718 switch (phydev->phy_id & phydev->drv->phy_id_mask) { in vsc8584_config_init()
1743 ret = -EINVAL; in vsc8584_config_init()
1781 for (i = 0; i < vsc8531->nleds; i++) { in vsc8584_config_init()
1782 ret = vsc85xx_led_cntl_set(phydev, i, vsc8531->leds_mode[i]); in vsc8584_config_init()
1822 struct vsc8531_private *vsc8531 = phydev->priv; in vsc85xx_config_init()
1828 rc = vsc85xx_mac_if_set(phydev, phydev->interface); in vsc85xx_config_init()
1832 rc = vsc85xx_edge_rate_cntl_set(phydev, vsc8531->rate_magic); in vsc85xx_config_init()
1836 phy_id = phydev->drv->phy_id & phydev->drv->phy_id_mask; in vsc85xx_config_init()
1848 for (i = 0; i < vsc8531->nleds; i++) { in vsc85xx_config_init()
1849 rc = vsc85xx_led_cntl_set(phydev, i, vsc8531->leds_mode[i]); in vsc85xx_config_init()
1867 return -EINVAL; in __phy_write_mcb_s6g()
1875 return -EIO; in __phy_write_mcb_s6g()
1880 return -ETIMEDOUT; in __phy_write_mcb_s6g()
1928 dev_err(&phydev->mdio.dev, "%s: QSGMII error: %d\n", in vsc8514_config_host_serdes()
1955 * are set at Power-On state and remain until PHY Reset. in vsc8514_config_pre_init()
1979 struct device *dev = &phydev->mdio.dev; in vsc8514_config_pre_init()
2020 /* Add pre-patching commands to: in vsc8514_config_pre_init()
2060 struct vsc8531_private *vsc8531 = phydev->priv; in vsc8514_config_init()
2063 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in vsc8514_config_init()
2075 * do the correct init sequence for all PHYs that are package-critical in vsc8514_config_init()
2076 * in this pre-init function. in vsc8514_config_init()
2101 for (i = 0; i < vsc8531->nleds; i++) { in vsc8514_config_init()
2102 ret = vsc85xx_led_cntl_set(phydev, i, vsc8531->leds_mode[i]); in vsc8514_config_init()
2118 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) in vsc85xx_ack_interrupt()
2128 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in vsc85xx_config_intr()
2174 rc = vsc85xx_mdix_set(phydev, phydev->mdix_ctrl); in vsc85xx_config_aneg()
2185 rc = vsc85xx_mdix_get(phydev, &phydev->mdix); in vsc85xx_read_status()
2199 vsc8531 = devm_kzalloc(&phydev->mdio.dev, sizeof(*vsc8531), GFP_KERNEL); in vsc8514_probe()
2201 return -ENOMEM; in vsc8514_probe()
2203 phydev->priv = vsc8531; in vsc8514_probe()
2206 devm_phy_package_join(&phydev->mdio.dev, phydev, in vsc8514_probe()
2207 vsc8531->base_addr, 0); in vsc8514_probe()
2209 vsc8531->nleds = 4; in vsc8514_probe()
2210 vsc8531->supp_led_modes = VSC85XX_SUPP_LED_MODES; in vsc8514_probe()
2211 vsc8531->hw_stats = vsc85xx_hw_stats; in vsc8514_probe()
2212 vsc8531->nstats = ARRAY_SIZE(vsc85xx_hw_stats); in vsc8514_probe()
2213 vsc8531->stats = devm_kcalloc(&phydev->mdio.dev, vsc8531->nstats, in vsc8514_probe()
2215 if (!vsc8531->stats) in vsc8514_probe()
2216 return -ENOMEM; in vsc8514_probe()
2228 vsc8531 = devm_kzalloc(&phydev->mdio.dev, sizeof(*vsc8531), GFP_KERNEL); in vsc8574_probe()
2230 return -ENOMEM; in vsc8574_probe()
2232 phydev->priv = vsc8531; in vsc8574_probe()
2235 devm_phy_package_join(&phydev->mdio.dev, phydev, in vsc8574_probe()
2236 vsc8531->base_addr, 0); in vsc8574_probe()
2238 vsc8531->nleds = 4; in vsc8574_probe()
2239 vsc8531->supp_led_modes = VSC8584_SUPP_LED_MODES; in vsc8574_probe()
2240 vsc8531->hw_stats = vsc8584_hw_stats; in vsc8574_probe()
2241 vsc8531->nstats = ARRAY_SIZE(vsc8584_hw_stats); in vsc8574_probe()
2242 vsc8531->stats = devm_kcalloc(&phydev->mdio.dev, vsc8531->nstats, in vsc8574_probe()
2244 if (!vsc8531->stats) in vsc8574_probe()
2245 return -ENOMEM; in vsc8574_probe()
2258 if ((phydev->phy_id & MSCC_DEV_REV_MASK) != VSC8584_REVB) { in vsc8584_probe()
2259 dev_err(&phydev->mdio.dev, "Only VSC8584 revB is supported.\n"); in vsc8584_probe()
2260 return -ENOTSUPP; in vsc8584_probe()
2263 vsc8531 = devm_kzalloc(&phydev->mdio.dev, sizeof(*vsc8531), GFP_KERNEL); in vsc8584_probe()
2265 return -ENOMEM; in vsc8584_probe()
2267 phydev->priv = vsc8531; in vsc8584_probe()
2270 devm_phy_package_join(&phydev->mdio.dev, phydev, vsc8531->base_addr, in vsc8584_probe()
2273 vsc8531->nleds = 4; in vsc8584_probe()
2274 vsc8531->supp_led_modes = VSC8584_SUPP_LED_MODES; in vsc8584_probe()
2275 vsc8531->hw_stats = vsc8584_hw_stats; in vsc8584_probe()
2276 vsc8531->nstats = ARRAY_SIZE(vsc8584_hw_stats); in vsc8584_probe()
2277 vsc8531->stats = devm_kcalloc(&phydev->mdio.dev, vsc8531->nstats, in vsc8584_probe()
2279 if (!vsc8531->stats) in vsc8584_probe()
2280 return -ENOMEM; in vsc8584_probe()
2306 vsc8531 = devm_kzalloc(&phydev->mdio.dev, sizeof(*vsc8531), GFP_KERNEL); in vsc85xx_probe()
2308 return -ENOMEM; in vsc85xx_probe()
2310 phydev->priv = vsc8531; in vsc85xx_probe()
2312 vsc8531->rate_magic = rate_magic; in vsc85xx_probe()
2313 vsc8531->nleds = 2; in vsc85xx_probe()
2314 vsc8531->supp_led_modes = VSC85XX_SUPP_LED_MODES; in vsc85xx_probe()
2315 vsc8531->hw_stats = vsc85xx_hw_stats; in vsc85xx_probe()
2316 vsc8531->nstats = ARRAY_SIZE(vsc85xx_hw_stats); in vsc85xx_probe()
2317 vsc8531->stats = devm_kcalloc(&phydev->mdio.dev, vsc8531->nstats, in vsc85xx_probe()
2319 if (!vsc8531->stats) in vsc85xx_probe()
2320 return -ENOMEM; in vsc85xx_probe()