Documentation / ACPI: update to GPIO descriptor API
[deliverable/linux.git] / arch / arm / mach-s3c24xx / pm-s3c2410.c
CommitLineData
1da177e4
LT
1/* linux/arch/arm/mach-s3c2410/pm.c
2 *
a21765a7 3 * Copyright (c) 2006 Simtec Electronics
1da177e4
LT
4 * Ben Dooks <ben@simtec.co.uk>
5 *
a21765a7 6 * S3C2410 (and compatible) Power Manager (Suspend-To-RAM) support
1da177e4
LT
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1da177e4
LT
21*/
22
1da177e4
LT
23#include <linux/init.h>
24#include <linux/suspend.h>
25#include <linux/errno.h>
26#include <linux/time.h>
4a858cfc 27#include <linux/device.h>
bb072c3c 28#include <linux/syscore_ops.h>
ec976d6e 29#include <linux/gpio.h>
fced80c7 30#include <linux/io.h>
c67d0f29 31#include <linux/platform_data/gpio-samsung-s3c24xx.h>
1da177e4 32
a21765a7 33#include <asm/mach-types.h>
1da177e4 34
232910d6 35#include <mach/hardware.h>
a09e64fb 36#include <mach/regs-gpio.h>
1da177e4 37
a2b7ba9c
BD
38#include <plat/cpu.h>
39#include <plat/pm.h>
1da177e4 40
232910d6
KK
41#include "h1940.h"
42
a21765a7 43static void s3c2410_pm_prepare(void)
1da177e4 44{
a21765a7 45 /* ensure at least GSTATUS3 has the resume address */
1da177e4 46
ef30e144 47 __raw_writel(virt_to_phys(s3c_cpu_resume), S3C2410_GSTATUS3);
1da177e4 48
6419711a
BD
49 S3C_PMDBG("GSTATUS3 0x%08x\n", __raw_readl(S3C2410_GSTATUS3));
50 S3C_PMDBG("GSTATUS4 0x%08x\n", __raw_readl(S3C2410_GSTATUS4));
1da177e4 51
a21765a7
BD
52 if (machine_is_h1940()) {
53 void *base = phys_to_virt(H1940_SUSPEND_CHECK);
54 unsigned long ptr;
55 unsigned long calc = 0;
1da177e4 56
a21765a7 57 /* generate check for the bootloader to check on resume */
1da177e4 58
a21765a7
BD
59 for (ptr = 0; ptr < 0x40000; ptr += 0x400)
60 calc += __raw_readl(base+ptr);
1da177e4 61
a21765a7 62 __raw_writel(calc, phys_to_virt(H1940_SUSPEND_CHECKSUM));
1da177e4
LT
63 }
64
0741b7d2 65 /* RX3715 and RX1950 use similar to H1940 code and the
a21765a7 66 * same offsets for resume and checksum pointers */
1da177e4 67
0741b7d2 68 if (machine_is_rx3715() || machine_is_rx1950()) {
a21765a7
BD
69 void *base = phys_to_virt(H1940_SUSPEND_CHECK);
70 unsigned long ptr;
71 unsigned long calc = 0;
1da177e4 72
a21765a7 73 /* generate check for the bootloader to check on resume */
1da177e4 74
a21765a7
BD
75 for (ptr = 0; ptr < 0x40000; ptr += 0x4)
76 calc += __raw_readl(base+ptr);
1da177e4 77
a21765a7 78 __raw_writel(calc, phys_to_virt(H1940_SUSPEND_CHECKSUM));
1da177e4
LT
79 }
80
94911735
SN
81 if (machine_is_aml_m5900()) {
82 gpio_request_one(S3C2410_GPF(2), GPIOF_OUT_INIT_HIGH, NULL);
83 gpio_free(S3C2410_GPF(2));
84 }
1da177e4 85
192ff91f
VK
86 if (machine_is_rx1950()) {
87 /* According to S3C2442 user's manual, page 7-17,
88 * when the system is operating in NAND boot mode,
89 * the hardware pin configuration - EINT[23:21] –
90 * must be set as input for starting up after
91 * wakeup from sleep mode
92 */
93 s3c_gpio_cfgpin(S3C2410_GPG(13), S3C2410_GPIO_INPUT);
94 s3c_gpio_cfgpin(S3C2410_GPG(14), S3C2410_GPIO_INPUT);
95 s3c_gpio_cfgpin(S3C2410_GPG(15), S3C2410_GPIO_INPUT);
96 }
1da177e4
LT
97}
98
bb072c3c 99static void s3c2410_pm_resume(void)
1da177e4 100{
a21765a7 101 unsigned long tmp;
1da177e4 102
a21765a7 103 /* unset the return-from-sleep flag, to ensure reset */
1da177e4 104
a21765a7
BD
105 tmp = __raw_readl(S3C2410_GSTATUS2);
106 tmp &= S3C2410_GSTATUS2_OFFRESET;
107 __raw_writel(tmp, S3C2410_GSTATUS2);
1da177e4 108
94911735
SN
109 if (machine_is_aml_m5900()) {
110 gpio_request_one(S3C2410_GPF(2), GPIOF_OUT_INIT_LOW, NULL);
111 gpio_free(S3C2410_GPF(2));
112 }
1da177e4
LT
113}
114
bb072c3c
RW
115struct syscore_ops s3c2410_pm_syscore_ops = {
116 .resume = s3c2410_pm_resume,
117};
118
04511a6f 119static int s3c2410_pm_add(struct device *dev, struct subsys_interface *sif)
1da177e4 120{
a21765a7
BD
121 pm_cpu_prep = s3c2410_pm_prepare;
122 pm_cpu_sleep = s3c2410_cpu_suspend;
1da177e4 123
a21765a7 124 return 0;
1da177e4
LT
125}
126
a21765a7 127#if defined(CONFIG_CPU_S3C2410)
4a858cfc
KS
128static struct subsys_interface s3c2410_pm_interface = {
129 .name = "s3c2410_pm",
130 .subsys = &s3c2410_subsys,
131 .add_dev = s3c2410_pm_add,
a21765a7 132};
1da177e4 133
a21765a7 134/* register ourselves */
1da177e4 135
a21765a7 136static int __init s3c2410_pm_drvinit(void)
1da177e4 137{
4a858cfc 138 return subsys_interface_register(&s3c2410_pm_interface);
1da177e4
LT
139}
140
a21765a7 141arch_initcall(s3c2410_pm_drvinit);
f0176794 142
4a858cfc
KS
143static struct subsys_interface s3c2410a_pm_interface = {
144 .name = "s3c2410a_pm",
ea04018e 145 .subsys = &s3c2410a_subsys,
4a858cfc 146 .add_dev = s3c2410_pm_add,
f0176794
BD
147};
148
149static int __init s3c2410a_pm_drvinit(void)
150{
4a858cfc 151 return subsys_interface_register(&s3c2410a_pm_interface);
f0176794
BD
152}
153
154arch_initcall(s3c2410a_pm_drvinit);
a21765a7 155#endif
1da177e4 156
a21765a7 157#if defined(CONFIG_CPU_S3C2440)
4a858cfc
KS
158static struct subsys_interface s3c2440_pm_interface = {
159 .name = "s3c2440_pm",
160 .subsys = &s3c2440_subsys,
161 .add_dev = s3c2410_pm_add,
a21765a7 162};
1da177e4 163
a21765a7 164static int __init s3c2440_pm_drvinit(void)
1da177e4 165{
4a858cfc 166 return subsys_interface_register(&s3c2440_pm_interface);
1da177e4
LT
167}
168
a21765a7
BD
169arch_initcall(s3c2440_pm_drvinit);
170#endif
1da177e4 171
a21765a7 172#if defined(CONFIG_CPU_S3C2442)
4a858cfc
KS
173static struct subsys_interface s3c2442_pm_interface = {
174 .name = "s3c2442_pm",
175 .subsys = &s3c2442_subsys,
176 .add_dev = s3c2410_pm_add,
1da177e4
LT
177};
178
a21765a7 179static int __init s3c2442_pm_drvinit(void)
1da177e4 180{
4a858cfc 181 return subsys_interface_register(&s3c2442_pm_interface);
1da177e4 182}
a21765a7
BD
183
184arch_initcall(s3c2442_pm_drvinit);
185#endif
This page took 0.751125 seconds and 5 git commands to generate.