2 * linux/arch/arm/mach-omap2/sleep.S
5 * Texas Instruments, <www.ti.com>
6 * Richard Woodruff <r-woodruff2@ti.com>
8 * (C) Copyright 2006 Nokia Corporation
9 * Fixed idle loop sleep
10 * Igor Stoppa <igor.stoppa@nokia.com>
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.
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.
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,
28 #include <linux/linkage.h>
29 #include <linux/poison.h> /* for SRAM_VA_MAGIC */
30 #include <asm/assembler.h>
31 #include <asm/arch/io.h>
32 #include <asm/arch/pm.h>
34 #include <asm/arch/omap24xx.h>
36 /* First address of reserved address space? apparently valid for OMAP2 & 3 */
37 #define A_SDRC0_V (0xC0000000)
42 * Forces OMAP into idle state
44 * omap24xx_idle_loop_suspend() - This bit of code just executes the WFI
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 ENTRY(omap24xx_idle_loop_suspend)
51 stmfd sp!, {r0, lr} @ save registers on stack
52 mov r0, #0x0 @ clear for mrc call
53 mcr p15, 0, r0, c7, c0, 4 @ wait for interrupt
54 ldmfd sp!, {r0, pc} @ restore regs and return
56 ENTRY(omap24xx_idle_loop_suspend_sz)
57 .word . - omap24xx_idle_loop_suspend
60 * omap242x_cpu_suspend() - Forces OMAP into deep sleep state by completing
61 * SDRC shutdown then ARM shutdown. Upon wake MPU is back on so just restore
65 * R0 : DLL ctrl value pre-Sleep
67 * The if the DPLL is going to AutoIdle. It seems like the DPLL may be back on
68 * when we get called, but the DLL probably isn't. We will wait a bit more in
69 * case the DPLL isn't quite there yet. The code will wait on DLL for DDR even
70 * if in unlocked mode.
72 * For less than 242x-ES2.2 upon wake from a sleep mode where the external
73 * oscillator was stopped, a timing bug exists where a non-stabilized 12MHz
74 * clock can pass into the PRCM can cause problems at DSP and IVA.
75 * To work around this the code will switch to the 32kHz source prior to sleep.
76 * Post sleep we will shift back to using the DPLL. Apparently,
77 * CM_IDLEST_CLKGEN does not reflect the full clock change so you need to wait
78 * 3x12MHz + 3x32kHz clocks for a full switch.
80 * The DLL load value is not kept in RETENTION or OFF. It needs to be restored
83 ENTRY(omap24xx_cpu_suspend)
84 stmfd sp!, {r0 - r12, lr} @ save registers on stack
85 mov r3, #0x0 @ clear for mrc call
86 mcr p15, 0, r3, c7, c10, 4 @ memory barrier, hope SDR/DDR finished
89 ldr r3, omap2_ocs_sdrc_power @ addr of sdrc power
90 ldr r4, [r3] @ value of sdrc power
91 orr r4, r4, #0x40 @ enable self refresh on idle req
92 mov r5, #0x2000 @ set delay (DPLL relock + DLL relock)
93 str r4, [r3] @ make it so
96 mcr p15, 0, r2, c7, c0, 4 @ wait for interrupt
99 subs r5, r5, #0x1 @ awake, wait just a bit
102 /* The DPLL has on before we take the DDR out of self refresh */
103 bic r4, r4, #0x40 @ now clear self refresh bit.
104 str r4, [r3] @ put vlaue back.
105 ldr r4, A_SDRC0 @ make a clock happen
107 nop @ start auto refresh only after clk ok
108 movs r0, r0 @ see if DDR or SDR
109 ldrne r1, omap2_ocs_sdrc_dlla_ctrl @ get addr of DLL ctrl
110 strne r0, [r1] @ rewrite DLLA to force DLL reload
111 addne r1, r1, #0x8 @ move to DLLB
112 strne r0, [r1] @ rewrite DLLB to force DLL reload
119 ldmfd sp!, {r0 - r12, pc} @ restore regs and return
121 .globl omap2_ocs_sdrc_power
122 .globl omap2_ocs_sdrc_dlla_ctrl
124 omap2_ocs_sdrc_power:
128 omap2_ocs_sdrc_dlla_ctrl:
131 ENTRY(omap24xx_cpu_suspend_sz)
132 .word . - omap24xx_cpu_suspend