Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Vaibhav Hiremath and committed by
Linus Torvalds
fc9bd902 427af9a6

+18
+18
drivers/rtc/rtc-omap.c
··· 22 22 #include <linux/platform_device.h> 23 23 #include <linux/of.h> 24 24 #include <linux/of_device.h> 25 + #include <linux/pm_runtime.h> 25 26 26 27 #include <asm/io.h> 27 28 ··· 365 364 goto fail; 366 365 } 367 366 367 + /* Enable the clock/module so that we can access the registers */ 368 + pm_runtime_enable(&pdev->dev); 369 + pm_runtime_get_sync(&pdev->dev); 370 + 368 371 id_entry = platform_get_device_id(pdev); 369 372 if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) { 370 373 rtc_writel(KICK0_VALUE, OMAP_RTC_KICK0_REG); ··· 453 448 fail0: 454 449 if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) 455 450 rtc_writel(0, OMAP_RTC_KICK0_REG); 451 + pm_runtime_put_sync(&pdev->dev); 452 + pm_runtime_disable(&pdev->dev); 456 453 iounmap(rtc_base); 457 454 fail: 458 455 release_mem_region(mem->start, resource_size(mem)); ··· 481 474 rtc_device_unregister(rtc); 482 475 if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) 483 476 rtc_writel(0, OMAP_RTC_KICK0_REG); 477 + 478 + /* Disable the clock/module */ 479 + pm_runtime_put_sync(&pdev->dev); 480 + pm_runtime_disable(&pdev->dev); 481 + 484 482 iounmap(rtc_base); 485 483 release_mem_region(mem->start, resource_size(mem)); 486 484 return 0; ··· 508 496 else 509 497 rtc_write(0, OMAP_RTC_INTERRUPTS_REG); 510 498 499 + /* Disable the clock/module */ 500 + pm_runtime_put_sync(&pdev->dev); 501 + 511 502 return 0; 512 503 } 513 504 514 505 static int omap_rtc_resume(struct platform_device *pdev) 515 506 { 507 + /* Enable the clock/module so that we can access the registers */ 508 + pm_runtime_get_sync(&pdev->dev); 509 + 516 510 if (device_may_wakeup(&pdev->dev)) 517 511 disable_irq_wake(omap_rtc_alarm); 518 512 else