1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29#include <linux/init.h>
30#include <linux/suspend.h>
31#include <linux/errno.h>
32#include <linux/time.h>
33#include <linux/gpio.h>
34#include <linux/interrupt.h>
35#include <linux/serial_core.h>
36#include <linux/io.h>
37
38#include <plat/regs-serial.h>
39#include <mach/regs-clock.h>
40#include <mach/regs-gpio.h>
41#include <mach/regs-irq.h>
42
43#include <asm/mach/time.h>
44
45#include <plat/gpio-cfg.h>
46#include <plat/pm.h>
47
48#include "regs-mem.h"
49
50#define PFX "s3c24xx-pm: "
51
52static struct sleep_save core_save[] = {
53 SAVE_ITEM(S3C2410_LOCKTIME),
54 SAVE_ITEM(S3C2410_CLKCON),
55
56
57
58
59
60
61
62
63
64 SAVE_ITEM(S3C2410_BWSCON),
65 SAVE_ITEM(S3C2410_BANKCON0),
66 SAVE_ITEM(S3C2410_BANKCON1),
67 SAVE_ITEM(S3C2410_BANKCON2),
68 SAVE_ITEM(S3C2410_BANKCON3),
69 SAVE_ITEM(S3C2410_BANKCON4),
70 SAVE_ITEM(S3C2410_BANKCON5),
71
72#ifndef CONFIG_CPU_FREQ
73 SAVE_ITEM(S3C2410_CLKDIVN),
74 SAVE_ITEM(S3C2410_MPLLCON),
75 SAVE_ITEM(S3C2410_REFRESH),
76#endif
77 SAVE_ITEM(S3C2410_UPLLCON),
78 SAVE_ITEM(S3C2410_CLKSLOW),
79};
80
81static struct sleep_save misc_save[] = {
82 SAVE_ITEM(S3C2410_DCLKCON),
83};
84
85
86
87
88
89
90
91static void s3c_pm_check_resume_pin(unsigned int pin, unsigned int irqoffs)
92{
93 unsigned long irqstate;
94 unsigned long pinstate;
95 int irq = gpio_to_irq(pin);
96
97 if (irqoffs < 4)
98 irqstate = s3c_irqwake_intmask & (1L<<irqoffs);
99 else
100 irqstate = s3c_irqwake_eintmask & (1L<<irqoffs);
101
102 pinstate = s3c_gpio_getcfg(pin);
103
104 if (!irqstate) {
105 if (pinstate == S3C2410_GPIO_IRQ)
106 S3C_PMDBG("Leaving IRQ %d (pin %d) as is\n", irq, pin);
107 } else {
108 if (pinstate == S3C2410_GPIO_IRQ) {
109 S3C_PMDBG("Disabling IRQ %d (pin %d)\n", irq, pin);
110 s3c_gpio_cfgpin(pin, S3C2410_GPIO_INPUT);
111 }
112 }
113}
114
115
116
117
118
119
120void s3c_pm_configure_extint(void)
121{
122 int pin;
123
124
125
126
127
128
129 for (pin = S3C2410_GPF(0); pin <= S3C2410_GPF(7); pin++) {
130 s3c_pm_check_resume_pin(pin, pin - S3C2410_GPF(0));
131 }
132
133 for (pin = S3C2410_GPG(0); pin <= S3C2410_GPG(7); pin++) {
134 s3c_pm_check_resume_pin(pin, (pin - S3C2410_GPG(0))+8);
135 }
136}
137
138
139void s3c_pm_restore_core(void)
140{
141 s3c_pm_do_restore_core(core_save, ARRAY_SIZE(core_save));
142 s3c_pm_do_restore(misc_save, ARRAY_SIZE(misc_save));
143}
144
145void s3c_pm_save_core(void)
146{
147 s3c_pm_do_save(misc_save, ARRAY_SIZE(misc_save));
148 s3c_pm_do_save(core_save, ARRAY_SIZE(core_save));
149}
150
151