]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/plat-omap/common.c
ARM: OMAP: Timer32K: Move 32k-based sched_clock() to common code
[linux-2.6-omap-h63xx.git] / arch / arm / plat-omap / common.c
index dd8708ad0a71833339c5e3abc23cf4711604275c..7f1cae16cfad66a95808690e434c6a10ef0a921f 100644 (file)
@@ -73,7 +73,7 @@ static const void *get_config(u16 tag, size_t len, int skip, size_t *len_out)
        }
        if (info != NULL) {
                /* Check the length as a lame attempt to check for
-                * binary inconsistancy. */
+                * binary inconsistency. */
                if (len != NO_LENGTH_CHECK) {
                        /* Word-align len */
                        if (len & 0x03)
@@ -172,7 +172,7 @@ console_initcall(omap_add_serial_console);
 #if defined(CONFIG_ARCH_OMAP16XX)
 #define TIMER_32K_SYNCHRONIZED         0xfffbc410
 #elif defined(CONFIG_ARCH_OMAP24XX)
-#define TIMER_32K_SYNCHRONIZED         0x48004010
+#define TIMER_32K_SYNCHRONIZED         (OMAP24XX_32KSYNCT_BASE + 0x10)
 #endif
 
 #ifdef TIMER_32K_SYNCHRONIZED
@@ -193,6 +193,23 @@ static struct clocksource clocksource_32k = {
        .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
+/*
+ * Rounds down to nearest nsec.
+ */
+unsigned long long omap_32k_ticks_to_nsecs(unsigned long ticks_32k)
+{
+       return cyc2ns(&clocksource_32k, ticks_32k);
+}
+
+/*
+ * Returns current time from boot in nsecs. It's OK for this to wrap
+ * around for now, as it's just a relative time stamp.
+ */
+unsigned long long sched_clock(void)
+{
+       return omap_32k_ticks_to_nsecs(omap_32k_read());
+}
+
 static int __init omap_init_clocksource_32k(void)
 {
        static char err[] __initdata = KERN_ERR