summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-06-16 18:03:10 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-06-16 18:21:49 +0200
commit852a82b90a5b718538642ebcffa25a168c98b329 (patch)
tree2c22fa31dd714526fe79ebbe7e5c8b5c129b2102
parent96b1d02b057164d4e521d7e9aa50ee5e1223008a (diff)
downloadrockbox-852a82b90a5b718538642ebcffa25a168c98b329.tar.gz
rockbox-852a82b90a5b718538642ebcffa25a168c98b329.tar.bz2
rockbox-852a82b90a5b718538642ebcffa25a168c98b329.zip
imx233: rewrite timrot using new register headers
Change-Id: Ia6dc7ac7e1fdf471a518111f5593bd96bc3acfac
-rw-r--r--firmware/target/arm/imx233/kernel-imx233.c2
-rw-r--r--firmware/target/arm/imx233/timer-imx233.c6
-rw-r--r--firmware/target/arm/imx233/timrot-imx233.c39
-rw-r--r--firmware/target/arm/imx233/timrot-imx233.h25
4 files changed, 18 insertions, 54 deletions
diff --git a/firmware/target/arm/imx233/kernel-imx233.c b/firmware/target/arm/imx233/kernel-imx233.c
index 752db68149..b3760a4782 100644
--- a/firmware/target/arm/imx233/kernel-imx233.c
+++ b/firmware/target/arm/imx233/kernel-imx233.c
@@ -33,7 +33,7 @@ void tick_start(unsigned int interval_in_ms)
{
/* use the 1-kHz XTAL clock source */
imx233_setup_timer(TICK_TIMER_NR, true, interval_in_ms,
- HW_TIMROT_TIMCTRL__SELECT_1KHZ_XTAL, HW_TIMROT_TIMCTRL__PRESCALE_1,
+ BV_TIMROT_TIMCTRLn_SELECT__1KHZ_XTAL, BV_TIMROT_TIMCTRLn_PRESCALE__DIV_BY_1,
false, &tick_timer);
}
diff --git a/firmware/target/arm/imx233/timer-imx233.c b/firmware/target/arm/imx233/timer-imx233.c
index 4175dde95a..b3c3ad56e8 100644
--- a/firmware/target/arm/imx233/timer-imx233.c
+++ b/firmware/target/arm/imx233/timer-imx233.c
@@ -58,13 +58,13 @@ bool timer_set(long cycles, bool start)
bool timer_start(IF_COP_VOID(int core))
{
imx233_setup_timer(USER_TIMER_NR, true, timer_cycles,
- HW_TIMROT_TIMCTRL__SELECT_32KHZ_XTAL, HW_TIMROT_TIMCTRL__PRESCALE_1,
+ BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL, BV_TIMROT_TIMCTRLn_PRESCALE__DIV_BY_1,
false, &timer_fn);
return true;
}
void timer_stop(void)
{
- imx233_setup_timer(USER_TIMER_NR, false, 0, HW_TIMROT_TIMCTRL__SELECT_NEVER_TICK,
- HW_TIMROT_TIMCTRL__PRESCALE_1, false, NULL);
+ imx233_setup_timer(USER_TIMER_NR, false, 0, BV_TIMROT_TIMCTRLn_SELECT__NEVER_TICK,
+ BV_TIMROT_TIMCTRLn_PRESCALE__DIV_BY_1, false, NULL);
}
diff --git a/firmware/target/arm/imx233/timrot-imx233.c b/firmware/target/arm/imx233/timrot-imx233.c
index 327b1d16b1..723ecc31ab 100644
--- a/firmware/target/arm/imx233/timrot-imx233.c
+++ b/firmware/target/arm/imx233/timrot-imx233.c
@@ -28,7 +28,7 @@ void INT_TIMER##nr(void) \
{ \
if(timer_fns[nr]) \
timer_fns[nr](); \
- __REG_CLR(HW_TIMROT_TIMCTRL(nr)) = HW_TIMROT_TIMCTRL__IRQ; \
+ BF_CLRn(TIMROT_TIMCTRLn, nr, IRQ); \
}
define_timer_irq(0)
@@ -40,33 +40,20 @@ void imx233_setup_timer(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);
-
- timer_fns[timer_nr] = fn;
-
- HW_TIMROT_TIMCTRL(timer_nr) = src | prescale;
- if(polarity)
- __REG_SET(HW_TIMROT_TIMCTRL(timer_nr)) = HW_TIMROT_TIMCTRL__POLARITY;
- if(reload)
- {
- __REG_SET(HW_TIMROT_TIMCTRL(timer_nr)) = HW_TIMROT_TIMCTRL__RELOAD;
- /* manual says count - 1 for reload timers */
- HW_TIMROT_TIMCOUNT(timer_nr) = count - 1;
- }
- else
- HW_TIMROT_TIMCOUNT(timer_nr) = count;
/* only enable interrupt if function is set */
- if(fn != NULL)
- {
- /* enable interrupt */
- imx233_icoll_enable_interrupt(INT_SRC_TIMER(timer_nr), true);
- /* clear irq bit and enable */
- __REG_CLR(HW_TIMROT_TIMCTRL(timer_nr)) = HW_TIMROT_TIMCTRL__IRQ;
- __REG_SET(HW_TIMROT_TIMCTRL(timer_nr)) = HW_TIMROT_TIMCTRL__IRQ_EN;
- }
- else
- imx233_icoll_enable_interrupt(INT_SRC_TIMER(timer_nr), false);
+ 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;
+ imx233_icoll_enable_interrupt(INT_SRC_TIMER(timer_nr), irq);
/* finally update */
- __REG_SET(HW_TIMROT_TIMCTRL(timer_nr)) = HW_TIMROT_TIMCTRL__UPDATE;
+ BF_SETn(TIMROT_TIMCTRLn, timer_nr, UPDATE);
restore_interrupt(oldstatus);
}
diff --git a/firmware/target/arm/imx233/timrot-imx233.h b/firmware/target/arm/imx233/timrot-imx233.h
index c79023da51..f7a7bc3f8d 100644
--- a/firmware/target/arm/imx233/timrot-imx233.h
+++ b/firmware/target/arm/imx233/timrot-imx233.h
@@ -24,30 +24,7 @@
#include "system.h"
#include "cpu.h"
-#define HW_TIMROT_BASE 0x80068000
-
-#define HW_TIMROT_ROTCTRL (*(volatile uint32_t *)(HW_TIMROT_BASE + 0x0))
-
-#define HW_TIMROT_ROTCOUNT (*(volatile uint32_t *)(HW_TIMROT_BASE + 0x10))
-
-#define HW_TIMROT_TIMCTRL(i) (*(volatile uint32_t *)(HW_TIMROT_BASE + 0x20 + (i) * 0x20))
-#define HW_TIMROT_TIMCTRL__IRQ (1 << 15)
-#define HW_TIMROT_TIMCTRL__IRQ_EN (1 << 14)
-#define HW_TIMROT_TIMCTRL__POLARITY (1 << 8)
-#define HW_TIMROT_TIMCTRL__UPDATE (1 << 7)
-#define HW_TIMROT_TIMCTRL__RELOAD (1 << 6)
-#define HW_TIMROT_TIMCTRL__PRESCALE_1 (0 << 4)
-#define HW_TIMROT_TIMCTRL__PRESCALE_2 (1 << 4)
-#define HW_TIMROT_TIMCTRL__PRESCALE_4 (2 << 4)
-#define HW_TIMROT_TIMCTRL__PRESCALE_8 (3 << 4)
-#define HW_TIMROT_TIMCTRL__SELECT_NEVER_TICK 0
-#define HW_TIMROT_TIMCTRL__SELECT_32KHZ_XTAL 8
-#define HW_TIMROT_TIMCTRL__SELECT_8KHZ_XTAL 9
-#define HW_TIMROT_TIMCTRL__SELECT_4KHZ_XTAL 10
-#define HW_TIMROT_TIMCTRL__SELECT_1KHZ_XTAL 11
-#define HW_TIMROT_TIMCTRL__SELECT_TICK_ALWAYS 12
-
-#define HW_TIMROT_TIMCOUNT(i) (*(volatile uint32_t *)(HW_TIMROT_BASE + 0x30 + (i) * 0x20))
+#include "regs/regs-timrot.h"
typedef void (*imx233_timer_fn_t)(void);