From patchwork Tue Jan 17 06:14:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 44513 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1588892wrn; Mon, 16 Jan 2023 22:18:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXucxInjLJbxBPJjygwGo0fTxXzLSKiLzw80QJK2eIF16gvAVk4qmW3CKD1TvrQ48GtM41lL X-Received: by 2002:a17:906:9605:b0:86d:bf67:a1c5 with SMTP id s5-20020a170906960500b0086dbf67a1c5mr1485365ejx.22.1673936281803; Mon, 16 Jan 2023 22:18:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673936281; cv=none; d=google.com; s=arc-20160816; b=mSFiJHphRPpxYooXT0M9pxbGpK+SrDipxkQkZ8K36REyAjno1IfemGKKQvMvCN4tsW s47XGXf5j3KMUTnQKJdZT6Ww0AIANVQmX5PxUtL9jvCELbOUkitRGfLHtWvh7wbKjfS2 zy/aZWGUJkx2E06qYy0zI6tTTQa8p5kHEXWdhTpJOw5dLuHMq5GfkIBcxri48Lt8jGay agh+DOOKJtzaYN+RMNpEVTfHDqHoNU9rkma08ZaGj/+oFK1nJZzT4PeLKfQKsHJQbtJI RJ6K+RX6oCYqpElWRn1p2Tcdlaz8XrowRqCEjBfCqkqqJykvoUw1qdFMlE3VOtOtB6mf R8HQ== 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=hN2Vdn6/YooKltzE6sHuXAME8HfRJ6mnqBZgezGkrFBtFw+nrp5zcf6sgtYTt7Q/1U scgttzobYJcddY4tQoUVEpx5ac+YDy07eeYKVV+WDcD+rzLZm34ueIie6jsiazurAAzn Agqrq4E5FaFJI0l9SeD7Am8Smq/X1gZv0wbe7vbl3vdw0axO+ZfT+ygnpVsQ1EIMLyE1 nk+QoGqhCT7H8VHN7dPA3zKcnOJuB2paQNyztEI5d5bV9tqdNu6HFKIGJI+gkSR7k046 I1a6PKEGyIliVYPtMNecIJHjlowiBBhjbV7EuqTsHg4tOAXmvb8kIRlG8JsE8pB1o1S3 rVmg== 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 qb3-20020a1709077e8300b00870dda3e82asi5505172ejc.924.2023.01.16.22.17.37; Mon, 16 Jan 2023 22:18:01 -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 S235882AbjAQGQ6 (ORCPT + 99 others); Tue, 17 Jan 2023 01:16:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235588AbjAQGP5 (ORCPT ); Tue, 17 Jan 2023 01:15:57 -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 3A266265AB for ; Mon, 16 Jan 2023 22:15:44 -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 ) id 1pHfFf-0002TW-Do; Tue, 17 Jan 2023 07:15:19 +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 ) id 1pHfFZ-006c0M-OF; Tue, 17 Jan 2023 07:15:13 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pHfFW-00FciY-Sk; Tue, 17 Jan 2023 07:15:10 +0100 From: Oleksij Rempel To: Rob Herring , Krzysztof Kozlowski , Shawn Guo , Sascha Hauer , Abel Vesa , Michael Turquette , Stephen Boyd , Richard Cochran Cc: Oleksij Rempel , kernel@pengutronix.de, Fabio Estevam , NXP Linux Team , Russell King , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v2 03/19] ARM: imx6q: skip ethernet refclock reconfiguration if enet_clk_ref is present Date: Tue, 17 Jan 2023 07:14:37 +0100 Message-Id: <20230117061453.3723649-4-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230117061453.3723649-1-o.rempel@pengutronix.de> References: <20230117061453.3723649-1-o.rempel@pengutronix.de> MIME-Version: 1.0 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755249410807521695?= X-GMAIL-MSGID: =?utf-8?q?1755249410807521695?= 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 --- 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__);