netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/3] net: stmmac: sti: use phy_interface_mode_is_rgmii()
  2025-04-15 16:42 [PATCH net-next 0/3] net: stmmac: sti cleanups Russell King (Oracle)
@ 2025-04-15 16:42 ` Russell King (Oracle)
  2025-04-15 16:51   ` Andrew Lunn
  2025-04-15 16:42 ` [PATCH net-next 2/3] net: stmmac: sti: convert to devm_stmmac_pltfr_probe() Russell King (Oracle)
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Russell King (Oracle) @ 2025-04-15 16:42 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, linux-arm-kernel, linux-stm32, Maxime Coquelin,
	netdev, Paolo Abeni

Replace the custom IS_PHY_IF_MODE_RGMII() macro with our generic
phy_interface_mode_is_rgmii() inline function.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
index be57c6c12c1c..c580647ff9dc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
@@ -23,12 +23,7 @@
 
 #define DWMAC_50MHZ	50000000
 
-#define IS_PHY_IF_MODE_RGMII(iface)	(iface == PHY_INTERFACE_MODE_RGMII || \
-			iface == PHY_INTERFACE_MODE_RGMII_ID || \
-			iface == PHY_INTERFACE_MODE_RGMII_RXID || \
-			iface == PHY_INTERFACE_MODE_RGMII_TXID)
-
-#define IS_PHY_IF_MODE_GBIT(iface)	(IS_PHY_IF_MODE_RGMII(iface) || \
+#define IS_PHY_IF_MODE_GBIT(iface)	(phy_interface_mode_is_rgmii(iface) || \
 					 iface == PHY_INTERFACE_MODE_GMII)
 
 /* STiH4xx register definitions (STiH407/STiH410 families)
@@ -148,7 +143,7 @@ static void stih4xx_fix_retime_src(void *priv, int spd, unsigned int mode)
 			src = TX_RETIME_SRC_CLKGEN;
 			freq = DWMAC_50MHZ;
 		}
-	} else if (IS_PHY_IF_MODE_RGMII(dwmac->interface)) {
+	} else if (phy_interface_mode_is_rgmii(dwmac->interface)) {
 		/* On GiGa clk source can be either ext or from clkgen */
 		freq = rgmii_clock(spd);
 
-- 
2.30.2


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

* [PATCH net-next 2/3] net: stmmac: sti: convert to devm_stmmac_pltfr_probe()
  2025-04-15 16:42 [PATCH net-next 0/3] net: stmmac: sti cleanups Russell King (Oracle)
  2025-04-15 16:42 ` [PATCH net-next 1/3] net: stmmac: sti: use phy_interface_mode_is_rgmii() Russell King (Oracle)
@ 2025-04-15 16:42 ` Russell King (Oracle)
  2025-04-15 16:52   ` Andrew Lunn
  2025-04-15 16:42 ` [PATCH net-next 3/3] net: stmmac: sti: convert to stmmac_pltfr_pm_ops Russell King (Oracle)
  2025-04-17  1:40 ` [PATCH net-next 0/3] net: stmmac: sti cleanups patchwork-bot+netdevbpf
  3 siblings, 1 reply; 8+ messages in thread
From: Russell King (Oracle) @ 2025-04-15 16:42 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, linux-arm-kernel, linux-stm32, Maxime Coquelin,
	netdev, Paolo Abeni

Convert sti to use the generic devm_stmmac_pltfr_probe() which will
call plat_dat->init()/plat_dat->exit() as appropriate, thus
simplifying the code.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../net/ethernet/stmicro/stmmac/dwmac-sti.c   | 54 +++++++++----------
 1 file changed, 26 insertions(+), 28 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
index c580647ff9dc..b6e09bd33894 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
@@ -233,6 +233,29 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac,
 	return 0;
 }
 
