1
0
Fork 0

watchdog: meson: Fix the wrong value of left time

The left time value is wrong when we get it by sysfs. The left time value
should be equal to preset timeout value minus elapsed time value. According
to the Meson-GXB/GXL datasheets which can be found at [0], the timeout value
is saved to BIT[0-15] of the WATCHDOG_TCNT, and elapsed time value is saved
to BIT[16-31] of the WATCHDOG_TCNT.

[0]: http://linux-meson.com

Fixes: 683fa50f0e ("watchdog: Add Meson GXBB Watchdog Driver")
Signed-off-by: Xingyu Chen <xingyu.chen@amlogic.com>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
alistair/sunxi64-5.4-dsi
Xingyu Chen 2019-09-29 18:53:49 +08:00 committed by Wim Van Sebroeck
parent 1993f1d7ca
commit 2c77734642
1 changed files with 2 additions and 2 deletions

View File

@ -89,8 +89,8 @@ static unsigned int meson_gxbb_wdt_get_timeleft(struct watchdog_device *wdt_dev)
reg = readl(data->reg_base + GXBB_WDT_TCNT_REG);
return ((reg >> GXBB_WDT_TCNT_CNT_SHIFT) -
(reg & GXBB_WDT_TCNT_SETUP_MASK)) / 1000;
return ((reg & GXBB_WDT_TCNT_SETUP_MASK) -
(reg >> GXBB_WDT_TCNT_CNT_SHIFT)) / 1000;
}
static const struct watchdog_ops meson_gxbb_wdt_ops = {