delay.S 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #include <asm/param.h>
  13. .text
  14. .LC0: .word loops_per_jiffy
  15. .LC1: .word (2199023*HZ)>>11
  16. /*
  17. * r0 <= 2000
  18. * lpj <= 0x01ffffff (max. 3355 bogomips)
  19. * HZ <= 1000
  20. */
  21. ENTRY(__udelay)
  22. ldr r2, .LC1
  23. mul r0, r2, r0
  24. ENTRY(__const_udelay) @ 0 <= r0 <= 0x7fffff06
  25. ldr r2, .LC0
  26. ldr r2, [r2] @ max = 0x01ffffff
  27. mov r0, r0, lsr #14 @ max = 0x0001ffff
  28. mov r2, r2, lsr #10 @ max = 0x00007fff
  29. mul r0, r2, r0 @ max = 2^32-1
  30. movs r0, r0, lsr #6
  31. moveq pc, lr
  32. /*
  33. * loops = r0 * HZ * loops_per_jiffy / 1000000
  34. *
  35. * Oh, if only we had a cycle counter...
  36. */
  37. @ Delay routine
  38. ENTRY(__delay)
  39. subs r0, r0, #1
  40. #if 0
  41. movls pc, lr
  42. subs r0, r0, #1
  43. movls pc, lr
  44. subs r0, r0, #1
  45. movls pc, lr
  46. subs r0, r0, #1
  47. movls pc, lr
  48. subs r0, r0, #1
  49. movls pc, lr
  50. subs r0, r0, #1
  51. movls pc, lr
  52. subs r0, r0, #1
  53. movls pc, lr
  54. subs r0, r0, #1
  55. #endif
  56. bhi __delay
  57. mov pc, lr