+static int sti_dwmac_init(struct platform_device *pdev, void *bsp_priv)
+{
+	struct sti_dwmac *dwmac = bsp_priv;
+	int ret;
+
+	ret = clk_prepare_enable(dwmac->clk);
+	if (ret)
+		return ret;
+
+	ret = sti_dwmac_set_mode(dwmac);
+	if (ret)
+		clk_disable_unprepare(dwmac->clk);
+
+	return ret;
+}
+
+static void sti_dwmac_exit(struct platform_device *pdev, void *bsp_priv)
+{
+	struct sti_dwmac *dwmac = bsp_priv;
+
+	clk_disable_unprepare(dwmac->clk);
+}
+
 static int sti_dwmac_probe(struct platform_device *pdev)
 {
 	struct plat_stmmacenet_data *plat_dat;
@@ -269,34 +292,10 @@ static int sti_dwmac_probe(struct platform_device *pdev)
 
 	plat_dat->bsp_priv = dwmac;
 	plat_dat->fix_mac_speed = data->fix_retime_src;
+	plat_dat->init = sti_dwmac_init;
+	plat_dat->exit = sti_dwmac_exit;
 
-	ret = clk_prepare_enable(dwmac->clk);
-	if (ret)
-		return ret;
-
-	ret = sti_dwmac_set_mode(dwmac);
-	if (ret)
-		goto disable_clk;
-
-	ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
-	if (ret)
-		goto disable_clk;
-
-	return 0;
-
-disable_clk:
-	clk_disable_unprepare(dwmac->clk);
-
-	return ret;
-}
-
-static void sti_dwmac_remove(struct platform_device *pdev)
-{
-	struct sti_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev);
-
-	stmmac_dvr_remove(&pdev->dev);
-
-	clk_disable_unprepare(dwmac->clk);
+	return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
 }
 
 static int sti_dwmac_suspend(struct device *dev)
