All of lore.kernel.org
 help / color / mirror / Atom feed
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 v2 03/19] ARM: imx6q: skip ethernet refclock reconfiguration if enet_clk_ref is present
Date: Tue, 17 Jan 2023 07:14:37 +0100	[thread overview]
Message-ID: <20230117061453.3723649-4-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20230117061453.3723649-1-o.rempel@pengutronix.de>

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__);
-- 
2.30.2


  parent reply	other threads:[~2023-01-17  6:17 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-17  6:14 [PATCH v2 00/19] ARM: imx: make Ethernet refclock configurable Oleksij Rempel
2023-01-17  6:14 ` [PATCH v2 01/19] clk: imx: add clk-gpr-mux driver Oleksij Rempel
2023-01-29 17:36   ` Abel Vesa
2023-01-17  6:14 ` [PATCH v2 02/19] clk: imx6q: add ethernet refclock mux support Oleksij Rempel
2023-01-29 17:34   ` Abel Vesa
2023-01-17  6:14 ` Oleksij Rempel [this message]
2023-01-17  6:14 ` [PATCH v2 04/19] ARM: dts: imx6qdl: use enet_clk_ref instead of enet_out for the FEC node Oleksij Rempel
2023-01-17  6:14 ` [PATCH v2 05/19] ARM: dts: imx6dl-lanmcu: configure ethernet reference clock parent Oleksij Rempel
2023-01-17  6:14 ` [PATCH v2 06/19] ARM: dts: imx6dl-alti6p: " Oleksij Rempel
2023-01-17  6:14 ` [PATCH v2 07/19] ARM: dts: imx6dl-plybas: " Oleksij Rempel
2023-01-17  6:14 ` [PATCH v2 08/19] ARM: dts: imx6dl-plym2m: " Oleksij Rempel
2023-01-17  6:14 ` [PATCH v2 09/19] ARM: dts: imx6dl-prtmvt: " Oleksij Rempel
2023-01-17  6:14 ` [PATCH v2 10/19] ARM: dts: imx6dl-victgo: " Oleksij Rempel
2023-01-17  6:14 ` [PATCH v2 11/19] ARM: dts: imx6q-prtwd2: " Oleksij Rempel
2023-01-17  6:14 ` [PATCH v2 12/19] ARM: dts: imx6qdl-skov-cpu: " Oleksij Rempel
2023-01-17  6:14 ` [PATCH v2 13/19] ARM: dts: imx6dl-eckelmann-ci4x10: " Oleksij Rempel
2023-01-17  6:14 ` [PATCH v2 14/19] clk: imx: add imx_obtain_fixed_of_clock() Oleksij Rempel
2023-01-29 17:33   ` Abel Vesa
2023-01-17  6:14 ` [PATCH v2 15/19] clk: imx6ul: fix enet1 gate configuration Oleksij Rempel
2023-01-29 17:32   ` Abel Vesa
2023-01-30 12:15     ` Oleksij Rempel
2023-01-30 14:54       ` Abel Vesa
2023-01-17  6:14 ` [PATCH v2 16/19] clk: imx6ul: add ethernet refclock mux support Oleksij Rempel
2023-01-30 22:05   ` Abel Vesa
2023-01-17  6:14 ` [PATCH v2 17/19] ARM: dts: imx6ul: set enet_clk_ref to CLK_ENETx_REF_SEL Oleksij Rempel
2023-01-17  6:14 ` [PATCH v2 18/19] ARM: mach-imx: imx6ul: remove not optional ethernet refclock overwrite Oleksij Rempel
2023-01-17  6:14 ` [PATCH v2 19/19] ARM: dts: imx6ul-prti6g: configure ethernet reference clock parent Oleksij Rempel
2023-01-30 22:11 ` [PATCH v2 00/19] ARM: imx: make Ethernet refclock configurable Abel Vesa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230117061453.3723649-4-o.rempel@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=abelvesa@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mturquette@baylibre.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=sboyd@kernel.org \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.