]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: stmmac: handle integrated PCS phy_intf_sel separately
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Fri, 30 Jan 2026 11:10:36 +0000 (11:10 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 3 Feb 2026 03:16:02 +0000 (19:16 -0800)
The dwmac core has no support for SGMII without using its integrated
PCS. Thus, PHY_INTF_SEL_SGMII is only supported when this block is
present, and it makes no sense for stmmac_get_phy_intf_sel() to decode
this.

None of the platform glue users that use stmmac_get_phy_intf_sel()
directly accept PHY_INTF_SEL_SGMII as a valid mode.

Check whether a PCS will be used by the driver for the interface mode,
and if it is the integrated PCS, query the integrated PCS for the
phy_intf_sel_i value to use.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Tested-by: Mohd Ayaan Anwar <mohd.anwar@oss.qualcomm.com>
Link: https://patch.msgid.link/E1vlmOa-00000006zvB-1fIe@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h

index fee5804e75c064c407af6aac7522e6323c40a9dd..9500b332a15269ce53a3599e5594df14a9e24336 100644 (file)
@@ -3159,8 +3159,6 @@ int stmmac_get_phy_intf_sel(phy_interface_t interface)
                phy_intf_sel = PHY_INTF_SEL_GMII_MII;
        else if (phy_interface_mode_is_rgmii(interface))
                phy_intf_sel = PHY_INTF_SEL_RGMII;
-       else if (interface == PHY_INTERFACE_MODE_SGMII)
-               phy_intf_sel = PHY_INTF_SEL_SGMII;
        else if (interface == PHY_INTERFACE_MODE_RMII)
                phy_intf_sel = PHY_INTF_SEL_RMII;
        else if (interface == PHY_INTERFACE_MODE_REVMII)
@@ -3174,13 +3172,24 @@ static int stmmac_prereset_configure(struct stmmac_priv *priv)
 {
        struct plat_stmmacenet_data *plat_dat = priv->plat;
        phy_interface_t interface;
+       struct phylink_pcs *pcs;
        int phy_intf_sel, ret;
 
        if (!plat_dat->set_phy_intf_sel)
                return 0;
 
        interface = plat_dat->phy_interface;
-       phy_intf_sel = stmmac_get_phy_intf_sel(interface);
+
+       /* Check whether this mode uses a PCS */
+       pcs = stmmac_mac_select_pcs(&priv->phylink_config, interface);
+       if (priv->integrated_pcs && pcs == &priv->integrated_pcs->pcs) {
+               /* Request the phy_intf_sel from the integrated PCS */
+               phy_intf_sel = stmmac_integrated_pcs_get_phy_intf_sel(pcs,
+                                                                   interface);
+       } else {
+               phy_intf_sel = stmmac_get_phy_intf_sel(interface);
+       }
+
        if (phy_intf_sel < 0) {
                netdev_err(priv->dev,
                           "failed to get phy_intf_sel for %s: %pe\n",
index e827c03ae932629856aba17a2a4463eaa2d897ec..88fa359ea71636190fa23a046a3385d4482a6d69 100644 (file)
@@ -81,6 +81,15 @@ void stmmac_integrated_pcs_irq(struct stmmac_priv *priv, u32 status,
        }
 }
 
+int stmmac_integrated_pcs_get_phy_intf_sel(struct phylink_pcs *pcs,
+                                          phy_interface_t interface)
+{
+       if (interface == PHY_INTERFACE_MODE_SGMII)
+               return PHY_INTF_SEL_SGMII;
+
+       return -EINVAL;
+}
+
 int stmmac_integrated_pcs_init(struct stmmac_priv *priv, unsigned int offset,
                               u32 int_mask)
 {
index 13ee5bd6c788343b447f062ac0694de43ec0512a..23bbd4f10bf84558482df90c25876eafd994f57c 100644 (file)
@@ -42,6 +42,8 @@ phylink_pcs_to_stmmac_pcs(struct phylink_pcs *pcs)
 
 void stmmac_integrated_pcs_irq(struct stmmac_priv *priv, u32 status,
                               struct stmmac_extra_stats *x);
+int stmmac_integrated_pcs_get_phy_intf_sel(struct phylink_pcs *pcs,
+                                          phy_interface_t interface);
 int stmmac_integrated_pcs_init(struct stmmac_priv *priv, unsigned int offset,
                               u32 int_mask);