diff options
| author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2013-12-14 01:07:32 -0500 |
|---|---|---|
| committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2013-12-18 09:13:50 -0500 |
| commit | 57dee992df244ccce6a6a3a88a43160e285da5d8 (patch) | |
| tree | e49a842874965835a97b77929fc6c455ccc98a4e /drivers/clocksource | |
| parent | dc1ccc48159d63eca5089e507c82c7d22ef60839 (diff) | |
clocksource: sh_cmt: Add clk_prepare/unprepare support
Prepare the clock at probe time, as there is no other appropriate place
in the driver where we're allowed to sleep.
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'drivers/clocksource')
| -rw-r--r-- | drivers/clocksource/sh_cmt.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 0965e9848b3d..940341a185d7 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c | |||
| @@ -634,12 +634,18 @@ static int sh_cmt_clock_event_next(unsigned long delta, | |||
| 634 | 634 | ||
| 635 | static void sh_cmt_clock_event_suspend(struct clock_event_device *ced) | 635 | static void sh_cmt_clock_event_suspend(struct clock_event_device *ced) |
| 636 | { | 636 | { |
| 637 | pm_genpd_syscore_poweroff(&ced_to_sh_cmt(ced)->pdev->dev); | 637 | struct sh_cmt_priv *p = ced_to_sh_cmt(ced); |
| 638 | |||
| 639 | pm_genpd_syscore_poweroff(&p->pdev->dev); | ||
| 640 | clk_unprepare(p->clk); | ||
| 638 | } | 641 | } |
| 639 | 642 | ||
| 640 | static void sh_cmt_clock_event_resume(struct clock_event_device *ced) | 643 | static void sh_cmt_clock_event_resume(struct clock_event_device *ced) |
| 641 | { | 644 | { |
| 642 | pm_genpd_syscore_poweron(&ced_to_sh_cmt(ced)->pdev->dev); | 645 | struct sh_cmt_priv *p = ced_to_sh_cmt(ced); |
| 646 | |||
| 647 | clk_prepare(p->clk); | ||
| 648 | pm_genpd_syscore_poweron(&p->pdev->dev); | ||
| 643 | } | 649 | } |
| 644 | 650 | ||
| 645 | static void sh_cmt_register_clockevent(struct sh_cmt_priv *p, | 651 | static void sh_cmt_register_clockevent(struct sh_cmt_priv *p, |
| @@ -737,6 +743,10 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) | |||
| 737 | goto err2; | 743 | goto err2; |
| 738 | } | 744 | } |
| 739 | 745 | ||
| 746 | ret = clk_prepare(p->clk); | ||
| 747 | if (ret < 0) | ||
| 748 | goto err3; | ||
| 749 | |||
| 740 | if (res2 && (resource_size(res2) == 4)) { | 750 | if (res2 && (resource_size(res2) == 4)) { |
| 741 | /* assume both CMSTR and CMCSR to be 32-bit */ | 751 | /* assume both CMSTR and CMCSR to be 32-bit */ |
| 742 | p->read_control = sh_cmt_read32; | 752 | p->read_control = sh_cmt_read32; |
| @@ -773,19 +783,21 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) | |||
| 773 | cfg->clocksource_rating); | 783 | cfg->clocksource_rating); |
| 774 | if (ret) { | 784 | if (ret) { |
| 775 | dev_err(&p->pdev->dev, "registration failed\n"); | 785 | dev_err(&p->pdev->dev, "registration failed\n"); |
| 776 | goto err3; | 786 | goto err4; |
| 777 | } | 787 | } |
| 778 | p->cs_enabled = false; | 788 | p->cs_enabled = false; |
| 779 | 789 | ||
| 780 | ret = setup_irq(irq, &p->irqaction); | 790 | ret = setup_irq(irq, &p->irqaction); |
| 781 | if (ret) { | 791 | if (ret) { |
| 782 | dev_err(&p->pdev->dev, "failed to request irq %d\n", irq); | 792 | dev_err(&p->pdev->dev, "failed to request irq %d\n", irq); |
| 783 | goto err3; | 793 | goto err4; |
| 784 | } | 794 | } |
| 785 | 795 | ||
| 786 | platform_set_drvdata(pdev, p); | 796 | platform_set_drvdata(pdev, p); |
| 787 | 797 | ||
| 788 | return 0; | 798 | return 0; |
| 799 | err4: | ||
| 800 | clk_unprepare(p->clk); | ||
| 789 | err3: | 801 | err3: |
| 790 | clk_put(p->clk); | 802 | clk_put(p->clk); |
| 791 | err2: | 803 | err2: |
