Skip to contentSkip to conversation

imx9: clock: support external RMII REF_CLK source for EQOS

PATCH In review Max Merchel 2 participants 2 messages Nov 20 – Nov 25

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

PATCH 1/1 imx9: clock: support external RMII REF_CLK source for EQOS

From: Martin Schmiedel <[email protected]>

The CPU supports RMII REF_CLK as output from the CPU and as input to the MAC in the CPU. While the first case is supported the second is not.

Check the presence of 'snps,rmii_refclk_ext' property in the MAC device node in imx93_eqos_interface_init and configure the direction bit in WAKEUPMIX BLKCTRL accordingly.

No changes for exisiting boards intended.

---
 arch/arm/include/asm/arch-imx9/imx-regs.h |  1 +
 arch/arm/mach-imx/imx9/clock.c            | 12 ++++++++++++
 2 files changed, 13 insertions(+)
arch/arm/include/asm/arch-imx9/imx-regs.h +1 -0
index 55f4f34e1bc..0358b0a9b2a 100644
@@ -90,6 +90,7 @@
 #define BCTRL_GPR_ENET_QOS_INTF_SEL_RMII         (0x4 << 1)
 #define BCTRL_GPR_ENET_QOS_INTF_SEL_RGMII        (0x1 << 1)
 #define BCTRL_GPR_ENET_QOS_CLK_GEN_EN            (0x1 << 0)
+#define BCTRL_GPR_ENET_QOS_CLK_SEL_EXT           (0x1 << 0)
 
 #define TRDC_AON_BASE		(0x44270000UL)
 #define TRDC_WAKEUP_BASE	(0x42460000UL)
arch/arm/mach-imx/imx9/clock.c +12 -0
index b05194502cd..c65a35c58fe 100644
@@ -12,6 +12,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/io.h>
 #include <div64.h>
+#include <dm/read.h>
 #include <errno.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
@@ -913,6 +914,17 @@ static int imx93_eqos_interface_init(struct udevice *dev, phy_interface_t interf
 			     BCTRL_GPR_ENET_QOS_CLK_GEN_EN);
 		break;
 	case PHY_INTERFACE_MODE_RMII:
+		/*
+		 * On boards where the PHY is REF_CLK master (its own crystal,
+		 * feeding REF_CLK into the SOC), the MAC's REF_CLK source mux
+		 * (the register right after eqos_gpr) must be switched to the
+		 * external pin - matches Linux's imx93_set_intf_mode()
+		 * (drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c). CLK_GEN_EN
+		 * is set unconditionally either way, same as Linux does.
+		 */
+		if (dev_read_bool(dev, "snps,rmii_refclk_ext"))
+			clrbits_le32(&bctrl->enet_clk_sel,
+				     BCTRL_GPR_ENET_QOS_CLK_SEL_EXT);
 		setbits_le32(&bctrl->eqos_gpr,
 			     BCTRL_GPR_ENET_QOS_INTF_SEL_RMII |
 			     BCTRL_GPR_ENET_QOS_CLK_GEN_EN);

base-commit: e6fa1282975af50acf44be7aa678b89e187f0860

Signature · 1 line
2.53.0
Reviewed-by Peng Fan on v1 1/1
#1 lore raw
Quoted 53 lines · On Fri, 20 Nov 2026 08:28:40 +0100 Max Merchel <[email protected]>…

From: Martin Schmiedel <[email protected]>

The CPU supports RMII REF_CLK as output from the CPU and as input to the MAC in the CPU. While the first case is supported the second is not.

Check the presence of 'snps,rmii_refclk_ext' property in the MAC device node in imx93_eqos_interface_init and configure the direction bit in WAKEUPMIX BLKCTRL accordingly.

No changes for exisiting boards intended.

---
 arch/arm/include/asm/arch-imx9/imx-regs.h |  1 +
 arch/arm/mach-imx/imx9/clock.c            | 12 ++++++++++++
 2 files changed, 13 insertions(+)
arch/arm/include/asm/arch-imx9/imx-regs.h +1 -0
index 55f4f34e1bc..0358b0a9b2a 100644
@@ -90,6 +90,7 @@
 #define BCTRL_GPR_ENET_QOS_INTF_SEL_RMII         (0x4 << 1)
 #define BCTRL_GPR_ENET_QOS_INTF_SEL_RGMII        (0x1 << 1)
 #define BCTRL_GPR_ENET_QOS_CLK_GEN_EN            (0x1 << 0)
+#define BCTRL_GPR_ENET_QOS_CLK_SEL_EXT           (0x1 << 0)
 
 #define TRDC_AON_BASE		(0x44270000UL)
 #define TRDC_WAKEUP_BASE	(0x42460000UL)
arch/arm/mach-imx/imx9/clock.c +5 -0
index b05194502cd..c65a35c58fe 100644
@@ -12,6 +12,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/io.h>
 #include <div64.h>
+#include <dm/read.h>
 #include <errno.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
@@ -913,6 +914,17 @@ static int imx93_eqos_interface_init(struct udevice *dev, phy_interface_t interf
 			     BCTRL_GPR_ENET_QOS_CLK_GEN_EN);
 		break;
 	case PHY_INTERFACE_MODE_RMII:
+		/*
+		 * On boards where the PHY is REF_CLK master (its own crystal,
+		 * feeding REF_CLK into the SOC), the MAC's REF_CLK source mux
+		 * (the register right after eqos_gpr) must be switched to the

arch/arm/mach-imx/imx9/clock.c static int imx93_eqos_interface_init(struct udevice *dev, phy_interface_t interf · line 930

Quoted 10 lines
arch/arm/mach-imx/imx9/clock.c +7 -0
+		 * external pin - matches Linux's imx93_set_intf_mode()
+		 * (drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c). CLK_GEN_EN
+		 * is set unconditionally either way, same as Linux does.
+		 */
+		if (dev_read_bool(dev, "snps,rmii_refclk_ext"))
+			clrbits_le32(&bctrl->enet_clk_sel,
+				     BCTRL_GPR_ENET_QOS_CLK_SEL_EXT);
 		setbits_le32(&bctrl->eqos_gpr,
 			     BCTRL_GPR_ENET_QOS_INTF_SEL_RMII |
 			     BCTRL_GPR_ENET_QOS_CLK_GEN_EN);