1 // SPDX-License-Identifier: GPL-2.0+
4 * Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
6 * (C) Copyright 2007-2012
7 * Nobobuhiro Iwamatsu <iwamatsu@nigauri.org>
10 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
14 #include <asm/processor.h>
17 #if defined(CONFIG_CPU_SH3)
37 #endif /* CONFIG_CPU_SH3 */
39 #if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_RMOBILE)
57 #endif /* CONFIG_CPU_SH4 */
60 #define TSTR_STR0 BIT(0)
62 static struct tmu_regs *tmu = (struct tmu_regs *)TMU_BASE;
64 unsigned long get_tbclk(void)
66 #ifdef CONFIG_RCAR_GEN2
67 return CONFIG_SYS_CLK_FREQ / 8;
69 return CONFIG_SYS_CLK_FREQ / 4;
73 unsigned long timer_read_counter(void)
75 return ~readl(&tmu->tcnt0);
80 writew(readw(&tmu->tcr0) & ~TCR_TPSC, &tmu->tcr0);
81 writeb(readb(&tmu->tstr) & ~TSTR_STR0, &tmu->tstr);
82 writeb(readb(&tmu->tstr) | TSTR_STR0, &tmu->tstr);