diff options
author | Jongpill Lee <boyko.lee@samsung.com> | 2010-10-02 06:13:42 -0400 |
---|---|---|
committer | Kukjin Kim <kgene.kim@samsung.com> | 2010-10-20 18:54:57 -0400 |
commit | ea31fd4330c823bd156d6484e32a0777c35f200f (patch) | |
tree | 1db9c8140448d53a8f404b3581af31d78cd3872a /arch | |
parent | dc425471b6d4e2a3c1d74745433816fc313f30e7 (diff) |
ARM: S5PV210: Add Power Management Support
This patch adds suspend-to-ram support for S5PV210.
Note. This patch is confirmed on SMDKV210 and SMDKC110 board.
Signed-off-by: Jongpill Lee <boyko.lee@samsung.com>
Signed-off-by: Sangbeom Kim <sbkim73@samsung.com>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-s5pv210/Kconfig | 6 | ||||
-rw-r--r-- | arch/arm/mach-s5pv210/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-s5pv210/include/mach/pm-core.h | 43 | ||||
-rw-r--r-- | arch/arm/mach-s5pv210/include/mach/regs-clock.h | 7 | ||||
-rw-r--r-- | arch/arm/mach-s5pv210/mach-smdkc110.c | 3 | ||||
-rw-r--r-- | arch/arm/mach-s5pv210/mach-smdkv210.c | 3 | ||||
-rw-r--r-- | arch/arm/mach-s5pv210/pm.c | 166 | ||||
-rw-r--r-- | arch/arm/mach-s5pv210/sleep.S | 170 | ||||
-rw-r--r-- | arch/arm/plat-s5p/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/plat-s5p/irq-pm.c | 93 | ||||
-rw-r--r-- | arch/arm/plat-s5p/pm.c | 52 | ||||
-rw-r--r-- | arch/arm/plat-samsung/pm-gpio.c | 4 |
12 files changed, 546 insertions, 4 deletions
diff --git a/arch/arm/mach-s5pv210/Kconfig b/arch/arm/mach-s5pv210/Kconfig index af2a8132eaba..640b590dc365 100644 --- a/arch/arm/mach-s5pv210/Kconfig +++ b/arch/arm/mach-s5pv210/Kconfig | |||
@@ -13,6 +13,7 @@ config CPU_S5PV210 | |||
13 | bool | 13 | bool |
14 | select S3C_PL330_DMA | 14 | select S3C_PL330_DMA |
15 | select S5P_EXT_INT | 15 | select S5P_EXT_INT |
16 | select S5PV210_PM if PM | ||
16 | help | 17 | help |
17 | Enable S5PV210 CPU support | 18 | Enable S5PV210 CPU support |
18 | 19 | ||
@@ -152,4 +153,9 @@ config MACH_TORBRECK | |||
152 | 153 | ||
153 | endmenu | 154 | endmenu |
154 | 155 | ||
156 | config S5PV210_PM | ||
157 | bool | ||
158 | help | ||
159 | Power Management code common to S5PV210 | ||
160 | |||
155 | endif | 161 | endif |
diff --git a/arch/arm/mach-s5pv210/Makefile b/arch/arm/mach-s5pv210/Makefile index 226f335b2d4a..157754f0a919 100644 --- a/arch/arm/mach-s5pv210/Makefile +++ b/arch/arm/mach-s5pv210/Makefile | |||
@@ -14,6 +14,7 @@ obj- := | |||
14 | 14 | ||
15 | obj-$(CONFIG_CPU_S5PV210) += cpu.o init.o clock.o dma.o gpiolib.o | 15 | obj-$(CONFIG_CPU_S5PV210) += cpu.o init.o clock.o dma.o gpiolib.o |
16 | obj-$(CONFIG_CPU_S5PV210) += setup-i2c0.o | 16 | obj-$(CONFIG_CPU_S5PV210) += setup-i2c0.o |
17 | obj-$(CONFIG_S5PV210_PM) += pm.o sleep.o | ||
17 | 18 | ||
18 | # machine support | 19 | # machine support |
19 | 20 | ||
diff --git a/arch/arm/mach-s5pv210/include/mach/pm-core.h b/arch/arm/mach-s5pv210/include/mach/pm-core.h new file mode 100644 index 000000000000..e8d394f8b057 --- /dev/null +++ b/arch/arm/mach-s5pv210/include/mach/pm-core.h | |||
@@ -0,0 +1,43 @@ | |||
1 | /* linux/arch/arm/mach-s5pv210/include/mach/pm-core.h | ||
2 | * | ||
3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com | ||
5 | * | ||
6 | * Based on arch/arm/mach-s3c2410/include/mach/pm-core.h, | ||
7 | * Copyright 2008 Simtec Electronics | ||
8 | * Ben Dooks <ben@simtec.co.uk> | ||
9 | * http://armlinux.simtec.co.uk/ | ||
10 | * | ||
11 | * S5PV210 - PM core support for arch/arm/plat-s5p/pm.c | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License version 2 as | ||
15 | * published by the Free Software Foundation. | ||
16 | */ | ||
17 | |||
18 | static inline void s3c_pm_debug_init_uart(void) | ||
19 | { | ||
20 | /* nothing here yet */ | ||
21 | } | ||
22 | |||
23 | static inline void s3c_pm_arch_prepare_irqs(void) | ||
24 | { | ||
25 | __raw_writel(s3c_irqwake_intmask, S5P_WAKEUP_MASK); | ||
26 | __raw_writel(s3c_irqwake_eintmask, S5P_EINT_WAKEUP_MASK); | ||
27 | } | ||
28 | |||
29 | static inline void s3c_pm_arch_stop_clocks(void) | ||
30 | { | ||
31 | /* nothing here yet */ | ||
32 | } | ||
33 | |||
34 | static inline void s3c_pm_arch_show_resume_irqs(void) | ||
35 | { | ||
36 | /* nothing here yet */ | ||
37 | } | ||
38 | |||
39 | static inline void s3c_pm_arch_update_uart(void __iomem *regs, | ||
40 | struct pm_uart_save *save) | ||
41 | { | ||
42 | /* nothing here yet */ | ||
43 | } | ||
diff --git a/arch/arm/mach-s5pv210/include/mach/regs-clock.h b/arch/arm/mach-s5pv210/include/mach/regs-clock.h index 499aef737476..929fd3a33f8a 100644 --- a/arch/arm/mach-s5pv210/include/mach/regs-clock.h +++ b/arch/arm/mach-s5pv210/include/mach/regs-clock.h | |||
@@ -95,7 +95,7 @@ | |||
95 | /* Registers related to power management */ | 95 | /* Registers related to power management */ |
96 | #define S5P_PWR_CFG S5P_CLKREG(0xC000) | 96 | #define S5P_PWR_CFG S5P_CLKREG(0xC000) |
97 | #define S5P_EINT_WAKEUP_MASK S5P_CLKREG(0xC004) | 97 | #define S5P_EINT_WAKEUP_MASK S5P_CLKREG(0xC004) |
98 | #define S5P_WAKEUP_MASK S5P_CLKREG(0xC008) | 98 | #define S5P_WAKEUP_MASK S5P_CLKREG(0xC008) |
99 | #define S5P_PWR_MODE S5P_CLKREG(0xC00C) | 99 | #define S5P_PWR_MODE S5P_CLKREG(0xC00C) |
100 | #define S5P_NORMAL_CFG S5P_CLKREG(0xC010) | 100 | #define S5P_NORMAL_CFG S5P_CLKREG(0xC010) |
101 | #define S5P_IDLE_CFG S5P_CLKREG(0xC020) | 101 | #define S5P_IDLE_CFG S5P_CLKREG(0xC020) |
@@ -159,8 +159,11 @@ | |||
159 | #define S5P_SLEEP_CFG_USBOSC_EN (1 << 1) | 159 | #define S5P_SLEEP_CFG_USBOSC_EN (1 << 1) |
160 | 160 | ||
161 | /* OTHERS Resgister */ | 161 | /* OTHERS Resgister */ |
162 | #define S5P_OTHERS_RET_IO (1 << 31) | ||
163 | #define S5P_OTHERS_RET_CF (1 << 30) | ||
164 | #define S5P_OTHERS_RET_MMC (1 << 29) | ||
165 | #define S5P_OTHERS_RET_UART (1 << 28) | ||
162 | #define S5P_OTHERS_USB_SIG_MASK (1 << 16) | 166 | #define S5P_OTHERS_USB_SIG_MASK (1 << 16) |
163 | #define S5P_OTHERS_MIPI_DPHY_EN (1 << 28) | ||
164 | 167 | ||
165 | /* MIPI */ | 168 | /* MIPI */ |
166 | #define S5P_MIPI_DPHY_EN (3) | 169 | #define S5P_MIPI_DPHY_EN (3) |
diff --git a/arch/arm/mach-s5pv210/mach-smdkc110.c b/arch/arm/mach-s5pv210/mach-smdkc110.c index 8211bb87c54b..053b50ddcfaa 100644 --- a/arch/arm/mach-s5pv210/mach-smdkc110.c +++ b/arch/arm/mach-s5pv210/mach-smdkc110.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <plat/cpu.h> | 28 | #include <plat/cpu.h> |
29 | #include <plat/ata.h> | 29 | #include <plat/ata.h> |
30 | #include <plat/iic.h> | 30 | #include <plat/iic.h> |
31 | #include <plat/pm.h> | ||
31 | 32 | ||
32 | /* Following are default values for UCON, ULCON and UFCON UART registers */ | 33 | /* Following are default values for UCON, ULCON and UFCON UART registers */ |
33 | #define SMDKC110_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ | 34 | #define SMDKC110_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ |
@@ -110,6 +111,8 @@ static void __init smdkc110_map_io(void) | |||
110 | 111 | ||
111 | static void __init smdkc110_machine_init(void) | 112 | static void __init smdkc110_machine_init(void) |
112 | { | 113 | { |
114 | s3c_pm_init(); | ||
115 | |||
113 | s3c_i2c0_set_platdata(NULL); | 116 | s3c_i2c0_set_platdata(NULL); |
114 | s3c_i2c1_set_platdata(NULL); | 117 | s3c_i2c1_set_platdata(NULL); |
115 | s3c_i2c2_set_platdata(NULL); | 118 | s3c_i2c2_set_platdata(NULL); |
diff --git a/arch/arm/mach-s5pv210/mach-smdkv210.c b/arch/arm/mach-s5pv210/mach-smdkv210.c index fbbc0a3c3738..5a9c79cb63bd 100644 --- a/arch/arm/mach-s5pv210/mach-smdkv210.c +++ b/arch/arm/mach-s5pv210/mach-smdkv210.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <plat/ata.h> | 31 | #include <plat/ata.h> |
32 | #include <plat/iic.h> | 32 | #include <plat/iic.h> |
33 | #include <plat/keypad.h> | 33 | #include <plat/keypad.h> |
34 | #include <plat/pm.h> | ||
34 | 35 | ||
35 | /* Following are default values for UCON, ULCON and UFCON UART registers */ | 36 | /* Following are default values for UCON, ULCON and UFCON UART registers */ |
36 | #define SMDKV210_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ | 37 | #define SMDKV210_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ |
@@ -145,6 +146,8 @@ static void __init smdkv210_map_io(void) | |||
145 | 146 | ||
146 | static void __init smdkv210_machine_init(void) | 147 | static void __init smdkv210_machine_init(void) |
147 | { | 148 | { |
149 | s3c_pm_init(); | ||
150 | |||
148 | samsung_keypad_set_platdata(&smdkv210_keypad_data); | 151 | samsung_keypad_set_platdata(&smdkv210_keypad_data); |
149 | s3c24xx_ts_set_platdata(&s3c_ts_platform); | 152 | s3c24xx_ts_set_platdata(&s3c_ts_platform); |
150 | 153 | ||
diff --git a/arch/arm/mach-s5pv210/pm.c b/arch/arm/mach-s5pv210/pm.c new file mode 100644 index 000000000000..549d7924fd4c --- /dev/null +++ b/arch/arm/mach-s5pv210/pm.c | |||
@@ -0,0 +1,166 @@ | |||
1 | /* linux/arch/arm/mach-s5pv210/pm.c | ||
2 | * | ||
3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com | ||
5 | * | ||
6 | * S5PV210 - Power Management support | ||
7 | * | ||
8 | * Based on arch/arm/mach-s3c2410/pm.c | ||
9 | * Copyright (c) 2006 Simtec Electronics | ||
10 | * Ben Dooks <ben@simtec.co.uk> | ||
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 version 2 as | ||
14 | * published by the Free Software Foundation. | ||
15 | */ | ||
16 | |||
17 | #include <linux/init.h> | ||
18 | #include <linux/suspend.h> | ||
19 | #include <linux/io.h> | ||
20 | |||
21 | #include <plat/cpu.h> | ||
22 | #include <plat/pm.h> | ||
23 | #include <plat/regs-timer.h> | ||
24 | |||
25 | #include <mach/regs-irq.h> | ||
26 | #include <mach/regs-clock.h> | ||
27 | |||
28 | static struct sleep_save s5pv210_core_save[] = { | ||
29 | /* Clock source */ | ||
30 | SAVE_ITEM(S5P_CLK_SRC0), | ||
31 | SAVE_ITEM(S5P_CLK_SRC1), | ||
32 | SAVE_ITEM(S5P_CLK_SRC2), | ||
33 | SAVE_ITEM(S5P_CLK_SRC3), | ||
34 | SAVE_ITEM(S5P_CLK_SRC4), | ||
35 | SAVE_ITEM(S5P_CLK_SRC5), | ||
36 | SAVE_ITEM(S5P_CLK_SRC6), | ||
37 | |||
38 | /* Clock source Mask */ | ||
39 | SAVE_ITEM(S5P_CLK_SRC_MASK0), | ||
40 | SAVE_ITEM(S5P_CLK_SRC_MASK1), | ||
41 | |||
42 | /* Clock Divider */ | ||
43 | SAVE_ITEM(S5P_CLK_DIV0), | ||
44 | SAVE_ITEM(S5P_CLK_DIV1), | ||
45 | SAVE_ITEM(S5P_CLK_DIV2), | ||
46 | SAVE_ITEM(S5P_CLK_DIV3), | ||
47 | SAVE_ITEM(S5P_CLK_DIV4), | ||
48 | SAVE_ITEM(S5P_CLK_DIV5), | ||
49 | SAVE_ITEM(S5P_CLK_DIV6), | ||
50 | SAVE_ITEM(S5P_CLK_DIV7), | ||
51 | |||
52 | /* Clock Main Gate */ | ||
53 | SAVE_ITEM(S5P_CLKGATE_MAIN0), | ||
54 | SAVE_ITEM(S5P_CLKGATE_MAIN1), | ||
55 | SAVE_ITEM(S5P_CLKGATE_MAIN2), | ||
56 | |||
57 | /* Clock source Peri Gate */ | ||
58 | SAVE_ITEM(S5P_CLKGATE_PERI0), | ||
59 | SAVE_ITEM(S5P_CLKGATE_PERI1), | ||
60 | |||
61 | /* Clock source SCLK Gate */ | ||
62 | SAVE_ITEM(S5P_CLKGATE_SCLK0), | ||
63 | SAVE_ITEM(S5P_CLKGATE_SCLK1), | ||
64 | |||
65 | /* Clock IP Clock gate */ | ||
66 | SAVE_ITEM(S5P_CLKGATE_IP0), | ||
67 | SAVE_ITEM(S5P_CLKGATE_IP1), | ||
68 | SAVE_ITEM(S5P_CLKGATE_IP2), | ||
69 | SAVE_ITEM(S5P_CLKGATE_IP3), | ||
70 | SAVE_ITEM(S5P_CLKGATE_IP4), | ||
71 | |||
72 | /* Clock Blcok and Bus gate */ | ||
73 | SAVE_ITEM(S5P_CLKGATE_BLOCK), | ||
74 | SAVE_ITEM(S5P_CLKGATE_BUS0), | ||
75 | |||
76 | /* Clock ETC */ | ||
77 | SAVE_ITEM(S5P_CLK_OUT), | ||
78 | SAVE_ITEM(S5P_MDNIE_SEL), | ||
79 | |||
80 | /* PWM Register */ | ||
81 | SAVE_ITEM(S3C2410_TCFG0), | ||
82 | SAVE_ITEM(S3C2410_TCFG1), | ||
83 | SAVE_ITEM(S3C64XX_TINT_CSTAT), | ||
84 | SAVE_ITEM(S3C2410_TCON), | ||
85 | SAVE_ITEM(S3C2410_TCNTB(0)), | ||
86 | SAVE_ITEM(S3C2410_TCMPB(0)), | ||
87 | SAVE_ITEM(S3C2410_TCNTO(0)), | ||
88 | }; | ||
89 | |||
90 | void s5pv210_cpu_suspend(void) | ||
91 | { | ||
92 | unsigned long tmp; | ||
93 | |||
94 | /* issue the standby signal into the pm unit. Note, we | ||
95 | * issue a write-buffer drain just in case */ | ||
96 | |||
97 | tmp = 0; | ||
98 | |||
99 | asm("b 1f\n\t" | ||
100 | ".align 5\n\t" | ||
101 | "1:\n\t" | ||
102 | "mcr p15, 0, %0, c7, c10, 5\n\t" | ||
103 | "mcr p15, 0, %0, c7, c10, 4\n\t" | ||
104 | "wfi" : : "r" (tmp)); | ||
105 | |||
106 | /* we should never get past here */ | ||
107 | panic("sleep resumed to originator?"); | ||
108 | } | ||
109 | |||
110 | static void s5pv210_pm_prepare(void) | ||
111 | { | ||
112 | unsigned int tmp; | ||
113 | |||
114 | /* ensure at least INFORM0 has the resume address */ | ||
115 | __raw_writel(virt_to_phys(s3c_cpu_resume), S5P_INFORM0); | ||
116 | |||
117 | tmp = __raw_readl(S5P_SLEEP_CFG); | ||
118 | tmp &= ~(S5P_SLEEP_CFG_OSC_EN | S5P_SLEEP_CFG_USBOSC_EN); | ||
119 | __raw_writel(tmp, S5P_SLEEP_CFG); | ||
120 | |||
121 | /* WFI for SLEEP mode configuration by SYSCON */ | ||
122 | tmp = __raw_readl(S5P_PWR_CFG); | ||
123 | tmp &= S5P_CFG_WFI_CLEAN; | ||
124 | tmp |= S5P_CFG_WFI_SLEEP; | ||
125 | __raw_writel(tmp, S5P_PWR_CFG); | ||
126 | |||
127 | /* SYSCON interrupt handling disable */ | ||
128 | tmp = __raw_readl(S5P_OTHERS); | ||
129 | tmp |= S5P_OTHER_SYSC_INTOFF; | ||
130 | __raw_writel(tmp, S5P_OTHERS); | ||
131 | |||
132 | s3c_pm_do_save(s5pv210_core_save, ARRAY_SIZE(s5pv210_core_save)); | ||
133 | } | ||
134 | |||
135 | static int s5pv210_pm_add(struct sys_device *sysdev) | ||
136 | { | ||
137 | pm_cpu_prep = s5pv210_pm_prepare; | ||
138 | pm_cpu_sleep = s5pv210_cpu_suspend; | ||
139 | |||
140 | return 0; | ||
141 | } | ||
142 | |||
143 | static int s5pv210_pm_resume(struct sys_device *dev) | ||
144 | { | ||
145 | u32 tmp; | ||
146 | |||
147 | tmp = __raw_readl(S5P_OTHERS); | ||
148 | tmp |= (S5P_OTHERS_RET_IO | S5P_OTHERS_RET_CF |\ | ||
149 | S5P_OTHERS_RET_MMC | S5P_OTHERS_RET_UART); | ||
150 | __raw_writel(tmp , S5P_OTHERS); | ||
151 | |||
152 | s3c_pm_do_restore_core(s5pv210_core_save, ARRAY_SIZE(s5pv210_core_save)); | ||
153 | |||
154 | return 0; | ||
155 | } | ||
156 | |||
157 | static struct sysdev_driver s5pv210_pm_driver = { | ||
158 | .add = s5pv210_pm_add, | ||
159 | .resume = s5pv210_pm_resume, | ||
160 | }; | ||
161 | |||
162 | static __init int s5pv210_pm_drvinit(void) | ||
163 | { | ||
164 | return sysdev_driver_register(&s5pv210_sysclass, &s5pv210_pm_driver); | ||
165 | } | ||
166 | arch_initcall(s5pv210_pm_drvinit); | ||
diff --git a/arch/arm/mach-s5pv210/sleep.S b/arch/arm/mach-s5pv210/sleep.S new file mode 100644 index 000000000000..d4d222b716b4 --- /dev/null +++ b/arch/arm/mach-s5pv210/sleep.S | |||
@@ -0,0 +1,170 @@ | |||
1 | /* linux/arch/arm/plat-s5p/sleep.S | ||
2 | * | ||
3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com | ||
5 | * | ||
6 | * S5PV210 power Manager (Suspend-To-RAM) support | ||
7 | * Based on S3C2410 sleep code by: | ||
8 | * Ben Dooks, (c) 2004 Simtec Electronics | ||
9 | * | ||
10 | * Based on PXA/SA1100 sleep code by: | ||
11 | * Nicolas Pitre, (c) 2002 Monta Vista Software Inc | ||
12 | * Cliff Brake, (c) 2001 | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License as published by | ||
16 | * the Free Software Foundation; either version 2 of the License, or | ||
17 | * (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
27 | */ | ||
28 | |||
29 | #include <linux/linkage.h> | ||
30 | #include <asm/assembler.h> | ||
31 | #include <asm/memory.h> | ||
32 | |||
33 | .text | ||
34 | |||
35 | /* s3c_cpu_save | ||
36 | * | ||
37 | * entry: | ||
38 | * r0 = save address (virtual addr of s3c_sleep_save_phys) | ||
39 | */ | ||
40 | |||
41 | ENTRY(s3c_cpu_save) | ||
42 | |||
43 | stmfd sp!, { r3 - r12, lr } | ||
44 | |||
45 | mrc p15, 0, r4, c13, c0, 0 @ FCSE/PID | ||
46 | mrc p15, 0, r5, c3, c0, 0 @ Domain ID | ||
47 | mrc p15, 0, r6, c2, c0, 0 @ Translation Table BASE0 | ||
48 | mrc p15, 0, r7, c2, c0, 1 @ Translation Table BASE1 | ||
49 | mrc p15, 0, r8, c2, c0, 2 @ Translation Table Control | ||
50 | mrc p15, 0, r9, c1, c0, 0 @ Control register | ||
51 | mrc p15, 0, r10, c1, c0, 1 @ Auxiliary control register | ||
52 | mrc p15, 0, r11, c1, c0, 2 @ Co-processor access controls | ||
53 | mrc p15, 0, r12, c10, c2, 0 @ Read PRRR | ||
54 | mrc p15, 0, r3, c10, c2, 1 @ READ NMRR | ||
55 | |||
56 | stmia r0, { r3 - r13 } | ||
57 | |||
58 | bl s3c_pm_cb_flushcache | ||
59 | |||
60 | ldr r0, =pm_cpu_sleep | ||
61 | ldr r0, [ r0 ] | ||
62 | mov pc, r0 | ||
63 | |||
64 | resume_with_mmu: | ||
65 | /* | ||
66 | * After MMU is turned on, restore the previous MMU table. | ||
67 | */ | ||
68 | ldr r9 , =(PAGE_OFFSET - PHYS_OFFSET) | ||
69 | add r4, r4, r9 | ||
70 | str r12, [r4] | ||
71 | |||
72 | ldmfd sp!, { r3 - r12, pc } | ||
73 | |||
74 | .ltorg | ||
75 | |||
76 | .data | ||
77 | |||
78 | .global s3c_sleep_save_phys | ||
79 | s3c_sleep_save_phys: | ||
80 | .word 0 | ||
81 | |||
82 | /* sleep magic, to allow the bootloader to check for an valid | ||
83 | * image to resume to. Must be the first word before the | ||
84 | * s3c_cpu_resume entry. | ||
85 | */ | ||
86 | |||
87 | .word 0x2bedf00d | ||
88 | |||
89 | /* s3c_cpu_resume | ||
90 | * | ||
91 | * resume code entry for bootloader to call | ||
92 | * | ||
93 | * we must put this code here in the data segment as we have no | ||
94 | * other way of restoring the stack pointer after sleep, and we | ||
95 | * must not write to the code segment (code is read-only) | ||
96 | */ | ||
97 | |||
98 | ENTRY(s3c_cpu_resume) | ||
99 | mov r0, #PSR_I_BIT | PSR_F_BIT | SVC_MODE | ||
100 | msr cpsr_c, r0 | ||
101 | |||
102 | mov r1, #0 | ||
103 | mcr p15, 0, r1, c8, c7, 0 @ invalidate TLBs | ||
104 | mcr p15, 0, r1, c7, c5, 0 @ invalidate I Cache | ||
105 | |||
106 | ldr r0, s3c_sleep_save_phys @ address of restore block | ||
107 | ldmia r0, { r3 - r13 } | ||
108 | |||
109 | mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID | ||
110 | mcr p15, 0, r5, c3, c0, 0 @ Domain ID | ||
111 | |||
112 | mcr p15, 0, r8, c2, c0, 2 @ Translation Table Control | ||
113 | mcr p15, 0, r7, c2, c0, 1 @ Translation Table BASE1 | ||
114 | mcr p15, 0, r6, c2, c0, 0 @ Translation Table BASE0 | ||
115 | |||
116 | mcr p15, 0, r10, c1, c0, 1 @ Auxiliary control register | ||
117 | |||
118 | mov r0, #0 | ||
119 | mcr p15, 0, r0, c8, c7, 0 @ Invalidate I & D TLB | ||
120 | |||
121 | mov r0, #0 @ restore copro access | ||
122 | mcr p15, 0, r11, c1, c0, 2 @ Co-processor access | ||
123 | mcr p15, 0, r0, c7, c5, 4 | ||
124 | |||
125 | mcr p15, 0, r12, c10, c2, 0 @ write PRRR | ||
126 | mcr p15, 0, r3, c10, c2, 1 @ write NMRR | ||
127 | |||
128 | /* | ||
129 | * In Cortex-A8, when MMU is turned on, the pipeline is flushed. | ||
130 | * And there are no valid entries in the MMU table at this point. | ||
131 | * So before turning on the MMU, the MMU entry for the DRAM address | ||
132 | * range is added. After the MMU is turned on, the other entries | ||
133 | * in the MMU table will be restored. | ||
134 | */ | ||
135 | |||
136 | /* r6 = Translation Table BASE0 */ | ||
137 | mov r4, r6 | ||
138 | mov r4, r4, LSR #14 | ||
139 | mov r4, r4, LSL #14 | ||
140 | |||
141 | /* Load address for adding to MMU table list */ | ||
142 | ldr r11, =0xE010F000 @ INFORM0 reg. | ||
143 | ldr r10, [r11, #0] | ||
144 | mov r10, r10, LSR #18 | ||
145 | bic r10, r10, #0x3 | ||
146 | orr r4, r4, r10 | ||
147 | |||
148 | /* Calculate MMU table entry */ | ||
149 | mov r10, r10, LSL #18 | ||
150 | ldr r5, =0x40E | ||
151 | orr r10, r10, r5 | ||
152 | |||
153 | /* Back up originally data */ | ||
154 | ldr r12, [r4] | ||
155 | |||
156 | /* Add calculated MMU table entry into MMU table list */ | ||
157 | str r10, [r4] | ||
158 | |||
159 | ldr r2, =resume_with_mmu | ||
160 | mcr p15, 0, r9, c1, c0, 0 @ turn on MMU, etc | ||
161 | |||
162 | nop | ||
163 | nop | ||
164 | nop | ||
165 | nop | ||
166 | nop @ second-to-last before mmu | ||
167 | |||
168 | mov pc, r2 @ go back to virtual address | ||
169 | |||
170 | .ltorg | ||
diff --git a/arch/arm/plat-s5p/Makefile b/arch/arm/plat-s5p/Makefile index e0823be3c8b9..de65238a7aef 100644 --- a/arch/arm/plat-s5p/Makefile +++ b/arch/arm/plat-s5p/Makefile | |||
@@ -19,6 +19,8 @@ obj-y += clock.o | |||
19 | obj-y += irq.o | 19 | obj-y += irq.o |
20 | obj-$(CONFIG_S5P_EXT_INT) += irq-eint.o | 20 | obj-$(CONFIG_S5P_EXT_INT) += irq-eint.o |
21 | obj-$(CONFIG_S5P_GPIO_INT) += irq-gpioint.o | 21 | obj-$(CONFIG_S5P_GPIO_INT) += irq-gpioint.o |
22 | obj-$(CONFIG_PM) += pm.o | ||
23 | obj-$(CONFIG_PM) += irq-pm.o | ||
22 | 24 | ||
23 | # devices | 25 | # devices |
24 | 26 | ||
diff --git a/arch/arm/plat-s5p/irq-pm.c b/arch/arm/plat-s5p/irq-pm.c new file mode 100644 index 000000000000..dc33b9ecda45 --- /dev/null +++ b/arch/arm/plat-s5p/irq-pm.c | |||
@@ -0,0 +1,93 @@ | |||
1 | /* linux/arch/arm/plat-s5p/irq-pm.c | ||
2 | * | ||
3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com | ||
5 | * | ||
6 | * Based on arch/arm/plat-s3c24xx/irq-pm.c, | ||
7 | * Copyright (c) 2003,2004 Simtec Electronics | ||
8 | * Ben Dooks <ben@simtec.co.uk> | ||
9 | * http://armlinux.simtec.co.uk/ | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * published by the Free Software Foundation. | ||
14 | */ | ||
15 | |||
16 | #include <linux/init.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/interrupt.h> | ||
19 | #include <linux/sysdev.h> | ||
20 | |||
21 | #include <plat/cpu.h> | ||
22 | #include <plat/irqs.h> | ||
23 | #include <plat/pm.h> | ||
24 | #include <mach/map.h> | ||
25 | |||
26 | #include <mach/regs-gpio.h> | ||
27 | #include <mach/regs-irq.h> | ||
28 | |||
29 | /* state for IRQs over sleep */ | ||
30 | |||
31 | /* default is to allow for EINT0..EINT31, and IRQ_RTC_TIC, IRQ_RTC_ALARM, | ||
32 | * as wakeup sources | ||
33 | * | ||
34 | * set bit to 1 in allow bitfield to enable the wakeup settings on it | ||
35 | */ | ||
36 | |||
37 | unsigned long s3c_irqwake_intallow = 0x00000006L; | ||
38 | unsigned long s3c_irqwake_eintallow = 0xffffffffL; | ||
39 | |||
40 | int s3c_irq_wake(unsigned int irqno, unsigned int state) | ||
41 | { | ||
42 | unsigned long irqbit; | ||
43 | |||
44 | switch (irqno) { | ||
45 | case IRQ_RTC_TIC: | ||
46 | case IRQ_RTC_ALARM: | ||
47 | irqbit = 1 << (irqno + 1 - IRQ_RTC_ALARM); | ||
48 | if (!state) | ||
49 | s3c_irqwake_intmask |= irqbit; | ||
50 | else | ||
51 | s3c_irqwake_intmask &= ~irqbit; | ||
52 | break; | ||
53 | default: | ||
54 | return -ENOENT; | ||
55 | } | ||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | static struct sleep_save eint_save[] = { | ||
60 | SAVE_ITEM(S5P_EINT_CON(0)), | ||
61 | SAVE_ITEM(S5P_EINT_CON(1)), | ||
62 | SAVE_ITEM(S5P_EINT_CON(2)), | ||
63 | SAVE_ITEM(S5P_EINT_CON(3)), | ||
64 | |||
65 | SAVE_ITEM(S5P_EINT_FLTCON(0)), | ||
66 | SAVE_ITEM(S5P_EINT_FLTCON(1)), | ||
67 | SAVE_ITEM(S5P_EINT_FLTCON(2)), | ||
68 | SAVE_ITEM(S5P_EINT_FLTCON(3)), | ||
69 | SAVE_ITEM(S5P_EINT_FLTCON(4)), | ||
70 | SAVE_ITEM(S5P_EINT_FLTCON(5)), | ||
71 | SAVE_ITEM(S5P_EINT_FLTCON(6)), | ||
72 | SAVE_ITEM(S5P_EINT_FLTCON(7)), | ||
73 | |||
74 | SAVE_ITEM(S5P_EINT_MASK(0)), | ||
75 | SAVE_ITEM(S5P_EINT_MASK(1)), | ||
76 | SAVE_ITEM(S5P_EINT_MASK(2)), | ||
77 | SAVE_ITEM(S5P_EINT_MASK(3)), | ||
78 | }; | ||
79 | |||
80 | int s3c24xx_irq_suspend(struct sys_device *dev, pm_message_t state) | ||
81 | { | ||
82 | s3c_pm_do_save(eint_save, ARRAY_SIZE(eint_save)); | ||
83 | |||
84 | return 0; | ||
85 | } | ||
86 | |||
87 | int s3c24xx_irq_resume(struct sys_device *dev) | ||
88 | { | ||
89 | s3c_pm_do_restore(eint_save, ARRAY_SIZE(eint_save)); | ||
90 | |||
91 | return 0; | ||
92 | } | ||
93 | |||
diff --git a/arch/arm/plat-s5p/pm.c b/arch/arm/plat-s5p/pm.c new file mode 100644 index 000000000000..d592b6304b48 --- /dev/null +++ b/arch/arm/plat-s5p/pm.c | |||
@@ -0,0 +1,52 @@ | |||
1 | /* linux/arch/arm/plat-s5p/pm.c | ||
2 | * | ||
3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com | ||
5 | * | ||
6 | * S5P Power Manager (Suspend-To-RAM) support | ||
7 | * | ||
8 | * Based on arch/arm/plat-s3c24xx/pm.c | ||
9 | * Copyright (c) 2004,2006 Simtec Electronics | ||
10 | * Ben Dooks <ben@simtec.co.uk> | ||
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 version 2 as | ||
14 | * published by the Free Software Foundation. | ||
15 | */ | ||
16 | |||
17 | #include <linux/suspend.h> | ||
18 | #include <plat/pm.h> | ||
19 | |||
20 | #define PFX "s5p pm: " | ||
21 | |||
22 | /* s3c_pm_check_resume_pin | ||
23 | * | ||
24 | * check to see if the pin is configured correctly for sleep mode, and | ||
25 | * make any necessary adjustments if it is not | ||
26 | */ | ||
27 | |||
28 | static void s3c_pm_check_resume_pin(unsigned int pin, unsigned int irqoffs) | ||
29 | { | ||
30 | /* nothing here yet */ | ||
31 | } | ||
32 | |||
33 | /* s3c_pm_configure_extint | ||
34 | * | ||
35 | * configure all external interrupt pins | ||
36 | */ | ||
37 | |||
38 | void s3c_pm_configure_extint(void) | ||
39 | { | ||
40 | /* nothing here yet */ | ||
41 | } | ||
42 | |||
43 | void s3c_pm_restore_core(void) | ||
44 | { | ||
45 | /* nothing here yet */ | ||
46 | } | ||
47 | |||
48 | void s3c_pm_save_core(void) | ||
49 | { | ||
50 | /* nothing here yet */ | ||
51 | } | ||
52 | |||
diff --git a/arch/arm/plat-samsung/pm-gpio.c b/arch/arm/plat-samsung/pm-gpio.c index 7df03f87fbfa..96528200eb79 100644 --- a/arch/arm/plat-samsung/pm-gpio.c +++ b/arch/arm/plat-samsung/pm-gpio.c | |||
@@ -192,7 +192,7 @@ struct s3c_gpio_pm s3c_gpio_pm_2bit = { | |||
192 | .resume = s3c_gpio_pm_2bit_resume, | 192 | .resume = s3c_gpio_pm_2bit_resume, |
193 | }; | 193 | }; |
194 | 194 | ||
195 | #ifdef CONFIG_ARCH_S3C64XX | 195 | #if defined(CONFIG_ARCH_S3C64XX) || defined(CONFIG_PLAT_S5P) |
196 | static void s3c_gpio_pm_4bit_save(struct s3c_gpio_chip *chip) | 196 | static void s3c_gpio_pm_4bit_save(struct s3c_gpio_chip *chip) |
197 | { | 197 | { |
198 | chip->pm_save[1] = __raw_readl(chip->base + OFFS_CON); | 198 | chip->pm_save[1] = __raw_readl(chip->base + OFFS_CON); |
@@ -302,7 +302,7 @@ struct s3c_gpio_pm s3c_gpio_pm_4bit = { | |||
302 | .save = s3c_gpio_pm_4bit_save, | 302 | .save = s3c_gpio_pm_4bit_save, |
303 | .resume = s3c_gpio_pm_4bit_resume, | 303 | .resume = s3c_gpio_pm_4bit_resume, |
304 | }; | 304 | }; |
305 | #endif /* CONFIG_ARCH_S3C64XX */ | 305 | #endif /* CONFIG_ARCH_S3C64XX || CONFIG_PLAT_S5P */ |
306 | 306 | ||
307 | /** | 307 | /** |
308 | * s3c_pm_save_gpio() - save gpio chip data for suspend | 308 | * s3c_pm_save_gpio() - save gpio chip data for suspend |