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