netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v3 0/3] net: stmmac: socfpga: 1000BaseX support and cleanups
@ 2025-04-24  7:12 Maxime Chevallier
  2025-04-24  7:12 ` [PATCH net-next v3 1/3] net: stmmac: socfpga: Enable internal GMII when using 1000BaseX Maxime Chevallier
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Maxime Chevallier @ 2025-04-24  7:12 UTC (permalink / raw)
  To: davem, Andrew Lunn, Russell King, Jakub Kicinski, Eric Dumazet,
	Paolo Abeni
  Cc: Maxime Chevallier, netdev, linux-kernel, thomas.petazzoni,
	Simon Horman, Alexis Lothoré, linux-stm32, linux-arm-kernel

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/20250422094701.49798-1-maxime.chevallier@bootlin.com/
V2: https://lore.kernel.org/netdev/20250423104646.189648-1-maxime.chevallier@bootlin.com/

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(-)

-- 
2.49.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next v3 1/3] net: stmmac: socfpga: Enable internal GMII when using 1000BaseX
  2025-04-24  7:12 [PATCH net-next v3 0/3] net: stmmac: socfpga: 1000BaseX support and cleanups Maxime Chevallier
@ 2025-04-24  7:12 ` Maxime Chevallier
  2025-04-24  7:12 ` [PATCH net-next v3 2/3] net: stmmac: socfpga: Don't check for phy to enable the SGMII adapter Maxime Chevallier
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Maxime Chevallier @ 2025-04-24  7:12 UTC (permalink / raw)
  To: davem, Andrew Lunn, Russell King, Jakub Kicinski, Eric Dumazet,
	Paolo Abeni
  Cc: Maxime Chevallier, netdev, linux-kernel, thomas.petazzoni,
	Simon Horman, Alexis Lothoré, linux-stm32, linux-arm-kernel,
	Russell King (Oracle)

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.

Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
index 59f90b123c5b..027356033e5e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
@@ -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:
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next v3 2/3] net: stmmac: socfpga: Don't check for phy to enable the SGMII adapter
  2025-04-24  7:12 [PATCH net-next v3 0/3] net: stmmac: socfpga: 1000BaseX support and cleanups Maxime Chevallier
  2025-04-24  7:12 ` [PATCH net-next v3 1/3] net: stmmac: socfpga: Enable internal GMII when using 1000BaseX Maxime Chevallier
@ 2025-04-24  7:12 ` Maxime Chevallier
  2025-04-24  7:12 ` [PATCH net-next v3 3/3] net: stmmac: socfpga: Remove unused pcs-mdiodev field Maxime Chevallier
  2025-04-28 13:30 ` [PATCH net-next v3 0/3] net: stmmac: socfpga: 1000BaseX support and cleanups patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Maxime Chevallier @ 2025-04-24  7:12 UTC (permalink / raw)
  To: davem, Andrew Lunn, Russell King, Jakub Kicinski, Eric Dumazet,
	Paolo Abeni
  Cc: Maxime Chevallier, netdev, linux-kernel, thomas.petazzoni,
	Simon Horman, Alexis Lothoré, linux-stm32, linux-arm-kernel

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>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
index 027356033e5e..c832a41c1747 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
@@ -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);
 }
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next v3 3/3] net: stmmac: socfpga: Remove unused pcs-mdiodev field
  2025-04-24  7:12 [PATCH net-next v3 0/3] net: stmmac: socfpga: 1000BaseX support and cleanups Maxime Chevallier
  2025-04-24  7:12 ` [PATCH net-next v3 1/3] net: stmmac: socfpga: Enable internal GMII when using 1000BaseX Maxime Chevallier
  2025-04-24  7:12 ` [PATCH net-next v3 2/3] net: stmmac: socfpga: Don't check for phy to enable the SGMII adapter Maxime Chevallier
@ 2025-04-24  7:12 ` Maxime Chevallier
  2025-04-28 13:30 ` [PATCH net-next v3 0/3] net: stmmac: socfpga: 1000BaseX support and cleanups patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Maxime Chevallier @ 2025-04-24  7:12 UTC (permalink / raw)
  To: davem, Andrew Lunn, Russell King, Jakub Kicinski, Eric Dumazet,
	Paolo Abeni
  Cc: Maxime Chevallier, netdev, linux-kernel, thomas.petazzoni,
	Simon Horman, Alexis Lothoré, linux-stm32, linux-arm-kernel,
	Russell King (Oracle)

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.

Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
index c832a41c1747..72b50f6d72f4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
@@ -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,
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v3 0/3] net: stmmac: socfpga: 1000BaseX support and cleanups
  2025-04-24  7:12 [PATCH net-next v3 0/3] net: stmmac: socfpga: 1000BaseX support and cleanups Maxime Chevallier
                   ` (2 preceding siblings ...)
  2025-04-24  7:12 ` [PATCH net-next v3 3/3] net: stmmac: socfpga: Remove unused pcs-mdiodev field Maxime Chevallier
@ 2025-04-28 13:30 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-04-28 13:30 UTC (permalink / raw)
  To: Maxime Chevallier
  Cc: davem, andrew, linux, kuba, edumazet, pabeni, netdev,
	linux-kernel, thomas.petazzoni, horms, alexis.lothore,
	linux-stm32, linux-arm-kernel

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-04-28 13:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-24  7:12 [PATCH net-next v3 0/3] net: stmmac: socfpga: 1000BaseX support and cleanups Maxime Chevallier
2025-04-24  7:12 ` [PATCH net-next v3 1/3] net: stmmac: socfpga: Enable internal GMII when using 1000BaseX Maxime Chevallier
2025-04-24  7:12 ` [PATCH net-next v3 2/3] net: stmmac: socfpga: Don't check for phy to enable the SGMII adapter Maxime Chevallier
2025-04-24  7:12 ` [PATCH net-next v3 3/3] net: stmmac: socfpga: Remove unused pcs-mdiodev field Maxime Chevallier
2025-04-28 13:30 ` [PATCH net-next v3 0/3] net: stmmac: socfpga: 1000BaseX support and cleanups patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).