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>
20 static struct tmu_regs *tmu = (struct tmu_regs *)TMU_BASE;
22 unsigned long get_tbclk(void)
24 u16 tmu_bit = (ffs(CONFIG_SYS_TMU_CLK_DIV) >> 1) - 1;
25 return get_tmu0_clk_rate() >> ((tmu_bit + 1) * 2);
28 unsigned long timer_read_counter(void)
30 return ~readl(&tmu->tcnt0);
33 static void tmu_timer_start(unsigned int timer)
37 writeb(readb(&tmu->tstr) | (1 << timer), &tmu->tstr);
40 static void tmu_timer_stop(unsigned int timer)
44 writeb(readb(&tmu->tstr) & ~(1 << timer), &tmu->tstr);
49 u16 tmu_bit = (ffs(CONFIG_SYS_TMU_CLK_DIV) >> 1) - 1;
50 writew((readw(&tmu->tcr0) & ~TCR_TPSC) | tmu_bit, &tmu->tcr0);