mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 5/5] ARM: i.MX8M: order early clock init like U-Boot
Date: Fri,  2 Oct 2026 13:35:50 +0200	[thread overview]
Message-ID: <20261002113554.2902941-5-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20261002113554.2902941-1-a.fatoum@pengutronix.de>

The clocks configured in __imx8m_early_clock_init() now match U-Boot's
clock_init(), but are written in a different order: DRAM first, then
GIC, SYS_PLL3, NOC and the ARM PLL last.

U-Boot sets up the ARM PLL right after enabling the SYS_PLL1/2 outputs,
then SYS_PLL3 and its NOC consumer, the GIC root and the DRAM clocks
last. Reorder to the same sequence, so the two can be compared side by
side. The remaining differences are:

  - barebox doesn't touch the NAND_USDHC_BUS and watchdog roots or the
    TEMP_SENSOR and SEC_DEBUG gates in the PBL

  - NXP's downstream U-Boot additionally configures the display clocks
    in clock_init() (VIDEO_PLL at 594MHz, the DISPLAY_AXI/APB and MIPI
    DSI roots, DISPMIX gate)

These are skipped as both barebox and Linux will configure these clocks
if needed before using them.

Every root and gate ends up with the same value, and each source is
enabled before a root is switched to it in either order.

No functional change.

Assisted-by: Claude:fable-5.1
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/mach-imx/imx8m.c | 83 +++++++++++++++++++--------------------
 1 file changed, 40 insertions(+), 43 deletions(-)

diff --git a/arch/arm/mach-imx/imx8m.c b/arch/arm/mach-imx/imx8m.c
index 23a920ffae2e..b9f8906d6ed2 100644
--- a/arch/arm/mach-imx/imx8m.c
+++ b/arch/arm/mach-imx/imx8m.c
@@ -82,6 +82,46 @@ static void __imx8m_early_clock_init(int cpu_type)
 		INTPLL_DIV20_CLKE_MASK;
 	writel(val, ana + IMX8MM_CCM_ANALOG_SYS_PLL2_GEN_CTRL);
 
+	/* Configure ARM at 1.2GHz */
+	imx8m_clock_set_target_val(IMX8M_ARM_A53_CLK_ROOT,
+				   IMX8M_CCM_TARGET_ROOTn_ENABLE |
+				   IMX8M_CCM_TARGET_ROOTn_MUX(2));
+
+	clk_pll1416x_early_configure(ana + IMX8MM_CCM_ANALOG_ARM_PLL_GEN_CTRL,
+				     1200000000UL, 25000000UL);
+
+	/* Bypass the A53 root and feed the cores from arm_pll_out directly */
+	imx8m_clock_set_target_val(IMX8M_CORE_SEL_CFG,
+				   IMX8M_CCM_TARGET_ROOTn_MUX(1));
+
+	if (cpu_type == IMX_CPU_IMX8MN || cpu_type == IMX_CPU_IMX8MP)
+		pll3_freq = 600000000UL;
+	else
+		pll3_freq = 750000000UL;
+
+	/* Configure SYS_PLL3 */
+	clk_pll1416x_early_configure(ana + IMX8MM_CCM_ANALOG_SYS_PLL3_GEN_CTRL,
+				     pll3_freq, 25000000UL);
+
+	if (cpu_type == IMX_CPU_IMX8MP) {
+		/* NOC_IO from sys_pll3_out, barebox proper sets NOC and GIC */
+		imx8m_clock_set_target_val(IMX8M_NOC_IO_CLK_ROOT,
+					   IMX8M_CCM_TARGET_ROOTn_ENABLE |
+					   IMX8M_CCM_TARGET_ROOTn_MUX(2));
+	} else {
+		/* NOC from undivided sys_pll3_out */
+		imx8m_clock_set_target_val(IMX8M_NOC_CLK_ROOT,
+					   IMX8M_CCM_TARGET_ROOTn_ENABLE |
+					   IMX8M_CCM_TARGET_ROOTn_MUX(2));
+
+		/* config GIC to sys_pll2_100m */
+		imx8m_ccgr_clock_disable(IMX8M_CCM_CCGR_GIC);
+		imx8m_clock_set_target_val(IMX8M_GIC_CLK_ROOT,
+					   IMX8M_CCM_TARGET_ROOTn_ENABLE |
+					   IMX8M_CCM_TARGET_ROOTn_MUX(3));
+		imx8m_ccgr_clock_enable(IMX8M_CCM_CCGR_GIC);
+	}
+
 	imx8m_ccgr_clock_disable(IMX8M_CCM_CCGR_DDR1);
 
 	imx8m_clock_set_target_val(IMX8M_DRAM_ALT_CLK_ROOT,
@@ -94,49 +134,6 @@ static void __imx8m_early_clock_init(int cpu_type)
 				   IMX8M_CCM_TARGET_ROOTn_MUX(1));
 
 	imx8m_ccgr_clock_enable(IMX8M_CCM_CCGR_DDR1);
