From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12781C4361B for ; Mon, 14 Dec 2020 09:23:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C592520771 for ; Mon, 14 Dec 2020 09:23:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407579AbgLNJXZ (ORCPT ); Mon, 14 Dec 2020 04:23:25 -0500 Received: from ns2.chip.baikal.ru ([94.125.187.42]:46526 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2439739AbgLNJSP (ORCPT ); Mon, 14 Dec 2020 04:18:15 -0500 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH 21/25] net: stmmac: dwc-qos: Discard Tx/Rx clocks request Date: Mon, 14 Dec 2020 12:16:11 +0300 Message-ID: <20201214091616.13545-22-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> References: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the Tx/Rx clocks with the same names are now requested and enabled/disabled in the STMMAC DT-based platform config method, there is no need in duplicating the same procedures in the DWC QoS Eth sub-driver. Discard it then, but make sure the denoted clocks have been specified for the platform. Note also the deprecated clock "phy_ref_clk" have been defined as the Tx clock in the DWC QoS Eth bindings. Let's use a pointer to the Tx clock defined in the platform data then instead of the unrelated pclk pointer. Signed-off-by: Serge Semin --- .../stmicro/stmmac/dwmac-dwc-qos-eth.c | 44 +++++-------------- 1 file changed, 11 insertions(+), 33 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 57f957898b60..f53a78448988 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c @@ -31,8 +31,6 @@ struct tegra_eqos { struct reset_control *rst; struct clk *clk_master; struct clk *clk_slave; - struct clk *clk_tx; - struct clk *clk_rx; struct gpio_desc *reset; }; @@ -155,7 +153,7 @@ static void *dwc_qos_probe(struct platform_device *pdev, goto disable; } - plat_dat->pclk = clk; + plat_dat->tx_clk = clk; return NULL; @@ -175,8 +173,8 @@ static int dwc_qos_remove(struct platform_device *pdev) * data so the stmmac_remove_config_dt() method wouldn't have disabled * the clocks too. */ - clk_disable_unprepare(priv->plat->pclk); - priv->plat->pclk = NULL; + clk_disable_unprepare(priv->plat->tx_clk); + priv->plat->tx_clk = NULL; clk_disable_unprepare(priv->plat->stmmac_clk); priv->plat->stmmac_clk = NULL; @@ -197,6 +195,7 @@ static int dwc_qos_remove(struct platform_device *pdev) static void tegra_eqos_fix_speed(void *priv, unsigned int speed) { struct tegra_eqos *eqos = priv; + struct stmmac_priv *sp = netdev_priv(dev_get_drvdata(eqos->dev)); unsigned long rate = 125000000; bool needs_calibration = false; u32 value; @@ -262,7 +261,7 @@ static void tegra_eqos_fix_speed(void *priv, unsigned int speed) writel(value, eqos->regs + AUTO_CAL_CONFIG); } - err = clk_set_rate(eqos->clk_tx, rate); + err = clk_set_rate(sp->plat->tx_clk, rate); if (err < 0) dev_err(eqos->dev, "failed to set TX rate: %d\n", err); } @@ -301,6 +300,11 @@ static void *tegra_eqos_probe(struct platform_device *pdev, if (!is_of_node(dev->fwnode)) goto bypass_clk_reset_gpio; + if (!data->tx_clk || !data->rx_clk) { + err = -EINVAL; + goto error; + } + eqos->clk_master = devm_clk_get(&pdev->dev, "master_bus"); if (IS_ERR(eqos->clk_master)) { err = PTR_ERR(eqos->clk_master); @@ -323,30 +327,10 @@ static void *tegra_eqos_probe(struct platform_device *pdev, data->stmmac_clk = eqos->clk_slave; - eqos->clk_rx = devm_clk_get(&pdev->dev, "rx"); - if (IS_ERR(eqos->clk_rx)) { - err = PTR_ERR(eqos->clk_rx); - goto disable_slave; - } - - err = clk_prepare_enable(eqos->clk_rx); - if (err < 0) - goto disable_slave; - - eqos->clk_tx = devm_clk_get(&pdev->dev, "tx"); - if (IS_ERR(eqos->clk_tx)) { - err = PTR_ERR(eqos->clk_tx); - goto disable_rx; - } - - err = clk_prepare_enable(eqos->clk_tx); - if (err < 0) - goto disable_rx; - eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset", GPIOD_OUT_HIGH); if (IS_ERR(eqos->reset)) { err = PTR_ERR(eqos->reset); - goto disable_tx; + goto disable_slave; } usleep_range(2000, 4000); @@ -389,10 +373,6 @@ static void *tegra_eqos_probe(struct platform_device *pdev, reset_control_assert(eqos->rst); reset_phy: gpiod_set_value(eqos->reset, 1); -disable_tx: - clk_disable_unprepare(eqos->clk_tx); -disable_rx: - clk_disable_unprepare(eqos->clk_rx); disable_slave: clk_disable_unprepare(eqos->clk_slave); data->stmmac_clk = NULL; @@ -410,8 +390,6 @@ static int tegra_eqos_remove(struct platform_device *pdev) reset_control_assert(eqos->rst); gpiod_set_value(eqos->reset, 1); - clk_disable_unprepare(eqos->clk_tx); - clk_disable_unprepare(eqos->clk_rx); clk_disable_unprepare(eqos->clk_slave); clk_disable_unprepare(eqos->clk_master); -- 2.29.2