sleep.S 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. /*
  2. * linux/arch/arm/mach-omap1/sleep.S
  3. *
  4. * Low-level OMAP730/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 <mach/io.h>
  37. #include <mach/pm.h>
  38. .text
  39. /*
  40. * Forces OMAP into deep sleep state
  41. *
  42. * omapXXXX_cpu_suspend()
  43. *
  44. * The values of the registers ARM_IDLECT1 and ARM_IDLECT2 are passed
  45. * as arg0 and arg1 from caller. arg0 is stored in register r0 and arg1
  46. * in register r1.
  47. *
  48. * Note: This code get's copied to internal SRAM at boot. When the OMAP
  49. * wakes up it continues execution at the point it went to sleep.
  50. *
  51. * Note: Because of errata work arounds we have processor specific functions
  52. * here. They are mostly the same, but slightly different.
  53. *
  54. */
  55. #if defined(CONFIG_ARCH_OMAP730)
  56. ENTRY(omap730_cpu_suspend)
  57. @ save registers on stack
  58. stmfd sp!, {r0 - r12, lr}
  59. @ Drain write cache
  60. mov r4, #0
  61. mcr p15, 0, r0, c7, c10, 4
  62. nop
  63. @ load base address of Traffic Controller
  64. mov r6, #TCMIF_ASM_BASE & 0xff000000
  65. orr r6, r6, #TCMIF_ASM_BASE & 0x00ff0000
  66. orr r6, r6, #TCMIF_ASM_BASE & 0x0000ff00
  67. @ prepare to put SDRAM into self-refresh manually
  68. ldr r7, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
  69. orr r9, r7, #SELF_REFRESH_MODE & 0xff000000
  70. orr r9, r9, #SELF_REFRESH_MODE & 0x000000ff
  71. str r9, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
  72. @ prepare to put EMIFS to Sleep
  73. ldr r8, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  74. orr r9, r8, #IDLE_EMIFS_REQUEST & 0xff
  75. str r9, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  76. @ load base address of ARM_IDLECT1 and ARM_IDLECT2
  77. mov r4, #CLKGEN_REG_ASM_BASE & 0xff000000
  78. orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x00ff0000
  79. orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x0000ff00
  80. @ turn off clock domains
  81. @ do not disable PERCK (0x04)
  82. mov r5, #OMAP730_IDLECT2_SLEEP_VAL & 0xff
  83. orr r5, r5, #OMAP730_IDLECT2_SLEEP_VAL & 0xff00
  84. strh r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
  85. @ request ARM idle
  86. mov r3, #OMAP730_IDLECT1_SLEEP_VAL & 0xff
  87. orr r3, r3, #OMAP730_IDLECT1_SLEEP_VAL & 0xff00
  88. strh r3, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
  89. @ disable instruction cache
  90. mrc p15, 0, r9, c1, c0, 0
  91. bic r2, r9, #0x1000
  92. mcr p15, 0, r2, c1, c0, 0
  93. nop
  94. /*
  95. * Let's wait for the next wake up event to wake us up. r0 can't be
  96. * used here because r0 holds ARM_IDLECT1
  97. */
  98. mov r2, #0
  99. mcr p15, 0, r2, c7, c0, 4 @ wait for interrupt
  100. /*
  101. * omap730_cpu_suspend()'s resume point.
  102. *
  103. * It will just start executing here, so we'll restore stuff from the
  104. * stack.
  105. */
  106. @ re-enable Icache
  107. mcr p15, 0, r9, c1, c0, 0
  108. @ reset the ARM_IDLECT1 and ARM_IDLECT2.
  109. strh r1, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
  110. strh r0, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
  111. @ Restore EMIFF controls
  112. str r7, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
  113. str r8, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  114. @ restore regs and return
  115. ldmfd sp!, {r0 - r12, pc}
  116. ENTRY(omap730_cpu_suspend_sz)
  117. .word . - omap730_cpu_suspend
  118. #endif /* CONFIG_ARCH_OMAP730 */
  119. #ifdef CONFIG_ARCH_OMAP15XX
  120. ENTRY(omap1510_cpu_suspend)
  121. @ save registers on stack
  122. stmfd sp!, {r0 - r12, lr}
  123. @ load base address of Traffic Controller
  124. mov r4, #TCMIF_ASM_BASE & 0xff000000
  125. orr r4, r4, #TCMIF_ASM_BASE & 0x00ff0000
  126. orr r4, r4, #TCMIF_ASM_BASE & 0x0000ff00
  127. @ work around errata of OMAP1510 PDE bit for TC shut down
  128. @ clear PDE bit
  129. ldr r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  130. bic r5, r5, #PDE_BIT & 0xff
  131. str r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  132. @ set PWD_EN bit
  133. and r5, r5, #PWD_EN_BIT & 0xff
  134. str r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  135. @ prepare to put SDRAM into self-refresh manually
  136. ldr r5, [r4, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
  137. orr r5, r5, #SELF_REFRESH_MODE & 0xff000000
  138. orr r5, r5, #SELF_REFRESH_MODE & 0x000000ff
  139. str r5, [r4, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
  140. @ prepare to put EMIFS to Sleep
  141. ldr r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  142. orr r5, r5, #IDLE_EMIFS_REQUEST & 0xff
  143. str r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  144. @ load base address of ARM_IDLECT1 and ARM_IDLECT2
  145. mov r4, #CLKGEN_REG_ASM_BASE & 0xff000000
  146. orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x00ff0000
  147. orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x0000ff00
  148. @ turn off clock domains
  149. mov r5, #OMAP1510_IDLE_CLOCK_DOMAINS & 0xff
  150. orr r5, r5, #OMAP1510_IDLE_CLOCK_DOMAINS & 0xff00
  151. strh r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
  152. @ request ARM idle
  153. mov r3, #OMAP1510_DEEP_SLEEP_REQUEST & 0xff
  154. orr r3, r3, #OMAP1510_DEEP_SLEEP_REQUEST & 0xff00
  155. strh r3, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
  156. mov r5, #IDLE_WAIT_CYCLES & 0xff
  157. orr r5, r5, #IDLE_WAIT_CYCLES & 0xff00
  158. l_1510_2:
  159. subs r5, r5, #1
  160. bne l_1510_2
  161. /*
  162. * Let's wait for the next wake up event to wake us up. r0 can't be
  163. * used here because r0 holds ARM_IDLECT1
  164. */
  165. mov r2, #0
  166. mcr p15, 0, r2, c7, c0, 4 @ wait for interrupt
  167. /*
  168. * omap1510_cpu_suspend()'s resume point.
  169. *
  170. * It will just start executing here, so we'll restore stuff from the
  171. * stack, reset the ARM_IDLECT1 and ARM_IDLECT2.
  172. */
  173. strh r1, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
  174. strh r0, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
  175. @ restore regs and return
  176. ldmfd sp!, {r0 - r12, pc}
  177. ENTRY(omap1510_cpu_suspend_sz)
  178. .word . - omap1510_cpu_suspend
  179. #endif /* CONFIG_ARCH_OMAP15XX */
  180. #if defined(CONFIG_ARCH_OMAP16XX)
  181. ENTRY(omap1610_cpu_suspend)
  182. @ save registers on stack
  183. stmfd sp!, {r0 - r12, lr}
  184. @ Drain write cache
  185. mov r4, #0
  186. mcr p15, 0, r0, c7, c10, 4
  187. nop
  188. @ Load base address of Traffic Controller
  189. mov r6, #TCMIF_ASM_BASE & 0xff000000
  190. orr r6, r6, #TCMIF_ASM_BASE & 0x00ff0000
  191. orr r6, r6, #TCMIF_ASM_BASE & 0x0000ff00
  192. @ Prepare to put SDRAM into self-refresh manually
  193. ldr r7, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
  194. orr r9, r7, #SELF_REFRESH_MODE & 0xff000000
  195. orr r9, r9, #SELF_REFRESH_MODE & 0x000000ff
  196. str r9, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
  197. @ Prepare to put EMIFS to Sleep
  198. ldr r8, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  199. orr r9, r8, #IDLE_EMIFS_REQUEST & 0xff
  200. str r9, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  201. @ Load base address of ARM_IDLECT1 and ARM_IDLECT2
  202. mov r4, #CLKGEN_REG_ASM_BASE & 0xff000000
  203. orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x00ff0000
  204. orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x0000ff00
  205. @ Turn off clock domains
  206. @ Do not disable PERCK (0x04)
  207. mov r5, #OMAP1610_IDLECT2_SLEEP_VAL & 0xff
  208. orr r5, r5, #OMAP1610_IDLECT2_SLEEP_VAL & 0xff00
  209. strh r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
  210. @ Request ARM idle
  211. mov r3, #OMAP1610_IDLECT1_SLEEP_VAL & 0xff
  212. orr r3, r3, #OMAP1610_IDLECT1_SLEEP_VAL & 0xff00
  213. strh r3, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
  214. /*
  215. * Let's wait for the next wake up event to wake us up. r0 can't be
  216. * used here because r0 holds ARM_IDLECT1
  217. */
  218. mov r2, #0
  219. mcr p15, 0, r2, c7, c0, 4 @ wait for interrupt
  220. @ Errata (HEL3SU467, section 1.4.4) specifies nop-instructions
  221. @ according to this formula:
  222. @ 2 + (4*DPLL_MULT)/DPLL_DIV/ARMDIV
  223. @ Max DPLL_MULT = 18
  224. @ DPLL_DIV = 1
  225. @ ARMDIV = 1
  226. @ => 74 nop-instructions
  227. nop
  228. nop
  229. nop
  230. nop
  231. nop
  232. nop
  233. nop
  234. nop
  235. nop
  236. nop @10
  237. nop
  238. nop
  239. nop
  240. nop
  241. nop
  242. nop
  243. nop
  244. nop
  245. nop
  246. nop @20
  247. nop
  248. nop
  249. nop
  250. nop
  251. nop
  252. nop
  253. nop
  254. nop
  255. nop
  256. nop @30
  257. nop
  258. nop
  259. nop
  260. nop
  261. nop
  262. nop
  263. nop
  264. nop
  265. nop
  266. nop @40
  267. nop
  268. nop
  269. nop
  270. nop
  271. nop
  272. nop
  273. nop
  274. nop
  275. nop
  276. nop @50
  277. nop
  278. nop
  279. nop
  280. nop
  281. nop
  282. nop
  283. nop
  284. nop
  285. nop
  286. nop @60
  287. nop
  288. nop
  289. nop
  290. nop
  291. nop
  292. nop
  293. nop
  294. nop
  295. nop
  296. nop @70
  297. nop
  298. nop
  299. nop
  300. nop @74
  301. /*
  302. * omap1610_cpu_suspend()'s resume point.
  303. *
  304. * It will just start executing here, so we'll restore stuff from the
  305. * stack.
  306. */
  307. @ Restore the ARM_IDLECT1 and ARM_IDLECT2.
  308. strh r1, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
  309. strh r0, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
  310. @ Restore EMIFF controls
  311. str r7, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
  312. str r8, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
  313. @ Restore regs and return
  314. ldmfd sp!, {r0 - r12, pc}
  315. ENTRY(omap1610_cpu_suspend_sz)
  316. .word . - omap1610_cpu_suspend
  317. #endif /* CONFIG_ARCH_OMAP16XX */