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

Tom Rini trini at konsulko.com
Fri Mar 3 03:18:30 UTC 2017


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 at 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 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"
> +);
> 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.

-- 
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>


More information about the U-Boot mailing list