]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/sh/kernel/time_32.c
sh: Add support for SH7786 CPU subtype.
[linux-2.6-omap-h63xx.git] / arch / sh / kernel / time_32.c
index 23ca711c27d2af9e6e15106a17bcdb8e92bea47c..c34e1e0f9b025072e8fb056d727a61e652656193 100644 (file)
@@ -41,14 +41,6 @@ static int null_rtc_set_time(const time_t secs)
        return 0;
 }
 
-/*
- * Null high precision timer functions for systems lacking one.
- */
-static cycle_t null_hpt_read(void)
-{
-       return 0;
-}
-
 void (*rtc_sh_get_time)(struct timespec *) = null_rtc_get_time;
 int (*rtc_sh_set_time)(const time_t) = null_rtc_set_time;
 
@@ -112,7 +104,6 @@ int do_settimeofday(struct timespec *tv)
 EXPORT_SYMBOL(do_settimeofday);
 #endif /* !CONFIG_GENERIC_TIME */
 
-#ifndef CONFIG_GENERIC_CLOCKEVENTS
 /* last time the RTC clock got updated */
 static long last_rtc_update;
 
@@ -125,11 +116,6 @@ void handle_timer_tick(void)
        if (current->pid)
                profile_tick(CPU_PROFILING);
 
-#ifdef CONFIG_HEARTBEAT
-       if (sh_mv.mv_heartbeat != NULL)
-               sh_mv.mv_heartbeat();
-#endif
-
        /*
         * Here we are in the timer irq handler. We just have irqs locally
         * disabled but we don't know if the timer_bh is running on the other
@@ -161,7 +147,6 @@ void handle_timer_tick(void)
        update_process_times(user_mode(get_irq_regs()));
 #endif
 }
-#endif /* !CONFIG_GENERIC_CLOCKEVENTS */
 
 #ifdef CONFIG_PM
 int timer_suspend(struct sys_device *dev, pm_message_t state)
@@ -194,7 +179,12 @@ static struct sysdev_class timer_sysclass = {
 
 static int __init timer_init_sysfs(void)
 {
-       int ret = sysdev_class_register(&timer_sysclass);
+       int ret;
+
+       if (!sys_timer)
+               return 0;
+
+       ret = sysdev_class_register(&timer_sysclass);
        if (ret != 0)
                return ret;
 
@@ -205,42 +195,21 @@ device_initcall(timer_init_sysfs);
 
 void (*board_time_init)(void);
 
-/*
- * Shamelessly based on the MIPS and Sparc64 work.
- */
-static unsigned long timer_ticks_per_nsec_quotient __read_mostly;
-unsigned long sh_hpt_frequency = 0;
-
-#define NSEC_PER_CYC_SHIFT     10
-
-static struct clocksource clocksource_sh = {
+struct clocksource clocksource_sh = {
        .name           = "SuperH",
-       .rating         = 200,
-       .mask           = CLOCKSOURCE_MASK(32),
-       .read           = null_hpt_read,
-       .shift          = 16,
-       .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
-static void __init init_sh_clocksource(void)
-{
-       if (!sh_hpt_frequency || clocksource_sh.read == null_hpt_read)
-               return;
-
-       clocksource_sh.mult = clocksource_hz2mult(sh_hpt_frequency,
-                                                 clocksource_sh.shift);
-
-       timer_ticks_per_nsec_quotient =
-               clocksource_hz2mult(sh_hpt_frequency, NSEC_PER_CYC_SHIFT);
-
-       clocksource_register(&clocksource_sh);
-}
-
 #ifdef CONFIG_GENERIC_TIME
 unsigned long long sched_clock(void)
 {
-       unsigned long long ticks = clocksource_sh.read();
-       return (ticks * timer_ticks_per_nsec_quotient) >> NSEC_PER_CYC_SHIFT;
+       unsigned long long cycles;
+
+       /* jiffies based sched_clock if no clocksource is installed */
+       if (!clocksource_sh.rating)
+               return (unsigned long long)jiffies * (NSEC_PER_SEC / HZ);
+
+       cycles = clocksource_sh.read();
+       return cyc2ns(&clocksource_sh, cycles);
 }
 #endif
 
@@ -264,24 +233,8 @@ void __init time_init(void)
         * initialized for us.
         */
        sys_timer = get_sys_timer();
-       printk(KERN_INFO "Using %s for system timer\n", sys_timer->name);
-
+       if (unlikely(!sys_timer))
+               panic("System timer missing.\n");
 
-       if (sys_timer->ops->read)
-               clocksource_sh.read = sys_timer->ops->read;
-
-       init_sh_clocksource();
-
-       if (sh_hpt_frequency)
-               printk("Using %lu.%03lu MHz high precision timer.\n",
-                      ((sh_hpt_frequency + 500) / 1000) / 1000,
-                      ((sh_hpt_frequency + 500) / 1000) % 1000);
-
-#if defined(CONFIG_SH_KGDB)
-       /*
-        * Set up kgdb as requested. We do it here because the serial
-        * init uses the timer vars we just set up for figuring baud.
-        */
-       kgdb_init();
-#endif
+       printk(KERN_INFO "Using %s for system timer\n", sys_timer->name);
 }