Skip to contentSkip to conversation

net: stmmac: stmmac_pltfr_find_clk()

PATCH Applied Russell King (Oracle) 4 participants 5 messages Apr 9, 2025 – Apr 11, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover net: stmmac: stmmac_pltfr_find_clk()

Hi,

The GBETH glue driver that is being proposed duplicates the clock finding from the bulk clock data in the stmmac platform data structure. iLet's provide a generic implementation that glue drivers can use, and convert dwc-qos-eth to use it.

 drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 18 ++------------
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c   | 11 +++++++++++
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h   |  3 +++
 3 files changed, 18 insertions(+), 14 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
#1 lore raw

PATCH v2 1/2 net: stmmac: provide stmmac_pltfr_find_clk()

Provide a generic way to find a clock in the bulk data.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 11 +++++++++++
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h |  3 +++
 2 files changed, 14 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +11 -0
index c73eff6a56b8..43c869f64c39 100644
@@ -709,6 +709,17 @@ devm_stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
 #endif /* CONFIG_OF */
 EXPORT_SYMBOL_GPL(devm_stmmac_probe_config_dt);
 
+struct clk *stmmac_pltfr_find_clk(struct plat_stmmacenet_data *plat_dat,
+				  const char *name)
+{
+	for (int i = 0; i < plat_dat->num_clks; i++)
+		if (strcmp(plat_dat->clks[i].id, name) == 0)
+			return plat_dat->clks[i].clk;
+
+	return NULL;
+}
+EXPORT_SYMBOL_GPL(stmmac_pltfr_find_clk);
+
 int stmmac_get_platform_resources(struct platform_device *pdev,
 				  struct stmmac_resources *stmmac_res)
 {
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h +3 -0
index 72dc1a32e46d..6e6561e29d6e 100644
@@ -14,6 +14,9 @@
 struct plat_stmmacenet_data *
 devm_stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac);
 
+struct clk *stmmac_pltfr_find_clk(struct plat_stmmacenet_data *plat_dat,
+				  const char *name);
+
 int stmmac_get_platform_resources(struct platform_device *pdev,
 				  struct stmmac_resources *stmmac_res);
 
Signature · 1 line
2.30.2
#2 lore raw

PATCH v2 2/2 net: stmmac: dwc-qos: use stmmac_pltfr_find_clk()

In reply to Russell King (Oracle)
---
 .../stmicro/stmmac/dwmac-dwc-qos-eth.c         | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +4 -14
index cd431f84f34f..5db318327d33 100644
@@ -34,16 +34,6 @@ struct tegra_eqos {
 	struct gpio_desc *reset;
 };
 
-static struct clk *dwc_eth_find_clk(struct plat_stmmacenet_data *plat_dat,
-				    const char *name)
-{
-	for (int i = 0; i < plat_dat->num_clks; i++)
-		if (strcmp(plat_dat->clks[i].id, name) == 0)
-			return plat_dat->clks[i].clk;
-
-	return NULL;
-}
-
 static int dwc_eth_dwmac_config_dt(struct platform_device *pdev,
 				   struct plat_stmmacenet_data *plat_dat)
 {
@@ -132,7 +122,7 @@ static int dwc_qos_probe(struct platform_device *pdev,
 			 struct plat_stmmacenet_data *plat_dat,
 			 struct stmmac_resources *stmmac_res)
 {
-	plat_dat->pclk = dwc_eth_find_clk(plat_dat, "phy_ref_clk");
+	plat_dat->pclk = stmmac_pltfr_find_clk(plat_dat, "phy_ref_clk");
 
 	return 0;
 }
@@ -242,7 +232,7 @@ static int tegra_eqos_probe(struct platform_device *pdev,
 	if (!is_of_node(dev->fwnode))
 		goto bypass_clk_reset_gpio;
 
-	plat_dat->clk_tx_i = dwc_eth_find_clk(plat_dat, "tx");
+	plat_dat->clk_tx_i = stmmac_pltfr_find_clk(plat_dat, "tx");
 
 	eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(eqos->reset)) {
@@ -362,8 +352,8 @@ static int dwc_eth_dwmac_probe(struct platform_device *pdev)
 	if (ret)
 		return dev_err_probe(&pdev->dev, ret, "Failed to enable clocks\n");
 
-	plat_dat->stmmac_clk = dwc_eth_find_clk(plat_dat,
-						data->stmmac_clk_name);
+	plat_dat->stmmac_clk = stmmac_pltfr_find_clk(plat_dat,
+						     data->stmmac_clk_name);
 
 	if (data->probe)
 		ret = data->probe(pdev, plat_dat, &stmmac_res);
Signature · 1 line
2.30.2
#4 lore raw
In reply to Russell King (Oracle)
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Wed, 9 Apr 2025 08:55:09 +0100 you wrote:

Hi,

The GBETH glue driver that is being proposed duplicates the clock finding from the bulk clock data in the stmmac platform data structure. iLet's provide a generic implementation that glue drivers can use, and convert dwc-qos-eth to use it.

[...]

Here is the summary with links:
- [net-next,v2,1/2] net: stmmac: provide stmmac_pltfr_find_clk()

    https://git.kernel.org/netdev/net-next/c/de6487201949
  - [net-next,v2,2/2] net: stmmac: dwc-qos: use stmmac_pltfr_find_clk()
    https://git.kernel.org/netdev/net-next/c/34e816acdb0d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html