blob: d09f782f5f0c5b705c7acc887ba86c11bc14c4f4 [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>
Simon Glass97589732020-05-10 11:40:02 -060014#include <init.h>
Nobuhiro Iwamatsu01213252008-07-08 12:03:24 +090015#include <asm/processor.h>
Nobuhiro Iwamatsuac890472008-11-20 16:44:42 +090016#include <asm/io.h>
Marek Vasut1f92cca2018-08-24 21:37:14 +020017
Marek Vasut1f92cca2018-08-24 21:37:14 +020018#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_RMOBILE)
Marek Vasutc633ed82018-08-24 21:43:17 +020019#define TSTR 0x4
Marek Vasutc633ed82018-08-24 21:43:17 +020020#define TCR0 0x10
Marek Vasut1f92cca2018-08-24 21:37:14 +020021#endif /* CONFIG_CPU_SH4 */
Nobuhiro Iwamatsue763f1a2012-08-21 13:14:46 +090022
Marek Vasutc633ed82018-08-24 21:43:17 +020023#define TCR_TPSC 0x07
Marek Vasute56385a2018-08-24 21:23:04 +020024#define TSTR_STR0 BIT(0)
Nobuhiro Iwamatsucc18f8d2013-07-23 13:57:24 +090025
Nobuhiro Iwamatsue763f1a2012-08-21 13:14:46 +090026int timer_init(void)
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090027{
Marek Vasutc633ed82018-08-24 21:43:17 +020028 writew(readw(TMU_BASE + TCR0) & ~TCR_TPSC, TMU_BASE + TCR0);
29 writeb(readb(TMU_BASE + TSTR) & ~TSTR_STR0, TMU_BASE + TSTR);
30 writeb(readb(TMU_BASE + TSTR) | TSTR_STR0, TMU_BASE + TSTR);
Nobuhiro Iwamatsuac890472008-11-20 16:44:42 +090031
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090032 return 0;
33}
34