2005-04-16 15:20:36 -07:00
|
|
|
/* delay.c: Delay loops for sparc64
|
|
|
|
*
|
2006-02-17 13:33:13 -07:00
|
|
|
* Copyright (C) 2004, 2006 David S. Miller <davem@davemloft.net>
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
|
|
|
* Based heavily upon x86 variant which is:
|
|
|
|
* Copyright (C) 1993 Linus Torvalds
|
|
|
|
* Copyright (C) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/delay.h>
|
2006-02-17 13:33:13 -07:00
|
|
|
#include <asm/timer.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
void __delay(unsigned long loops)
|
|
|
|
{
|
2006-02-17 13:33:13 -07:00
|
|
|
unsigned long bclock, now;
|
|
|
|
|
|
|
|
bclock = tick_ops->get_tick();
|
|
|
|
do {
|
|
|
|
now = tick_ops->get_tick();
|
|
|
|
} while ((now-bclock) < loops);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* We used to multiply by HZ after shifting down by 32 bits
|
|
|
|
* but that runs into problems for higher values of HZ and
|
|
|
|
* slow cpus.
|
|
|
|
*/
|
|
|
|
void __const_udelay(unsigned long n)
|
|
|
|
{
|
|
|
|
n *= 4;
|
|
|
|
|
2005-06-21 17:14:34 -07:00
|
|
|
n *= (cpu_data(raw_smp_processor_id()).udelay_val * (HZ/4));
|
2005-04-16 15:20:36 -07:00
|
|
|
n >>= 32;
|
|
|
|
|
|
|
|
__delay(n + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void __udelay(unsigned long n)
|
|
|
|
{
|
|
|
|
__const_udelay(n * 0x10c7UL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void __ndelay(unsigned long n)
|
|
|
|
{
|
|
|
|
__const_udelay(n * 0x5UL);
|
|
|
|
}
|