Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Nobuhiro Iwamatsu | 970dc33 | 2007-05-13 20:58:00 +0900 | [diff] [blame] | 2 | /* |
Jean-Christophe PLAGNIOL-VILLARD | 5170410 | 2009-06-04 12:06:47 +0200 | [diff] [blame] | 3 | * (C) Copyright 2009 |
| 4 | * Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> |
| 5 | * |
Nobuhiro Iwamatsu | e763f1a | 2012-08-21 13:14:46 +0900 | [diff] [blame] | 6 | * (C) Copyright 2007-2012 |
Nobuhiro Iwamatsu | ac89047 | 2008-11-20 16:44:42 +0900 | [diff] [blame] | 7 | * Nobobuhiro Iwamatsu <iwamatsu@nigauri.org> |
| 8 | * |
| 9 | * (C) Copyright 2003 |
| 10 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
Nobuhiro Iwamatsu | 970dc33 | 2007-05-13 20:58:00 +0900 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <common.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 14 | #include <init.h> |
Nobuhiro Iwamatsu | 0121325 | 2008-07-08 12:03:24 +0900 | [diff] [blame] | 15 | #include <asm/processor.h> |
Nobuhiro Iwamatsu | ac89047 | 2008-11-20 16:44:42 +0900 | [diff] [blame] | 16 | #include <asm/io.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 17 | #include <linux/bitops.h> |
Marek Vasut | 1f92cca | 2018-08-24 21:37:14 +0200 | [diff] [blame] | 18 | |
Marek Vasut | 1f92cca | 2018-08-24 21:37:14 +0200 | [diff] [blame] | 19 | #if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_RMOBILE) |
Marek Vasut | c633ed8 | 2018-08-24 21:43:17 +0200 | [diff] [blame] | 20 | #define TSTR 0x4 |
Marek Vasut | c633ed8 | 2018-08-24 21:43:17 +0200 | [diff] [blame] | 21 | #define TCR0 0x10 |
Marek Vasut | 1f92cca | 2018-08-24 21:37:14 +0200 | [diff] [blame] | 22 | #endif /* CONFIG_CPU_SH4 */ |
Nobuhiro Iwamatsu | e763f1a | 2012-08-21 13:14:46 +0900 | [diff] [blame] | 23 | |
Marek Vasut | c633ed8 | 2018-08-24 21:43:17 +0200 | [diff] [blame] | 24 | #define TCR_TPSC 0x07 |
Marek Vasut | e56385a | 2018-08-24 21:23:04 +0200 | [diff] [blame] | 25 | #define TSTR_STR0 BIT(0) |
Nobuhiro Iwamatsu | cc18f8d | 2013-07-23 13:57:24 +0900 | [diff] [blame] | 26 | |
Nobuhiro Iwamatsu | e763f1a | 2012-08-21 13:14:46 +0900 | [diff] [blame] | 27 | int timer_init(void) |
Nobuhiro Iwamatsu | 970dc33 | 2007-05-13 20:58:00 +0900 | [diff] [blame] | 28 | { |
Marek Vasut | c633ed8 | 2018-08-24 21:43:17 +0200 | [diff] [blame] | 29 | writew(readw(TMU_BASE + TCR0) & ~TCR_TPSC, TMU_BASE + TCR0); |
| 30 | writeb(readb(TMU_BASE + TSTR) & ~TSTR_STR0, TMU_BASE + TSTR); |
| 31 | writeb(readb(TMU_BASE + TSTR) | TSTR_STR0, TMU_BASE + TSTR); |
Nobuhiro Iwamatsu | ac89047 | 2008-11-20 16:44:42 +0900 | [diff] [blame] | 32 | |
Nobuhiro Iwamatsu | 970dc33 | 2007-05-13 20:58:00 +0900 | [diff] [blame] | 33 | return 0; |
| 34 | } |