diff options
Diffstat (limited to 'arch/arm/mach-pxa/generic.c')
-rw-r--r-- | arch/arm/mach-pxa/generic.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c index 698aeec52961..76970598f550 100644 --- a/arch/arm/mach-pxa/generic.c +++ b/arch/arm/mach-pxa/generic.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/ioport.h> | 23 | #include <linux/ioport.h> |
24 | #include <linux/pm.h> | 24 | #include <linux/pm.h> |
25 | #include <linux/string.h> | 25 | #include <linux/string.h> |
26 | #include <linux/sysdev.h> | ||
26 | 27 | ||
27 | #include <asm/hardware.h> | 28 | #include <asm/hardware.h> |
28 | #include <asm/irq.h> | 29 | #include <asm/irq.h> |
@@ -226,3 +227,59 @@ void __init pxa_map_io(void) | |||
226 | iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc)); | 227 | iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc)); |
227 | get_clk_frequency_khz(1); | 228 | get_clk_frequency_khz(1); |
228 | } | 229 | } |
230 | |||
231 | #ifdef CONFIG_PM | ||
232 | |||
233 | static unsigned long saved_gplr[4]; | ||
234 | static unsigned long saved_gpdr[4]; | ||
235 | static unsigned long saved_grer[4]; | ||
236 | static unsigned long saved_gfer[4]; | ||
237 | |||
238 | static int pxa_gpio_suspend(struct sys_device *dev, pm_message_t state) | ||
239 | { | ||
240 | int i, gpio; | ||
241 | |||
242 | for (gpio = 0, i = 0; gpio < pxa_last_gpio; gpio += 32, i++) { | ||
243 | saved_gplr[i] = GPLR(gpio); | ||
244 | saved_gpdr[i] = GPDR(gpio); | ||
245 | saved_grer[i] = GRER(gpio); | ||
246 | saved_gfer[i] = GFER(gpio); | ||
247 | |||
248 | /* Clear GPIO transition detect bits */ | ||
249 | GEDR(gpio) = GEDR(gpio); | ||
250 | } | ||
251 | return 0; | ||
252 | } | ||
253 | |||
254 | static int pxa_gpio_resume(struct sys_device *dev) | ||
255 | { | ||
256 | int i, gpio; | ||
257 | |||
258 | for (gpio = 0, i = 0; gpio < pxa_last_gpio; gpio += 32, i++) { | ||
259 | /* restore level with set/clear */ | ||
260 | GPSR(gpio) = saved_gplr[i]; | ||
261 | GPCR(gpio) = ~saved_gplr[i]; | ||
262 | |||
263 | GRER(gpio) = saved_grer[i]; | ||
264 | GFER(gpio) = saved_gfer[i]; | ||
265 | GPDR(gpio) = saved_gpdr[i]; | ||
266 | } | ||
267 | return 0; | ||
268 | } | ||
269 | #else | ||
270 | #define pxa_gpio_suspend NULL | ||
271 | #define pxa_gpio_resume NULL | ||
272 | #endif | ||
273 | |||
274 | struct sysdev_class pxa_gpio_sysclass = { | ||
275 | .name = "gpio", | ||
276 | .suspend = pxa_gpio_suspend, | ||
277 | .resume = pxa_gpio_resume, | ||
278 | }; | ||
279 | |||
280 | static int __init pxa_gpio_init(void) | ||
281 | { | ||
282 | return sysdev_class_register(&pxa_gpio_sysclass); | ||
283 | } | ||
284 | |||
285 | core_initcall(pxa_gpio_init); | ||