From patchwork Thu Dec 22 08:54:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3/3] rtc: max8925: add function to work as wakeup source Date: Wed, 21 Dec 2011 22:54:11 -0000 From: Haojian Zhuang X-Patchwork-Id: 132792 Message-Id: <1324544051-1494-3-git-send-email-haojian.zhuang@marvell.com> To: a.zummo@towertech.it, rtc-linux@googlegroups.com, linux-arm-kernel@lists.infradead.org Cc: Kevin Liu From: Kevin Liu Signed-off-by: Kevin Liu --- drivers/rtc/rtc-max8925.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c index 8564749..721385c 100644 --- a/drivers/rtc/rtc-max8925.c +++ b/drivers/rtc/rtc-max8925.c @@ -272,6 +272,8 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev) /* XXX - isn't this redundant? */ platform_set_drvdata(pdev, info); + device_init_wakeup(&pdev->dev, 1); + info->rtc_dev = rtc_device_register("max8925-rtc", &pdev->dev, &max8925_rtc_ops, THIS_MODULE); ret = PTR_ERR(info->rtc_dev); @@ -301,10 +303,38 @@ static int __devexit max8925_rtc_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM +static int max8925_rtc_suspend(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); + + if (device_may_wakeup(dev)) + chip->wakeup_flag |= 1 << MAX8925_IRQ_RTC_ALARM0; + return 0; +} +static int max8925_rtc_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); + + if (device_may_wakeup(dev)) + chip->wakeup_flag &= ~(1 << MAX8925_IRQ_RTC_ALARM0); + return 0; +} +static struct dev_pm_ops max8925_rtc_pm_ops = { + .suspend = max8925_rtc_suspend, + .resume = max8925_rtc_resume, +}; +#endif + static struct platform_driver max8925_rtc_driver = { .driver = { .name = "max8925-rtc", .owner = THIS_MODULE, +#ifdef CONFIG_PM + .pm = &max8925_rtc_pm_ops, +#endif }, .probe = max8925_rtc_probe, .remove = __devexit_p(max8925_rtc_remove),