]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/arm/cpu/s3c44b0/timer.c
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
62 ulong
get_timer (ulong base
)
64 return get_timer_masked () - base
;
67 void __udelay (unsigned long usec
)
77 while (get_timer_masked () < tmo
)
81 ulong
get_timer_masked (void)
83 ulong now
= READ_TIMER
;
87 timestamp
+= lastdec
- now
;
89 /* we have an overflow ... */
90 timestamp
+= lastdec
+ TIMER_LOAD_VAL
- now
;
97 void udelay_masked (unsigned long usec
)
105 tmo
*= CONFIG_SYS_HZ
;
108 tmo
= usec
* CONFIG_SYS_HZ
;
112 endtime
= get_timer(0) + tmo
;
115 ulong now
= get_timer_masked ();
116 diff
= endtime
- now
;