delay.S 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * linux/arch/unicore32/lib/delay.S
  3. *
  4. * Code specific to PKUnity SoC and UniCore ISA
  5. *
  6. * Copyright (C) 2001-2010 GUAN Xue-tao
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/linkage.h>
  13. #include <asm/assembler.h>
  14. #include <asm/param.h>
  15. .text
  16. .LC0: .word loops_per_jiffy
  17. .LC1: .word (2199023*HZ)>>11
  18. /*
  19. * r0 <= 2000
  20. * lpj <= 0x01ffffff (max. 3355 bogomips)
  21. * HZ <= 1000
  22. */
  23. ENTRY(__udelay)
  24. ldw r2, .LC1
  25. mul r0, r2, r0
  26. ENTRY(__const_udelay) @ 0 <= r0 <= 0x7fffff06
  27. ldw r2, .LC0
  28. ldw r2, [r2] @ max = 0x01ffffff
  29. mov r0, r0 >> #14 @ max = 0x0001ffff
  30. mov r2, r2 >> #10 @ max = 0x00007fff
  31. mul r0, r2, r0 @ max = 2^32-1
  32. mov.a r0, r0 >> #6
  33. cmoveq pc, lr
  34. /*
  35. * loops = r0 * HZ * loops_per_jiffy / 1000000
  36. *
  37. * Oh, if only we had a cycle counter...
  38. */
  39. @ Delay routine
  40. ENTRY(__delay)
  41. sub.a r0, r0, #2
  42. bua __delay
  43. mov pc, lr
  44. ENDPROC(__udelay)
  45. ENDPROC(__const_udelay)
  46. ENDPROC(__delay)