4
* http://www.dave-tech.it
5
* http://www.wawnet.biz
6
* mailto:info@wawnet.biz
8
* See file CREDITS for list of people who contributed to this
11
* This program is free software; you can redistribute it and/or
12
* modify it under the terms of the GNU General Public License as
13
* published by the Free Software Foundation; either version 2 of
14
* the License, or (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28
#include <asm/hardware.h>
30
/* we always count down the max. */
31
#define TIMER_LOAD_VAL 0xffff
33
/* macro to read the 16 bit timer */
34
#define READ_TIMER (TCNTO1 & 0xffff)
37
#error CONFIG_USE_IRQ NOT supported
40
static ulong timestamp;
48
TCNTB1 = TIMER_LOAD_VAL;
54
lastdec = TCNTB1 = TIMER_LOAD_VAL;
60
* timer without interrupts
63
void reset_timer (void)
65
reset_timer_masked ();
68
ulong get_timer (ulong base)
70
return get_timer_masked () - base;
73
void set_timer (ulong t)
78
void __udelay (unsigned long usec)
88
while (get_timer_masked () < tmo)
92
void reset_timer_masked (void)
99
ulong get_timer_masked (void)
101
ulong now = READ_TIMER;
103
if (lastdec >= now) {
105
timestamp += lastdec - now;
107
/* we have an overflow ... */
108
timestamp += lastdec + TIMER_LOAD_VAL - now;
115
void udelay_masked (unsigned long usec)
123
tmo *= CONFIG_SYS_HZ;
126
tmo = usec * CONFIG_SYS_HZ;
130
endtime = get_timer(0) + tmo;
133
ulong now = get_timer_masked ();
134
diff = endtime - now;