rtc: pcf2127: support generic watchdog timing configuration
authorHugo Villeneuve <hvilleneuve@dimonoff.com>
Thu, 22 Jun 2023 14:57:57 +0000 (10:57 -0400)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Thu, 27 Jul 2023 20:54:52 +0000 (22:54 +0200)
commitadb9675d74e403537150f025ed2b7a2e1ed0a7b4
treeb88341b2856bb6fede909960a2f5151ea42eaf6b
parent3d715ebaf006bd5a495e9a717cf0fc5c260ee738
rtc: pcf2127: support generic watchdog timing configuration

Introduce in the configuration structure two new values to hold the
watchdog clock source and the min_hw_heartbeat_ms value.

The minimum and maximum timeout values are automatically computed from
the watchdog clock source value for each variant.

The PCF2131 has no 1Hz watchdog clock source, as is the case for
PCF2127/29.

The next best choice is using a 1/4Hz clock, giving a watchdog timeout
range between 4 and 1016s. By using the same register configuration as
for the PCF2127/29, the 1/4Hz clock source is selected.

Note: the PCF2127 datasheet gives a min/max range between 1 and 255s,
but it should be between 2 and 254s, because the watchdog is triggered
when the timer value reaches 1, not 0.

Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Link: https://lore.kernel.org/r/20230622145800.2442116-15-hugo@hugovil.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-pcf2127.c