[openwrt/openwrt] realtek: pcs: add mapping for SerDes hardware mode

LEDE Commits lede-commits at lists.infradead.org
Tue Dec 23 09:56:38 PST 2025


hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/0f176ef961585d28100ed98011eec9918aba3e51

commit 0f176ef961585d28100ed98011eec9918aba3e51
Author: Jonas Jelonek <jelonek.jonas at gmail.com>
AuthorDate: Fri Dec 19 10:11:06 2025 +0000

    realtek: pcs: add mapping for SerDes hardware mode
    
    Add a generic mapper for mapping the PHY_INTERFACE_MODE_* modes to the
    SerDes hardware modes RTPCS_SDS_MODE_*. This is to be used by all
    subtargets step-by-step and avoids having subtarget-specific code for
    that simple mapping.
    
    Signed-off-by: Jonas Jelonek <jelonek.jonas at gmail.com>
    Link: https://github.com/openwrt/openwrt/pull/21184
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 .../files-6.12/drivers/net/pcs/pcs-rtl-otto.c      | 37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)

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 cdc18c0505..61f7339533 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
@@ -278,6 +278,43 @@ static struct rtpcs_link *rtpcs_phylink_pcs_to_link(struct phylink_pcs *pcs)
 	return container_of(pcs, struct rtpcs_link, pcs);
 }
 
+__maybe_unused
+static int rtpcs_sds_determine_hw_mode(struct rtpcs_serdes *sds,
+                                       phy_interface_t if_mode,
+                                       enum rtpcs_sds_mode *hw_mode)
+{
+	switch (if_mode) {
+	case PHY_INTERFACE_MODE_NA:
+		*hw_mode = RTPCS_SDS_MODE_OFF;
+		break;
+	case PHY_INTERFACE_MODE_1000BASEX:
+		*hw_mode = RTPCS_SDS_MODE_1000BASEX;
+		break;
+	case PHY_INTERFACE_MODE_2500BASEX:
+		*hw_mode = RTPCS_SDS_MODE_2500BASEX;
+		break;
+	case PHY_INTERFACE_MODE_10GBASER:
+		*hw_mode = RTPCS_SDS_MODE_10GBASER;
+		break;
+	case PHY_INTERFACE_MODE_SGMII:
+		*hw_mode = RTPCS_SDS_MODE_SGMII;
+		break;
+	case PHY_INTERFACE_MODE_QSGMII:
+		*hw_mode = RTPCS_SDS_MODE_QSGMII;
+		break;
+	case PHY_INTERFACE_MODE_USXGMII:
+		/* TODO: set this depending on number of links on SerDes */
+		*hw_mode = RTPCS_SDS_MODE_USXGMII_10GSXGMII;
+		break;
+	default:
+		return -ENOTSUPP;
+	}
+
+	/* TODO: check if the particular SerDes supports the mode */
+
+	return 0;
+}
+
 /* Variant-specific functions */
 
 /* RTL838X */




More information about the lede-commits mailing list