aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-at91rm9200/time.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/arch/arm/mach-at91rm9200/time.c b/arch/arm/mach-at91rm9200/time.c
index 7ffcf443b99f..36798a8d532a 100644
--- a/arch/arm/mach-at91rm9200/time.c
+++ b/arch/arm/mach-at91rm9200/time.c
@@ -31,6 +31,8 @@
31#include <asm/irq.h> 31#include <asm/irq.h>
32#include <asm/mach/time.h> 32#include <asm/mach/time.h>
33 33
34static unsigned long last_crtr;
35
34/* 36/*
35 * The ST_CRTR is updated asynchronously to the master clock. It is therefore 37 * The ST_CRTR is updated asynchronously to the master clock. It is therefore
36 * necessary to read it twice (with the same value) to ensure accuracy. 38 * necessary to read it twice (with the same value) to ensure accuracy.
@@ -56,7 +58,7 @@ static unsigned long at91rm9200_gettimeoffset(void)
56{ 58{
57 unsigned long elapsed; 59 unsigned long elapsed;
58 60
59 elapsed = (read_CRTR() - at91_sys_read(AT91_ST_RTAR)) & AT91_ST_ALMV; 61 elapsed = (read_CRTR() - last_crtr) & AT91_ST_ALMV;
60 62
61 return (unsigned long)(elapsed * (tick_nsec / 1000)) / LATCH; 63 return (unsigned long)(elapsed * (tick_nsec / 1000)) / LATCH;
62} 64}
@@ -66,15 +68,12 @@ static unsigned long at91rm9200_gettimeoffset(void)
66 */ 68 */
67static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) 69static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
68{ 70{
69 unsigned long rtar;
70
71 if (at91_sys_read(AT91_ST_SR) & AT91_ST_PITS) { /* This is a shared interrupt */ 71 if (at91_sys_read(AT91_ST_SR) & AT91_ST_PITS) { /* This is a shared interrupt */
72 write_seqlock(&xtime_lock); 72 write_seqlock(&xtime_lock);
73 73
74 while (((read_CRTR() - at91_sys_read(AT91_ST_RTAR)) & AT91_ST_ALMV) >= LATCH) { 74 while (((read_CRTR() - last_crtr) & AT91_ST_ALMV) >= LATCH) {
75 timer_tick(regs); 75 timer_tick(regs);
76 rtar = (at91_sys_read(AT91_ST_RTAR) + LATCH) & AT91_ST_ALMV; 76 last_crtr = (last_crtr + LATCH) & AT91_ST_ALMV;
77 at91_sys_write(AT91_ST_RTAR, rtar);
78 } 77 }
79 78
80 write_sequnlock(&xtime_lock); 79 write_sequnlock(&xtime_lock);
@@ -87,7 +86,7 @@ static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id, struct pt_r
87 86
88static struct irqaction at91rm9200_timer_irq = { 87static struct irqaction at91rm9200_timer_irq = {
89 .name = "at91_tick", 88 .name = "at91_tick",
90 .flags = SA_SHIRQ | SA_INTERRUPT, 89 .flags = SA_SHIRQ | SA_INTERRUPT | SA_TIMER,
91 .handler = at91rm9200_timer_interrupt 90 .handler = at91rm9200_timer_interrupt
92}; 91};
93 92