@@ -334,7 +333,6 @@ MODULE_DEVICE_TABLE(of, sti_dwmac_match);
 
 static struct platform_driver sti_dwmac_driver = {
 	.probe  = sti_dwmac_probe,
-	.remove = sti_dwmac_remove,
 	.driver = {
 		.name           = "sti-dwmac",
 		.pm		= pm_sleep_ptr(&sti_dwmac_pm_ops),
-- 
2.30.2


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

* [PATCH net-next 3/3] net: stmmac: sti: convert to stmmac_pltfr_pm_ops
  2025-04-15 16:42 [PATCH net-next 0/3] net: stmmac: sti cleanups Russell King (Oracle)
  2025-04-15 16:42 ` [PATCH net-next 1/3] net: stmmac: sti: use phy_interface_mode_is_rgmii() Russell King (Oracle)
  2025-04-15 16:42 ` [PATCH net-next 2/3] net: stmmac: sti: convert to devm_stmmac_pltfr_probe() Russell King (Oracle)
@ 2025-04-15 16:42 ` Russell King (Oracle)
  2025-04-15 16:53   ` Andrew Lunn
  2025-04-17  1:40 ` [PATCH net-next 0/3] net: stmmac: sti cleanups patchwork-bot+netdevbpf
  3 siblings, 1 reply; 8+ messages in thread
From: Russell King (Oracle) @ 2025-04-15 16:42 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, linux-arm-kernel, linux-stm32, Maxime Coquelin,
	netdev, Paolo Abeni

As we now have the plat_dat->init()/plat_dat->exit() populated which
have the required functionality on suspend/resume, we can now use
stmmac_pltfr_pm_ops which has methods that call these two functions.
Switch over to use this.

Doing so also fills in the runtime PM ops and _noirq variants as well.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../net/ethernet/stmicro/stmmac/dwmac-sti.c   | 25 +------------------
 1 file changed, 1 insertion(+), 24 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
index b6e09bd33894..53d5ce1f6dc6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
@@ -298,29 +298,6 @@ static int sti_dwmac_probe(struct platform_device *pdev)
 	return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
 }
 
-static int sti_dwmac_suspend(struct device *dev)
-{
-	struct sti_dwmac *dwmac = get_stmmac_bsp_priv(dev);
-	int ret = stmmac_suspend(dev);
-
-	clk_disable_unprepare(dwmac->clk);
-
-	return ret;
-}
-
-static int sti_dwmac_resume(struct device *dev)
-{
-	struct sti_dwmac *dwmac = get_stmmac_bsp_priv(dev);
-
-	clk_prepare_enable(dwmac->clk);
-	sti_dwmac_set_mode(dwmac);
-
-	return stmmac_resume(dev);
-}
-
-static DEFINE_SIMPLE_DEV_PM_OPS(sti_dwmac_pm_ops, sti_dwmac_suspend,
-						  sti_dwmac_resume);
-
 static const struct sti_dwmac_of_data stih4xx_dwmac_data = {
 	.fix_retime_src = stih4xx_fix_retime_src,
 };
@@ -335,7 +312,7 @@ static struct platform_driver sti_dwmac_driver = {
 	.probe  = sti_dwmac_probe,
 	.driver = {
 		.name           = "sti-dwmac",
-		.pm		= pm_sleep_ptr(&sti_dwmac_pm_ops),
+		.pm		= &stmmac_pltfr_pm_ops,
 		.of_match_table = sti_dwmac_match,
 	},
 };
-- 
2.30.2


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

* [PATCH net-next 0/3] net: stmmac: sti cleanups
@ 2025-04-15 16:42 Russell King (Oracle)
  2025-04-15 16:42 ` [PATCH net-next 1/3] net: stmmac: sti: use phy_interface_mode_is_rgmii() Russell King (Oracle)
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Russell King (Oracle) @ 2025-04-15 16:42 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, linux-arm-kernel, linux-stm32, Maxime Coquelin,
	netdev, Paolo Abeni

Clean up the STI platform glue code.

- IS_PHY_IF_MODE_RGMII() is just a duplicate for
  phy_interface_mode_is_rgmii(), so use the generic version that we
  already have.

- add init/exit functions that call clk_prepare_enable(),
  sti_dwmac_set_mode() and clk_disable_unprepare() as appropriate,
  converting to devm_stmmac_pltfr_probe().

- the custom suspend/resume ops do basically what the generic ones
  do with init/exit functions populated, but also add runtime and
  noirq ops. Update STI to use the generic ops.

 drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | 88 ++++++++-----------------
 1 file changed, 29 insertions(+), 59 deletions(-)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH net-next 1/3] net: stmmac: sti: use phy_interface_mode_is_rgmii()
  2025-04-15 16:42 ` [PATCH net-next 1/3] net: stmmac: sti: use phy_interface_mode_is_rgmii() Russell King (Oracle)
@ 2025-04-15 16:51   ` Andrew Lunn
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2025-04-15 16:51 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Heiner Kallweit, Alexandre Torgue, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, linux-arm-kernel, linux-stm32,
	Maxime Coquelin, netdev, Paolo Abeni

On Tue, Apr 15, 2025 at 05:42:23PM +0100, Russell King (Oracle) wrote:
> Replace the custom IS_PHY_IF_MODE_RGMII() macro with our generic
> phy_interface_mode_is_rgmii() inline function.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next 2/3] net: stmmac: sti: convert to devm_stmmac_pltfr_probe()
  2025-04-15 16:42 ` [PATCH net-next 2/3] net: stmmac: sti: convert to devm_stmmac_pltfr_probe() Russell King (Oracle)
@ 2025-04-15 16:52   ` Andrew Lunn
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2025-04-15 16:52 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Heiner Kallweit, Alexandre Torgue, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, linux-arm-kernel, linux-stm32,
	Maxime Coquelin, netdev, Paolo Abeni

