delay.h 955 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * U-Boot - delay.h Routines for introducing delays
  3. *
  4. * Copyright (c) 2005-2007 Analog Devices Inc.
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #ifndef _BLACKFIN_DELAY_H
  9. #define _BLACKFIN_DELAY_H
  10. /*
  11. * Changes made by akbar.hussain@Lineo.com, for BLACKFIN
  12. * Copyright (C) 1994 Hamish Macdonald
  13. *
  14. * Delay routines, using a pre-computed "loops_per_second" value.
  15. */
  16. static __inline__ void __delay(unsigned long loops)
  17. {
  18. __asm__ __volatile__("1:\t%0 += -1;\n\t"
  19. "cc = %0 == 0;\n\t"
  20. "if ! cc jump 1b;\n":"=d"(loops)
  21. :"0"(loops));
  22. }
  23. /*
  24. * Use only for very small delays ( < 1 msec). Should probably use a
  25. * lookup table, really, as the multiplications take much too long with
  26. * short delays. This is a "reasonable" implementation, though (and the
  27. * first constant multiplications gets optimized away if the delay is
  28. * a constant)
  29. */
  30. static __inline__ void __udelay(unsigned long usecs)
  31. {
  32. __delay(usecs);
  33. }
  34. #endif