summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAlejandro Gonzalez <alex.gonzalez@digi.com>2010-06-16 11:32:18 +0200
committerAlejandro Gonzalez <alex.gonzalez@digi.com>2010-06-23 11:24:48 +0200
commit057b9b859cee72a4e70658ae6e28a1ad1f37bad5 (patch)
tree5f4fb8072203c0e8e01af8c42d58a4650b1f51e9 /drivers
parente7708a44045df4a7b590f45745d6d8b30c41ef7d (diff)
GPIO: Make suspend to RAM with GPIO wake up source work
Because the BSP implements GPIOs as system devices, but the sysfs uses the device model, this is an ugly way of supporting this functionality without moving the GPIO subsystem to the device model. Signed-off-by: Alejandro Gonzalez <alex.gonzalez@digi.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/power/sysfs.c17
-rw-r--r--drivers/gpio/gpiolib.c6
2 files changed, 23 insertions, 0 deletions
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 596aeecfdffe..0b3e0b7eb7fa 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -6,6 +6,10 @@
#include <linux/string.h>
#include "power.h"
+#include <asm/mach-types.h>
+#include <linux/interrupt.h>
+#include <mach/gpio.h>
+
/*
* wakeup - Report/change current wakeup option for device
*
@@ -72,6 +76,19 @@ wake_store(struct device * dev, struct device_attribute *attr,
device_set_wakeup_enable(dev, 0);
else
return -EINVAL;
+
+ if ( machine_is_ccwmx51js() || machine_is_ccmx51js() ) {
+ char *name = NULL;
+ char *ep;
+ unsigned int gpio;
+
+ /* Check whether this is a GPIO and if so configure it as wake up source */
+ if( (name = strstr(dev->kobj.name , "gpio")) ) {
+ gpio = simple_strtol(name+strlen("gpio"), &ep, 0);
+ set_irq_wake(gpio_to_irq(gpio),1);
+ }
+ }
+
return n;
}
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 51a8d4103be5..908b750f4901 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -8,6 +8,7 @@
#include <linux/seq_file.h>
#include <linux/gpio.h>
+#include <asm/mach-types.h>
/* Optional implementation infrastructure for GPIO interfaces.
*
@@ -474,6 +475,11 @@ int gpio_export(unsigned gpio, bool direction_may_change)
dev = device_create(&gpio_class, desc->chip->dev, MKDEV(0, 0),
desc, ioname ? ioname : "gpio%d", gpio);
+
+ if ( machine_is_ccwmx51js() || machine_is_ccmx51js() )
+ // Allow this device to be used as wake up source
+ device_set_wakeup_capable(dev,1);
+
if (dev) {
if (direction_may_change)
status = sysfs_create_group(&dev->kobj,