2011-02-06 23:48:39 +08:00
|
|
|
#include <linux/linkage.h>
|
2011-02-11 19:32:19 +08:00
|
|
|
#include <linux/threads.h>
|
2011-02-06 23:48:39 +08:00
|
|
|
#include <asm/asm-offsets.h>
|
|
|
|
#include <asm/assembler.h>
|
|
|
|
#include <asm/glue-cache.h>
|
|
|
|
#include <asm/glue-proc.h>
|
|
|
|
#include <asm/system.h>
|
|
|
|
.text
|
|
|
|
|
|
|
|
/*
|
2011-09-01 18:52:33 +08:00
|
|
|
* Save CPU state for a suspend. This saves the CPU general purpose
|
|
|
|
* registers, and allocates space on the kernel stack to save the CPU
|
|
|
|
* specific registers and some other data for resume.
|
|
|
|
* r0 = suspend function arg0
|
|
|
|
* r1 = suspend function
|
2011-02-06 23:48:39 +08:00
|
|
|
*/
|
2011-06-23 00:41:48 +08:00
|
|
|
ENTRY(__cpu_suspend)
|
2011-06-13 22:58:34 +08:00
|
|
|
stmfd sp!, {r4 - r11, lr}
|
2011-02-06 23:48:39 +08:00
|
|
|
#ifdef MULTI_CPU
|
|
|
|
ldr r10, =processor
|
2011-09-01 18:52:33 +08:00
|
|
|
ldr r4, [r10, #CPU_SLEEP_SIZE] @ size of CPU sleep state
|
2011-02-11 19:32:19 +08:00
|
|
|
#else
|
2011-09-01 18:52:33 +08:00
|
|
|
ldr r4, =cpu_suspend_size
|
2011-06-13 20:53:06 +08:00
|
|
|
#endif
|
2011-09-01 18:52:33 +08:00
|
|
|
mov r5, sp @ current virtual SP
|
|
|
|
add r4, r4, #12 @ Space for pgd, virt sp, phys resume fn
|
|
|
|
sub sp, sp, r4 @ allocate CPU state on stack
|
|
|
|
stmfd sp!, {r0, r1} @ save suspend func arg and pointer
|
|
|
|
add r0, sp, #8 @ save pointer to save block
|
|
|
|
mov r1, r4 @ size of save block
|
|
|
|
mov r2, r5 @ virtual SP
|
|
|
|
ldr r3, =sleep_save_sp
|
2011-02-11 19:32:19 +08:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
ALT_SMP(mrc p15, 0, lr, c0, c0, 5)
|
|
|
|
ALT_UP(mov lr, #0)
|
|
|
|
and lr, lr, #15
|
2011-09-01 18:52:33 +08:00
|
|
|
add r3, r3, lr, lsl #2
|
2011-02-06 23:48:39 +08:00
|
|
|
#endif
|
2011-09-01 18:52:33 +08:00
|
|
|
bl __cpu_suspend_save
|
2011-07-02 16:54:01 +08:00
|
|
|
adr lr, BSYM(cpu_suspend_abort)
|
2011-06-13 22:28:40 +08:00
|
|
|
ldmfd sp!, {r0, pc} @ call suspend fn
|
2011-06-23 00:41:48 +08:00
|
|
|
ENDPROC(__cpu_suspend)
|
2011-02-06 23:48:39 +08:00
|
|
|
.ltorg
|
|
|
|
|
2011-07-02 16:54:01 +08:00
|
|
|
cpu_suspend_abort:
|
2011-08-28 05:39:09 +08:00
|
|
|
ldmia sp!, {r1 - r3} @ pop phys pgd, virt SP, phys resume fn
|
2011-08-27 18:17:36 +08:00
|
|
|
teq r0, #0
|
|
|
|
moveq r0, #1 @ force non-zero value
|
2011-07-02 16:54:01 +08:00
|
|
|
mov sp, r2
|
|
|
|
ldmfd sp!, {r4 - r11, pc}
|
|
|
|
ENDPROC(cpu_suspend_abort)
|
|
|
|
|
2011-02-06 23:48:39 +08:00
|
|
|
/*
|
|
|
|
* r0 = control register value
|
|
|
|
*/
|
2011-09-01 06:26:18 +08:00
|
|
|
.align 5
|
2011-11-15 19:11:19 +08:00
|
|
|
.pushsection .idmap.text,"ax"
|
2011-02-06 23:48:39 +08:00
|
|
|
ENTRY(cpu_resume_mmu)
|
|
|
|
ldr r3, =cpu_resume_after_mmu
|
2011-08-27 03:28:52 +08:00
|
|
|
mcr p15, 0, r0, c1, c0, 0 @ turn on MMU, I-cache, etc
|
|
|
|
mrc p15, 0, r0, c0, c0, 0 @ read id reg
|
|
|
|
mov r0, r0
|
|
|
|
mov r0, r0
|
2011-02-06 23:48:39 +08:00
|
|
|
mov pc, r3 @ jump to virtual address
|
2011-09-01 06:26:18 +08:00
|
|
|
ENDPROC(cpu_resume_mmu)
|
2011-11-15 19:11:19 +08:00
|
|
|
.popsection
|
2011-02-06 23:48:39 +08:00
|
|
|
cpu_resume_after_mmu:
|
2011-06-21 23:32:58 +08:00
|
|
|
bl cpu_init @ restore the und/abt/irq banked regs
|
2011-07-02 16:54:01 +08:00
|
|
|
mov r0, #0 @ return zero on success
|
2011-06-13 22:04:14 +08:00
|
|
|
ldmfd sp!, {r4 - r11, pc}
|
2011-02-06 23:48:39 +08:00
|
|
|
ENDPROC(cpu_resume_after_mmu)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note: Yes, part of the following code is located into the .data section.
|
|
|
|
* This is to allow sleep_save_sp to be accessed with a relative load
|
|
|
|
* while we can't rely on any MMU translation. We could have put
|
|
|
|
* sleep_save_sp in the .text section as well, but some setups might
|
|
|
|
* insist on it to be truly read-only.
|
|
|
|
*/
|
|
|
|
.data
|
|
|
|
.align
|
|
|
|
ENTRY(cpu_resume)
|
2011-02-11 19:32:19 +08:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
adr r0, sleep_save_sp
|
|
|
|
ALT_SMP(mrc p15, 0, r1, c0, c0, 5)
|
|
|
|
ALT_UP(mov r1, #0)
|
|
|
|
and r1, r1, #15
|
|
|
|
ldr r0, [r0, r1, lsl #2] @ stack phys addr
|
|
|
|
#else
|
2011-02-06 23:48:39 +08:00
|
|
|
ldr r0, sleep_save_sp @ stack phys addr
|
2011-02-11 19:32:19 +08:00
|
|
|
#endif
|
2011-03-23 02:09:14 +08:00
|
|
|
setmode PSR_I_BIT | PSR_F_BIT | SVC_MODE, r1 @ set SVC, irqs off
|
2011-08-28 05:39:09 +08:00
|
|
|
@ load phys pgd, stack, resume fn
|
|
|
|
ARM( ldmia r0!, {r1, sp, pc} )
|
|
|
|
THUMB( ldmia r0!, {r1, r2, r3} )
|
|
|
|
THUMB( mov sp, r2 )
|
|
|
|
THUMB( bx r3 )
|
2011-02-06 23:48:39 +08:00
|
|
|
ENDPROC(cpu_resume)
|
|
|
|
|
|
|
|
sleep_save_sp:
|
2011-02-11 19:32:19 +08:00
|
|
|
.rept CONFIG_NR_CPUS
|
|
|
|
.long 0 @ preserve stack phys ptr here
|
|
|
|
.endr
|