summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMarco Felsch <m.felsch@pengutronix.de>2019-11-04 11:28:06 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-11-05 11:09:36 +0100
commitcbfdbf38c190bc9197f85c9633f103cdc15de571 (patch)
tree5756177bdecf7d1d8c49cf42a74a14d4d1c2ee9f /drivers
parent7d3b130af9d282e9a5b788bd44d1ad6528a3bde1 (diff)
downloadbarebox-cbfdbf38c190bc9197f85c9633f103cdc15de571.tar.gz
barebox-cbfdbf38c190bc9197f85c9633f103cdc15de571.tar.xz
mfd: da9063: fix watchdog ping execution
The watchdog resets the system if the watchdog gets pinged to fast. Between each watchdog ping must be a pause of at least 200ms. This commit fixes that by rejecting two fast requests. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mfd/da9063.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/mfd/da9063.c b/drivers/mfd/da9063.c
index 7099c48703..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;
}