summaryrefslogtreecommitdiff
path: root/src/arch/ppc/lib/timer.c
diff options
context:
space:
mode:
authorGreg Watson <jarrah@users.sourceforge.net>2003-06-09 21:29:23 +0000
committerGreg Watson <jarrah@users.sourceforge.net>2003-06-09 21:29:23 +0000
commit032211593248d4d9a569ecfd269a2433ea5b1c7c (patch)
tree0cd5ca04ea4add897a92f4df7c6cc37730d8daf8 /src/arch/ppc/lib/timer.c
parentfd958cea68e7df40c47a3a97762d2433b5a52819 (diff)
downloadcoreboot-032211593248d4d9a569ecfd269a2433ea5b1c7c.tar.xz
Moved from freebios
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@862 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src/arch/ppc/lib/timer.c')
-rw-r--r--src/arch/ppc/lib/timer.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/arch/ppc/lib/timer.c b/src/arch/ppc/lib/timer.c
new file mode 100644
index 0000000000..8f968f1a5f
--- /dev/null
+++ b/src/arch/ppc/lib/timer.c
@@ -0,0 +1,31 @@
+/* $Id$ */
+/* Copyright 2000 AG Electronics Ltd. */
+/* This code is distributed without warranty under the GPL v2 (see COPYING) */
+
+#include <timer.h>
+#include <bsp.h>
+
+unsigned get_hz(void)
+{
+ return bsp_clock_speed();
+}
+
+unsigned ticks_since_boot(void)
+{
+ extern unsigned long long _timebase(void);
+ return (unsigned) (_timebase());
+}
+
+void sleep_ticks(unsigned ticks)
+{
+ unsigned then = ticks + ticks_since_boot();
+ while(ticks_since_boot() < then)
+ ;
+}
+
+void udelay(int usecs)
+{
+ unsigned ticksperusec = get_hz() / 1000000;
+
+ sleep_ticks(ticksperusec * usecs);
+}