aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorVaibhav Hiremath <hvaibhav@ti.com>2012-12-17 19:02:18 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-17 20:15:20 -0500
commitfc9bd9022e8d5863f3efce34cc38cb0c6187271c (patch)
treed2d92c36dfbe7eb874374571a655b2bbdcb3ca7a /drivers
parent427af9a6216b5845d428f27111add5311c381797 (diff)
rtc: omap: add runtime pm support
OMAP1 RTC driver is used in multiple devices like, OMAPL138 and AM33XX. Driver currently doesn't handle any clocks, which may be right for OMAP1 architecture but in case of AM33XX, the clock/module needs to be enabled in order to access the registers. So convert this driver to runtime pm, which internally handles rest. [afzal@ti.com: handle error path] Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com> Signed-off-by: Afzal Mohammed <afzal@ti.com> Acked-by: Sekhar Nori <nsekhar@ti.com> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: Sekhar Nori <nsekhar@ti.com> Cc: Kevin Hilman <khilman@ti.com> Cc: Russell King <linux@arm.linux.org.uk> Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Daniel Mack <zonque@gmail.com> Cc: Vaibhav Hiremath <hvaibhav@ti.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/rtc/rtc-omap.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index dff9ff476b0d..600971407aac 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -22,6 +22,7 @@
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/of.h> 23#include <linux/of.h>
24#include <linux/of_device.h> 24#include <linux/of_device.h>
25#include <linux/pm_runtime.h>
25 26
26#include <asm/io.h> 27#include <asm/io.h>
27 28
@@ -364,6 +365,10 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
364 goto fail; 365 goto fail;
365 } 366 }
366 367
368 /* Enable the clock/module so that we can access the registers */
369 pm_runtime_enable(&pdev->dev);
370 pm_runtime_get_sync(&pdev->dev);
371
367 id_entry = platform_get_device_id(pdev); 372 id_entry = platform_get_device_id(pdev);
368 if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) { 373 if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) {
369 rtc_writel(KICK0_VALUE, OMAP_RTC_KICK0_REG); 374 rtc_writel(KICK0_VALUE, OMAP_RTC_KICK0_REG);
@@ -448,6 +453,8 @@ fail1:
448fail0: 453fail0:
449 if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) 454 if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER))
450 rtc_writel(0, OMAP_RTC_KICK0_REG); 455 rtc_writel(0, OMAP_RTC_KICK0_REG);
456 pm_runtime_put_sync(&pdev->dev);
457 pm_runtime_disable(&pdev->dev);
451 iounmap(rtc_base); 458 iounmap(rtc_base);
452fail: 459fail:
453 release_mem_region(mem->start, resource_size(mem)); 460 release_mem_region(mem->start, resource_size(mem));
@@ -474,6 +481,11 @@ static int __exit omap_rtc_remove(struct platform_device *pdev)
474 rtc_device_unregister(rtc); 481 rtc_device_unregister(rtc);
475 if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) 482 if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER))
476 rtc_writel(0, OMAP_RTC_KICK0_REG); 483 rtc_writel(0, OMAP_RTC_KICK0_REG);
484
485 /* Disable the clock/module */
486 pm_runtime_put_sync(&pdev->dev);
487 pm_runtime_disable(&pdev->dev);
488
477 iounmap(rtc_base); 489 iounmap(rtc_base);
478 release_mem_region(mem->start, resource_size(mem)); 490 release_mem_region(mem->start, resource_size(mem));
479 return 0; 491 return 0;
@@ -496,11 +508,17 @@ static int omap_rtc_suspend(struct platform_device *pdev, pm_message_t state)
496 else 508 else
497 rtc_write(0, OMAP_RTC_INTERRUPTS_REG); 509 rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
498 510
511 /* Disable the clock/module */
512 pm_runtime_put_sync(&pdev->dev);
513
499 return 0; 514 return 0;
500} 515}
501 516
502static int omap_rtc_resume(struct platform_device *pdev) 517static int omap_rtc_resume(struct platform_device *pdev)
503{ 518{
519 /* Enable the clock/module so that we can access the registers */
520 pm_runtime_get_sync(&pdev->dev);
521
504 if (device_may_wakeup(&pdev->dev)) 522 if (device_may_wakeup(&pdev->dev))
505 disable_irq_wake(omap_rtc_alarm); 523 disable_irq_wake(omap_rtc_alarm);
506 else 524 else