]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: pcs: rtl93xx: extract MAC-driven mode bring-up helper
authorJonas Jelonek <jelonek.jonas@gmail.com>
Thu, 4 Jun 2026 22:30:17 +0000 (22:30 +0000)
committerJonas Jelonek <jelonek.jonas@gmail.com>
Sat, 6 Jun 2026 07:54:57 +0000 (09:54 +0200)
The MAC-driven set_mode path on RTL930x performs three steps: release the
IP mode force-lock so the MAC side takes over (deactivate forces IP=OFF),
write the MAC mode, then apply the USXGMII submode for modes that need
one. Pull these into a shared rtpcs_93xx_sds_set_mac_driven_mode() helper.

No functional change: rtpcs_930x_sds_set_mode now calls the helper instead
of open-coding the sequence. This prepares the helper for reuse by the
RTL931x XSGMII path, which currently lacks the IP force-unlock and so is
left pinned OFF by a preceding deactivate.

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

index b48d790090161444444e73b82d35cdeea59be175..103387f26296d7869959a8e9c7b3b012a76902a5 100644 (file)
@@ -1508,6 +1508,27 @@ static int rtpcs_93xx_sds_set_mac_mode(struct rtpcs_serdes *sds, enum rtpcs_sds_
        return 0;
 }
 
+/*
+ * Bring up a MAC-driven mode: release the IP mode force-lock so the MAC
+ * side takes over (deactivate forces IP=OFF; this undoes that), set the
+ * MAC mode, then apply the USXGMII submode if the mode needs one.
+ */
+static int rtpcs_93xx_sds_set_mac_driven_mode(struct rtpcs_serdes *sds,
+                                             enum rtpcs_sds_mode hw_mode)
+{
+       int ret;
+
+       ret = rtpcs_sds_write_bits(sds, 0x1f, 0x09, 6, 6, 0);
+       if (ret)
+               return ret;
+
+       ret = rtpcs_93xx_sds_set_mac_mode(sds, hw_mode);
+       if (ret)
+               return ret;
+
+       return rtpcs_93xx_sds_apply_usxgmii_submode(sds, hw_mode);
+}
+
 /*
  * Read/write the SerDes IP mode register: page 0x1f reg 0x09, bits 11:7
  * hold the 5-bit mode value, bit 6 is the "force mode" enable. The same
@@ -1873,8 +1894,6 @@ static int rtpcs_930x_sds_apply_ip_mode(struct rtpcs_serdes *sds,
 
 static int rtpcs_930x_sds_set_mode(struct rtpcs_serdes *sds, enum rtpcs_sds_mode hw_mode)
 {
-       int ret;
-
        /*
         * Several modes can be configured via MAC setup, just by setting
         * a register to a specific value and the MAC will configure
@@ -1893,19 +1912,7 @@ static int rtpcs_930x_sds_set_mode(struct rtpcs_serdes *sds, enum rtpcs_sds_mode
                break;
        }
 
-       /*
-        * MAC-driven modes: release the IP mode force-lock so the MAC side
-        * takes over. deactivate forces IP=OFF; this undoes that.
-        */
-       ret = rtpcs_sds_write_bits(sds, 0x1f, 0x09, 6, 6, 0);
-       if (ret)
-               return ret;
-
-       ret = rtpcs_93xx_sds_set_mac_mode(sds, hw_mode);
-       if (ret)
-               return ret;
-
-       return rtpcs_93xx_sds_apply_usxgmii_submode(sds, hw_mode);
+       return rtpcs_93xx_sds_set_mac_driven_mode(sds, hw_mode);
 }
 
 static int rtpcs_930x_sds_deactivate(struct rtpcs_serdes *sds)