clocksource/drivers/sh_cmt: Make sure channel clock supply is enabled
authorGeert Uytterhoeven <geert+renesas@glider.be>
Thu, 10 Dec 2020 19:46:48 +0000 (20:46 +0100)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Mon, 18 Jan 2021 15:20:37 +0000 (16:20 +0100)
commit2a97d55333e4299f32c98cca6dc5c4db1c5855fc
tree3b1b92acc922af054b3184f98e11187c9bbbc590
parent7a3b8758bd6e45f7b671723b5c9fa2b69d0787ae
clocksource/drivers/sh_cmt: Make sure channel clock supply is enabled

The Renesas Compare Match Timer 0 and 1 (CMT0/1) variants have a
register to control the clock supply to the individual channels.
Currently the driver does not touch this register, and relies on the
documented initial value, which has the clock supply enabled for all
channels present.

However, when Linux starts on the APE6-EVM development board, only the
clock supply to the first CMT1 channel is enabled.  Hence the first
channel (used as a clockevent) works, while the second channel (used as
a clocksource) does not.  Note that the default system clocksource is
the Cortex-A15 architectured timer, and the user needs to manually
switch to the CMT1 clocksource to trigger the broken behavior.

Fix this by removing the fragile dependency on implicit reset and/or
boot loader state, and by enabling the clock supply explicitly for all
channels used instead.  This requires postponing the clk_disable() call,
else the timer's registers cannot be accessed in sh_cmt_setup_channel().

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20201210194648.2901899-1-geert+renesas@glider.be
drivers/clocksource/sh_cmt.c