aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/gpio.c
diff options
context:
space:
mode:
authoreric miao <eric.miao@marvell.com>2008-03-04 03:13:58 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-04-19 06:29:04 -0400
commit663707c1a99b23a79f9e21117b7c1bdbfe80a899 (patch)
treef864865940e4f5252b56ee295cf317cbb0c12631 /arch/arm/mach-pxa/gpio.c
parentb9e25aced33eeb7279ccbaef198f28370cfb4e93 (diff)
[ARM] pxa: move GPIO sysdev outside of generic.c into gpio.c
Signed-off-by: eric miao <eric.miao@marvell.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-pxa/gpio.c')
-rw-r--r--arch/arm/mach-pxa/gpio.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/arch/arm/mach-pxa/gpio.c b/arch/arm/mach-pxa/gpio.c
index bf4c08408f2e..a98b2da4c962 100644
--- a/arch/arm/mach-pxa/gpio.c
+++ b/arch/arm/mach-pxa/gpio.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/irq.h> 17#include <linux/irq.h>
18#include <linux/sysdev.h>
18 19
19#include <asm/gpio.h> 20#include <asm/gpio.h>
20#include <asm/hardware.h> 21#include <asm/hardware.h>
@@ -338,3 +339,59 @@ void __init pxa_init_gpio(int gpio_nr, set_wake_t fn)
338 gpiochip_add(&pxa_gpio_chip[i].chip); 339 gpiochip_add(&pxa_gpio_chip[i].chip);
339 } 340 }
340} 341}
342
343#ifdef CONFIG_PM
344
345static unsigned long saved_gplr[4];
346static unsigned long saved_gpdr[4];
347static unsigned long saved_grer[4];
348static unsigned long saved_gfer[4];
349
350static int pxa_gpio_suspend(struct sys_device *dev, pm_message_t state)
351{
352 int i, gpio;
353
354 for (gpio = 0, i = 0; gpio < pxa_last_gpio; gpio += 32, i++) {
355 saved_gplr[i] = GPLR(gpio);
356 saved_gpdr[i] = GPDR(gpio);
357 saved_grer[i] = GRER(gpio);
358 saved_gfer[i] = GFER(gpio);
359
360 /* Clear GPIO transition detect bits */
361 GEDR(gpio) = GEDR(gpio);
362 }
363 return 0;
364}
365
366static int pxa_gpio_resume(struct sys_device *dev)
367{
368 int i, gpio;
369
370 for (gpio = 0, i = 0; gpio < pxa_last_gpio; gpio += 32, i++) {
371 /* restore level with set/clear */
372 GPSR(gpio) = saved_gplr[i];
373 GPCR(gpio) = ~saved_gplr[i];
374
375 GRER(gpio) = saved_grer[i];
376 GFER(gpio) = saved_gfer[i];
377 GPDR(gpio) = saved_gpdr[i];
378 }
379 return 0;
380}
381#else
382#define pxa_gpio_suspend NULL
383#define pxa_gpio_resume NULL
384#endif
385
386struct sysdev_class pxa_gpio_sysclass = {
387 .name = "gpio",
388 .suspend = pxa_gpio_suspend,
389 .resume = pxa_gpio_resume,
390};
391
392static int __init pxa_gpio_init(void)
393{
394 return sysdev_class_register(&pxa_gpio_sysclass);
395}
396
397core_initcall(pxa_gpio_init);