3 * Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
6 * Nobobuhiro Iwamatsu <iwamatsu@nigauri.org>
9 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
11 * See file CREDITS for list of people who contributed to this
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 #include <asm/processor.h>
34 #define TMU_MAX_COUNTER (~0UL)
36 static void tmu_timer_start(unsigned int timer)
41 outb(inb(TSTR) | (1 << timer), TSTR);
44 static void tmu_timer_stop(unsigned int timer)
50 outb(val & ~(1 << timer), TSTR);
55 /* Divide clock by 4 */
64 In theory we should return a true 64bit value (ie something that doesn't
65 overflow). However, we don't. Therefore if TMU runs at fastest rate of
66 6.75 MHz this value will wrap after u-boot has been running for approx
69 unsigned long long get_ticks(void)
71 return (0 - inl(TCNT0));
74 unsigned long get_timer(unsigned long base)
76 return ((0 - inl(TCNT0)) - base);
79 void set_timer(unsigned long t)
84 void reset_timer(void)
91 void udelay(unsigned long usec)
93 unsigned int start = get_timer(0);
94 unsigned int end = start + (usec * ((CFG_HZ + 500000) / 1000000));
96 while (get_timer(0) < end)
100 unsigned long get_tbclk(void)