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.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/arch/arm/mach-sa1100/time.c b/arch/arm/mach-sa1100/time.c
index fdf7b016e7ad..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;
@@ -62,8 +46,6 @@ sa1100_timer_interrupt(int irq, void *dev_id)
62{ 46{
63 unsigned int next_match; 47 unsigned int next_match;
64 48
65 write_seqlock(&xtime_lock);
66
67#ifdef CONFIG_NO_IDLE_HZ 49#ifdef CONFIG_NO_IDLE_HZ
68 if (match_posponed) { 50 if (match_posponed) {
69 match_posponed = 0; 51 match_posponed = 0;
@@ -85,8 +67,6 @@ sa1100_timer_interrupt(int irq, void *dev_id)
85 next_match = (OSMR0 += LATCH); 67 next_match = (OSMR0 += LATCH);
86 } while ((signed long)(next_match - OSCR) <= 0); 68 } while ((signed long)(next_match - OSCR) <= 0);
87 69
88 write_sequnlock(&xtime_lock);
89
90 return IRQ_HANDLED; 70 return IRQ_HANDLED;
91} 71}
92 72
@@ -96,6 +76,20 @@ static struct irqaction sa1100_timer_irq = {
96 .handler = sa1100_timer_interrupt, 76 .handler = sa1100_timer_interrupt,
97}; 77};
98 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
99static void __init sa1100_timer_init(void) 93static void __init sa1100_timer_init(void)
100{ 94{
101 unsigned long flags; 95 unsigned long flags;
@@ -109,6 +103,11 @@ static void __init sa1100_timer_init(void)
109 OIER = OIER_E0; /* enable match on timer 0 to cause interrupts */ 103 OIER = OIER_E0; /* enable match on timer 0 to cause interrupts */
110 OSMR0 = OSCR + LATCH; /* set initial match */ 104 OSMR0 = OSCR + LATCH; /* set initial match */
111 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);
112} 111}
113 112
114#ifdef CONFIG_NO_IDLE_HZ 113#ifdef CONFIG_NO_IDLE_HZ
@@ -182,7 +181,6 @@ struct sys_timer sa1100_timer = {
182 .init = sa1100_timer_init, 181 .init = sa1100_timer_init,
183 .suspend = sa1100_timer_suspend, 182 .suspend = sa1100_timer_suspend,
184 .resume = sa1100_timer_resume, 183 .resume = sa1100_timer_resume,
185 .offset = sa1100_gettimeoffset,
186#ifdef CONFIG_NO_IDLE_HZ 184#ifdef CONFIG_NO_IDLE_HZ
187 .dyn_tick = &sa1100_dyn_tick, 185 .dyn_tick = &sa1100_dyn_tick,
188#endif 186#endif