[U-Boot] [PATCH 1/2] watchdog: driver support for fsl-lsch2

Support watchdog driver for fsl-lsch2. If you want to use it, please enable CONFIG_IMX_WATCHDOG, and CONFIG_HW_WATCHDOG. define CONFIG_WATCHDOG_TIMEOUT_MSECS to set watchdog timeout.
Signed-off-by: Xiaoliang Yang xiaoliang.yang_1@nxp.com --- arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 | 9 +++++++++ drivers/watchdog/Makefile | 2 ++ drivers/watchdog/imx_watchdog.c | 7 +++++++ 3 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 index a6ef830..5682fe5 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 +++ b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 @@ -8,3 +8,12 @@ Freescale LayerScape with Chassis Generation 2
This architecture supports Freescale ARMv8 SoCs with Chassis generation 2, for example LS1043A. + +Watchdog support Overview +------------------- +Support watchdog driver for LSCH2. Watchdog driver is disabled in default, +please set CONFIG_IMX_WATCHDOG and CONFIG_HW_WATCHDOG to enable it. +Use following config to set watchdog timeout, if this config is not defined, +the default timeout value is 128s which is the maximum. Set 10 seconds for +example: + #define CONFIG_WATCHDOG_TIMEOUT_MSECS 10000 diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 08406ca..19c631b 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -7,6 +7,8 @@ obj-$(CONFIG_AT91SAM9_WATCHDOG) += at91sam9_wdt.o obj-$(CONFIG_FTWDT010_WATCHDOG) += ftwdt010_wdt.o ifneq (,$(filter $(SOC), mx25 mx31 mx35 mx5 mx6 mx7 vf610)) obj-y += imx_watchdog.o +else +obj-$(CONFIG_IMX_WATCHDOG) += imx_watchdog.o endif obj-$(CONFIG_S5P) += s5p_wdt.o obj-$(CONFIG_XILINX_TB_WATCHDOG) += xilinx_tb_wdt.o diff --git a/drivers/watchdog/imx_watchdog.c b/drivers/watchdog/imx_watchdog.c index 3f826d1..ddcf474 100644 --- a/drivers/watchdog/imx_watchdog.c +++ b/drivers/watchdog/imx_watchdog.c @@ -8,6 +8,9 @@ #include <asm/io.h> #include <watchdog.h> #include <asm/arch/imx-regs.h> +#ifdef CONFIG_FSL_LSCH2 +#include <asm/arch/immap_lsch2.h> +#endif #include <fsl_wdog.h>
#ifdef CONFIG_IMX_WATCHDOG @@ -33,8 +36,12 @@ void hw_watchdog_init(void) #define CONFIG_WATCHDOG_TIMEOUT_MSECS 128000 #endif timeout = (CONFIG_WATCHDOG_TIMEOUT_MSECS / 500) - 1; +#ifdef CONFIG_FSL_LSCH2 + writew((WCR_WDA | WCR_SRS | WCR_WDE) << 8 | timeout, &wdog->wcr); +#else writew(WCR_WDZST | WCR_WDBG | WCR_WDE | WCR_WDT | WCR_SRS | WCR_WDA | SET_WCR_WT(timeout), &wdog->wcr); +#endif /* CONFIG_FSL_LSCH2*/ hw_watchdog_reset(); } #endif

Add Kconfig support for CONFIG_WATCHDOG_RESET_DISABLE, use this config to disable watchdog reset in imx_watchdog driver, so that the watchdog will not be fed in u-boot.
Signed-off-by: Xiaoliang Yang xiaoliang.yang_1@nxp.com --- arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 | 2 ++ drivers/watchdog/Kconfig | 6 ++++++ drivers/watchdog/imx_watchdog.c | 2 ++ 3 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 index 5682fe5..0357249 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 +++ b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 @@ -17,3 +17,5 @@ Use following config to set watchdog timeout, if this config is not defined, the default timeout value is 128s which is the maximum. Set 10 seconds for example: #define CONFIG_WATCHDOG_TIMEOUT_MSECS 10000 +Set CONFIG_WATCHDOG_RESET_DISABLE to disable reset watchdog, so that the +watchdog will not be fed in u-boot. diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index d545b3e..b06c544 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -111,4 +111,10 @@ config XILINX_TB_WATCHDOG Select this to enable Xilinx Axi watchdog timer, which can be found on some Xilinx Microblaze Platforms.
+config WATCHDOG_RESET_DISABLE + bool "Disable reset watchdog" + help + Disable reset watchdog, which can let WATCHDOG_RESET invalid, so + that the watchdog will not be fed in u-boot. + endmenu diff --git a/drivers/watchdog/imx_watchdog.c b/drivers/watchdog/imx_watchdog.c index ddcf474..14cc618 100644 --- a/drivers/watchdog/imx_watchdog.c +++ b/drivers/watchdog/imx_watchdog.c @@ -16,10 +16,12 @@ #ifdef CONFIG_IMX_WATCHDOG void hw_watchdog_reset(void) { +#ifndef CONFIG_WATCHDOG_RESET_DISABLE struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;
writew(0x5555, &wdog->wsr); writew(0xaaaa, &wdog->wsr); +#endif /* CONFIG_WATCHDOG_RESET_DISABLE*/ }
void hw_watchdog_init(void)

