realtek: pcs: rtl931x: map interface mode to hardware mode
authorJonas Jelonek <jelonek.jonas@gmail.com>
Mon, 15 Dec 2025 17:37:01 +0000 (17:37 +0000)
committerHauke Mehrtens <hauke@hauke-m.de>
Tue, 23 Dec 2025 17:53:33 +0000 (18:53 +0100)
The PCS driver is intended to use a dedicated hardware mode in the
future because the hardware capabilities and modes of the SerDes do not
align with the PHY_INTERFACE_MODE_* modes.

For the beginning, use the previously introduced generic mode mapping
in the SerDes setup and assign the determined hardware mode to the
corresponding field of a SerDes instance. This allows parallel usage of
both mode representations for the time being, until the phy_interface_t
modes can be dropped from internal functions completely.

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

index 535bded4c35400da11b7c6689354ae74627ebeed..381d205d0d884865f359cc6828247799dc36e505 100644 (file)
@@ -278,7 +278,6 @@ static struct rtpcs_link *rtpcs_phylink_pcs_to_link(struct phylink_pcs *pcs)
        return container_of(pcs, struct rtpcs_link, pcs);
 }
 
-__maybe_unused
 static int rtpcs_sds_determine_hw_mode(struct rtpcs_serdes *sds,
                                        phy_interface_t if_mode,
                                        enum rtpcs_sds_mode *hw_mode)
@@ -2805,6 +2804,7 @@ static int rtpcs_931x_setup_serdes(struct rtpcs_serdes *sds,
        struct rtpcs_serdes *even_sds = rtpcs_sds_get_even(sds);
        struct rtpcs_ctrl *ctrl = sds->ctrl;
        u32 band, ori, model_info, val;
+       enum rtpcs_sds_mode hw_mode;
        u32 sds_id = sds->id;
        int ret, chiptype = 0;
 
@@ -2854,6 +2854,13 @@ static int rtpcs_931x_setup_serdes(struct rtpcs_serdes *sds,
        /* this was in rtl931x_phylink_mac_config in dsa/rtl83xx/dsa.c before */
        band = rtpcs_931x_sds_cmu_band_get(sds, mode);
 
+       ret = rtpcs_sds_determine_hw_mode(sds, mode, &hw_mode);
+       if (ret < 0) {
+               dev_err(ctrl->dev, "SerDes %u doesn't support %s mode\n", sds_id,
+                       phy_modes(mode));
+               return -ENOTSUPP;
+       }
+
        ret = rtpcs_931x_sds_config_mode(sds, mode, chiptype);
        if (ret < 0)
                return ret;
@@ -2894,6 +2901,7 @@ static int rtpcs_931x_setup_serdes(struct rtpcs_serdes *sds,
                else
                        rtpcs_931x_sds_fiber_mode_set(sds, mode);
        }
+       sds->hw_mode = hw_mode;
 
        return 0;
 }