2011-02-06 22:48:39 +07:00
|
|
|
#include <linux/linkage.h>
|
2011-02-11 18:32:19 +07:00
|
|
|
#include <linux/threads.h>
|
2011-02-06 22:48:39 +07: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
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save CPU state for a suspend
|
|
|
|
* r1 = v:p offset
|
2011-06-13 21:28:40 +07:00
|
|
|
* r2 = suspend function arg0
|
2011-06-13 21:58:34 +07:00
|
|
|
* r3 = suspend function
|
2011-02-06 22:48:39 +07:00
|
|
|
*/
|
2011-06-22 23:41:48 +07:00
|
|
|
ENTRY(__cpu_suspend)
|
2011-06-13 21:58:34 +07:00
|
|
|
stmfd sp!, {r4 - r11, lr}
|
2011-02-06 22:48:39 +07:00
|
|
|
#ifdef MULTI_CPU
|
|
|
|
ldr r10, =processor
|
2011-06-13 21:25:11 +07:00
|
|
|
ldr r5, [r10, #CPU_SLEEP_SIZE] @ size of CPU sleep state
|
2011-02-06 22:48:39 +07:00
|
|
|
ldr ip, [r10, #CPU_DO_RESUME] @ virtual resume function
|
2011-02-11 18:32:19 +07:00
|
|
|
#else
|
2011-06-13 21:25:11 +07:00
|
|
|
ldr r5, =cpu_suspend_size
|
2011-06-13 19:39:44 +07:00
|
|
|
ldr ip, =cpu_do_resume
|
2011-06-13 19:53:06 +07:00
|
|
|
#endif
|
2011-06-13 21:25:11 +07:00
|
|
|
mov r6, sp @ current virtual SP
|
|
|
|
sub sp, sp, r5 @ allocate CPU state on stack
|
2011-07-02 15:54:01 +07:00
|
|
|
mov r0, sp @ save pointer to CPU save block
|
2011-06-13 19:39:44 +07:00
|
|
|
add ip, ip, r1 @ convert resume fn to phys
|
2011-08-27 02:28:52 +07:00
|
|
|
stmfd sp!, {r6, ip} @ save virt SP, phys resume fn
|
2011-06-13 21:25:11 +07:00
|
|
|
ldr r5, =sleep_save_sp
|
|
|
|
add r6, sp, r1 @ convert SP to phys
|
2011-06-13 21:58:34 +07:00
|
|
|
stmfd sp!, {r2, r3} @ save suspend func arg and pointer
|
2011-02-11 18:32:19 +07:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
ALT_SMP(mrc p15, 0, lr, c0, c0, 5)
|
|
|
|
ALT_UP(mov lr, #0)
|
|
|
|
and lr, lr, #15
|
2011-06-13 21:25:11 +07:00
|
|
|
str r6, [r5, lr, lsl #2] @ save phys SP
|
2011-02-11 18:32:19 +07:00
|
|
|
#else
|
2011-06-13 21:25:11 +07:00
|
|
|
str r6, [r5] @ save phys SP
|
2011-02-11 18:32:19 +07:00
|
|
|
#endif
|
2011-06-13 19:53:06 +07:00
|
|
|
#ifdef MULTI_CPU
|
|
|
|
mov lr, pc
|
|
|
|
ldr pc, [r10, #CPU_DO_SUSPEND] @ save CPU state
|
|
|
|
#else
|
2011-02-06 22:48:39 +07:00
|
|
|
bl cpu_do_suspend
|
|
|
|
#endif
|
|
|
|
|
|
|
|
@ flush data cache
|
|
|
|
#ifdef MULTI_CACHE
|
|
|
|
ldr r10, =cpu_cache
|
2011-06-13 21:28:40 +07:00
|
|
|
mov lr, pc
|
2011-02-06 22:48:39 +07:00
|
|
|
ldr pc, [r10, #CACHE_FLUSH_KERN_ALL]
|
|
|
|
#else
|
2011-06-13 21:28:40 +07:00
|
|
|
bl __cpuc_flush_kern_all
|
2011-02-06 22:48:39 +07:00
|
|
|
#endif
|
2011-07-02 15:54:01 +07:00
|
|
|
adr lr, BSYM(cpu_suspend_abort)
|
2011-06-13 21:28:40 +07:00
|
|
|
ldmfd sp!, {r0, pc} @ call suspend fn
|
2011-06-22 23:41:48 +07:00
|
|
|
ENDPROC(__cpu_suspend)
|
2011-02-06 22:48:39 +07:00
|
|
|
.ltorg
|
|
|
|
|
2011-07-02 15:54:01 +07:00
|
|
|
cpu_suspend_abort:
|
2011-08-27 02:28:52 +07:00
|
|
|
ldmia sp!, {r2 - r3} @ pop virt SP, phys resume fn
|
2011-08-27 17:17:36 +07:00
|
|
|
teq r0, #0
|
|
|
|
moveq r0, #1 @ force non-zero value
|
2011-07-02 15:54:01 +07:00
|
|
|
mov sp, r2
|
|
|
|
ldmfd sp!, {r4 - r11, pc}
|
|
|
|
ENDPROC(cpu_suspend_abort)
|
|
|
|
|
2011-02-06 22:48:39 +07:00
|
|
|
/*
|
|
|
|
* r0 = control register value
|
|
|
|
* r1 = v:p offset (preserved by cpu_do_resume)
|
|
|
|
* r2 = phys page table base
|
|
|
|
* r3 = L1 section flags
|
|
|
|
*/
|
|
|
|
ENTRY(cpu_resume_mmu)
|
|
|
|
ldr r3, =cpu_resume_after_mmu
|
|
|
|
b cpu_resume_turn_mmu_on
|
|
|
|
ENDPROC(cpu_resume_mmu)
|
|
|
|
.ltorg
|
|
|
|
.align 5
|
2011-08-27 02:28:52 +07:00
|
|
|
ENTRY(cpu_resume_turn_mmu_on)
|
|
|
|
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 22:48:39 +07:00
|
|
|
mov pc, r3 @ jump to virtual address
|
|
|
|
ENDPROC(cpu_resume_turn_mmu_on)
|
|
|
|
cpu_resume_after_mmu:
|
2011-06-21 22:32:58 +07:00
|
|
|
bl cpu_init @ restore the und/abt/irq banked regs
|
2011-07-02 15:54:01 +07:00
|
|
|
mov r0, #0 @ return zero on success
|
2011-06-13 21:04:14 +07:00
|
|
|
ldmfd sp!, {r4 - r11, pc}
|
2011-02-06 22:48:39 +07: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 18:32:19 +07: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 22:48:39 +07:00
|
|
|
ldr r0, sleep_save_sp @ stack phys addr
|
2011-02-11 18:32:19 +07:00
|
|
|
#endif
|
2011-03-23 01:09:14 +07:00
|
|
|
setmode PSR_I_BIT | PSR_F_BIT | SVC_MODE, r1 @ set SVC, irqs off
|
2011-08-27 02:28:52 +07:00
|
|
|
@ load stack, resume fn
|
|
|
|
ARM( ldmia r0!, {sp, pc} )
|
|
|
|
THUMB( ldmia r0!, {r2, r3} )
|
|
|
|
THUMB( mov sp, r2 )
|
|
|
|
THUMB( bx r3 )
|
2011-02-06 22:48:39 +07:00
|
|
|
ENDPROC(cpu_resume)
|
|
|
|
|
|
|
|
sleep_save_sp:
|
2011-02-11 18:32:19 +07:00
|
|
|
.rept CONFIG_NR_CPUS
|
|
|
|
.long 0 @ preserve stack phys ptr here
|
|
|
|
.endr
|