summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/imx233/timrot-imx233.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-02-02 04:15:27 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2014-02-10 23:14:23 +0100
commit4495913c289d34271197dce0dc5f6c45f5ea62e6 (patch)
treebab4b2e477bcc1fdb5876cbf1ab36165de6aee46 /firmware/target/arm/imx233/timrot-imx233.c
parentc1609b08892ec6878c6cc1ea20689145d23a51e6 (diff)
downloadrockbox-4495913c289d34271197dce0dc5f6c45f5ea62e6.tar.gz
rockbox-4495913c289d34271197dce0dc5f6c45f5ea62e6.tar.bz2
rockbox-4495913c289d34271197dce0dc5f6c45f5ea62e6.zip
imx233: clean timrot a bit
Change-Id: Ic803a6b5c93978cd3246e553579ac8a1ba35e191
Diffstat (limited to 'firmware/target/arm/imx233/timrot-imx233.c')
-rw-r--r--firmware/target/arm/imx233/timrot-imx233.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/firmware/target/arm/imx233/timrot-imx233.c b/firmware/target/arm/imx233/timrot-imx233.c
index 848f640b5c..14b9bdca7b 100644
--- a/firmware/target/arm/imx233/timrot-imx233.c
+++ b/firmware/target/arm/imx233/timrot-imx233.c
@@ -20,8 +20,9 @@
****************************************************************************/
#include "timrot-imx233.h"
#include "clkctrl-imx233.h"
+#include "string.h"
-imx233_timer_fn_t timer_fns[4];
+static imx233_timer_fn_t timer_fns[4];
#define define_timer_irq(nr) \
void INT_TIMER##nr(void) \
@@ -36,28 +37,37 @@ define_timer_irq(1)
define_timer_irq(2)
define_timer_irq(3)
-void imx233_setup_timer(unsigned timer_nr, bool reload, unsigned count,
+void imx233_timrot_setup(unsigned timer_nr, bool reload, unsigned count,
unsigned src, unsigned prescale, bool polarity, imx233_timer_fn_t fn)
{
int oldstatus = disable_interrupt_save(IRQ_FIQ_STATUS);
/* only enable interrupt if function is set */
bool irq = fn != NULL;
-
timer_fns[timer_nr] = fn;
- HW_TIMROT_TIMCTRLn(timer_nr) = BF_OR6(TIMROT_TIMCTRLn, SELECT(src),
- PRESCALE(prescale), POLARITY(polarity), RELOAD(reload), IRQ(irq),
- IRQ_EN(irq));
-
/* manual says count - 1 for reload timers */
- HW_TIMROT_TIMCOUNTn(timer_nr) = reload ? count - 1 : reload;
+ 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);
- /* finally update */
- BF_SETn(TIMROT_TIMCTRLn, timer_nr, UPDATE);
+ HW_TIMROT_TIMCOUNTn(timer_nr) = reload ? count - 1 : count;
restore_interrupt(oldstatus);
}
+struct imx233_timrot_info_t imx233_timrot_get_info(unsigned timer_nr)
+{
+ struct imx233_timrot_info_t info;
+ memset(&info, 0, sizeof(info));
+ info.src = BF_RDn(TIMROT_TIMCTRLn, timer_nr, SELECT);
+ info.prescale = BF_RDn(TIMROT_TIMCTRLn, timer_nr, PRESCALE);
+ info.reload = BF_RDn(TIMROT_TIMCTRLn, timer_nr, RELOAD);
+ info.polarity = BF_RDn(TIMROT_TIMCTRLn, timer_nr, POLARITY);
+ info.fixed_count = BF_RDn(TIMROT_TIMCOUNTn, timer_nr, FIXED_COUNT);
+ info.run_count = BF_RDn(TIMROT_TIMCOUNTn, timer_nr, RUNNING_COUNT);
+ return info;
+}
+
void imx233_timrot_init(void)
{
imx233_reset_block(&HW_TIMROT_ROTCTRL);