Skip to contentSkip to conversation

clk: imx: Use Clock framework to register UART clocks

PATCH In review Adam Ford 2 participants 17 messages Mar 18, 2025 – Mar 21, 2025

Subsystems (3)
lore
Share & tools
lore

Adam Ford

author
#0 lore raw

cover clk: imx: Use Clock framework to register UART clocks

Currenty, most peripherals enable/disable their respecive clocks using the clock framework, but serial ports various imx platsforms do not. Some of the newer NXP SoC's register the UART clocks, but they are not necessarily associated the to serial_mxc driver, so these clocks need to be manually enabled. Even when the driver model enumerates the UART, the driver model doesn't always reflect the proper clock state, because these clocks are not controlled by the serial driver.

This series does a few things:

Register the missing UART clocks on imx6, 8mm, 8mn, fixes a build dependency on CCF_FRAMEWORK on imx8mp in SPL, bulk enables the UART clocks from the serial_mxc driver, and finally, removes the manual references to enabling the UART clocks on Beacon EmbeddedWorks imx8mm, imx8mn, and imx8mp development kits.

I don't have access to an imx6 board right now, nor do I have imx9 or imxrt boards, so I can't verify regressions on those platforms.

For users who want to try this series and remove the manual UART calls, make sure the SoC clock driver is enabled in SPL and OF_SPL_REMOVE_PROPS should not remove the clocks or clock names.

With this series both "clk dump" and "dm tree" show the UART clocks are registred and the one clocking the console UART is enabled and running.

Adam Ford (10):
clk: imx6q: Properly handle imx6qp ESPI clk_sels
clk: imx6q: Register UART clocks
clk: imx8mm: register UART clocks
clk: imx8mn: register UART clocks
serial: mxc: Support bulk enabling clocks
board: beacon: imx8mm: Let clock system enable UART clock
board: beacon: imx8mn: Let clock system enable UART clock
clk: imx: select SPL_CLK_COMPOSITE_CCF when SPL_CLK_IMX8MP
configs: imx8mp_beacon: Select SPL_CLK_IMX8MP
board: beacon: imx8mp: Let clock system enable UART clock

 board/beacon/imx8mm/spl.c             |  6 +----
 board/beacon/imx8mn/spl.c             |  2 --
 board/beacon/imx8mp/spl.c             |  2 --
 configs/imx8mp_beacon_defconfig       |  1 +
 drivers/clk/imx/Kconfig               |  1 +
 drivers/clk/imx/clk-imx6q.c           | 34 ++++++++++++++++++++++++---
 drivers/clk/imx/clk-imx8mm.c          | 34 +++++++++++++++++++++++++++
 drivers/clk/imx/clk-imx8mn.c          | 32 +++++++++++++++++++++++++
 drivers/serial/serial_mxc.c           | 11 +++++++++
 include/dm/platform_data/serial_mxc.h |  1 +
 10 files changed, 112 insertions(+), 12 deletions(-)
Signature · 1 line
2.45.2
author
#1 lore raw

PATCH v3 1/10 clk: imx6q: Properly handle imx6qp ECSPI clk_sels

The ECSPI clock has the ability to select between pll3_60m and osc on the imx6qp, where it's fixed on other variants. Fix this by adding using a helper function to determine SoC variant and register the clock accordingly.

---
 drivers/clk/imx/clk-imx6q.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
V3:  No change 
V2:  Fix the name "ECSPI" and elimiate helper function by

directly calling of_machine_is_compatible.

drivers/clk/imx/clk-imx6q.c +12 -2
index df9f0285e1e..15ad0c9ac06 100644
@@ -35,6 +35,7 @@ static const char *const usdhc_sels[] = { "pll2_pfd2_396m", "pll2_pfd0_352m", };
 static const char *const periph_sels[]	= { "periph_pre", "periph_clk2", };
 static const char *const periph_pre_sels[] = { "pll2_bus", "pll2_pfd2_396m",
 					       "pll2_pfd0_352m", "pll2_198m", };
