Patchwork [U-Boot,V2] MX31: Cleanup clock function

login
register
mail settings
Submitter Stefano Babic
Date July 14, 2011, 8:43 a.m.
Message ID <1310633037-5687-1-git-send-email-sbabic@denx.de>
Download mbox | patch
Permalink /patch/104642/
State Accepted
Commit 9f008bb47dd696d9e539fea2f045ae01b0c78a25
Headers show

Comments

Stefano Babic - July 14, 2011, 8:43 a.m.
The patch provide the same API used with other i.MX
processors and get rid of mx31_ functions.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---

Changes since V1:
	- remove unneeded initialization for enum (Fabio Estevam)

 arch/arm/cpu/arm1136/mx31/generic.c    |   21 ++++++++++++++++++++-
 arch/arm/include/asm/arch-mx31/clock.h |   11 +++++++++--
 drivers/spi/mxc_spi.c                  |    2 --
 3 files changed, 29 insertions(+), 5 deletions(-)

Patch

diff --git a/arch/arm/cpu/arm1136/mx31/generic.c b/arch/arm/cpu/arm1136/mx31/generic.c
index 4ebf38d..248431b 100644
--- a/arch/arm/cpu/arm1136/mx31/generic.c
+++ b/arch/arm/cpu/arm1136/mx31/generic.c
@@ -23,6 +23,7 @@ 
 
 #include <common.h>
 #include <asm/arch/imx-regs.h>
+#include <asm/arch/clock.h>
 #include <asm/io.h>
 
 static u32 mx31_decode_pll(u32 reg, u32 infreq)
@@ -60,7 +61,7 @@  static u32 mx31_get_mcu_main_clk(void)
 	return mx31_get_mpl_dpdgck_clk();
 }
 
-u32 mx31_get_ipg_clk(void)
+static u32 mx31_get_ipg_clk(void)
 {
 	u32 freq = mx31_get_mcu_main_clk();
 	u32 pdr0 = __REG(CCM_PDR0);
@@ -78,6 +79,24 @@  void mx31_dump_clocks(void)
 	printf("ipg clock     : %dHz\n", mx31_get_ipg_clk());
 }
 
+unsigned int mxc_get_clock(enum mxc_clock clk)
+{
+	switch (clk) {
+	case MXC_ARM_CLK:
+		return mx31_get_mcu_main_clk();
+	case MXC_IPG_CLK:
+	case MXC_CSPI_CLK:
+	case MXC_UART_CLK:
+		return mx31_get_ipg_clk();
+	}
+	return -1;
+}
+
+u32 imx_get_uartclk(void)
+{
+	return mxc_get_clock(MXC_UART_CLK);
+}
+
 void mx31_gpio_mux(unsigned long mode)
 {
 	unsigned long reg, shift, tmp;
diff --git a/arch/arm/include/asm/arch-mx31/clock.h b/arch/arm/include/asm/arch-mx31/clock.h
index 9f7ae80..fb035c4 100644
--- a/arch/arm/include/asm/arch-mx31/clock.h
+++ b/arch/arm/include/asm/arch-mx31/clock.h
@@ -24,8 +24,15 @@ 
 #ifndef __ASM_ARCH_CLOCK_H
 #define __ASM_ARCH_CLOCK_H
 
-extern u32 mx31_get_ipg_clk(void);
-#define imx_get_uartclk mx31_get_ipg_clk
+enum mxc_clock {
+	MXC_ARM_CLK,
+	MXC_IPG_CLK,
+	MXC_CSPI_CLK,
+	MXC_UART_CLK,
+};
+
+unsigned int mxc_get_clock(enum mxc_clock clk);
+extern u32 imx_get_uartclk();
 extern void mx31_gpio_mux(unsigned long mode);
 extern void mx31_set_pad(enum iomux_pins pin, u32 config);
 
diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c
index 698e726..81381d9 100644
--- a/drivers/spi/mxc_spi.c
+++ b/drivers/spi/mxc_spi.c
@@ -60,8 +60,6 @@  static unsigned long spi_bases[] = {
 	0x53f84000,
 };
 
-#define mxc_get_clock(x)	mx31_get_ipg_clk()
-
 #elif defined(CONFIG_MX51)
 
 #define MXC_CSPICTRL_EN		(1 << 0)