delay.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef _BLACKFIN_DELAY_H
  2. #define _BLACKFIN_DELAY_H
  3. static inline void __delay(unsigned long loops)
  4. {
  5. /* FIXME: Currently the assembler doesn't recognize Loop Register Clobbers,
  6. uncomment this as soon those are implemented */
  7. /*
  8. __asm__ __volatile__ ( "\t LSETUP (1f,1f) LC0= %0\n\t"
  9. "1:\t NOP;\n\t"
  10. : :"a" (loops)
  11. : "LT0","LB0","LC0");
  12. */
  13. __asm__ __volatile__("[--SP] = LC0;\n\t"
  14. "[--SP] = LT0;\n\t"
  15. "[--SP] = LB0;\n\t"
  16. "LSETUP (1f,1f) LC0 = %0;\n\t"
  17. "1:\t NOP;\n\t"
  18. "LB0 = [SP++];\n\t"
  19. "LT0 = [SP++];\n\t"
  20. "LC0 = [SP++];\n"
  21. :
  22. :"a" (loops));
  23. }
  24. #include <linux/param.h> /* needed for HZ */
  25. /*
  26. * Use only for very small delays ( < 1 msec). Should probably use a
  27. * lookup table, really, as the multiplications take much too long with
  28. * short delays. This is a "reasonable" implementation, though (and the
  29. * first constant multiplications gets optimized away if the delay is
  30. * a constant)
  31. */
  32. static inline void udelay(unsigned long usecs)
  33. {
  34. extern unsigned long loops_per_jiffy;
  35. __delay(usecs * loops_per_jiffy / (1000000 / HZ));
  36. }
  37. #endif /* defined(_BLACKFIN_DELAY_H) */