From patchwork Mon Dec 14 09:16:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 11971641 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.8 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 DAEDBC4361B for ; Mon, 14 Dec 2020 09:21:37 +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 9373D20771 for ; Mon, 14 Dec 2020 09:21:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9373D20771 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=C6ISL4z0pe4JeCjVgELSwZ+BR0LGjgiIdngkrK99cLU=; b=wlvpbCanQkMvf+0mWRkSMLUAH /EGUqkWl69qBc4vzLrKbCwxhDjK7oKMgZBoWEMxXbx4xPHlQDWGPKlXucjXkB2+JX5g2HGZB0PT4z 4TlpCWo5ZIRSeidXy6DZ3fA5bXzPRLgVnGku83t61QOMjzHmSp11hyi/dw+hbvPAMk5JCrUFgWs6H Gp4PAwiO2Rl9nogHVngCKVrGKpXHWTdA57fLjXNoIvAmvQQd6yMHAXIlPs35QZftsuz/T4+/JknsE 3zEg3WURkj+vvWUUi9aQ+HLNUn3LpB2T1BBhQl77JRql+3e+pIqDq+crpdmEneyuUORUV2Xd36gzz UOuC3vIvQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kok1O-0003Oi-Uc; Mon, 14 Dec 2020 09:19:59 +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 1kojy9-0001ZQ-EV for linux-arm-kernel@lists.infradead.org; Mon, 14 Dec 2020 09:16:44 +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 20/25] net: stmmac: Add Tx/Rx platform clocks support Date: Mon, 14 Dec 2020 12:16:10 +0300 Message-ID: <20201214091616.13545-21-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 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-20201214_041637_811781_99E3E904 X-CRM114-Status: GOOD ( 13.13 ) 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 | 24 +++++++++++++++++++ include/linux/stmmac.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 38e8836861c4..943498d57e3a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -588,6 +588,24 @@ 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)) { @@ -613,6 +631,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); @@ -634,6 +656,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 628e28903b8b..b75cf13d088c 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -185,6 +185,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;