Commit 57dee992 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Daniel Lezcano

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: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: default avatarSimon Horman <horms+renesas@verge.net.au>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent dc1ccc48
...@@ -634,12 +634,18 @@ static int sh_cmt_clock_event_next(unsigned long delta, ...@@ -634,12 +634,18 @@ static int sh_cmt_clock_event_next(unsigned long delta,
static void sh_cmt_clock_event_suspend(struct clock_event_device *ced) static void sh_cmt_clock_event_suspend(struct clock_event_device *ced)
{ {
pm_genpd_syscore_poweroff(&ced_to_sh_cmt(ced)->pdev->dev); struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
pm_genpd_syscore_poweroff(&p->pdev->dev);
clk_unprepare(p->clk);
} }
static void sh_cmt_clock_event_resume(struct clock_event_device *ced) static void sh_cmt_clock_event_resume(struct clock_event_device *ced)
{ {
pm_genpd_syscore_poweron(&ced_to_sh_cmt(ced)->pdev->dev); struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
clk_prepare(p->clk);
pm_genpd_syscore_poweron(&p->pdev->dev);
} }
static void sh_cmt_register_clockevent(struct sh_cmt_priv *p, 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,6 +743,10 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
goto err2; goto err2;
} }
ret = clk_prepare(p->clk);
if (ret < 0)
goto err3;
if (res2 && (resource_size(res2) == 4)) { if (res2 && (resource_size(res2) == 4)) {
/* assume both CMSTR and CMCSR to be 32-bit */ /* assume both CMSTR and CMCSR to be 32-bit */
p->read_control = sh_cmt_read32; 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,19 +783,21 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
cfg->clocksource_rating); cfg->clocksource_rating);
if (ret) { if (ret) {
dev_err(&p->pdev->dev, "registration failed\n"); dev_err(&p->pdev->dev, "registration failed\n");
goto err3; goto err4;
} }
p->cs_enabled = false; p->cs_enabled = false;
ret = setup_irq(irq, &p->irqaction); ret = setup_irq(irq, &p->irqaction);
if (ret) { if (ret) {
dev_err(&p->pdev->dev, "failed to request irq %d\n", irq); dev_err(&p->pdev->dev, "failed to request irq %d\n", irq);
goto err3; goto err4;
} }
platform_set_drvdata(pdev, p); platform_set_drvdata(pdev, p);
return 0; return 0;
err4:
clk_unprepare(p->clk);
err3: err3:
clk_put(p->clk); clk_put(p->clk);
err2: err2:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment