netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: stmmac: dwc-qos: clean up clock initialisation
@ 2025-02-21 11:38 ` Russell King (Oracle)
  2025-02-24 19:24   ` Russell King (Oracle)
  2025-02-26 10:26   ` Swathi K S
  0 siblings, 2 replies; 3+ messages in thread
From: Russell King (Oracle) @ 2025-02-21 11:38 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 clock initialisation by providing a helper to find a
named clock in the bulk clocks, and provide the name of the stmmac
clock in match data so we can locate the stmmac clock in generic
code.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
dwc_eth_find_clk() should probably become a generic helper given that
plat_dat->clks is part of the core platform support code, but that
can be done later when converting more drivers - which I will get
around to once I've got the set_clk_tx_rate() patch series out that
someone else needs to make progress.

 .../stmicro/stmmac/dwmac-dwc-qos-eth.c        | 32 +++++++++++--------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index 392574bdd4a4..9e2035d1fb86 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -35,6 +35,16 @@ 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 0;
+}
+
 static int dwc_eth_dwmac_config_dt(struct platform_device *pdev,
 				   struct plat_stmmacenet_data *plat_dat)
 {
@@ -121,12 +131,7 @@ static int dwc_qos_probe(struct platform_device *pdev,
 			 struct plat_stmmacenet_data *plat_dat,
 			 struct stmmac_resources *stmmac_res)
 {
-	for (int i = 0; i < plat_dat->num_clks; i++) {
-		if (strcmp(plat_dat->clks[i].id, "apb_pclk") == 0)
-			plat_dat->stmmac_clk = plat_dat->clks[i].clk;
-		else if (strcmp(plat_dat->clks[i].id, "phy_ref_clk") == 0)
-			plat_dat->pclk = plat_dat->clks[i].clk;
-	}
+	plat_dat->pclk = dwc_eth_find_clk(plat_dat, "phy_ref_clk");
 
 	return 0;
 }
@@ -237,18 +242,12 @@ static int tegra_eqos_probe(struct platform_device *pdev,
 
 	eqos->dev = &pdev->dev;
 	eqos->regs = res->addr;
+	eqos->clk_slave = data->stmmac_clk;
 
 	if (!is_of_node(dev->fwnode))
 		goto bypass_clk_reset_gpio;
 
-	for (int i = 0; i < data->num_clks; i++) {
-		if (strcmp(data->clks[i].id, "slave_bus") == 0) {
-			eqos->clk_slave = data->clks[i].clk;
-			data->stmmac_clk = eqos->clk_slave;
-		} else if (strcmp(data->clks[i].id, "tx") == 0) {
-			eqos->clk_tx = data->clks[i].clk;
-		}
-	}
+	eqos->clk_tx = dwc_eth_find_clk(data, "tx");
 
 	eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(eqos->reset)) {
@@ -312,15 +311,18 @@ struct dwc_eth_dwmac_data {
 		     struct plat_stmmacenet_data *data,
 		     struct stmmac_resources *res);
 	void (*remove)(struct platform_device *pdev);
+	const char *stmmac_clk_name;
 };
 
 static const struct dwc_eth_dwmac_data dwc_qos_data = {
 	.probe = dwc_qos_probe,
+	.stmmac_clk_name = "apb_pclk",
 };
 
 static const struct dwc_eth_dwmac_data tegra_eqos_data = {
 	.probe = tegra_eqos_probe,
 	.remove = tegra_eqos_remove,
+	.stmmac_clk_name = "slave_bus",
 };
 
 static int dwc_eth_dwmac_probe(struct platform_device *pdev)
@@ -360,6 +362,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");
 
+	data->stmmac_clk = dwc_eth_find_clk(plat_dat, data->stmmac_clk_name);
+
 	ret = data->probe(pdev, plat_dat, &stmmac_res);
 	if (ret < 0) {
 		dev_err_probe(&pdev->dev, ret, "failed to probe subdriver\n");
-- 
2.30.2


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

* Re: [PATCH net-next] net: stmmac: dwc-qos: clean up clock initialisation
  2025-02-21 11:38 ` [PATCH net-next] net: stmmac: dwc-qos: clean up clock initialisation Russell King (Oracle)
@ 2025-02-24 19:24   ` Russell King (Oracle)
  2025-02-26 10:26   ` Swathi K S
  1 sibling, 0 replies; 3+ messages in thread
From: Russell King (Oracle) @ 2025-02-24 19:24 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
	David S. Miller, Eric Dumazet, linux-arm-kernel, linux-stm32,
	Maxime Coquelin, netdev, Paolo Abeni

On Fri, Feb 21, 2025 at 11:38:25AM +0000, Russell King (Oracle) wrote:
> Clean up the clock initialisation by providing a helper to find a
> named clock in the bulk clocks, and provide the name of the stmmac
> clock in match data so we can locate the stmmac clock in generic
> code.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
> dwc_eth_find_clk() should probably become a generic helper given that
> plat_dat->clks is part of the core platform support code, but that
> can be done later when converting more drivers - which I will get
> around to once I've got the set_clk_tx_rate() patch series out that
> someone else needs to make progress.

Jakub,

This one can also be removed from patchwork.

Thanks!

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

* Re: [PATCH net-next] net: stmmac: dwc-qos: clean up clock initialisation
  2025-02-21 11:38 ` [PATCH net-next] net: stmmac: dwc-qos: clean up clock initialisation Russell King (Oracle)
  2025-02-24 19:24   ` Russell King (Oracle)
