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 ulong get_timer (ulong base) 17 { 18 return get_timer_masked (); 19 } 20 21 void __udelay (unsigned long usec) 22 { 23 udelay_masked (usec); 24 } 25 26 ulong get_timer_masked (void) 27 { 28 return OSCR; 29 } 30 31 void udelay_masked (unsigned long usec) 32 { 33 ulong tmo; 34 ulong endtime; 35 signed long diff; 36 37 if (usec >= 1000) { 38 tmo = usec / 1000; 39 tmo *= CONFIG_SYS_HZ; 40 tmo /= 1000; 41 } else { 42 tmo = usec * CONFIG_SYS_HZ; 43 tmo /= (1000*1000); 44 } 45 46 endtime = get_timer_masked () + tmo; 47 48 do { 49 ulong now = get_timer_masked (); 50 diff = endtime - now; 51 } while (diff >= 0); 52 } 53 54 /* 55 * This function is derived from PowerPC code (read timebase as long long). 56 * On ARM it just returns the timer value. 57 */ 58 unsigned long long get_ticks(void) 59 { 60 return get_timer(0); 61 } 62 63 /* 64 * This function is derived from PowerPC code (timebase clock frequency). 65 * On ARM it returns the number of timer ticks per second. 66 */ 67 ulong get_tbclk (void) 68 { 69 ulong tbclk; 70 71 tbclk = CONFIG_SYS_HZ; 72 return tbclk; 73 } 74