delay.c 889 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* delay.c: Delay loops for sparc64
  2. *
  3. * Copyright (C) 2004, 2006 David S. Miller <davem@davemloft.net>
  4. *
  5. * Based heavily upon x86 variant which is:
  6. * Copyright (C) 1993 Linus Torvalds
  7. * Copyright (C) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
  8. */
  9. #include <linux/delay.h>
  10. #include <asm/timer.h>
  11. void __delay(unsigned long loops)
  12. {
  13. unsigned long bclock, now;
  14. bclock = tick_ops->get_tick();
  15. do {
  16. now = tick_ops->get_tick();
  17. } while ((now-bclock) < loops);
  18. }
  19. /* We used to multiply by HZ after shifting down by 32 bits
  20. * but that runs into problems for higher values of HZ and
  21. * slow cpus.
  22. */
  23. void __const_udelay(unsigned long n)
  24. {
  25. n *= 4;
  26. n *= (cpu_data(raw_smp_processor_id()).udelay_val * (HZ/4));
  27. n >>= 32;
  28. __delay(n + 1);
  29. }
  30. void __udelay(unsigned long n)
  31. {
  32. __const_udelay(n * 0x10c7UL);
  33. }
  34. void __ndelay(unsigned long n)
  35. {
  36. __const_udelay(n * 0x5UL);
  37. }