@ 2025-02-26 10:26   ` Swathi K S
  1 sibling, 0 replies; 3+ messages in thread
From: Swathi K S @ 2025-02-26 10:26 UTC (permalink / raw)
  To: rmk+kernel
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, krzk+dt, swathi.ks, netdev, devicetree,
	linux-stm32, linux-arm-kernel, linux-kernel, pankaj.dubey,
	ravi.patel, gost.dev

>Precedence: bulk
>X-Mailing-List: netdev@vger.kernel.org
>List-Id: <netdev.vger.kernel.org>
>List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
>List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
>MIME-Version: 1.0
>Content-Disposition: inline
>Content-Transfer-Encoding: 8bit
>Content-Type: text/plain; charset="utf-8"
>Message-Id: <E1tlRMP-004Vt5-W1@rmk-PC.armlinux.org.uk>
>Sender: Russell King <rmk@armlinux.org.uk>
>Date: Fri, 21 Feb 2025 11:38:25 +0000
>
>Clean up the clock initialisation by providing a helper to find a
>named clock in the bulk clocks, and provide the name of the stmmac
>clock in match data so we can locate the stmmac clock in generic
>code.
>
>Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
>---
>dwc_eth_find_clk() should probably become a generic helper given that
>plat_dat->clks is part of the core platform support code, but that
>can be done later when converting more drivers - which I will get
>around to once I've got the set_clk_tx_rate() patch series out that
>someone else needs to make progress.
>
> .../stmicro/stmmac/dwmac-dwc-qos-eth.c        | 32 +++++++++++--------
> 1 file changed, 18 insertions(+), 14 deletions(-)
>
>diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
>index 392574bdd4a4..9e2035d1fb86 100644
>--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
>+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
>@@ -35,6 +35,16 @@ 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 0;
>+}
>+
> static int dwc_eth_dwmac_config_dt(struct platform_device *pdev,
> 				   struct plat_stmmacenet_data *plat_dat)
> {
>@@ -121,12 +131,7 @@ static int dwc_qos_probe(struct platform_device *pdev,
> 			 struct plat_stmmacenet_data *plat_dat,
> 			 struct stmmac_resources *stmmac_res)
> {
>-	for (int i = 0; i < plat_dat->num_clks; i++) {
>-		if (strcmp(plat_dat->clks[i].id, "apb_pclk") == 0)
>-			plat_dat->stmmac_clk = plat_dat->clks[i].clk;
>-		else if (strcmp(plat_dat->clks[i].id, "phy_ref_clk") == 0)
>-			plat_dat->pclk = plat_dat->clks[i].clk;
>-	}
>+	plat_dat->pclk = dwc_eth_find_clk(plat_dat, "phy_ref_clk");
> 
> 	return 0;
> }
>@@ -237,18 +242,12 @@ static int tegra_eqos_probe(struct platform_device *pdev,
> 
> 	eqos->dev = &pdev->dev;
> 	eqos->regs = res->addr;
>+	eqos->clk_slave = data->stmmac_clk;
> 
> 	if (!is_of_node(dev->fwnode))
> 		goto bypass_clk_reset_gpio;
> 
>-	for (int i = 0; i < data->num_clks; i++) {
>-		if (strcmp(data->clks[i].id, "slave_bus") == 0) {
>-			eqos->clk_slave = data->clks[i].clk;
>-			data->stmmac_clk = eqos->clk_slave;
>-		} else if (strcmp(data->clks[i].id, "tx") == 0) {
>-			eqos->clk_tx = data->clks[i].clk;
>-		}
>-	}
>+	eqos->clk_tx = dwc_eth_find_clk(data, "tx");
> 
> 	eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset", GPIOD_OUT_HIGH);
> 	if (IS_ERR(eqos->reset)) {
>@@ -312,15 +311,18 @@ struct dwc_eth_dwmac_data {
> 		     struct plat_stmmacenet_data *data,
> 		     struct stmmac_resources *res);
> 	void (*remove)(struct platform_device *pdev);
>+	const char *stmmac_clk_name;
> };
> 
> static const struct dwc_eth_dwmac_data dwc_qos_data = {
> 	.probe = dwc_qos_probe,
>+	.stmmac_clk_name = "apb_pclk",
> };
> 
> static const struct dwc_eth_dwmac_data tegra_eqos_data = {
> 	.probe = tegra_eqos_probe,
> 	.remove = tegra_eqos_remove,
>+	.stmmac_clk_name = "slave_bus",
> };
> 
> static int dwc_eth_dwmac_probe(struct platform_device *pdev)
>@@ -360,6 +362,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");
> 
>+	data->stmmac_clk = dwc_eth_find_clk(plat_dat, data->stmmac_clk_name);
>+
> 	ret = data->probe(pdev, plat_dat, &stmmac_res);
> 	if (ret < 0) {
> 		dev_err_probe(&pdev->dev, ret, "failed to probe subdriver\n");

Hi Russell,
Tested this patch on FSD platform and it works.
Please feel free to add Tested-by: Swathi K S <swathi.ks@samsung.com>

-Swathi

>-- 
>2.30.2

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

end of thread, other threads:[~2025-02-27  3:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20250226103145epcas5p12873b39b9b467f35a38151e1938976d4@epcas5p1.samsung.com>
2025-02-21 11:38 ` [PATCH net-next] net: stmmac: dwc-qos: clean up clock initialisation Russell King (Oracle)
2025-02-24 19:24   ` Russell King (Oracle)
2025-02-26 10:26   ` Swathi K S

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