[openwrt/openwrt] realtek: dsa,pcs: rtl931x: let PCS driver setup SerDes

LEDE Commits lede-commits at lists.infradead.org
Sun Oct 19 14:50:31 PDT 2025


hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/4a5de35dbada5d76510030afdd39ddf836e3b459

commit 4a5de35dbada5d76510030afdd39ddf836e3b459
Author: Jonas Jelonek <jelonek.jonas at gmail.com>
AuthorDate: Wed Oct 8 14:21:57 2025 +0000

    realtek: dsa,pcs: rtl931x: let PCS driver setup SerDes
    
    Remove SerDes initialization/configuration calls from the DSA driver in
    'rtl931x_phylink_mac_config' and let our PCS driver setup the SerDes now
    that the driver is able to do that.
    
    pcs_config of the PCS driver is automatically called by phylink, thus
    there's no need to call it on our own.
    
    Note that in rtl931x_phylink_mac_config the MAC is enabled before
    pcs_config is called. While this seems to work, it isn't good and needs
    to be fixed.
    
    Signed-off-by: Jonas Jelonek <jelonek.jonas at gmail.com>
    Link: https://github.com/openwrt/openwrt/pull/20369
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 .../files-6.12/drivers/net/dsa/rtl83xx/dsa.c       | 44 +---------------------
 .../files-6.12/drivers/net/pcs/pcs-rtl-otto.c      |  1 +
 2 files changed, 2 insertions(+), 43 deletions(-)

diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c
index 9e274f357b..fa3ecd816f 100644
--- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c
+++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c
@@ -692,52 +692,11 @@ static void rtl931x_phylink_mac_config(struct dsa_switch *ds, int port,
 {
 	struct rtl838x_switch_priv *priv = ds->priv;
 	int sds_num;
-	u32 reg, band;
+	u32 reg;
 
 	sds_num = priv->ports[port].sds_num;
 	pr_info("%s: speed %d sds_num %d\n", __func__, state->speed, sds_num);
 
-	switch (state->interface) {
-	case PHY_INTERFACE_MODE_1000BASEX:
-		band = rtl931x_sds_cmu_band_get(sds_num, PHY_INTERFACE_MODE_1000BASEX);
-		rtl931x_sds_init(sds_num, PHY_INTERFACE_MODE_1000BASEX);
-		break;
-	case PHY_INTERFACE_MODE_XGMII:
-		band = rtl931x_sds_cmu_band_get(sds_num, PHY_INTERFACE_MODE_XGMII);
-		rtl931x_sds_init(sds_num, PHY_INTERFACE_MODE_XGMII);
-		break;
-	case PHY_INTERFACE_MODE_10GBASER:
-	case PHY_INTERFACE_MODE_10GKR:
-		band = rtl931x_sds_cmu_band_get(sds_num, PHY_INTERFACE_MODE_10GBASER);
-		rtl931x_sds_init(sds_num, PHY_INTERFACE_MODE_10GBASER);
-		break;
-	case PHY_INTERFACE_MODE_USXGMII:
-		/*
-		 * TODO: USXGMII is currently the swiss army knife to declare 10G
-		 * multi port PHYs. Real devices use other modes instead. Especially
-		 *
-		 * - RTL8224 is driven in 10G_QXGMII
-		 * - RTL8218D/E are driven in (Realtek proprietary) XSGMII (10G SGMII)
-		 *
-		 * For now disable all USXGMII SerDes handling and rely on U-Boot setup.
-		 */
-		 break;
-	case PHY_INTERFACE_MODE_SGMII:
-		pr_info("%s setting mode PHY_INTERFACE_MODE_SGMII\n", __func__);
-		band = rtl931x_sds_cmu_band_get(sds_num, PHY_INTERFACE_MODE_SGMII);
-		rtl931x_sds_init(sds_num, PHY_INTERFACE_MODE_SGMII);
-		band = rtl931x_sds_cmu_band_set(sds_num, true, 62, PHY_INTERFACE_MODE_SGMII);
-		break;
-	case PHY_INTERFACE_MODE_QSGMII:
-		band = rtl931x_sds_cmu_band_get(sds_num, PHY_INTERFACE_MODE_QSGMII);
-		rtl931x_sds_init(sds_num, PHY_INTERFACE_MODE_QSGMII);
-		break;
-	default:
-		pr_err("%s: unknown serdes mode: %s\n",
-			__func__, phy_modes(state->interface));
-		return;
-	}
-
 	reg = sw_r32(priv->r->mac_force_mode_ctrl(port));
 	pr_info("%s reading FORCE_MODE_CTRL: %08x\n", __func__, reg);
 
@@ -755,7 +714,6 @@ static void rtl931x_phylink_mac_config(struct dsa_switch *ds, int port,
 		reg |= RTL931X_DUPLEX_MODE;
 
 	sw_w32(reg, priv->r->mac_force_mode_ctrl(port));
-
 }
 
 static void rtl93xx_phylink_mac_config(struct dsa_switch *ds, int port,
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 8cb0c03e64..a0fee490fa 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
@@ -1069,6 +1069,7 @@ static const struct rtpcs_config rtpcs_931x_cfg = {
 	.mac_tx_pause_sts	= RTPCS_931X_MAC_TX_PAUSE_STS,
 	.pcs_ops		= &rtpcs_931x_pcs_ops,
 	.set_autoneg		= rtpcs_93xx_set_autoneg,
+	.setup_serdes		= rtpcs_931x_setup_serdes,
 };
 
 static const struct of_device_id rtpcs_of_match[] = {




More information about the lede-commits mailing list