aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2012-08-05 19:43:03 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2012-09-03 19:36:02 -0400
commit9bb5ec8872312751f992cdac9968805fe03e81aa (patch)
treebfc05b25c305ea89ce4bd4d66d0f7fc50eb49ab6 /drivers/clocksource
parenteaa49a8cd1f98a6486413d902e7304df026a1fa9 (diff)
sh: CMT: Introduce clocksource/clock events suspend/resume routines
Introduce suspend/resume routines for SH CMT clock event devices and modify the suspend/resume routines for SH CMT clock sources such that if those devices belong to a PM domain, the generic PM domains framework will be notified that the given domain may be turned off (during system suspend) or that it has to be turned on (during system resume). Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Magnus Damm <damm@opensource.se>
Diffstat (limited to 'drivers/clocksource')
-rw-r--r--drivers/clocksource/sh_cmt.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index 98b06baafcc6..c06d27fc59e8 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -464,9 +464,20 @@ static void sh_cmt_clocksource_disable(struct clocksource *cs)
464 sh_cmt_stop(cs_to_sh_cmt(cs), FLAG_CLOCKSOURCE); 464 sh_cmt_stop(cs_to_sh_cmt(cs), FLAG_CLOCKSOURCE);
465} 465}
466 466
467static void sh_cmt_clocksource_suspend(struct clocksource *cs)
468{
469 struct sh_cmt_priv *p = cs_to_sh_cmt(cs);
470
471 sh_cmt_stop(p, FLAG_CLOCKSOURCE);
472 pm_genpd_syscore_poweroff(&p->pdev->dev);
473}
474
467static void sh_cmt_clocksource_resume(struct clocksource *cs) 475static void sh_cmt_clocksource_resume(struct clocksource *cs)
468{ 476{
469 sh_cmt_start(cs_to_sh_cmt(cs), FLAG_CLOCKSOURCE); 477 struct sh_cmt_priv *p = cs_to_sh_cmt(cs);
478
479 pm_genpd_syscore_poweron(&p->pdev->dev);
480 sh_cmt_start(p, FLAG_CLOCKSOURCE);
470} 481}
471 482
472static int sh_cmt_register_clocksource(struct sh_cmt_priv *p, 483static int sh_cmt_register_clocksource(struct sh_cmt_priv *p,
@@ -479,7 +490,7 @@ static int sh_cmt_register_clocksource(struct sh_cmt_priv *p,
479 cs->read = sh_cmt_clocksource_read; 490 cs->read = sh_cmt_clocksource_read;
480 cs->enable = sh_cmt_clocksource_enable; 491 cs->enable = sh_cmt_clocksource_enable;
481 cs->disable = sh_cmt_clocksource_disable; 492 cs->disable = sh_cmt_clocksource_disable;
482 cs->suspend = sh_cmt_clocksource_disable; 493 cs->suspend = sh_cmt_clocksource_suspend;
483 cs->resume = sh_cmt_clocksource_resume; 494 cs->resume = sh_cmt_clocksource_resume;
484 cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); 495 cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8);
485 cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; 496 cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
@@ -562,6 +573,16 @@ static int sh_cmt_clock_event_next(unsigned long delta,
562 return 0; 573 return 0;
563} 574}
564 575
576static void sh_cmt_clock_event_suspend(struct clock_event_device *ced)
577{
578 pm_genpd_syscore_poweroff(&ced_to_sh_cmt(ced)->pdev->dev);
579}
580
581static void sh_cmt_clock_event_resume(struct clock_event_device *ced)
582{
583 pm_genpd_syscore_poweron(&ced_to_sh_cmt(ced)->pdev->dev);
584}
585
565static void sh_cmt_register_clockevent(struct sh_cmt_priv *p, 586static void sh_cmt_register_clockevent(struct sh_cmt_priv *p,
566 char *name, unsigned long rating) 587 char *name, unsigned long rating)
567{ 588{
@@ -576,6 +597,8 @@ static void sh_cmt_register_clockevent(struct sh_cmt_priv *p,
576 ced->cpumask = cpumask_of(0); 597 ced->cpumask = cpumask_of(0);
577 ced->set_next_event = sh_cmt_clock_event_next; 598 ced->set_next_event = sh_cmt_clock_event_next;
578 ced->set_mode = sh_cmt_clock_event_mode; 599 ced->set_mode = sh_cmt_clock_event_mode;
600 ced->suspend = sh_cmt_clock_event_suspend;
601 ced->resume = sh_cmt_clock_event_resume;
579 602
580 dev_info(&p->pdev->dev, "used for clock events\n"); 603 dev_info(&p->pdev->dev, "used for clock events\n");
581 clockevents_register_device(ced); 604 clockevents_register_device(ced);
@@ -690,8 +713,12 @@ static int __devinit sh_cmt_probe(struct platform_device *pdev)
690 struct sh_cmt_priv *p = platform_get_drvdata(pdev); 713 struct sh_cmt_priv *p = platform_get_drvdata(pdev);
691 int ret; 714 int ret;
692 715
693 if (!is_early_platform_device(pdev)) 716 if (!is_early_platform_device(pdev)) {
694 pm_genpd_dev_always_on(&pdev->dev, true); 717 struct sh_timer_config *cfg = pdev->dev.platform_data;
718
719 if (cfg->clocksource_rating || cfg->clockevent_rating)
720 pm_genpd_dev_always_on(&pdev->dev, true);
721 }
695 722
696 if (p) { 723 if (p) {
697 dev_info(&pdev->dev, "kept as earlytimer\n"); 724 dev_info(&pdev->dev, "kept as earlytimer\n");