delay.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (C) 1995-2004 Russell King
  3. *
  4. * Delay routines, using a pre-computed "loops_per_second" value.
  5. */
  6. #ifndef __ASM_ARM_DELAY_H
  7. #define __ASM_ARM_DELAY_H
  8. #include <asm/memory.h>
  9. #include <asm/param.h> /* HZ */
  10. #define MAX_UDELAY_MS 2
  11. #define UDELAY_MULT UL(2147 * HZ + 483648 * HZ / 1000000)
  12. #define UDELAY_SHIFT 31
  13. #ifndef __ASSEMBLY__
  14. struct delay_timer {
  15. unsigned long (*read_current_timer)(void);
  16. unsigned long freq;
  17. };
  18. extern struct arm_delay_ops {
  19. void (*delay)(unsigned long);
  20. void (*const_udelay)(unsigned long);
  21. void (*udelay)(unsigned long);
  22. unsigned long ticks_per_jiffy;
  23. } arm_delay_ops;
  24. #define __delay(n) arm_delay_ops.delay(n)
  25. /*
  26. * This function intentionally does not exist; if you see references to
  27. * it, it means that you're calling udelay() with an out of range value.
  28. *
  29. * With currently imposed limits, this means that we support a max delay
  30. * of 2000us. Further limits: HZ<=1000
  31. */
  32. extern void __bad_udelay(void);
  33. /*
  34. * division by multiplication: you don't have to worry about
  35. * loss of precision.
  36. *
  37. * Use only for very small delays ( < 2 msec). Should probably use a
  38. * lookup table, really, as the multiplications take much too long with
  39. * short delays. This is a "reasonable" implementation, though (and the
  40. * first constant multiplications gets optimized away if the delay is
  41. * a constant)
  42. */
  43. #define __udelay(n) arm_delay_ops.udelay(n)
  44. #define __const_udelay(n) arm_delay_ops.const_udelay(n)
  45. #define udelay(n) \
  46. (__builtin_constant_p(n) ? \
  47. ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \
  48. __const_udelay((n) * UDELAY_MULT)) : \
  49. __udelay(n))
  50. /* Loop-based definitions for assembly code. */
  51. extern void __loop_delay(unsigned long loops);
  52. extern void __loop_udelay(unsigned long usecs);
  53. extern void __loop_const_udelay(unsigned long);
  54. /* Delay-loop timer registration. */
  55. #define ARCH_HAS_READ_CURRENT_TIMER
  56. extern void register_current_timer_delay(const struct delay_timer *timer);
  57. #endif /* __ASSEMBLY__ */
  58. #endif /* defined(_ARM_DELAY_H) */