xref: /openbmc/u-boot/arch/sh/lib/time.c (revision 0eee446e)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2009
4  * Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
5  *
6  * (C) Copyright 2007-2012
7  * Nobobuhiro Iwamatsu <iwamatsu@nigauri.org>
8  *
9  * (C) Copyright 2003
10  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
11  */
12 
13 #include <common.h>
14 #include <asm/processor.h>
15 #include <asm/io.h>
16 
17 #if defined(CONFIG_CPU_SH3)
18 #define TSTR	0x2
19 #define TCR0	0xc
20 #endif /* CONFIG_CPU_SH3 */
21 
22 #if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_RMOBILE)
23 #define TSTR	0x4
24 #define TCR0	0x10
25 #endif /* CONFIG_CPU_SH4 */
26 
27 #define TCR_TPSC	0x07
28 #define TSTR_STR0	BIT(0)
29 
timer_init(void)30 int timer_init(void)
31 {
32 	writew(readw(TMU_BASE + TCR0) & ~TCR_TPSC, TMU_BASE + TCR0);
33 	writeb(readb(TMU_BASE + TSTR) & ~TSTR_STR0, TMU_BASE + TSTR);
34 	writeb(readb(TMU_BASE + TSTR) | TSTR_STR0, TMU_BASE + TSTR);
35 
36 	return 0;
37 }
38 
39