diff options
Diffstat (limited to 'drivers/rtc/rtc-tps65910.c')
-rw-r--r-- | drivers/rtc/rtc-tps65910.c | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c index e5fef141a0e2..8bd8115329b5 100644 --- a/drivers/rtc/rtc-tps65910.c +++ b/drivers/rtc/rtc-tps65910.c | |||
@@ -22,13 +22,13 @@ | |||
22 | #include <linux/rtc.h> | 22 | #include <linux/rtc.h> |
23 | #include <linux/bcd.h> | 23 | #include <linux/bcd.h> |
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/pm_runtime.h> | ||
25 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
26 | #include <linux/mfd/tps65910.h> | 27 | #include <linux/mfd/tps65910.h> |
27 | 28 | ||
28 | struct tps65910_rtc { | 29 | struct tps65910_rtc { |
29 | struct rtc_device *rtc; | 30 | struct rtc_device *rtc; |
30 | /* To store the list of enabled interrupts */ | 31 | int irq; |
31 | u32 irqstat; | ||
32 | }; | 32 | }; |
33 | 33 | ||
34 | /* Total number of RTC registers needed to set time*/ | 34 | /* Total number of RTC registers needed to set time*/ |
@@ -267,13 +267,14 @@ static int tps65910_rtc_probe(struct platform_device *pdev) | |||
267 | } | 267 | } |
268 | 268 | ||
269 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, | 269 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
270 | tps65910_rtc_interrupt, IRQF_TRIGGER_LOW, | 270 | tps65910_rtc_interrupt, IRQF_TRIGGER_LOW | IRQF_EARLY_RESUME, |
271 | dev_name(&pdev->dev), &pdev->dev); | 271 | dev_name(&pdev->dev), &pdev->dev); |
272 | if (ret < 0) { | 272 | if (ret < 0) { |
273 | dev_err(&pdev->dev, "IRQ is not free.\n"); | 273 | dev_err(&pdev->dev, "IRQ is not free.\n"); |
274 | return ret; | 274 | return ret; |
275 | } | 275 | } |
276 | device_init_wakeup(&pdev->dev, 1); | 276 | tps_rtc->irq = irq; |
277 | device_set_wakeup_capable(&pdev->dev, 1); | ||
277 | 278 | ||
278 | tps_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, | 279 | tps_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, |
279 | &tps65910_rtc_ops, THIS_MODULE); | 280 | &tps65910_rtc_ops, THIS_MODULE); |
@@ -304,49 +305,36 @@ static int tps65910_rtc_remove(struct platform_device *pdev) | |||
304 | } | 305 | } |
305 | 306 | ||
306 | #ifdef CONFIG_PM_SLEEP | 307 | #ifdef CONFIG_PM_SLEEP |
307 | |||
308 | static int tps65910_rtc_suspend(struct device *dev) | 308 | static int tps65910_rtc_suspend(struct device *dev) |
309 | { | 309 | { |
310 | struct tps65910 *tps = dev_get_drvdata(dev->parent); | 310 | struct tps65910_rtc *tps_rtc = dev_get_drvdata(dev); |
311 | u8 alarm = TPS65910_RTC_INTERRUPTS_IT_ALARM; | ||
312 | int ret; | ||
313 | |||
314 | /* Store current list of enabled interrupts*/ | ||
315 | ret = regmap_read(tps->regmap, TPS65910_RTC_INTERRUPTS, | ||
316 | &tps->rtc->irqstat); | ||
317 | if (ret < 0) | ||
318 | return ret; | ||
319 | 311 | ||
320 | /* Enable RTC ALARM interrupt only */ | 312 | if (device_may_wakeup(dev)) |
321 | return regmap_write(tps->regmap, TPS65910_RTC_INTERRUPTS, alarm); | 313 | enable_irq_wake(tps_rtc->irq); |
314 | return 0; | ||
322 | } | 315 | } |
323 | 316 | ||
324 | static int tps65910_rtc_resume(struct device *dev) | 317 | static int tps65910_rtc_resume(struct device *dev) |
325 | { | 318 | { |
326 | struct tps65910 *tps = dev_get_drvdata(dev->parent); | 319 | struct tps65910_rtc *tps_rtc = dev_get_drvdata(dev); |
327 | 320 | ||
328 | /* Restore list of enabled interrupts before suspend */ | 321 | if (device_may_wakeup(dev)) |
329 | return regmap_write(tps->regmap, TPS65910_RTC_INTERRUPTS, | 322 | disable_irq_wake(tps_rtc->irq); |
330 | tps->rtc->irqstat); | 323 | return 0; |
331 | } | 324 | } |
325 | #endif | ||
332 | 326 | ||
333 | static const struct dev_pm_ops tps65910_rtc_pm_ops = { | 327 | static const struct dev_pm_ops tps65910_rtc_pm_ops = { |
334 | .suspend = tps65910_rtc_suspend, | 328 | SET_SYSTEM_SLEEP_PM_OPS(tps65910_rtc_suspend, tps65910_rtc_resume) |
335 | .resume = tps65910_rtc_resume, | ||
336 | }; | 329 | }; |
337 | 330 | ||
338 | #define DEV_PM_OPS (&tps65910_rtc_pm_ops) | ||
339 | #else | ||
340 | #define DEV_PM_OPS NULL | ||
341 | #endif | ||
342 | |||
343 | static struct platform_driver tps65910_rtc_driver = { | 331 | static struct platform_driver tps65910_rtc_driver = { |
344 | .probe = tps65910_rtc_probe, | 332 | .probe = tps65910_rtc_probe, |
345 | .remove = tps65910_rtc_remove, | 333 | .remove = tps65910_rtc_remove, |
346 | .driver = { | 334 | .driver = { |
347 | .owner = THIS_MODULE, | 335 | .owner = THIS_MODULE, |
348 | .name = "tps65910-rtc", | 336 | .name = "tps65910-rtc", |
349 | .pm = DEV_PM_OPS, | 337 | .pm = &tps65910_rtc_pm_ops, |
350 | }, | 338 | }, |
351 | }; | 339 | }; |
352 | 340 | ||