Skip to contentSkip to conversation

ARM: imx6plus: enable internal routing of clk_enet_ref where possible

PATCH Superseded Sven Van Asbroeck 4 participants 7 messages Jun 13, 2020 – Jun 24, 2020

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

To: Shawn Guo <[email protected]>

Cc Sascha Hauer <[email protected]>
Cc Pengutronix Kernel Team <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc NXP Linux Team <[email protected]>
---
 arch/arm/mach-imx/mach-imx6q.c              | 18 ++++++++++++++++++
 include/linux/mfd/syscon/imx6q-iomuxc-gpr.h |  1 +
 2 files changed, 19 insertions(+)

Tree: next-20200613

arch/arm/mach-imx/mach-imx6q.c +18 -0
index 85c084a716ab..4d22567bb650 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 && cpu_is_imx6q() &&
+			imx_get_soc_revision() >= IMX_CHIP_REVISION_2_0) {
+		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 · 7 lines
2.17.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw

Hi Fugang,

Can you take a look at this patch? Thanks!

Shawn

Quoted 74 lines · Sven Van Asbroeck

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.

To: Shawn Guo <[email protected]>

Cc Sascha Hauer <[email protected]>
Cc Pengutronix Kernel Team <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc NXP Linux Team <[email protected]>
---
 arch/arm/mach-imx/mach-imx6q.c              | 18 ++++++++++++++++++
 include/linux/mfd/syscon/imx6q-iomuxc-gpr.h |  1 +
 2 files changed, 19 insertions(+)

Tree: next-20200613

arch/arm/mach-imx/mach-imx6q.c +18 -0
index 85c084a716ab..4d22567bb650 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 && cpu_is_imx6q() &&
+			imx_get_soc_revision() >= IMX_CHIP_REVISION_2_0) {
+		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
Reviewed-by
#2 lore raw

From: Shawn Guo <[email protected]> Sent: Tuesday, June 23, 2020 7:54 PM

Quoted 4 lines

Hi Fugang,

Can you take a look at this patch? Thanks!

The patch looks good.

Quoted 87 lines

Shawn

Quoted 23 lines · Sven Van Asbroeck

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.

To: Shawn Guo <[email protected]>

Cc Sascha Hauer <[email protected]>
Cc Pengutronix Kernel Team <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc NXP Linux Team <[email protected]>
Quoted 2 lines
---
 arch/arm/mach-imx/mach-imx6q.c              | 18

++++++++++++++++++

Quoted 11 lines
 include/linux/mfd/syscon/imx6q-iomuxc-gpr.h |  1 +
 2 files changed, 19 insertions(+)

Tree: next-20200613

(quoted diff) +0 -0

b/arch/arm/mach-imx/mach-imx6q.c index 85c084a716ab..4d22567bb650 100644

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

Quoted 5 lines
arch/arm/mach-imx/mach-imx6q.c +2 -0
@@ -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

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

Quoted 3 lines
arch/arm/mach-imx/mach-imx6q.c +3 -0
+      * be the PTP clock source, instead of having to be routed through
+      * pads.
+      * Board designs which route the ANATOP/CCM clock through pads

are

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

Quoted 4 lines
arch/arm/mach-imx/mach-imx6q.c +4 -0
+      * unaffected when routing happens internally. So on these designs,
+      * route internally by default.
+      */
+     if (clksel == IMX6Q_GPR1_ENET_CLK_SEL_ANATOP &&

cpu_is_imx6q() &&

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

Quoted 1 line
arch/arm/mach-imx/mach-imx6q.c +1 -0
+                     imx_get_soc_revision() >=

IMX_CHIP_REVISION_2_0) {

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

Quoted 3 lines
arch/arm/mach-imx/mach-imx6q.c +3 -0
+             if (!IS_ERR(gpr))
+                     regmap_update_bits(gpr, IOMUXC_GPR5,
+

IMX6Q_GPR5_ENET_TXCLK_SEL,

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

Quoted 1 line
arch/arm/mach-imx/mach-imx6q.c +1 -0
+

IMX6Q_GPR5_ENET_TXCLK_SEL);

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

Quoted 2 lines
arch/arm/mach-imx/mach-imx6q.c +2 -0
+             else
+                     pr_err("failed to find fsl,imx6q-iomuxc-gpr

regmap\n");

Quoted 21 lines
arch/arm/mach-imx/mach-imx6q.c +2 -0
+             }
+
      clk_put(enet_ref);
 put_ptp_clk:
      clk_put(ptp_clk);
include/linux/mfd/syscon/imx6q-iomuxc-gpr.h +1 -1
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)
 
--

2.17.1

#3 lore raw

Hi Andy,

Quoted 3 lines · Andy Duan

The patch looks good.

Thank you !

To check we're on a plus, the patch uses:
cpu_is_imx6q() && imx_get_soc_revision() >= IMX_CHIP_REVISION_2_0

Fabio Estevam suggested that perhaps checking of_machine_is_compatible("fsl,imx6qp") might be preferable. What is your opinion on this?

#4 lore raw

From: Sven Van Asbroeck <[email protected]> Sent: Wednesday, June 24, 2020 10:56 AM

Quoted 7 lines

Hi Andy,

Quoted 3 lines · Andy Duan

The patch looks good.

Quoted 8 lines

Thank you !

To check we're on a plus, the patch uses:
cpu_is_imx6q() && imx_get_soc_revision() >= IMX_CHIP_REVISION_2_0

Fabio Estevam suggested that perhaps checking of_machine_is_compatible("fsl,imx6qp") might be preferable. What is your opinion on this?

Yes, I also think of_machine_is_compatible() is much better. Thanks.

reviewer
#5 lore raw
In reply to Sven Van Asbroeck

Hi Sven,

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

Quoted 10 lines · Sven Van Asbroeck
arch/arm/mach-imx/mach-imx6q.c +10 -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 && cpu_is_imx6q() &&
+                       imx_get_soc_revision() >= IMX_CHIP_REVISION_2_0) {

You should limit this to imx6 quad plus only, so you would better check against "fsl,imx6qp".

#6 lore raw

Hi Fabio,

Quoted 3 lines · Fabio Estevam

You should limit this to imx6 quad plus only, so you would better check against "fsl,imx6qp".

Excellent suggestion, thank you ! I tried to determine if running on a plus by using the method from imx6q_init_machine(). But yes, checking for "fsl,imx6qp" sounds much more elegant.