Skip to content

Commit b02180e

Browse files
claudiubezneadlezcano
authored andcommitted
clocksource/drivers/timer-microchip-pit64b: Use mchp_pit64b_{suspend, resume}
Use mchp_pit64b_suspend() and mchp_pit64b_resume() to disable or enable timers clocks on init and remove specific clk_prepare_{disable, enable} calls. This is ok also for clockevent timer as proper clock enable, disable is done on .set_state_oneshot, .set_state_periodic, .set_state_shutdown calls. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Link: https://lore.kernel.org/r/20220609094041.1796372-3-claudiu.beznea@microchip.com Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
1 parent 2c9c4c9 commit b02180e

1 file changed

Lines changed: 5 additions & 19 deletions

File tree

drivers/clocksource/timer-microchip-pit64b.c

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ static int __init mchp_pit64b_init_clksrc(struct mchp_pit64b_timer *timer,
344344
if (!cs)
345345
return -ENOMEM;
346346

347+
mchp_pit64b_resume(timer);
347348
mchp_pit64b_reset(timer, ULLONG_MAX, MCHP_PIT64B_MR_CONT, 0);
348349

349350
mchp_pit64b_cs_base = timer->base;
@@ -365,8 +366,7 @@ static int __init mchp_pit64b_init_clksrc(struct mchp_pit64b_timer *timer,
365366
pr_debug("clksrc: Failed to register PIT64B clocksource!\n");
366367

367368
/* Stop timer. */
368-
writel_relaxed(MCHP_PIT64B_CR_SWRST,
369-
timer->base + MCHP_PIT64B_CR);
369+
mchp_pit64b_suspend(timer);
370370
kfree(cs);
371371

372372
return ret;
@@ -450,19 +450,10 @@ static int __init mchp_pit64b_dt_init_timer(struct device_node *node,
450450
if (ret)
451451
goto irq_unmap;
452452

453-
ret = clk_prepare_enable(timer.pclk);
454-
if (ret)
455-
goto irq_unmap;
456-
457-
if (timer.mode & MCHP_PIT64B_MR_SGCLK) {
458-
ret = clk_prepare_enable(timer.gclk);
459-
if (ret)
460-
goto pclk_unprepare;
461-
453+
if (timer.mode & MCHP_PIT64B_MR_SGCLK)
462454
clk_rate = clk_get_rate(timer.gclk);
463-
} else {
455+
else
464456
clk_rate = clk_get_rate(timer.pclk);
465-
}
466457
clk_rate = clk_rate / (MCHP_PIT64B_MODE_TO_PRES(timer.mode) + 1);
467458

468459
if (clkevt)
@@ -471,15 +462,10 @@ static int __init mchp_pit64b_dt_init_timer(struct device_node *node,
471462
ret = mchp_pit64b_init_clksrc(&timer, clk_rate);
472463

473464
if (ret)
474-
goto gclk_unprepare;
465+
goto irq_unmap;
475466

476467
return 0;
477468

478-
gclk_unprepare:
479-
if (timer.mode & MCHP_PIT64B_MR_SGCLK)
480-
clk_disable_unprepare(timer.gclk);
481-
pclk_unprepare:
482-
clk_disable_unprepare(timer.pclk);
483469
irq_unmap:
484470
irq_dispose_mapping(irq);
485471
io_unmap:

0 commit comments

Comments
 (0)