On Tue, Apr 15, 2025 at 05:42:29PM +0100, Russell King (Oracle) wrote:
> Convert sti to use the generic devm_stmmac_pltfr_probe() which will
> call plat_dat->init()/plat_dat->exit() as appropriate, thus
> simplifying the code.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next 3/3] net: stmmac: sti: convert to stmmac_pltfr_pm_ops
  2025-04-15 16:42 ` [PATCH net-next 3/3] net: stmmac: sti: convert to stmmac_pltfr_pm_ops Russell King (Oracle)
@ 2025-04-15 16:53   ` Andrew Lunn
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2025-04-15 16:53 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Heiner Kallweit, Alexandre Torgue, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, linux-arm-kernel, linux-stm32,
	Maxime Coquelin, netdev, Paolo Abeni

On Tue, Apr 15, 2025 at 05:42:34PM +0100, Russell King (Oracle) wrote:
> As we now have the plat_dat->init()/plat_dat->exit() populated which
> have the required functionality on suspend/resume, we can now use
> stmmac_pltfr_pm_ops which has methods that call these two functions.
> Switch over to use this.
> 
> Doing so also fills in the runtime PM ops and _noirq variants as well.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next 0/3] net: stmmac: sti cleanups
  2025-04-15 16:42 [PATCH net-next 0/3] net: stmmac: sti cleanups Russell King (Oracle)
                   ` (2 preceding siblings ...)
  2025-04-15 16:42 ` [PATCH net-next 3/3] net: stmmac: sti: convert to stmmac_pltfr_pm_ops Russell King (Oracle)
@ 2025-04-17  1:40 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-04-17  1:40 UTC (permalink / raw)
  To: Russell King
  Cc: andrew, hkallweit1, alexandre.torgue, andrew+netdev, davem,
	edumazet, kuba, linux-arm-kernel, linux-stm32, mcoquelin.stm32,
	netdev, pabeni

Hello:

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

On Tue, 15 Apr 2025 17:42:39 +0100 you wrote:
> Clean up the STI platform glue code.
> 
> - IS_PHY_IF_MODE_RGMII() is just a duplicate for
>   phy_interface_mode_is_rgmii(), so use the generic version that we
>   already have.
> 
> - add init/exit functions that call clk_prepare_enable(),
>   sti_dwmac_set_mode() and clk_disable_unprepare() as appropriate,
>   converting to devm_stmmac_pltfr_probe().
> 
> [...]

Here is the summary with links:
  - [net-next,1/3] net: stmmac: sti: use phy_interface_mode_is_rgmii()
    https://git.kernel.org/netdev/net-next/c/72d02a9f9410
  - [net-next,2/3] net: stmmac: sti: convert to devm_stmmac_pltfr_probe()
    https://git.kernel.org/netdev/net-next/c/403068c6c9c2
  - [net-next,3/3] net: stmmac: sti: convert to stmmac_pltfr_pm_ops
    https://git.kernel.org/netdev/net-next/c/b3334f9f708c

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] 8+ messages in thread

end of thread, other threads:[~2025-04-17  1:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-15 16:42 [PATCH net-next 0/3] net: stmmac: sti cleanups Russell King (Oracle)
2025-04-15 16:42 ` [PATCH net-next 1/3] net: stmmac: sti: use phy_interface_mode_is_rgmii() Russell King (Oracle)
2025-04-15 16:51   ` Andrew Lunn
2025-04-15 16:42 ` [PATCH net-next 2/3] net: stmmac: sti: convert to devm_stmmac_pltfr_probe() Russell King (Oracle)
2025-04-15 16:52   ` Andrew Lunn
2025-04-15 16:42 ` [PATCH net-next 3/3] net: stmmac: sti: convert to stmmac_pltfr_pm_ops Russell King (Oracle)
2025-04-15 16:53   ` Andrew Lunn
2025-04-17  1:40 ` [PATCH net-next 0/3] net: stmmac: sti 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).