summaryrefslogtreecommitdiff
path: root/cpu
diff options
context:
space:
mode:
authorMichael Brandt <michael.brandt@stericsson.com>2010-06-21 15:04:15 +0200
committerMichael BRANDT <michael.brandt@stericsson.com>2010-07-23 14:33:59 +0200
commitcb1de5258f06a9e9f18ca20e65fc0fd2e21cde21 (patch)
tree05f1da19d7b4dd03ec6fa71a700b672b817a08fb /cpu
parentc00ace75f2658989625d99e0a4e49f4428924555 (diff)
MTU updates.
This patch includes a few timer related changes. - Use MTU timer 2 instead of 0. - Fixed TIMER_CLOCK (133 MHz instead of 110 MHz). - Change MTU prescaler to 16. Change-Id: I589e531bbf2c7f0b317f05604f7550141babc11c Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/2499 Reviewed-by: Michael BRANDT <michael.brandt@stericsson.com>
Diffstat (limited to 'cpu')
-rw-r--r--cpu/arm_cortexa9/stw8500/timer.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/cpu/arm_cortexa9/stw8500/timer.c b/cpu/arm_cortexa9/stw8500/timer.c
index 1760a6472..3a3f311c8 100644
--- a/cpu/arm_cortexa9/stw8500/timer.c
+++ b/cpu/arm_cortexa9/stw8500/timer.c
@@ -64,25 +64,34 @@
#define MTU_PCELL2 0xff8
#define MTU_PCELL3 0xffC
-#define TIMER_CLOCK (110 * 1000 * 1000)
-#define COUNT_TO_USEC(x) ((x) / 110)
-#define USEC_TO_COUNT(x) ((x) * 110)
+/*
+ * The MTU is clocked at 133 MHz by default. (V1 and later)
+ */
+#define TIMER_CLOCK (133 * 1000 * 1000 / 16)
+#define COUNT_TO_USEC(x) ((x) * 16 / 133)
+#define USEC_TO_COUNT(x) ((x) * 133 / 16)
#define TICKS_PER_HZ (TIMER_CLOCK / CONFIG_SYS_HZ)
#define TICKS_TO_HZ(x) ((x) / TICKS_PER_HZ)
+/*
+ * MTU timer to use (from 0 to 3).
+ * Linux ux500 timer0 on MTU0 and timer0 on MTU1
+ */
+#define MTU_TIMER 2
+
static unsigned int timerbase;
/* macro to read the 32 bit timer: since it decrements, we invert read value */
-#define READ_TIMER() (~readl(timerbase + MTU_VAL(0)))
+#define READ_TIMER() (~readl(timerbase + MTU_VAL(MTU_TIMER)))
-/* Configure a free-running, auto-wrap counter with no prescaler */
+/* Configure a free-running, auto-wrap counter with /16 prescaler */
int timer_init(void)
{
timerbase = u8500_is_earlydrop() ? U8500_MTU0_BASE_ED
: U8500_MTU0_BASE_V1;
- writel(MTU_CRn_ENA | MTU_CRn_PRESCALE_1 | MTU_CRn_32BITS,
- timerbase + MTU_CR(0));
+ writel(MTU_CRn_ENA | MTU_CRn_PRESCALE_16 | MTU_CRn_32BITS,
+ timerbase + MTU_CR(MTU_TIMER));
reset_timer();
return 0;
}
@@ -90,7 +99,7 @@ int timer_init(void)
/* Restart counting from 0 */
void reset_timer(void)
{
- writel(0, timerbase + MTU_LR(0)); /* Immediate effect */
+ writel(0, timerbase + MTU_LR(MTU_TIMER)); /* Immediate effect */
}
/* Return how many HZ passed since "base" */