[v3,03/19] ARM: imx6q: skip ethernet refclock reconfiguration if enet_clk_ref is present
Message ID | 20230131084642.709385-4-o.rempel@pengutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2637251wrn; Tue, 31 Jan 2023 00:53:41 -0800 (PST) X-Google-Smtp-Source: AK7set+nUtAV8QwdmFh7pSJX7prH0KdRC8utoZITqrcsMzCipetqnX0zn5NmlaD/ieMzlgg3V3xm X-Received: by 2002:a17:90a:e7cd:b0:228:d42c:d5d6 with SMTP id kb13-20020a17090ae7cd00b00228d42cd5d6mr12489977pjb.27.1675155221195; Tue, 31 Jan 2023 00:53:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675155221; cv=none; d=google.com; s=arc-20160816; b=XqaUKhgCkZKTTfQbaML/zkn3u9uh+9Ldh+XvTucHrlMBAFyjyfrubD6+mt9SlPGjzD 8o2KeEblx53naSiTlhLsu8YHmGyJAbEGoQScgaMgu8krnTKcyyME6gCTRgxhaFguCYPI FDJhhzunhh05V+1X207IhUr394C3RYTnYVORQ00C1h9cQFTwIpwBfsZ4+OrOF6eYaCRd +QXqFsHBA8sKpTZgmx3K+A1ZaYU7xVD5C9/tsdKh7e392J6DZ5254iUHUjo8Ednk2Q4s 67cUdBVKVq0CaVMgbntu0O6KSlEFGUmoZiL0lo6qp2X8kc3rxXXZ/qPmlL0bsAMEvb5u 2dGw== 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=NKAM+52DP2e8x/TtHek9h1Bhf4AHTLQuWAxwKS2y76c=; b=OoAEHN0I3Oa9vyD4OiO0vJa8QVOVxLkOtYECvlLTEFG9HjXe53rphvVsAGx1DoiwRG a2EF4PYFY+p1xDckoXbYjUfq6cadchbNKOPueKUw7BaZQUlOtlAMb+JwlaH+yt8sSH5j 69sBAGV0UBKcW9FS8i32ooIv7F7Q80/8RzPYxSoVgKHA+S4o0zqhd7av9f+uZ1/VMb6I mccBJymqx62qhx7xSBNR3eqGjV4ngmi2kAoq5cXrw4vL7Cfqo1WZDyQ/c0Zxnj45bjjY SW6fhQfLIFX1rpoEYGsQFX0/D8OfjnHVCy80PtzHttfC9iUse5iKpbL2MJPJ3Fwia4Uu Ix7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s1-20020a17090a948100b00228f8ce4657si19395847pjo.5.2023.01.31.00.53.27; Tue, 31 Jan 2023 00:53:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232018AbjAaIvx (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Tue, 31 Jan 2023 03:51:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231640AbjAaIvV (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 31 Jan 2023 03:51:21 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E228A4FC25 for <linux-kernel@vger.kernel.org>; Tue, 31 Jan 2023 00:47:24 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <ore@pengutronix.de>) id 1pMmHv-0003tF-9d; Tue, 31 Jan 2023 09:46:47 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from <ore@pengutronix.de>) id 1pMmHv-001eLx-9n; Tue, 31 Jan 2023 09:46:46 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from <ore@pengutronix.de>) id 1pMmHr-002yZK-1d; Tue, 31 Jan 2023 09:46:43 +0100 From: Oleksij Rempel <o.rempel@pengutronix.de> To: Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Shawn Guo <shawnguo@kernel.org>, Sascha Hauer <s.hauer@pengutronix.de>, Abel Vesa <abelvesa@kernel.org>, Michael Turquette <mturquette@baylibre.com>, Stephen Boyd <sboyd@kernel.org>, Richard Cochran <richardcochran@gmail.com> Cc: Oleksij Rempel <o.rempel@pengutronix.de>, kernel@pengutronix.de, Fabio Estevam <festevam@gmail.com>, NXP Linux Team <linux-imx@nxp.com>, Russell King <linux@armlinux.org.uk>, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v3 03/19] ARM: imx6q: skip ethernet refclock reconfiguration if enet_clk_ref is present Date: Tue, 31 Jan 2023 09:46:26 +0100 Message-Id: <20230131084642.709385-4-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230131084642.709385-1-o.rempel@pengutronix.de> References: <20230131084642.709385-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756527561374904015?= X-GMAIL-MSGID: =?utf-8?q?1756527561374904015?= |
Series |
ARM: imx: make Ethernet refclock configurable
|
|
Commit Message
Oleksij Rempel
Jan. 31, 2023, 8:46 a.m. UTC
Current mach-imx6q code has following logic:
- if ptp clock of the ethernet controller node is attached to the SoC
internal enet_ref clock, then we configure RMII reference clock pin as
output by setting IOMUXC_GPR1 BIT(21).
In this case - MAC (SoC) is the clock provider, PHY is the clock consumer.
- if ptp clock of the ethernet controller node is not attached to the
enet_ref clock, then we configure RMII reference clock pin as input by
clearing IOMUXC_GPR1 BIT(21).
In this case - PHY is the clock provider, MAC is the clock consumer.
According to the Freescale MX6SDL ReferenceManual v4, IOMUXC_GPR1 BIT(21)
(page 2033) this configuration bit is not related to the PTP (IEEE1588)
clock:
21 ENET_CLK_SEL - choose enet reference clk mode:
0 - get enet tx reference clk from pad (external OSC for both external
PHY and Internal Controller)
1 - get enet tx reference clk from internal clock from anatop (loopback
through pad), this clock also sent out to external PHY.
According to the Documentation/devicetree/bindings/net/fsl,fec.yaml:
The "ptp"(option), for IEEE1588 timer clock that requires the clock.
The "enet_clk_ref"(option), for MAC transmit/receiver reference clock
like RGMII TXC clock or RMII reference clock. It depends on board
design, the clock is required if RGMII TXC and RMII reference clock
source from SOC internal PLL.
The "enet_out"(option), output clock for external device, like supply
clock for PHY. The clock is required if PHY clock source from SOC.
We can see, that "enet_clk_ref" clock is the best fit for this purpose.
Other properties like "ptp" is designed for IEEE1588 and "enet_out" do
not have real functionality within imx related clock infrastructure.
Since the "enet_clk_ref" is not used by the imx6qdl devicetrees, we can
use it as indicator of potentially properly configured DT. At same time
we can keep ptp clock based logic as the fallback for old DTs.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
arch/arm/mach-imx/mach-imx6q.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c index c9d7c29d95e1..7f6200925752 100644 --- a/arch/arm/mach-imx/mach-imx6q.c +++ b/arch/arm/mach-imx/mach-imx6q.c @@ -79,7 +79,7 @@ static void __init imx6q_enet_phy_init(void) static void __init imx6q_1588_init(void) { struct device_node *np; - struct clk *ptp_clk; + struct clk *ptp_clk, *fec_enet_ref; struct clk *enet_ref; struct regmap *gpr; u32 clksel; @@ -90,6 +90,14 @@ static void __init imx6q_1588_init(void) return; } + /* + * If enet_clk_ref configured, we assume DT did it properly and . + * clk-imx6q.c will do needed configuration. + */ + fec_enet_ref = of_clk_get_by_name(np, "enet_clk_ref"); + if (!IS_ERR(fec_enet_ref)) + goto put_node; + ptp_clk = of_clk_get(np, 2); if (IS_ERR(ptp_clk)) { pr_warn("%s: failed to get ptp clock\n", __func__);