diff options
author | Andrew Victor <andrew@sanpeople.com> | 2006-06-19 10:23:41 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2006-06-19 10:23:41 -0400 |
commit | 963151f2471d0e6475d8b2d3a005417aec1766f7 (patch) | |
tree | 37602e1518fea1fea3243f7a527ea3c7deea3d34 /arch | |
parent | 91f8ed835ffb34b4108cc16eefd3303e4068bee0 (diff) |
[ARM] 3579/1: AT91RM9200 Timer simplification
Patch from Andrew Victor
Use a global variable 'last_crtr' to store the time of the last timer
tick instead of the ST_RTAR register.
It's faster, frees up the ST_RTAR register for other uses, and hopefully
makes the code more understandable. [Patch from Peter Menzebach]
Also add the SA_TIMER flag to Timer IRQ. (It seems to be required for
the realtime preempt patch).
Signed-off-by: Andrew Victor <andrew@sanpeople.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-at91rm9200/time.c | 13 |
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 | ||
34 | static 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 | */ |
67 | static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) | 69 | static 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 | ||
88 | static struct irqaction at91rm9200_timer_irq = { | 87 | static 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 | ||