Skip to contentSkip to conversation

imx6: fix LDB clock source selection bugs

PATCH In review Md Shofiqul Islam 2 participants 4 messages May 18 – May 22 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

cover imx6: fix LDB clock source selection bugs

Two fixes following Brian's review of the v2 LDB clock series:

1. select_ldb_di_clock_source() had clk0 and clk1 written to the wrong registers (LDB_DI1 and LDB_DI0 respectively). Silent until now because all callers passed the same value for both arguments.

2. The CONFIG_SPL_BUILD guard in clk-imx6q.c was too broad — it excluded SPL builds that legitimately need LDB clock init when CONFIG_SPL_VIDEO is enabled. Also adds the missing guards in aristainetos.c and b1x5v2.c so select_ldb_di_clock_source() is only called when video support is actually configured.

Md Shofiqul Islam (2):
imx6: clock: fix clk0/clk1 swap in select_ldb_di_clock_source()
imx6: guard LDB clock init with appropriate video config

 arch/arm/mach-imx/mx6/clock.c     | 4 ++--
 board/aristainetos/aristainetos.c | 2 ++
 board/ge/b1x5v2/b1x5v2.c          | 3 ++-
 drivers/clk/imx/clk-imx6q.c       | 6 +++---
 4 files changed, 9 insertions(+), 6 deletions(-)
Signature · 1 line
2.51.1
#2 lore raw

PATCH 1/2 imx6: clock: fix clk0/clk1 swap in select_ldb_di_clock_source()

clk0 was being written to LDB_DI1_CLK_SEL and clk1 to LDB_DI0_CLK_SEL. The arguments were silently effective before because all callers passed the same value for both, but the mapping was reversed.

Fixes bd3e19dbd90 ("imx6: clock: allow different clock sources for ldb")
---
 arch/arm/mach-imx/mx6/clock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-imx/mx6/clock.c +2 -2
index 828a101ba05..646d1fff6d7 100644
@@ -1525,8 +1525,8 @@ void select_ldb_di_clock_source(enum ldb_di_clock clk0, enum ldb_di_clock clk1)
 	reg = readl(&mxc_ccm->cs2cdr);
 	reg &= ~(MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK
 	      | MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK);
-	reg |= ((clk0 << MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET)
-	      | (clk1 << MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET));
+	reg |= ((clk1 << MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET)
+	      | (clk0 << MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET));
 	writel(reg, &mxc_ccm->cs2cdr);
 
 	/* Unbypass pll3_sw_clk */
Signature · 1 line
2.51.1
#3 lore raw

PATCH 2/2 imx6: guard LDB clock init with appropriate video config

In reply to Md Shofiqul Islam

Brian pointed out that SPL can support VIDEO, PANEL, and SPLASH_SCREEN, so guarding select_ldb_di_clock_source() with !CONFIG_SPL_BUILD was too broad — it excluded SPL builds that legitimately need the LDB clocks.

- b1x5v2: guard with CONFIG_SPL_VIDEO as Brian suggested
- aristainetos: guard with CONFIG_VIDEO_IPUV3 (no SPL on this board)
- clk-imx6q: fix guard mismatch — imx6q_init_ldb_clks() was defined only for CONFIG_SPL_VIDEO but called for !CONFIG_SPL_BUILD, causing a build failure on non-SPL boards using CONFIG_VIDEO_IPUV3; use (!CONFIG_SPL_BUILD || CONFIG_SPL_VIDEO) on both definition and call

Fixes faa4793ad3d ("clk: imx6q: guard LDB clock init with CONFIG_SPL_BUILD")
---
 board/aristainetos/aristainetos.c | 2 ++
 board/ge/b1x5v2/b1x5v2.c          | 3 ++-
 drivers/clk/imx/clk-imx6q.c       | 6 +++---
 3 files changed, 7 insertions(+), 4 deletions(-)
board/aristainetos/aristainetos.c +2 -0
index 4a2349e165b..c163b49209e 100644
@@ -218,7 +218,9 @@ static void set_gpr_register(void)
 
 int board_early_init_f(void)
 {
+#if defined(CONFIG_VIDEO_IPUV3)
 	select_ldb_di_clock_source(MXC_PLL5_CLK, MXC_PLL5_CLK);
+#endif
 	set_gpr_register();
 
 	/*
board/ge/b1x5v2/b1x5v2.c +2 -1
index f7751fd6fb1..da7cb880eeb 100644
@@ -320,8 +320,9 @@ int overwrite_console(void)
 
 int board_early_init_f(void)
 {
+#if defined(CONFIG_SPL_VIDEO)
 	select_ldb_di_clock_source(MXC_PLL5_CLK, MXC_PLL5_CLK);
-
+#endif
 	return 0;
 }
 
drivers/clk/imx/clk-imx6q.c +3 -3
index 379155096e8..5be303468a9 100644
@@ -156,7 +156,7 @@ static struct clk_div_table video_div_table[] = {
 
 static unsigned int share_count_mipi_core_cfg;
 
-#if !defined(CONFIG_SPL_BUILD)
+#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_VIDEO)
 static void of_assigned_ldb_sels(struct udevice *dev, int *ldb_di0_sel,
 				 int *ldb_di1_sel)
 {
@@ -271,7 +271,7 @@ static void imx6q_init_ldb_clks(struct udevice *dev)
 
 	select_ldb_di_clock_source(ldb_di_clk[0], ldb_di_clk[1]);
 }
-#endif /* !CONFIG_SPL_BUILD */
+#endif /* !CONFIG_SPL_BUILD || CONFIG_SPL_VIDEO */
 
 static int imx6q_clk_probe(struct udevice *dev)
 {
@@ -490,7 +490,7 @@ static int imx6q_clk_probe(struct udevice *dev)
 		 * Need to set the clocks now and make them read-only due to a
 		 * hardware bug. Fixed on the i.MX6 QuadPlus
 		 */
-#if !defined(CONFIG_SPL_BUILD)
+#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_VIDEO)
 		imx6q_init_ldb_clks(dev);
 #endif
 		clk_dm(IMX6QDL_CLK_LDB_DI0_SEL,
Signature · 1 line
2.51.1
reviewer
#4 lore raw
In reply to Md Shofiqul Islam

Hi Md Shofiqul,

Quoted 2 lines · Md Shofiqul Islam

Two fixes following Brian's review of the v2 LDB clock series:

Please coordinate with Brian and submit your fixes as part of his series.