[openwrt/openwrt] realtek: pcs: drop PCS creation without SerDes ref

LEDE Commits lede-commits at lists.infradead.org
Tue Dec 16 04:38:17 PST 2025


robimarko pushed a commit to openwrt/openwrt.git, branch openwrt-25.12:
https://git.openwrt.org/e989bf80a86147acb8444e13db5e298f55a2a728

commit e989bf80a86147acb8444e13db5e298f55a2a728
Author: Jonas Jelonek <jelonek.jonas at gmail.com>
AuthorDate: Thu Dec 11 22:37:33 2025 +0000

    realtek: pcs: drop PCS creation without SerDes ref
    
    Since the beginning, the PCS driver had the ability to call its
    rtpcs_create without a reference to a valid PCS node. A comment in the
    code mentions that this is done for RTL838X and its built-in octa-PHY
    which is connected directly instead of via a SerDes. Further
    explanations are not provided.
    
    Drop this ability and make the rtpcs_create call in the dsa driver
    conditional. As the built-in PHY of RTL838X isn't attached to a SerDes,
    there is no obvious point of having the PCS driver in that chain. The
    ports are marked as internal and have no pcs-handle, thus no phylink_pcs
    instance should be created.
    
    Signed-off-by: Jonas Jelonek <jelonek.jonas at gmail.com>
    Link: https://github.com/openwrt/openwrt/pull/21146
    Signed-off-by: Robert Marko <robimarko at gmail.com>
    (cherry picked from commit a58e41e522bf5b273fa626e03546b92141731d9c)
---
 .../files-6.12/drivers/net/dsa/rtl83xx/common.c    | 14 +++++++-----
 .../files-6.12/drivers/net/pcs/pcs-rtl-otto.c      | 26 ++++++----------------
 2 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
index 85818391b5..787ceda834 100644
--- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
+++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
@@ -331,12 +331,14 @@ static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
 			continue;
 		}
 
-		priv->pcs[pn] = rtpcs_create(priv->dev, pcs_node, pn);
-		if (IS_ERR(priv->pcs[pn])) {
-			dev_err(priv->dev, "port %u failed to create PCS instance: %ld\n",
-				pn, PTR_ERR(priv->pcs[pn]));
-			priv->pcs[pn] = NULL;
-			continue;
+		if (pcs_node) {
+			priv->pcs[pn] = rtpcs_create(priv->dev, pcs_node, pn);
+			if (IS_ERR(priv->pcs[pn])) {
+				dev_err(priv->dev, "port %u failed to create PCS instance: %ld\n",
+					pn, PTR_ERR(priv->pcs[pn]));
+				priv->pcs[pn] = NULL;
+				continue;
+			}
 		}
 
 		if (of_get_phy_mode(dn, &interface))
diff --git a/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c b/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c
index e41c89e713..8368870b62 100644
--- a/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c
+++ b/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c
@@ -2930,26 +2930,12 @@ struct phylink_pcs *rtpcs_create(struct device *dev, struct device_node *np, int
 	struct device_node *pcs_np;
 	struct rtpcs_ctrl *ctrl;
 	struct rtpcs_link *link;
-	int sds;
-
-	/*
-	 * RTL838x devices have a built-in octa port RTL8218B PHY that is not attached via
-	 * a SerDes. Allow to be called with an empty SerDes device node. In this case lookup
-	 * the parent/driver node directly.
-	 */
-	if (np) {
-		if (!of_device_is_available(np))
-			return ERR_PTR(-ENODEV);
-
-		if (of_property_read_u32(np, "reg", &sds))
-			return ERR_PTR(-EINVAL);
+	u32 sds;
 
-		pcs_np = of_get_parent(np);
-	} else {
-		pcs_np = of_find_compatible_node(NULL, NULL, "realtek,otto-pcs");
-		sds = -1;
-	}
+	if (!np || !of_device_is_available(np))
+		return ERR_PTR(-ENODEV);
 
+	pcs_np = of_get_parent(np);
 	if (!pcs_np)
 		return ERR_PTR(-ENODEV);
 
@@ -2972,7 +2958,9 @@ struct phylink_pcs *rtpcs_create(struct device *dev, struct device_node *np, int
 	if (port < 0 || port > ctrl->cfg->cpu_port)
 		return ERR_PTR(-EINVAL);
 
-	if (sds !=  -1 && rtpcs_sds_read(ctrl, sds, 0, 0) < 0)
+	if (of_property_read_u32(np, "reg", &sds))
+		return ERR_PTR(-EINVAL);
+	if (rtpcs_sds_read(ctrl, sds, 0, 0) < 0)
 		return ERR_PTR(-EINVAL);
 
 	link = kzalloc(sizeof(*link), GFP_KERNEL);




More information about the lede-commits mailing list