1 /* linux/arch/arm/plat-s3c24xx/sleep.S
3 * Copyright (c) 2004 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
6 * S3C2410 Power Manager (Suspend-To-RAM) support
8 * Based on PXA/SA1100 sleep code by:
9 * Nicolas Pitre, (c) 2002 Monta Vista Software Inc
10 * Cliff Brake, (c) 2001
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/linkage.h>
28 #include <asm/assembler.h>
29 #include <mach/hardware.h>
32 #include <mach/regs-gpio.h>
33 #include <mach/regs-clock.h>
34 #include <mach/regs-mem.h>
35 #include <asm/plat-s3c/regs-serial.h>
37 /* CONFIG_DEBUG_RESUME is dangerous if your bootloader does not
38 * reset the UART configuration, only enable if you really need this!
40 //#define CONFIG_DEBUG_RESUME
46 * save enough of the CPU state to allow us to re-start
47 * pm.c code. as we store items like the sp/lr, we will
48 * end up returning from this function when the cpu resumes
49 * so the return value is set to mark this.
51 * This arangement means we avoid having to flush the cache
55 * r0 = pointer to save block
58 * r0 = 0 => we stored everything
59 * 1 => resumed from sleep
62 ENTRY(s3c2410_cpu_save)
63 stmfd sp!, { r4 - r12, lr }
65 @@ store co-processor registers
67 mrc p15, 0, r4, c13, c0, 0 @ PID
68 mrc p15, 0, r5, c3, c0, 0 @ Domain ID
69 mrc p15, 0, r6, c2, c0, 0 @ translation table base address
70 mrc p15, 0, r7, c1, c0, 0 @ control register
72 stmia r0, { r4 - r13 }
75 ldmfd sp, { r4 - r12, pc }
77 @@ return to the caller, after having the MMU
78 @@ turned on, this restores the last bits from the
82 ldmfd sp!, { r4 - r12, pc }
86 @@ the next bits sit in the .data segment, even though they
87 @@ happen to be code... the s3c2410_sleep_save_phys needs to be
88 @@ accessed by the resume code before it can restore the MMU.
89 @@ This means that the variable has to be close enough for the
90 @@ code to read it... since the .text segment needs to be RO,
91 @@ the data segment can be the only place to put this code.
95 .global s3c2410_sleep_save_phys
96 s3c2410_sleep_save_phys:
100 /* sleep magic, to allow the bootloader to check for an valid
101 * image to resume to. Must be the first word before the
102 * s3c2410_cpu_resume entry.
107 /* s3c2410_cpu_resume
109 * resume code entry for bootloader to call
111 * we must put this code here in the data segment as we have no
112 * other way of restoring the stack pointer after sleep, and we
113 * must not write to the code segment (code is read-only)
116 ENTRY(s3c2410_cpu_resume)
117 mov r0, #PSR_I_BIT | PSR_F_BIT | SVC_MODE
120 @@ load UART to allow us to print the two characters for
123 mov r2, #S3C24XX_PA_UART & 0xff000000
124 orr r2, r2, #S3C24XX_PA_UART & 0xff000
127 /* SMDK2440 LED set */
128 mov r14, #S3C24XX_PA_GPIO
129 ldr r12, [ r14, #0x54 ]
132 str r12, [ r14, #0x54 ]
135 #ifdef CONFIG_DEBUG_RESUME
137 strb r3, [ r2, #S3C2410_UTXH ]
139 ldrb r14, [ r3, #S3C2410_UTRSTAT ]
140 tst r14, #S3C2410_UTRSTAT_TXE
142 #endif /* CONFIG_DEBUG_RESUME */
145 mcr p15, 0, r1, c8, c7, 0 @@ invalidate I & D TLBs
146 mcr p15, 0, r1, c7, c7, 0 @@ invalidate I & D caches
148 ldr r0, s3c2410_sleep_save_phys @ address of restore block
149 ldmia r0, { r4 - r13 }
151 mcr p15, 0, r4, c13, c0, 0 @ PID
152 mcr p15, 0, r5, c3, c0, 0 @ Domain ID
153 mcr p15, 0, r6, c2, c0, 0 @ translation table base
155 #ifdef CONFIG_DEBUG_RESUME
157 strb r3, [ r2, #S3C2410_UTXH ]
160 ldr r2, =resume_with_mmu
161 mcr p15, 0, r7, c1, c0, 0 @ turn on MMU, etc
162 nop @ second-to-last before mmu
163 mov pc, r2 @ go back to virtual address