From patchwork Mon Feb 8 13:56:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 12076085 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=-14.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 899E3C433E9 for ; Mon, 8 Feb 2021 17:22:07 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B8F5E64E56 for ; Mon, 8 Feb 2021 17:22:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8F5E64E56 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baikalelectronics.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SvNg+VudJebEcGsgTRovTG3JcUKgaEaSYRPUaMlo0cM=; b=bReYpbO/PwhDUmYbGCHZWuoLc FlU7mOyHk6Ml/vYNECxBLgorDP/a5JvT2YwFgc2FjcwtwmMN68tSCcHCBZiCJZTUjWplyZz0g2hkA ealVZ6Hy7JHbjzPTjn+0ZokAk9jEMah7CofhbmcmB5TtT/GcQUAKVXYTtvVEOoYF0rr4+NsnE5PyB ZPMCWADsv0E2cJUoKOQO20qizS/lpcm5kMi66A3fq4+6adcvpvUHWiaBmJGFiPk4PVsDCtiS+lZSg 2Labco//lvTGOLLxJskFt5FY4L4JXHSK2hDQ73eT5YctoT9KmuFDiX7jId4xwe5sJFvvwS+MG3sdU yzG/yElxA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l97GP-0006wS-1s; Mon, 08 Feb 2021 14:11:41 +0000 Received: from mail.baikalelectronics.com ([87.245.175.226] helo=mail.baikalelectronics.ru) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l97B3-00048v-AI for linux-arm-kernel@lists.infradead.org; Mon, 08 Feb 2021 14:06:12 +0000 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 Subject: [PATCH v2 19/24] net: stmmac: Add Tx/Rx platform clocks support Date: Mon, 8 Feb 2021 16:56:03 +0300 Message-ID: <20210208135609.7685-20-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> References: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210208_090609_902642_7CE05EE8 X-CRM114-Status: GOOD ( 12.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin , Alexey Malahov , Serge Semin , Vyacheslav Mitrofanov , Pavel Parkhomenko , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Depending on the DW *MAC configuration it can be at least connected to an external Transmit clock, but in some cases to an external Receive clock generator. In order to simplify/unify the sub-drivers code and to prevent having the same clocks named differently add the Tx/Rx clocks support to the generic STMMAC DT-based platform data initialization method under the names "tx" and "rx" respectively. The bindings schema has already been altered in accordance with that. Signed-off-by: Serge Semin --- .../ethernet/stmicro/stmmac/stmmac_platform.c | 22 +++++++++++++++++++ include/linux/stmmac.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 9a7c94622c36..a6e35c84e135 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -585,6 +585,22 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) } clk_prepare_enable(plat->pclk); + plat->tx_clk = devm_clk_get_optional(&pdev->dev, "tx"); + if (IS_ERR(plat->tx_clk)) { + rc = PTR_ERR(plat->tx_clk); + dev_err_probe(&pdev->dev, rc, "Cannot get Tx clock\n"); + goto error_tx_clk_get; + } + clk_prepare_enable(plat->tx_clk); + + plat->rx_clk = devm_clk_get_optional(&pdev->dev, "rx"); + if (IS_ERR(plat->rx_clk)) { + rc = PTR_ERR(plat->rx_clk); + dev_err_probe(&pdev->dev, rc, "Cannot get Rx clock\n"); + goto error_rx_clk_get; + } + clk_prepare_enable(plat->rx_clk); + /* Fall-back to main clock in case of no PTP ref is passed */ plat->clk_ptp_ref = devm_clk_get_optional(&pdev->dev, "ptp_ref"); if (IS_ERR(plat->clk_ptp_ref)) { @@ -609,6 +625,10 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) return plat; error_hw_init: + clk_disable_unprepare(plat->rx_clk); +error_rx_clk_get: + clk_disable_unprepare(plat->tx_clk); +error_tx_clk_get: clk_disable_unprepare(plat->pclk); error_pclk_get: clk_disable_unprepare(plat->stmmac_clk); @@ -630,6 +650,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) void stmmac_remove_config_dt(struct platform_device *pdev, struct plat_stmmacenet_data *plat) { + clk_disable_unprepare(plat->rx_clk); + clk_disable_unprepare(plat->tx_clk); clk_disable_unprepare(plat->pclk); clk_disable_unprepare(plat->stmmac_clk); of_node_put(plat->phy_node); diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index 15ca6b4167cc..cec970adaf2e 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -186,6 +186,8 @@ struct plat_stmmacenet_data { void *bsp_priv; struct clk *stmmac_clk; struct clk *pclk; + struct clk *tx_clk; + struct clk *rx_clk; struct clk *clk_ptp_ref; unsigned int clk_ptp_rate; unsigned int clk_ref_rate;