diff options
author | Stefan Christ <s.christ@phytec.de> | 2016-07-05 13:53:17 +0200 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2016-07-21 20:06:57 +0200 |
commit | ae036af8962da5856be2ee2b5543e65014cd608f (patch) | |
tree | 74b6ff89c93196e65f7026c4e14fbf32c7fecb79 /drivers/rtc | |
parent | e89487fef537975f2c95c6c41316201c2e0869ab (diff) | |
download | op-kernel-dev-ae036af8962da5856be2ee2b5543e65014cd608f.zip op-kernel-dev-ae036af8962da5856be2ee2b5543e65014cd608f.tar.gz |
rtc: m41t80: add suspend handlers for alarm IRQ
Allow the alarm IRQ of RTC to be used as a wakeup source for the system
suspend.
Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/rtc-m41t80.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index 042d6a2..58698d2 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c @@ -335,6 +335,30 @@ static struct rtc_class_ops m41t80_rtc_ops = { .proc = m41t80_rtc_proc, }; +#ifdef CONFIG_PM_SLEEP +static int m41t80_suspend(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + + if (client->irq >= 0 && device_may_wakeup(dev)) + enable_irq_wake(client->irq); + + return 0; +} + +static int m41t80_resume(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + + if (client->irq >= 0 && device_may_wakeup(dev)) + disable_irq_wake(client->irq); + + return 0; +} +#endif + +static SIMPLE_DEV_PM_OPS(m41t80_pm, m41t80_suspend, m41t80_resume); + static ssize_t flags_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -870,6 +894,7 @@ static int m41t80_remove(struct i2c_client *client) static struct i2c_driver m41t80_driver = { .driver = { .name = "rtc-m41t80", + .pm = &m41t80_pm, }, .probe = m41t80_probe, .remove = m41t80_remove, |