aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/suspend.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2011-09-01 06:52:33 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-09-20 18:33:44 -0400
commitabda1bd5f4e04054ce083c298fcd68a743e9df03 (patch)
treebdbc41f348d17a6cdb7259a0604d3f501801f3b6 /arch/arm/kernel/suspend.c
parent62b2d07c0ea9db40a1787d2d0ab49f03c3e0613c (diff)
ARM: pm: convert some assembly to C
Convert some of the sleep.S guts to C code, which makes it easier to use our macros and to add L2 cache handling. We provide a helper function, __cpu_suspend_save(), which deals with saving the common state, setting up for resume, and flushing caches. The remainder left as assembly code is the saving of the CPU general purpose registers, and allocating space on the stack to save the CPU specific registers and resume state. Tested-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Tested-by: Shawn Guo <shawn.guo@linaro.org> Tested-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/kernel/suspend.c')
-rw-r--r--arch/arm/kernel/suspend.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/arch/arm/kernel/suspend.c b/arch/arm/kernel/suspend.c
index ed4160b64e66..2d60f1903206 100644
--- a/arch/arm/kernel/suspend.c
+++ b/arch/arm/kernel/suspend.c
@@ -8,10 +8,29 @@
8 8
9static pgd_t *suspend_pgd; 9static pgd_t *suspend_pgd;
10 10
11extern int __cpu_suspend(int, long, unsigned long, int (*)(unsigned long)); 11extern int __cpu_suspend(unsigned long, int (*)(unsigned long));
12extern void cpu_resume_mmu(void); 12extern void cpu_resume_mmu(void);
13 13
14/* 14/*
15 * This is called by __cpu_suspend() to save the state, and do whatever
16 * flushing is required to ensure that when the CPU goes to sleep we have
17 * the necessary data available when the caches are not searched.
18 */
19void __cpu_suspend_save(u32 *ptr, u32 ptrsz, u32 sp, u32 *save_ptr)
20{
21 *save_ptr = virt_to_phys(ptr);
22
23 /* This must correspond to the LDM in cpu_resume() assembly */
24 *ptr++ = virt_to_phys(suspend_pgd);
25 *ptr++ = sp;
26 *ptr++ = virt_to_phys(cpu_do_resume);
27
28 cpu_do_suspend(ptr);
29
30 flush_cache_all();
31}
32
33/*
15 * Hide the first two arguments to __cpu_suspend - these are an implementation 34 * Hide the first two arguments to __cpu_suspend - these are an implementation
16 * detail which platform code shouldn't have to know about. 35 * detail which platform code shouldn't have to know about.
17 */ 36 */
@@ -29,8 +48,7 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
29 * resume (indicated by a zero return code), we need to switch 48 * resume (indicated by a zero return code), we need to switch
30 * back to the correct page tables. 49 * back to the correct page tables.
31 */ 50 */
32 ret = __cpu_suspend(virt_to_phys(suspend_pgd), 51 ret = __cpu_suspend(arg, fn);
33 PHYS_OFFSET - PAGE_OFFSET, arg, fn);
34 if (ret == 0) { 52 if (ret == 0) {
35 cpu_switch_mm(mm->pgd, mm); 53 cpu_switch_mm(mm->pgd, mm);
36 local_flush_tlb_all(); 54 local_flush_tlb_all();