Patchwork [U-Boot,1/6] sh: timer: Mask bit of timer prescaler

login
register
mail settings
Submitter Nobuhiro Iwamatsu
Date Aug. 22, 2013, 1:57 a.m.
Message ID <1377136635-27875-1-git-send-email-nobuhiro.iwamatsu.yj@renesas.com>
Download mbox | patch
Permalink /patch/268928/
State Accepted
Delegated to: Nobuhiro Iwamatsu
Headers show

Comments

Nobuhiro Iwamatsu - Aug. 22, 2013, 1:57 a.m.
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>
---
 arch/sh/lib/time.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch

diff --git a/arch/sh/lib/time.c b/arch/sh/lib/time.c
index 1fe537e..8f83d46 100644
--- a/arch/sh/lib/time.c
+++ b/arch/sh/lib/time.c
@@ -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);