sleep34xx.S 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. /*
  2. * linux/arch/arm/mach-omap2/sleep.S
  3. *
  4. * (C) Copyright 2007
  5. * Texas Instruments
  6. * Karthik Dasu <karthik-dp@ti.com>
  7. *
  8. * (C) Copyright 2004
  9. * Texas Instruments, <www.ti.com>
  10. * Richard Woodruff <r-woodruff2@ti.com>
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. #include <linux/linkage.h>
  28. #include <asm/assembler.h>
  29. #include <plat/sram.h>
  30. #include <mach/io.h>
  31. #include "cm.h"
  32. #include "prm.h"
  33. #include "sdrc.h"
  34. #include "control.h"
  35. #define SDRC_SCRATCHPAD_SEM_V 0xfa00291c
  36. #define PM_PREPWSTST_CORE_P 0x48306AE8
  37. #define PM_PWSTCTRL_MPU_P OMAP3430_PRM_BASE + MPU_MOD + OMAP2_PM_PWSTCTRL
  38. #define CM_IDLEST1_CORE_V OMAP34XX_CM_REGADDR(CORE_MOD, CM_IDLEST1)
  39. #define CM_IDLEST_CKGEN_V OMAP34XX_CM_REGADDR(PLL_MOD, CM_IDLEST)
  40. #define SRAM_BASE_P 0x40200000
  41. #define CONTROL_STAT 0x480022F0
  42. #define CONTROL_MEM_RTA_CTRL (OMAP343X_CTRL_BASE\
  43. + OMAP36XX_CONTROL_MEM_RTA_CTRL)
  44. #define SCRATCHPAD_MEM_OFFS 0x310 /* Move this as correct place is
  45. * available */
  46. #define SCRATCHPAD_BASE_P (OMAP343X_CTRL_BASE + OMAP343X_CONTROL_MEM_WKUP\
  47. + SCRATCHPAD_MEM_OFFS)
  48. #define SDRC_POWER_V OMAP34XX_SDRC_REGADDR(SDRC_POWER)
  49. #define SDRC_SYSCONFIG_P (OMAP343X_SDRC_BASE + SDRC_SYSCONFIG)
  50. #define SDRC_MR_0_P (OMAP343X_SDRC_BASE + SDRC_MR_0)
  51. #define SDRC_EMR2_0_P (OMAP343X_SDRC_BASE + SDRC_EMR2_0)
  52. #define SDRC_MANUAL_0_P (OMAP343X_SDRC_BASE + SDRC_MANUAL_0)
  53. #define SDRC_MR_1_P (OMAP343X_SDRC_BASE + SDRC_MR_1)
  54. #define SDRC_EMR2_1_P (OMAP343X_SDRC_BASE + SDRC_EMR2_1)
  55. #define SDRC_MANUAL_1_P (OMAP343X_SDRC_BASE + SDRC_MANUAL_1)
  56. #define SDRC_DLLA_STATUS_V OMAP34XX_SDRC_REGADDR(SDRC_DLLA_STATUS)
  57. #define SDRC_DLLA_CTRL_V OMAP34XX_SDRC_REGADDR(SDRC_DLLA_CTRL)
  58. /*
  59. * API functions
  60. */
  61. .text
  62. /* Function call to get the restore pointer for resume from OFF */
  63. ENTRY(get_restore_pointer)
  64. stmfd sp!, {lr} @ save registers on stack
  65. adr r0, restore
  66. ldmfd sp!, {pc} @ restore regs and return
  67. ENTRY(get_restore_pointer_sz)
  68. .word . - get_restore_pointer
  69. .text
  70. /* Function call to get the restore pointer for 3630 resume from OFF */
  71. ENTRY(get_omap3630_restore_pointer)
  72. stmfd sp!, {lr} @ save registers on stack
  73. adr r0, restore_3630
  74. ldmfd sp!, {pc} @ restore regs and return
  75. ENTRY(get_omap3630_restore_pointer_sz)
  76. .word . - get_omap3630_restore_pointer
  77. .text
  78. /*
  79. * L2 cache needs to be toggled for stable OFF mode functionality on 3630.
  80. * This function sets up a fflag that will allow for this toggling to take
  81. * place on 3630. Hopefully some version in the future maynot need this
  82. */
  83. ENTRY(enable_omap3630_toggle_l2_on_restore)
  84. stmfd sp!, {lr} @ save registers on stack
  85. /* Setup so that we will disable and enable l2 */
  86. mov r1, #0x1
  87. str r1, l2dis_3630
  88. ldmfd sp!, {pc} @ restore regs and return
  89. .text
  90. /* Function call to get the restore pointer for for ES3 to resume from OFF */
  91. ENTRY(get_es3_restore_pointer)
  92. stmfd sp!, {lr} @ save registers on stack
  93. adr r0, restore_es3
  94. ldmfd sp!, {pc} @ restore regs and return
  95. ENTRY(get_es3_restore_pointer_sz)
  96. .word . - get_es3_restore_pointer
  97. ENTRY(es3_sdrc_fix)
  98. ldr r4, sdrc_syscfg @ get config addr
  99. ldr r5, [r4] @ get value
  100. tst r5, #0x100 @ is part access blocked
  101. it eq
  102. biceq r5, r5, #0x100 @ clear bit if set
  103. str r5, [r4] @ write back change
  104. ldr r4, sdrc_mr_0 @ get config addr
  105. ldr r5, [r4] @ get value
  106. str r5, [r4] @ write back change
  107. ldr r4, sdrc_emr2_0 @ get config addr
  108. ldr r5, [r4] @ get value
  109. str r5, [r4] @ write back change
  110. ldr r4, sdrc_manual_0 @ get config addr
  111. mov r5, #0x2 @ autorefresh command
  112. str r5, [r4] @ kick off refreshes
  113. ldr r4, sdrc_mr_1 @ get config addr
  114. ldr r5, [r4] @ get value
  115. str r5, [r4] @ write back change
  116. ldr r4, sdrc_emr2_1 @ get config addr
  117. ldr r5, [r4] @ get value
  118. str r5, [r4] @ write back change
  119. ldr r4, sdrc_manual_1 @ get config addr
  120. mov r5, #0x2 @ autorefresh command
  121. str r5, [r4] @ kick off refreshes
  122. bx lr
  123. sdrc_syscfg:
  124. .word SDRC_SYSCONFIG_P
  125. sdrc_mr_0:
  126. .word SDRC_MR_0_P
  127. sdrc_emr2_0:
  128. .word SDRC_EMR2_0_P
  129. sdrc_manual_0:
  130. .word SDRC_MANUAL_0_P
  131. sdrc_mr_1:
  132. .word SDRC_MR_1_P
  133. sdrc_emr2_1:
  134. .word SDRC_EMR2_1_P
  135. sdrc_manual_1:
  136. .word SDRC_MANUAL_1_P
  137. ENTRY(es3_sdrc_fix_sz)
  138. .word . - es3_sdrc_fix
  139. /* Function to call rom code to save secure ram context */
  140. ENTRY(save_secure_ram_context)
  141. stmfd sp!, {r1-r12, lr} @ save registers on stack
  142. adr r3, api_params @ r3 points to parameters
  143. str r0, [r3,#0x4] @ r0 has sdram address
  144. ldr r12, high_mask
  145. and r3, r3, r12
  146. ldr r12, sram_phy_addr_mask
  147. orr r3, r3, r12
  148. mov r0, #25 @ set service ID for PPA
  149. mov r12, r0 @ copy secure service ID in r12
  150. mov r1, #0 @ set task id for ROM code in r1
  151. mov r2, #4 @ set some flags in r2, r6
  152. mov r6, #0xff
  153. mcr p15, 0, r0, c7, c10, 4 @ data write barrier
  154. mcr p15, 0, r0, c7, c10, 5 @ data memory barrier
  155. .word 0xE1600071 @ call SMI monitor (smi #1)
  156. nop
  157. nop
  158. nop
  159. nop
  160. ldmfd sp!, {r1-r12, pc}
  161. sram_phy_addr_mask:
  162. .word SRAM_BASE_P
  163. high_mask:
  164. .word 0xffff
  165. api_params:
  166. .word 0x4, 0x0, 0x0, 0x1, 0x1
  167. ENTRY(save_secure_ram_context_sz)
  168. .word . - save_secure_ram_context
  169. /*
  170. * Forces OMAP into idle state
  171. *
  172. * omap34xx_suspend() - This bit of code just executes the WFI
  173. * for normal idles.
  174. *
  175. * Note: This code get's copied to internal SRAM at boot. When the OMAP
  176. * wakes up it continues execution at the point it went to sleep.
  177. */
  178. ENTRY(omap34xx_cpu_suspend)
  179. stmfd sp!, {r0-r12, lr} @ save registers on stack
  180. /* r0 contains restore pointer in sdram */
  181. /* r1 contains information about saving context */
  182. ldr r4, sdrc_power @ read the SDRC_POWER register
  183. ldr r5, [r4] @ read the contents of SDRC_POWER
  184. orr r5, r5, #0x40 @ enable self refresh on idle req
  185. str r5, [r4] @ write back to SDRC_POWER register
  186. cmp r1, #0x0
  187. /* If context save is required, do that and execute wfi */
  188. bne save_context_wfi
  189. /* Data memory barrier and Data sync barrier */
  190. mov r1, #0
  191. mcr p15, 0, r1, c7, c10, 4
  192. mcr p15, 0, r1, c7, c10, 5
  193. wfi @ wait for interrupt
  194. nop
  195. nop
  196. nop
  197. nop
  198. nop
  199. nop
  200. nop
  201. nop
  202. nop
  203. nop
  204. bl wait_sdrc_ok
  205. ldmfd sp!, {r0-r12, pc} @ restore regs and return
  206. restore_es3:
  207. ldr r5, pm_prepwstst_core_p
  208. ldr r4, [r5]
  209. and r4, r4, #0x3
  210. cmp r4, #0x0 @ Check if previous power state of CORE is OFF
  211. bne restore
  212. adr r0, es3_sdrc_fix
  213. ldr r1, sram_base
  214. ldr r2, es3_sdrc_fix_sz
  215. mov r2, r2, ror #2
  216. copy_to_sram:
  217. ldmia r0!, {r3} @ val = *src
  218. stmia r1!, {r3} @ *dst = val
  219. subs r2, r2, #0x1 @ num_words--
  220. bne copy_to_sram
  221. ldr r1, sram_base
  222. blx r1
  223. b restore
  224. restore_3630:
  225. ldr r1, pm_prepwstst_core_p
  226. ldr r2, [r1]
  227. and r2, r2, #0x3
  228. cmp r2, #0x0 @ Check if previous power state of CORE is OFF
  229. bne restore
  230. /* Disable RTA before giving control */
  231. ldr r1, control_mem_rta
  232. mov r2, #OMAP36XX_RTA_DISABLE
  233. str r2, [r1]
  234. /* Fall thru for the remaining logic */
  235. restore:
  236. /* Check what was the reason for mpu reset and store the reason in r9*/
  237. /* 1 - Only L1 and logic lost */
  238. /* 2 - Only L2 lost - In this case, we wont be here */
  239. /* 3 - Both L1 and L2 lost */
  240. ldr r1, pm_pwstctrl_mpu
  241. ldr r2, [r1]
  242. and r2, r2, #0x3
  243. cmp r2, #0x0 @ Check if target power state was OFF or RET
  244. moveq r9, #0x3 @ MPU OFF => L1 and L2 lost
  245. movne r9, #0x1 @ Only L1 and L2 lost => avoid L2 invalidation
  246. bne logic_l1_restore
  247. ldr r0, l2dis_3630
  248. cmp r0, #0x1 @ should we disable L2 on 3630?
  249. bne skipl2dis
  250. mrc p15, 0, r0, c1, c0, 1
  251. bic r0, r0, #2 @ disable L2 cache
  252. mcr p15, 0, r0, c1, c0, 1
  253. skipl2dis:
  254. ldr r0, control_stat
  255. ldr r1, [r0]
  256. and r1, #0x700
  257. cmp r1, #0x300
  258. beq l2_inv_gp
  259. mov r0, #40 @ set service ID for PPA
  260. mov r12, r0 @ copy secure Service ID in r12
  261. mov r1, #0 @ set task id for ROM code in r1
  262. mov r2, #4 @ set some flags in r2, r6
  263. mov r6, #0xff
  264. adr r3, l2_inv_api_params @ r3 points to dummy parameters
  265. mcr p15, 0, r0, c7, c10, 4 @ data write barrier
  266. mcr p15, 0, r0, c7, c10, 5 @ data memory barrier
  267. .word 0xE1600071 @ call SMI monitor (smi #1)
  268. /* Write to Aux control register to set some bits */
  269. mov r0, #42 @ set service ID for PPA
  270. mov r12, r0 @ copy secure Service ID in r12
  271. mov r1, #0 @ set task id for ROM code in r1
  272. mov r2, #4 @ set some flags in r2, r6
  273. mov r6, #0xff
  274. ldr r4, scratchpad_base
  275. ldr r3, [r4, #0xBC] @ r3 points to parameters
  276. mcr p15, 0, r0, c7, c10, 4 @ data write barrier
  277. mcr p15, 0, r0, c7, c10, 5 @ data memory barrier
  278. .word 0xE1600071 @ call SMI monitor (smi #1)
  279. #ifdef CONFIG_OMAP3_L2_AUX_SECURE_SAVE_RESTORE
  280. /* Restore L2 aux control register */
  281. @ set service ID for PPA
  282. mov r0, #CONFIG_OMAP3_L2_AUX_SECURE_SERVICE_SET_ID
  283. mov r12, r0 @ copy service ID in r12
  284. mov r1, #0 @ set task ID for ROM code in r1
  285. mov r2, #4 @ set some flags in r2, r6
  286. mov r6, #0xff
  287. ldr r4, scratchpad_base
  288. ldr r3, [r4, #0xBC]
  289. adds r3, r3, #8 @ r3 points to parameters
  290. mcr p15, 0, r0, c7, c10, 4 @ data write barrier
  291. mcr p15, 0, r0, c7, c10, 5 @ data memory barrier
  292. .word 0xE1600071 @ call SMI monitor (smi #1)
  293. #endif
  294. b logic_l1_restore
  295. l2_inv_api_params:
  296. .word 0x1, 0x00
  297. l2_inv_gp:
  298. /* Execute smi to invalidate L2 cache */
  299. mov r12, #0x1 @ set up to invalide L2
  300. smi: .word 0xE1600070 @ Call SMI monitor (smieq)
  301. /* Write to Aux control register to set some bits */
  302. ldr r4, scratchpad_base
  303. ldr r3, [r4,#0xBC]
  304. ldr r0, [r3,#4]
  305. mov r12, #0x3
  306. .word 0xE1600070 @ Call SMI monitor (smieq)
  307. ldr r4, scratchpad_base
  308. ldr r3, [r4,#0xBC]
  309. ldr r0, [r3,#12]
  310. mov r12, #0x2
  311. .word 0xE1600070 @ Call SMI monitor (smieq)
  312. logic_l1_restore:
  313. ldr r1, l2dis_3630
  314. cmp r1, #0x1 @ Do we need to re-enable L2 on 3630?
  315. bne skipl2reen
  316. mrc p15, 0, r1, c1, c0, 1
  317. orr r1, r1, #2 @ re-enable L2 cache
  318. mcr p15, 0, r1, c1, c0, 1
  319. skipl2reen:
  320. mov r1, #0
  321. /* Invalidate all instruction caches to PoU
  322. * and flush branch target cache */
  323. mcr p15, 0, r1, c7, c5, 0
  324. ldr r4, scratchpad_base
  325. ldr r3, [r4,#0xBC]
  326. adds r3, r3, #16
  327. ldmia r3!, {r4-r6}
  328. mov sp, r4
  329. msr spsr_cxsf, r5
  330. mov lr, r6
  331. ldmia r3!, {r4-r9}
  332. /* Coprocessor access Control Register */
  333. mcr p15, 0, r4, c1, c0, 2
  334. /* TTBR0 */
  335. MCR p15, 0, r5, c2, c0, 0
  336. /* TTBR1 */
  337. MCR p15, 0, r6, c2, c0, 1
  338. /* Translation table base control register */
  339. MCR p15, 0, r7, c2, c0, 2
  340. /*domain access Control Register */
  341. MCR p15, 0, r8, c3, c0, 0
  342. /* data fault status Register */
  343. MCR p15, 0, r9, c5, c0, 0
  344. ldmia r3!,{r4-r8}
  345. /* instruction fault status Register */
  346. MCR p15, 0, r4, c5, c0, 1
  347. /*Data Auxiliary Fault Status Register */
  348. MCR p15, 0, r5, c5, c1, 0
  349. /*Instruction Auxiliary Fault Status Register*/
  350. MCR p15, 0, r6, c5, c1, 1
  351. /*Data Fault Address Register */
  352. MCR p15, 0, r7, c6, c0, 0
  353. /*Instruction Fault Address Register*/
  354. MCR p15, 0, r8, c6, c0, 2
  355. ldmia r3!,{r4-r7}
  356. /* user r/w thread and process ID */
  357. MCR p15, 0, r4, c13, c0, 2
  358. /* user ro thread and process ID */
  359. MCR p15, 0, r5, c13, c0, 3
  360. /*Privileged only thread and process ID */
  361. MCR p15, 0, r6, c13, c0, 4
  362. /* cache size selection */
  363. MCR p15, 2, r7, c0, c0, 0
  364. ldmia r3!,{r4-r8}
  365. /* Data TLB lockdown registers */
  366. MCR p15, 0, r4, c10, c0, 0
  367. /* Instruction TLB lockdown registers */
  368. MCR p15, 0, r5, c10, c0, 1
  369. /* Secure or Nonsecure Vector Base Address */
  370. MCR p15, 0, r6, c12, c0, 0
  371. /* FCSE PID */
  372. MCR p15, 0, r7, c13, c0, 0
  373. /* Context PID */
  374. MCR p15, 0, r8, c13, c0, 1
  375. ldmia r3!,{r4-r5}
  376. /* primary memory remap register */
  377. MCR p15, 0, r4, c10, c2, 0
  378. /*normal memory remap register */
  379. MCR p15, 0, r5, c10, c2, 1
  380. /* Restore cpsr */
  381. ldmia r3!,{r4} /*load CPSR from SDRAM*/
  382. msr cpsr, r4 /*store cpsr */
  383. /* Enabling MMU here */
  384. mrc p15, 0, r7, c2, c0, 2 /* Read TTBRControl */
  385. /* Extract N (0:2) bits and decide whether to use TTBR0 or TTBR1*/
  386. and r7, #0x7
  387. cmp r7, #0x0
  388. beq usettbr0
  389. ttbr_error:
  390. /* More work needs to be done to support N[0:2] value other than 0
  391. * So looping here so that the error can be detected
  392. */
  393. b ttbr_error
  394. usettbr0:
  395. mrc p15, 0, r2, c2, c0, 0
  396. ldr r5, ttbrbit_mask
  397. and r2, r5
  398. mov r4, pc
  399. ldr r5, table_index_mask
  400. and r4, r5 /* r4 = 31 to 20 bits of pc */
  401. /* Extract the value to be written to table entry */
  402. ldr r1, table_entry
  403. add r1, r1, r4 /* r1 has value to be written to table entry*/
  404. /* Getting the address of table entry to modify */
  405. lsr r4, #18
  406. add r2, r4 /* r2 has the location which needs to be modified */
  407. /* Storing previous entry of location being modified */
  408. ldr r5, scratchpad_base
  409. ldr r4, [r2]
  410. str r4, [r5, #0xC0]
  411. /* Modify the table entry */
  412. str r1, [r2]
  413. /* Storing address of entry being modified
  414. * - will be restored after enabling MMU */
  415. ldr r5, scratchpad_base
  416. str r2, [r5, #0xC4]
  417. mov r0, #0
  418. mcr p15, 0, r0, c7, c5, 4 @ Flush prefetch buffer
  419. mcr p15, 0, r0, c7, c5, 6 @ Invalidate branch predictor array
  420. mcr p15, 0, r0, c8, c5, 0 @ Invalidate instruction TLB
  421. mcr p15, 0, r0, c8, c6, 0 @ Invalidate data TLB
  422. /* Restore control register but dont enable caches here*/
  423. /* Caches will be enabled after restoring MMU table entry */
  424. ldmia r3!, {r4}
  425. /* Store previous value of control register in scratchpad */
  426. str r4, [r5, #0xC8]
  427. ldr r2, cache_pred_disable_mask
  428. and r4, r2
  429. mcr p15, 0, r4, c1, c0, 0
  430. ldmfd sp!, {r0-r12, pc} @ restore regs and return
  431. save_context_wfi:
  432. mov r8, r0 /* Store SDRAM address in r8 */
  433. mrc p15, 0, r5, c1, c0, 1 @ Read Auxiliary Control Register
  434. mov r4, #0x1 @ Number of parameters for restore call
  435. stmia r8!, {r4-r5} @ Push parameters for restore call
  436. mrc p15, 1, r5, c9, c0, 2 @ Read L2 AUX ctrl register
  437. stmia r8!, {r4-r5} @ Push parameters for restore call
  438. /* Check what that target sleep state is:stored in r1*/
  439. /* 1 - Only L1 and logic lost */
  440. /* 2 - Only L2 lost */
  441. /* 3 - Both L1 and L2 lost */
  442. cmp r1, #0x2 /* Only L2 lost */
  443. beq clean_l2
  444. cmp r1, #0x1 /* L2 retained */
  445. /* r9 stores whether to clean L2 or not*/
  446. moveq r9, #0x0 /* Dont Clean L2 */
  447. movne r9, #0x1 /* Clean L2 */
  448. l1_logic_lost:
  449. /* Store sp and spsr to SDRAM */
  450. mov r4, sp
  451. mrs r5, spsr
  452. mov r6, lr
  453. stmia r8!, {r4-r6}
  454. /* Save all ARM registers */
  455. /* Coprocessor access control register */
  456. mrc p15, 0, r6, c1, c0, 2
  457. stmia r8!, {r6}
  458. /* TTBR0, TTBR1 and Translation table base control */
  459. mrc p15, 0, r4, c2, c0, 0
  460. mrc p15, 0, r5, c2, c0, 1
  461. mrc p15, 0, r6, c2, c0, 2
  462. stmia r8!, {r4-r6}
  463. /* Domain access control register, data fault status register,
  464. and instruction fault status register */
  465. mrc p15, 0, r4, c3, c0, 0
  466. mrc p15, 0, r5, c5, c0, 0
  467. mrc p15, 0, r6, c5, c0, 1
  468. stmia r8!, {r4-r6}
  469. /* Data aux fault status register, instruction aux fault status,
  470. datat fault address register and instruction fault address register*/
  471. mrc p15, 0, r4, c5, c1, 0
  472. mrc p15, 0, r5, c5, c1, 1
  473. mrc p15, 0, r6, c6, c0, 0
  474. mrc p15, 0, r7, c6, c0, 2
  475. stmia r8!, {r4-r7}
  476. /* user r/w thread and process ID, user r/o thread and process ID,
  477. priv only thread and process ID, cache size selection */
  478. mrc p15, 0, r4, c13, c0, 2
  479. mrc p15, 0, r5, c13, c0, 3
  480. mrc p15, 0, r6, c13, c0, 4
  481. mrc p15, 2, r7, c0, c0, 0
  482. stmia r8!, {r4-r7}
  483. /* Data TLB lockdown, instruction TLB lockdown registers */
  484. mrc p15, 0, r5, c10, c0, 0
  485. mrc p15, 0, r6, c10, c0, 1
  486. stmia r8!, {r5-r6}
  487. /* Secure or non secure vector base address, FCSE PID, Context PID*/
  488. mrc p15, 0, r4, c12, c0, 0
  489. mrc p15, 0, r5, c13, c0, 0
  490. mrc p15, 0, r6, c13, c0, 1
  491. stmia r8!, {r4-r6}
  492. /* Primary remap, normal remap registers */
  493. mrc p15, 0, r4, c10, c2, 0
  494. mrc p15, 0, r5, c10, c2, 1
  495. stmia r8!,{r4-r5}
  496. /* Store current cpsr*/
  497. mrs r2, cpsr
  498. stmia r8!, {r2}
  499. mrc p15, 0, r4, c1, c0, 0
  500. /* save control register */
  501. stmia r8!, {r4}
  502. clean_caches:
  503. /* Clean Data or unified cache to POU*/
  504. /* How to invalidate only L1 cache???? - #FIX_ME# */
  505. /* mcr p15, 0, r11, c7, c11, 1 */
  506. cmp r9, #1 /* Check whether L2 inval is required or not*/
  507. bne skip_l2_inval
  508. clean_l2:
  509. /*
  510. * Jump out to kernel flush routine
  511. * - reuse that code is better
  512. * - it executes in a cached space so is faster than refetch per-block
  513. * - should be faster and will change with kernel
  514. * - 'might' have to copy address, load and jump to it
  515. * - lr is used since we are running in SRAM currently.
  516. */
  517. ldr r1, kernel_flush
  518. mov lr, pc
  519. bx r1
  520. skip_l2_inval:
  521. /* Data memory barrier and Data sync barrier */
  522. mov r1, #0
  523. mcr p15, 0, r1, c7, c10, 4
  524. mcr p15, 0, r1, c7, c10, 5
  525. wfi @ wait for interrupt
  526. nop
  527. nop
  528. nop
  529. nop
  530. nop
  531. nop
  532. nop
  533. nop
  534. nop
  535. nop
  536. bl wait_sdrc_ok
  537. /* restore regs and return */
  538. ldmfd sp!, {r0-r12, pc}
  539. /* Make sure SDRC accesses are ok */
  540. wait_sdrc_ok:
  541. /* DPLL3 must be locked before accessing the SDRC. Maybe the HW ensures this. */
  542. ldr r4, cm_idlest_ckgen
  543. wait_dpll3_lock:
  544. ldr r5, [r4]
  545. tst r5, #1
  546. beq wait_dpll3_lock
  547. ldr r4, cm_idlest1_core
  548. wait_sdrc_ready:
  549. ldr r5, [r4]
  550. tst r5, #0x2
  551. bne wait_sdrc_ready
  552. /* allow DLL powerdown upon hw idle req */
  553. ldr r4, sdrc_power
  554. ldr r5, [r4]
  555. bic r5, r5, #0x40
  556. str r5, [r4]
  557. is_dll_in_lock_mode:
  558. /* Is dll in lock mode? */
  559. ldr r4, sdrc_dlla_ctrl
  560. ldr r5, [r4]
  561. tst r5, #0x4
  562. bxne lr
  563. /* wait till dll locks */
  564. wait_dll_lock_timed:
  565. ldr r4, wait_dll_lock_counter
  566. add r4, r4, #1
  567. str r4, wait_dll_lock_counter
  568. ldr r4, sdrc_dlla_status
  569. mov r6, #8 /* Wait 20uS for lock */
  570. wait_dll_lock:
  571. subs r6, r6, #0x1
  572. beq kick_dll
  573. ldr r5, [r4]
  574. and r5, r5, #0x4
  575. cmp r5, #0x4
  576. bne wait_dll_lock
  577. bx lr
  578. /* disable/reenable DLL if not locked */
  579. kick_dll:
  580. ldr r4, sdrc_dlla_ctrl
  581. ldr r5, [r4]
  582. mov r6, r5
  583. bic r6, #(1<<3) /* disable dll */
  584. str r6, [r4]
  585. dsb
  586. orr r6, r6, #(1<<3) /* enable dll */
  587. str r6, [r4]
  588. dsb
  589. ldr r4, kick_counter
  590. add r4, r4, #1
  591. str r4, kick_counter
  592. b wait_dll_lock_timed
  593. cm_idlest1_core:
  594. .word CM_IDLEST1_CORE_V
  595. cm_idlest_ckgen:
  596. .word CM_IDLEST_CKGEN_V
  597. sdrc_dlla_status:
  598. .word SDRC_DLLA_STATUS_V
  599. sdrc_dlla_ctrl:
  600. .word SDRC_DLLA_CTRL_V
  601. pm_prepwstst_core_p:
  602. .word PM_PREPWSTST_CORE_P
  603. pm_pwstctrl_mpu:
  604. .word PM_PWSTCTRL_MPU_P
  605. scratchpad_base:
  606. .word SCRATCHPAD_BASE_P
  607. sram_base:
  608. .word SRAM_BASE_P + 0x8000
  609. sdrc_power:
  610. .word SDRC_POWER_V
  611. ttbrbit_mask:
  612. .word 0xFFFFC000
  613. table_index_mask:
  614. .word 0xFFF00000
  615. table_entry:
  616. .word 0x00000C02
  617. cache_pred_disable_mask:
  618. .word 0xFFFFE7FB
  619. control_stat:
  620. .word CONTROL_STAT
  621. control_mem_rta:
  622. .word CONTROL_MEM_RTA_CTRL
  623. kernel_flush:
  624. .word v7_flush_dcache_all
  625. l2dis_3630:
  626. .word 0
  627. /*
  628. * When exporting to userspace while the counters are in SRAM,
  629. * these 2 words need to be at the end to facilitate retrival!
  630. */
  631. kick_counter:
  632. .word 0
  633. wait_dll_lock_counter:
  634. .word 0
  635. ENTRY(omap34xx_cpu_suspend_sz)
  636. .word . - omap34xx_cpu_suspend