2 * Low-level PXA250/210 sleep/wakeUp support
5 * Copyright (c) 2001 Cliff Brake <cbrake@accelent.com>
7 * Adapted for PXA by Nicolas Pitre:
8 * Copyright (c) 2002 Monta Vista Software, Inc.
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License.
14 #include <linux/linkage.h>
15 #include <asm/assembler.h>
16 #include <mach/hardware.h>
17 #include <mach/smemc.h>
18 #include <mach/pxa2xx-regs.h>
20 #define MDREFR_KDIV 0x200a4000 // all banks
21 #define CCCR_SLEEP 0x00000107 // L=7 2N=2 A=0 PPDIS=0 CPDIS=0
27 * pxa3xx_cpu_suspend() - forces CPU into sleep state (S2D3C4)
31 ENTRY(pxa3xx_cpu_suspend)
36 stmfd sp!, {r2 - r12, lr} @ save registers on stack
38 ldr r3, =pxa_cpu_resume @ resume function
41 mov r0, #0x06 @ S2D3C4 mode
42 mcr p14, 0, r0, c7, c0, 0 @ enter sleep
44 20: b 20b @ waiting for sleep
45 #endif /* CONFIG_PXA3xx */
49 * pxa27x_cpu_suspend()
51 * Forces CPU into sleep state.
53 * r0 = value for PWRMODE M field for desired sleep state
56 ENTRY(pxa27x_cpu_suspend)
61 stmfd sp!, {r2 - r12, lr} @ save registers on stack
62 mov r4, r0 @ save sleep mode
63 ldr r3, =pxa_cpu_resume @ resume function
66 @ Put the processor to sleep
67 @ (also workaround for sighting 28071)
69 @ prepare value for sleep mode
70 mov r1, r4 @ sleep mode
72 @ prepare pointer to physical address 0 (virtual mapping in generic.c)
73 mov r2, #UNCACHED_PHYS_0
75 @ prepare SDRAM refresh settings
79 @ enable SDRAM self-refresh mode
80 orr r5, r5, #MDREFR_SLFRSH
82 @ set SDCLKx divide-by-2 bits (this is part of a workaround for Errata 50)
86 @ Intel PXA270 Specification Update notes problems sleeping
87 @ with core operating above 91 MHz
88 @ (see Errata 50, ...processor does not exit from sleep...)
91 ldr r8, [r6] @ keep original value for resume
93 ldr r7, =CCCR_SLEEP @ prepare CCCR sleep value
94 mov r0, #0x2 @ prepare value for CLKCFG
96 @ align execution to a cache line
102 * pxa25x_cpu_suspend()
104 * Forces CPU into sleep state.
106 * r0 = value for PWRMODE M field for desired sleep state
110 ENTRY(pxa25x_cpu_suspend)
111 stmfd sp!, {r2 - r12, lr} @ save registers on stack
112 mov r4, r0 @ save sleep mode
113 ldr r3, =pxa_cpu_resume @ resume function
115 @ prepare value for sleep mode
116 mov r1, r4 @ sleep mode
118 @ prepare pointer to physical address 0 (virtual mapping in generic.c)
119 mov r2, #UNCACHED_PHYS_0
121 @ prepare SDRAM refresh settings
125 @ enable SDRAM self-refresh mode
126 orr r5, r5, #MDREFR_SLFRSH
128 @ Intel PXA255 Specification Update notes problems
129 @ about suspending with PXBus operating above 133MHz
130 @ (see Errata 31, GPIO output signals, ... unpredictable in sleep
132 @ We keep the change-down close to the actual suspend on SDRAM
133 @ as possible to eliminate messing about with the refresh clock
134 @ as the system will restore with the original speed settings
136 @ Ben Dooks, 13-Sep-2004
139 ldr r8, [r6] @ keep original value for resume
141 @ ensure x1 for run and turbo mode with memory clock
142 bic r7, r8, #CCCR_M_MASK | CCCR_N_MASK
143 orr r7, r7, #(1<<5) | (2<<7)
145 @ check that the memory frequency is within limits
146 and r14, r7, #CCCR_L_MASK
148 bicne r7, r7, #CCCR_L_MASK
149 orrne r7, r7, #1 @@ 99.53MHz
151 @ get ready for the change
153 @ note, turbo is not preserved over sleep so there is no
154 @ point in preserving it here. we save it on the stack with the
155 @ other CP registers instead.
157 mcr p14, 0, r0, c6, c0, 0
158 orr r0, r0, #2 @ initiate change bit
166 @ All needed values are now in registers.
167 @ These last instructions should be in cache
169 @ initiate the frequency change...
171 mcr p14, 0, r0, c6, c0, 0
173 @ restore the original cpu speed value for resume
176 @ need 6 13-MHz cycles before changing PWRMODE
177 @ just set frequency to 91-MHz... 6*91/13 = 42
184 @ Intel PXA270 Specification Update notes problems performing
185 @ external accesses after SDRAM is put in self-refresh mode
186 @ (see Errata 39 ...hangs when entering self-refresh mode)
188 @ force address lines low by reading at physical address 0
191 @ put SDRAM into self-refresh
195 mcr p14, 0, r1, c7, c0, 0 @ PWRMODE
197 20: b 20b @ loop waiting for sleep
202 * entry point from bootloader into kernel during resume
207 #ifndef CONFIG_IWMMXT
210 ldmfd sp!, {r4 - r12, pc} @ return to caller