delay.S 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * linux/arch/arm/lib/delay.S
  3. *
  4. * Copyright (C) 1995, 1996 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/linkage.h>
  11. #include <asm/assembler.h>
  12. .text
  13. LC0: .word loops_per_jiffy
  14. /*
  15. * 0 <= r0 <= 2000
  16. */
  17. ENTRY(__udelay)
  18. mov r2, #0x6800
  19. orr r2, r2, #0x00db
  20. mul r0, r2, r0
  21. ENTRY(__const_udelay) @ 0 <= r0 <= 0x01ffffff
  22. ldr r2, LC0
  23. ldr r2, [r2] @ max = 0x0fffffff
  24. mov r0, r0, lsr #11 @ max = 0x00003fff
  25. mov r2, r2, lsr #11 @ max = 0x0003ffff
  26. mul r0, r2, r0 @ max = 2^32-1
  27. movs r0, r0, lsr #6
  28. RETINSTR(moveq,pc,lr)
  29. /*
  30. * loops = (r0 * 0x10c6 * 100 * loops_per_jiffy) / 2^32
  31. *
  32. * Oh, if only we had a cycle counter...
  33. */
  34. @ Delay routine
  35. ENTRY(__delay)
  36. subs r0, r0, #1
  37. #if 0
  38. RETINSTR(movls,pc,lr)
  39. subs r0, r0, #1
  40. RETINSTR(movls,pc,lr)
  41. subs r0, r0, #1
  42. RETINSTR(movls,pc,lr)
  43. subs r0, r0, #1
  44. RETINSTR(movls,pc,lr)
  45. subs r0, r0, #1
  46. RETINSTR(movls,pc,lr)
  47. subs r0, r0, #1
  48. RETINSTR(movls,pc,lr)
  49. subs r0, r0, #1
  50. RETINSTR(movls,pc,lr)
  51. subs r0, r0, #1
  52. #endif
  53. bhi __delay
  54. RETINSTR(mov,pc,lr)