linux/drivers/clk/ingenic
Aidan MacDonald 6726d552a6 clk: ingenic-tcu: Properly enable registers before accessing timers
Access to registers is guarded by ingenic_tcu_{enable,disable}_regs()
so the stop bit can be cleared before accessing a timer channel, but
those functions did not clear the stop bit on SoCs with a global TCU
clock gate.

Testing on the X1000 has revealed that the stop bits must be cleared
_and_ the global TCU clock must be ungated to access timer registers.
This appears to be the norm on Ingenic SoCs, and is specified in the
documentation for the X1000 and numerous JZ47xx SoCs.

If the stop bit isn't cleared, register writes don't take effect and
the system can be left in a broken state, eg. the watchdog timer may
not run.

The bug probably went unnoticed because stop bits are zeroed when
the SoC is reset, and the kernel does not set them unless a timer
gets disabled at runtime. However, it is possible that a bootloader
or a previous kernel (if using kexec) leaves the stop bits set and
we should not rely on them being cleared.

Fixing this is easy: have ingenic_tcu_{enable,disable}_regs() always
clear the stop bit, regardless of the presence of a global TCU gate.

Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Tested-by: Paul Cercueil <paul@crapouillou.net>
Fixes: 4f89e4b8f1 ("clk: ingenic: Add driver for the TCU clocks")
Cc: stable@vger.kernel.org
Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
Link: https://lore.kernel.org/r/20220617122254.738900-1-aidanmacdonald.0x0@gmail.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
2022-08-31 18:28:20 -07:00
..
cgu.c clk: ingenic: Allow specifying common clock flags 2022-05-18 13:56:16 -07:00
cgu.h clk: ingenic: Allow specifying common clock flags 2022-05-18 13:56:16 -07:00
jz4725b-cgu.c clk: ingenic: Mark critical clocks in Ingenic SoCs 2022-05-18 13:56:22 -07:00
jz4740-cgu.c clk: ingenic: Mark critical clocks in Ingenic SoCs 2022-05-18 13:56:22 -07:00
jz4760-cgu.c clk: ingenic: Mark critical clocks in Ingenic SoCs 2022-05-18 13:56:22 -07:00
jz4770-cgu.c clk: ingenic: Mark critical clocks in Ingenic SoCs 2022-05-18 13:56:22 -07:00
jz4780-cgu.c clk: ingenic: Mark critical clocks in Ingenic SoCs 2022-05-18 13:56:22 -07:00
Kconfig clk: ingenic: Add support for the JZ4760 2021-06-27 19:49:18 -07:00
Makefile clk: ingenic: Add support for the JZ4760 2021-06-27 19:49:18 -07:00
pm.c clk: ingenic: Handle setting the Low-Power Mode bit 2019-06-25 15:43:15 -07:00
pm.h clk: ingenic: Handle setting the Low-Power Mode bit 2019-06-25 15:43:15 -07:00
tcu.c clk: ingenic-tcu: Properly enable registers before accessing timers 2022-08-31 18:28:20 -07:00
x1000-cgu.c clk: ingenic: Mark critical clocks in Ingenic SoCs 2022-05-18 13:56:22 -07:00
x1830-cgu.c clk: ingenic: Mark critical clocks in Ingenic SoCs 2022-05-18 13:56:22 -07:00