Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
* [PATCH net-next 00/11] net: stmmac: cleanup transmit clock setting
@ 2025-02-27  9:16 Russell King (Oracle)
  2025-02-27  9:16 ` [PATCH net-next 07/11] net: stmmac: imx: use generic stmmac_set_clk_tx_rate() Russell King (Oracle)
  2025-02-28 18:30 ` [PATCH net-next 00/11] net: stmmac: cleanup transmit clock setting patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Russell King (Oracle) @ 2025-02-27  9:16 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Drew Fustini,
	Emil Renner Berthing, Eric Dumazet, Fabio Estevam, Fu Wei,
	Guo Ren, imx, Jakub Kicinski, Jan Petrous, Jerome Brunet,
	Kevin Hilman, linux-amlogic, linux-arm-kernel, linux-riscv,
	linux-stm32, Martin Blumenstingl, Maxime Coquelin, Minda Chen,
	Neil Armstrong, netdev, Paolo Abeni, Pengutronix Kernel Team,
	Sascha Hauer, Shawn Guo

Hi,

A lot of stmmac platform code which sets the transmit clock is very
similar - they decode the speed to the clock rate (125, 25 or 2.5 MHz)
and then set a clock to that rate.

The DWMAC core appears to have a clock input for the transmit section
called clk_tx_i which requires this rate.

This series moves the code which sets this clock into the core stmmac
code.

Patch 1 adds a hook that platforms can use to configure the clock rate.
Patch 2 adds a generic implementation.
The remainder of the patches convert the glue code for various platforms
to use this new infrastructure.

Changes since RFC: fix build errors, add Thierry Reding's r-b. More
platform glue conversions.

 .../ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c    | 10 +----
 drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c    | 21 ++++++++++-
 .../net/ethernet/stmicro/stmmac/dwmac-intel-plat.c | 24 ++----------
 .../net/ethernet/stmicro/stmmac/dwmac-ipq806x.c    |  9 +++--
 drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c  |  9 +++--
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c     | 10 +++--
 drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c    | 22 ++---------
 .../net/ethernet/stmicro/stmmac/dwmac-starfive.c   | 26 ++-----------
 drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c  | 18 +++++----
 drivers/net/ethernet/stmicro/stmmac/stmmac.h       |  2 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 43 ++++++++++++++++++++++
 include/linux/stmmac.h                             |  4 ++
 12 files changed, 108 insertions(+), 90 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] 4+ messages in thread

* [PATCH net-next 07/11] net: stmmac: imx: use generic stmmac_set_clk_tx_rate()
  2025-02-27  9:16 [PATCH net-next 00/11] net: stmmac: cleanup transmit clock setting Russell King (Oracle)
@ 2025-02-27  9:16 ` Russell King (Oracle)
  2025-02-27 14:01   ` Andrew Lunn
  2025-02-28 18:30 ` [PATCH net-next 00/11] net: stmmac: cleanup transmit clock setting patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Russell King (Oracle) @ 2025-02-27  9:16 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
	Fabio Estevam, imx, Jakub Kicinski, linux-arm-kernel, linux-stm32,
	Maxime Coquelin, netdev, Paolo Abeni, Pengutronix Kernel Team,
	Sascha Hauer, Shawn Guo

Convert non-i.MX93 users to use the generic stmmac_set_clk_tx_rate() to
configure the MAC transmit clock rate.

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

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
index 610204b51e3f..5d279fa54b3e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
@@ -192,6 +192,19 @@ static void imx_dwmac_exit(struct platform_device *pdev, void *priv)
 	/* nothing to do now */
 }
 
+static int imx_dwmac_set_clk_tx_rate(void *bsp_priv, struct clk *clk_tx_i,
+				     phy_interface_t interface, int speed)
+{
+	struct imx_priv_data *dwmac = bsp_priv;
+
+	interface = dwmac->plat_dat->mac_interface;
+	if (interface == PHY_INTERFACE_MODE_RMII ||
+	    interface == PHY_INTERFACE_MODE_MII)
+		return 0;
+
+	return stmmac_set_clk_tx_rate(bsp_priv, clk_tx_i, interface, speed);
+}
+
 static void imx_dwmac_fix_speed(void *priv, int speed, unsigned int mode)
 {
 	struct plat_stmmacenet_data *plat_dat;
@@ -358,7 +371,6 @@ static int imx_dwmac_probe(struct platform_device *pdev)
 	plat_dat->init = imx_dwmac_init;
 	plat_dat->exit = imx_dwmac_exit;
 	plat_dat->clks_config = imx_dwmac_clks_config;
-	plat_dat->fix_mac_speed = imx_dwmac_fix_speed;
 	plat_dat->bsp_priv = dwmac;
 	dwmac->plat_dat = plat_dat;
 	dwmac->base_addr = stmmac_res.addr;
@@ -371,8 +383,13 @@ static int imx_dwmac_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_dwmac_init;
 
-	if (dwmac->ops->fix_mac_speed)
+	if (dwmac->ops->fix_mac_speed) {
 		plat_dat->fix_mac_speed = dwmac->ops->fix_mac_speed;
+	} else if (!dwmac->ops->mac_rgmii_txclk_auto_adj) {
+		plat_dat->clk_tx_i = dwmac->clk_tx;
+		plat_dat->set_clk_tx_rate = imx_dwmac_set_clk_tx_rate;
+	}
+
 	dwmac->plat_dat->fix_soc_reset = dwmac->ops->fix_soc_reset;
 
 	ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
-- 
2.30.2


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

* Re: [PATCH net-next 07/11] net: stmmac: imx: use generic stmmac_set_clk_tx_rate()
  2025-02-27  9:16 ` [PATCH net-next 07/11] net: stmmac: imx: use generic stmmac_set_clk_tx_rate() Russell King (Oracle)
