blob: c7829c9b097438582049e1410881b9ba8f333094 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenk15809242002-09-08 20:56:32 +00002/*
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>
wdenk15809242002-09-08 20:56:32 +000010 */
11
12#include <common.h>
13#include <SA-1100.h>
14
wdenk15809242002-09-08 20:56:32 +000015ulong get_timer (ulong base)
16{
17 return get_timer_masked ();
18}
19
wdenk15809242002-09-08 20:56:32 +000020ulong get_timer_masked (void)
21{
22 return OSCR;
23}
24
Patrick Delaunayaa33fe82018-10-05 11:33:51 +020025void __udelay (unsigned long usec)
wdenk15809242002-09-08 20:56:32 +000026{
27 ulong tmo;
wdenk101e8df2005-04-04 12:08:28 +000028 ulong endtime;
29 signed long diff;
wdenk15809242002-09-08 20:56:32 +000030
wdenk101e8df2005-04-04 12:08:28 +000031 if (usec >= 1000) {
32 tmo = usec / 1000;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020033 tmo *= CONFIG_SYS_HZ;
wdenk101e8df2005-04-04 12:08:28 +000034 tmo /= 1000;
35 } else {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020036 tmo = usec * CONFIG_SYS_HZ;
wdenk101e8df2005-04-04 12:08:28 +000037 tmo /= (1000*1000);
38 }
wdenk15809242002-09-08 20:56:32 +000039
wdenk101e8df2005-04-04 12:08:28 +000040 endtime = get_timer_masked () + tmo;
wdenk15809242002-09-08 20:56:32 +000041
wdenk101e8df2005-04-04 12:08:28 +000042 do {
43 ulong now = get_timer_masked ();
44 diff = endtime - now;
45 } while (diff >= 0);
wdenk15809242002-09-08 20:56:32 +000046}
wdenkaaf224a2004-03-14 15:20:55 +000047
48/*
49 * This function is derived from PowerPC code (read timebase as long long).
50 * On ARM it just returns the timer value.
51 */
52unsigned long long get_ticks(void)
53{
54 return get_timer(0);
55}
56
57/*
58 * This function is derived from PowerPC code (timebase clock frequency).
59 * On ARM it returns the number of timer ticks per second.
60 */
61ulong get_tbclk (void)
62{
Masahiro Yamada63a75782016-09-06 22:17:38 +090063 return CONFIG_SYS_HZ;
wdenkaaf224a2004-03-14 15:20:55 +000064}