Skip to contentSkip to conversation

net: stmmac: socfpga: 1000BaseX support and cleanups

PATCH Applied Maxime Chevallier 2 participants 5 messages Apr 24, 2025 – Apr 28, 2025

Subsystems (5)
lore
Share & tools
lore

Maxime Chevallier

author maintainer
#0 lore raw

v3 cover net: stmmac: socfpga: 1000BaseX support and cleanups

Hi everyone,

This V3 is simply a re-send of V2, targeting net-next instead of net as the V2 did by mistake.

No other changes besides a rebase on net-next were made.

This small series sorts-out 1000BaseX support and does a bit of cleanup for the Lynx conversion.

Patch 1 makes sure that we set the right phy_mode when working in 1000BaseX mode, so that the internal GMII is configured correctly.

Patch 2 removes a check for phy_device upon calling fix_mac_speed(). As the SGMII adapter may be chained to a Lynx PCS, checking for a phy_device to be attached to the netdev before enabling the SGMII adapter doesn't make sense, as we won't have a downstream PHY when using 1000BaseX.

Patch 3 cleans an unused field from the PCS conversion.

Changes in V3:
- None besides targeting net-next instead of net

Changes in V2:
- Added Russell's review tags
- Reworked patch 2 to check for phy_interface when configuring the adapter, as suggested by Russell.

V1: https://lore.kernel.org/netdev/[email protected]/
V2: https://lore.kernel.org/netdev/[email protected]/

Maxime Chevallier (3):
net: stmmac: socfpga: Enable internal GMII when using 1000BaseX
net: stmmac: socfpga: Don't check for phy to enable the SGMII adapter
net: stmmac: socfpga: Remove unused pcs-mdiodev field

 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c   | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH v3 1/3 net: stmmac: socfpga: Enable internal GMII when using 1000BaseX

Dwmac Socfpga may be used with an instance of a Lynx / Altera TSE PCS, in which case it gains support for 1000BaseX.

It appears that the PCS is wired to the MAC through an internal GMII bus. Make sure that we enable the GMII_MII mode for the internal MAC when using 1000BaseX.

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +1 -0
index 59f90b123c5b..027356033e5e 100644
@@ -256,6 +256,7 @@ static int socfpga_set_phy_mode_common(int phymode, u32 *val)
 	case PHY_INTERFACE_MODE_MII:
 	case PHY_INTERFACE_MODE_GMII:
 	case PHY_INTERFACE_MODE_SGMII:
+	case PHY_INTERFACE_MODE_1000BASEX:
 		*val = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII;
 		break;
 	case PHY_INTERFACE_MODE_RMII:
Signature · 1 line
2.49.0
author maintainer
#2 lore raw

PATCH v3 2/3 net: stmmac: socfpga: Don't check for phy to enable the SGMII adapter

In reply to Maxime Chevallier

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.

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +7 -6
index 027356033e5e..c832a41c1747 100644
@@ -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);
 }
Signature · 1 line
2.49.0
author maintainer
#3 lore raw

PATCH v3 3/3 net: stmmac: socfpga: Remove unused pcs-mdiodev field

In reply to Maxime Chevallier

When dwmac-socfpga was converted to using the Lynx PCS (previously referred to in the driver as the Altera TSE PCS), the lynx_pcs_create_mdiodev() was used to create the pcs instance.

As this function didn't exist in the early versions of the series, a local mdiodev object was stored for PCS creation. It was never used, but still made it into the driver, so remove it.

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +0 -1
index c832a41c1747..72b50f6d72f4 100644
@@ -59,7 +59,6 @@ struct socfpga_dwmac {
 	void __iomem *sgmii_adapter_base;
 	bool f2h_ptp_ref_clk;
 	const struct socfpga_dwmac_ops *ops;
-	struct mdio_device *pcs_mdiodev;
 };
 
 static void socfpga_dwmac_fix_mac_speed(void *bsp_priv, int speed,
Signature · 1 line
2.49.0
#4 lore raw
In reply to Maxime Chevallier
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Thu, 24 Apr 2025 09:12:19 +0200 you wrote:

Hi everyone,

This V3 is simply a re-send of V2, targeting net-next instead of net as the V2 did by mistake.

No other changes besides a rebase on net-next were made.

[...]

Here is the summary with links:
- [net-next,v3,1/3] net: stmmac: socfpga: Enable internal GMII when using 1000BaseX

    https://git.kernel.org/netdev/net-next/c/6fba40e7f610
  - [net-next,v3,2/3] net: stmmac: socfpga: Don't check for phy to enable the SGMII adapter
    https://git.kernel.org/netdev/net-next/c/3bf19459da62
  - [net-next,v3,3/3] net: stmmac: socfpga: Remove unused pcs-mdiodev field
    https://git.kernel.org/netdev/net-next/c/8fb33581bb8a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html