summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhangfei Gao <zhangfei.gao@linaro.org>2013-04-01 09:46:04 +0800
committerAndrey Konovalov <andrey.konovalov@linaro.org>2013-10-16 22:18:52 +0400
commitbd6757f02ea091ecf15bc188672d93b04ca16250 (patch)
tree18cd3673446a1e2cd1d3066d650db6c0dc71bacc
parent0a91b84e34306ae431e8bfe856bb531a6739e544 (diff)
How to test: Documentation/rtc.txt echo +n > /sys/class/rtc/rtc1/wakealarm; (n is seconds to genetate wakeup irq) echo mem > /sys/power/state Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
-rw-r--r--drivers/rtc/rtc-pl031.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index 0f0609b1aa2c..7fbb5c1d38fc 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -371,6 +371,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
}
}
+ device_init_wakeup(&adev->dev, 1);
ldata->rtc = rtc_device_register("pl031", &adev->dev, ops,
THIS_MODULE);
if (IS_ERR(ldata->rtc)) {
@@ -384,8 +385,6 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
goto out_no_irq;
}
- device_init_wakeup(&adev->dev, 1);
-
return 0;
out_no_irq:
@@ -402,6 +401,32 @@ err_req:
return ret;
}
+#ifdef CONFIG_PM
+static int pl031_suspend(struct device *dev)
+{
+ struct amba_device *adev = to_amba_device(dev);
+
+ if (adev->irq[0] >= 0 && device_may_wakeup(&adev->dev))
+ enable_irq_wake(adev->irq[0]);
+ return 0;
+}
+
+static int pl031_resume(struct device *dev)
+{
+ struct amba_device *adev = to_amba_device(dev);
+
+ if (adev->irq[0] >= 0 && device_may_wakeup(&adev->dev))
+ disable_irq_wake(adev->irq[0]);
+ return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(pl031_pm, pl031_suspend, pl031_resume);
+
+#define PL031_PM (&pl031_pm)
+#else
+#define PL031_PM NULL
+#endif
+
/* Operations for the original ARM version */
static struct pl031_vendor_data arm_pl031 = {
.ops = {
@@ -471,6 +496,7 @@ MODULE_DEVICE_TABLE(amba, pl031_ids);
static struct amba_driver pl031_driver = {
.drv = {
.name = "rtc-pl031",
+ .pm = PL031_PM,
},
.id_table = pl031_ids,
.probe = pl031_probe,