* [PATCH net-next 00/11] net: stmmac: cleanup transmit clock setting
@ 2025-02-27 9:16 Russell King (Oracle)
2025-02-27 9:17 ` [PATCH net-next 11/11] net: stmmac: thead: switch to use set_clk_tx_rate() hook 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!
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next 11/11] net: stmmac: thead: switch to use set_clk_tx_rate() hook
2025-02-27 9:16 [PATCH net-next 00/11] net: stmmac: cleanup transmit clock setting Russell King (Oracle)
@ 2025-02-27 9:17 ` Russell King (Oracle)
2025-02-27 14:04 ` 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:17 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Drew Fustini,
Eric Dumazet, Fu Wei, Guo Ren, Jakub Kicinski, linux-arm-kernel,
linux-riscv, linux-stm32, Maxime Coquelin, netdev, Paolo Abeni
Switch from using the fix_mac_speed() hook to set_clk_tx_rate() to
manage the transmit clock.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/dwmac-thead.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
index f9f2bd65959f..c72ee759aae5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
@@ -101,10 +101,11 @@ static int thead_dwmac_set_txclk_dir(struct plat_stmmacenet_data *plat)
return 0;
}
-static void thead_dwmac_fix_speed(void *priv, int speed, unsigned int mode)
+static int thead_set_clk_tx_rate(void *bsp_priv, struct clk *clk_tx_i,
+ phy_interface_t interface, int speed)
{
+ struct thead_dwmac *dwmac = bsp_priv;
struct plat_stmmacenet_data *plat;
- struct thead_dwmac *dwmac = priv;
unsigned long rate;
long tx_rate;
u32 div, reg;
@@ -114,7 +115,7 @@ static void thead_dwmac_fix_speed(void *priv, int speed, unsigned int mode)
switch (plat->mac_interface) {
/* For MII, rxc/txc is provided by phy */
case PHY_INTERFACE_MODE_MII:
- return;
+ return 0;
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
@@ -127,23 +128,24 @@ static void thead_dwmac_fix_speed(void *priv, int speed, unsigned int mode)
tx_rate = rgmii_clock(speed);
if (tx_rate < 0) {
dev_err(dwmac->dev, "invalid speed %d\n", speed);
- return;
+ return tx_rate;
}
div = rate / tx_rate;
if (rate != tx_rate * div) {
dev_err(dwmac->dev, "invalid gmac rate %lu\n", rate);
- return;
+ return -EINVAL;
}
reg = FIELD_PREP(GMAC_PLLCLK_DIV_EN, 1) |
FIELD_PREP(GMAC_PLLCLK_DIV_NUM, div);
writel(reg, dwmac->apb_base + GMAC_PLLCLK_DIV);
- break;
+ return 0;
+
default:
dev_err(dwmac->dev, "unsupported phy interface %d\n",
plat->mac_interface);
- return;
+ return -EINVAL;
}
}
@@ -235,7 +237,7 @@ static int thead_dwmac_probe(struct platform_device *pdev)
dwmac->plat = plat;
dwmac->apb_base = apb;
plat->bsp_priv = dwmac;
- plat->fix_mac_speed = thead_dwmac_fix_speed;
+ plat->set_clk_tx_rate = thead_set_clk_tx_rate;
plat->init = thead_dwmac_init;
return devm_stmmac_pltfr_probe(pdev, plat, &stmmac_res);
--
2.30.2
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 11/11] net: stmmac: thead: switch to use set_clk_tx_rate() hook
2025-02-27 9:17 ` [PATCH net-next 11/11] net: stmmac: thead: switch to use set_clk_tx_rate() hook Russell King (Oracle)
@ 2025-02-27 14:04 ` Andrew Lunn
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2025-02-27 14:04 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, Alexandre Torgue, Andrew Lunn, David S. Miller,
Drew Fustini, Eric Dumazet, Fu Wei, Guo Ren, Jakub Kicinski,
linux-arm-kernel, linux-riscv, linux-stm32, Maxime Coquelin,
netdev, Paolo Abeni
On Thu, Feb 27, 2025 at 09:17:14AM +0000, Russell King (Oracle) wrote:
> Switch from using the fix_mac_speed() hook to set_clk_tx_rate() to
> manage the transmit clock.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ 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:17 ` [PATCH net-next 11/11] net: stmmac: thead: switch to use set_clk_tx_rate() hook 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
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-02-28 18:50 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:17 ` [PATCH net-next 11/11] net: stmmac: thead: switch to use set_clk_tx_rate() hook Russell King (Oracle)
2025-02-27 14:04 ` 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