summaryrefslogtreecommitdiff
path: root/drivers/rtc
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2013-01-21 11:35:35 +0530
committerDan Willemsen <dwillemsen@nvidia.com>2013-09-14 12:50:50 -0700
commit5280b60bf1f20a95e08d5579af8285365f3d54b0 (patch)
treee10fae0c885493f9ea3fc6baf24a01b57dbc48fb /drivers/rtc
parent79f128b901e9ffec5e2a70df659cc2820d522f17 (diff)
rtc: max77660: add wake capabilities and suspend/resume
Enable wake of from the RTC when enetering into suspend and disable wake in resume. Also make wake capable so that wake capabilty can be enable/disable through user space. Change-Id: Ibe118a62d13109dd25b5f5d025d8bef68117cf61 Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-on: http://git-master/r/192835 Reviewed-by: Automatic_Commit_Validation_User
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-max77660.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/drivers/rtc/rtc-max77660.c b/drivers/rtc/rtc-max77660.c
index afbebdc9f8b9..c818dd2cc610 100644
--- a/drivers/rtc/rtc-max77660.c
+++ b/drivers/rtc/rtc-max77660.c
@@ -16,6 +16,7 @@
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/i2c.h>
+#include <linux/pm.h>
#include <linux/rtc.h>
#include <linux/mfd/max77660/max77660-core.h>
@@ -540,13 +541,6 @@ static int __devinit max77660_rtc_probe(struct platform_device *pdev)
goto out;
}
- /*
- * RTC should be a wakeup source, or alarm dev can't link to
- * this devices. that cause Android time change not set into
- * RTC register.
- */
- device_init_wakeup(&pdev->dev, true);
-
rtc->rtc = rtc_device_register("max77660-rtc", &pdev->dev,
&max77660_rtc_ops, THIS_MODULE);
if (IS_ERR_OR_NULL(rtc->rtc)) {
@@ -560,16 +554,14 @@ static int __devinit max77660_rtc_probe(struct platform_device *pdev)
rtc->irq = parent_pdata->irq_base + MAX77660_IRQ_RTC;
ret = request_threaded_irq(rtc->irq, NULL, max77660_rtc_irq,
- IRQF_ONESHOT, "max77660-rtc", rtc);
+ IRQF_ONESHOT | IRQF_EARLY_RESUME, "max77660-rtc", rtc);
if (ret < 0) {
dev_err(rtc->dev, "probe: Failed to request irq %d\n",
rtc->irq);
rtc->irq = -1;
- } else {
- device_init_wakeup(rtc->dev, 1);
- enable_irq_wake(rtc->irq);
}
+ device_set_wakeup_capable(&pdev->dev, 1);
return 0;
out:
@@ -601,12 +593,37 @@ static void max77660_rtc_shutdown(struct platform_device *pdev)
max77660_rtc_alarm_irq_enable(&pdev->dev, 0);
}
+#ifdef CONFIG_PM_SLEEP
+static int max77660_rtc_suspend(struct device *dev)
+{
+ struct max77660_rtc *rtc = dev_get_drvdata(dev);
+
+ if (device_may_wakeup(dev))
+ enable_irq_wake(rtc->irq);
+ return 0;
+}
+
+static int max77660_rtc_resume(struct device *dev)
+{
+ struct max77660_rtc *rtc = dev_get_drvdata(dev);
+
+ if (device_may_wakeup(dev))
+ disable_irq_wake(rtc->irq);
+ return 0;
+};
+#endif
+
+static const struct dev_pm_ops max77660_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(max77660_rtc_suspend, max77660_rtc_resume)
+};
+
static struct platform_driver max77660_rtc_driver = {
.probe = max77660_rtc_probe,
.remove = __devexit_p(max77660_rtc_remove),
.driver = {
- .name = "max77660-rtc",
- .owner = THIS_MODULE,
+ .name = "max77660-rtc",
+ .owner = THIS_MODULE,
+ .pm = &max77660_pm_ops,
},
.shutdown = max77660_rtc_shutdown,
};