summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/imx233/timrot-imx233.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-02-10 22:26:19 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2014-02-10 23:14:26 +0100
commit34fb6906dd645688870ff137a3d94cb58abca120 (patch)
tree7bd8f170a4f29161456bb24a5b64e7f9d5007daa /firmware/target/arm/imx233/timrot-imx233.c
parent619f7fba939064c0728ef50c72474ccb4898df3a (diff)
downloadrockbox-34fb6906dd645688870ff137a3d94cb58abca120.tar.gz
rockbox-34fb6906dd645688870ff137a3d94cb58abca120.tar.bz2
rockbox-34fb6906dd645688870ff137a3d94cb58abca120.zip
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
Diffstat (limited to 'firmware/target/arm/imx233/timrot-imx233.c')
-rw-r--r--firmware/target/arm/imx233/timrot-imx233.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/firmware/target/arm/imx233/timrot-imx233.c b/firmware/target/arm/imx233/timrot-imx233.c
index 0ba86c755d..22f9853051 100644
--- a/firmware/target/arm/imx233/timrot-imx233.c
+++ b/firmware/target/arm/imx233/timrot-imx233.c
@@ -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),
+ /* 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), UPDATE(1));
+ IRQ_EN(irq));
imx233_icoll_enable_interrupt(INT_SRC_TIMER(timer_nr), irq);
- HW_TIMROT_TIMCOUNTn(timer_nr) = reload ? count - 1 : count;
restore_interrupt(oldstatus);
}