delay.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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/param.h> /* HZ */
  9. extern void __delay(int loops);
  10. /*
  11. * This function intentionally does not exist; if you see references to
  12. * it, it means that you're calling udelay() with an out of range value.
  13. *
  14. * With currently imposed limits, this means that we support a max delay
  15. * of 2000us. Further limits: HZ<=1000 and bogomips<=3355
  16. */
  17. extern void __bad_udelay(void);
  18. /*
  19. * division by multiplication: you don't have to worry about
  20. * loss of precision.
  21. *
  22. * Use only for very small delays ( < 1 msec). Should probably use a
  23. * lookup table, really, as the multiplications take much too long with
  24. * short delays. This is a "reasonable" implementation, though (and the
  25. * first constant multiplications gets optimized away if the delay is
  26. * a constant)
  27. */
  28. extern void __udelay(unsigned long usecs);
  29. extern void __const_udelay(unsigned long);
  30. #define MAX_UDELAY_MS 2
  31. #define udelay(n) \
  32. (__builtin_constant_p(n) ? \
  33. ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \
  34. __const_udelay((n) * ((2199023U*HZ)>>11))) : \
  35. __udelay(n))
  36. #endif /* defined(_ARM_DELAY_H) */