2011-02-06 16:48:39 +01:00
|
|
|
#include <linux/linkage.h>
|
2011-02-11 12:32:19 +01:00
|
|
|
#include <linux/threads.h>
|
2011-02-06 16:48:39 +01:00
|
|
|
#include <asm/asm-offsets.h>
|
|
|
|
#include <asm/assembler.h>
|
|
|
|
#include <asm/glue-cache.h>
|
|
|
|
#include <asm/glue-proc.h>
|
|
|
|
.text
|
|
|
|
|
|
|
|
/*
|
2011-09-01 12:52:33 +02: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 16:48:39 +01:00
|
|
|
*/
|
2011-06-22 18:41:48 +02:00
|
|
|
ENTRY(__cpu_suspend)
|
2011-06-13 16:58:34 +02:00
|
|
|
stmfd sp!, {r4 - r11, lr}
|
2011-02-06 16:48:39 +01:00
|
|
|
#ifdef MULTI_CPU
|
|
|
|
ldr r10, =processor
|
2011-09-01 12:52:33 +02:00
|
|
|
ldr r4, [r10, #CPU_SLEEP_SIZE] @ size of CPU sleep state
|
2011-02-11 12:32:19 +01:00
|
|
|
#else
|
2011-09-01 12:52:33 +02:00
|
|
|
ldr r4, =cpu_suspend_size
|
2011-06-13 14:53:06 +02:00
|
|
|
#endif
|
2011-09-01 12:52:33 +02: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 12:32:19 +01: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 12:52:33 +02:00
|
|
|
add r3, r3, lr, lsl #2
|
2011-02-06 16:48:39 +01:00
|
|
|
#endif
|
2011-09-01 12:52:33 +02:00
|
|
|
bl __cpu_suspend_save
|
2011-07-02 10:54:01 +02:00
|
|
|
adr lr, BSYM(cpu_suspend_abort)
|
2011-06-13 16:28:40 +02:00
|
|
|
ldmfd sp!, {r0, pc} @ call suspend fn
|
2011-06-22 18:41:48 +02:00
|
|
|
ENDPROC(__cpu_suspend)
|
2011-02-06 16:48:39 +01:00
|
|
|
.ltorg
|
|
|
|
|
2011-07-02 10:54:01 +02:00
|
|
|
cpu_suspend_abort:
|
2011-08-27 23:39:09 +02:00
|
|
|
ldmia sp!, {r1 - r3} @ pop phys pgd, virt SP, phys resume fn
|
2011-08-27 12:17:36 +02:00
|
|
|
teq r0, #0
|
|
|
|
moveq r0, #1 @ force non-zero value
|
2011-07-02 10:54:01 +02:00
|
|
|
mov sp, r2
|
|
|
|
ldmfd sp!, {r4 - r11, pc}
|
|
|
|
ENDPROC(cpu_suspend_abort)
|
|
|
|
|
2011-02-06 16:48:39 +01:00
|
|
|
/*
|
|
|
|
* r0 = control register value
|
|
|
|
*/
|
2011-09-01 00:26:18 +02:00
|
|
|
.align 5
|
2011-11-15 12:11:19 +01:00
|
|
|
.pushsection .idmap.text,"ax"
|
2011-02-06 16:48:39 +01:00
|
|
|
ENTRY(cpu_resume_mmu)
|
|
|
|
ldr r3, =cpu_resume_after_mmu
|
2011-11-22 18:30:28 +01:00
|
|
|
instr_sync
|
2011-08-26 21:28:52 +02:00
|
|
|
mcr p15, 0, r0, c1, c0, 0 @ turn on MMU, I-cache, etc
|
|
|
|
mrc p15, 0, r0, c0, c0, 0 @ read id reg
|
2011-11-22 18:30:28 +01:00
|
|
|
instr_sync
|
2011-08-26 21:28:52 +02:00
|
|
|
mov r0, r0
|
|
|
|
mov r0, r0
|
2011-02-06 16:48:39 +01:00
|
|
|
mov pc, r3 @ jump to virtual address
|
2011-09-01 00:26:18 +02:00
|
|
|
ENDPROC(cpu_resume_mmu)
|
2011-11-15 12:11:19 +01:00
|
|
|
.popsection
|
2011-02-06 16:48:39 +01:00
|
|
|
cpu_resume_after_mmu:
|
2011-06-21 17:32:58 +02:00
|
|
|
bl cpu_init @ restore the und/abt/irq banked regs
|
2011-07-02 10:54:01 +02:00
|
|
|
mov r0, #0 @ return zero on success
|
2011-06-13 16:04:14 +02:00
|
|
|
ldmfd sp!, {r4 - r11, pc}
|
2011-02-06 16:48:39 +01: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 12:32:19 +01: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 16:48:39 +01:00
|
|
|
ldr r0, sleep_save_sp @ stack phys addr
|
2011-02-11 12:32:19 +01:00
|
|
|
#endif
|
2011-03-22 19:09:14 +01:00
|
|
|
setmode PSR_I_BIT | PSR_F_BIT | SVC_MODE, r1 @ set SVC, irqs off
|
2011-08-27 23:39:09 +02: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 16:48:39 +01:00
|
|
|
ENDPROC(cpu_resume)
|
|
|
|
|
|
|
|
sleep_save_sp:
|
2011-02-11 12:32:19 +01:00
|
|
|
.rept CONFIG_NR_CPUS
|
|
|
|
.long 0 @ preserve stack phys ptr here
|
|
|
|
.endr
|