blob: fb317f95d550085d0476451e03b52e6d628eeed3 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +09002/*
Jean-Christophe PLAGNIOL-VILLARD51704102009-06-04 12:06:47 +02003 * (C) Copyright 2009
4 * Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
5 *
Nobuhiro Iwamatsue763f1a2012-08-21 13:14:46 +09006 * (C) Copyright 2007-2012
Nobuhiro Iwamatsuac890472008-11-20 16:44:42 +09007 * Nobobuhiro Iwamatsu <iwamatsu@nigauri.org>
8 *
9 * (C) Copyright 2003
10 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090011 */
12
13#include <common.h>
Nobuhiro Iwamatsu01213252008-07-08 12:03:24 +090014#include <asm/processor.h>
Nobuhiro Iwamatsuac890472008-11-20 16:44:42 +090015#include <asm/io.h>
Marek Vasut1f92cca2018-08-24 21:37:14 +020016
17#if defined(CONFIG_CPU_SH3)
Marek Vasutc633ed82018-08-24 21:43:17 +020018#define TSTR 0x2
Marek Vasutc633ed82018-08-24 21:43:17 +020019#define TCR0 0xc
Marek Vasut1f92cca2018-08-24 21:37:14 +020020#endif /* CONFIG_CPU_SH3 */
21
22#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_RMOBILE)
Marek Vasutc633ed82018-08-24 21:43:17 +020023#define TSTR 0x4
Marek Vasutc633ed82018-08-24 21:43:17 +020024#define TCR0 0x10
Marek Vasut1f92cca2018-08-24 21:37:14 +020025#endif /* CONFIG_CPU_SH4 */
Nobuhiro Iwamatsue763f1a2012-08-21 13:14:46 +090026
Marek Vasutc633ed82018-08-24 21:43:17 +020027#define TCR_TPSC 0x07
Marek Vasute56385a2018-08-24 21:23:04 +020028#define TSTR_STR0 BIT(0)
Nobuhiro Iwamatsucc18f8d2013-07-23 13:57:24 +090029
Nobuhiro Iwamatsue763f1a2012-08-21 13:14:46 +090030int timer_init(void)
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090031{
Marek Vasutc633ed82018-08-24 21:43:17 +020032 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);
Nobuhiro Iwamatsuac890472008-11-20 16:44:42 +090035
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090036 return 0;
37}
38