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