]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: pcs: rtl931x: fix SerDes mode application 20736/head
authorJonas Jelonek <jelonek.jonas@gmail.com>
Sat, 20 Dec 2025 23:53:20 +0000 (23:53 +0000)
committerRobert Marko <robimarko@gmail.com>
Mon, 29 Dec 2025 16:06:19 +0000 (17:06 +0100)
The SerDes mode setting at the end of rtpcs_931x_setup_serdes is
currently broken although it is mostly similar to what the SDK does [1].
It prevents several modes from being set, especially fiber modes. This
seems to be one (if not the only) issue for currently missing SFP
support.

Add a small helper function which takes cares of setting the mode, to
keep the still valid different procedure when using XSGMII mode. Only
this helper is called in rtpcs_931x_setup_serdes to keep it clean there.

As a functional change, call mode application in every case, not just
for SGMII, QSGMII and USXGMII. We can assume the SDK is misleading in
this case, either accidentially or on purpose. This makes SFP modules
work in theory. In practice, there still seem to be device-specific
issues which need to be fixed later. These issues may include no link
detection or link flapping.

[1] https://github.com/plappermaul/realtek-doc/blob/f7f85ffc14c6e575ad94f2b427106de533b888fe/sources/rtk-dms1250/src/dal/mango/dal_mango_construct.c#L2266

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

index a28b01d59f4810b69bcfc513e055c93acf038bda..e00e19b1f3113f101e425da99e2b25e1dfeb3d31 100644 (file)
@@ -2476,6 +2476,15 @@ static int rtpcs_931x_sds_set_ip_mode(struct rtpcs_serdes *sds,
        return rtpcs_sds_write_bits(sds, 0x1f, 0x9, 11, 6, mode_val);
 }
 
+static int rtpcs_931x_sds_set_mode(struct rtpcs_serdes *sds,
+                                  enum rtpcs_sds_mode hw_mode)
+{
+       if (hw_mode == RTPCS_SDS_MODE_XSGMII)
+               return rtpcs_931x_sds_set_mac_mode(sds, hw_mode);
+       else
+               return rtpcs_931x_sds_set_ip_mode(sds, hw_mode);
+}
+
 static void rtpcs_931x_sds_reset(struct rtpcs_serdes *sds)
 {
        struct rtpcs_ctrl *ctrl = sds->ctrl;
@@ -2951,16 +2960,7 @@ static int rtpcs_931x_setup_serdes(struct rtpcs_serdes *sds,
 
        rtpcs_931x_sds_power(sds, true);
 
-       if (mode == PHY_INTERFACE_MODE_XGMII ||
-           mode == PHY_INTERFACE_MODE_QSGMII ||
-           mode == PHY_INTERFACE_MODE_SGMII ||
-           mode == PHY_INTERFACE_MODE_USXGMII) {
-               if (mode == PHY_INTERFACE_MODE_XGMII)
-                       ret = rtpcs_931x_sds_set_mac_mode(sds, hw_mode);
-               else
-                       ret = rtpcs_931x_sds_set_ip_mode(sds, hw_mode);
-       }
-
+       ret = rtpcs_931x_sds_set_mode(sds, hw_mode);
        if (ret < 0)
                return ret;