-
-	if (cpu_type != IMX_CPU_IMX8MP) {
-		/* 8MP ROM already set GIC to 400Mhz, system_pll1_800m with div = 2 */
-		/* For everything else, config GIC to sys_pll2_100m */
-		imx8m_ccgr_clock_disable(IMX8M_CCM_CCGR_GIC);
-		imx8m_clock_set_target_val(IMX8M_GIC_CLK_ROOT,
-					   IMX8M_CCM_TARGET_ROOTn_ENABLE |
-					   IMX8M_CCM_TARGET_ROOTn_MUX(3));
-		imx8m_ccgr_clock_enable(IMX8M_CCM_CCGR_GIC);
-	}
-
-	if (cpu_type == IMX_CPU_IMX8MN || cpu_type == IMX_CPU_IMX8MP)
-		pll3_freq = 600000000UL;
-	else
-		pll3_freq = 750000000UL;
-
-	/* Configure SYS_PLL3 */
-	clk_pll1416x_early_configure(ana + IMX8MM_CCM_ANALOG_SYS_PLL3_GEN_CTRL,
-				     pll3_freq, 25000000UL);
-
-	if (cpu_type == IMX_CPU_IMX8MP) {
-		/* 8MP ROM already set NOC to 800Mhz, only need to configure NOC_IO clk to 600Mhz */
-		imx8m_clock_set_target_val(IMX8M_NOC_IO_CLK_ROOT,
-					   IMX8M_CCM_TARGET_ROOTn_ENABLE |
-					   IMX8M_CCM_TARGET_ROOTn_MUX(2));
-	} else {
-		/* NOC from undivided sys_pll3_out */
-		imx8m_clock_set_target_val(IMX8M_NOC_CLK_ROOT,
-					   IMX8M_CCM_TARGET_ROOTn_ENABLE |
-					   IMX8M_CCM_TARGET_ROOTn_MUX(2));
-	}
-
-	imx8m_clock_set_target_val(IMX8M_ARM_A53_CLK_ROOT,
-				   IMX8M_CCM_TARGET_ROOTn_ENABLE |
-				   IMX8M_CCM_TARGET_ROOTn_MUX(2));
-
-	/* Configure ARM PLL to 1.2GHz */
-	clk_pll1416x_early_configure(ana + IMX8MM_CCM_ANALOG_ARM_PLL_GEN_CTRL,
-				     1200000000UL, 25000000UL);
-
-	/* Bypass the A53 root and feed the cores from arm_pll_out directly */
-	imx8m_clock_set_target_val(IMX8M_CORE_SEL_CFG,
-				   IMX8M_CCM_TARGET_ROOTn_MUX(1));
 }
 
 void imx8mm_early_clock_init(void)
-- 
2.47.3




      parent reply	other threads:[~2026-10-02 11:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02 11:35 [PATCH master 1/5] clk: imx: pll14xx: enable PLL output in clk_pll1416x_early_set_rate() Ahmad Fatoum
2026-10-02 11:35 ` [PATCH master 2/5] ARM: i.MX8MM/8MN: clock NOC from SYS_PLL3 in early clock init Ahmad Fatoum
2026-10-02 11:35 ` [PATCH master 3/5] ARM: i.MX8M: feed A53 cores from ARM PLL via CORE_SEL_CFG " Ahmad Fatoum
2026-10-02 11:35 ` [PATCH master 4/5] ARM: i.MX8M: source dram_apb from sys_pll2_200m " Ahmad Fatoum
2026-10-02 11:35 ` Ahmad Fatoum [this message]

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=20261002113554.2902941-5-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox