aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68knommu
diff options
context:
space:
mode:
Diffstat (limited to 'arch/m68knommu')
-rw-r--r--arch/m68knommu/platform/5307/timers.c10
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)
62 62
63/***************************************************************************/ 63/***************************************************************************/
64 64
65static int ticks_per_intr;
66
65void coldfire_timer_init(irq_handler_t handler) 67void coldfire_timer_init(irq_handler_t handler)
66{ 68{
67 __raw_writew(MCFTIMER_TMR_DISABLE, TA(MCFTIMER_TMR)); 69 __raw_writew(MCFTIMER_TMR_DISABLE, TA(MCFTIMER_TMR));
68 __raw_writetrr(((MCF_BUSCLK / 16) / HZ), TA(MCFTIMER_TRR)); 70 ticks_per_intr = (MCF_BUSCLK / 16) / HZ;
71 __raw_writetrr(ticks_per_intr - 1, TA(MCFTIMER_TRR));
69 __raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 | 72 __raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 |
70 MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, TA(MCFTIMER_TMR)); 73 MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, TA(MCFTIMER_TMR));
71 74
@@ -81,11 +84,10 @@ void coldfire_timer_init(irq_handler_t handler)
81 84
82unsigned long coldfire_timer_offset(void) 85unsigned long coldfire_timer_offset(void)
83{ 86{
84 unsigned long trr, tcn, offset; 87 unsigned long tcn, offset;
85 88
86 tcn = __raw_readw(TA(MCFTIMER_TCN)); 89 tcn = __raw_readw(TA(MCFTIMER_TCN));
87 trr = __raw_readtrr(TA(MCFTIMER_TRR)); 90 offset = ((tcn + 1) * (1000000 / HZ)) / ticks_per_intr;
88 offset = (tcn * (1000000 / HZ)) / trr;
89 91
90 /* Check if we just wrapped the counters and maybe missed a tick */ 92 /* Check if we just wrapped the counters and maybe missed a tick */
91 if ((offset < (1000000 / HZ / 2)) && mcf_timerirqpending(1)) 93 if ((offset < (1000000 / HZ / 2)) && mcf_timerirqpending(1))