Skip to contentSkip to conversation

imx6: clock: add support to get LCD pixel clock rate

PATCH RESEND In review Dario Binacchi 3 participants 8 messages Apr 22, 2023 – May 2, 2023

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

cover imx6: clock: add support to get LCD pixel clock rate

The series adds a function to get the LCD pixel clock rate. Also improves video PLLL rate calculation.

Dario Binacchi (3):
imx6: clock: improve calculations to get the PLL video rate
imx6: clock: add support to get LCD pixel clock rate
imx6: clock: print real pixel clock rate

 arch/arm/include/asm/arch-mx6/clock.h |  2 +
 arch/arm/mach-imx/mx6/clock.c         | 66 ++++++++++++++++++++++++++-
 2 files changed, 67 insertions(+), 1 deletion(-)
Signature · 1 line
2.32.0
#1 lore raw

PATCH RESEND 1/3 imx6: clock: improve calculations to get the PLL video rate

During some tests to check the pixel clock rate in the transition from U-Boot to the Linux kernel, I noticed that with the same configuration of the registers the debug messages reported different rates.

The same Linux kernel calculations are now used to get the PLL video rate.

---

 arch/arm/mach-imx/mx6/clock.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm/mach-imx/mx6/clock.c +5 -1
index cb9d629be408..17d8dcd5c841 100644
@@ -213,6 +213,7 @@ int enable_spi_clk(unsigned char enable, unsigned spi_num)
 static u32 decode_pll(enum pll_clocks pll, u32 infreq)
 {
 	u32 div, test_div, pll_num, pll_denom;
+	u64 temp64;
 
 	switch (pll) {
 	case PLL_SYS:
@@ -272,7 +273,10 @@ static u32 decode_pll(enum pll_clocks pll, u32 infreq)
 		}
 		test_div = 1 << (2 - test_div);
 
-		return infreq * (div + pll_num / pll_denom) / test_div;
+		temp64 = (u64)infreq;
+		temp64 *= pll_num;
+		do_div(temp64, pll_denom);
+		return infreq * div + (unsigned long)temp64;
 	default:
 		return 0;
 	}
Signature · 1 line
2.32.0
#2 lore raw

PATCH RESEND 1/3 imx6: clock: improve calculations to get the PLL video rate

Quoted 7 lines

During some tests to check the pixel clock rate in the transition from U-Boot to the Linux kernel, I noticed that with the same configuration of the registers the debug messages reported different rates. The same Linux kernel calculations are now used to get the PLL video rate.

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#3 lore raw

PATCH RESEND 2/3 imx6: clock: add support to get LCD pixel clock rate

In reply to Dario Binacchi

Add the get_lcd_clk() function to get the LCD pixel clock rate.

The patch has been tested on imx6ul platform.

---

 arch/arm/include/asm/arch-mx6/clock.h |  2 +
 arch/arm/mach-imx/mx6/clock.c         | 58 +++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
arch/arm/include/asm/arch-mx6/clock.h +2 -0
index 8ae49715789c..81af89c631f5 100644
@@ -41,6 +41,8 @@ enum mxc_clock {
 	MXC_SATA_CLK,
 	MXC_NFC_CLK,
 	MXC_I2C_CLK,
+	MXC_LCDIF1_CLK,
+	MXC_LCDIF2_CLK,
 };
 
 enum ldb_di_clock {
arch/arm/mach-imx/mx6/clock.c +58 -0

70 lines not on this page · raw message

Signature · 1 line
2.32.0
#4 lore raw

PATCH RESEND 2/3 imx6: clock: add support to get LCD pixel clock rate

Quoted 3 lines

Add the get_lcd_clk() function to get the LCD pixel clock rate. The patch has been tested on imx6ul platform.

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#5 lore raw

PATCH RESEND 3/3 imx6: clock: print real pixel clock rate

In reply to Dario Binacchi

Add debug messages to print the real pixel clock rate, which may not be the requested one.

---

 arch/arm/mach-imx/mx6/clock.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-imx/mx6/clock.c +2 -0
index 267d86ab4194..1bdc568f9b14 100644
@@ -802,6 +802,7 @@ void mxs_set_lcdclk(u32 base_addr, u32 freq)
 		}
 
 		enable_lcdif_clock(base_addr, 1);
+		debug("pixel clock = %u\n", mxc_get_clock(MXC_LCDIF1_CLK));
 	} else if (is_mx6sx()) {
 		/* Setting LCDIF2 for i.MX6SX */
 		if (enable_pll_video(pll_div, pll_num, pll_denom, post_div))
@@ -823,6 +824,7 @@ void mxs_set_lcdclk(u32 base_addr, u32 freq)
 				 MXC_CCM_CSCMR1_LCDIF2_PODF_OFFSET));
 
 		enable_lcdif_clock(base_addr, 1);
+		debug("pixel clock = %u\n", mxc_get_clock(MXC_LCDIF2_CLK));
 	}
 }
 
Signature · 1 line
2.32.0
#6 lore raw

PATCH RESEND 3/3 imx6: clock: print real pixel clock rate

Quoted 3 lines

Add debug messages to print the real pixel clock rate, which may not be the requested one.

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
reviewer Reviewed-by on the v1 series
#7 lore raw
In reply to Dario Binacchi

Hi Dario,

Quoted 9 lines · Dario Binacchi

The series adds a function to get the LCD pixel clock rate. Also improves video PLLL rate calculation.

Dario Binacchi (3):
imx6: clock: improve calculations to get the PLL video rate
imx6: clock: add support to get LCD pixel clock rate
imx6: clock: print real pixel clock rate

For the series: