Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4024497pxb; Mon, 8 Feb 2021 06:16:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJymbTjbpI20Wav7iJaOnL9LnGC6G1NkiTxSrgOnkPts8dPBMdCKN4E6I6a5LN81lwKxwdpe X-Received: by 2002:a17:906:ce24:: with SMTP id sd4mr16606766ejb.21.1612793808961; Mon, 08 Feb 2021 06:16:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612793808; cv=none; d=google.com; s=arc-20160816; b=MGktDrg6cxIIpAITzT0BL+2T8KUmoRbOyG3YtoDGxh3d2L6KAIDshlbp4uXFZ9tuOZ Mbpardm6m4OD3oqhQYc9hfX44Av8Wz+5DByE7lhLyu3++fvUYWiD6lex9GBGWDhC9z3J k3p/oE4w5KJ+7+N24Nrk4zSt6o55kVCa+t7+WiHrTosfZ4Md91AiHUpXAwS9FWD0D1dL IT6OnIWmMM6oUzK+UwaUmTup+534K+b4KqJuZ8plM9r1Yt6LVW3GSYwW0v7qeYsoG0jM APsAMFlJXrj1OFwa9yMhNSwYtSLqOa2UOWWn2eIR/GwSluhR9zdxFt8hCVn63CMDWlLw uW7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=LQjFvyQq2FeUl14k3g5/8AdStgCK4AjHPt+6lLT4PLA=; b=RoEwkWW4iy4rZdoxJcFu3IqddfDk/OUplrXz5YmY/+D3wxxKnbCNTeWKtOnrjnooRd lM1UOowd1P/Y3ISQGDb9TWEI1NU4NTbZbGWQ9QYn6eW+ajizLhmQEHH4bM7ay7JPtifG gMgtZjDa1hpDYYpXWrC5jFhDlPHC5+sWGJAcdfbCtX3Z+moJgkuU3FgDxGj6PVWAEQrm S8E//yudUfhjuTpdaMbj5/ERE+TFpmekyZpO/xGvCxBcboBmn2rEgEycmbCRD8O9mzqJ QQ8v9IiFDyj9GHK/wY4XNlqFlK7Vzwpwk7Q8+TqZeZVgg5mz/ajw1jSUfMSUQIkJGTBH 3HyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cx13si240281edb.500.2021.02.08.06.16.25; Mon, 08 Feb 2021 06:16:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231953AbhBHOMc (ORCPT + 99 others); Mon, 8 Feb 2021 09:12:32 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:57070 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232021AbhBHN6L (ORCPT ); Mon, 8 Feb 2021 08:58:11 -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 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 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 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; -- 2.29.2