aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhangfei Gao <zhangfei.gao@linaro.org>2013-04-01 09:46:04 +0800
committerGuodong Xu <guodong.xu@linaro.org>2013-04-23 18:28:17 +0800
commit838a81e0bfbfb8cd23b79f866632657fd5ce5a38 (patch)
tree47ee6c052f219ed79d6d540ddf2eb9dbc40522a9
parent43c5e583c21c1bcf136fd3e9ca5377c1122466ed (diff)
drivers/rtc/rtc-pl031.c: use rtc as wakeup source
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.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index 81c5077feff3..e141a43dc65f 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)) {
@@ -400,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 = {
@@ -469,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,