made timer more generic
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1051 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
parent
008c127074
commit
cc6b6c4c83
|
@ -2,29 +2,29 @@
|
||||||
/* This code is distributed without warranty under the GPL v2 (see COPYING) */
|
/* This code is distributed without warranty under the GPL v2 (see COPYING) */
|
||||||
|
|
||||||
#include <timer.h>
|
#include <timer.h>
|
||||||
#include <bsp.h>
|
#include <ppc.h>
|
||||||
|
|
||||||
unsigned get_hz(void)
|
unsigned long get_hz(void)
|
||||||
{
|
{
|
||||||
return bsp_clock_speed();
|
return get_clock_speed();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned ticks_since_boot(void)
|
unsigned long ticks_since_boot(void)
|
||||||
{
|
{
|
||||||
extern unsigned long long _timebase(void);
|
extern unsigned long _timebase(void);
|
||||||
return (unsigned) (_timebase());
|
return _timebase();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sleep_ticks(unsigned ticks)
|
void sleep_ticks(unsigned long ticks)
|
||||||
{
|
{
|
||||||
unsigned then = ticks + ticks_since_boot();
|
unsigned long then = ticks + ticks_since_boot();
|
||||||
while(ticks_since_boot() < then)
|
while(ticks_since_boot() < then)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
void udelay(int usecs)
|
void udelay(int usecs)
|
||||||
{
|
{
|
||||||
unsigned ticksperusec = get_hz() / 1000000;
|
unsigned long ticksperusec = get_hz() / 1000000;
|
||||||
|
|
||||||
sleep_ticks(ticksperusec * usecs);
|
sleep_ticks(ticksperusec * usecs);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue