From ae52a1f314f65822a4c3a75f292816581be22ea1 Mon Sep 17 00:00:00 2001
From: Bhaskar Upadhaya <Bhaskar.Upadhaya@nxp.com>
Date: Wed, 9 Jul 2025 13:23:51 +0300
Subject: [PATCH] phy: Add 2.5G SGMII interface mode

Add 2.5G SGMII interface mode(PHY_INTERFACE_MODE_2500SGMII)
in existing phy_interface list. This is synonymous with
PHY_INTERFACE_MODE_2500BASEX without in-band autoneg used for the sole
purpose of connecting to on-board PHYs (not SFP modules), which we keep
for backwards compatibility with NXP device trees.

Signed-off-by: Bhaskar Upadhaya <Bhaskar.Upadhaya@nxp.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 Documentation/devicetree/bindings/net/ethernet-controller.yaml | 1 +
 drivers/net/phy/phy-core.c                                     | 1 +
 drivers/net/phy/phy_caps.c                                     | 1 +
 drivers/net/phy/phylink.c                                      | 1 +
 include/linux/phy.h                                            | 3 +++
 5 files changed, 7 insertions(+)

--- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml
+++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
@@ -42,6 +42,7 @@ properties:
       - mii-lite
       - gmii
       - sgmii
+      - sgmii-2500
       - psgmii
       - qsgmii
       - qusgmii
--- a/drivers/net/phy/phy-core.c
+++ b/drivers/net/phy/phy-core.c
@@ -178,6 +178,7 @@ int phy_interface_num_ports(phy_interfac
 	case PHY_INTERFACE_MODE_SMII:
 	case PHY_INTERFACE_MODE_1000BASEX:
 	case PHY_INTERFACE_MODE_2500BASEX:
+	case PHY_INTERFACE_MODE_2500SGMII:
 	case PHY_INTERFACE_MODE_5GBASER:
 	case PHY_INTERFACE_MODE_10GBASER:
 	case PHY_INTERFACE_MODE_25GBASER:
--- a/drivers/net/phy/phy_caps.c
+++ b/drivers/net/phy/phy_caps.c
@@ -331,6 +331,7 @@ unsigned long phy_caps_from_interface(ph
 		link_caps |= BIT(LINK_CAPA_1000FD);
 		break;
 
+	case PHY_INTERFACE_MODE_2500SGMII:
 	case PHY_INTERFACE_MODE_2500BASEX:
 		link_caps |= BIT(LINK_CAPA_2500FD);
 		break;
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -274,6 +274,7 @@ static int phylink_interface_max_speed(p
 	case PHY_INTERFACE_MODE_GMII:
 		return SPEED_1000;
 
+	case PHY_INTERFACE_MODE_2500SGMII:
 	case PHY_INTERFACE_MODE_2500BASEX:
 	case PHY_INTERFACE_MODE_10G_QXGMII:
 		return SPEED_2500;
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -136,6 +136,7 @@ typedef enum {
 	PHY_INTERFACE_MODE_100BASEX,
 	PHY_INTERFACE_MODE_1000BASEX,
 	PHY_INTERFACE_MODE_2500BASEX,
+	PHY_INTERFACE_MODE_2500SGMII,
 	PHY_INTERFACE_MODE_5GBASER,
 	PHY_INTERFACE_MODE_RXAUI,
 	PHY_INTERFACE_MODE_XAUI,
@@ -220,6 +221,8 @@ static inline const char *phy_modes(phy_
 		return "gmii";
 	case PHY_INTERFACE_MODE_SGMII:
 		return "sgmii";
+	case PHY_INTERFACE_MODE_2500SGMII:
+		return "sgmii-2500";
 	case PHY_INTERFACE_MODE_TBI:
 		return "tbi";
 	case PHY_INTERFACE_MODE_REVMII:
