aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-sa1100/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-sa1100/time.c')
-rw-r--r--arch/arm/mach-sa1100/time.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/arch/arm/mach-sa1100/time.c b/arch/arm/mach-sa1100/time.c
index 47f8640438e6..c2677368d6af 100644
--- a/arch/arm/mach-sa1100/time.c
+++ b/arch/arm/mach-sa1100/time.c
@@ -14,6 +14,7 @@
14#include <linux/irq.h> 14#include <linux/irq.h>
15#include <linux/timex.h> 15#include <linux/timex.h>
16#include <linux/signal.h> 16#include <linux/signal.h>
17#include <linux/clocksource.h>
17 18
18#include <asm/mach/time.h> 19#include <asm/mach/time.h>
19#include <asm/hardware.h> 20#include <asm/hardware.h>
@@ -35,23 +36,6 @@ static int sa1100_set_rtc(void)
35 return 0; 36 return 0;
36} 37}
37 38
38/* IRQs are disabled before entering here from do_gettimeofday() */
39static unsigned long sa1100_gettimeoffset (void)
40{
41 unsigned long ticks_to_match, elapsed, usec;
42
43 /* Get ticks before next timer match */
44 ticks_to_match = OSMR0 - OSCR;
45
46 /* We need elapsed ticks since last match */
47 elapsed = LATCH - ticks_to_match;
48
49 /* Now convert them to usec */
50 usec = (unsigned long)(elapsed * (tick_nsec / 1000))/LATCH;
51
52 return usec;
53}
54
55#ifdef CONFIG_NO_IDLE_HZ 39#ifdef CONFIG_NO_IDLE_HZ
56static unsigned long initial_match; 40static unsigned long initial_match;
57static int match_posponed; 41static int match_posponed;
@@ -92,6 +76,20 @@ static struct irqaction sa1100_timer_irq = {
92 .handler = sa1100_timer_interrupt, 76 .handler = sa1100_timer_interrupt,
93}; 77};
94 78
79static cycle_t sa1100_read_oscr(void)
80{
81 return OSCR;
82}
83
84static struct clocksource cksrc_sa1100_oscr = {
85 .name = "oscr",
86 .rating = 200,
87 .read = sa1100_read_oscr,
88 .mask = CLOCKSOURCE_MASK(32),
89 .shift = 20,
90 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
91};
92
95static void __init sa1100_timer_init(void) 93static void __init sa1100_timer_init(void)
96{ 94{
97 unsigned long flags; 95 unsigned long flags;
@@ -105,6 +103,11 @@ static void __init sa1100_timer_init(void)
105 OIER = OIER_E0; /* enable match on timer 0 to cause interrupts */ 103 OIER = OIER_E0; /* enable match on timer 0 to cause interrupts */
106 OSMR0 = OSCR + LATCH; /* set initial match */ 104 OSMR0 = OSCR + LATCH; /* set initial match */
107 local_irq_restore(flags); 105 local_irq_restore(flags);
106
107 cksrc_sa1100_oscr.mult =
108 clocksource_hz2mult(CLOCK_TICK_RATE, cksrc_sa1100_oscr.shift);
109
110 clocksource_register(&cksrc_sa1100_oscr);
108} 111}
109 112
110#ifdef CONFIG_NO_IDLE_HZ 113#ifdef CONFIG_NO_IDLE_HZ
@@ -178,7 +181,6 @@ struct sys_timer sa1100_timer = {
178 .init = sa1100_timer_init, 181 .init = sa1100_timer_init,
179 .suspend = sa1100_timer_suspend, 182 .suspend = sa1100_timer_suspend,
180 .resume = sa1100_timer_resume, 183 .resume = sa1100_timer_resume,
181 .offset = sa1100_gettimeoffset,
182#ifdef CONFIG_NO_IDLE_HZ 184#ifdef CONFIG_NO_IDLE_HZ
183 .dyn_tick = &sa1100_dyn_tick, 185 .dyn_tick = &sa1100_dyn_tick,
184#endif 186#endif