Lines Matching +full:phy +full:- +full:pma

1 // SPDX-License-Identifier: GPL-2.0
11 #include <linux/pcs/pcs-xpcs.h>
13 #include <linux/phy.h>
17 #include "pcs-xpcs.h"
169 const struct dw_xpcs_compat *compat = &desc->compat[i]; in xpcs_find_compat()
171 for (j = 0; j < compat->num_interfaces; j++) in xpcs_find_compat()
172 if (compat->interface[j] == interface) in xpcs_find_compat()
183 compat = xpcs_find_compat(xpcs->desc, interface); in xpcs_get_an_mode()
185 return -ENODEV; in xpcs_get_an_mode()
187 return compat->an_mode; in xpcs_get_an_mode()
196 for (i = 0; compat->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++) in __xpcs_linkmode_supported()
197 if (compat->supported[i] == linkmode) in __xpcs_linkmode_supported()
208 return mdiodev_c45_read(xpcs->mdiodev, dev, reg); in xpcs_read()
213 return mdiodev_c45_write(xpcs->mdiodev, dev, reg, val); in xpcs_write()
219 return mdiodev_c45_modify_changed(xpcs->mdiodev, dev, reg, mask, set); in xpcs_modify_changed()
254 } while (ret & MDIO_CTRL1_RESET && --retries); in xpcs_poll_reset()
256 return (ret & MDIO_CTRL1_RESET) ? -ETIMEDOUT : 0; in xpcs_poll_reset()
264 switch (compat->an_mode) { in xpcs_soft_reset()
275 return -EINVAL; in xpcs_soft_reset()
287 if ((__state)->link) \
288 dev_warn(&(__xpcs)->mdiodev->dev, ##__args); \
299 return -EFAULT; in xpcs_read_fault_c73()
317 return -EFAULT; in xpcs_read_fault_c73()
333 return -EFAULT; in xpcs_read_fault_c73()
493 phylink_clear(state->lp_advertising, Autoneg); in xpcs_read_lpa_c73()
497 phylink_set(state->lp_advertising, Autoneg); in xpcs_read_lpa_c73()
500 for (i = ARRAY_SIZE(lpa); --i >= 0; ) { in xpcs_read_lpa_c73()
508 mii_c73_mod_linkmode(state->lp_advertising, lpa); in xpcs_read_lpa_c73()
516 unsigned long *adv = state->advertising; in xpcs_get_max_xlgmii_speed()
570 state->pause = MLO_PAUSE_TX | MLO_PAUSE_RX; in xpcs_resolve_pma()
571 state->duplex = DUPLEX_FULL; in xpcs_resolve_pma()
573 switch (state->interface) { in xpcs_resolve_pma()
575 state->speed = SPEED_10000; in xpcs_resolve_pma()
578 state->speed = xpcs_get_max_xlgmii_speed(xpcs, state); in xpcs_resolve_pma()
581 state->speed = SPEED_UNKNOWN; in xpcs_resolve_pma()
595 compat = xpcs_find_compat(xpcs->desc, state->interface); in xpcs_validate()
597 return -EINVAL; in xpcs_validate()
599 /* Populate the supported link modes for this PHY interface type. in xpcs_validate()
603 for (i = 0; compat->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++) in xpcs_validate()
604 set_bit(compat->supported[i], xpcs_supported); in xpcs_validate()
616 const struct dw_xpcs_compat *compat = &xpcs->desc->compat[i]; in xpcs_get_interfaces()
618 for (j = 0; j < compat->num_interfaces; j++) in xpcs_get_interfaces()
619 __set_bit(compat->interface[j], interfaces); in xpcs_get_interfaces()
667 if (xpcs->info.pma == WX_TXGBE_XPCS_PMA_10G_ID) in xpcs_config_aneg_c37_sgmii()
670 /* For AN for C37 SGMII mode, the settings are :- in xpcs_config_aneg_c37_sgmii()
682 * PHY about the link state change after C28 AN is completed in xpcs_config_aneg_c37_sgmii()
683 * between PHY and Link Partner. There is also no need to in xpcs_config_aneg_c37_sgmii()
684 * trigger AN restart for MAC-side SGMII. in xpcs_config_aneg_c37_sgmii()
705 if (xpcs->info.pma == WX_TXGBE_XPCS_PMA_10G_ID) { in xpcs_config_aneg_c37_sgmii()
707 /* Hardware requires it to be PHY side SGMII */ in xpcs_config_aneg_c37_sgmii()
727 if (xpcs->info.pma == WX_TXGBE_XPCS_PMA_10G_ID) in xpcs_config_aneg_c37_sgmii()
749 if (xpcs->info.pma == WX_TXGBE_XPCS_PMA_10G_ID) in xpcs_config_aneg_c37_1000basex()
752 /* According to Chap 7.12, to set 1000BASE-X C37 AN, AN must in xpcs_config_aneg_c37_1000basex()
753 * be disabled first:- in xpcs_config_aneg_c37_1000basex()
755 * 2) VR_MII_AN_CTRL Bit(2:1)[PCS_MODE] = 00b (1000BASE-X C37) in xpcs_config_aneg_c37_1000basex()
773 if (!xpcs->pcs.poll) in xpcs_config_aneg_c37_1000basex()
836 compat = xpcs_find_compat(xpcs->desc, interface); in xpcs_do_config()
838 return -ENODEV; in xpcs_do_config()
840 if (xpcs->info.pma == WX_TXGBE_XPCS_PMA_10G_ID) { in xpcs_do_config()
846 switch (compat->an_mode) { in xpcs_do_config()
873 return -EINVAL; in xpcs_do_config()
876 if (compat->pma_config) { in xpcs_do_config()
877 ret = compat->pma_config(xpcs); in xpcs_do_config()
905 /* The link status bit is latching-low, so it is important to in xpcs_get_state_c73()
906 * avoid unnecessary re-reads of this register to avoid missing in xpcs_get_state_c73()
907 * a link-down event. in xpcs_get_state_c73()
911 state->link = false; in xpcs_get_state_c73()
916 state->link = !!(pcs_stat1 & MDIO_STAT1_LSTATUS); in xpcs_get_state_c73()
925 state->link = 0; in xpcs_get_state_c73()
927 return xpcs_do_config(xpcs, state->interface, NULL, in xpcs_get_state_c73()
932 if (!state->link) in xpcs_get_state_c73()
936 state->advertising); in xpcs_get_state_c73()
938 /* The link status bit is latching-low, so it is important to in xpcs_get_state_c73()
939 * avoid unnecessary re-reads of this register to avoid missing in xpcs_get_state_c73()
940 * a link-down event. in xpcs_get_state_c73()
944 state->link = false; in xpcs_get_state_c73()
948 state->an_complete = xpcs_aneg_done_c73(xpcs, state, compat, in xpcs_get_state_c73()
950 if (!state->an_complete) { in xpcs_get_state_c73()
951 state->link = false; in xpcs_get_state_c73()
957 state->link = false; in xpcs_get_state_c73()
975 state->link = false; in xpcs_get_state_c37_sgmii()
976 state->speed = SPEED_UNKNOWN; in xpcs_get_state_c37_sgmii()
977 state->duplex = DUPLEX_UNKNOWN; in xpcs_get_state_c37_sgmii()
978 state->pause = 0; in xpcs_get_state_c37_sgmii()
990 state->link = true; in xpcs_get_state_c37_sgmii()
995 state->speed = SPEED_1000; in xpcs_get_state_c37_sgmii()
997 state->speed = SPEED_100; in xpcs_get_state_c37_sgmii()
999 state->speed = SPEED_10; in xpcs_get_state_c37_sgmii()
1002 state->duplex = DUPLEX_FULL; in xpcs_get_state_c37_sgmii()
1004 state->duplex = DUPLEX_HALF; in xpcs_get_state_c37_sgmii()
1008 state->link = true; in xpcs_get_state_c37_sgmii()
1016 state->speed = SPEED_1000; in xpcs_get_state_c37_sgmii()
1018 state->speed = SPEED_100; in xpcs_get_state_c37_sgmii()
1020 state->speed = SPEED_10; in xpcs_get_state_c37_sgmii()
1027 state->duplex = DUPLEX_FULL; in xpcs_get_state_c37_sgmii()
1029 state->duplex = DUPLEX_HALF; in xpcs_get_state_c37_sgmii()
1043 state->advertising)) { in xpcs_get_state_c37_1000basex()
1045 state->link = false; in xpcs_get_state_c37_1000basex()
1056 if (!xpcs->pcs.poll) { in xpcs_get_state_c37_1000basex()
1079 state->link = 0; in xpcs_get_state_2500basex()
1083 state->link = !!(ret & DW_VR_MII_MMD_STS_LINK_STS); in xpcs_get_state_2500basex()
1084 if (!state->link) in xpcs_get_state_2500basex()
1087 state->speed = SPEED_2500; in xpcs_get_state_2500basex()
1088 state->pause |= MLO_PAUSE_TX | MLO_PAUSE_RX; in xpcs_get_state_2500basex()
1089 state->duplex = DUPLEX_FULL; in xpcs_get_state_2500basex()
1101 compat = xpcs_find_compat(xpcs->desc, state->interface); in xpcs_get_state()
1105 switch (compat->an_mode) { in xpcs_get_state()
1107 phylink_mii_c45_pcs_get_state(xpcs->mdiodev, state); in xpcs_get_state()
1222 return -ENODEV; in xpcs_get_id()
1232 /* If Device IDs are not all zeros or ones, then 10GBase-X/R or C73 in xpcs_get_id()
1233 * KR/KX4 PCS found. Otherwise fallback to detecting 1000Base-X or C37 in xpcs_get_id()
1250 /* Set the PCS ID if it hasn't been pre-initialized */ in xpcs_get_id()
1251 if (xpcs->info.pcs == DW_XPCS_ID_NATIVE) in xpcs_get_id()
1252 xpcs->info.pcs = id; in xpcs_get_id()
1254 /* Find out PMA/PMD ID from MMD 1 device ID registers */ in xpcs_get_id()
1271 /* Set the PMA ID if it hasn't been pre-initialized */ in xpcs_get_id()
1272 if (xpcs->info.pma == DW_XPCS_PMA_ID_NATIVE) in xpcs_get_id()
1273 xpcs->info.pma = id; in xpcs_get_id()
1380 return ERR_PTR(-ENOMEM); in xpcs_create_data()
1383 xpcs->mdiodev = mdiodev; in xpcs_create_data()
1384 xpcs->pcs.ops = &xpcs_phylink_ops; in xpcs_create_data()
1385 xpcs->pcs.neg_mode = true; in xpcs_create_data()
1386 xpcs->pcs.poll = true; in xpcs_create_data()
1393 mdio_device_put(xpcs->mdiodev); in xpcs_free_data()
1403 struct device *dev = &xpcs->mdiodev->dev; in xpcs_init_clks()
1407 xpcs->clks[i].id = ids[i]; in xpcs_init_clks()
1409 ret = clk_bulk_get_optional(dev, DW_XPCS_NUM_CLKS, xpcs->clks); in xpcs_init_clks()
1413 ret = clk_bulk_prepare_enable(DW_XPCS_NUM_CLKS, xpcs->clks); in xpcs_init_clks()
1422 clk_bulk_disable_unprepare(DW_XPCS_NUM_CLKS, xpcs->clks); in xpcs_clear_clks()
1424 clk_bulk_put(DW_XPCS_NUM_CLKS, xpcs->clks); in xpcs_clear_clks()
1432 info = dev_get_platdata(&xpcs->mdiodev->dev); in xpcs_init_id()
1434 xpcs->info.pcs = DW_XPCS_ID_NATIVE; in xpcs_init_id()
1435 xpcs->info.pma = DW_XPCS_PMA_ID_NATIVE; in xpcs_init_id()
1437 xpcs->info = *info; in xpcs_init_id()
1447 if ((xpcs->info.pcs & desc->mask) != desc->id) in xpcs_init_id()
1450 xpcs->desc = desc; in xpcs_init_id()
1455 if (!xpcs->desc) in xpcs_init_id()
1456 return -ENODEV; in xpcs_init_id()
1465 compat = xpcs_find_compat(xpcs->desc, interface); in xpcs_init_iface()
1467 return -EINVAL; in xpcs_init_iface()
1469 if (xpcs->info.pma == WX_TXGBE_XPCS_PMA_10G_ID) { in xpcs_init_iface()
1470 xpcs->pcs.poll = false; in xpcs_init_iface()
1511 * xpcs_create_mdiodev() - create a DW xPCS instance with the MDIO @addr
1512 * @bus: pointer to the MDIO-bus descriptor for the device to be looked at
1513 * @addr: device MDIO-bus ID
1514 * @interface: requested PHY interface
1516 * Return: a pointer to the DW XPCS handle if successful, otherwise -ENODEV if
1518 * to the data allocation and MDIO-bus communications.
1545 * xpcs_create_fwnode() - Create a DW xPCS instance from @fwnode
1547 * @interface: requested PHY interface
1549 * Return: a pointer to the DW XPCS handle if successful, otherwise -ENODEV if
1551 * bus, -EPROBE_DEFER if the respective MDIO-device instance couldn't be found,
1552 * other negative errno related to the data allocations and MDIO-bus
1562 return ERR_PTR(-ENODEV); in xpcs_create_fwnode()
1566 return ERR_PTR(-EPROBE_DEFER); in xpcs_create_fwnode()