[openwrt/openwrt] realtek: rtl930x: move SerDes mapping from MDIO to PCS

LEDE Commits lede-commits at lists.infradead.org
Wed Jan 28 12:10:47 PST 2026


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/0a1e1016b4d82dabedcb231dc4fd7fb65ba16736

commit 0a1e1016b4d82dabedcb231dc4fd7fb65ba16736
Author: Jonas Jelonek <jelonek.jonas at gmail.com>
AuthorDate: Sun Jan 18 17:58:58 2026 +0000

    realtek: rtl930x: move SerDes mapping from MDIO to PCS
    
    For RTL930x, the SerDes MDIO driver performed a slight SerDes ID mapping
    on certain conditions. Instead of keeping this mapping in the MDIO and
    try to extend it for further quirks, lets just be a plain MDIO here and
    let the user (PCS) deal with these complex quirks.
    
    Drop the mapping from the SerDes MDIO driver and move it to the PCS
    driver by leveraging the previously introduced SerDes operations
    structure. Define separate ops which incorporate this mapping and use
    those instead of the generic implementations.
    
    Signed-off-by: Jonas Jelonek <jelonek.jonas at gmail.com>
    Link: https://github.com/openwrt/openwrt/pull/21592
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 .../drivers/net/mdio/mdio-realtek-otto-serdes.c    |  3 --
 .../files-6.12/drivers/net/pcs/pcs-rtl-otto.c      | 32 ++++++++++++++++++++--
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto-serdes.c b/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto-serdes.c
index 641a6196b9..9ae62bfc4f 100644
--- a/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto-serdes.c
+++ b/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto-serdes.c
@@ -326,9 +326,6 @@ static int rtsds_rt93xx_io(struct rtsds_ctrl *ctrl, int sds, int page, int regnu
  */
 static int rtsds_930x_get_backing_sds(int sds, int page)
 {
-	if (sds == 3 && page < 4)
-		return 10;
-
 	return sds;
 }
 
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 c8e10bc025..31b40038f4 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
@@ -932,6 +932,34 @@ static int rtpcs_839x_setup_serdes(struct rtpcs_serdes *sds,
 
 /* RTL930X */
 
+/* 
+ * RTL930X needs a special mapping from logic SerDes ID to physical SerDes ID,
+ * which takes the page into account. This applies to most of read/write calls.
+ */
+static int rtpcs_930x_sds_get_phys_sds_id(int sds_id, int page)
+{
+        if (sds_id == 3 && page < 4)
+                return 10;
+
+        return sds_id;
+}
+
+static int rtpcs_930x_sds_op_read(struct rtpcs_serdes *sds, int page, int regnum, int bithigh,
+				  int bitlow)
+{
+	int sds_id = rtpcs_930x_sds_get_phys_sds_id(sds->id, page);
+
+	return __rtpcs_sds_read_raw(sds->ctrl, sds_id, page, regnum, bithigh, bitlow);
+}
+
+static int rtpcs_930x_sds_op_write(struct rtpcs_serdes *sds, int page, int regnum, int bithigh,
+				   int bitlow, u16 value)
+{
+	int sds_id = rtpcs_930x_sds_get_phys_sds_id(sds->id, page);
+
+	return __rtpcs_sds_write_raw(sds->ctrl, sds_id, page, regnum, bithigh, bitlow, value);
+}
+
 static const u16 rtpcs_930x_sds_regs[] = {
 	0x0194, 0x0194, 0x0194, 0x0194,		/* SDS_MODE_SEL_0 */
 	0x02a0, 0x02a0, 0x02a0, 0x02a0,		/* SDS_MODE_SEL_1 */
@@ -3857,8 +3885,8 @@ static const struct phylink_pcs_ops rtpcs_930x_pcs_ops = {
 };
 
 static const struct rtpcs_serdes_ops rtpcs_930x_sds_ops = {
-	.read			= rtpcs_generic_sds_op_read,
-	.write			= rtpcs_generic_sds_op_write,
+	.read			= rtpcs_930x_sds_op_read,
+	.write			= rtpcs_930x_sds_op_write,
 };
 
 static const struct rtpcs_config rtpcs_930x_cfg = {




More information about the lede-commits mailing list