]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/arm/cpu/pxa/timer.c
8d0f82679b0a12707ce428d2a9a2bde13e1211a2
3 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
4 * Marius Groeger <mgroeger@sysgo.de>
7 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
8 * Alex Zuepke <azu@sysgo.de>
10 * See file CREDITS for list of people who contributed to this
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation; either version 2 of
16 * the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 #include <asm/arch/pxa-regs.h>
34 #error: interrupts not implemented yet
37 #if defined(CONFIG_PXA27X) || defined(CONFIG_CPU_MONAHANS)
38 #define TIMER_FREQ_HZ 3250000
39 #elif defined(CONFIG_PXA250)
40 #define TIMER_FREQ_HZ 3686400
42 #error "Timer frequency unknown - please config PXA CPU type"
45 static inline unsigned long long tick_to_time(unsigned long long tick
)
47 tick
*= CONFIG_SYS_HZ
;
48 do_div(tick
, TIMER_FREQ_HZ
);
52 static inline unsigned long long us_to_tick(unsigned long long us
)
54 us
= us
* TIMER_FREQ_HZ
+ 999999;
66 void reset_timer (void)
68 reset_timer_masked ();
71 ulong
get_timer (ulong base
)
73 return get_timer_masked () - base
;
76 void set_timer (ulong t
)
81 void __udelay (unsigned long usec
)
87 void reset_timer_masked (void)
92 ulong
get_timer_masked (void)
94 return tick_to_time(get_ticks());
97 void udelay_masked (unsigned long usec
)
99 unsigned long long tmp
;
102 tmo
= us_to_tick(usec
);
103 tmp
= get_ticks() + tmo
; /* get current timestamp */
105 while (get_ticks() < tmp
) /* loop till event */
111 * This function is derived from PowerPC code (read timebase as long long).
112 * On ARM it just returns the timer value.
114 unsigned long long get_ticks(void)
120 * This function is derived from PowerPC code (timebase clock frequency).
121 * On ARM it returns the number of timer ticks per second.
123 ulong
get_tbclk (void)
126 tbclk
= TIMER_FREQ_HZ
;