2 * linux/arch/arm/mach-omap1/sleep.S
4 * Low-level OMAP730/1510/1610 sleep/wakeUp support
7 * Copyright (c) 2001 Cliff Brake <cbrake@accelent.com>
9 * Adapted for PXA by Nicolas Pitre:
10 * Copyright (c) 2002 Monta Vista Software, Inc.
12 * Support for OMAP1510/1610 by Dirk Behme <dirk.behme@de.bosch.com>
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.
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.
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.
35 #include <linux/linkage.h>
36 #include <asm/assembler.h>
37 #include <asm/arch/io.h>
38 #include <asm/arch/pm.h>
43 * Forces OMAP into idle state
45 * omapXXXX_idle_loop_suspend()
47 * Note: This code get's copied to internal SRAM at boot. When the OMAP
48 * wakes up it continues execution at the point it went to sleep.
50 * Note: Because of slightly different configuration values we have
51 * processor specific functions here.
54 #if defined(CONFIG_ARCH_OMAP730)
55 ENTRY(omap730_idle_loop_suspend)
57 stmfd sp!, {r0 - r12, lr} @ save registers on stack
59 @ load base address of ARM_IDLECT1 and ARM_IDLECT2
60 mov r4, #CLKGEN_REG_ASM_BASE & 0xff000000
61 orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x00ff0000
62 orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x0000ff00
64 @ turn off clock domains
65 @ get ARM_IDLECT2 into r2
66 ldrh r2, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
67 mov r5, #OMAP730_IDLECT2_SLEEP_VAL & 0xff
68 orr r5, r5, #OMAP730_IDLECT2_SLEEP_VAL & 0xff00
69 strh r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
72 @ get ARM_IDLECT1 into r1
73 ldrh r1, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
74 orr r3, r1, #OMAP730_IDLE_LOOP_REQUEST & 0xffff
75 strh r3, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
77 mov r5, #IDLE_WAIT_CYCLES & 0xff
78 orr r5, r5, #IDLE_WAIT_CYCLES & 0xff00
79 l_730: subs r5, r5, #1
82 * Let's wait for the next clock tick to wake us up.
85 mcr p15, 0, r0, c7, c0, 4 @ wait for interrupt
87 * omap730_idle_loop_suspend()'s resume point.
89 * It will just start executing here, so we'll restore stuff from the
90 * stack, reset the ARM_IDLECT1 and ARM_IDLECT2.
93 @ restore ARM_IDLECT1 and ARM_IDLECT2 and return
94 @ r1 has ARM_IDLECT1 and r2 still has ARM_IDLECT2
95 strh r2, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
96 strh r1, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
98 ldmfd sp!, {r0 - r12, pc} @ restore regs and return
100 ENTRY(omap730_idle_loop_suspend_sz)
101 .word . - omap730_idle_loop_suspend
102 #endif /* CONFIG_ARCH_OMAP730 */
104 #ifdef CONFIG_ARCH_OMAP15XX
105 ENTRY(omap1510_idle_loop_suspend)
107 stmfd sp!, {r0 - r12, lr} @ save registers on stack
109 @ load base address of ARM_IDLECT1 and ARM_IDLECT2
110 mov r4, #CLKGEN_REG_ASM_BASE & 0xff000000
111 orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x00ff0000
112 orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x0000ff00
114 @ turn off clock domains
115 @ get ARM_IDLECT2 into r2
116 ldrh r2, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
117 mov r5, #OMAP1510_IDLE_CLOCK_DOMAINS & 0xff
118 orr r5, r5, #OMAP1510_IDLE_CLOCK_DOMAINS & 0xff00
119 strh r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
122 @ get ARM_IDLECT1 into r1
123 ldrh r1, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
124 orr r3, r1, #OMAP1510_IDLE_LOOP_REQUEST & 0xffff
125 strh r3, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
127 mov r5, #IDLE_WAIT_CYCLES & 0xff
128 orr r5, r5, #IDLE_WAIT_CYCLES & 0xff00
129 l_1510: subs r5, r5, #1
132 * Let's wait for the next clock tick to wake us up.
135 mcr p15, 0, r0, c7, c0, 4 @ wait for interrupt
137 * omap1510_idle_loop_suspend()'s resume point.
139 * It will just start executing here, so we'll restore stuff from the
140 * stack, reset the ARM_IDLECT1 and ARM_IDLECT2.
143 @ restore ARM_IDLECT1 and ARM_IDLECT2 and return
144 @ r1 has ARM_IDLECT1 and r2 still has ARM_IDLECT2
145 strh r2, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
146 strh r1, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
148 ldmfd sp!, {r0 - r12, pc} @ restore regs and return
150 ENTRY(omap1510_idle_loop_suspend_sz)
151 .word . - omap1510_idle_loop_suspend
152 #endif /* CONFIG_ARCH_OMAP15XX */
154 #if defined(CONFIG_ARCH_OMAP16XX)
155 ENTRY(omap1610_idle_loop_suspend)
157 stmfd sp!, {r0 - r12, lr} @ save registers on stack
159 @ load base address of ARM_IDLECT1 and ARM_IDLECT2
160 mov r4, #CLKGEN_REG_ASM_BASE & 0xff000000
161 orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x00ff0000
162 orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x0000ff00
164 @ turn off clock domains
165 @ get ARM_IDLECT2 into r2
166 ldrh r2, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
167 mov r5, #OMAP1610_IDLECT2_SLEEP_VAL & 0xff
168 orr r5, r5, #OMAP1610_IDLECT2_SLEEP_VAL & 0xff00
169 strh r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
172 @ get ARM_IDLECT1 into r1
173 ldrh r1, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
174 orr r3, r1, #OMAP1610_IDLE_LOOP_REQUEST & 0xffff
175 strh r3, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
177 mov r5, #IDLE_WAIT_CYCLES & 0xff
178 orr r5, r5, #IDLE_WAIT_CYCLES & 0xff00
179 l_1610: subs r5, r5, #1
182 * Let's wait for the next clock tick to wake us up.
185 mcr p15, 0, r0, c7, c0, 4 @ wait for interrupt
187 * omap1610_idle_loop_suspend()'s resume point.
189 * It will just start executing here, so we'll restore stuff from the
190 * stack, reset the ARM_IDLECT1 and ARM_IDLECT2.
193 @ restore ARM_IDLECT1 and ARM_IDLECT2 and return
194 @ r1 has ARM_IDLECT1 and r2 still has ARM_IDLECT2
195 strh r2, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
196 strh r1, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
198 ldmfd sp!, {r0 - r12, pc} @ restore regs and return
200 ENTRY(omap1610_idle_loop_suspend_sz)
201 .word . - omap1610_idle_loop_suspend
202 #endif /* CONFIG_ARCH_OMAP16XX */
205 * Forces OMAP into deep sleep state
207 * omapXXXX_cpu_suspend()
209 * The values of the registers ARM_IDLECT1 and ARM_IDLECT2 are passed
210 * as arg0 and arg1 from caller. arg0 is stored in register r0 and arg1
213 * Note: This code get's copied to internal SRAM at boot. When the OMAP
214 * wakes up it continues execution at the point it went to sleep.
216 * Note: Because of errata work arounds we have processor specific functions
217 * here. They are mostly the same, but slightly different.
221 #if defined(CONFIG_ARCH_OMAP730)
222 ENTRY(omap730_cpu_suspend)
224 @ save registers on stack
225 stmfd sp!, {r0 - r12, lr}
229 mcr p15, 0, r0, c7, c10, 4
232 @ load base address of Traffic Controller
233 mov r6, #TCMIF_ASM_BASE & 0xff000000
234 orr r6, r6, #TCMIF_ASM_BASE & 0x00ff0000
235 orr r6, r6, #TCMIF_ASM_BASE & 0x0000ff00
237 @ prepare to put SDRAM into self-refresh manually
238 ldr r7, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
239 orr r9, r7, #SELF_REFRESH_MODE & 0xff000000
240 orr r9, r9, #SELF_REFRESH_MODE & 0x000000ff
241 str r9, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
243 @ prepare to put EMIFS to Sleep
244 ldr r8, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
245 orr r9, r8, #IDLE_EMIFS_REQUEST & 0xff
246 str r9, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
248 @ load base address of ARM_IDLECT1 and ARM_IDLECT2
249 mov r4, #CLKGEN_REG_ASM_BASE & 0xff000000
250 orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x00ff0000
251 orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x0000ff00
253 @ turn off clock domains
254 @ do not disable PERCK (0x04)
255 mov r5, #OMAP730_IDLECT2_SLEEP_VAL & 0xff
256 orr r5, r5, #OMAP730_IDLECT2_SLEEP_VAL & 0xff00
257 strh r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
260 mov r3, #OMAP730_IDLECT1_SLEEP_VAL & 0xff
261 orr r3, r3, #OMAP730_IDLECT1_SLEEP_VAL & 0xff00
262 strh r3, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
264 @ disable instruction cache
265 mrc p15, 0, r9, c1, c0, 0
267 mcr p15, 0, r2, c1, c0, 0
271 * Let's wait for the next wake up event to wake us up. r0 can't be
272 * used here because r0 holds ARM_IDLECT1
275 mcr p15, 0, r2, c7, c0, 4 @ wait for interrupt
277 * omap730_cpu_suspend()'s resume point.
279 * It will just start executing here, so we'll restore stuff from the
283 mcr p15, 0, r9, c1, c0, 0
285 @ reset the ARM_IDLECT1 and ARM_IDLECT2.
286 strh r1, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
287 strh r0, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
289 @ Restore EMIFF controls
290 str r7, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
291 str r8, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
293 @ restore regs and return
294 ldmfd sp!, {r0 - r12, pc}
296 ENTRY(omap730_cpu_suspend_sz)
297 .word . - omap730_cpu_suspend
298 #endif /* CONFIG_ARCH_OMAP730 */
300 #ifdef CONFIG_ARCH_OMAP15XX
301 ENTRY(omap1510_cpu_suspend)
303 @ save registers on stack
304 stmfd sp!, {r0 - r12, lr}
306 @ load base address of Traffic Controller
307 mov r4, #TCMIF_ASM_BASE & 0xff000000
308 orr r4, r4, #TCMIF_ASM_BASE & 0x00ff0000
309 orr r4, r4, #TCMIF_ASM_BASE & 0x0000ff00
311 @ work around errata of OMAP1510 PDE bit for TC shut down
313 ldr r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
314 bic r5, r5, #PDE_BIT & 0xff
315 str r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
318 and r5, r5, #PWD_EN_BIT & 0xff
319 str r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
321 @ prepare to put SDRAM into self-refresh manually
322 ldr r5, [r4, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
323 orr r5, r5, #SELF_REFRESH_MODE & 0xff000000
324 orr r5, r5, #SELF_REFRESH_MODE & 0x000000ff
325 str r5, [r4, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
327 @ prepare to put EMIFS to Sleep
328 ldr r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
329 orr r5, r5, #IDLE_EMIFS_REQUEST & 0xff
330 str r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
332 @ load base address of ARM_IDLECT1 and ARM_IDLECT2
333 mov r4, #CLKGEN_REG_ASM_BASE & 0xff000000
334 orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x00ff0000
335 orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x0000ff00
337 @ turn off clock domains
338 mov r5, #OMAP1510_IDLE_CLOCK_DOMAINS & 0xff
339 orr r5, r5, #OMAP1510_IDLE_CLOCK_DOMAINS & 0xff00
340 strh r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
343 mov r3, #OMAP1510_DEEP_SLEEP_REQUEST & 0xff
344 orr r3, r3, #OMAP1510_DEEP_SLEEP_REQUEST & 0xff00
345 strh r3, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
347 mov r5, #IDLE_WAIT_CYCLES & 0xff
348 orr r5, r5, #IDLE_WAIT_CYCLES & 0xff00
353 * Let's wait for the next wake up event to wake us up. r0 can't be
354 * used here because r0 holds ARM_IDLECT1
357 mcr p15, 0, r2, c7, c0, 4 @ wait for interrupt
359 * omap1510_cpu_suspend()'s resume point.
361 * It will just start executing here, so we'll restore stuff from the
362 * stack, reset the ARM_IDLECT1 and ARM_IDLECT2.
364 strh r1, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
365 strh r0, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
367 @ restore regs and return
368 ldmfd sp!, {r0 - r12, pc}
370 ENTRY(omap1510_cpu_suspend_sz)
371 .word . - omap1510_cpu_suspend
372 #endif /* CONFIG_ARCH_OMAP15XX */
374 #if defined(CONFIG_ARCH_OMAP16XX)
375 ENTRY(omap1610_cpu_suspend)
377 @ save registers on stack
378 stmfd sp!, {r0 - r12, lr}
382 mcr p15, 0, r0, c7, c10, 4
385 @ Load base address of Traffic Controller
386 mov r6, #TCMIF_ASM_BASE & 0xff000000
387 orr r6, r6, #TCMIF_ASM_BASE & 0x00ff0000
388 orr r6, r6, #TCMIF_ASM_BASE & 0x0000ff00
390 @ Prepare to put SDRAM into self-refresh manually
391 ldr r7, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
392 orr r9, r7, #SELF_REFRESH_MODE & 0xff000000
393 orr r9, r9, #SELF_REFRESH_MODE & 0x000000ff
394 str r9, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
396 @ Prepare to put EMIFS to Sleep
397 ldr r8, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
398 orr r9, r8, #IDLE_EMIFS_REQUEST & 0xff
399 str r9, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
401 @ Load base address of ARM_IDLECT1 and ARM_IDLECT2
402 mov r4, #CLKGEN_REG_ASM_BASE & 0xff000000
403 orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x00ff0000
404 orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x0000ff00
406 @ Turn off clock domains
407 @ Do not disable PERCK (0x04)
408 mov r5, #OMAP1610_IDLECT2_SLEEP_VAL & 0xff
409 orr r5, r5, #OMAP1610_IDLECT2_SLEEP_VAL & 0xff00
410 strh r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
413 mov r3, #OMAP1610_IDLECT1_SLEEP_VAL & 0xff
414 orr r3, r3, #OMAP1610_IDLECT1_SLEEP_VAL & 0xff00
415 strh r3, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
418 * Let's wait for the next wake up event to wake us up. r0 can't be
419 * used here because r0 holds ARM_IDLECT1
422 mcr p15, 0, r2, c7, c0, 4 @ wait for interrupt
424 @ Errata (HEL3SU467, section 1.4.4) specifies nop-instructions
425 @ according to this formula:
426 @ 2 + (4*DPLL_MULT)/DPLL_DIV/ARMDIV
430 @ => 74 nop-instructions
506 * omap1610_cpu_suspend()'s resume point.
508 * It will just start executing here, so we'll restore stuff from the
511 @ Restore the ARM_IDLECT1 and ARM_IDLECT2.
512 strh r1, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
513 strh r0, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
515 @ Restore EMIFF controls
516 str r7, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
517 str r8, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
519 @ Restore regs and return
520 ldmfd sp!, {r0 - r12, pc}
522 ENTRY(omap1610_cpu_suspend_sz)
523 .word . - omap1610_cpu_suspend
524 #endif /* CONFIG_ARCH_OMAP16XX */