Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Nobuhiro Iwamatsu | 0b135cf | 2007-05-13 20:58:00 +0900 | [diff] [blame] | 2 | /* |
Jean-Christophe PLAGNIOL-VILLARD | 8dd29c8 | 2009-06-04 12:06:47 +0200 | [diff] [blame] | 3 | * (C) Copyright 2009 |
| 4 | * Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> |
| 5 | * |
Nobuhiro Iwamatsu | 73f35e0 | 2012-08-21 13:14:46 +0900 | [diff] [blame] | 6 | * (C) Copyright 2007-2012 |
Nobuhiro Iwamatsu | e9d5f35 | 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 | 0b135cf | 2007-05-13 20:58:00 +0900 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <common.h> |
Simon Glass | 691d719 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 14 | #include <init.h> |
Nobuhiro Iwamatsu | 9e23fe0 | 2008-07-08 12:03:24 +0900 | [diff] [blame] | 15 | #include <asm/processor.h> |
Nobuhiro Iwamatsu | e9d5f35 | 2008-11-20 16:44:42 +0900 | [diff] [blame] | 16 | #include <asm/io.h> |
Simon Glass | cd93d62 | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 17 | #include <linux/bitops.h> |
Marek Vasut | 8b39df9 | 2018-08-24 21:37:14 +0200 | [diff] [blame] | 18 | |
Marek Vasut | 8b39df9 | 2018-08-24 21:37:14 +0200 | [diff] [blame] | 19 | #if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_RMOBILE) |
Marek Vasut | f02c1f6 | 2018-08-24 21:43:17 +0200 | [diff] [blame] | 20 | #define TSTR 0x4 |
Marek Vasut | f02c1f6 | 2018-08-24 21:43:17 +0200 | [diff] [blame] | 21 | #define TCR0 0x10 |
Marek Vasut | 8b39df9 | 2018-08-24 21:37:14 +0200 | [diff] [blame] | 22 | #endif /* CONFIG_CPU_SH4 */ |
Nobuhiro Iwamatsu | 73f35e0 | 2012-08-21 13:14:46 +0900 | [diff] [blame] | 23 | |
Marek Vasut | f02c1f6 | 2018-08-24 21:43:17 +0200 | [diff] [blame] | 24 | #define TCR_TPSC 0x07 |
Marek Vasut | 15f11fc | 2018-08-24 21:23:04 +0200 | [diff] [blame] | 25 | #define TSTR_STR0 BIT(0) |
Nobuhiro Iwamatsu | 861bd4b | 2013-07-23 13:57:24 +0900 | [diff] [blame] | 26 | |
Nobuhiro Iwamatsu | 73f35e0 | 2012-08-21 13:14:46 +0900 | [diff] [blame] | 27 | int timer_init(void) |
Nobuhiro Iwamatsu | 0b135cf | 2007-05-13 20:58:00 +0900 | [diff] [blame] | 28 | { |
Marek Vasut | f02c1f6 | 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 | e9d5f35 | 2008-11-20 16:44:42 +0900 | [diff] [blame] | 32 | |
Nobuhiro Iwamatsu | 0b135cf | 2007-05-13 20:58:00 +0900 | [diff] [blame] | 33 | return 0; |
| 34 | } |
| 35 | |