sh: timer: Mask bit of timer prescaler
authorNobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Tue, 23 Jul 2013 04:57:24 +0000 (13:57 +0900)
committerNobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Thu, 17 Oct 2013 00:34:38 +0000 (09:34 +0900)
timer_init function sets timer prescaler bit.
The previous code so did not mask this bit, this function was to overwrite
the bit. This will fix this problem.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
arch/sh/lib/time.c

index 1fe537e83bcb2d1f44f71458f3f8cbb0d3a6399d..8f83d467920b692d8cce071cfd37b650b02205f7 100644 (file)
@@ -17,6 +17,8 @@
 #include <asm/io.h>
 #include <sh_tmu.h>
 
+#define TCR_TPSC 0x07
+
 static struct tmu_regs *tmu = (struct tmu_regs *)TMU_BASE;
 
 static u16 bit;
@@ -61,7 +63,7 @@ static void tmu_timer_stop(unsigned int timer)
 int timer_init(void)
 {
        bit = (ffs(CONFIG_SYS_TMU_CLK_DIV) >> 1) - 1;
-       writew(readw(&tmu->tcr0) | bit, &tmu->tcr0);
+       writew((readw(&tmu->tcr0) & ~TCR_TPSC) | bit, &tmu->tcr0);
 
        tmu_timer_stop(0);
        tmu_timer_start(0);