Skip to contentSkip to conversation

net: stmmac: socfpga: 1000BaseX support and cleanups

PATCH Superseded Maxime Chevallier 1 participant 5 messages Apr 23, 2025

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Maxime Chevallier

author maintainer
#0 lore raw

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

Hello everyone,

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 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]/

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 v2 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.

---
V2: Added Russell's r'd-by tag

 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 v2 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.

---
V2: - Following Russell's review, added a check for the phy_interface.
- Had to rename some variables around, following the naming conventions for that driver

 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 v2 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.

---
V2: Added Russell's r'd-by tag

 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
author maintainer
#4 lore raw
In reply to Maxime Chevallier

On Wed, 23 Apr 2025 12:46:42 +0200
Maxime Chevallier <[email protected]> wrote:

Hi,

Quoted 8 lines

Hello everyone,

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.

Quoted 7 lines

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.

I mixed-up my command while generating this series, it targets net-next and not net...

I'll respin tomorrow with the proper destination tree, sorry about that.

Maxime