Skip to contentSkip to conversation

cmd: wdt: Add "wdt disable" command

PATCH New Lukasz Majewski 2 participants 4 messages Mar 3, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: wdt: Add "wdt disable" command

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

---
 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
cmd/Kconfig +6 -0
index e339d86..293e0bb 100644
@@ -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
cmd/Makefile +2 -0
index 9c9a9d1..4934427 100644
@@ -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
cmd/wdt.c new file +32 -0
new file mode 100644
index 0000000..aeaa9c2
@@ -0,0 +1,32 @@
+/*
+ * wdt.c -- Watchdog support command
+ *
+ * Copyright (C) 2017
+ * Lukasz Majewski, DENX Software Engineering, lukma at 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"
+);
include/watchdog.h +2 -0
index 174c894..b0716c5 100644
@@ -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
 	/*
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 cmd: wdt: Add "wdt disable" command

Quoted 17 lines · Lukasz Majewski

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

---
 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
cmd/Kconfig +0 -0
index e339d86..293e0bb 100644

cmd/Kconfig config CMD_REMOTEPROC · line 431

Quoted 6 lines
cmd/Kconfig +3 -0
@@ -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.

Quoted 62 lines
cmd/Kconfig +3 -0
+	help
+	  Enables the "wdt" command, which is used to control a watchdog timer.
+
 config CMD_GPIO
 	bool "gpio"
 	help
cmd/Makefile +2 -0
index 9c9a9d1..4934427 100644
@@ -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
cmd/wdt.c new file +32 -0
new file mode 100644
index 0000000..aeaa9c2
@@ -0,0 +1,32 @@
+/*
+ * wdt.c -- Watchdog support command
+ *
+ * Copyright (C) 2017
+ * Lukasz Majewski, DENX Software Engineering, lukma at 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"
+);
include/watchdog.h +0 -0
index 174c894..b0716c5 100644

include/watchdog.h int init_func_watchdog_reset(void); · line 50

Quoted 10 lines
include/watchdog.h +2 -0
@@ -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.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170302/1777b312/attachment.sig>
#2 lore raw

PATCH 1/1 cmd: wdt: Add "wdt disable" command

Hi Tom,

Quoted 22 lines · Lukasz Majewski
Quoted 21 lines

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

---
 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
cmd/Kconfig +0 -0
index e339d86..293e0bb 100644
@@ -426,6 +426,12 @@ config CMD_REMOTEPROC
 	help
 	  Support for Remote Processor control
 
Quoted 5 lines

cmd/Kconfig config CMD_REMOTEPROC · line 431

Quoted 3 lines
cmd/Kconfig +3 -0
+config CMD_WDT
+	bool "wdt"
+	default n

No need for default n, that is the default.

Ach... ok.

Quoted 68 lines
Quoted 68 lines
cmd/Kconfig +2 -0
+	help
+	  Enables the "wdt" command, which is used to control a

watchdog timer. +
config CMD_GPIO

cmd/Kconfig +0 -0
 	bool "gpio"
 	help
cmd/Makefile +2 -0
index 9c9a9d1..4934427 100644
@@ -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
cmd/wdt.c new file +32 -0
new file mode 100644
index 0000000..aeaa9c2
@@ -0,0 +1,32 @@
+/*
+ * wdt.c -- Watchdog support command
+ *
+ * Copyright (C) 2017
+ * Lukasz Majewski, DENX Software Engineering, lukma at 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"
+);
include/watchdog.h +1 -0
index 174c894..b0716c5 100644
@@ -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);
 
Quoted 8 lines

include/watchdog.h int init_func_watchdog_reset(void); · line 50

Quoted 5 lines
include/watchdog.h +1 -0
 		#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.

Quoted 4 lines

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 at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170303/88fe80a3/attachment.sig>

#3 lore raw

PATCH 1/1 cmd: wdt: Add "wdt disable" command

Quoted 111 lines · Lukasz Majewski

Hi Tom,

Quoted 22 lines · Lukasz Majewski
Quoted 21 lines

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

---
 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
cmd/Kconfig +0 -0
index e339d86..293e0bb 100644
@@ -426,6 +426,12 @@ config CMD_REMOTEPROC
 	help
 	  Support for Remote Processor control
 
Quoted 5 lines

cmd/Kconfig config CMD_REMOTEPROC · line 431

Quoted 3 lines
cmd/Kconfig +3 -0
+config CMD_WDT
+	bool "wdt"
+	default n

No need for default n, that is the default.

Ach... ok.

Quoted 68 lines
Quoted 68 lines
cmd/Kconfig +2 -0
+	help
+	  Enables the "wdt" command, which is used to control a

watchdog timer. +
config CMD_GPIO

cmd/Kconfig +0 -0
 	bool "gpio"
 	help
cmd/Makefile +2 -0
index 9c9a9d1..4934427 100644
@@ -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
cmd/wdt.c new file +32 -0
new file mode 100644
index 0000000..aeaa9c2
@@ -0,0 +1,32 @@
+/*
+ * wdt.c -- Watchdog support command
+ *
+ * Copyright (C) 2017
+ * Lukasz Majewski, DENX Software Engineering, lukma at 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"
+);
include/watchdog.h +1 -0
index 174c894..b0716c5 100644
@@ -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);
 
Quoted 8 lines

include/watchdog.h int init_func_watchdog_reset(void); · line 50

Quoted 5 lines
include/watchdog.h +1 -0
 		#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.

Quoted 7 lines
Quoted 4 lines

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?

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170303/e6c35300/attachment.sig>