clocksource/drivers/sh_cmt: Access registers according to spec
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Wed, 30 Nov 2022 21:06:09 +0000 (22:06 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 1 Dec 2022 10:56:25 +0000 (11:56 +0100)
commit3f44f7156f59cae06e9160eafb5d8b2dfd09e639
treeed1a7e7f2e03fa975d05800307d2122ad0e82001
parentd6c494e8ee932b2b21ff4b718eebb378e91b3da0
clocksource/drivers/sh_cmt: Access registers according to spec

Documentation for most CMTs say that it takes two input clocks before
changes propagate to the timer. This is especially relevant when the timer
is stopped to change further settings.

Implement the delays according to the spec. To avoid unnecessary delays in
atomic mode, also check if the to-be-written value actually differs.

CMCNT is a bit special because testing showed that it requires 3 cycles to
propagate, which affects all CMTs. Also, the WRFLAG needs to be checked
before writing. This fixes "cannot clear CMCNT" messages which occur often
on R-Car Gen4 SoCs, but only very rarely on older SoCs for some reason.

Fixes: 81b3b2711072 ("clocksource: sh_cmt: Add support for multiple channels per device")
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20221130210609.7718-1-wsa+renesas@sang-engineering.com
drivers/clocksource/sh_cmt.c