]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: dsa,pcs: rtl931x: let PCS driver setup SerDes
authorJonas Jelonek <jelonek.jonas@gmail.com>
Wed, 8 Oct 2025 14:21:57 +0000 (14:21 +0000)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 19 Oct 2025 21:49:56 +0000 (23:49 +0200)
Remove SerDes initialization/configuration calls from the DSA driver in
'rtl931x_phylink_mac_config' and let our PCS driver setup the SerDes now
that the driver is able to do that.

pcs_config of the PCS driver is automatically called by phylink, thus
there's no need to call it on our own.

Note that in rtl931x_phylink_mac_config the MAC is enabled before
pcs_config is called. While this seems to work, it isn't good and needs
to be fixed.

Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/20369
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c
target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c

index 9e274f357b4bb81c413a9e8fadd0bf19ece55f90..fa3ecd816f99c91ddb57c19844046060f80af0e9 100644 (file)
@@ -692,52 +692,11 @@ static void rtl931x_phylink_mac_config(struct dsa_switch *ds, int port,
 {
        struct rtl838x_switch_priv *priv = ds->priv;
        int sds_num;
-       u32 reg, band;
+       u32 reg;
 
        sds_num = priv->ports[port].sds_num;
        pr_info("%s: speed %d sds_num %d\n", __func__, state->speed, sds_num);
 
-       switch (state->interface) {
-       case PHY_INTERFACE_MODE_1000BASEX:
-               band = rtl931x_sds_cmu_band_get(sds_num, PHY_INTERFACE_MODE_1000BASEX);
-               rtl931x_sds_init(sds_num, PHY_INTERFACE_MODE_1000BASEX);
-               break;
-       case PHY_INTERFACE_MODE_XGMII:
-               band = rtl931x_sds_cmu_band_get(sds_num, PHY_INTERFACE_MODE_XGMII);
-               rtl931x_sds_init(sds_num, PHY_INTERFACE_MODE_XGMII);
-               break;
-       case PHY_INTERFACE_MODE_10GBASER:
-       case PHY_INTERFACE_MODE_10GKR:
-               band = rtl931x_sds_cmu_band_get(sds_num, PHY_INTERFACE_MODE_10GBASER);
-               rtl931x_sds_init(sds_num, PHY_INTERFACE_MODE_10GBASER);
-               break;
-       case PHY_INTERFACE_MODE_USXGMII:
-               /*
-                * TODO: USXGMII is currently the swiss army knife to declare 10G
-                * multi port PHYs. Real devices use other modes instead. Especially
-                *
-                * - RTL8224 is driven in 10G_QXGMII
-                * - RTL8218D/E are driven in (Realtek proprietary) XSGMII (10G SGMII)
-                *
-                * For now disable all USXGMII SerDes handling and rely on U-Boot setup.
-                */
-                break;
-       case PHY_INTERFACE_MODE_SGMII:
-               pr_info("%s setting mode PHY_INTERFACE_MODE_SGMII\n", __func__);
-               band = rtl931x_sds_cmu_band_get(sds_num, PHY_INTERFACE_MODE_SGMII);
-               rtl931x_sds_init(sds_num, PHY_INTERFACE_MODE_SGMII);
-               band = rtl931x_sds_cmu_band_set(sds_num, true, 62, PHY_INTERFACE_MODE_SGMII);
-               break;
-       case PHY_INTERFACE_MODE_QSGMII:
-               band = rtl931x_sds_cmu_band_get(sds_num, PHY_INTERFACE_MODE_QSGMII);
-               rtl931x_sds_init(sds_num, PHY_INTERFACE_MODE_QSGMII);
-               break;
-       default:
-               pr_err("%s: unknown serdes mode: %s\n",
-                       __func__, phy_modes(state->interface));
-               return;
-       }
-
        reg = sw_r32(priv->r->mac_force_mode_ctrl(port));
        pr_info("%s reading FORCE_MODE_CTRL: %08x\n", __func__, reg);
 
@@ -755,7 +714,6 @@ static void rtl931x_phylink_mac_config(struct dsa_switch *ds, int port,
                reg |= RTL931X_DUPLEX_MODE;
 
        sw_w32(reg, priv->r->mac_force_mode_ctrl(port));
-
 }
 
 static void rtl93xx_phylink_mac_config(struct dsa_switch *ds, int port,
index 8cb0c03e641a1bdde37ee7312abd0c265d98a86c..a0fee490fab93a48002751267864c590a2406d3c 100644 (file)
@@ -1069,6 +1069,7 @@ static const struct rtpcs_config rtpcs_931x_cfg = {
        .mac_tx_pause_sts       = RTPCS_931X_MAC_TX_PAUSE_STS,
        .pcs_ops                = &rtpcs_931x_pcs_ops,
        .set_autoneg            = rtpcs_93xx_set_autoneg,
+       .setup_serdes           = rtpcs_931x_setup_serdes,
 };
 
 static const struct of_device_id rtpcs_of_match[] = {