Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: pm: add generic CPU suspend/resume support

This adds core support for saving and restoring CPU coprocessor
registers for suspend/resume support. This contains support for suspend
with ARM920, ARM926, SA11x0, PXA25x, PXA27x, PXA3xx, V6 and V7 CPUs.
Tested on Assabet and Tegra 2.

Tested-by: Colin Cross <ccross@android.com>
Tested-by: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

+522 -33
+3
arch/arm/include/asm/glue-proc.h
··· 256 256 #define cpu_dcache_clean_area __glue(CPU_NAME,_dcache_clean_area) 257 257 #define cpu_do_switch_mm __glue(CPU_NAME,_switch_mm) 258 258 #define cpu_set_pte_ext __glue(CPU_NAME,_set_pte_ext) 259 + #define cpu_suspend_size __glue(CPU_NAME,_suspend_size) 260 + #define cpu_do_suspend __glue(CPU_NAME,_do_suspend) 261 + #define cpu_do_resume __glue(CPU_NAME,_do_resume) 259 262 #endif 260 263 261 264 #endif
+7
arch/arm/include/asm/proc-fns.h
··· 66 66 * ignore 'ext'. 67 67 */ 68 68 void (*set_pte_ext)(pte_t *ptep, pte_t pte, unsigned int ext); 69 + 70 + /* Suspend/resume */ 71 + unsigned int suspend_size; 72 + void (*do_suspend)(void *); 73 + void (*do_resume)(void *); 69 74 } processor; 70 75 71 76 #ifndef MULTI_CPU ··· 90 85 #define cpu_set_pte_ext(ptep,pte,ext) processor.set_pte_ext(ptep,pte,ext) 91 86 #define cpu_do_switch_mm(pgd,mm) processor.switch_mm(pgd,mm) 92 87 #endif 88 + 89 + extern void cpu_resume(void); 93 90 94 91 #include <asm/memory.h> 95 92
+1
arch/arm/kernel/Makefile
··· 29 29 obj-$(CONFIG_ARTHUR) += arthur.o 30 30 obj-$(CONFIG_ISA_DMA) += dma-isa.o 31 31 obj-$(CONFIG_PCI) += bios32.o isa.o 32 + obj-$(CONFIG_PM) += sleep.o 32 33 obj-$(CONFIG_HAVE_SCHED_CLOCK) += sched_clock.o 33 34 obj-$(CONFIG_SMP) += smp.o smp_tlb.o 34 35 obj-$(CONFIG_HAVE_ARM_SCU) += smp_scu.o
+9
arch/arm/kernel/asm-offsets.c
··· 13 13 #include <linux/sched.h> 14 14 #include <linux/mm.h> 15 15 #include <linux/dma-mapping.h> 16 + #include <asm/cacheflush.h> 16 17 #include <asm/glue-df.h> 17 18 #include <asm/glue-pf.h> 18 19 #include <asm/mach/arch.h> ··· 116 115 #endif 117 116 #ifdef MULTI_PABORT 118 117 DEFINE(PROCESSOR_PABT_FUNC, offsetof(struct processor, _prefetch_abort)); 118 + #endif 119 + #ifdef MULTI_CPU 120 + DEFINE(CPU_SLEEP_SIZE, offsetof(struct processor, suspend_size)); 121 + DEFINE(CPU_DO_SUSPEND, offsetof(struct processor, do_suspend)); 122 + DEFINE(CPU_DO_RESUME, offsetof(struct processor, do_resume)); 123 + #endif 124 + #ifdef MULTI_CACHE 125 + DEFINE(CACHE_FLUSH_KERN_ALL, offsetof(struct cpu_cache_fns, flush_kern_all)); 119 126 #endif 120 127 BLANK(); 121 128 DEFINE(DMA_BIDIRECTIONAL, DMA_BIDIRECTIONAL);
+109
arch/arm/kernel/sleep.S
··· 1 + #include <linux/linkage.h> 2 + #include <asm/asm-offsets.h> 3 + #include <asm/assembler.h> 4 + #include <asm/glue-cache.h> 5 + #include <asm/glue-proc.h> 6 + #include <asm/system.h> 7 + .text 8 + 9 + /* 10 + * Save CPU state for a suspend 11 + * r1 = v:p offset 12 + * r3 = virtual return function 13 + * Note: sp is decremented to allocate space for CPU state on stack 14 + * r0-r3,r9,r10,lr corrupted 15 + */ 16 + ENTRY(cpu_suspend) 17 + mov r9, lr 18 + #ifdef MULTI_CPU 19 + ldr r10, =processor 20 + mov r2, sp @ current virtual SP 21 + ldr r0, [r10, #CPU_SLEEP_SIZE] @ size of CPU sleep state 22 + ldr ip, [r10, #CPU_DO_RESUME] @ virtual resume function 23 + sub sp, sp, r0 @ allocate CPU state on stack 24 + mov r0, sp @ save pointer 25 + add ip, ip, r1 @ convert resume fn to phys 26 + stmfd sp!, {r1, r2, r3, ip} @ save v:p, virt SP, retfn, phys resume fn 27 + ldr r3, =sleep_save_sp 28 + add r2, sp, r1 @ convert SP to phys 29 + str r2, [r3] @ save phys SP 30 + mov lr, pc 31 + ldr pc, [r10, #CPU_DO_SUSPEND] @ save CPU state 32 + #else 33 + mov r2, sp @ current virtual SP 34 + ldr r0, =cpu_suspend_size 35 + sub sp, sp, r0 @ allocate CPU state on stack 36 + mov r0, sp @ save pointer 37 + stmfd sp!, {r1, r2, r3} @ save v:p, virt SP, return fn 38 + ldr r3, =sleep_save_sp 39 + add r2, sp, r1 @ convert SP to phys 40 + str r2, [r3] @ save phys SP 41 + bl cpu_do_suspend 42 + #endif 43 + 44 + @ flush data cache 45 + #ifdef MULTI_CACHE 46 + ldr r10, =cpu_cache 47 + mov lr, r9 48 + ldr pc, [r10, #CACHE_FLUSH_KERN_ALL] 49 + #else 50 + mov lr, r9 51 + b __cpuc_flush_kern_all 52 + #endif 53 + ENDPROC(cpu_suspend) 54 + .ltorg 55 + 56 + /* 57 + * r0 = control register value 58 + * r1 = v:p offset (preserved by cpu_do_resume) 59 + * r2 = phys page table base 60 + * r3 = L1 section flags 61 + */ 62 + ENTRY(cpu_resume_mmu) 63 + adr r4, cpu_resume_turn_mmu_on 64 + mov r4, r4, lsr #20 65 + orr r3, r3, r4, lsl #20 66 + ldr r5, [r2, r4, lsl #2] @ save old mapping 67 + str r3, [r2, r4, lsl #2] @ setup 1:1 mapping for mmu code 68 + sub r2, r2, r1 69 + ldr r3, =cpu_resume_after_mmu 70 + bic r1, r0, #CR_C @ ensure D-cache is disabled 71 + b cpu_resume_turn_mmu_on 72 + ENDPROC(cpu_resume_mmu) 73 + .ltorg 74 + .align 5 75 + cpu_resume_turn_mmu_on: 76 + mcr p15, 0, r1, c1, c0, 0 @ turn on MMU, I-cache, etc 77 + mrc p15, 0, r1, c0, c0, 0 @ read id reg 78 + mov r1, r1 79 + mov r1, r1 80 + mov pc, r3 @ jump to virtual address 81 + ENDPROC(cpu_resume_turn_mmu_on) 82 + cpu_resume_after_mmu: 83 + str r5, [r2, r4, lsl #2] @ restore old mapping 84 + mcr p15, 0, r0, c1, c0, 0 @ turn on D-cache 85 + mov pc, lr 86 + ENDPROC(cpu_resume_after_mmu) 87 + 88 + /* 89 + * Note: Yes, part of the following code is located into the .data section. 90 + * This is to allow sleep_save_sp to be accessed with a relative load 91 + * while we can't rely on any MMU translation. We could have put 92 + * sleep_save_sp in the .text section as well, but some setups might 93 + * insist on it to be truly read-only. 94 + */ 95 + .data 96 + .align 97 + ENTRY(cpu_resume) 98 + ldr r0, sleep_save_sp @ stack phys addr 99 + msr cpsr_c, #PSR_I_BIT | PSR_F_BIT | SVC_MODE @ set SVC, irqs off 100 + #ifdef MULTI_CPU 101 + ldmia r0!, {r1, sp, lr, pc} @ load v:p, stack, return fn, resume fn 102 + #else 103 + ldmia r0!, {r1, sp, lr} @ load v:p, stack, return fn 104 + b cpu_do_resume 105 + #endif 106 + ENDPROC(cpu_resume) 107 + 108 + sleep_save_sp: 109 + .word 0 @ preserve stack phys ptr here
+3
arch/arm/mm/proc-arm1020.S
··· 493 493 .word cpu_arm1020_dcache_clean_area 494 494 .word cpu_arm1020_switch_mm 495 495 .word cpu_arm1020_set_pte_ext 496 + .word 0 497 + .word 0 498 + .word 0 496 499 .size arm1020_processor_functions, . - arm1020_processor_functions 497 500 498 501 .section ".rodata"
+3
arch/arm/mm/proc-arm1020e.S
··· 474 474 .word cpu_arm1020e_dcache_clean_area 475 475 .word cpu_arm1020e_switch_mm 476 476 .word cpu_arm1020e_set_pte_ext 477 + .word 0 478 + .word 0 479 + .word 0 477 480 .size arm1020e_processor_functions, . - arm1020e_processor_functions 478 481 479 482 .section ".rodata"
+3
arch/arm/mm/proc-arm1022.S
··· 457 457 .word cpu_arm1022_dcache_clean_area 458 458 .word cpu_arm1022_switch_mm 459 459 .word cpu_arm1022_set_pte_ext 460 + .word 0 461 + .word 0 462 + .word 0 460 463 .size arm1022_processor_functions, . - arm1022_processor_functions 461 464 462 465 .section ".rodata"
+3
arch/arm/mm/proc-arm1026.S
··· 452 452 .word cpu_arm1026_dcache_clean_area 453 453 .word cpu_arm1026_switch_mm 454 454 .word cpu_arm1026_set_pte_ext 455 + .word 0 456 + .word 0 457 + .word 0 455 458 .size arm1026_processor_functions, . - arm1026_processor_functions 456 459 457 460 .section .rodata
+6
arch/arm/mm/proc-arm6_7.S
··· 284 284 .word cpu_arm6_dcache_clean_area 285 285 .word cpu_arm6_switch_mm 286 286 .word cpu_arm6_set_pte_ext 287 + .word 0 288 + .word 0 289 + .word 0 287 290 .size arm6_processor_functions, . - arm6_processor_functions 288 291 289 292 /* ··· 304 301 .word cpu_arm7_dcache_clean_area 305 302 .word cpu_arm7_switch_mm 306 303 .word cpu_arm7_set_pte_ext 304 + .word 0 305 + .word 0 306 + .word 0 307 307 .size arm7_processor_functions, . - arm7_processor_functions 308 308 309 309 .section ".rodata"
+3
arch/arm/mm/proc-arm720.S
··· 185 185 .word cpu_arm720_dcache_clean_area 186 186 .word cpu_arm720_switch_mm 187 187 .word cpu_arm720_set_pte_ext 188 + .word 0 189 + .word 0 190 + .word 0 188 191 .size arm720_processor_functions, . - arm720_processor_functions 189 192 190 193 .section ".rodata"
+3
arch/arm/mm/proc-arm740.S
··· 130 130 .word cpu_arm740_dcache_clean_area 131 131 .word cpu_arm740_switch_mm 132 132 .word 0 @ cpu_*_set_pte 133 + .word 0 134 + .word 0 135 + .word 0 133 136 .size arm740_processor_functions, . - arm740_processor_functions 134 137 135 138 .section ".rodata"
+3
arch/arm/mm/proc-arm7tdmi.S
··· 70 70 .word cpu_arm7tdmi_dcache_clean_area 71 71 .word cpu_arm7tdmi_switch_mm 72 72 .word 0 @ cpu_*_set_pte 73 + .word 0 74 + .word 0 75 + .word 0 73 76 .size arm7tdmi_processor_functions, . - arm7tdmi_processor_functions 74 77 75 78 .section ".rodata"
+37
arch/arm/mm/proc-arm920.S
··· 387 387 #endif 388 388 mov pc, lr 389 389 390 + /* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */ 391 + .globl cpu_arm920_suspend_size 392 + .equ cpu_arm920_suspend_size, 4 * 3 393 + #ifdef CONFIG_PM 394 + ENTRY(cpu_arm920_do_suspend) 395 + stmfd sp!, {r4 - r7, lr} 396 + mrc p15, 0, r4, c13, c0, 0 @ PID 397 + mrc p15, 0, r5, c3, c0, 0 @ Domain ID 398 + mrc p15, 0, r6, c2, c0, 0 @ TTB address 399 + mrc p15, 0, r7, c1, c0, 0 @ Control register 400 + stmia r0, {r4 - r7} 401 + ldmfd sp!, {r4 - r7, pc} 402 + ENDPROC(cpu_arm920_do_suspend) 403 + 404 + ENTRY(cpu_arm920_do_resume) 405 + mov ip, #0 406 + mcr p15, 0, ip, c8, c7, 0 @ invalidate I+D TLBs 407 + mcr p15, 0, ip, c7, c7, 0 @ invalidate I+D caches 408 + ldmia r0, {r4 - r7} 409 + mcr p15, 0, r4, c13, c0, 0 @ PID 410 + mcr p15, 0, r5, c3, c0, 0 @ Domain ID 411 + mcr p15, 0, r6, c2, c0, 0 @ TTB address 412 + mov r0, r7 @ control register 413 + mov r2, r6, lsr #14 @ get TTB0 base 414 + mov r2, r2, lsl #14 415 + ldr r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ 416 + PMD_SECT_CACHEABLE | PMD_BIT4 | PMD_SECT_AP_WRITE 417 + b cpu_resume_mmu 418 + ENDPROC(cpu_arm920_do_resume) 419 + #else 420 + #define cpu_arm920_do_suspend 0 421 + #define cpu_arm920_do_resume 0 422 + #endif 423 + 390 424 __CPUINIT 391 425 392 426 .type __arm920_setup, #function ··· 466 432 .word cpu_arm920_dcache_clean_area 467 433 .word cpu_arm920_switch_mm 468 434 .word cpu_arm920_set_pte_ext 435 + .word cpu_arm920_suspend_size 436 + .word cpu_arm920_do_suspend 437 + .word cpu_arm920_do_resume 469 438 .size arm920_processor_functions, . - arm920_processor_functions 470 439 471 440 .section ".rodata"
+3
arch/arm/mm/proc-arm922.S
··· 436 436 .word cpu_arm922_dcache_clean_area 437 437 .word cpu_arm922_switch_mm 438 438 .word cpu_arm922_set_pte_ext 439 + .word 0 440 + .word 0 441 + .word 0 439 442 .size arm922_processor_functions, . - arm922_processor_functions 440 443 441 444 .section ".rodata"
+3
arch/arm/mm/proc-arm925.S
··· 503 503 .word cpu_arm925_dcache_clean_area 504 504 .word cpu_arm925_switch_mm 505 505 .word cpu_arm925_set_pte_ext 506 + .word 0 507 + .word 0 508 + .word 0 506 509 .size arm925_processor_functions, . - arm925_processor_functions 507 510 508 511 .section ".rodata"
+37
arch/arm/mm/proc-arm926.S
··· 401 401 #endif 402 402 mov pc, lr 403 403 404 + /* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */ 405 + .globl cpu_arm926_suspend_size 406 + .equ cpu_arm926_suspend_size, 4 * 3 407 + #ifdef CONFIG_PM 408 + ENTRY(cpu_arm926_do_suspend) 409 + stmfd sp!, {r4 - r7, lr} 410 + mrc p15, 0, r4, c13, c0, 0 @ PID 411 + mrc p15, 0, r5, c3, c0, 0 @ Domain ID 412 + mrc p15, 0, r6, c2, c0, 0 @ TTB address 413 + mrc p15, 0, r7, c1, c0, 0 @ Control register 414 + stmia r0, {r4 - r7} 415 + ldmfd sp!, {r4 - r7, pc} 416 + ENDPROC(cpu_arm926_do_suspend) 417 + 418 + ENTRY(cpu_arm926_do_resume) 419 + mov ip, #0 420 + mcr p15, 0, ip, c8, c7, 0 @ invalidate I+D TLBs 421 + mcr p15, 0, ip, c7, c7, 0 @ invalidate I+D caches 422 + ldmia r0, {r4 - r7} 423 + mcr p15, 0, r4, c13, c0, 0 @ PID 424 + mcr p15, 0, r5, c3, c0, 0 @ Domain ID 425 + mcr p15, 0, r6, c2, c0, 0 @ TTB address 426 + mov r0, r7 @ control register 427 + mov r2, r6, lsr #14 @ get TTB0 base 428 + mov r2, r2, lsl #14 429 + ldr r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ 430 + PMD_SECT_CACHEABLE | PMD_BIT4 | PMD_SECT_AP_WRITE 431 + b cpu_resume_mmu 432 + ENDPROC(cpu_arm926_do_resume) 433 + #else 434 + #define cpu_arm926_do_suspend 0 435 + #define cpu_arm926_do_resume 0 436 + #endif 437 + 404 438 __CPUINIT 405 439 406 440 .type __arm926_setup, #function ··· 490 456 .word cpu_arm926_dcache_clean_area 491 457 .word cpu_arm926_switch_mm 492 458 .word cpu_arm926_set_pte_ext 459 + .word cpu_arm926_suspend_size 460 + .word cpu_arm926_do_suspend 461 + .word cpu_arm926_do_resume 493 462 .size arm926_processor_functions, . - arm926_processor_functions 494 463 495 464 .section ".rodata"
+3
arch/arm/mm/proc-arm940.S
··· 363 363 .word cpu_arm940_dcache_clean_area 364 364 .word cpu_arm940_switch_mm 365 365 .word 0 @ cpu_*_set_pte 366 + .word 0 367 + .word 0 368 + .word 0 366 369 .size arm940_processor_functions, . - arm940_processor_functions 367 370 368 371 .section ".rodata"
+3
arch/arm/mm/proc-arm946.S
··· 419 419 .word cpu_arm946_dcache_clean_area 420 420 .word cpu_arm946_switch_mm 421 421 .word 0 @ cpu_*_set_pte 422 + .word 0 423 + .word 0 424 + .word 0 422 425 .size arm946_processor_functions, . - arm946_processor_functions 423 426 424 427 .section ".rodata"
+3
arch/arm/mm/proc-arm9tdmi.S
··· 70 70 .word cpu_arm9tdmi_dcache_clean_area 71 71 .word cpu_arm9tdmi_switch_mm 72 72 .word 0 @ cpu_*_set_pte 73 + .word 0 74 + .word 0 75 + .word 0 73 76 .size arm9tdmi_processor_functions, . - arm9tdmi_processor_functions 74 77 75 78 .section ".rodata"
+3
arch/arm/mm/proc-fa526.S
··· 195 195 .word cpu_fa526_dcache_clean_area 196 196 .word cpu_fa526_switch_mm 197 197 .word cpu_fa526_set_pte_ext 198 + .word 0 199 + .word 0 200 + .word 0 198 201 .size fa526_processor_functions, . - fa526_processor_functions 199 202 200 203 .section ".rodata"
+3
arch/arm/mm/proc-feroceon.S
··· 554 554 .word cpu_feroceon_dcache_clean_area 555 555 .word cpu_feroceon_switch_mm 556 556 .word cpu_feroceon_set_pte_ext 557 + .word 0 558 + .word 0 559 + .word 0 557 560 .size feroceon_processor_functions, . - feroceon_processor_functions 558 561 559 562 .section ".rodata"
+3
arch/arm/mm/proc-mohawk.S
··· 388 388 .word cpu_mohawk_dcache_clean_area 389 389 .word cpu_mohawk_switch_mm 390 390 .word cpu_mohawk_set_pte_ext 391 + .word 0 392 + .word 0 393 + .word 0 391 394 .size mohawk_processor_functions, . - mohawk_processor_functions 392 395 393 396 .section ".rodata"
+3
arch/arm/mm/proc-sa110.S
··· 203 203 .word cpu_sa110_dcache_clean_area 204 204 .word cpu_sa110_switch_mm 205 205 .word cpu_sa110_set_pte_ext 206 + .word 0 207 + .word 0 208 + .word 0 206 209 .size sa110_processor_functions, . - sa110_processor_functions 207 210 208 211 .section ".rodata"
+39
arch/arm/mm/proc-sa1100.S
··· 169 169 #endif 170 170 mov pc, lr 171 171 172 + .globl cpu_sa1100_suspend_size 173 + .equ cpu_sa1100_suspend_size, 4*4 174 + #ifdef CONFIG_PM 175 + ENTRY(cpu_sa1100_do_suspend) 176 + stmfd sp!, {r4 - r7, lr} 177 + mrc p15, 0, r4, c3, c0, 0 @ domain ID 178 + mrc p15, 0, r5, c2, c0, 0 @ translation table base addr 179 + mrc p15, 0, r6, c13, c0, 0 @ PID 180 + mrc p15, 0, r7, c1, c0, 0 @ control reg 181 + stmia r0, {r4 - r7} @ store cp regs 182 + ldmfd sp!, {r4 - r7, pc} 183 + ENDPROC(cpu_sa1100_do_suspend) 184 + 185 + ENTRY(cpu_sa1100_do_resume) 186 + ldmia r0, {r4 - r7} @ load cp regs 187 + mov r1, #0 188 + mcr p15, 0, r1, c8, c7, 0 @ flush I+D TLBs 189 + mcr p15, 0, r1, c7, c7, 0 @ flush I&D cache 190 + mcr p15, 0, r1, c9, c0, 0 @ invalidate RB 191 + mcr p15, 0, r1, c9, c0, 5 @ allow user space to use RB 192 + 193 + mcr p15, 0, r4, c3, c0, 0 @ domain ID 194 + mcr p15, 0, r5, c2, c0, 0 @ translation table base addr 195 + mcr p15, 0, r6, c13, c0, 0 @ PID 196 + mov r0, r7 @ control register 197 + mov r2, r5, lsr #14 @ get TTB0 base 198 + mov r2, r2, lsl #14 199 + ldr r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ 200 + PMD_SECT_CACHEABLE | PMD_SECT_AP_WRITE 201 + b cpu_resume_mmu 202 + ENDPROC(cpu_sa1100_do_resume) 203 + #else 204 + #define cpu_sa1100_do_suspend 0 205 + #define cpu_sa1100_do_resume 0 206 + #endif 207 + 172 208 __CPUINIT 173 209 174 210 .type __sa1100_setup, #function ··· 254 218 .word cpu_sa1100_dcache_clean_area 255 219 .word cpu_sa1100_switch_mm 256 220 .word cpu_sa1100_set_pte_ext 221 + .word cpu_sa1100_suspend_size 222 + .word cpu_sa1100_do_suspend 223 + .word cpu_sa1100_do_resume 257 224 .size sa1100_processor_functions, . - sa1100_processor_functions 258 225 259 226 .section ".rodata"
+50
arch/arm/mm/proc-v6.S
··· 121 121 #endif 122 122 mov pc, lr 123 123 124 + /* Suspend/resume support: taken from arch/arm/mach-s3c64xx/sleep.S */ 125 + .globl cpu_v6_suspend_size 126 + .equ cpu_v6_suspend_size, 4 * 8 127 + #ifdef CONFIG_PM 128 + ENTRY(cpu_v6_do_suspend) 129 + stmfd sp!, {r4 - r11, lr} 130 + mrc p15, 0, r4, c13, c0, 0 @ FCSE/PID 131 + mrc p15, 0, r5, c13, c0, 1 @ Context ID 132 + mrc p15, 0, r6, c3, c0, 0 @ Domain ID 133 + mrc p15, 0, r7, c2, c0, 0 @ Translation table base 0 134 + mrc p15, 0, r8, c2, c0, 1 @ Translation table base 1 135 + mrc p15, 0, r9, c1, c0, 1 @ auxillary control register 136 + mrc p15, 0, r10, c1, c0, 2 @ co-processor access control 137 + mrc p15, 0, r11, c1, c0, 0 @ control register 138 + stmia r0, {r4 - r11} 139 + ldmfd sp!, {r4- r11, pc} 140 + ENDPROC(cpu_v6_do_suspend) 141 + 142 + ENTRY(cpu_v6_do_resume) 143 + mov ip, #0 144 + mcr p15, 0, ip, c7, c14, 0 @ clean+invalidate D cache 145 + mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache 146 + mcr p15, 0, ip, c7, c15, 0 @ clean+invalidate cache 147 + mcr p15, 0, ip, c7, c10, 4 @ drain write buffer 148 + ldmia r0, {r4 - r11} 149 + mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID 150 + mcr p15, 0, r5, c13, c0, 1 @ Context ID 151 + mcr p15, 0, r6, c3, c0, 0 @ Domain ID 152 + mcr p15, 0, r7, c2, c0, 0 @ Translation table base 0 153 + mcr p15, 0, r8, c2, c0, 1 @ Translation table base 1 154 + mcr p15, 0, r9, c1, c0, 1 @ auxillary control register 155 + mcr p15, 0, r10, c1, c0, 2 @ co-processor access control 156 + mcr p15, 0, ip, c2, c0, 2 @ TTB control register 157 + mcr p15, 0, ip, c7, c5, 4 @ ISB 158 + mov r0, r11 @ control register 159 + mov r2, r7, lsr #14 @ get TTB0 base 160 + mov r2, r2, lsl #14 161 + ldr r3, cpu_resume_l1_flags 162 + b cpu_resume_mmu 163 + ENDPROC(cpu_v6_do_resume) 164 + cpu_resume_l1_flags: 165 + ALT_SMP(.long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_FLAGS_SMP) 166 + ALT_UP(.long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_FLAGS_UP) 167 + #else 168 + #define cpu_v6_do_suspend 0 169 + #define cpu_v6_do_resume 0 170 + #endif 124 171 125 172 126 173 .type cpu_v6_name, #object ··· 253 206 .word cpu_v6_dcache_clean_area 254 207 .word cpu_v6_switch_mm 255 208 .word cpu_v6_set_pte_ext 209 + .word cpu_v6_suspend_size 210 + .word cpu_v6_do_suspend 211 + .word cpu_v6_do_resume 256 212 .size v6_processor_functions, . - v6_processor_functions 257 213 258 214 .section ".rodata"
+86 -30
arch/arm/mm/proc-v7.S
··· 171 171 .ascii "ARMv7 Processor" 172 172 .align 173 173 174 + /* 175 + * Memory region attributes with SCTLR.TRE=1 176 + * 177 + * n = TEX[0],C,B 178 + * TR = PRRR[2n+1:2n] - memory type 179 + * IR = NMRR[2n+1:2n] - inner cacheable property 180 + * OR = NMRR[2n+17:2n+16] - outer cacheable property 181 + * 182 + * n TR IR OR 183 + * UNCACHED 000 00 184 + * BUFFERABLE 001 10 00 00 185 + * WRITETHROUGH 010 10 10 10 186 + * WRITEBACK 011 10 11 11 187 + * reserved 110 188 + * WRITEALLOC 111 10 01 01 189 + * DEV_SHARED 100 01 190 + * DEV_NONSHARED 100 01 191 + * DEV_WC 001 10 192 + * DEV_CACHED 011 10 193 + * 194 + * Other attributes: 195 + * 196 + * DS0 = PRRR[16] = 0 - device shareable property 197 + * DS1 = PRRR[17] = 1 - device shareable property 198 + * NS0 = PRRR[18] = 0 - normal shareable property 199 + * NS1 = PRRR[19] = 1 - normal shareable property 200 + * NOS = PRRR[24+n] = 1 - not outer shareable 201 + */ 202 + .equ PRRR, 0xff0a81a8 203 + .equ NMRR, 0x40e040e0 204 + 205 + /* Suspend/resume support: derived from arch/arm/mach-s5pv210/sleep.S */ 206 + .globl cpu_v7_suspend_size 207 + .equ cpu_v7_suspend_size, 4 * 8 208 + #ifdef CONFIG_PM 209 + ENTRY(cpu_v7_do_suspend) 210 + stmfd sp!, {r4 - r11, lr} 211 + mrc p15, 0, r4, c13, c0, 0 @ FCSE/PID 212 + mrc p15, 0, r5, c13, c0, 1 @ Context ID 213 + mrc p15, 0, r6, c3, c0, 0 @ Domain ID 214 + mrc p15, 0, r7, c2, c0, 0 @ TTB 0 215 + mrc p15, 0, r8, c2, c0, 1 @ TTB 1 216 + mrc p15, 0, r9, c1, c0, 0 @ Control register 217 + mrc p15, 0, r10, c1, c0, 1 @ Auxiliary control register 218 + mrc p15, 0, r11, c1, c0, 2 @ Co-processor access control 219 + stmia r0, {r4 - r11} 220 + ldmfd sp!, {r4 - r11, pc} 221 + ENDPROC(cpu_v7_do_suspend) 222 + 223 + ENTRY(cpu_v7_do_resume) 224 + mov ip, #0 225 + mcr p15, 0, ip, c8, c7, 0 @ invalidate TLBs 226 + mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache 227 + ldmia r0, {r4 - r11} 228 + mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID 229 + mcr p15, 0, r5, c13, c0, 1 @ Context ID 230 + mcr p15, 0, r6, c3, c0, 0 @ Domain ID 231 + mcr p15, 0, r7, c2, c0, 0 @ TTB 0 232 + mcr p15, 0, r8, c2, c0, 1 @ TTB 1 233 + mcr p15, 0, ip, c2, c0, 2 @ TTB control register 234 + mcr p15, 0, r10, c1, c0, 1 @ Auxillary control register 235 + mcr p15, 0, r11, c1, c0, 2 @ Co-processor access control 236 + ldr r4, =PRRR @ PRRR 237 + ldr r5, =NMRR @ NMRR 238 + mcr p15, 0, r4, c10, c2, 0 @ write PRRR 239 + mcr p15, 0, r5, c10, c2, 1 @ write NMRR 240 + isb 241 + mov r0, r9 @ control register 242 + mov r2, r7, lsr #14 @ get TTB0 base 243 + mov r2, r2, lsl #14 244 + ldr r3, cpu_resume_l1_flags 245 + b cpu_resume_mmu 246 + ENDPROC(cpu_v7_do_resume) 247 + cpu_resume_l1_flags: 248 + ALT_SMP(.long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_FLAGS_SMP) 249 + ALT_UP(.long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_FLAGS_UP) 250 + #else 251 + #define cpu_v7_do_suspend 0 252 + #define cpu_v7_do_resume 0 253 + #endif 254 + 174 255 __CPUINIT 175 256 176 257 /* ··· 357 276 ALT_SMP(orr r4, r4, #TTB_FLAGS_SMP) 358 277 ALT_UP(orr r4, r4, #TTB_FLAGS_UP) 359 278 mcr p15, 0, r4, c2, c0, 1 @ load TTB1 360 - /* 361 - * Memory region attributes with SCTLR.TRE=1 362 - * 363 - * n = TEX[0],C,B 364 - * TR = PRRR[2n+1:2n] - memory type 365 - * IR = NMRR[2n+1:2n] - inner cacheable property 366 - * OR = NMRR[2n+17:2n+16] - outer cacheable property 367 - * 368 - * n TR IR OR 369 - * UNCACHED 000 00 370 - * BUFFERABLE 001 10 00 00 371 - * WRITETHROUGH 010 10 10 10 372 - * WRITEBACK 011 10 11 11 373 - * reserved 110 374 - * WRITEALLOC 111 10 01 01 375 - * DEV_SHARED 100 01 376 - * DEV_NONSHARED 100 01 377 - * DEV_WC 001 10 378 - * DEV_CACHED 011 10 379 - * 380 - * Other attributes: 381 - * 382 - * DS0 = PRRR[16] = 0 - device shareable property 383 - * DS1 = PRRR[17] = 1 - device shareable property 384 - * NS0 = PRRR[18] = 0 - normal shareable property 385 - * NS1 = PRRR[19] = 1 - normal shareable property 386 - * NOS = PRRR[24+n] = 1 - not outer shareable 387 - */ 388 - ldr r5, =0xff0a81a8 @ PRRR 389 - ldr r6, =0x40e040e0 @ NMRR 279 + ldr r5, =PRRR @ PRRR 280 + ldr r6, =NMRR @ NMRR 390 281 mcr p15, 0, r5, c10, c2, 0 @ write PRRR 391 282 mcr p15, 0, r6, c10, c2, 1 @ write NMRR 392 283 #endif ··· 404 351 .word cpu_v7_dcache_clean_area 405 352 .word cpu_v7_switch_mm 406 353 .word cpu_v7_set_pte_ext 354 + .word 0 355 + .word 0 356 + .word 0 407 357 .size v7_processor_functions, . - v7_processor_functions 408 358 409 359 .section ".rodata"
+47 -1
arch/arm/mm/proc-xsc3.S
··· 413 413 mov pc, lr 414 414 415 415 .ltorg 416 - 417 416 .align 417 + 418 + .globl cpu_xsc3_suspend_size 419 + .equ cpu_xsc3_suspend_size, 4 * 8 420 + #ifdef CONFIG_PM 421 + ENTRY(cpu_xsc3_do_suspend) 422 + stmfd sp!, {r4 - r10, lr} 423 + mrc p14, 0, r4, c6, c0, 0 @ clock configuration, for turbo mode 424 + mrc p15, 0, r5, c15, c1, 0 @ CP access reg 425 + mrc p15, 0, r6, c13, c0, 0 @ PID 426 + mrc p15, 0, r7, c3, c0, 0 @ domain ID 427 + mrc p15, 0, r8, c2, c0, 0 @ translation table base addr 428 + mrc p15, 0, r9, c1, c0, 1 @ auxiliary control reg 429 + mrc p15, 0, r10, c1, c0, 0 @ control reg 430 + bic r4, r4, #2 @ clear frequency change bit 431 + stmia r0, {r1, r4 - r10} @ store v:p offset + cp regs 432 + ldmia sp!, {r4 - r10, pc} 433 + ENDPROC(cpu_xsc3_do_suspend) 434 + 435 + ENTRY(cpu_xsc3_do_resume) 436 + ldmia r0, {r1, r4 - r10} @ load v:p offset + cp regs 437 + mov ip, #0 438 + mcr p15, 0, ip, c7, c7, 0 @ invalidate I & D caches, BTB 439 + mcr p15, 0, ip, c7, c10, 4 @ drain write (&fill) buffer 440 + mcr p15, 0, ip, c7, c5, 4 @ flush prefetch buffer 441 + mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 442 + mcr p14, 0, r4, c6, c0, 0 @ clock configuration, turbo mode. 443 + mcr p15, 0, r5, c15, c1, 0 @ CP access reg 444 + mcr p15, 0, r6, c13, c0, 0 @ PID 445 + mcr p15, 0, r7, c3, c0, 0 @ domain ID 446 + mcr p15, 0, r8, c2, c0, 0 @ translation table base addr 447 + mcr p15, 0, r9, c1, c0, 1 @ auxiliary control reg 448 + 449 + @ temporarily map resume_turn_on_mmu into the page table, 450 + @ otherwise prefetch abort occurs after MMU is turned on 451 + mov r0, r10 @ control register 452 + mov r2, r8, lsr #14 @ get TTB0 base 453 + mov r2, r2, lsl #14 454 + ldr r3, =0x542e @ section flags 455 + b cpu_resume_mmu 456 + ENDPROC(cpu_xsc3_do_resume) 457 + #else 458 + #define cpu_xsc3_do_suspend 0 459 + #define cpu_xsc3_do_resume 0 460 + #endif 418 461 419 462 __CPUINIT 420 463 ··· 519 476 .word cpu_xsc3_dcache_clean_area 520 477 .word cpu_xsc3_switch_mm 521 478 .word cpu_xsc3_set_pte_ext 479 + .word cpu_xsc3_suspend_size 480 + .word cpu_xsc3_do_suspend 481 + .word cpu_xsc3_do_resume 522 482 .size xsc3_processor_functions, . - xsc3_processor_functions 523 483 524 484 .section ".rodata"
+43 -2
arch/arm/mm/proc-xscale.S
··· 513 513 xscale_set_pte_ext_epilogue 514 514 mov pc, lr 515 515 516 - 517 516 .ltorg 518 - 519 517 .align 518 + 519 + .globl cpu_xscale_suspend_size 520 + .equ cpu_xscale_suspend_size, 4 * 7 521 + #ifdef CONFIG_PM 522 + ENTRY(cpu_xscale_do_suspend) 523 + stmfd sp!, {r4 - r10, lr} 524 + mrc p14, 0, r4, c6, c0, 0 @ clock configuration, for turbo mode 525 + mrc p15, 0, r5, c15, c1, 0 @ CP access reg 526 + mrc p15, 0, r6, c13, c0, 0 @ PID 527 + mrc p15, 0, r7, c3, c0, 0 @ domain ID 528 + mrc p15, 0, r8, c2, c0, 0 @ translation table base addr 529 + mrc p15, 0, r9, c1, c1, 0 @ auxiliary control reg 530 + mrc p15, 0, r10, c1, c0, 0 @ control reg 531 + bic r4, r4, #2 @ clear frequency change bit 532 + stmia r0, {r4 - r10} @ store cp regs 533 + ldmfd sp!, {r4 - r10, pc} 534 + ENDPROC(cpu_xscale_do_suspend) 535 + 536 + ENTRY(cpu_xscale_do_resume) 537 + ldmia r0, {r4 - r10} @ load cp regs 538 + mov ip, #0 539 + mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 540 + mcr p15, 0, ip, c7, c7, 0 @ invalidate I & D caches, BTB 541 + mcr p14, 0, r4, c6, c0, 0 @ clock configuration, turbo mode. 542 + mcr p15, 0, r5, c15, c1, 0 @ CP access reg 543 + mcr p15, 0, r6, c13, c0, 0 @ PID 544 + mcr p15, 0, r7, c3, c0, 0 @ domain ID 545 + mcr p15, 0, r8, c2, c0, 0 @ translation table base addr 546 + mcr p15, 0, r9, c1, c1, 0 @ auxiliary control reg 547 + mov r0, r10 @ control register 548 + mov r2, r8, lsr #14 @ get TTB0 base 549 + mov r2, r2, lsl #14 550 + ldr r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ 551 + PMD_SECT_CACHEABLE | PMD_SECT_AP_WRITE 552 + b cpu_resume_mmu 553 + ENDPROC(cpu_xscale_do_resume) 554 + #else 555 + #define cpu_xscale_do_suspend 0 556 + #define cpu_xscale_do_resume 0 557 + #endif 520 558 521 559 __CPUINIT 522 560 ··· 603 565 .word cpu_xscale_dcache_clean_area 604 566 .word cpu_xscale_switch_mm 605 567 .word cpu_xscale_set_pte_ext 568 + .word cpu_xscale_suspend_size 569 + .word cpu_xscale_do_suspend 570 + .word cpu_xscale_do_resume 606 571 .size xscale_processor_functions, . - xscale_processor_functions 607 572 608 573 .section ".rodata"