[PATCH] ARM omap: add omap4_get_sysclk()
Christoph Fritz
chf.fritz at googlemail.com
Thu Apr 4 02:42:35 EDT 2013
This patch adds a function to get actual system clock.
Signed-off-by: Christoph Fritz <chf.fritz at googlemail.com>
---
arch/arm/mach-omap/include/mach/omap4-clock.h | 4 ++++
arch/arm/mach-omap/omap4_clock.c | 19 +++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/arch/arm/mach-omap/include/mach/omap4-clock.h b/arch/arm/mach-omap/include/mach/omap4-clock.h
index 8f49aa3..9e53e16 100644
--- a/arch/arm/mach-omap/include/mach/omap4-clock.h
+++ b/arch/arm/mach-omap/include/mach/omap4-clock.h
@@ -4,7 +4,10 @@
/* PRCM */
#define CM_SYS_CLKSEL 0x4a306110
+#define CM_SYS_CLKSEL_12M 0x1
+#define CM_SYS_CLKSEL_16M8 0x3
#define CM_SYS_CLKSEL_19M2 0x4
+#define CM_SYS_CLKSEL_26M 0x5
#define CM_SYS_CLKSEL_38M4 0x7
/* PRM.CKGEN module registers */
@@ -341,5 +344,6 @@ void omap4_enable_gpio1_wup_clocks(void);
void omap4_enable_gpio_clocks(void);
void omap4_enable_all_clocks(void);
void omap4_do_scale_tps62361(u32 reg, u32 volt_mv);
+int omap4_get_sysclk(void);
#endif /* __MACH_OMAP4_CLOCK_H */
diff --git a/arch/arm/mach-omap/omap4_clock.c b/arch/arm/mach-omap/omap4_clock.c
index 889d1f9..37af756 100644
--- a/arch/arm/mach-omap/omap4_clock.c
+++ b/arch/arm/mach-omap/omap4_clock.c
@@ -413,3 +413,22 @@ void omap4_do_scale_tps62361(u32 reg, u32 volt_mv)
OMAP44XX_PRM_VC_VAL_BYPASS, LDELAY))
debug("Scaling voltage failed for vdd_mpu from TPS\n");
}
+
+int omap4_get_sysclk(void)
+{
+ int omap4_cm_sys_clks[] = {
+ -1,
+ 12000000, /* CM_SYS_CLKSEL_12M */
+ -1,
+ 16800000, /* CM_SYS_CLKSEL_16M8 */
+ 19200000, /* CM_SYS_CLKSEL_19M2 */
+ 26000000, /* CM_SYS_CLKSEL_26M */
+ -1,
+ 38400000, /* CM_SYS_CLKSEL_38M4 */
+ };
+ int v = __raw_readl(CM_SYS_CLKSEL);
+
+ if (v >= ARRAY_SIZE(omap4_cm_sys_clks))
+ return -1;
+ return omap4_cm_sys_clks[v];
+}
--
1.7.10.4
More information about the barebox
mailing list