]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
imx-common: Factor out get_ahb_clk()
authorFabio Estevam <festevam@gmail.com>
Sun, 29 Apr 2012 08:11:13 +0000 (08:11 +0000)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Tue, 15 May 2012 06:31:32 +0000 (08:31 +0200)
get_ahb_clk() is a common function between mx5 and mx6.

Place it into imx-common directory.

Cc: Dirk Behme <dirk.behme@googlemail.com>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
arch/arm/cpu/armv7/imx-common/cpu.c
arch/arm/cpu/armv7/mx5/clock.c
arch/arm/cpu/armv7/mx6/clock.c
arch/arm/include/asm/arch-mx5/sys_proto.h
arch/arm/include/asm/arch-mx6/crm_regs.h [moved from arch/arm/include/asm/arch-mx6/ccm_regs.h with 99% similarity]
arch/arm/include/asm/arch-mx6/sys_proto.h

index 3d58d8ae9160c7f0ff2e0fceeb03d7a80aeab537..b96fa5bdb96ff945306da36e8a416c1d3e48dd38 100644 (file)
@@ -29,6 +29,7 @@
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/sys_proto.h>
+#include <asm/arch/crm_regs.h>
 
 #ifdef CONFIG_FSL_ESDHC
 #include <fsl_esdhc.h>
@@ -127,3 +128,15 @@ void reset_cpu(ulong addr)
 {
        __raw_writew(4, WDOG1_BASE_ADDR);
 }
+
+u32 get_ahb_clk(void)
+{
+       struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
+       u32 reg, ahb_podf;
+
+       reg = __raw_readl(&imx_ccm->cbcdr);
+       reg &= MXC_CCM_CBCDR_AHB_PODF_MASK;
+       ahb_podf = reg >> MXC_CCM_CBCDR_AHB_PODF_OFFSET;
+
+       return get_periph_clk() / (ahb_podf + 1);
+}
index d769a4d7724bcc820f5610d0e12908665c01b14d..903e20776213b6ac5a6d04c46ad0e7596c96d178 100644 (file)
@@ -30,6 +30,7 @@
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/clock.h>
 #include <div64.h>
+#include <asm/arch/sys_proto.h>
 
 enum pll_clocks {
        PLL1_CLOCK = 0,
@@ -192,7 +193,7 @@ u32 get_mcu_main_clk(void)
 /*
  * Get the rate of peripheral's root clock.
  */
-static u32 get_periph_clk(void)
+u32 get_periph_clk(void)
 {
        u32 reg;
 
@@ -212,22 +213,6 @@ static u32 get_periph_clk(void)
        /* NOTREACHED */
 }
 
-/*
- * Get the rate of ahb clock.
- */
-static u32 get_ahb_clk(void)
-{
-       uint32_t freq, div, reg;
-
-       freq = get_periph_clk();
-
-       reg = __raw_readl(&mxc_ccm->cbcdr);
-       div = ((reg & MXC_CCM_CBCDR_AHB_PODF_MASK) >>
-                       MXC_CCM_CBCDR_AHB_PODF_OFFSET) + 1;
-
-       return freq / div;
-}
-
 /*
  * Get the rate of ipg clock.
  */
index ef98563ff7639a3895e5dc00acd9cc30bb3c6772..0f05432941750427e7bb9448b3e7185981f07d55 100644 (file)
@@ -24,8 +24,9 @@
 #include <asm/io.h>
 #include <asm/errno.h>
 #include <asm/arch/imx-regs.h>
-#include <asm/arch/ccm_regs.h>
+#include <asm/arch/crm_regs.h>
 #include <asm/arch/clock.h>
+#include <asm/arch/sys_proto.h>
 
 enum pll_clocks {
        PLL_SYS,        /* System PLL */
@@ -34,7 +35,7 @@ enum pll_clocks {
        PLL_ENET,       /* ENET PLL */
 };
 
-struct imx_ccm_reg *imx_ccm = (struct imx_ccm_reg *)CCM_BASE_ADDR;
+struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
 
 void enable_usboh3_clk(unsigned char enable)
 {
@@ -92,7 +93,7 @@ static u32 get_mcu_main_clk(void)
        return freq / (reg + 1);
 }
 
-static u32 get_periph_clk(void)
+u32 get_periph_clk(void)
 {
        u32 reg, freq = 0;
 
@@ -139,18 +140,6 @@ static u32 get_periph_clk(void)
        return freq;
 }
 
-
-static u32 get_ahb_clk(void)
-{
-       u32 reg, ahb_podf;
-
-       reg = __raw_readl(&imx_ccm->cbcdr);
-       reg &= MXC_CCM_CBCDR_AHB_PODF_MASK;
-       ahb_podf = reg >> MXC_CCM_CBCDR_AHB_PODF_OFFSET;
-
-       return get_periph_clk() / (ahb_podf + 1);
-}
-
 static u32 get_ipg_clk(void)
 {
        u32 reg, ipg_podf;
index 13d12ee1a445dbb76dc4d1494f338bd854e8b6e3..3f10d2914cb6d66867d14c30697206d4e33ddfb7 100644 (file)
@@ -35,5 +35,7 @@ void set_chipselect_size(int const);
  */
 
 int fecmxc_initialize(bd_t *bis);
+u32 get_ahb_clk(void);
+u32 get_periph_clk(void);
 
 #endif
similarity index 99%
rename from arch/arm/include/asm/arch-mx6/ccm_regs.h
rename to arch/arm/include/asm/arch-mx6/crm_regs.h
index 4af0b901642ba09d43e466d258c379b5c88e7ebe..0e605c26f5923edb34197536e116bf79e6d38159 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef __ARCH_ARM_MACH_MX6_CCM_REGS_H__
 #define __ARCH_ARM_MACH_MX6_CCM_REGS_H__
 
-struct imx_ccm_reg {
+struct mxc_ccm_reg {
        u32 ccr;        /* 0x0000 */
        u32 ccdr;
        u32 csr;
index 668e77af6ab09829b5c136e98740de858bc6f49b..69687a855e87bcea0b982c03d6303603d796c400 100644 (file)
@@ -34,5 +34,6 @@ u32 get_cpu_rev(void);
  */
 
 int fecmxc_initialize(bd_t *bis);
-
+u32 get_ahb_clk(void);
+u32 get_periph_clk(void);
 #endif