imx233: preventive fix of timrot

The old could trigger an immediate IRQ if for example the count was 0
when setting up the timer: since the count was updared *after* clearing the
IRQ, it could fire in between.

Change-Id: I0357b201655bc0e56425ffb249ca807525f30217
This commit is contained in:
Amaury Pouly 2014-02-10 22:26:19 +01:00
parent 619f7fba93
commit 34fb6906dd

View file

@ -45,12 +45,17 @@ void imx233_timrot_setup(unsigned timer_nr, bool reload, unsigned count,
bool irq = fn != NULL;
timer_fns[timer_nr] = fn;
/* manual says count - 1 for reload timers */
HW_TIMROT_TIMCTRLn(timer_nr) = BF_OR7(TIMROT_TIMCTRLn, SELECT(src),
PRESCALE(prescale), POLARITY(polarity), RELOAD(reload), IRQ(irq),
IRQ_EN(irq), UPDATE(1));
imx233_icoll_enable_interrupt(INT_SRC_TIMER(timer_nr), irq);
/* make sure we start from stop state */
HW_TIMROT_TIMCTRLn(timer_nr) = BF_OR2(TIMROT_TIMCTRLn,
SELECT(BV_TIMROT_TIMCTRLn_SELECT__NEVER_TICK), UPDATE(1));
/* write count and take effect immediately with UPDATE
* manual says count-1 for reload timers */
HW_TIMROT_TIMCOUNTn(timer_nr) = reload ? count - 1 : count;
/* start timer */
HW_TIMROT_TIMCTRLn(timer_nr) = BF_OR6(TIMROT_TIMCTRLn, SELECT(src),
PRESCALE(prescale), POLARITY(polarity), RELOAD(reload), IRQ(irq),
IRQ_EN(irq));
imx233_icoll_enable_interrupt(INT_SRC_TIMER(timer_nr), irq);
restore_interrupt(oldstatus);
}