Merge branch 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[deliverable/linux.git] / arch / arm / mach-s3c24xx / pm-s3c2412.c
1 /* linux/arch/arm/mach-s3c2412/pm.c
2 *
3 * Copyright (c) 2006 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * http://armlinux.simtec.co.uk/.
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 version 2 as
10 * published by the Free Software Foundation.
11 */
12
13 #include <linux/kernel.h>
14 #include <linux/types.h>
15 #include <linux/interrupt.h>
16 #include <linux/list.h>
17 #include <linux/timer.h>
18 #include <linux/init.h>
19 #include <linux/device.h>
20 #include <linux/syscore_ops.h>
21 #include <linux/platform_device.h>
22 #include <linux/io.h>
23
24 #include <asm/cacheflush.h>
25 #include <asm/irq.h>
26
27 #include <mach/hardware.h>
28 #include <mach/regs-gpio.h>
29
30 #include <plat/cpu.h>
31 #include <plat/pm.h>
32 #include <plat/s3c2412.h>
33
34 #include "regs-dsc.h"
35 #include "s3c2412-power.h"
36
37 extern void s3c2412_sleep_enter(void);
38
39 static int s3c2412_cpu_suspend(unsigned long arg)
40 {
41 unsigned long tmp;
42
43 /* set our standby method to sleep */
44
45 tmp = __raw_readl(S3C2412_PWRCFG);
46 tmp |= S3C2412_PWRCFG_STANDBYWFI_SLEEP;
47 __raw_writel(tmp, S3C2412_PWRCFG);
48
49 s3c2412_sleep_enter();
50
51 pr_info("Failed to suspend the system\n");
52 return 1; /* Aborting suspend */
53 }
54
55 static void s3c2412_pm_prepare(void)
56 {
57 }
58
59 static int s3c2412_pm_add(struct device *dev, struct subsys_interface *sif)
60 {
61 pm_cpu_prep = s3c2412_pm_prepare;
62 pm_cpu_sleep = s3c2412_cpu_suspend;
63
64 return 0;
65 }
66
67 static struct sleep_save s3c2412_sleep[] = {
68 SAVE_ITEM(S3C2412_DSC0),
69 SAVE_ITEM(S3C2412_DSC1),
70 SAVE_ITEM(S3C2413_GPJDAT),
71 SAVE_ITEM(S3C2413_GPJCON),
72 SAVE_ITEM(S3C2413_GPJUP),
73
74 /* save the PWRCFG to get back to original sleep method */
75
76 SAVE_ITEM(S3C2412_PWRCFG),
77
78 /* save the sleep configuration anyway, just in case these
79 * get damaged during wakeup */
80
81 SAVE_ITEM(S3C2412_GPBSLPCON),
82 SAVE_ITEM(S3C2412_GPCSLPCON),
83 SAVE_ITEM(S3C2412_GPDSLPCON),
84 SAVE_ITEM(S3C2412_GPFSLPCON),
85 SAVE_ITEM(S3C2412_GPGSLPCON),
86 SAVE_ITEM(S3C2412_GPHSLPCON),
87 SAVE_ITEM(S3C2413_GPJSLPCON),
88 };
89
90 static struct subsys_interface s3c2412_pm_interface = {
91 .name = "s3c2412_pm",
92 .subsys = &s3c2412_subsys,
93 .add_dev = s3c2412_pm_add,
94 };
95
96 static __init int s3c2412_pm_init(void)
97 {
98 return subsys_interface_register(&s3c2412_pm_interface);
99 }
100
101 arch_initcall(s3c2412_pm_init);
102
103 static int s3c2412_pm_suspend(void)
104 {
105 s3c_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
106 return 0;
107 }
108
109 static void s3c2412_pm_resume(void)
110 {
111 unsigned long tmp;
112
113 tmp = __raw_readl(S3C2412_PWRCFG);
114 tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
115 tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
116 __raw_writel(tmp, S3C2412_PWRCFG);
117
118 s3c_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
119 }
120
121 struct syscore_ops s3c2412_pm_syscore_ops = {
122 .suspend = s3c2412_pm_suspend,
123 .resume = s3c2412_pm_resume,
124 };
This page took 0.079497 seconds and 5 git commands to generate.