sleep.S 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. adr r3, BSYM(pxa3xx_finish_suspend)
  34. bl cpu_suspend
  35. b pxa_cpu_resume
  36. pxa3xx_finish_suspend:
  37. mov r0, #0x06 @ S2D3C4 mode
  38. mcr p14, 0, r0, c7, c0, 0 @ enter sleep
  39. 20: b 20b @ waiting for sleep
  40. #endif /* CONFIG_PXA3xx */
  41. #ifdef CONFIG_PXA27x
  42. /*
  43. * pxa27x_cpu_suspend()
  44. *
  45. * Forces CPU into sleep state.
  46. *
  47. * r0 = value for PWRMODE M field for desired sleep state
  48. * r1 = v:p offset
  49. */
  50. ENTRY(pxa27x_cpu_suspend)
  51. #ifndef CONFIG_IWMMXT
  52. mra r2, r3, acc0
  53. #endif
  54. stmfd sp!, {r2 - r12, lr} @ save registers on stack
  55. mov r2, r0 @ save sleep mode
  56. adr r3, BSYM(pxa27x_finish_suspend)
  57. bl cpu_suspend
  58. b pxa_cpu_resume
  59. pxa27x_finish_suspend:
  60. @ Put the processor to sleep
  61. @ (also workaround for sighting 28071)
  62. @ prepare value for sleep mode
  63. mov r1, r0 @ sleep mode
  64. @ prepare pointer to physical address 0 (virtual mapping in generic.c)
  65. mov r2, #UNCACHED_PHYS_0
  66. @ prepare SDRAM refresh settings
  67. ldr r4, =MDREFR
  68. ldr r5, [r4]
  69. @ enable SDRAM self-refresh mode
  70. orr r5, r5, #MDREFR_SLFRSH
  71. @ set SDCLKx divide-by-2 bits (this is part of a workaround for Errata 50)
  72. ldr r6, =MDREFR_KDIV
  73. orr r5, r5, r6
  74. @ Intel PXA270 Specification Update notes problems sleeping
  75. @ with core operating above 91 MHz
  76. @ (see Errata 50, ...processor does not exit from sleep...)
  77. ldr r6, =CCCR
  78. ldr r8, [r6] @ keep original value for resume
  79. ldr r7, =CCCR_SLEEP @ prepare CCCR sleep value
  80. mov r0, #0x2 @ prepare value for CLKCFG
  81. @ align execution to a cache line
  82. b pxa_cpu_do_suspend
  83. #endif
  84. #ifdef CONFIG_PXA25x
  85. /*
  86. * pxa25x_cpu_suspend()
  87. *
  88. * Forces CPU into sleep state.
  89. *
  90. * r0 = value for PWRMODE M field for desired sleep state
  91. * r1 = v:p offset
  92. */
  93. ENTRY(pxa25x_cpu_suspend)
  94. stmfd sp!, {r2 - r12, lr} @ save registers on stack
  95. mov r2, r0 @ save sleep mode
  96. adr r3, BSYM(pxa25x_finish_suspend)
  97. bl cpu_suspend
  98. b pxa_cpu_resume
  99. pxa25x_finish_suspend:
  100. @ prepare value for sleep mode
  101. mov r1, r0 @ sleep mode
  102. @ prepare pointer to physical address 0 (virtual mapping in generic.c)
  103. mov r2, #UNCACHED_PHYS_0
  104. @ prepare SDRAM refresh settings
  105. ldr r4, =MDREFR
  106. ldr r5, [r4]
  107. @ enable SDRAM self-refresh mode
  108. orr r5, r5, #MDREFR_SLFRSH
  109. @ Intel PXA255 Specification Update notes problems
  110. @ about suspending with PXBus operating above 133MHz
  111. @ (see Errata 31, GPIO output signals, ... unpredictable in sleep
  112. @
  113. @ We keep the change-down close to the actual suspend on SDRAM
  114. @ as possible to eliminate messing about with the refresh clock
  115. @ as the system will restore with the original speed settings
  116. @
  117. @ Ben Dooks, 13-Sep-2004
  118. ldr r6, =CCCR
  119. ldr r8, [r6] @ keep original value for resume
  120. @ ensure x1 for run and turbo mode with memory clock
  121. bic r7, r8, #CCCR_M_MASK | CCCR_N_MASK
  122. orr r7, r7, #(1<<5) | (2<<7)
  123. @ check that the memory frequency is within limits
  124. and r14, r7, #CCCR_L_MASK
  125. teq r14, #1
  126. bicne r7, r7, #CCCR_L_MASK
  127. orrne r7, r7, #1 @@ 99.53MHz
  128. @ get ready for the change
  129. @ note, turbo is not preserved over sleep so there is no
  130. @ point in preserving it here. we save it on the stack with the
  131. @ other CP registers instead.
  132. mov r0, #0
  133. mcr p14, 0, r0, c6, c0, 0
  134. orr r0, r0, #2 @ initiate change bit
  135. b pxa_cpu_do_suspend
  136. #endif
  137. .ltorg
  138. .align 5
  139. pxa_cpu_do_suspend:
  140. @ All needed values are now in registers.
  141. @ These last instructions should be in cache
  142. @ initiate the frequency change...
  143. str r7, [r6]
  144. mcr p14, 0, r0, c6, c0, 0
  145. @ restore the original cpu speed value for resume
  146. str r8, [r6]
  147. @ need 6 13-MHz cycles before changing PWRMODE
  148. @ just set frequency to 91-MHz... 6*91/13 = 42
  149. mov r0, #42
  150. 10: subs r0, r0, #1
  151. bne 10b
  152. @ Do not reorder...
  153. @ Intel PXA270 Specification Update notes problems performing
  154. @ external accesses after SDRAM is put in self-refresh mode
  155. @ (see Errata 39 ...hangs when entering self-refresh mode)
  156. @ force address lines low by reading at physical address 0
  157. ldr r3, [r2]
  158. @ put SDRAM into self-refresh
  159. str r5, [r4]
  160. @ enter sleep mode
  161. mcr p14, 0, r1, c7, c0, 0 @ PWRMODE
  162. 20: b 20b @ loop waiting for sleep
  163. /*
  164. * pxa_cpu_resume()
  165. *
  166. * entry point from bootloader into kernel during resume
  167. */
  168. .align 5
  169. pxa_cpu_resume:
  170. ldmfd sp!, {r2, r3}
  171. #ifndef CONFIG_IWMMXT
  172. mar acc0, r2, r3
  173. #endif
  174. ldmfd sp!, {r4 - r12, pc} @ return to caller