blob: fd7032f84ae7623198f97a28fc40854941be61b3 [file] [log] [blame]
Uwe Kleine-König58862692007-05-09 07:51:49 +02001/* linux/arch/arm/plat-s3c24xx/sleep.S
Ben Dooksa21765a2007-02-11 18:31:01 +01002 *
3 * Copyright (c) 2004 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * S3C2410 Power Manager (Suspend-To-RAM) support
7 *
8 * Based on PXA/SA1100 sleep code by:
9 * Nicolas Pitre, (c) 2002 Monta Vista Software Inc
10 * Cliff Brake, (c) 2001
11 *
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.
16 *
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.
21 *
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
25*/
26
27#include <linux/linkage.h>
28#include <asm/assembler.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/hardware.h>
30#include <mach/map.h>
Ben Dooksa21765a2007-02-11 18:31:01 +010031
Russell Kinga09e64f2008-08-05 16:14:15 +010032#include <mach/regs-gpio.h>
33#include <mach/regs-clock.h>
34#include <mach/regs-mem.h>
Ben Dooksa2b7ba92008-10-07 22:26:09 +010035#include <plat/regs-serial.h>
Ben Dooksa21765a2007-02-11 18:31:01 +010036
37/* CONFIG_DEBUG_RESUME is dangerous if your bootloader does not
38 * reset the UART configuration, only enable if you really need this!
39*/
40//#define CONFIG_DEBUG_RESUME
41
42 .text
43
Ben Dooksef30e142008-12-12 00:24:19 +000044 /* s3c_cpu_save
Ben Dooksa21765a2007-02-11 18:31:01 +010045 *
Ben Dooksa21765a2007-02-11 18:31:01 +010046 * entry:
Russell King2e2f3d32011-02-06 17:39:31 +000047 * r1 = v:p offset
Ben Dooksa21765a2007-02-11 18:31:01 +010048 */
49
Ben Dooksef30e142008-12-12 00:24:19 +000050ENTRY(s3c_cpu_save)
Ben Dooksa21765a2007-02-11 18:31:01 +010051 stmfd sp!, { r4 - r12, lr }
Russell King2e2f3d32011-02-06 17:39:31 +000052 ldr r3, =resume_with_mmu
53 bl cpu_suspend
Ben Dooksa21765a2007-02-11 18:31:01 +010054
Ben Dooksfff94cd2009-03-10 11:48:07 +000055 @@ jump to final code to send system to sleep
56 ldr r0, =pm_cpu_sleep
57 @@ldr pc, [ r0 ]
58 ldr r0, [ r0 ]
59 mov pc, r0
60
Ben Dooksa21765a2007-02-11 18:31:01 +010061 @@ return to the caller, after having the MMU
62 @@ turned on, this restores the last bits from the
63 @@ stack
64resume_with_mmu:
Ben Dooksa21765a2007-02-11 18:31:01 +010065 ldmfd sp!, { r4 - r12, pc }
66
67 .ltorg
68
Ben Dooks6c729af2007-09-30 09:59:15 +010069 /* sleep magic, to allow the bootloader to check for an valid
70 * image to resume to. Must be the first word before the
Ben Dooksef30e142008-12-12 00:24:19 +000071 * s3c_cpu_resume entry.
Ben Dooks6c729af2007-09-30 09:59:15 +010072 */
73
74 .word 0x2bedf00d
75
Ben Dooksef30e142008-12-12 00:24:19 +000076 /* s3c_cpu_resume
Ben Dooksa21765a2007-02-11 18:31:01 +010077 *
78 * resume code entry for bootloader to call
Ben Dooksa21765a2007-02-11 18:31:01 +010079 */
80
Ben Dooksef30e142008-12-12 00:24:19 +000081ENTRY(s3c_cpu_resume)
Ben Dooksa21765a2007-02-11 18:31:01 +010082 mov r0, #PSR_I_BIT | PSR_F_BIT | SVC_MODE
83 msr cpsr_c, r0
84
85 @@ load UART to allow us to print the two characters for
86 @@ resume debug
87
88 mov r2, #S3C24XX_PA_UART & 0xff000000
89 orr r2, r2, #S3C24XX_PA_UART & 0xff000
90
91#if 0
92 /* SMDK2440 LED set */
93 mov r14, #S3C24XX_PA_GPIO
94 ldr r12, [ r14, #0x54 ]
95 bic r12, r12, #3<<4
96 orr r12, r12, #1<<7
97 str r12, [ r14, #0x54 ]
98#endif
99
100#ifdef CONFIG_DEBUG_RESUME
101 mov r3, #'L'
102 strb r3, [ r2, #S3C2410_UTXH ]
1031001:
104 ldrb r14, [ r3, #S3C2410_UTRSTAT ]
105 tst r14, #S3C2410_UTRSTAT_TXE
106 beq 1001b
107#endif /* CONFIG_DEBUG_RESUME */
108
Russell King2e2f3d32011-02-06 17:39:31 +0000109 b cpu_resume