[PATCH] Adding IPU clock query functions for i.MX31 and i.MX35

Juergen Beisert jbe at pengutronix.de
Tue Nov 24 11:04:17 EST 2009


Adding IPU clock query functions for i.MX31 and i.MX35
(used to generate their LCD timing).

BTW: All functions are declared with the 'ulong' return type, but some are
defined with 'unsigned long'. And yes, its the same, but IMHO one type should
be used for all.

Signed-off-by: Juergen Beisert <jbe at pengutronix.de>

---
 arch/arm/mach-imx/speed-imx31.c |   12 ++++++++++++
 arch/arm/mach-imx/speed-imx35.c |   31 +++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

Index: u-boot-v2/arch/arm/mach-imx/speed-imx35.c
===================================================================
--- u-boot-v2.orig/arch/arm/mach-imx/speed-imx35.c
+++ u-boot-v2/arch/arm/mach-imx/speed-imx35.c
@@ -118,6 +118,37 @@ unsigned long imx_get_gptclk(void)
 	return imx_get_ipgclk();
 }
 
+/**
+ * Calculate the current pixel clock speed (aka HSP or IPU)
+ * @return 0 on failure or current frequency in Hz
+ */
+unsigned long imx_get_lcdclk(void)
+{
+	unsigned long hsp_podf = (readl(IMX_CCM_BASE + CCM_PDR0) >> 20) & 0x03;
+	unsigned long base_clk = imx_get_armclk();
+
+	if (base_clk > 400 * 1000 * 1000) {
+		switch(hsp_podf) {
+		case 0:
+			return base_clk >> 2;
+		case 1:
+			return base_clk >> 3;
+		case 2:
+			return base_clk / 3;
+		}
+	} else {
+		switch(hsp_podf) {
+		case 0:
+		case 2:
+			return base_clk / 3;
+		case 1:
+			return base_clk / 6;
+		}
+	}
+
+	return 0;
+}
+
 unsigned long imx_get_uartclk(void)
 {
 	unsigned long pdr3 = readl(IMX_CCM_BASE + CCM_PDR3);
Index: u-boot-v2/arch/arm/mach-imx/speed-imx31.c
===================================================================
--- u-boot-v2.orig/arch/arm/mach-imx/speed-imx31.c
+++ u-boot-v2/arch/arm/mach-imx/speed-imx31.c
@@ -41,6 +41,18 @@ ulong imx_get_mcu_main_clk(void)
 	return imx_get_mpl_dpdgck_clk();
 }
 
+/**
+ * Calculate the current pixel clock speed (aka HSP or IPU)
+ * @return 0 on failure or current frequency in Hz
+ */
+ulong imx_get_lcdclk(void)
+{
+	ulong hsp_podf = (readl(IMX_CCM_BASE + CCM_PDR0) >> 11) & 0x03;
+	ulong base_clk = imx_get_mcu_main_clk();
+
+	return base_clk / (hsp_podf + 1);
+}
+
 ulong imx_get_perclk1(void)
 {
 	u32 freq = imx_get_mcu_main_clk();

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | Phone: +49-8766-939 228     |
Vertretung Sued/Muenchen, Germany             | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686              | http://www.pengutronix.de/  |




More information about the barebox mailing list