diff options
author | Greg Ungerer <gerg@snapgear.com> | 2007-06-08 22:46:39 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-06-09 02:23:32 +0200 |
commit | 4342f4ace2335d4fa9fe52b4cceca979413470b2 (patch) | |
tree | bb535e947751c32311b266b638c6ae5302958d9b /arch/m68knommu | |
parent | update checkpatch.pl to version 0.03 (diff) | |
download | linux-4342f4ace2335d4fa9fe52b4cceca979413470b2.tar.xz linux-4342f4ace2335d4fa9fe52b4cceca979413470b2.zip |
m68knommu: fix ColdFire timer off by 1
The coldfire timer runs from 0 to TRR included, then 0 again and so on. It
counts thus actually TRR + 1 steps for 1 tick, not TRR. Fix that.
Signed-off-by: Philippe De Muyter <phdm@macqel.be>
Signed-off-by: Greg Ungerer <gerg@uclinux.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/m68knommu')
-rw-r--r-- | arch/m68knommu/platform/5307/timers.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/arch/m68knommu/platform/5307/timers.c b/arch/m68knommu/platform/5307/timers.c index 92e58070b016..fb66eadd5896 100644 --- a/arch/m68knommu/platform/5307/timers.c +++ b/arch/m68knommu/platform/5307/timers.c @@ -62,10 +62,13 @@ void coldfire_tick(void) /***************************************************************************/ +static int ticks_per_intr; + void coldfire_timer_init(irq_handler_t handler) { __raw_writew(MCFTIMER_TMR_DISABLE, TA(MCFTIMER_TMR)); - __raw_writetrr(((MCF_BUSCLK / 16) / HZ), TA(MCFTIMER_TRR)); + ticks_per_intr = (MCF_BUSCLK / 16) / HZ; + __raw_writetrr(ticks_per_intr - 1, TA(MCFTIMER_TRR)); __raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 | MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, TA(MCFTIMER_TMR)); @@ -81,11 +84,10 @@ void coldfire_timer_init(irq_handler_t handler) unsigned long coldfire_timer_offset(void) { - unsigned long trr, tcn, offset; + unsigned long tcn, offset; tcn = __raw_readw(TA(MCFTIMER_TCN)); - trr = __raw_readtrr(TA(MCFTIMER_TRR)); - offset = (tcn * (1000000 / HZ)) / trr; + offset = ((tcn + 1) * (1000000 / HZ)) / ticks_per_intr; /* Check if we just wrapped the counters and maybe missed a tick */ if ((offset < (1000000 / HZ / 2)) && mcf_timerirqpending(1)) |