]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: stmmac: socfpga: Don't check for phy to enable the SGMII adapter
authorMaxime Chevallier <maxime.chevallier@bootlin.com>
Thu, 24 Apr 2025 07:12:21 +0000 (09:12 +0200)
committerJakub Kicinski <kuba@kernel.org>
Mon, 28 Apr 2025 13:17:46 +0000 (06:17 -0700)
The SGMII adapter needs to be enabled for both Cisco SGMII and 1000BaseX
operations. It doesn't make sense to check for an attached phydev here,
as we simply might not have any, in particular if we're using the
1000BaseX interface mode.

Make so that we only re-enable the SGMII adapter when it's present, and
when we use a phy_mode that is handled by said adapter.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20250424071223.221239-3-maxime.chevallier@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c

index 027356033e5e0bf79f75e1a912753134c198019f..c832a41c17473205379dba302d15a14c4de38a75 100644 (file)
@@ -62,14 +62,13 @@ struct socfpga_dwmac {
        struct mdio_device *pcs_mdiodev;
 };
 
-static void socfpga_dwmac_fix_mac_speed(void *priv, int speed, unsigned int mode)
+static void socfpga_dwmac_fix_mac_speed(void *bsp_priv, int speed,
+                                       unsigned int mode)
 {
-       struct socfpga_dwmac *dwmac = (struct socfpga_dwmac *)priv;
+       struct socfpga_dwmac *dwmac = (struct socfpga_dwmac *)bsp_priv;
+       struct stmmac_priv *priv = netdev_priv(dev_get_drvdata(dwmac->dev));
        void __iomem *splitter_base = dwmac->splitter_base;
        void __iomem *sgmii_adapter_base = dwmac->sgmii_adapter_base;
-       struct device *dev = dwmac->dev;
-       struct net_device *ndev = dev_get_drvdata(dev);
-       struct phy_device *phy_dev = ndev->phydev;
        u32 val;
 
        if (sgmii_adapter_base)
@@ -96,7 +95,9 @@ static void socfpga_dwmac_fix_mac_speed(void *priv, int speed, unsigned int mode
                writel(val, splitter_base + EMAC_SPLITTER_CTRL_REG);
        }
 
-       if (phy_dev && sgmii_adapter_base)
+       if ((priv->plat->phy_interface == PHY_INTERFACE_MODE_SGMII ||
+            priv->plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) &&
+            sgmii_adapter_base)
                writew(SGMII_ADAPTER_ENABLE,
                       sgmii_adapter_base + SGMII_ADAPTER_CTRL_REG);
 }