From: Jonas Jelonek Date: Sun, 18 Jan 2026 17:58:58 +0000 (+0000) Subject: realtek: rtl930x: move SerDes mapping from MDIO to PCS X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a1e1016b4d82dabedcb231dc4fd7fb65ba16736;p=thirdparty%2Fopenwrt.git 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 Link: https://github.com/openwrt/openwrt/pull/21592 Signed-off-by: Robert Marko --- 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 641a6196b90..9ae62bfc4fa 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 c8e10bc0250..31b40038f4f 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 = {