aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-s3c.c
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2013-04-29 19:19:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 21:28:28 -0400
commit32e445aab4049692cfe5b6cafa8ab1706b0ef8a3 (patch)
tree24ad884cd39e91cfa6e168a017741d91baf8fcde /drivers/rtc/rtc-s3c.c
parentbc48b9023b0ee7ec4ad0d6b3332804d3b3e77fa8 (diff)
drivers/rtc/rtc-s3c.c: convert s3c_rtc to dev_pm_ops
Instead of using legacy suspend/resume methods, using newer dev_pm_ops structure allows better control over power management. Also, 'wake_en' variable is moved, because it is only used when CONFIG_PM_SLEEP is enabled. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-s3c.c')
-rw-r--r--drivers/rtc/rtc-s3c.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 7dcf719d9b85..653a4dcbfe7d 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -51,7 +51,6 @@ static struct clk *rtc_clk;
51static void __iomem *s3c_rtc_base; 51static void __iomem *s3c_rtc_base;
52static int s3c_rtc_alarmno = NO_IRQ; 52static int s3c_rtc_alarmno = NO_IRQ;
53static int s3c_rtc_tickno = NO_IRQ; 53static int s3c_rtc_tickno = NO_IRQ;
54static bool wake_en;
55static enum s3c_cpu_type s3c_rtc_cpu_type; 54static enum s3c_cpu_type s3c_rtc_cpu_type;
56 55
57static DEFINE_SPINLOCK(s3c_rtc_pie_lock); 56static DEFINE_SPINLOCK(s3c_rtc_pie_lock);
@@ -579,14 +578,16 @@ static int s3c_rtc_probe(struct platform_device *pdev)
579 return ret; 578 return ret;
580} 579}
581 580
582#ifdef CONFIG_PM 581#ifdef CONFIG_PM_SLEEP
583
584/* RTC Power management control */ 582/* RTC Power management control */
585 583
586static int ticnt_save, ticnt_en_save; 584static int ticnt_save, ticnt_en_save;
585static bool wake_en;
587 586
588static int s3c_rtc_suspend(struct platform_device *pdev, pm_message_t state) 587static int s3c_rtc_suspend(struct device *dev)
589{ 588{
589 struct platform_device *pdev = to_platform_device(dev);
590
590 clk_enable(rtc_clk); 591 clk_enable(rtc_clk);
591 /* save TICNT for anyone using periodic interrupts */ 592 /* save TICNT for anyone using periodic interrupts */
592 ticnt_save = readb(s3c_rtc_base + S3C2410_TICNT); 593 ticnt_save = readb(s3c_rtc_base + S3C2410_TICNT);
@@ -596,19 +597,20 @@ static int s3c_rtc_suspend(struct platform_device *pdev, pm_message_t state)
596 } 597 }
597 s3c_rtc_enable(pdev, 0); 598 s3c_rtc_enable(pdev, 0);
598 599
599 if (device_may_wakeup(&pdev->dev) && !wake_en) { 600 if (device_may_wakeup(dev) && !wake_en) {
600 if (enable_irq_wake(s3c_rtc_alarmno) == 0) 601 if (enable_irq_wake(s3c_rtc_alarmno) == 0)
601 wake_en = true; 602 wake_en = true;
602 else 603 else
603 dev_err(&pdev->dev, "enable_irq_wake failed\n"); 604 dev_err(dev, "enable_irq_wake failed\n");
604 } 605 }
605 clk_disable(rtc_clk); 606 clk_disable(rtc_clk);
606 607
607 return 0; 608 return 0;
608} 609}
609 610
610static int s3c_rtc_resume(struct platform_device *pdev) 611static int s3c_rtc_resume(struct device *dev)
611{ 612{
613 struct platform_device *pdev = to_platform_device(dev);
612 unsigned int tmp; 614 unsigned int tmp;
613 615
614 clk_enable(rtc_clk); 616 clk_enable(rtc_clk);
@@ -619,7 +621,7 @@ static int s3c_rtc_resume(struct platform_device *pdev)
619 writew(tmp | ticnt_en_save, s3c_rtc_base + S3C2410_RTCCON); 621 writew(tmp | ticnt_en_save, s3c_rtc_base + S3C2410_RTCCON);
620 } 622 }
621 623
622 if (device_may_wakeup(&pdev->dev) && wake_en) { 624 if (device_may_wakeup(dev) && wake_en) {
623 disable_irq_wake(s3c_rtc_alarmno); 625 disable_irq_wake(s3c_rtc_alarmno);
624 wake_en = false; 626 wake_en = false;
625 } 627 }
@@ -627,11 +629,10 @@ static int s3c_rtc_resume(struct platform_device *pdev)
627 629
628 return 0; 630 return 0;
629} 631}
630#else
631#define s3c_rtc_suspend NULL
632#define s3c_rtc_resume NULL
633#endif 632#endif
634 633
634static SIMPLE_DEV_PM_OPS(s3c_rtc_pm_ops, s3c_rtc_suspend, s3c_rtc_resume);
635
635#ifdef CONFIG_OF 636#ifdef CONFIG_OF
636static struct s3c_rtc_drv_data s3c_rtc_drv_data_array[] = { 637static struct s3c_rtc_drv_data s3c_rtc_drv_data_array[] = {
637 [TYPE_S3C2410] = { TYPE_S3C2410 }, 638 [TYPE_S3C2410] = { TYPE_S3C2410 },
@@ -681,12 +682,11 @@ MODULE_DEVICE_TABLE(platform, s3c_rtc_driver_ids);
681static struct platform_driver s3c_rtc_driver = { 682static struct platform_driver s3c_rtc_driver = {
682 .probe = s3c_rtc_probe, 683 .probe = s3c_rtc_probe,
683 .remove = s3c_rtc_remove, 684 .remove = s3c_rtc_remove,
684 .suspend = s3c_rtc_suspend,
685 .resume = s3c_rtc_resume,
686 .id_table = s3c_rtc_driver_ids, 685 .id_table = s3c_rtc_driver_ids,
687 .driver = { 686 .driver = {
688 .name = "s3c-rtc", 687 .name = "s3c-rtc",
689 .owner = THIS_MODULE, 688 .owner = THIS_MODULE,
689 .pm = &s3c_rtc_pm_ops,
690 .of_match_table = of_match_ptr(s3c_rtc_dt_match), 690 .of_match_table = of_match_ptr(s3c_rtc_dt_match),
691 }, 691 },
692}; 692};