[openwrt/openwrt] realtek: pcs: rtl931x: fix MII mode setting

LEDE Commits lede-commits at lists.infradead.org
Mon Dec 29 08:06:26 PST 2025


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/6614fcb95ef71c666cf3c169754f39c14a03921b

commit 6614fcb95ef71c666cf3c169754f39c14a03921b
Author: Jonas Jelonek <jelonek.jonas at gmail.com>
AuthorDate: Sat Dec 20 21:42:34 2025 +0000

    realtek: pcs: rtl931x: fix MII mode setting
    
    The function 'rtpcs_931x_sds_mii_mode_set' does not correctly write the
    register. It just write a plain value at the determined register
    address. While this works for SerDes with (id mod 4 == 0), it doesn't
    for the other SerDes.
    
    Fix that by using a corresponding shift and writing only some bits
    instead of the whole register.
    
    While at it, drop an unneeded blank line, add comment to explain a bit
    that is set and use the BIT(..) helper for that instead of manual shift.
    
    Signed-off-by: Jonas Jelonek <jelonek.jonas at gmail.com>
    Link: https://github.com/openwrt/openwrt/pull/20736
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

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 bf2110ef53..48b890114f 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
@@ -2381,6 +2381,7 @@ static void rtpcs_931x_sds_mii_mode_set(struct rtpcs_serdes *sds,
 					phy_interface_t mode)
 {
 	u32 val;
+	int shift = ((sds->id & 0x3) << 3);
 
 	switch (mode) {
 	case PHY_INTERFACE_MODE_QSGMII:
@@ -2400,10 +2401,10 @@ static void rtpcs_931x_sds_mii_mode_set(struct rtpcs_serdes *sds,
 		return;
 	}
 
-	val |= (1 << 7);
-
-	regmap_write(sds->ctrl->map,
-		     RTL931X_SERDES_MODE_CTRL + 4 * (sds->id >> 2), val);
+	val |= BIT(7); /* force mode bit */
+	regmap_write_bits(sds->ctrl->map,
+			  RTL931X_SERDES_MODE_CTRL + 4 * (sds->id >> 2),
+			  0xff << shift, val << shift);
 }
 
 static void rtpcs_931x_sds_disable(struct rtpcs_serdes *sds)




More information about the lede-commits mailing list