delay.c 893 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* delay.c: Delay loops for sparc64
  2. *
  3. * Copyright (C) 2004 David S. Miller <davem@redhat.com>
  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. void __delay(unsigned long loops)
  11. {
  12. __asm__ __volatile__(
  13. " b,pt %%xcc, 1f\n"
  14. " cmp %0, 0\n"
  15. " .align 32\n"
  16. "1:\n"
  17. " bne,pt %%xcc, 1b\n"
  18. " subcc %0, 1, %0\n"
  19. : "=&r" (loops)
  20. : "0" (loops)
  21. : "cc");
  22. }
  23. /* We used to multiply by HZ after shifting down by 32 bits
  24. * but that runs into problems for higher values of HZ and
  25. * slow cpus.
  26. */
  27. void __const_udelay(unsigned long n)
  28. {
  29. n *= 4;
  30. n *= (cpu_data(raw_smp_processor_id()).udelay_val * (HZ/4));
  31. n >>= 32;
  32. __delay(n + 1);
  33. }
  34. void __udelay(unsigned long n)
  35. {
  36. __const_udelay(n * 0x10c7UL);
  37. }
  38. void __ndelay(unsigned long n)
  39. {
  40. __const_udelay(n * 0x5UL);
  41. }