From patchwork Mon Feb 24 16:53:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13988516 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 15BF4C021BC for ; Mon, 24 Feb 2025 16:58:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=umYeIPet2tcZyz4GzEekGgRyYmU8ulrysbDkXqBk+Z8=; b=tr9pJxOdnpdGBqk8YHIyCsAuf9 rWbUPR+Waj4bgnn9ZUAIK/NxdCtEf7XwLVpfBl+wPbH5LklgrTDE6lq+lgXW0+zbtlj+kliaFjMrb y6f4/OluMfvU+4def+LAREIZrkkoTD8Lo6gw1JaQeIZDsef0lyzz8opvJZGM6aKWsKrqAzI2nmK3v SRRDizt2e5tqk/ugkfmHbLhn+uZlSwzXz+yYZpuhJQvvCNF/pdaFcEyzXREjs9ZNnrwAP+/wOp0iH cbeddSJ+KfGJCnEW4OvL4mn0COBbxpH6s+X/tSrWmXf4JcyLu6qNihopzlilezE0G+DcUR6rJBPjx L78hDjpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tmbmS-0000000EWPz-3lhI; Mon, 24 Feb 2025 16:58:08 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tmbi8-0000000EVBW-1P21 for linux-arm-kernel@lists.infradead.org; Mon, 24 Feb 2025 16:53:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=umYeIPet2tcZyz4GzEekGgRyYmU8ulrysbDkXqBk+Z8=; b=aYpPnCOzBaiW1h9FMViYsO37xl uAu9j110cWm/Xiq3L68vMVAL/DIQ+DgbH+Ai8s/Ke4BGIaXTgd01H+Tg0YhFLyrf7okYzaMstmIak bwtexRyX/keJy4Fd2U2+3Un/R7HvbQX6GbTfyIs9qDHK5NyBSJiHSv4xLzJnKZc7KcwEuvCWj1b4t RSFhlZUsTxvnG6tV9CAJclg6sBxk9uE6ZQ1+3RHN/0miGmM2UY6R+jjUQfn5EBSNWG+e0yAcHpqZi ycg5BJmJ5e/AhnaY5qTjU+/7yUYHJ1wTgLNsXV3to29zatZqDhT6QHK3GMsJ999r2LnAFdT68dvpe cX9BzIGw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:36038 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tmbi3-00070W-2M; Mon, 24 Feb 2025 16:53:35 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tmbhj-004vSz-Pt; Mon, 24 Feb 2025 16:53:15 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni Subject: [PATCH net-next v3 2/2] net: stmmac: dwc-qos: clean up clock initialisation MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Mon, 24 Feb 2025 16:53:15 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250224_085340_373979_E7FCA3B3 X-CRM114-Status: GOOD ( 14.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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) Reviewed-by: Andrew Lunn --- .../stmicro/stmmac/dwmac-dwc-qos-eth.c | 33 +++++++++++-------- 1 file changed, 19 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 acb0a2e1664f..6cadf24a575c 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 NULL; +} + 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 = plat_dat->stmmac_clk; if (!is_of_node(dev->fwnode)) goto bypass_clk_reset_gpio; - for (int i = 0; i < plat_dat->num_clks; i++) { - if (strcmp(plat_dat->clks[i].id, "slave_bus") == 0) { - eqos->clk_slave = plat_dat->clks[i].clk; - plat_dat->stmmac_clk = eqos->clk_slave; - } else if (strcmp(plat_dat->clks[i].id, "tx") == 0) { - eqos->clk_tx = plat_dat->clks[i].clk; - } - } + eqos->clk_tx = dwc_eth_find_clk(plat_dat, "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 *plat_dat, 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,9 @@ 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); + ret = data->probe(pdev, plat_dat, &stmmac_res); if (ret < 0) { dev_err_probe(&pdev->dev, ret, "failed to probe subdriver\n");