Skip to contentSkip to conversation

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

PATCH Superseded Dario Binacchi 2 participants 5 messages Feb 25, 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 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
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] imx6: clock: improve calculations to get the PLL video rate

Quoted 27 lines · Dario Binacchi

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 +1 -0
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:

arch/arm/mach-imx/mx6/clock.c static u32 decode_pll(enum pll_clocks pll, u32 infreq) · line 281

Quoted 10 lines
arch/arm/mach-imx/mx6/clock.c +4 -1
@@ -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;
Quoted 5 lines
arch/arm/mach-imx/mx6/clock.c +0 -1
        }
--

2.32.0

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#3 lore raw

PATCH 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 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