]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/kernel/time.c
[ARM] 3855/1: Add generic time support
[linux-2.6-omap-h63xx.git] / arch / arm / kernel / time.c
index d7d932c02866d51336414ecf44f3c98c935abedd..d4dceb5f06e94181b0300fbd3a1375f6a573194d 100644 (file)
@@ -16,7 +16,6 @@
  *  1998-12-20  Updated NTP code according to technical memorandum Jan '96
  *              "A Kernel Model for Precision Timekeeping" by Dave Mills
  */
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/interrupt.h>
@@ -70,10 +69,12 @@ EXPORT_SYMBOL(profile_pc);
  */
 int (*set_rtc)(void);
 
+#ifndef CONFIG_GENERIC_TIME
 static unsigned long dummy_gettimeoffset(void)
 {
        return 0;
 }
+#endif
 
 /*
  * Scheduler clock - returns current time in nanosec units.
@@ -231,6 +232,7 @@ static inline void do_leds(void)
 #define        do_leds()
 #endif
 
+#ifndef CONFIG_GENERIC_TIME
 void do_gettimeofday(struct timeval *tv)
 {
        unsigned long flags;
@@ -292,6 +294,7 @@ int do_settimeofday(struct timespec *tv)
 }
 
 EXPORT_SYMBOL(do_settimeofday);
+#endif /* !CONFIG_GENERIC_TIME */
 
 /**
  * save_time_delta - Save the offset between system time and RTC time
@@ -379,7 +382,7 @@ static int timer_dyn_tick_enable(void)
        int ret = -ENODEV;
 
        if (dyn_tick) {
-               write_seqlock_irqsave(&xtime_lock, flags);
+               spin_lock_irqsave(&dyn_tick->lock, flags);
                ret = 0;
                if (!(dyn_tick->state & DYN_TICK_ENABLED)) {
                        ret = dyn_tick->enable();
@@ -387,7 +390,7 @@ static int timer_dyn_tick_enable(void)
                        if (ret == 0)
                                dyn_tick->state |= DYN_TICK_ENABLED;
                }
-               write_sequnlock_irqrestore(&xtime_lock, flags);
+               spin_unlock_irqrestore(&dyn_tick->lock, flags);
        }
 
        return ret;
@@ -400,7 +403,7 @@ static int timer_dyn_tick_disable(void)
        int ret = -ENODEV;
 
        if (dyn_tick) {
-               write_seqlock_irqsave(&xtime_lock, flags);
+               spin_lock_irqsave(&dyn_tick->lock, flags);
                ret = 0;
                if (dyn_tick->state & DYN_TICK_ENABLED) {
                        ret = dyn_tick->disable();
@@ -408,7 +411,7 @@ static int timer_dyn_tick_disable(void)
                        if (ret == 0)
                                dyn_tick->state &= ~DYN_TICK_ENABLED;
                }
-               write_sequnlock_irqrestore(&xtime_lock, flags);
+               spin_unlock_irqrestore(&dyn_tick->lock, flags);
        }
 
        return ret;
@@ -422,13 +425,20 @@ static int timer_dyn_tick_disable(void)
 void timer_dyn_reprogram(void)
 {
        struct dyn_tick_timer *dyn_tick = system_timer->dyn_tick;
+       unsigned long next, seq, flags;
 
-       if (dyn_tick) {
-               write_seqlock(&xtime_lock);
-               if (dyn_tick->state & DYN_TICK_ENABLED)
-                       dyn_tick->reprogram(next_timer_interrupt() - jiffies);
-               write_sequnlock(&xtime_lock);
+       if (!dyn_tick)
+               return;
+
+       spin_lock_irqsave(&dyn_tick->lock, flags);
+       if (dyn_tick->state & DYN_TICK_ENABLED) {
+               next = next_timer_interrupt();
+               do {
+                       seq = read_seqbegin(&xtime_lock);
+                       dyn_tick->reprogram(next - jiffies);
+               } while (read_seqretry(&xtime_lock, seq));
        }
+       spin_unlock_irqrestore(&dyn_tick->lock, flags);
 }
 
 static ssize_t timer_show_dyn_tick(struct sys_device *dev, char *buf)
@@ -494,8 +504,15 @@ device_initcall(timer_init_sysfs);
 
 void __init time_init(void)
 {
+#ifndef CONFIG_GENERIC_TIME
        if (system_timer->offset == NULL)
                system_timer->offset = dummy_gettimeoffset;
+#endif
        system_timer->init();
+
+#ifdef CONFIG_NO_IDLE_HZ
+       if (system_timer->dyn_tick)
+               system_timer->dyn_tick->lock = SPIN_LOCK_UNLOCKED;
+#endif
 }