Hi York,
The old version of this patch is: http://patchwork.ozlabs.org/patch/918957/ There is a little mistake about LSCH3 not support for imx-watchdog in old version patch, I have fixed it. If there is a need to rewrite CONFIG_IMX_WATCHDOG to Kconfig file, I will pull a new patch to do this. It doesn't affect this patch.
Regards, Xiaoliang Yang
-----Original Message----- From: Xiaoliang Yang xiaoliang.yang_1@nxp.com Sent: 2018年10月17日 10:54 To: Xiaoliang Yang xiaoliang.yang_1@nxp.com; York Sun york.sun@nxp.com; u-boot@lists.denx.de Subject: [PATCH 1/2] watchdog: driver support for fsl-lsch2
Support watchdog driver for fsl-lsch2. If you want to use it, please enable CONFIG_IMX_WATCHDOG, and CONFIG_HW_WATCHDOG. define CONFIG_WATCHDOG_TIMEOUT_MSECS to set watchdog timeout.
Signed-off-by: Xiaoliang Yang xiaoliang.yang_1@nxp.com --- arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 | 9 +++++++++ drivers/watchdog/Makefile | 2 ++ drivers/watchdog/imx_watchdog.c | 7 +++++++ 3 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 index a6ef830..5682fe5 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 +++ b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 @@ -8,3 +8,12 @@ Freescale LayerScape with Chassis Generation 2
This architecture supports Freescale ARMv8 SoCs with Chassis generation 2, for example LS1043A. + +Watchdog support Overview +------------------- +Support watchdog driver for LSCH2. Watchdog driver is disabled in +default, please set CONFIG_IMX_WATCHDOG and CONFIG_HW_WATCHDOG to enable it. +Use following config to set watchdog timeout, if this config is not +defined, the default timeout value is 128s which is the maximum. Set 10 +seconds for +example: + #define CONFIG_WATCHDOG_TIMEOUT_MSECS 10000 diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 08406ca..19c631b 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -7,6 +7,8 @@ obj-$(CONFIG_AT91SAM9_WATCHDOG) += at91sam9_wdt.o obj-$(CONFIG_FTWDT010_WATCHDOG) += ftwdt010_wdt.o ifneq (,$(filter $(SOC), mx25 mx31 mx35 mx5 mx6 mx7 vf610)) obj-y += imx_watchdog.o +else +obj-$(CONFIG_IMX_WATCHDOG) += imx_watchdog.o endif obj-$(CONFIG_S5P) += s5p_wdt.o obj-$(CONFIG_XILINX_TB_WATCHDOG) += xilinx_tb_wdt.o diff --git a/drivers/watchdog/imx_watchdog.c b/drivers/watchdog/imx_watchdog.c index 3f826d1..ddcf474 100644 --- a/drivers/watchdog/imx_watchdog.c +++ b/drivers/watchdog/imx_watchdog.c @@ -8,6 +8,9 @@ #include <asm/io.h> #include <watchdog.h> #include <asm/arch/imx-regs.h> +#ifdef CONFIG_FSL_LSCH2 +#include <asm/arch/immap_lsch2.h> +#endif #include <fsl_wdog.h>
#ifdef CONFIG_IMX_WATCHDOG @@ -33,8 +36,12 @@ void hw_watchdog_init(void) #define CONFIG_WATCHDOG_TIMEOUT_MSECS 128000 #endif timeout = (CONFIG_WATCHDOG_TIMEOUT_MSECS / 500) - 1; +#ifdef CONFIG_FSL_LSCH2 + writew((WCR_WDA | WCR_SRS | WCR_WDE) << 8 | timeout, &wdog->wcr); +#else writew(WCR_WDZST | WCR_WDBG | WCR_WDE | WCR_WDT | WCR_SRS | WCR_WDA | SET_WCR_WT(timeout), &wdog->wcr); +#endif /* CONFIG_FSL_LSCH2*/ hw_watchdog_reset(); } #endif -- 1.7.1

On 10/16/18 20:06, Xiaoliang Yang wrote:
Hi York,
The old version of this patch is: http://patchwork.ozlabs.org/patch/918957/ There is a little mistake about LSCH3 not support for imx-watchdog in old version patch, I have fixed it. If there is a need to rewrite CONFIG_IMX_WATCHDOG to Kconfig file, I will pull a new patch to do this. It doesn't affect this patch.
Let's focus on this version. I see you are targeting lsch2. What you should have done was to update the revision number and add change log.
York
participants (2)
-
Xiaoliang Yang
-
York Sun