3 * Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
5 * (C) Copyright 2007-2012
6 * Nobobuhiro Iwamatsu <iwamatsu@nigauri.org>
9 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
11 * SPDX-License-Identifier: GPL-2.0+
15 #include <asm/processor.h>
21 static struct tmu_regs *tmu = (struct tmu_regs *)TMU_BASE;
23 unsigned long get_tbclk(void)
25 u16 tmu_bit = (ffs(CONFIG_SYS_TMU_CLK_DIV) >> 1) - 1;
26 return get_tmu0_clk_rate() >> ((tmu_bit + 1) * 2);
29 unsigned long timer_read_counter(void)
31 return ~readl(&tmu->tcnt0);
34 static void tmu_timer_start(unsigned int timer)
38 writeb(readb(&tmu->tstr) | (1 << timer), &tmu->tstr);
41 static void tmu_timer_stop(unsigned int timer)
45 writeb(readb(&tmu->tstr) & ~(1 << timer), &tmu->tstr);
50 u16 tmu_bit = (ffs(CONFIG_SYS_TMU_CLK_DIV) >> 1) - 1;
51 writew((readw(&tmu->tcr0) & ~TCR_TPSC) | tmu_bit, &tmu->tcr0);