summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAlejandro Gonzalez <alex.gonzalez@digi.com>2010-06-29 12:47:59 +0200
committerAlejandro Gonzalez <alex.gonzalez@digi.com>2010-06-29 12:47:59 +0200
commit03aa1f973871d4b34490e02db5e3fa0e7f03073a (patch)
treeac3948169a7c7af47f1606cf29045d0c4b58c260 /drivers
parent8948e75e75d30aaf314a81edb2db1c401031e826 (diff)
ccwmx51: Allow for the GPIO and RTC wake up interrupts to be disabled.
Signed-off-by: Alejandro Gonzalez <alex.gonzalez@digi.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/power/sysfs.c46
-rw-r--r--drivers/rtc/rtc-mc13892.c20
2 files changed, 50 insertions, 16 deletions
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 0b3e0b7eb7fa..d5be766493a4 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -10,6 +10,8 @@
#include <linux/interrupt.h>
#include <mach/gpio.h>
+#include <linux/irq.h>
+
/*
* wakeup - Report/change current wakeup option for device
*
@@ -61,33 +63,49 @@ wake_store(struct device * dev, struct device_attribute *attr,
{
char *cp;
int len = n;
+ char *name = NULL;
+ char *ep;
+ unsigned int gpio;
+ int irq;
+ int is_gpio = 0;
+ struct irq_desc *desc;
if (!device_can_wakeup(dev))
return -EINVAL;
+ if ( machine_is_ccwmx51js() || machine_is_ccmx51js() ) {
+ /* Check whether this is a GPIO */
+ if( (name = strstr(dev->kobj.name , "gpio")) ) {
+ is_gpio = 1;
+ gpio = simple_strtol(name+strlen("gpio"), &ep, 0);
+ irq = gpio_to_irq(gpio);
+ }
+ }
+
cp = memchr(buf, '\n', n);
if (cp)
len = cp - buf;
if (len == sizeof enabled - 1
- && strncmp(buf, enabled, sizeof enabled - 1) == 0)
+ && strncmp(buf, enabled, sizeof enabled - 1) == 0) {
device_set_wakeup_enable(dev, 1);
+ if ( is_gpio ) {
+ /* Configure it as wake up source */
+ set_irq_wake(irq,1);
+ }
+ }
else if (len == sizeof disabled - 1
- && strncmp(buf, disabled, sizeof disabled - 1) == 0)
+ && strncmp(buf, disabled, sizeof disabled - 1) == 0) {
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);
+ if ( is_gpio ) {
+ desc = irq_to_desc(irq);
+ if(desc->status & IRQ_WAKEUP){
+ /* Deconfigure it as wake up source */
+ disable_irq_wake(irq);
+ }
}
}
+ else
+ return -EINVAL;
return n;
}
diff --git a/drivers/rtc/rtc-mc13892.c b/drivers/rtc/rtc-mc13892.c
index 3b7e3af4e54c..213aba5c8d85 100644
--- a/drivers/rtc/rtc-mc13892.c
+++ b/drivers/rtc/rtc-mc13892.c
@@ -18,6 +18,8 @@
#include <linux/pmic_status.h>
#include <linux/pmic_external.h>
+#include <linux/irq.h>
+
#define RTC_TIME_LSH 0
#define RTC_DAY_LSH 0
#define RTCALARM_TIME_LSH 0
@@ -232,8 +234,22 @@ static int __exit mxc_rtc_remove(struct platform_device *pdev)
static int mxc_rtc_suspend(struct platform_device *pdev, pm_message_t state)
{
- if (device_may_wakeup(&pdev->dev))
- enable_irq_wake(platform_get_irq(pdev, 0));
+ int irq;
+ struct irq_desc *desc;
+
+ if(!pdev)
+ return -1;
+
+ irq = platform_get_irq(pdev, 0);
+
+ if (device_may_wakeup(&pdev->dev)) {
+ enable_irq_wake(irq);
+ }
+ else {
+ desc = irq_to_desc(irq);
+ if(desc->status & IRQ_WAKEUP)
+ disable_irq_wake(irq);
+ }
return 0;
}