[U-Boot] [PATCH] cmd: wdt: Add "wdt disable" command

Add support for "wdt disable" command necessary for disabling the watchdog timer.
Signed-off-by: Lukasz Majewski lukma@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, lukma@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 /*

On Fri, Mar 03, 2017 at 01:01:11AM +0100, Lukasz Majewski wrote:
Add support for "wdt disable" command necessary for disabling the watchdog timer.
Signed-off-by: Lukasz Majewski lukma@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
No need for default n, that is the default.
- 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, lukma@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 /*
Can we add other commands, enable (calling _init() or _reset(), I'm not sure which off the top of my head) as well? And we may want to think how to handle that only "omap" and "xilinx_tb" support the _disable function today.

Hi Tom,
On Fri, Mar 03, 2017 at 01:01:11AM +0100, Lukasz Majewski wrote:
Add support for "wdt disable" command necessary for disabling the watchdog timer.
Signed-off-by: Lukasz Majewski lukma@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
No need for default n, that is the default.
Ach... ok.
- 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, lukma@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 /*
Can we add other commands, enable (calling _init() or _reset(), I'm not sure which off the top of my head) as well?
OK, I will think about adding such code.
And we may want to think how to handle that only "omap" and "xilinx_tb" support the _disable function today.
The problem with WDT is that it is a "legacy" code, used by many boards and in many places. We do need to be careful here ....
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de

On Fri, Mar 03, 2017 at 09:46:37AM +0100, Lukasz Majewski wrote:
Hi Tom,
On Fri, Mar 03, 2017 at 01:01:11AM +0100, Lukasz Majewski wrote:
Add support for "wdt disable" command necessary for disabling the watchdog timer.
Signed-off-by: Lukasz Majewski lukma@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
No need for default n, that is the default.
Ach... ok.
- 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, lukma@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 /*
Can we add other commands, enable (calling _init() or _reset(), I'm not sure which off the top of my head) as well?
OK, I will think about adding such code.
And we may want to think how to handle that only "omap" and "xilinx_tb" support the _disable function today.
The problem with WDT is that it is a "legacy" code, used by many boards and in many places. We do need to be careful here ....
Exactly. Perhaps a weak function that just returns error?
participants (2)
-
Lukasz Majewski
-
Tom Rini