i.MX25: esdhc: Add mxc_get_clock infrastructure
authorTimo Ketola <timo@exertus.fi>
Wed, 18 Apr 2012 22:55:28 +0000 (22:55 +0000)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Tue, 15 May 2012 06:31:33 +0000 (08:31 +0200)
Defining CONFIG_FSL_ESDHC brings in a call to get_clocks, so let's
implement get_clocks function. This is how it seems to be implemented
elsewhere.

Signed-off-by: Timo Ketola <timo@exertus.fi>
Acked-by: Stefano Babic <sbabic@denx.de>
arch/arm/cpu/arm926ejs/mx25/generic.c
arch/arm/include/asm/arch-mx25/clock.h

index 9cadb7c34c0c6adffe68044055b4ff99c44001cf..8b07dae2b938a6cbc8021291c22f27f70e0bd4c1 100644 (file)
 #include <asm/io.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/imx25-pinmux.h>
+#include <asm/arch/clock.h>
 #ifdef CONFIG_MXC_MMC
 #include <asm/arch/mxcmmc.h>
 #endif
 
+#ifdef CONFIG_FSL_ESDHC
+DECLARE_GLOBAL_DATA_PTR;
+#endif
+
 /*
  *  get the system pll clock in Hz
  *
@@ -105,6 +110,20 @@ ulong imx_get_perclk(int clk)
        return lldiv(fref, div);
 }
 
+unsigned int mxc_get_clock(enum mxc_clock clk)
+{
+       if (clk >= MXC_CLK_NUM)
+               return -1;
+       switch (clk) {
+       case MXC_ARM_CLK:
+               return imx_get_armclk();
+       case MXC_FEC_CLK:
+               return imx_get_ahbclk();
+       default:
+               return imx_get_perclk(clk);
+       }
+}
+
 u32 get_cpu_rev(void)
 {
        u32 srev;
@@ -182,6 +201,14 @@ int cpu_eth_init(bd_t *bis)
 #endif
 }
 
+int get_clocks(void)
+{
+#ifdef CONFIG_FSL_ESDHC
+       gd->sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
+#endif
+       return 0;
+}
+
 /*
  * Initializes on-chip MMC controllers.
  * to override, implement board_mmc_init()
index c59f5885700c577214c734b7fa3a7b38fd15ba89..0f47eaf053c2dd57de62eff3d21d310c9636ba8b 100644 (file)
 #ifndef __ASM_ARCH_CLOCK_H
 #define __ASM_ARCH_CLOCK_H
 
+enum mxc_clock {
+       MXC_CSI_CLK,
+       MXC_EPIT_CLK,
+       MXC_ESAI_CLK,
+       MXC_ESDHC1_CLK,
+       MXC_ESDHC2_CLK,
+       MXC_GPT_CLK,
+       MXC_I2C_CLK,
+       MXC_LCDC_CLK,
+       MXC_NFC_CLK,
+       MXC_OWIRE_CLK,
+       MXC_PWM_CLK,
+       MXC_SIM1_CLK,
+       MXC_SIM2_CLK,
+       MXC_SSI1_CLK,
+       MXC_SSI2_CLK,
+       MXC_UART_CLK,
+       MXC_ARM_CLK,
+       MXC_FEC_CLK,
+       MXC_CLK_NUM
+};
+
 ulong imx_get_perclk(int clk);
 ulong imx_get_ahbclk(void);
 
 #define imx_get_uartclk() imx_get_perclk(15)
 #define imx_get_fecclk() (imx_get_ahbclk()/2)
 
+unsigned int mxc_get_clock(enum mxc_clock clk);
 
 #endif /* __ASM_ARCH_CLOCK_H */