sleep.S 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /*
  2. * linux/arch/arm/mach-omap1/sleep.S
  3. *
  4. * Low-level OMAP7XX/1510/1610 sleep/wakeUp support
  5. *
  6. * Initial SA1110 code:
  7. * Copyright (c) 2001 Cliff Brake <cbrake@accelent.com>
  8. *
  9. * Adapted for PXA by Nicolas Pitre:
  10. * Copyright (c) 2002 Monta Vista Software, Inc.
  11. *
  12. * Support for OMAP1510/1610 by Dirk Behme <dirk.behme@de.bosch.com>
  13. *
  14. * This program is free software; you can redistribute it and/or modify it
  15. * under the terms of the GNU General Public License as published by the
  16. * Free Software Foundation; either version 2 of the License, or (at your
  17. * option) any later version.
  18. *
  19. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  20. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  21. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  22. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  23. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  24. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  25. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  28. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. *
  30. * You should have received a copy of the GNU General Public License along
  31. * with this program; if not, write to the Free Software Foundation, Inc.,
  32. * 675 Mass Ave, Cambridge, MA 02139, USA.
  33. */
  34. #include <linux/linkage.h>
  35. #include <asm/assembler.h>
  36. #include "hardware.h"
  37. #include "iomap.h"
  38. #include "pm.h"
  39. .text
  40. /*
  41. * Forces OMAP into deep sleep state
  42. *
  43. * omapXXXX_cpu_suspend()
  44. *
  45. * The values of the registers ARM_IDLECT1 and ARM_IDLECT2 are passed
  46. * as arg0 and arg1 from caller. arg0 is stored in register r0 and arg1
  47. * in register r1.
  48. *
  49. * Note: This code get's copied to internal SRAM at boot. When the OMAP
  50. * wakes up it continues execution at the point it went to sleep.
  51. *
  52. * Note: Because of errata work arounds we have processor specific functions
  53. * here. They are mostly the same, but slightly different.
  54. *
  55. */
  56. #ifdef CONFIG_ARCH_OMAP15XX
  57. .align 3
  58. ENTRY(omap1510_cpu_suspend)
  59. @ save registers on stack
  60. stmfd sp!, {r0 - r12, lr}
  61. @ load base address of Traffic Controller
  62. mov r4, #TCMIF_ASM_BASE & 0xff000000
  63. orr r4, r4, #TCMIF_ASM_BASE & 0x00ff0000
  64. orr r4, r4, #TCMIF_ASM_BASE & 0x0000ff00
  65. @ work around errata of OMAP1510 PDE bit for TC shut down
  66. @ clear PDE bit
  67. ldr r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  68. bic r5, r5, #PDE_BIT & 0xff
  69. str r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  70. @ set PWD_EN bit
  71. and r5, r5, #PWD_EN_BIT & 0xff
  72. str r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  73. @ prepare to put SDRAM into self-refresh manually
  74. ldr r5, [r4, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
  75. orr r5, r5, #SELF_REFRESH_MODE & 0xff000000
  76. orr r5, r5, #SELF_REFRESH_MODE & 0x000000ff
  77. str r5, [r4, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
  78. @ prepare to put EMIFS to Sleep
  79. ldr r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  80. orr r5, r5, #IDLE_EMIFS_REQUEST & 0xff
  81. str r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  82. @ load base address of ARM_IDLECT1 and ARM_IDLECT2
  83. mov r4, #CLKGEN_REG_ASM_BASE & 0xff000000
  84. orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x00ff0000
  85. orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x0000ff00
  86. @ turn off clock domains
  87. mov r5, #OMAP1510_IDLE_CLOCK_DOMAINS & 0xff
  88. orr r5, r5, #OMAP1510_IDLE_CLOCK_DOMAINS & 0xff00
  89. strh r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
  90. @ request ARM idle
  91. mov r3, #OMAP1510_DEEP_SLEEP_REQUEST & 0xff
  92. orr r3, r3, #OMAP1510_DEEP_SLEEP_REQUEST & 0xff00
  93. strh r3, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
  94. mov r5, #IDLE_WAIT_CYCLES & 0xff
  95. orr r5, r5, #IDLE_WAIT_CYCLES & 0xff00
  96. l_1510_2:
  97. subs r5, r5, #1
  98. bne l_1510_2
  99. /*
  100. * Let's wait for the next wake up event to wake us up. r0 can't be
  101. * used here because r0 holds ARM_IDLECT1
  102. */
  103. mov r2, #0
  104. mcr p15, 0, r2, c7, c0, 4 @ wait for interrupt
  105. /*
  106. * omap1510_cpu_suspend()'s resume point.
  107. *
  108. * It will just start executing here, so we'll restore stuff from the
  109. * stack, reset the ARM_IDLECT1 and ARM_IDLECT2.
  110. */
  111. strh r1, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
  112. strh r0, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
  113. @ restore regs and return
  114. ldmfd sp!, {r0 - r12, pc}
  115. ENTRY(omap1510_cpu_suspend_sz)
  116. .word . - omap1510_cpu_suspend
  117. #endif /* CONFIG_ARCH_OMAP15XX */
  118. #if defined(CONFIG_ARCH_OMAP16XX)
  119. .align 3
  120. ENTRY(omap1610_cpu_suspend)
  121. @ save registers on stack
  122. stmfd sp!, {r0 - r12, lr}
  123. @ Drain write cache
  124. mov r4, #0
  125. mcr p15, 0, r0, c7, c10, 4
  126. nop
  127. @ Load base address of Traffic Controller
  128. mov r6, #TCMIF_ASM_BASE & 0xff000000
  129. orr r6, r6, #TCMIF_ASM_BASE & 0x00ff0000
  130. orr r6, r6, #TCMIF_ASM_BASE & 0x0000ff00
  131. @ Prepare to put SDRAM into self-refresh manually
  132. ldr r7, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
  133. orr r9, r7, #SELF_REFRESH_MODE & 0xff000000
  134. orr r9, r9, #SELF_REFRESH_MODE & 0x000000ff
  135. str r9, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
  136. @ Prepare to put EMIFS to Sleep
  137. ldr r8, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  138. orr r9, r8, #IDLE_EMIFS_REQUEST & 0xff
  139. str r9, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  140. @ Load base address of ARM_IDLECT1 and ARM_IDLECT2
  141. mov r4, #CLKGEN_REG_ASM_BASE & 0xff000000
  142. orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x00ff0000
  143. orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x0000ff00
  144. @ Turn off clock domains
  145. @ Do not disable PERCK (0x04)
  146. mov r5, #OMAP1610_IDLECT2_SLEEP_VAL & 0xff
  147. orr r5, r5, #OMAP1610_IDLECT2_SLEEP_VAL & 0xff00
  148. strh r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
  149. @ Request ARM idle
  150. mov r3, #OMAP1610_IDLECT1_SLEEP_VAL & 0xff
  151. orr r3, r3, #OMAP1610_IDLECT1_SLEEP_VAL & 0xff00
  152. strh r3, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
  153. /*
  154. * Let's wait for the next wake up event to wake us up. r0 can't be
  155. * used here because r0 holds ARM_IDLECT1
  156. */
  157. mov r2, #0
  158. mcr p15, 0, r2, c7, c0, 4 @ wait for interrupt
  159. @ Errata (HEL3SU467, section 1.4.4) specifies nop-instructions
  160. @ according to this formula:
  161. @ 2 + (4*DPLL_MULT)/DPLL_DIV/ARMDIV
  162. @ Max DPLL_MULT = 18
  163. @ DPLL_DIV = 1
  164. @ ARMDIV = 1
  165. @ => 74 nop-instructions
  166. nop
  167. nop
  168. nop
  169. nop
  170. nop
  171. nop
  172. nop
  173. nop
  174. nop
  175. nop @10
  176. nop
  177. nop
  178. nop
  179. nop
  180. nop
  181. nop
  182. nop
  183. nop
  184. nop
  185. nop @20
  186. nop
  187. nop
  188. nop
  189. nop
  190. nop
  191. nop
  192. nop
  193. nop
  194. nop
  195. nop @30
  196. nop
  197. nop
  198. nop
  199. nop
  200. nop
  201. nop
  202. nop
  203. nop
  204. nop
  205. nop @40
  206. nop
  207. nop
  208. nop
  209. nop
  210. nop
  211. nop
  212. nop
  213. nop
  214. nop
  215. nop @50
  216. nop
  217. nop
  218. nop
  219. nop
  220. nop
  221. nop
  222. nop
  223. nop
  224. nop
  225. nop @60
  226. nop
  227. nop
  228. nop
  229. nop
  230. nop
  231. nop
  232. nop
  233. nop
  234. nop
  235. nop @70
  236. nop
  237. nop
  238. nop
  239. nop @74
  240. /*
  241. * omap1610_cpu_suspend()'s resume point.
  242. *
  243. * It will just start executing here, so we'll restore stuff from the
  244. * stack.
  245. */
  246. @ Restore the ARM_IDLECT1 and ARM_IDLECT2.
  247. strh r1, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
  248. strh r0, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
  249. @ Restore EMIFF controls
  250. str r7, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
  251. str r8, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  252. @ Restore regs and return
  253. ldmfd sp!, {r0 - r12, pc}
  254. ENTRY(omap1610_cpu_suspend_sz)
  255. .word . - omap1610_cpu_suspend
  256. #endif /* CONFIG_ARCH_OMAP16XX */