delay.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * linux/arch/unicore32/include/asm/delay.h
  3. *
  4. * Code specific to PKUnity SoC and UniCore ISA
  5. *
  6. * Copyright (C) 2001-2010 GUAN Xue-tao
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * Delay routines, using a pre-computed "loops_per_second" value.
  13. */
  14. #ifndef __UNICORE_DELAY_H__
  15. #define __UNICORE_DELAY_H__
  16. #include <asm/param.h> /* HZ */
  17. extern void __delay(int loops);
  18. /*
  19. * This function intentionally does not exist; if you see references to
  20. * it, it means that you're calling udelay() with an out of range value.
  21. *
  22. * With currently imposed limits, this means that we support a max delay
  23. * of 2000us. Further limits: HZ<=1000 and bogomips<=3355
  24. */
  25. extern void __bad_udelay(void);
  26. /*
  27. * division by multiplication: you don't have to worry about
  28. * loss of precision.
  29. *
  30. * Use only for very small delays ( < 1 msec). Should probably use a
  31. * lookup table, really, as the multiplications take much too long with
  32. * short delays. This is a "reasonable" implementation, though (and the
  33. * first constant multiplications gets optimized away if the delay is
  34. * a constant)
  35. */
  36. extern void __udelay(unsigned long usecs);
  37. extern void __const_udelay(unsigned long);
  38. #define MAX_UDELAY_MS 2
  39. #define udelay(n) \
  40. (__builtin_constant_p(n) ? \
  41. ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \
  42. __const_udelay((n) * ((2199023U*HZ)>>11))) : \
  43. __udelay(n))
  44. #endif /* __UNICORE_DELAY_H__ */