blob: 51e1cc1181c06be7edda98f52801f2a9a0c6bf41 [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
Marek Vasut1f92cca2018-08-24 21:37:14 +020017#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_RMOBILE)
Marek Vasutc633ed82018-08-24 21:43:17 +020018#define TSTR 0x4
Marek Vasutc633ed82018-08-24 21:43:17 +020019#define TCR0 0x10
Marek Vasut1f92cca2018-08-24 21:37:14 +020020#endif /* CONFIG_CPU_SH4 */
Nobuhiro Iwamatsue763f1a2012-08-21 13:14:46 +090021
Marek Vasutc633ed82018-08-24 21:43:17 +020022#define TCR_TPSC 0x07
Marek Vasute56385a2018-08-24 21:23:04 +020023#define TSTR_STR0 BIT(0)
Nobuhiro Iwamatsucc18f8d2013-07-23 13:57:24 +090024
Nobuhiro Iwamatsue763f1a2012-08-21 13:14:46 +090025int timer_init(void)
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090026{
Marek Vasutc633ed82018-08-24 21:43:17 +020027 writew(readw(TMU_BASE + TCR0) & ~TCR_TPSC, TMU_BASE + TCR0);
28 writeb(readb(TMU_BASE + TSTR) & ~TSTR_STR0, TMU_BASE + TSTR);
29 writeb(readb(TMU_BASE + TSTR) | TSTR_STR0, TMU_BASE + TSTR);
Nobuhiro Iwamatsuac890472008-11-20 16:44:42 +090030
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090031 return 0;
32}
33