@ 2025-02-27 14:01   ` Andrew Lunn
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2025-02-27 14:01 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Heiner Kallweit, Alexandre Torgue, Andrew Lunn, David S. Miller,
	Eric Dumazet, Fabio Estevam, imx, Jakub Kicinski,
	linux-arm-kernel, linux-stm32, Maxime Coquelin, netdev,
	Paolo Abeni, Pengutronix Kernel Team, Sascha Hauer, Shawn Guo

On Thu, Feb 27, 2025 at 09:16:54AM +0000, Russell King (Oracle) wrote:
> Convert non-i.MX93 users to use the generic stmmac_set_clk_tx_rate() to
> configure the MAC transmit clock rate.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

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

    Andrew

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

* Re: [PATCH net-next 00/11] net: stmmac: cleanup transmit clock setting
  2025-02-27  9:16 [PATCH net-next 00/11] net: stmmac: cleanup transmit clock setting Russell King (Oracle)
  2025-02-27  9:16 ` [PATCH net-next 07/11] net: stmmac: imx: use generic stmmac_set_clk_tx_rate() Russell King (Oracle)
@ 2025-02-28 18:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-02-28 18:30 UTC (permalink / raw)
  To: Russell King
  Cc: andrew, hkallweit1, alexandre.torgue, andrew+netdev, davem, drew,
	kernel, edumazet, festevam, wefu, guoren, imx, kuba, jan.petrous,
	jbrunet, khilman, linux-amlogic, linux-arm-kernel, linux-riscv,
	linux-stm32, martin.blumenstingl, mcoquelin.stm32, minda.chen,
	neil.armstrong, netdev, pabeni, kernel, s.hauer, shawnguo

Hello:

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

On Thu, 27 Feb 2025 09:16:15 +0000 you wrote:
> Hi,
> 
> A lot of stmmac platform code which sets the transmit clock is very
> similar - they decode the speed to the clock rate (125, 25 or 2.5 MHz)
> and then set a clock to that rate.
> 
> The DWMAC core appears to have a clock input for the transmit section
> called clk_tx_i which requires this rate.
> 
> [...]

Here is the summary with links:
  - [net-next,01/11] net: stmmac: provide set_clk_tx_rate() hook
    https://git.kernel.org/netdev/net-next/c/dea5c8ec20be
  - [net-next,02/11] net: stmmac: provide generic implementation for set_clk_tx_rate method
    https://git.kernel.org/netdev/net-next/c/12bce6d5404e
  - [net-next,03/11] net: stmmac: dwc-qos: use generic stmmac_set_clk_tx_rate()
    https://git.kernel.org/netdev/net-next/c/17c24f6dc641
  - [net-next,04/11] net: stmmac: starfive: use generic stmmac_set_clk_tx_rate()
    https://git.kernel.org/netdev/net-next/c/c81eb3da0be8
  - [net-next,05/11] net: stmmac: s32: use generic stmmac_set_clk_tx_rate()
    https://git.kernel.org/netdev/net-next/c/36fa8c960720
  - [net-next,06/11] net: stmmac: intel: use generic stmmac_set_clk_tx_rate()
    https://git.kernel.org/netdev/net-next/c/61356fb1b0d6
  - [net-next,07/11] net: stmmac: imx: use generic stmmac_set_clk_tx_rate()
    https://git.kernel.org/netdev/net-next/c/b693ce4f2704
  - [net-next,08/11] net: stmmac: rk: switch to use set_clk_tx_rate() hook
    https://git.kernel.org/netdev/net-next/c/c8caf6100f6d
  - [net-next,09/11] net: stmmac: ipq806x: switch to use set_clk_tx_rate() hook
    https://git.kernel.org/netdev/net-next/c/ca723519c28b
  - [net-next,10/11] net: stmmac: meson: switch to use set_clk_tx_rate() hook
    https://git.kernel.org/netdev/net-next/c/2a7d55f901a5
  - [net-next,11/11] net: stmmac: thead: switch to use set_clk_tx_rate() hook
    https://git.kernel.org/netdev/net-next/c/945db208fbe7

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

end of thread, other threads:[~2025-02-28 18:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-27  9:16 [PATCH net-next 00/11] net: stmmac: cleanup transmit clock setting Russell King (Oracle)
2025-02-27  9:16 ` [PATCH net-next 07/11] net: stmmac: imx: use generic stmmac_set_clk_tx_rate() Russell King (Oracle)
2025-02-27 14:01   ` Andrew Lunn
2025-02-28 18:30 ` [PATCH net-next 00/11] net: stmmac: cleanup transmit clock setting 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