sleep.S 9.1 KB

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