From: Claudiu Manoil <[email protected]>

The ENETC pseudo-MACs are proprietary internal links that do not
implement any standard MII interface, so restrict their supported PHY
interface modes to PHY_INTERFACE_MODE_INTERNAL only.

Since pseudo-MACs can operate at any speed between 10Mbps and 25Gbps
in multiples of 10Mbps, set their MAC capabilities to cover the full
range of standard full-duplex speeds: 10/100/1000/2500/5000/10000/
20000/25000 Mbps.

For standalone ENETC (v4), expand the supported interface modes to
include 10GBASER in addition to the existing RGMII, SGMII, 1000BASEX,
2500BASEX and USXGMII modes, with MAC capabilities up to 10G. MAC_1000
is replaced with MAC_1000FD to explicitly exclude 1000M half-duplex,
which is not supported.

Signed-off-by: Claudiu Manoil <[email protected]>
Signed-off-by: Wei Fang <[email protected]>
Reviewed-by: Maxime Chevallier <[email protected]>
---
 drivers/net/ethernet/freescale/enetc/enetc.h  |  2 +-
 .../net/ethernet/freescale/enetc/enetc4_pf.c  |  1 -
 .../freescale/enetc/enetc_pf_common.c         | 44 +++++++++++++------
 3 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h 
b/drivers/net/ethernet/freescale/enetc/enetc.h
index 06a9f1ee0970..8839cfb49bcf 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.h
+++ b/drivers/net/ethernet/freescale/enetc/enetc.h
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
-/* Copyright 2017-2019 NXP */
+/* Copyright 2017-2019, 2025-2026 NXP */
 
 #include <linux/timer.h>
 #include <linux/pci.h>
diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c 
b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
index f24269a48c26..75ee117e9b1d 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
@@ -602,7 +602,6 @@ static void enetc4_mac_config(struct enetc_pf *pf, unsigned 
int mode,
                val |= IFMODE_SGMII;
                break;
        case PHY_INTERFACE_MODE_10GBASER:
-       case PHY_INTERFACE_MODE_XGMII:
        case PHY_INTERFACE_MODE_USXGMII:
                val |= IFMODE_XGMII;
                break;
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c 
b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c
index 3597cb81a7cc..781b22198ca8 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
-/* Copyright 2024 NXP */
+/* Copyright 2024-2026 NXP */
 
 #include <linux/fsl/enetc_mdio.h>
 #include <linux/of_mdio.h>
@@ -359,7 +359,8 @@ static bool enetc_port_has_pcs(struct enetc_pf *pf)
        return (pf->if_mode == PHY_INTERFACE_MODE_SGMII ||
                pf->if_mode == PHY_INTERFACE_MODE_1000BASEX ||
                pf->if_mode == PHY_INTERFACE_MODE_2500BASEX ||
-               pf->if_mode == PHY_INTERFACE_MODE_USXGMII);
+               pf->if_mode == PHY_INTERFACE_MODE_USXGMII ||
+               pf->if_mode == PHY_INTERFACE_MODE_10GBASER);
 }
 
 int enetc_mdiobus_create(struct enetc_pf *pf, struct device_node *node)
@@ -400,25 +401,42 @@ int enetc_phylink_create(struct enetc_ndev_priv *priv, 
struct device_node *node,
 {
        struct enetc_pf *pf = enetc_si_priv(priv->si);
        struct phylink *phylink;
+       unsigned long mac_caps;
        int err;
 
        pf->phylink_config.dev = &priv->ndev->dev;
        pf->phylink_config.type = PHYLINK_NETDEV;
-       pf->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
-               MAC_10 | MAC_100 | MAC_1000 | MAC_2500FD;
 
        __set_bit(PHY_INTERFACE_MODE_INTERNAL,
                  pf->phylink_config.supported_interfaces);
-       __set_bit(PHY_INTERFACE_MODE_SGMII,
-                 pf->phylink_config.supported_interfaces);
-       __set_bit(PHY_INTERFACE_MODE_1000BASEX,
-                 pf->phylink_config.supported_interfaces);
-       __set_bit(PHY_INTERFACE_MODE_2500BASEX,
-                 pf->phylink_config.supported_interfaces);
-       __set_bit(PHY_INTERFACE_MODE_USXGMII,
-                 pf->phylink_config.supported_interfaces);
-       phy_interface_set_rgmii(pf->phylink_config.supported_interfaces);
 
+       mac_caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE;
+       if (!enetc_is_pseudo_mac(priv->si)) {
+               mac_caps |= MAC_10 | MAC_100 | MAC_1000FD | MAC_2500FD;
+
+               __set_bit(PHY_INTERFACE_MODE_SGMII,
+                         pf->phylink_config.supported_interfaces);
+               __set_bit(PHY_INTERFACE_MODE_1000BASEX,
+                         pf->phylink_config.supported_interfaces);
+               __set_bit(PHY_INTERFACE_MODE_2500BASEX,
+                         pf->phylink_config.supported_interfaces);
+               __set_bit(PHY_INTERFACE_MODE_USXGMII,
+                         pf->phylink_config.supported_interfaces);
+
+               if (!is_enetc_rev1(priv->si)) {
+                       mac_caps |= MAC_5000FD | MAC_10000FD;
+                       __set_bit(PHY_INTERFACE_MODE_10GBASER,
+                                 pf->phylink_config.supported_interfaces);
+               }
+
+               
phy_interface_set_rgmii(pf->phylink_config.supported_interfaces);
+       } else {
+               mac_caps |= MAC_10FD | MAC_100FD | MAC_1000FD | MAC_2500FD |
+                           MAC_5000FD | MAC_10000FD | MAC_20000FD |
+                           MAC_25000FD;
+       }
+
+       pf->phylink_config.mac_capabilities = mac_caps;
        phylink = phylink_create(&pf->phylink_config, of_fwnode_handle(node),
                                 pf->if_mode, ops);
        if (IS_ERR(phylink)) {
-- 
2.34.1


Reply via email to