]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: pcs: rtl931x: use xsg_write instead of open-coded pattern
authorJonas Jelonek <jelonek.jonas@gmail.com>
Sun, 21 Jun 2026 10:53:59 +0000 (10:53 +0000)
committerJonas Jelonek <jelonek.jonas@gmail.com>
Mon, 22 Jun 2026 11:02:07 +0000 (13:02 +0200)
The xsg_write operation for RTL931x already offers the correct procedure
writing to both page + 0x40 and page + 0x80. Though, this wasn't used
so far because this pattern was still open-coded where needed. Replace
that with the xsg_write helper call.

In clear_symerr, this deliberately changes the exact sequence of
operations a bit. However, this shouldn't have any practical effect and
testing shows no issues.

Link: https://github.com/openwrt/openwrt/pull/23904
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
target/linux/realtek/files-6.18/drivers/net/pcs/pcs-rtl-otto.c

index 0cab0af37d11fcbd09dc3b2130df9c811e3cc8c9..db7c25d39784e4756452d7485e1e05ef5aa64036 100644 (file)
@@ -3178,21 +3178,13 @@ static void rtpcs_931x_sds_clear_symerr(struct rtpcs_serdes *sds,
        case RTPCS_SDS_MODE_SGMII:
        case RTPCS_SDS_MODE_XSGMII:
                for (int i = 0; i < 4; ++i) {
-                       rtpcs_sds_write_bits(sds, 0x41, 0x18, 2, 0, i);
-                       rtpcs_sds_write_bits(sds, 0x41, 0x3, 15, 8, 0x0);
-                       rtpcs_sds_write_bits(sds, 0x41, 0x2, 15, 0, 0x0);
-               }
-
-               for (int i = 0; i < 4; ++i) {
-                       rtpcs_sds_write_bits(sds, 0x81, 0x18, 2, 0, i);
-                       rtpcs_sds_write_bits(sds, 0x81, 0x3, 15, 8, 0x0);
-                       rtpcs_sds_write_bits(sds, 0x81, 0x2, 15, 0, 0x0);
+                       rtpcs_sds_xsg_write_bits(sds, 0x1, 0x18, 2, 0, i);
+                       rtpcs_sds_xsg_write_bits(sds, 0x1, 0x3, 15, 8, 0x0);
+                       rtpcs_sds_xsg_write(sds, 0x1, 0x2, 0x0);
                }
 
-               rtpcs_sds_write_bits(sds, 0x41, 0x0, 15, 0, 0x0);
-               rtpcs_sds_write_bits(sds, 0x41, 0x1, 15, 8, 0x0);
-               rtpcs_sds_write_bits(sds, 0x81, 0x0, 15, 0, 0x0);
-               rtpcs_sds_write_bits(sds, 0x81, 0x1, 15, 8, 0x0);
+               rtpcs_sds_xsg_write(sds, 0x1, 0x0, 0x0);
+               rtpcs_sds_xsg_write_bits(sds, 0x1, 0x1, 15, 8, 0x0);
                break;
        case RTPCS_SDS_MODE_1000BASEX:
                rtpcs_sds_write_bits(sds, 0x41, 0x18, 2, 0, 0x0);
@@ -3540,11 +3532,7 @@ static int rtpcs_931x_sds_config_polarity(struct rtpcs_serdes *sds, unsigned int
 
        /* xsg_*_inv */
        val = (rx_val << 1) | tx_val;
-       ret = rtpcs_sds_write_bits(sds, 0x40, 0x0, 9, 8, val);
-       if (ret)
-               return ret;
-
-       return rtpcs_sds_write_bits(sds, 0x80, 0x0, 9, 8, val);
+       return rtpcs_sds_xsg_write_bits(sds, 0x0, 0x0, 9, 8, val);
 }
 
 static const struct rtpcs_sds_tx_config rtpcs_931x_sds_tx_cfg_v1[] = {
@@ -3804,8 +3792,7 @@ static int rtpcs_931x_sds_config_hw_mode(struct rtpcs_serdes *sds,
                break;
 
        case RTPCS_SDS_MODE_XSGMII:
-               rtpcs_sds_write_bits(sds, 0x40, 0xE, 12, 12, 1);
-               rtpcs_sds_write_bits(sds, 0x80, 0xE, 12, 12, 1);
+               rtpcs_sds_xsg_write_bits(sds, 0x0, 0xe, 12, 12, 0x1);
                break;
 
        case RTPCS_SDS_MODE_USXGMII_10GSXGMII: