delay.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* delay.h: FRV delay code
  2. *
  3. * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #ifndef _ASM_DELAY_H
  12. #define _ASM_DELAY_H
  13. #include <asm/param.h>
  14. #include <asm/timer-regs.h>
  15. /*
  16. * delay loop - runs at __core_clock_speed_HZ / 2 [there are 2 insns in the loop]
  17. */
  18. extern unsigned long __delay_loops_MHz;
  19. static inline void __delay(unsigned long loops)
  20. {
  21. asm volatile("1: subicc %0,#1,%0,icc0 \n"
  22. " bnc icc0,#2,1b \n"
  23. : "=r" (loops)
  24. : "0" (loops)
  25. : "icc0"
  26. );
  27. }
  28. /*
  29. * Use only for very small delays ( < 1 msec). Should probably use a
  30. * lookup table, really, as the multiplications take much too long with
  31. * short delays. This is a "reasonable" implementation, though (and the
  32. * first constant multiplications gets optimized away if the delay is
  33. * a constant)
  34. */
  35. extern unsigned long loops_per_jiffy;
  36. static inline void udelay(unsigned long usecs)
  37. {
  38. __delay(usecs * __delay_loops_MHz);
  39. }
  40. #define ndelay(n) udelay((n) * 5)
  41. #endif /* _ASM_DELAY_H */