Commit | Line | Data |
---|---|---|
a21765a7 BD |
1 | /* linux/arch/arm/plat-s3c24xx/pm.c |
2 | * | |
3 | * Copyright (c) 2004,2006 Simtec Electronics | |
4 | * Ben Dooks <ben@simtec.co.uk> | |
5 | * | |
6 | * S3C24XX Power Manager (Suspend-To-RAM) support | |
7 | * | |
8 | * See Documentation/arm/Samsung-S3C24XX/Suspend.txt for more information | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License as published by | |
12 | * the Free Software Foundation; either version 2 of the License, or | |
13 | * (at your option) any later version. | |
14 | * | |
15 | * This program is distributed in the hope that it will be useful, | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | * GNU General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU General Public License | |
21 | * along with this program; if not, write to the Free Software | |
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 | * | |
24 | * Parts based on arch/arm/mach-pxa/pm.c | |
25 | * | |
26 | * Thanks to Dimitry Andric for debugging | |
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/interrupt.h> | |
a21765a7 | 34 | #include <linux/serial_core.h> |
fced80c7 | 35 | #include <linux/io.h> |
a21765a7 | 36 | |
a2b7ba9c | 37 | #include <plat/regs-serial.h> |
a09e64fb RK |
38 | #include <mach/regs-clock.h> |
39 | #include <mach/regs-gpio.h> | |
40 | #include <mach/regs-mem.h> | |
41 | #include <mach/regs-irq.h> | |
a21765a7 BD |
42 | |
43 | #include <asm/mach/time.h> | |
44 | ||
a2b7ba9c | 45 | #include <plat/pm.h> |
a21765a7 | 46 | |
a21765a7 BD |
47 | #define PFX "s3c24xx-pm: " |
48 | ||
49 | static struct sleep_save core_save[] = { | |
50 | SAVE_ITEM(S3C2410_LOCKTIME), | |
51 | SAVE_ITEM(S3C2410_CLKCON), | |
52 | ||
53 | /* we restore the timings here, with the proviso that the board | |
54 | * brings the system up in an slower, or equal frequency setting | |
55 | * to the original system. | |
56 | * | |
57 | * if we cannot guarantee this, then things are going to go very | |
58 | * wrong here, as we modify the refresh and both pll settings. | |
59 | */ | |
60 | ||
61 | SAVE_ITEM(S3C2410_BWSCON), | |
62 | SAVE_ITEM(S3C2410_BANKCON0), | |
63 | SAVE_ITEM(S3C2410_BANKCON1), | |
64 | SAVE_ITEM(S3C2410_BANKCON2), | |
65 | SAVE_ITEM(S3C2410_BANKCON3), | |
66 | SAVE_ITEM(S3C2410_BANKCON4), | |
67 | SAVE_ITEM(S3C2410_BANKCON5), | |
68 | ||
e425382e | 69 | #ifndef CONFIG_CPU_FREQ |
a21765a7 BD |
70 | SAVE_ITEM(S3C2410_CLKDIVN), |
71 | SAVE_ITEM(S3C2410_MPLLCON), | |
e425382e BD |
72 | SAVE_ITEM(S3C2410_REFRESH), |
73 | #endif | |
a21765a7 BD |
74 | SAVE_ITEM(S3C2410_UPLLCON), |
75 | SAVE_ITEM(S3C2410_CLKSLOW), | |
a21765a7 BD |
76 | }; |
77 | ||
62feee64 | 78 | static struct sleep_save misc_save[] = { |
a21765a7 BD |
79 | SAVE_ITEM(S3C2410_DCLKCON), |
80 | }; | |
81 | ||
549c7e33 | 82 | /* s3c_pm_check_resume_pin |
a21765a7 BD |
83 | * |
84 | * check to see if the pin is configured correctly for sleep mode, and | |
85 | * make any necessary adjustments if it is not | |
86 | */ | |
87 | ||
549c7e33 | 88 | static void s3c_pm_check_resume_pin(unsigned int pin, unsigned int irqoffs) |
a21765a7 BD |
89 | { |
90 | unsigned long irqstate; | |
91 | unsigned long pinstate; | |
92 | int irq = s3c2410_gpio_getirq(pin); | |
93 | ||
94 | if (irqoffs < 4) | |
95 | irqstate = s3c_irqwake_intmask & (1L<<irqoffs); | |
96 | else | |
97 | irqstate = s3c_irqwake_eintmask & (1L<<irqoffs); | |
98 | ||
99 | pinstate = s3c2410_gpio_getcfg(pin); | |
100 | ||
101 | if (!irqstate) { | |
102 | if (pinstate == S3C2410_GPIO_IRQ) | |
6419711a | 103 | S3C_PMDBG("Leaving IRQ %d (pin %d) enabled\n", irq, pin); |
a21765a7 BD |
104 | } else { |
105 | if (pinstate == S3C2410_GPIO_IRQ) { | |
6419711a | 106 | S3C_PMDBG("Disabling IRQ %d (pin %d)\n", irq, pin); |
a21765a7 BD |
107 | s3c2410_gpio_cfgpin(pin, S3C2410_GPIO_INPUT); |
108 | } | |
109 | } | |
110 | } | |
111 | ||
2261e0e6 | 112 | /* s3c_pm_configure_extint |
a21765a7 BD |
113 | * |
114 | * configure all external interrupt pins | |
115 | */ | |
116 | ||
2261e0e6 | 117 | void s3c_pm_configure_extint(void) |
a21765a7 BD |
118 | { |
119 | int pin; | |
120 | ||
121 | /* for each of the external interrupts (EINT0..EINT15) we | |
122 | * need to check wether it is an external interrupt source, | |
123 | * and then configure it as an input if it is not | |
124 | */ | |
125 | ||
126 | for (pin = S3C2410_GPF0; pin <= S3C2410_GPF7; pin++) { | |
549c7e33 | 127 | s3c_pm_check_resume_pin(pin, pin - S3C2410_GPF0); |
a21765a7 BD |
128 | } |
129 | ||
130 | for (pin = S3C2410_GPG0; pin <= S3C2410_GPG7; pin++) { | |
549c7e33 | 131 | s3c_pm_check_resume_pin(pin, (pin - S3C2410_GPG0)+8); |
a21765a7 BD |
132 | } |
133 | } | |
134 | ||
62feee64 | 135 | |
2261e0e6 | 136 | void s3c_pm_restore_core(void) |
a21765a7 | 137 | { |
6419711a BD |
138 | s3c_pm_do_restore_core(core_save, ARRAY_SIZE(core_save)); |
139 | s3c_pm_do_restore(misc_save, ARRAY_SIZE(misc_save)); | |
a21765a7 BD |
140 | } |
141 | ||
2261e0e6 | 142 | void s3c_pm_save_core(void) |
a21765a7 | 143 | { |
2261e0e6 BD |
144 | s3c_pm_do_save(misc_save, ARRAY_SIZE(misc_save)); |
145 | s3c_pm_do_save(core_save, ARRAY_SIZE(core_save)); | |
a21765a7 | 146 | } |
2261e0e6 | 147 |