• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2002
4  * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
5  * Marius Groeger <mgroeger@sysgo.de>
6  *
7  * (C) Copyright 2002
8  * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
9  * Alex Zuepke <azu@sysgo.de>
10  */
11 
12 #include <common.h>
13 #include <SA-1100.h>
14 
get_timer(ulong base)15 ulong get_timer (ulong base)
16 {
17 	return get_timer_masked ();
18 }
19 
__udelay(unsigned long usec)20 void __udelay (unsigned long usec)
21 {
22 	udelay_masked (usec);
23 }
24 
get_timer_masked(void)25 ulong get_timer_masked (void)
26 {
27 	return OSCR;
28 }
29 
udelay_masked(unsigned long usec)30 void udelay_masked (unsigned long usec)
31 {
32 	ulong tmo;
33 	ulong endtime;
34 	signed long diff;
35 
36 	if (usec >= 1000) {
37 		tmo = usec / 1000;
38 		tmo *= CONFIG_SYS_HZ;
39 		tmo /= 1000;
40 	} else {
41 		tmo = usec * CONFIG_SYS_HZ;
42 		tmo /= (1000*1000);
43 	}
44 
45 	endtime = get_timer_masked () + tmo;
46 
47 	do {
48 		ulong now = get_timer_masked ();
49 		diff = endtime - now;
50 	} while (diff >= 0);
51 }
52 
53 /*
54  * This function is derived from PowerPC code (read timebase as long long).
55  * On ARM it just returns the timer value.
56  */
get_ticks(void)57 unsigned long long get_ticks(void)
58 {
59 	return get_timer(0);
60 }
61 
62 /*
63  * This function is derived from PowerPC code (timebase clock frequency).
64  * On ARM it returns the number of timer ticks per second.
65  */
get_tbclk(void)66 ulong get_tbclk (void)
67 {
68 	return CONFIG_SYS_HZ;
69 }
70