aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
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
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')
-rw-r--r--arch/arm/mach-pxa/generic.c62
-rw-r--r--arch/arm/mach-pxa/gpio.c57
2 files changed, 57 insertions, 62 deletions
diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
index 80721c610d41..331f29b2d0cd 100644
--- a/arch/arm/mach-pxa/generic.c
+++ b/arch/arm/mach-pxa/generic.c
@@ -19,14 +19,8 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/delay.h>
23#include <linux/ioport.h>
24#include <linux/pm.h>
25#include <linux/string.h>
26#include <linux/sysdev.h>
27 22
28#include <asm/hardware.h> 23#include <asm/hardware.h>
29#include <asm/irq.h>
30#include <asm/system.h> 24#include <asm/system.h>
31#include <asm/pgtable.h> 25#include <asm/pgtable.h>
32#include <asm/mach/map.h> 26#include <asm/mach/map.h>
@@ -134,59 +128,3 @@ void __init pxa_map_io(void)
134 iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc)); 128 iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc));
135 get_clk_frequency_khz(1); 129 get_clk_frequency_khz(1);
136} 130}
137
138#ifdef CONFIG_PM
139
140static unsigned long saved_gplr[4];
141static unsigned long saved_gpdr[4];
142static unsigned long saved_grer[4];
143static unsigned long saved_gfer[4];
144
145static int pxa_gpio_suspend(struct sys_device *dev, pm_message_t state)
146{
147 int i, gpio;
148
149 for (gpio = 0, i = 0; gpio < pxa_last_gpio; gpio += 32, i++) {
150 saved_gplr[i] = GPLR(gpio);
151 saved_gpdr[i] = GPDR(gpio);
152 saved_grer[i] = GRER(gpio);
153 saved_gfer[i] = GFER(gpio);
154
155 /* Clear GPIO transition detect bits */
156 GEDR(gpio) = GEDR(gpio);
157 }
158 return 0;
159}
160
161static int pxa_gpio_resume(struct sys_device *dev)
162{
163 int i, gpio;
164
165 for (gpio = 0, i = 0; gpio < pxa_last_gpio; gpio += 32, i++) {
166 /* restore level with set/clear */
167 GPSR(gpio) = saved_gplr[i];
168 GPCR(gpio) = ~saved_gplr[i];
169
170 GRER(gpio) = saved_grer[i];
171 GFER(gpio) = saved_gfer[i];
172 GPDR(gpio) = saved_gpdr[i];
173 }
174 return 0;
175}
176#else
177#define pxa_gpio_suspend NULL
178#define pxa_gpio_resume NULL
179#endif
180
181struct sysdev_class pxa_gpio_sysclass = {
182 .name = "gpio",
183 .suspend = pxa_gpio_suspend,
184 .resume = pxa_gpio_resume,
185};
186
187static int __init pxa_gpio_init(void)
188{
189 return sysdev_class_register(&pxa_gpio_sysclass);
190}
191
192core_initcall(pxa_gpio_init);
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);