summaryrefslogtreecommitdiff
path: root/src/arch/ppc/lib/timer.c
blob: 37576d71f4ea72ef06b7f7ed2674c76f1c43bb08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* Copyright 2000  AG Electronics Ltd. */
/* This code is distributed without warranty under the GPL v2 (see COPYING) */

#include <timer.h>
#include <ppc.h>

unsigned long get_hz(void)
{
	return get_clock_speed();
}

unsigned long ticks_since_boot(void)
{
	extern unsigned long _timebase(void);
	return _timebase();
}

void sleep_ticks(unsigned long ticks)
{
	unsigned long then = ticks + ticks_since_boot();
	while(ticks_since_boot() < then)
		;
}

void udelay(int usecs)
{
	unsigned long ticksperusec = get_hz() / 1000000;

	sleep_ticks(ticksperusec * usecs);
}