summaryrefslogtreecommitdiff
path: root/drivers/watchdog/wdt-uclass.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2019-04-26 20:50:00 +0300
committerTom Rini <trini@konsulko.com>2019-04-26 20:50:00 +0300
commit07b68b7843ad1fa15d63dcd26b5ca5a053fcc27f (patch)
treef9b57804a3f3c57efcb5a17c836396b3b04dbf5f /drivers/watchdog/wdt-uclass.c
parent1c64692df20c1f491ea79de3a732428611bb0ba0 (diff)
parentb684d4031b38b6b6a9e22676c7c6e2770e767cc7 (diff)
downloadu-boot-07b68b7843ad1fa15d63dcd26b5ca5a053fcc27f.tar.xz
Merge git://git.denx.de/u-boot-marvell
- Add DM based generic watchdog start and reset implementation and remove all ad-hoc implementations (Stefan) - Move mv_sdhci to DM (Pierre) - Misc turris_omnia updates (Pierre) - Change openrd targets to correctly build again (size changes and fixes to the dts targets) and bring it back into Travis builds (Stefan) - Add Kirkwood db-88f6281-bp board (Chris)
Diffstat (limited to 'drivers/watchdog/wdt-uclass.c')
-rw-r--r--drivers/watchdog/wdt-uclass.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c
index 23b7e3360d..bbfac4f0f9 100644
--- a/drivers/watchdog/wdt-uclass.c
+++ b/drivers/watchdog/wdt-uclass.c
@@ -10,6 +10,8 @@
#include <dm/device-internal.h>
#include <dm/lists.h>
+DECLARE_GLOBAL_DATA_PTR;
+
int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
{
const struct wdt_ops *ops = device_get_ops(dev);
@@ -63,6 +65,30 @@ int wdt_expire_now(struct udevice *dev, ulong flags)
return ret;
}
+#if defined(CONFIG_WATCHDOG)
+/*
+ * Called by macro WATCHDOG_RESET. This function be called *very* early,
+ * so we need to make sure, that the watchdog driver is ready before using
+ * it in this function.
+ */
+void watchdog_reset(void)
+{
+ static ulong next_reset;
+ ulong now;
+
+ /* Exit if GD is not ready or watchdog is not initialized yet */
+ if (!gd || !(gd->flags & GD_FLG_WDT_READY))
+ return;
+
+ /* Do not reset the watchdog too often */
+ now = get_timer(0);
+ if (now > next_reset) {
+ next_reset = now + 1000; /* reset every 1000ms */
+ wdt_reset(gd->watchdog_dev);
+ }
+}
+#endif
+
static int wdt_post_bind(struct udevice *dev)
{
#if defined(CONFIG_NEEDS_MANUAL_RELOC)