diff options
Diffstat (limited to 'arch/arm/mach-pxa/sleep.S')
-rw-r--r-- | arch/arm/mach-pxa/sleep.S | 191 |
1 files changed, 15 insertions, 176 deletions
diff --git a/arch/arm/mach-pxa/sleep.S b/arch/arm/mach-pxa/sleep.S index c551da86baf6..6f5368899d84 100644 --- a/arch/arm/mach-pxa/sleep.S +++ b/arch/arm/mach-pxa/sleep.S | |||
@@ -22,133 +22,26 @@ | |||
22 | 22 | ||
23 | .text | 23 | .text |
24 | 24 | ||
25 | pxa_cpu_save_cp: | ||
26 | @ get coprocessor registers | ||
27 | mrc p14, 0, r3, c6, c0, 0 @ clock configuration, for turbo mode | ||
28 | mrc p15, 0, r4, c15, c1, 0 @ CP access reg | ||
29 | mrc p15, 0, r5, c13, c0, 0 @ PID | ||
30 | mrc p15, 0, r6, c3, c0, 0 @ domain ID | ||
31 | mrc p15, 0, r7, c2, c0, 0 @ translation table base addr | ||
32 | mrc p15, 0, r8, c1, c1, 0 @ auxiliary control reg | ||
33 | mrc p15, 0, r9, c1, c0, 0 @ control reg | ||
34 | |||
35 | bic r3, r3, #2 @ clear frequency change bit | ||
36 | |||
37 | @ store them plus current virtual stack ptr on stack | ||
38 | mov r10, sp | ||
39 | stmfd sp!, {r3 - r10} | ||
40 | |||
41 | mov pc, lr | ||
42 | |||
43 | pxa_cpu_save_sp: | ||
44 | @ preserve phys address of stack | ||
45 | mov r0, sp | ||
46 | str lr, [sp, #-4]! | ||
47 | bl sleep_phys_sp | ||
48 | ldr r1, =sleep_save_sp | ||
49 | str r0, [r1] | ||
50 | ldr pc, [sp], #4 | ||
51 | |||
52 | #ifdef CONFIG_PXA3xx | 25 | #ifdef CONFIG_PXA3xx |
53 | /* | 26 | /* |
54 | * pxa3xx_cpu_suspend() - forces CPU into sleep state (S2D3C4) | 27 | * pxa3xx_cpu_suspend() - forces CPU into sleep state (S2D3C4) |
55 | * | 28 | * |
56 | * NOTE: unfortunately, pxa_cpu_save_cp can not be reused here since | 29 | * r0 = v:p offset |
57 | * the auxiliary control register address is different between pxa3xx | ||
58 | * and pxa{25x,27x} | ||
59 | */ | 30 | */ |
60 | |||
61 | ENTRY(pxa3xx_cpu_suspend) | 31 | ENTRY(pxa3xx_cpu_suspend) |
62 | 32 | ||
63 | #ifndef CONFIG_IWMMXT | 33 | #ifndef CONFIG_IWMMXT |
64 | mra r2, r3, acc0 | 34 | mra r2, r3, acc0 |
65 | #endif | 35 | #endif |
66 | stmfd sp!, {r2 - r12, lr} @ save registers on stack | 36 | stmfd sp!, {r2 - r12, lr} @ save registers on stack |
67 | 37 | mov r1, r0 | |
68 | mrc p14, 0, r3, c6, c0, 0 @ clock configuration, for turbo mode | 38 | ldr r3, =pxa_cpu_resume @ resume function |
69 | mrc p15, 0, r4, c15, c1, 0 @ CP access reg | 39 | bl cpu_suspend |
70 | mrc p15, 0, r5, c13, c0, 0 @ PID | ||
71 | mrc p15, 0, r6, c3, c0, 0 @ domain ID | ||
72 | mrc p15, 0, r7, c2, c0, 0 @ translation table base addr | ||
73 | mrc p15, 0, r8, c1, c0, 1 @ auxiliary control reg | ||
74 | mrc p15, 0, r9, c1, c0, 0 @ control reg | ||
75 | |||
76 | bic r3, r3, #2 @ clear frequency change bit | ||
77 | |||
78 | @ store them plus current virtual stack ptr on stack | ||
79 | mov r10, sp | ||
80 | stmfd sp!, {r3 - r10} | ||
81 | |||
82 | @ store physical address of stack pointer | ||
83 | mov r0, sp | ||
84 | bl sleep_phys_sp | ||
85 | ldr r1, =sleep_save_sp | ||
86 | str r0, [r1] | ||
87 | |||
88 | @ clean data cache | ||
89 | bl xsc3_flush_kern_cache_all | ||
90 | 40 | ||
91 | mov r0, #0x06 @ S2D3C4 mode | 41 | mov r0, #0x06 @ S2D3C4 mode |
92 | mcr p14, 0, r0, c7, c0, 0 @ enter sleep | 42 | mcr p14, 0, r0, c7, c0, 0 @ enter sleep |
93 | 43 | ||
94 | 20: b 20b @ waiting for sleep | 44 | 20: b 20b @ waiting for sleep |
95 | |||
96 | .data | ||
97 | .align 5 | ||
98 | /* | ||
99 | * pxa3xx_cpu_resume | ||
100 | */ | ||
101 | |||
102 | ENTRY(pxa3xx_cpu_resume) | ||
103 | |||
104 | mov r0, #PSR_I_BIT | PSR_F_BIT | SVC_MODE @ set SVC, irqs off | ||
105 | msr cpsr_c, r0 | ||
106 | |||
107 | ldr r0, sleep_save_sp @ stack phys addr | ||
108 | ldmfd r0, {r3 - r9, sp} @ CP regs + virt stack ptr | ||
109 | |||
110 | mov r1, #0 | ||
111 | mcr p15, 0, r1, c7, c7, 0 @ invalidate I & D caches, BTB | ||
112 | mcr p15, 0, r1, c7, c10, 4 @ drain write (&fill) buffer | ||
113 | mcr p15, 0, r1, c7, c5, 4 @ flush prefetch buffer | ||
114 | mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs | ||
115 | |||
116 | mcr p14, 0, r3, c6, c0, 0 @ clock configuration, turbo mode. | ||
117 | mcr p15, 0, r4, c15, c1, 0 @ CP access reg | ||
118 | mcr p15, 0, r5, c13, c0, 0 @ PID | ||
119 | mcr p15, 0, r6, c3, c0, 0 @ domain ID | ||
120 | mcr p15, 0, r7, c2, c0, 0 @ translation table base addr | ||
121 | mcr p15, 0, r8, c1, c0, 1 @ auxiliary control reg | ||
122 | |||
123 | @ temporarily map resume_turn_on_mmu into the page table, | ||
124 | @ otherwise prefetch abort occurs after MMU is turned on | ||
125 | mov r1, r7 | ||
126 | bic r1, r1, #0x00ff | ||
127 | bic r1, r1, #0x3f00 | ||
128 | ldr r2, =0x542e | ||
129 | |||
130 | adr r3, resume_turn_on_mmu | ||
131 | mov r3, r3, lsr #20 | ||
132 | orr r4, r2, r3, lsl #20 | ||
133 | ldr r5, [r1, r3, lsl #2] | ||
134 | str r4, [r1, r3, lsl #2] | ||
135 | |||
136 | @ Mapping page table address in the page table | ||
137 | mov r6, r1, lsr #20 | ||
138 | orr r7, r2, r6, lsl #20 | ||
139 | ldr r8, [r1, r6, lsl #2] | ||
140 | str r7, [r1, r6, lsl #2] | ||
141 | |||
142 | ldr r2, =pxa3xx_resume_after_mmu @ absolute virtual address | ||
143 | b resume_turn_on_mmu @ cache align execution | ||
144 | |||
145 | .text | ||
146 | pxa3xx_resume_after_mmu: | ||
147 | /* restore the temporary mapping */ | ||
148 | str r5, [r1, r3, lsl #2] | ||
149 | str r8, [r1, r6, lsl #2] | ||
150 | b resume_after_mmu | ||
151 | |||
152 | #endif /* CONFIG_PXA3xx */ | 45 | #endif /* CONFIG_PXA3xx */ |
153 | 46 | ||
154 | #ifdef CONFIG_PXA27x | 47 | #ifdef CONFIG_PXA27x |
@@ -158,28 +51,23 @@ pxa3xx_resume_after_mmu: | |||
158 | * Forces CPU into sleep state. | 51 | * Forces CPU into sleep state. |
159 | * | 52 | * |
160 | * r0 = value for PWRMODE M field for desired sleep state | 53 | * r0 = value for PWRMODE M field for desired sleep state |
54 | * r1 = v:p offset | ||
161 | */ | 55 | */ |
162 | |||
163 | ENTRY(pxa27x_cpu_suspend) | 56 | ENTRY(pxa27x_cpu_suspend) |
164 | 57 | ||
165 | #ifndef CONFIG_IWMMXT | 58 | #ifndef CONFIG_IWMMXT |
166 | mra r2, r3, acc0 | 59 | mra r2, r3, acc0 |
167 | #endif | 60 | #endif |
168 | stmfd sp!, {r2 - r12, lr} @ save registers on stack | 61 | stmfd sp!, {r2 - r12, lr} @ save registers on stack |
169 | 62 | mov r4, r0 @ save sleep mode | |
170 | bl pxa_cpu_save_cp | 63 | ldr r3, =pxa_cpu_resume @ resume function |
171 | 64 | bl cpu_suspend | |
172 | mov r5, r0 @ save sleep mode | ||
173 | bl pxa_cpu_save_sp | ||
174 | |||
175 | @ clean data cache | ||
176 | bl xscale_flush_kern_cache_all | ||
177 | 65 | ||
178 | @ Put the processor to sleep | 66 | @ Put the processor to sleep |
179 | @ (also workaround for sighting 28071) | 67 | @ (also workaround for sighting 28071) |
180 | 68 | ||
181 | @ prepare value for sleep mode | 69 | @ prepare value for sleep mode |
182 | mov r1, r5 @ sleep mode | 70 | mov r1, r4 @ sleep mode |
183 | 71 | ||
184 | @ prepare pointer to physical address 0 (virtual mapping in generic.c) | 72 | @ prepare pointer to physical address 0 (virtual mapping in generic.c) |
185 | mov r2, #UNCACHED_PHYS_0 | 73 | mov r2, #UNCACHED_PHYS_0 |
@@ -216,21 +104,16 @@ ENTRY(pxa27x_cpu_suspend) | |||
216 | * Forces CPU into sleep state. | 104 | * Forces CPU into sleep state. |
217 | * | 105 | * |
218 | * r0 = value for PWRMODE M field for desired sleep state | 106 | * r0 = value for PWRMODE M field for desired sleep state |
107 | * r1 = v:p offset | ||
219 | */ | 108 | */ |
220 | 109 | ||
221 | ENTRY(pxa25x_cpu_suspend) | 110 | ENTRY(pxa25x_cpu_suspend) |
222 | stmfd sp!, {r2 - r12, lr} @ save registers on stack | 111 | stmfd sp!, {r2 - r12, lr} @ save registers on stack |
223 | 112 | mov r4, r0 @ save sleep mode | |
224 | bl pxa_cpu_save_cp | 113 | ldr r3, =pxa_cpu_resume @ resume function |
225 | 114 | bl cpu_suspend | |
226 | mov r5, r0 @ save sleep mode | ||
227 | bl pxa_cpu_save_sp | ||
228 | |||
229 | @ clean data cache | ||
230 | bl xscale_flush_kern_cache_all | ||
231 | |||
232 | @ prepare value for sleep mode | 115 | @ prepare value for sleep mode |
233 | mov r1, r5 @ sleep mode | 116 | mov r1, r4 @ sleep mode |
234 | 117 | ||
235 | @ prepare pointer to physical address 0 (virtual mapping in generic.c) | 118 | @ prepare pointer to physical address 0 (virtual mapping in generic.c) |
236 | mov r2, #UNCACHED_PHYS_0 | 119 | mov r2, #UNCACHED_PHYS_0 |
@@ -317,53 +200,9 @@ pxa_cpu_do_suspend: | |||
317 | * pxa_cpu_resume() | 200 | * pxa_cpu_resume() |
318 | * | 201 | * |
319 | * entry point from bootloader into kernel during resume | 202 | * entry point from bootloader into kernel during resume |
320 | * | ||
321 | * Note: Yes, part of the following code is located into the .data section. | ||
322 | * This is to allow sleep_save_sp to be accessed with a relative load | ||
323 | * while we can't rely on any MMU translation. We could have put | ||
324 | * sleep_save_sp in the .text section as well, but some setups might | ||
325 | * insist on it to be truly read-only. | ||
326 | */ | 203 | */ |
327 | |||
328 | .data | ||
329 | .align 5 | ||
330 | ENTRY(pxa_cpu_resume) | ||
331 | mov r0, #PSR_I_BIT | PSR_F_BIT | SVC_MODE @ set SVC, irqs off | ||
332 | msr cpsr_c, r0 | ||
333 | |||
334 | ldr r0, sleep_save_sp @ stack phys addr | ||
335 | ldr r2, =resume_after_mmu @ its absolute virtual address | ||
336 | ldmfd r0, {r3 - r9, sp} @ CP regs + virt stack ptr | ||
337 | |||
338 | mov r1, #0 | ||
339 | mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs | ||
340 | mcr p15, 0, r1, c7, c7, 0 @ invalidate I & D caches, BTB | ||
341 | |||
342 | mcr p14, 0, r3, c6, c0, 0 @ clock configuration, turbo mode. | ||
343 | mcr p15, 0, r4, c15, c1, 0 @ CP access reg | ||
344 | mcr p15, 0, r5, c13, c0, 0 @ PID | ||
345 | mcr p15, 0, r6, c3, c0, 0 @ domain ID | ||
346 | mcr p15, 0, r7, c2, c0, 0 @ translation table base addr | ||
347 | mcr p15, 0, r8, c1, c1, 0 @ auxiliary control reg | ||
348 | b resume_turn_on_mmu @ cache align execution | ||
349 | |||
350 | .align 5 | 204 | .align 5 |
351 | resume_turn_on_mmu: | 205 | pxa_cpu_resume: |
352 | mcr p15, 0, r9, c1, c0, 0 @ turn on MMU, caches, etc. | ||
353 | |||
354 | @ Let us ensure we jump to resume_after_mmu only when the mcr above | ||
355 | @ actually took effect. They call it the "cpwait" operation. | ||
356 | mrc p15, 0, r0, c2, c0, 0 @ queue a dependency on CP15 | ||
357 | sub pc, r2, r0, lsr #32 @ jump to virtual addr | ||
358 | nop | ||
359 | nop | ||
360 | nop | ||
361 | |||
362 | sleep_save_sp: | ||
363 | .word 0 @ preserve stack phys ptr here | ||
364 | |||
365 | .text | ||
366 | resume_after_mmu: | ||
367 | ldmfd sp!, {r2, r3} | 206 | ldmfd sp!, {r2, r3} |
368 | #ifndef CONFIG_IWMMXT | 207 | #ifndef CONFIG_IWMMXT |
369 | mar acc0, r2, r3 | 208 | mar acc0, r2, r3 |