diff options
author | Imre Deak <imre.deak@solidboot.com> | 2006-09-25 05:41:21 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2006-09-25 05:41:21 -0400 |
commit | df51a84d93e776b7481d937ccd60be1b27d320c5 (patch) | |
tree | e94a6327eff576dac2ea84cae1e7e3ebda0f0cfe /arch/arm | |
parent | ae78dcf79aefa98a1ed245898467eb6d3bfc11e6 (diff) |
ARM: OMAP: timer32k: fix tick count calculation when reprogramming
Reprogramming takes places before putting the CPU into idle mode if
the dynamic tick option is enabled. The timer is then set to expire
at the next pending timer event. Because some time has already passed
since the last reported jiffy we have to wait less than the time
specified in jiffies.
Also make sure we don't set a load value of 0 whose outcome is
unspecified according to the TRM.
Signed-off-by: Imre Deak <imre.deak@solidboot.com>
Signed-off-by: Juha Yrjola <juha.yrjola@solidboot.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/plat-omap/timer32k.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/arch/arm/plat-omap/timer32k.c b/arch/arm/plat-omap/timer32k.c index 281ecc7fcdfc..f7b4e89de518 100644 --- a/arch/arm/plat-omap/timer32k.c +++ b/arch/arm/plat-omap/timer32k.c | |||
@@ -105,6 +105,8 @@ static inline unsigned long omap_32k_timer_read(int reg) | |||
105 | 105 | ||
106 | static inline void omap_32k_timer_start(unsigned long load_val) | 106 | static inline void omap_32k_timer_start(unsigned long load_val) |
107 | { | 107 | { |
108 | if (!load_val) | ||
109 | load_val = 1; | ||
108 | omap_32k_timer_write(load_val, OMAP1_32K_TIMER_TVR); | 110 | omap_32k_timer_write(load_val, OMAP1_32K_TIMER_TVR); |
109 | omap_32k_timer_write(0x0f, OMAP1_32K_TIMER_CR); | 111 | omap_32k_timer_write(0x0f, OMAP1_32K_TIMER_CR); |
110 | } | 112 | } |
@@ -230,7 +232,15 @@ static irqreturn_t omap_32k_timer_interrupt(int irq, void *dev_id, | |||
230 | */ | 232 | */ |
231 | void omap_32k_timer_reprogram(unsigned long next_tick) | 233 | void omap_32k_timer_reprogram(unsigned long next_tick) |
232 | { | 234 | { |
233 | omap_32k_timer_start(JIFFIES_TO_HW_TICKS(next_tick, 32768) + 1); | 235 | unsigned long ticks = JIFFIES_TO_HW_TICKS(next_tick, 32768) + 1; |
236 | unsigned long now = omap_32k_sync_timer_read(); | ||
237 | unsigned long idled = now - omap_32k_last_tick; | ||
238 | |||
239 | if (idled + 1 < ticks) | ||
240 | ticks -= idled; | ||
241 | else | ||
242 | ticks = 1; | ||
243 | omap_32k_timer_start(ticks); | ||
234 | } | 244 | } |
235 | 245 | ||
236 | static struct irqaction omap_32k_timer_irq; | 246 | static struct irqaction omap_32k_timer_irq; |