Add support for "wdt disable" command necessary for disabling the watchdog
timer.

Signed-off-by: Lukasz Majewski <lu...@denx.de>
---
 cmd/Kconfig        |  6 ++++++
 cmd/Makefile       |  2 ++
 cmd/wdt.c          | 32 ++++++++++++++++++++++++++++++++
 include/watchdog.h |  2 ++
 4 files changed, 42 insertions(+)
 create mode 100644 cmd/wdt.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index e339d86..293e0bb 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -426,6 +426,12 @@ config CMD_REMOTEPROC
        help
          Support for Remote Processor control
 
+config CMD_WDT
+       bool "wdt"
+       default n
+       help
+         Enables the "wdt" command, which is used to control a watchdog timer.
+
 config CMD_GPIO
        bool "gpio"
        help
diff --git a/cmd/Makefile b/cmd/Makefile
index 9c9a9d1..4934427 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -157,6 +157,8 @@ obj-$(CONFIG_CMD_ETHSW) += ethsw.o
 # Power
 obj-$(CONFIG_CMD_PMIC) += pmic.o
 obj-$(CONFIG_CMD_REGULATOR) += regulator.o
+
+obj-$(CONFIG_CMD_WDT) += wdt.o
 endif # !CONFIG_SPL_BUILD
 
 obj-$(CONFIG_CMD_BLOB) += blob.o
diff --git a/cmd/wdt.c b/cmd/wdt.c
new file mode 100644
index 0000000..aeaa9c2
--- /dev/null
+++ b/cmd/wdt.c
@@ -0,0 +1,32 @@
+/*
+ * wdt.c -- Watchdog support command
+ *
+ * Copyright (C) 2017
+ * Lukasz Majewski, DENX Software Engineering, lu...@denx.de.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <watchdog.h>
+
+static int do_wdt(cmd_tbl_t *cmdtp, int flag, int argc,
+                         char * const argv[])
+{
+       int ret = CMD_RET_SUCCESS;
+
+       if (argc < 2 || argc > 2)
+               return CMD_RET_USAGE;
+
+       if (!strcmp(argv[1], "disable")) {
+               WATCHDOG_DISABLE();
+               printf("WDT disabled\n");
+       }
+
+       return ret;
+}
+
+U_BOOT_CMD(wdt, CONFIG_SYS_MAXARGS, 1, do_wdt,
+       "Watchdog (wdt)",
+       "disable - disable watchdog\n"
+);
diff --git a/include/watchdog.h b/include/watchdog.h
index 174c894..b0716c5 100644
--- a/include/watchdog.h
+++ b/include/watchdog.h
@@ -41,8 +41,10 @@ int init_func_watchdog_reset(void);
                #define WATCHDOG_RESET bl hw_watchdog_reset
        #else
                extern void hw_watchdog_reset(void);
+               void hw_watchdog_disable(void);
 
                #define WATCHDOG_RESET hw_watchdog_reset
+               #define WATCHDOG_DISABLE hw_watchdog_disable
        #endif /* __ASSEMBLY__ */
 #else
        /*
-- 
2.1.4

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/listinfo/u-boot

Reply via email to