Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1005126rwb; Fri, 13 Jan 2023 06:52:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXvM0xiKz6wttBAb2HOZ5JOO/e+c26LZb+6Q8025fP70nh3eT56Vc6PI3Ht0LeWTgjN9/SBu X-Received: by 2002:a17:902:934b:b0:188:760f:d831 with SMTP id g11-20020a170902934b00b00188760fd831mr84743893plp.7.1673621545714; Fri, 13 Jan 2023 06:52:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673621545; cv=none; d=google.com; s=arc-20160816; b=Yl+XORxQsFKQ5z0rIB65wbrHv8KzPBEALFOqg8D6ZOBbZzlaD8kH4Id2eNyz69U2cw zdM3cmabIGb+JoKy6MUSOoDBl9FoHWgKOv06759Un2Eyd7sawGJgIwTnoOU+NLsgogUa DPPfcW0AdkKnjBtVJqnZ6+vMYY14CVPskJPNX7rGhZ/ygIIcFdgSxbqkTx+uQdezRdhS 1bU334765EM9IOxpmBpAA0lGgWzMdALlu8KOw5jlToYXdFyLsRCzkx/xe6koadgxx9Uv 0xJpkAkfMQsE3AB5UZcyYfbuYzi2NPMsnqeK6FyVNLfizx165NmdQdEY/34dJB9ShbeY tlsA== 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=U+4U6Q3MkzBhgRzIOmOl3beaVa950H5kwm/ERmE9yimW+5Yu0C4CUUvzlQauvLfo5a gy1zaDRonZfipYBUwzWa/LzK4NdgLoI+gI1f7oNCQR6986Ug4BrFcg8PkZ8NDnm3tWDL bCQ96rFWGSfhPUHTpzZIKXpj2V64O4mfQeGSf8IBtB9e+1jwQbTVttgAju0y9seSoU/V SZbrHMVslc//ls6N5Vk8M3Kamjc6r4dNCgvnFwyFGlBUOtWURQVxQXL6GvyS3KKMS2eN Dj7YfeXB57lvGqcuuU+Zjy4fRLgL31Lcnyders/qxhfLPeyKFAh9PypMxJxputYXfa04 i/jw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e16-20020a17090301d000b00189b36a5427si20897672plh.16.2023.01.13.06.52.19; Fri, 13 Jan 2023 06:52:25 -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 S230086AbjAMOfq (ORCPT + 51 others); Fri, 13 Jan 2023 09:35:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230085AbjAMOdh (ORCPT ); Fri, 13 Jan 2023 09:33:37 -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 0C95E50049 for ; Fri, 13 Jan 2023 06:28:03 -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 1pGL1e-0006Dv-KE; Fri, 13 Jan 2023 15:27:22 +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 1pGL1d-005mya-FJ; Fri, 13 Jan 2023 15:27:21 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pGL1b-00CkPv-BB; Fri, 13 Jan 2023 15:27:19 +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 , Lee Jones , Russell King , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v1 03/20] ARM: imx6q: skip ethernet refclock reconfiguration if enet_clk_ref is present Date: Fri, 13 Jan 2023 15:27:01 +0100 Message-Id: <20230113142718.3038265-4-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230113142718.3038265-1-o.rempel@pengutronix.de> References: <20230113142718.3038265-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: X-Mailing-List: linux-kernel@vger.kernel.org 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__); -- 2.30.2