delay.h 904 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef _H8300_DELAY_H
  2. #define _H8300_DELAY_H
  3. #include <asm/param.h>
  4. /*
  5. * Copyright (C) 2002 Yoshinori Sato <ysato@sourceforge.jp>
  6. *
  7. * Delay routines, using a pre-computed "loops_per_second" value.
  8. */
  9. static inline void __delay(unsigned long loops)
  10. {
  11. __asm__ __volatile__ ("1:\n\t"
  12. "dec.l #1,%0\n\t"
  13. "bne 1b"
  14. :"=r" (loops):"0"(loops));
  15. }
  16. /*
  17. * Use only for very small delays ( < 1 msec). Should probably use a
  18. * lookup table, really, as the multiplications take much too long with
  19. * short delays. This is a "reasonable" implementation, though (and the
  20. * first constant multiplications gets optimized away if the delay is
  21. * a constant)
  22. */
  23. extern unsigned long loops_per_jiffy;
  24. static inline void udelay(unsigned long usecs)
  25. {
  26. usecs *= 4295; /* 2**32 / 1000000 */
  27. usecs /= (loops_per_jiffy*HZ);
  28. if (usecs)
  29. __delay(usecs);
  30. }
  31. #endif /* _H8300_DELAY_H */