]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: pcs: rtl930x: fold 1G/10G PHY power into {de,}activate
authorJonas Jelonek <jelonek.jonas@gmail.com>
Wed, 22 Apr 2026 14:35:18 +0000 (14:35 +0000)
committerJonas Jelonek <jelonek.jonas@gmail.com>
Tue, 26 May 2026 06:37:59 +0000 (08:37 +0200)
Move the 1G and 10G PHY block power-up writes (clear BMCR_PDOWN on pages
0x02 and 0x04) out of rtpcs_930x_phy_enable_10g_1g() and into
rtpcs_930x_sds_activate(), and add the mirror writes (set BMCR_PDOWN) to
rtpcs_930x_sds_deactivate(). Same for the fiber RX bit.

With 1G PHY / 10G PHY / fiber RX all now handled symmetrically, drop the
rtpcs_930x_phy_enable_10g_1g() helper. The remaining write it contained
(set medium = fiber on page 0x1f reg 11 bit 1) is unrelated to power
management, unconditionally applied, and to-be-inspected for non-fiber
modes. Move it inline into setup_serdes with a TODO comment; proper
mode-aware handling is out of scope for this commit.

Behavioural note: the 1G/10G PHY blocks and fiber RX are now
power-cycled on every mode transition. Previously they were only
powered up (never explicitly down) and the state persisted across
reconfigure. The new behaviour makes each setup_serdes a standalone
bring-up that does not rely on the prior state of these bits.

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

index b19be93d2ace8bbb19dd9a280c6a4becdaa57a48..241acfbb909881e146a2e65dc63a944e7637a8a0 100644 (file)
@@ -1864,7 +1864,42 @@ static int rtpcs_930x_sds_set_mode(struct rtpcs_serdes *sds, enum rtpcs_sds_mode
 
 static int rtpcs_930x_sds_deactivate(struct rtpcs_serdes *sds)
 {
-       return rtpcs_930x_sds_set_mode(sds, RTPCS_SDS_MODE_OFF);
+       int ret;
+
+       ret = rtpcs_930x_sds_set_mode(sds, RTPCS_SDS_MODE_OFF);
+       if (ret)
+               return ret;
+
+       /* Disable fiber RX. */
+       ret = rtpcs_sds_write_bits(sds, 0x20, 2, 12, 12, 1);
+       if (ret)
+               return ret;
+
+       /* Power down the 1G PHY block. */
+       ret = rtpcs_sds_write_bits(sds, 0x02, MII_BMCR, 11, 11, 1); /* BMCR_PDOWN */
+       if (ret)
+               return ret;
+
+       /* Power down the 10G PHY block. */
+       return rtpcs_sds_write_bits(sds, 0x04, MII_BMCR, 11, 11, 1); /* BMCR_PDOWN */
+}
+
+static int rtpcs_930x_sds_activate(struct rtpcs_serdes *sds)
+{
+       int ret;
+
+       /* Enable fiber RX. */
+       ret = rtpcs_sds_write_bits(sds, 0x20, 2, 12, 12, 0);
+       if (ret)
+               return ret;
+
+       /* Power up the 1G PHY block. */
+       ret = rtpcs_sds_write_bits(sds, 0x02, MII_BMCR, 11, 11, 0); /* BMCR_PDOWN */
+       if (ret)
+               return ret;
+
+       /* Power up the 10G PHY block. */
+       return rtpcs_sds_write_bits(sds, 0x04, MII_BMCR, 11, 11, 0); /* BMCR_PDOWN */
 }
 
 static void rtpcs_930x_sds_tx_config(struct rtpcs_serdes *sds,
@@ -2749,18 +2784,6 @@ static int rtpcs_930x_sds_check_calibration(struct rtpcs_serdes *sds,
        return 0;
 }
 
-static void rtpcs_930x_phy_enable_10g_1g(struct rtpcs_serdes *sds)
-{
-       /* Enable 1GBit PHY */
-       rtpcs_sds_write_bits(sds, 0x02, MII_BMCR, 11, 11, 0x0); /* BMCR_PDOWN */
-
-       /* Enable 10GBit PHY */
-       rtpcs_sds_write_bits(sds, 0x04, MII_BMCR, 11, 11, 0x0); /* BMCR_PDOWN */
-
-       /* dal_longan_construct_mac_default_10gmedia_fiber */
-       rtpcs_sds_write_bits(sds, 0x1f, 11, 1, 1, 0x1);
-}
-
 static int rtpcs_930x_sds_10g_idle(struct rtpcs_serdes *sds)
 {
        struct rtpcs_serdes *even_sds = rtpcs_sds_get_even(sds);
@@ -3029,8 +3052,12 @@ static int rtpcs_930x_setup_serdes(struct rtpcs_serdes *sds,
 
        /* Maybe use dal_longan_sds_init */
 
-       /* dal_longan_construct_serdesConfig_init */ /* Serdes Construct */
-       rtpcs_930x_phy_enable_10g_1g(sds);
+       /*
+        * dal_longan_construct_mac_default_10gmedia_fiber: set medium to fiber.
+        * TODO: this is unconditional regardless of hw_mode; needs mode-aware
+        * handling.
+        */
+       rtpcs_sds_write_bits(sds, 0x1f, 11, 1, 1, 1);
 
        /* Enable SDS in desired mode */
        ret = rtpcs_930x_sds_set_mode(sds, hw_mode);
@@ -3039,8 +3066,7 @@ static int rtpcs_930x_setup_serdes(struct rtpcs_serdes *sds,
 
        sds->hw_mode = hw_mode;
 
-       /* Enable Fiber RX */
-       rtpcs_sds_write_bits(sds, 0x20, 2, 12, 12, 0);
+       rtpcs_930x_sds_activate(sds);
 
        if (hw_mode == RTPCS_SDS_MODE_QSGMII)
                goto skip_cali;