sleep.S 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * Low-level PXA250/210 sleep/wakeUp support
  3. *
  4. * Initial SA1110 code:
  5. * Copyright (c) 2001 Cliff Brake <cbrake@accelent.com>
  6. *
  7. * Adapted for PXA by Nicolas Pitre:
  8. * Copyright (c) 2002 Monta Vista Software, Inc.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License.
  12. */
  13. #include <linux/linkage.h>
  14. #include <asm/assembler.h>
  15. #include <mach/hardware.h>
  16. #include <mach/smemc.h>
  17. #include <mach/pxa2xx-regs.h>
  18. #define MDREFR_KDIV 0x200a4000 // all banks
  19. #define CCCR_SLEEP 0x00000107 // L=7 2N=2 A=0 PPDIS=0 CPDIS=0
  20. .text
  21. #ifdef CONFIG_PXA3xx
  22. /*
  23. * pxa3xx_cpu_suspend() - forces CPU into sleep state (S2D3C4)
  24. *
  25. * r0 = v:p offset
  26. */
  27. ENTRY(pxa3xx_cpu_suspend)
  28. #ifndef CONFIG_IWMMXT
  29. mra r2, r3, acc0
  30. #endif
  31. stmfd sp!, {r2 - r12, lr} @ save registers on stack
  32. mov r1, r0
  33. ldr r3, =pxa_cpu_resume @ resume function
  34. bl cpu_suspend
  35. mov r0, #0x06 @ S2D3C4 mode
  36. mcr p14, 0, r0, c7, c0, 0 @ enter sleep
  37. 20: b 20b @ waiting for sleep
  38. #endif /* CONFIG_PXA3xx */
  39. #ifdef CONFIG_PXA27x
  40. /*
  41. * pxa27x_cpu_suspend()
  42. *
  43. * Forces CPU into sleep state.
  44. *
  45. * r0 = value for PWRMODE M field for desired sleep state
  46. * r1 = v:p offset
  47. */
  48. ENTRY(pxa27x_cpu_suspend)
  49. #ifndef CONFIG_IWMMXT
  50. mra r2, r3, acc0
  51. #endif
  52. stmfd sp!, {r2 - r12, lr} @ save registers on stack
  53. mov r4, r0 @ save sleep mode
  54. ldr r3, =pxa_cpu_resume @ resume function
  55. bl cpu_suspend
  56. @ Put the processor to sleep
  57. @ (also workaround for sighting 28071)
  58. @ prepare value for sleep mode
  59. mov r1, r4 @ sleep mode
  60. @ prepare pointer to physical address 0 (virtual mapping in generic.c)
  61. mov r2, #UNCACHED_PHYS_0
  62. @ prepare SDRAM refresh settings
  63. ldr r4, =MDREFR
  64. ldr r5, [r4]
  65. @ enable SDRAM self-refresh mode
  66. orr r5, r5, #MDREFR_SLFRSH
  67. @ set SDCLKx divide-by-2 bits (this is part of a workaround for Errata 50)
  68. ldr r6, =MDREFR_KDIV
  69. orr r5, r5, r6
  70. @ Intel PXA270 Specification Update notes problems sleeping
  71. @ with core operating above 91 MHz
  72. @ (see Errata 50, ...processor does not exit from sleep...)
  73. ldr r6, =CCCR
  74. ldr r8, [r6] @ keep original value for resume
  75. ldr r7, =CCCR_SLEEP @ prepare CCCR sleep value
  76. mov r0, #0x2 @ prepare value for CLKCFG
  77. @ align execution to a cache line
  78. b pxa_cpu_do_suspend
  79. #endif
  80. #ifdef CONFIG_PXA25x
  81. /*
  82. * pxa25x_cpu_suspend()
  83. *
  84. * Forces CPU into sleep state.
  85. *
  86. * r0 = value for PWRMODE M field for desired sleep state
  87. * r1 = v:p offset
  88. */
  89. ENTRY(pxa25x_cpu_suspend)
  90. stmfd sp!, {r2 - r12, lr} @ save registers on stack
  91. mov r4, r0 @ save sleep mode
  92. ldr r3, =pxa_cpu_resume @ resume function
  93. bl cpu_suspend
  94. @ prepare value for sleep mode
  95. mov r1, r4 @ sleep mode
  96. @ prepare pointer to physical address 0 (virtual mapping in generic.c)
  97. mov r2, #UNCACHED_PHYS_0
  98. @ prepare SDRAM refresh settings
  99. ldr r4, =MDREFR
  100. ldr r5, [r4]
  101. @ enable SDRAM self-refresh mode
  102. orr r5, r5, #MDREFR_SLFRSH
  103. @ Intel PXA255 Specification Update notes problems
  104. @ about suspending with PXBus operating above 133MHz
  105. @ (see Errata 31, GPIO output signals, ... unpredictable in sleep
  106. @
  107. @ We keep the change-down close to the actual suspend on SDRAM
  108. @ as possible to eliminate messing about with the refresh clock
  109. @ as the system will restore with the original speed settings
  110. @
  111. @ Ben Dooks, 13-Sep-2004
  112. ldr r6, =CCCR
  113. ldr r8, [r6] @ keep original value for resume
  114. @ ensure x1 for run and turbo mode with memory clock
  115. bic r7, r8, #CCCR_M_MASK | CCCR_N_MASK
  116. orr r7, r7, #(1<<5) | (2<<7)
  117. @ check that the memory frequency is within limits
  118. and r14, r7, #CCCR_L_MASK
  119. teq r14, #1
  120. bicne r7, r7, #CCCR_L_MASK
  121. orrne r7, r7, #1 @@ 99.53MHz
  122. @ get ready for the change
  123. @ note, turbo is not preserved over sleep so there is no
  124. @ point in preserving it here. we save it on the stack with the
  125. @ other CP registers instead.
  126. mov r0, #0
  127. mcr p14, 0, r0, c6, c0, 0
  128. orr r0, r0, #2 @ initiate change bit
  129. b pxa_cpu_do_suspend
  130. #endif
  131. .ltorg
  132. .align 5
  133. pxa_cpu_do_suspend:
  134. @ All needed values are now in registers.
  135. @ These last instructions should be in cache
  136. @ initiate the frequency change...
  137. str r7, [r6]
  138. mcr p14, 0, r0, c6, c0, 0
  139. @ restore the original cpu speed value for resume
  140. str r8, [r6]
  141. @ need 6 13-MHz cycles before changing PWRMODE
  142. @ just set frequency to 91-MHz... 6*91/13 = 42
  143. mov r0, #42
  144. 10: subs r0, r0, #1
  145. bne 10b
  146. @ Do not reorder...
  147. @ Intel PXA270 Specification Update notes problems performing
  148. @ external accesses after SDRAM is put in self-refresh mode
  149. @ (see Errata 39 ...hangs when entering self-refresh mode)
  150. @ force address lines low by reading at physical address 0
  151. ldr r3, [r2]
  152. @ put SDRAM into self-refresh
  153. str r5, [r4]
  154. @ enter sleep mode
  155. mcr p14, 0, r1, c7, c0, 0 @ PWRMODE
  156. 20: b 20b @ loop waiting for sleep
  157. /*
  158. * pxa_cpu_resume()
  159. *
  160. * entry point from bootloader into kernel during resume
  161. */
  162. .align 5
  163. pxa_cpu_resume:
  164. ldmfd sp!, {r2, r3}
  165. #ifndef CONFIG_IWMMXT
  166. mar acc0, r2, r3
  167. #endif
  168. ldmfd sp!, {r4 - r12, pc} @ return to caller