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>
|
|
|
|
#include <asm/system.h>
|
|
|
|
.text
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save CPU state for a suspend
|
2011-08-27 23:39:09 +02:00
|
|
|
* r0 = phys addr of temporary page tables
|
2011-02-06 16:48:39 +01:00
|
|
|
* r1 = v:p offset
|
2011-06-13 16:28:40 +02:00
|
|
|
* r2 = suspend function arg0
|
2011-06-13 16:58:34 +02:00
|
|
|
* r3 = 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-08-27 23:39:09 +02:00
|
|
|
mov r4, r0
|
2011-02-06 16:48:39 +01:00
|
|
|
#ifdef MULTI_CPU
|
|
|
|
ldr r10, =processor
|
2011-06-13 16:25:11 +02:00
|
|
|
ldr r5, [r10, #CPU_SLEEP_SIZE] @ size of CPU sleep state
|
2011-02-06 16:48:39 +01:00
|
|
|
ldr ip, [r10, #CPU_DO_RESUME] @ virtual resume function
|
2011-02-11 12:32:19 +01:00
|
|
|
#else
|
2011-06-13 16:25:11 +02:00
|
|
|
ldr r5, =cpu_suspend_size
|
2011-06-13 14:39:44 +02:00
|
|
|
ldr ip, =cpu_do_resume
|
2011-06-13 14:53:06 +02:00
|
|
|
#endif
|
2011-06-13 16:25:11 +02:00
|
|
|
mov r6, sp @ current virtual SP
|
|
|
|
sub sp, sp, r5 @ allocate CPU state on stack
|
2011-07-02 10:54:01 +02:00
|
|
|
mov r0, sp @ save pointer to CPU save block
|
2011-06-13 14:39:44 +02:00
|
|
|
add ip, ip, r1 @ convert resume fn to phys
|
2011-08-27 23:39:09 +02:00
|
|
|
stmfd sp!, {r4, r6, ip} @ save phys pgd, virt SP, phys resume fn
|
2011-06-13 16:25:11 +02:00
|
|
|
ldr r5, =sleep_save_sp
|
|
|
|
add r6, sp, r1 @ convert SP to phys
|
2011-06-13 16:58:34 +02:00
|
|
|
stmfd sp!, {r2, r3} @ save suspend func arg and pointer
|
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-06-13 16:25:11 +02:00
|
|
|
str r6, [r5, lr, lsl #2] @ save phys SP
|
2011-02-11 12:32:19 +01:00
|
|
|
#else
|
2011-06-13 16:25:11 +02:00
|
|
|
str r6, [r5] @ save phys SP
|
2011-02-11 12:32:19 +01:00
|
|
|
#endif
|
2011-06-13 14:53:06 +02:00
|
|
|
#ifdef MULTI_CPU
|
|
|
|
mov lr, pc
|
|
|
|
ldr pc, [r10, #CPU_DO_SUSPEND] @ save CPU state
|
|
|
|
#else
|
2011-02-06 16:48:39 +01:00
|
|
|
bl cpu_do_suspend
|
|
|
|
#endif
|
|
|
|
|
|
|
|
@ flush data cache
|
|
|
|
#ifdef MULTI_CACHE
|
|
|
|
ldr r10, =cpu_cache
|
2011-06-13 16:28:40 +02:00
|
|
|
mov lr, pc
|
2011-02-06 16:48:39 +01:00
|
|
|
ldr pc, [r10, #CACHE_FLUSH_KERN_ALL]
|
|
|
|
#else
|
2011-06-13 16:28:40 +02:00
|
|
|
bl __cpuc_flush_kern_all
|
2011-02-06 16:48:39 +01:00
|
|
|
#endif
|
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
|
|
|
|
*/
|
|
|
|
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-26 21:28:52 +02: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 16:48:39 +01:00
|
|
|
mov pc, r3 @ jump to virtual address
|
|
|
|
ENDPROC(cpu_resume_turn_mmu_on)
|
|
|
|
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
|