realtek: pcs: add mapping for SerDes hardware mode
authorJonas Jelonek <jelonek.jonas@gmail.com>
Fri, 19 Dec 2025 10:11:06 +0000 (10:11 +0000)
committerHauke Mehrtens <hauke@hauke-m.de>
Tue, 23 Dec 2025 17:53:33 +0000 (18:53 +0100)
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@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/21184
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c

index cdc18c050526bc8970dac198d3dc18716c7cee67..61f73395335c86b59d1fa2eb7d71a08011124e80 100644 (file)
@@ -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 */