summaryrefslogtreecommitdiff
path: root/src/arch/ppc/lib/timer.c
blob: 8f968f1a5f48622a35ff07f9fa9e631707afacc3 (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
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);
}