Skip to contentSkip to conversation

ARM: imx6plus: enable internal routing of clk_enet_ref where possible

PATCH In review Sven Van Asbroeck 2 participants 3 messages Jun 24, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ARM: imx6plus: enable internal routing of clk_enet_ref where possible

On imx6, the ethernet reference clock (clk_enet_ref) can be generated by either the imx6, or an external source (e.g. an oscillator or the PHY). When generated by the imx6, the clock source (from ANATOP) must be routed to the input of clk_enet_ref via two pads on the SoC, typically via a dedicated track on the PCB.

On an imx6 plus however, there is a new setting which enables this clock to be routed internally on the SoC, from its ANATOP clock source, straight to clk_enet_ref, without having to go through the SoC pads.

Board designs where the clock is generated by the imx6 should not be affected by routing the clock internally. Therefore on a plus, we can enable internal routing by default.

---
v2 -> v3:
- remove check for imx6q, which is already implied when of_machine_is_compatible("fsl,imx6qp")
v1 -> v2:
- Fabio Estevam: use of_machine_is_compatible() to determine if we are running on an imx6 plus.

To: Shawn Guo <[email protected]>
To: Andy Duan <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: NXP Linux Team <[email protected]>
Cc: [email protected]
Cc: [email protected]

 arch/arm/mach-imx/mach-imx6q.c              | 18 ++++++++++++++++++
 include/linux/mfd/syscon/imx6q-iomuxc-gpr.h |  1 +
 2 files changed, 19 insertions(+)
arch/arm/mach-imx/mach-imx6q.c +18 -0
index 85c084a716ab..a760779b934e 100644
@@ -203,6 +203,24 @@ static void __init imx6q_1588_init(void)
 	else
 		pr_err("failed to find fsl,imx6q-iomuxc-gpr regmap\n");
 
+	/*
+	 * On imx6 plus, enet_ref from ANATOP/CCM can be internally routed to
+	 * be the PTP clock source, instead of having to be routed through
+	 * pads.
+	 * Board designs which route the ANATOP/CCM clock through pads are
+	 * unaffected when routing happens internally. So on these designs,
+	 * route internally by default.
+	 */
+	if (clksel == IMX6Q_GPR1_ENET_CLK_SEL_ANATOP &&
+			of_machine_is_compatible("fsl,imx6qp")) {
+		if (!IS_ERR(gpr))
+			regmap_update_bits(gpr, IOMUXC_GPR5,
+					IMX6Q_GPR5_ENET_TXCLK_SEL,
+					IMX6Q_GPR5_ENET_TXCLK_SEL);
+		else
+			pr_err("failed to find fsl,imx6q-iomuxc-gpr regmap\n");
+		}
+
 	clk_put(enet_ref);
 put_ptp_clk:
 	clk_put(ptp_clk);
include/linux/mfd/syscon/imx6q-iomuxc-gpr.h +1 -0
index d4b5e527a7a3..eb65d48da0df 100644
@@ -240,6 +240,7 @@
 #define IMX6Q_GPR4_IPU_RD_CACHE_CTL		BIT(0)
 
 #define IMX6Q_GPR5_L2_CLK_STOP			BIT(8)
+#define IMX6Q_GPR5_ENET_TXCLK_SEL		BIT(9)
 #define IMX6Q_GPR5_SATA_SW_PD			BIT(10)
 #define IMX6Q_GPR5_SATA_SW_RST			BIT(11)
 
Signature · 1 line
2.17.1
reviewer
#1 lore raw

Hi Sven,

arch/arm/mach-imx/mach-imx6q.c static void __init imx6q_1588_init(void) · line 216

Quoted 11 lines · Sven Van Asbroeck
arch/arm/mach-imx/mach-imx6q.c +11 -0
+       /*
+        * On imx6 plus, enet_ref from ANATOP/CCM can be internally routed to
+        * be the PTP clock source, instead of having to be routed through
+        * pads.
+        * Board designs which route the ANATOP/CCM clock through pads are
+        * unaffected when routing happens internally. So on these designs,
+        * route internally by default.
+        */
+       if (clksel == IMX6Q_GPR1_ENET_CLK_SEL_ANATOP &&
+                       of_machine_is_compatible("fsl,imx6qp")) {
+               if (!IS_ERR(gpr))

We could avoid checking for if (!IS_ERR(gpr)) two times in a row if the following patch is applied before yours:
https://pastebin.com/raw/Ftkq2VVp

What do you think?

Thanks

#2 lore raw

Hi Fabio,

Quoted 6 lines · Fabio Estevam

We could avoid checking for if (!IS_ERR(gpr)) two times in a row if the following patch is applied before yours:
https://pastebin.com/raw/Ftkq2VVp

What do you think?

I think this is a good idea.
I was never fully comfortable with checking IS_ERR(gpr) twice, but I know from experience that minimal patches are more likely to be accepted.

Shawn / Andy, what do you think? Should I re-spin this as a patch set, with Fabio's patch in front?