diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2019-11-07 14:26:42 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-11-07 14:26:42 +0100 |
commit | 047d617c6449da6b17a3b844802bb5e127fef7c3 (patch) | |
tree | 6d28caf8a4f7c155b3406d71a0b5f7c38f844eac /drivers/mfd | |
parent | cd8a909bb3e7af6d905e4b554b10a3bf9718f5c5 (diff) | |
parent | cbfdbf38c190bc9197f85c9633f103cdc15de571 (diff) | |
download | barebox-047d617c6449da6b17a3b844802bb5e127fef7c3.tar.gz barebox-047d617c6449da6b17a3b844802bb5e127fef7c3.tar.xz |
Merge branch 'for-next/watchdog'
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/da9063.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/mfd/da9063.c b/drivers/mfd/da9063.c index b61e764876..e1343bac76 100644 --- a/drivers/mfd/da9063.c +++ b/drivers/mfd/da9063.c @@ -14,6 +14,7 @@ */ #include <common.h> +#include <clock.h> #include <driver.h> #include <gpio.h> #include <restart.h> @@ -33,6 +34,7 @@ struct da9063 { struct i2c_client *client1; struct device_d *dev; unsigned int timeout; + uint64_t last_ping; }; /* forbidden/impossible value; timeout will be set to this value initially to @@ -237,6 +239,14 @@ static int da9063_watchdog_ping(struct da9063 *priv) int ret; u8 val; + /* + * The watchdog has a cool down phase of 200ms and if we ping to fast + * the da9062/3 resets the system. Reject those requests has a maximum + * failure of 10% if the watchdog timeout is set to 2.048s. + */ + if (!is_timeout(priv->last_ping, 200 * MSECOND)) + return 0; + dev_dbg(priv->dev, "ping\n"); /* reset watchdog timer; register is self clearing */ @@ -245,6 +255,8 @@ static int da9063_watchdog_ping(struct da9063 *priv) if (ret < 0) return ret; + priv->last_ping = get_time_ns(); + return 0; } @@ -270,7 +282,7 @@ static int da9063_watchdog_set_timeout(struct watchdog *wd, unsigned timeout) while (timeout > (2048 << scale) && scale <= 6) scale++; dev_dbg(dev, "calculated TWDSCALE=%u (req=%ims calc=%ims)\n", - scale, timeout, 2048 << scale); + scale + 1, timeout, 2048 << scale); scale++; /* scale 0 disables the WD */ } |