+static const char *const ecspi_sels[] = { "pll3_60m", "osc", };
 
 static int imx6q_clk_probe(struct udevice *dev)
 {
@@ -78,6 +79,11 @@ static int imx6q_clk_probe(struct udevice *dev)
 	       imx_clk_mux("usdhc4_sel", base + 0x1c, 19, 1,
 			   usdhc_sels, ARRAY_SIZE(usdhc_sels)));
 
+	if (of_machine_is_compatible("fsl,imx6qp")
+		clk_dm(IMX6QDL_CLK_ECSPI_SEL,
+		       imx_clk_mux("ecspi_sel",	base + 0x38, 18, 1, ecspi_sels,
+				   ARRAY_SIZE(ecspi_sels)));
+
 	clk_dm(IMX6QDL_CLK_USDHC1_PODF,
 	       imx_clk_divider("usdhc1_podf", "usdhc1_sel",
 			       base + 0x24, 11, 3));
@@ -91,8 +97,12 @@ static int imx6q_clk_probe(struct udevice *dev)
 	       imx_clk_divider("usdhc4_podf", "usdhc4_sel",
 			       base + 0x24, 22, 3));
 
-	clk_dm(IMX6QDL_CLK_ECSPI_ROOT,
-	       imx_clk_divider("ecspi_root", "pll3_60m", base + 0x38, 19, 6));
+	if (of_machine_is_compatible("fsl,imx6qp")
+		clk_dm(IMX6QDL_CLK_ECSPI_ROOT,
+		       imx_clk_divider("ecspi_root", "ecspi_sel", base + 0x38, 19, 6));
+	else
+		clk_dm(IMX6QDL_CLK_ECSPI_ROOT,
+		       imx_clk_divider("ecspi_root", "pll3_60m", base + 0x38, 19, 6));
 
 	clk_dm(IMX6QDL_CLK_ECSPI1,
 	       imx_clk_gate2("ecspi1", "ecspi_root", base + 0x6c, 0));
Signature · 1 line
2.45.2
reviewer
#2 lore raw

Re: [PATCH V3 01/10] clk: imx6q: Properly handle imx6qp ECSPI clk_sels

Quoted 1 line · Adam Ford

+ if (of_machine_is_compatible("fsl,imx6qp")

Missing closing parenthesis.

drivers/clk/imx/clk-imx6q.c static int imx6q_clk_probe(struct udevice *dev) · line 100

Quoted 3 lines
drivers/clk/imx/clk-imx6q.c +1 -2
-       clk_dm(IMX6QDL_CLK_ECSPI_ROOT,
-              imx_clk_divider("ecspi_root", "pll3_60m", base + 0x38, 19, 6));
+       if (of_machine_is_compatible("fsl,imx6qp")

Same here.

author
#3 lore raw

Re: [PATCH V3 01/10] clk: imx6q: Properly handle imx6qp ECSPI clk_sels

Quoted 5 lines · Fabio Estevam
Quoted 1 line · Adam Ford

+ if (of_machine_is_compatible("fsl,imx6qp")

Quoted 7 lines

Missing closing parenthesis.

drivers/clk/imx/clk-imx6q.c static int imx6q_clk_probe(struct udevice *dev) · line 100

Quoted 3 lines
drivers/clk/imx/clk-imx6q.c +1 -2
-       clk_dm(IMX6QDL_CLK_ECSPI_ROOT,
-              imx_clk_divider("ecspi_root", "pll3_60m", base + 0x38, 19, 6));
+       if (of_machine_is_compatible("fsl,imx6qp")

Same here.

Sorry about all the noise.

I think I forgot to type 'git add' before the "git commit --amend" so the fix didn't get applied, but because the same file was shown in the commit message, it looked like the fix was in place. I'll have to confirm when I get back to my build machine.

I'll manually build a few more mx6 platforms and try to spend some more time trying to figure out the CI/CD tools.

adam

reviewer
#4 lore raw

Re: [PATCH V3 01/10] clk: imx6q: Properly handle imx6qp ECSPI clk_sels

Quoted 9 lines · Adam Ford

Sorry about all the noise.

I think I forgot to type 'git add' before the "git commit --amend" so the fix didn't get applied, but because the same file was shown in the commit message, it looked like the fix was in place. I'll have to confirm when I get back to my build machine.

I'll manually build a few more mx6 platforms and try to spend some more time trying to figure out the CI/CD tools.

I have manually fixed patches 1 and 2 and now CI is happy with the series.

No need to resend it.

author
#5 lore raw

Re: [PATCH V3 01/10] clk: imx6q: Properly handle imx6qp ECSPI clk_sels

Quoted 10 lines · Fabio Estevam
Quoted 7 lines · Adam Ford

Sorry about all the noise.

I think I forgot to type 'git add' before the "git commit --amend" so the fix didn't get applied, but because the same file was shown in the commit message, it looked like the fix was in place. I'll have to confirm when I get back to my build machine.

Quoted 6 lines
Quoted 2 lines

I'll manually build a few more mx6 platforms and try to spend some more time trying to figure out the CI/CD tools.

I have manually fixed patches 1 and 2 and now CI is happy with the series.

No need to resend it.

I am sorry you had to do that. :-(

Thanks for help.

adam

reviewer
#6 lore raw

Re: [PATCH V3 01/10] clk: imx6q: Properly handle imx6qp ECSPI clk_sels

In reply to Fabio Estevam
Quoted 3 lines · Fabio Estevam

I have manually fixed patches 1 and 2 and now CI is happy with the series.

No need to resend it.

Applied the series to u-boot-imx/next, thanks.

author
#7 lore raw

PATCH v3 2/10 clk: imx6q: Register UART clocks

In reply to Adam Ford

In order to use the driver model and clock system to enable UART clocks from the serial driver, it's necessary to register the UART clocks. With the helper function to check for imx6qp vs other variants, the UART can register for both scenarios.

---

V3:  No change
V2:  Directly call of_machine_is_compatible("fsl,imx6qp") instead of

using a helper function

 drivers/clk/imx/clk-imx6q.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/clk/imx/clk-imx6q.c +17 -3
index 15ad0c9ac06..a4295614016 100644
@@ -35,6 +35,7 @@ static const char *const usdhc_sels[] = { "pll2_pfd2_396m", "pll2_pfd0_352m", };
 static const char *const periph_sels[]	= { "periph_pre", "periph_clk2", };
 static const char *const periph_pre_sels[] = { "pll2_bus", "pll2_pfd2_396m",
 					       "pll2_pfd0_352m", "pll2_198m", };
+static const char *const uart_sels[] = { "pll3_80m", "osc", };
 static const char *const ecspi_sels[] = { "pll3_60m", "osc", };
 
 static int imx6q_clk_probe(struct udevice *dev)
@@ -79,10 +80,14 @@ static int imx6q_clk_probe(struct udevice *dev)
 	       imx_clk_mux("usdhc4_sel", base + 0x1c, 19, 1,
 			   usdhc_sels, ARRAY_SIZE(usdhc_sels)));
 
-	if (of_machine_is_compatible("fsl,imx6qp")
+	if (of_machine_is_compatible("fsl,imx6qp") {
+		clk_dm(IMX6QDL_CLK_UART_SEL,
+		       imx_clk_mux("uart_sel", base + 0x24, 6, 1, uart_sels,
+				   ARRAY_SIZE(uart_sels)));
 		clk_dm(IMX6QDL_CLK_ECSPI_SEL,
 		       imx_clk_mux("ecspi_sel",	base + 0x38, 18, 1, ecspi_sels,
 				   ARRAY_SIZE(ecspi_sels)));
+	}
 
 	clk_dm(IMX6QDL_CLK_USDHC1_PODF,
 	       imx_clk_divider("usdhc1_podf", "usdhc1_sel",
@@ -97,12 +102,17 @@ static int imx6q_clk_probe(struct udevice *dev)
 	       imx_clk_divider("usdhc4_podf", "usdhc4_sel",
 			       base + 0x24, 22, 3));
 
-	if (of_machine_is_compatible("fsl,imx6qp")
+	if (of_machine_is_compatible("fsl,imx6qp") {
+		clk_dm(IMX6QDL_CLK_UART_SERIAL_PODF,
+		       imx_clk_divider("uart_serial_podf", "uart_sel", base + 0x24, 0, 6));
 		clk_dm(IMX6QDL_CLK_ECSPI_ROOT,
 		       imx_clk_divider("ecspi_root", "ecspi_sel", base + 0x38, 19, 6));
-	else
+	} else {
+		clk_dm(IMX6QDL_CLK_UART_SERIAL_PODF,
+		       imx_clk_divider("uart_serial_podf", "pll3_80m", base + 0x24, 0, 6));
 		clk_dm(IMX6QDL_CLK_ECSPI_ROOT,
 		       imx_clk_divider("ecspi_root", "pll3_60m", base + 0x38, 19, 6));
+	}
 
 	clk_dm(IMX6QDL_CLK_ECSPI1,
 	       imx_clk_gate2("ecspi1", "ecspi_root", base + 0x6c, 0));
@@ -112,6 +122,10 @@ static int imx6q_clk_probe(struct udevice *dev)
 	       imx_clk_gate2("ecspi3", "ecspi_root", base + 0x6c, 4));
 	clk_dm(IMX6QDL_CLK_ECSPI4,
 	       imx_clk_gate2("ecspi4", "ecspi_root", base + 0x6c, 6));
+	clk_dm(IMX6QDL_CLK_UART_IPG,
+	       imx_clk_gate2("uart_ipg", "ipg", base + 0x7c, 24));
+	clk_dm(IMX6QDL_CLK_UART_SERIAL,
+	       imx_clk_gate2("uart_serial", "uart_serial_podf",  base + 0x7c, 26));
 	clk_dm(IMX6QDL_CLK_USDHC1,
 	       imx_clk_gate2("usdhc1", "usdhc1_podf", base + 0x80, 2));
 	clk_dm(IMX6QDL_CLK_USDHC2,
Signature · 1 line
2.45.2
author
#8 lore raw

PATCH v3 3/10 clk: imx8mm: register UART clocks

In reply to Adam Ford

In order to let the serial driver enable the clocks, the UART clocks must be registered first.

---
 drivers/clk/imx/clk-imx8mm.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
V3:  No change
V2:  No Change
drivers/clk/imx/clk-imx8mm.c +34 -0
index bb6958f0ec2..378c07caba3 100644
@@ -81,6 +81,22 @@ static const char * const imx8mm_i2c4_sels[] = {"clock-osc-24m", "sys_pll1_160m"
 						"sys_pll3_out", "audio_pll1_out", "video_pll1_out",
 						"audio_pll2_out", "sys_pll1_133m", };
 
+static const char * const imx8mm_uart1_sels[] = {"clock-osc-24m", "sys_pll1_80m", "sys_pll2_200m",
+					  "sys_pll2_100m", "sys_pll3_out", "clk_ext2", "clk_ext4",
+					  "audio_pll2_out", };
+
+static const char * const imx8mm_uart2_sels[] = {"clock-osc-24m", "sys_pll1_80m", "sys_pll2_200m",
+					  "sys_pll2_100m", "sys_pll3_out", "clk_ext2", "clk_ext3",
+					  "audio_pll2_out", };
+
+static const char * const imx8mm_uart3_sels[] = {"clock-osc-24m", "sys_pll1_80m", "sys_pll2_200m",
+					  "sys_pll2_100m", "sys_pll3_out", "clk_ext2", "clk_ext4",
+					  "audio_pll2_out", };
+
+static const char * const imx8mm_uart4_sels[] = {"clock-osc-24m", "sys_pll1_80m", "sys_pll2_200m",
+					  "sys_pll2_100m", "sys_pll3_out", "clk_ext2", "clk_ext3",
+					  "audio_pll2_out", };
+
 #if CONFIG_IS_ENABLED(PCIE_DW_IMX)
 static const char * const imx8mm_pcie1_ctrl_sels[] = {"clock-osc-24m", "sys_pll2_250m", "sys_pll2_200m",
 						      "sys_pll1_266m", "sys_pll1_800m", "sys_pll2_500m",
@@ -322,6 +338,24 @@ static int imx8mm_clk_probe(struct udevice *dev)
 	       imx8m_clk_composite("i2c3", imx8mm_i2c3_sels, base + 0xae00));
 	clk_dm(IMX8MM_CLK_I2C4,
 	       imx8m_clk_composite("i2c4", imx8mm_i2c4_sels, base + 0xae80));
+
+	clk_dm(IMX8MM_CLK_UART1,
+	       imx8m_clk_composite("uart1", imx8mm_uart1_sels, base + 0xaf00));
+	clk_dm(IMX8MM_CLK_UART2,
+	       imx8m_clk_composite("uart2", imx8mm_uart2_sels, base + 0xaf80));
+	clk_dm(IMX8MM_CLK_UART3,
+	       imx8m_clk_composite("uart3", imx8mm_uart3_sels, base + 0xb000));
+	clk_dm(IMX8MM_CLK_UART4,
+	       imx8m_clk_composite("uart4", imx8mm_uart4_sels, base + 0xb080));
+	clk_dm(IMX8MM_CLK_UART1_ROOT,
+	       imx_clk_gate4("uart1_root_clk", "uart1", base + 0x4490, 0));
+	clk_dm(IMX8MM_CLK_UART2_ROOT,
+	       imx_clk_gate4("uart2_root_clk", "uart2", base + 0x44a0, 0));
+	clk_dm(IMX8MM_CLK_UART3_ROOT,
+	       imx_clk_gate4("uart3_root_clk", "uart3", base + 0x44b0, 0));
+	clk_dm(IMX8MM_CLK_UART4_ROOT,
+	       imx_clk_gate4("uart4_root_clk", "uart4", base + 0x44c0, 0));
+
 	clk_dm(IMX8MM_CLK_WDOG,
 	       imx8m_clk_composite("wdog", imx8mm_wdog_sels, base + 0xb900));
 	clk_dm(IMX8MM_CLK_USDHC3,
Signature · 1 line
2.45.2
author
#9 lore raw

PATCH v3 4/10 clk: imx8mn: register UART clocks

In reply to Adam Ford

In order to let the serial driver enable the clocks, the UART clocks must be registered first.

---
 drivers/clk/imx/clk-imx8mn.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
V3:  No change
V2:  No Change
drivers/clk/imx/clk-imx8mn.c +32 -0
index be15ebd0e25..54ae887817a 100644
@@ -97,6 +97,22 @@ static const char * const imx8mn_i2c4_sels[] = {"clock-osc-24m", "sys_pll1_160m"
 						"sys_pll3_out", "audio_pll1_out", "video_pll_out",
 						"audio_pll2_out", "sys_pll1_133m", };
 
+static const char * const imx8mn_uart1_sels[] = {"clock-osc-24m", "sys_pll1_80m", "sys_pll2_200m",
+						 "sys_pll2_100m", "sys_pll3_out", "clk_ext2",
+						 "clk_ext4", "audio_pll2_out", };
+
+static const char * const imx8mn_uart2_sels[] = {"clock-osc-24m", "sys_pll1_80m", "sys_pll2_200m",
+						 "sys_pll2_100m", "sys_pll3_out", "clk_ext2",
+						 "clk_ext3", "audio_pll2_out", };
+
+static const char * const imx8mn_uart3_sels[] = {"clock-osc-24m", "sys_pll1_80m", "sys_pll2_200m",
+						 "sys_pll2_100m", "sys_pll3_out", "clk_ext2",
+						 "clk_ext4", "audio_pll2_out", };
+
+static const char * const imx8mn_uart4_sels[] = {"clock-osc-24m", "sys_pll1_80m", "sys_pll2_200m",
+						 "sys_pll2_100m", "sys_pll3_out", "clk_ext2",
+						 "clk_ext3", "audio_pll2_out", };
+
 #ifndef CONFIG_XPL_BUILD
 static const char * const imx8mn_pwm1_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m",
 						"sys_pll1_40m", "sys_pll3_out", "clk_ext1",
@@ -311,6 +327,14 @@ static int imx8mn_clk_probe(struct udevice *dev)
 	       imx8m_clk_composite("i2c3", imx8mn_i2c3_sels, base + 0xae00));
 	clk_dm(IMX8MN_CLK_I2C4,
 	       imx8m_clk_composite("i2c4", imx8mn_i2c4_sels, base + 0xae80));
+	clk_dm(IMX8MN_CLK_UART1,
+	       imx8m_clk_composite("uart1", imx8mn_uart1_sels, base + 0xaf00));
+	clk_dm(IMX8MN_CLK_UART2,
+	       imx8m_clk_composite("uart2", imx8mn_uart2_sels, base + 0xaf80));
+	clk_dm(IMX8MN_CLK_UART3,
+	       imx8m_clk_composite("uart3", imx8mn_uart3_sels, base + 0xb000));
+	clk_dm(IMX8MN_CLK_UART4,
+	       imx8m_clk_composite("uart4", imx8mn_uart4_sels, base + 0xb080));
 	clk_dm(IMX8MN_CLK_WDOG,
 	       imx8m_clk_composite("wdog", imx8mn_wdog_sels, base + 0xb900));
 	clk_dm(IMX8MN_CLK_USDHC3,
@@ -355,6 +379,14 @@ static int imx8mn_clk_probe(struct udevice *dev)
 	       imx_clk_gate2_shared2("nand_usdhc_rawnand_clk",
 				     "nand_usdhc_bus", base + 0x4300, 0,
 				     &share_count_nand));
+	clk_dm(IMX8MN_CLK_UART1_ROOT,
+	       imx_clk_gate4("uart1_root_clk", "uart1", base + 0x4490, 0));
+	clk_dm(IMX8MN_CLK_UART2_ROOT,
+	       imx_clk_gate4("uart2_root_clk", "uart2", base + 0x44a0, 0));
+	clk_dm(IMX8MN_CLK_UART3_ROOT,
+	       imx_clk_gate4("uart3_root_clk", "uart3", base + 0x44b0, 0));
+	clk_dm(IMX8MN_CLK_UART4_ROOT,
+	       imx_clk_gate4("uart4_root_clk", "uart4", base + 0x44c0, 0));
 	clk_dm(IMX8MN_CLK_USB1_CTRL_ROOT,
 		imx_clk_gate4("usb1_ctrl_root_clk", "usb_bus", base + 0x44d0, 0));
 
Signature · 1 line
2.45.2
author
#10 lore raw

PATCH v3 5/10 serial: mxc: Support bulk enabling clocks

In reply to Adam Ford

Depending on the platform, there may be multiple clock sources required to enable a UART. Use the bulk functions to get and enable the clocks when the UART probes. This can facilitate the removal of functions to manually enable the clock.

This is made dependent on CLK_CCF which is used on imx6q, imx8m[mnqp], several imxrt, imx9. If/when the UART clock registration is done for older boards, this limitation could be updated.

---
 drivers/serial/serial_mxc.c           | 11 +++++++++++
 include/dm/platform_data/serial_mxc.h |  3 +++
 2 files changed, 14 insertions(+)
V3:  Fix second build issue not caught in V2
V2:  Fix build issue when built without CLK_CCF
drivers/serial/serial_mxc.c +11 -0
index c5fd740be4d..28f4435d01d 100644
@@ -3,6 +3,7 @@
  * (c) 2007 Sascha Hauer <[email protected]>
  */
 
+#include <clk.h>
 #include <dm.h>
 #include <errno.h>
 #include <watchdog.h>
@@ -312,7 +313,17 @@ int mxc_serial_setbrg(struct udevice *dev, int baudrate)
 static int mxc_serial_probe(struct udevice *dev)
 {
 	struct mxc_serial_plat *plat = dev_get_plat(dev);
+#if CONFIG_IS_ENABLED(CLK_CCF)
+	int ret;
 
+	ret = clk_get_bulk(dev, &plat->clks);
+	if (ret)
+		return ret;
+
+	ret = clk_enable_bulk(&plat->clks);
+	if (ret)
+		return ret;
+#endif
 	_mxc_serial_init(plat->reg, plat->use_dte);
 
 	return 0;
include/dm/platform_data/serial_mxc.h +3 -0
index cc59eeb1dd1..52657aa3deb 100644
@@ -9,6 +9,9 @@
 /* Information about a serial port */
 struct mxc_serial_plat {
 	struct mxc_uart *reg;  /* address of registers in physical memory */
+#if CONFIG_IS_ENABLED(CLK_CCF)
+	struct clk_bulk clks;
+#endif
 	bool use_dte;
 };
 
Signature · 1 line
2.45.2
author
#11 lore raw

PATCH v3 6/10 board: beacon: imx8mm: Let clock system enable UART clock

In reply to Adam Ford

Now that the UART driver can enable the required clocks, remove the hard-coded clock enable. This requires a small re-order of a couple functions.

---
 board/beacon/imx8mm/spl.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

V3: No change
V2: No change

board/beacon/imx8mm/spl.c +1 -5
index 12013aa5a4d..93ee5b7ee0c 100644
@@ -100,9 +100,6 @@ void board_init_f(ulong dummy)
 	int ret;
 
 	arch_cpu_init();
-
-	init_uart_clk(1);
-
 	timer_init();
 
 	/* Clear the BSS. */
@@ -114,8 +111,6 @@ void board_init_f(ulong dummy)
 		hang();
 	}
 
-	preloader_console_init();
-
 	ret = uclass_get_device_by_name(UCLASS_CLK,
 					"clock-controller@30380000",
 					&dev);
@@ -124,6 +119,7 @@ void board_init_f(ulong dummy)
 		hang();
 	}
 
+	preloader_console_init();
 	enable_tzc380();
 
 	power_init_board();
Signature · 1 line
2.45.2
author
#12 lore raw

PATCH v3 7/10 board: beacon: imx8mn: Let clock system enable UART clock

In reply to Adam Ford

Now that the UART driver can enable the required clocks, remove the hard-coded clock enable.

---
 board/beacon/imx8mn/spl.c | 2 --
 1 file changed, 2 deletions(-)
V3:  No Change
V2:  No change
board/beacon/imx8mn/spl.c +0 -2
index f03841e5a01..e91d3fdcf5e 100644
@@ -111,8 +111,6 @@ int board_early_init_f(void)
 	/* Claiming pwm pins prevents LCD flicker during startup*/
 	imx_iomux_v3_setup_multiple_pads(pwm_pads, ARRAY_SIZE(pwm_pads));
 
-	init_uart_clk(1);
-
 	return 0;
 }
 
Signature · 1 line
2.45.2
author
#13 lore raw

PATCH v3 8/10 clk: imx: select SPL_CLK_COMPOSITE_CCF when SPL_CLK_IMX8MP

In reply to Adam Ford

If SPL_CLK_IMX8MP is selected alone, it causes a build error. The clock composite is required when using the clock framework, so select it when SPL_CLK_IMX8MP is enabled. This is already being done outside of SPL.

---
 drivers/clk/imx/Kconfig | 1 +
 1 file changed, 1 insertion(+)
V3:  No change
V2:  No change
drivers/clk/imx/Kconfig +1 -0
index 56d893e0579..d17a54fb9b3 100644
@@ -60,6 +60,7 @@ config SPL_CLK_IMX8MP
 	depends on ARCH_IMX8M && SPL
 	select SPL_CLK
 	select SPL_CLK_CCF
+	select SPL_CLK_COMPOSITE_CCF
 	help
 	  This enables SPL DM/DTS support for clock driver in i.MX8MP
 
Signature · 1 line
2.45.2
author
#14 lore raw

PATCH v3 9/10 configs: imx8mp_beacon: Select SPL_CLK_IMX8MP

In reply to Adam Ford

In preparation to remove manual references for enabling some clocks, enable SPL_CLK_IMX8MP which automatically enables SPL_CCF and SPL_CLK_COMPOSITE_CCF which permit various drivers to activate their respective clocks automatically.

---
 configs/imx8mp_beacon_defconfig | 1 +
 1 file changed, 1 insertion(+)
V3:  No change
V2:  No change
configs/imx8mp_beacon_defconfig +1 -0
index f39e4f5dd28..9709f628f9c 100644
@@ -86,6 +86,7 @@ CONFIG_USE_ETHPRIME=y
 CONFIG_ETHPRIME="eth1"
 CONFIG_SPL_DM=y
 CONFIG_CLK_COMPOSITE_CCF=y
+CONFIG_SPL_CLK_IMX8MP=y
 CONFIG_CLK_IMX8MP=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x42800000
Signature · 1 line
2.45.2
author
#15 lore raw

PATCH v3 10/10 board: beacon: imx8mp: Let clock system enable UART clock

In reply to Adam Ford

Now that the UART driver can enable the required clocks, remove the hard-coded clock enable.

---
 board/beacon/imx8mp/spl.c | 2 --
 1 file changed, 2 deletions(-)
V3:  No change
V2:  No change
board/beacon/imx8mp/spl.c +0 -2
index 30d577f7e0e..6b357d90a3f 100644
@@ -112,8 +112,6 @@ void board_init_f(ulong dummy)
 
 	arch_cpu_init();
 
-	init_uart_clk(1);
-
 	ret = spl_early_init();
 	if (ret) {
 		debug("spl_init() failed: %d\n", ret);
Signature · 1 line
2.45.2
reviewer
#16 lore raw
In reply to Adam Ford
Quoted 10 lines · Adam Ford

Currenty, most peripherals enable/disable their respecive clocks using the clock framework, but serial ports various imx platsforms do not. Some of the newer NXP SoC's register the UART clocks, but they are not necessarily associated the to serial_mxc driver, so these clocks need to be manually enabled. Even when the driver model enumerates the UART, the driver model doesn't always reflect the proper clock state, because these clocks are not controlled by the serial driver.

This series does a few things:

Still fails:
https://source.denx.de/u-boot/custodians/u-boot-imx/-/jobs/1068998/raw

arm: + kp_imx6q_tpc
+drivers/clk/imx/clk-imx6q.c: In function 'imx6q_clk_probe':
+drivers/clk/imx/clk-imx6q.c:83:51: error: expected ')' before '{' token

+   83 |         if (of_machine_is_compatible("fsl,imx6qp") {
+      |            ~                                      ^~
+      |                                                   )

+drivers/clk/imx/clk-imx6q.c:83:9: note: '-Wmisleading-indentation' is disabled from this point onwards, since column-tracking was disabled due to the size of the code/headers
+ | ^~
+drivers/clk/imx/clk-imx6q.c:83:9: note: adding '-flarge-source-files' will allow for more column-tracking support, at the expense of compilation time and memory
+drivers/clk/imx/clk-imx6q.c:179:1: error: expected declaration or statement at end of input
+ 179 | };
+ | ^
+drivers/clk/imx/clk-imx6q.c: At top level:
+drivers/clk/imx/clk-imx6q.c:41:12: error: 'imx6q_clk_probe' defined but not used [-Werror=unused-function]
+ 41 | static int imx6q_clk_probe(struct udevice *dev)
+ | ^~~~~~~~~~~~~~~
+drivers/clk/imx/clk-imx6q.c:39:26: error: 'ecspi_sels' defined but not used [-Werror=unused-const-variable=]
+ 39 | static const char *const ecspi_sels[] = { "pll3_60m", "osc", };
+ | ^~~~~~~~~~
+drivers/clk/imx/clk-imx6q.c:38:26: error: 'uart_sels' defined but not used [-Werror=unused-const-variable=]
+ 38 | static const char *const uart_sels[] = { "pll3_80m", "osc", };
+ | ^~~~~~~~~
+drivers/clk/imx/clk-imx6q.c:36:26: error: 'periph_pre_sels' defined but not used [-Werror=unused-const-variable=]
+ 36 | static const char *const periph_pre_sels[] = { "pll2_bus",
"pll2_pfd2_396m",
+ | ^~~~~~~~~~~~~~~
+drivers/clk/imx/clk-imx6q.c:35:26: error: 'periph_sels' defined but not used [-Werror=unused-const-variable=]
+ 35 | static const char *const periph_sels[] = { "periph_pre",
"periph_clk2", };
+ | ^~~~~~~~~~~
+drivers/clk/imx/clk-imx6q.c:26:23: error: 'imx6q_clk_ops' defined but not used [-Werror=unused-variable]
+ 26 | static struct clk_ops imx6q_clk_ops = {
+ | ^~~~~~~~~~~~~
+cc1: all warnings being treated as errors
+make[4]: *** [scripts/Makefile.build:257: drivers/clk/imx/clk-imx6q.o] Error 1 +make[3]: *** [scripts/Makefile.build:398: drivers/clk/imx] Error 2 +make[2]: *** [scripts/Makefile.build:398: drivers/clk] Error 2 +make[1]: *** [Makefile:1917: drivers] Error 2
+make: *** [Makefile:177: sub-make] Error 2