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

Support watchdog driver for layerscape. If you want to use it, please define CONFIG_IMX_WATCHDOG, 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 | 10 ++++++++++ drivers/watchdog/Makefile | 2 +- drivers/watchdog/imx_watchdog.c | 11 +++++++++++ 3 files changed, 22 insertions(+), 1 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..87b91eb 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 +++ b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 @@ -8,3 +8,13 @@ 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 Layerscape. Use following configs to enable it: + #define CONFIG_IMX_WATCHDOG + #define CONFIG_HW_WATCHDOG +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 f405f51..4835b27 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -5,7 +5,7 @@
obj-$(CONFIG_AT91SAM9_WATCHDOG) += at91sam9_wdt.o obj-$(CONFIG_FTWDT010_WATCHDOG) += ftwdt010_wdt.o -ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610)) +ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610 fsl-layerscape)) obj-y += imx_watchdog.o endif obj-$(CONFIG_S5P) += s5p_wdt.o diff --git a/drivers/watchdog/imx_watchdog.c b/drivers/watchdog/imx_watchdog.c index 3f826d1..3ad4e55 100644 --- a/drivers/watchdog/imx_watchdog.c +++ b/drivers/watchdog/imx_watchdog.c @@ -8,6 +8,13 @@ #include <asm/io.h> #include <watchdog.h> #include <asm/arch/imx-regs.h> +#ifdef CONFIG_FSL_LAYERSCAPE +#ifdef CONFIG_FSL_LSCH3 +#include <asm/arch/immap_lsch3.h> +#elif defined(CONFIG_FSL_LSCH2) +#include <asm/arch/immap_lsch2.h> +#endif +#endif #include <fsl_wdog.h>
#ifdef CONFIG_IMX_WATCHDOG @@ -33,8 +40,12 @@ void hw_watchdog_init(void) #define CONFIG_WATCHDOG_TIMEOUT_MSECS 128000 #endif timeout = (CONFIG_WATCHDOG_TIMEOUT_MSECS / 500) - 1; +#ifdef CONFIG_FSL_LAYERSCAPE + 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_LAYERSCAPE*/ 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 | 3 +++ drivers/watchdog/Kconfig | 5 +++++ 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 87b91eb..c43a99b 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 +++ b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 @@ -18,3 +18,6 @@ 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 +Use following config to disable reset watchdog, so that the watchdog will +not be fed in u-boot: + #define CONFIG_WATCHDOG_RESET_DISABLE diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 148c6a0..f9b3035 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -103,4 +103,9 @@ config WDT_CDNS Select this to enable Cadence watchdog timer, which can be found on some Xilinx Microzed Platform.
+config WATCHDOG_RESET_DISABLE + bool "Disable reset watchdog" + help + Disable reset watchdog, which can let WATCHDOG_RESET invalid. + endmenu diff --git a/drivers/watchdog/imx_watchdog.c b/drivers/watchdog/imx_watchdog.c index 3ad4e55..6691ee9 100644 --- a/drivers/watchdog/imx_watchdog.c +++ b/drivers/watchdog/imx_watchdog.c @@ -20,10 +20,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)

On 05/23/2018 12:52 AM, Xiaoliang Yang wrote:
Support watchdog driver for layerscape. If you want to use it, please define CONFIG_IMX_WATCHDOG, 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 | 10 ++++++++++ drivers/watchdog/Makefile | 2 +- drivers/watchdog/imx_watchdog.c | 11 +++++++++++ 3 files changed, 22 insertions(+), 1 deletions(-)
Isn't this the same as you sent two days ago?
York

Hi york,
Yes, I sent it two days ago, but it's failed to send to u-boot list, so I resend it.
Xiaoliang Yang
-----Original Message----- From: York Sun Sent: 2018年5月24日 6:58 To: Xiaoliang Yang xiaoliang.yang_1@nxp.com; u-boot@lists.denx.de Subject: Re: [PATCH 1/2] watchdog: driver support for layerscape
On 05/23/2018 12:52 AM, Xiaoliang Yang wrote:
Support watchdog driver for layerscape. If you want to use it, please define CONFIG_IMX_WATCHDOG, 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 | 10 ++++++++++ drivers/watchdog/Makefile | 2 +- drivers/watchdog/imx_watchdog.c | 11 +++++++++++ 3 files changed, 22 insertions(+), 1 deletions(-)
Isn't this the same as you sent two days ago?
York

On 05/23/2018 12:52 AM, Xiaoliang Yang wrote:
Support watchdog driver for layerscape. If you want to use it, please define CONFIG_IMX_WATCHDOG, 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 | 10 ++++++++++ drivers/watchdog/Makefile | 2 +- drivers/watchdog/imx_watchdog.c | 11 +++++++++++ 3 files changed, 22 insertions(+), 1 deletions(-)
I see compiling error. For example ls2080ardb. Please make sure you test all boards.
York

Thanks York,
This watchdog driver is really not support LSCH3. I'll change the patch like following to build the imx_watchdog.c only in LSCH2 of layerscape, do you think it's appropriate?
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 86cf94b..ea47ccf 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -7,8 +7,12 @@
obj-$(CONFIG_AT91SAM9_WATCHDOG) += at91sam9_wdt.o obj-$(CONFIG_FTWDT010_WATCHDOG) += ftwdt010_wdt.o -ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610 fsl-layerscape)) +ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610)) obj-y += imx_watchdog.o +else +ifdef CONFIG_FSL_LSCH2 +obj-$(CONFIG_IMX_WATCHDOG) += imx_watchdog.o +endif endif
Regards, Xiaoliang Yang
-----Original Message----- From: York Sun Sent: 2018年5月31日 6:12 To: Xiaoliang Yang xiaoliang.yang_1@nxp.com; u-boot@lists.denx.de Subject: Re: [PATCH 1/2] watchdog: driver support for layerscape
On 05/23/2018 12:52 AM, Xiaoliang Yang wrote:
Support watchdog driver for layerscape. If you want to use it, please define CONFIG_IMX_WATCHDOG, 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 | 10 ++++++++++ drivers/watchdog/Makefile | 2 +- drivers/watchdog/imx_watchdog.c | 11 +++++++++++ 3 files changed, 22 insertions(+), 1 deletions(-)
I see compiling error. For example ls2080ardb. Please make sure you test all boards.
York

On 05/31/2018 01:01 AM, Xiaoliang Yang wrote:
Thanks York,
This watchdog driver is really not support LSCH3. I'll change the patch like following to build the imx_watchdog.c only in LSCH2 of layerscape, do you think it's appropriate?
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 86cf94b..ea47ccf 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -7,8 +7,12 @@
obj-$(CONFIG_AT91SAM9_WATCHDOG) += at91sam9_wdt.o obj-$(CONFIG_FTWDT010_WATCHDOG) += ftwdt010_wdt.o -ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610 fsl-layerscape)) +ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610)) obj-y += imx_watchdog.o +else +ifdef CONFIG_FSL_LSCH2 +obj-$(CONFIG_IMX_WATCHDOG) += imx_watchdog.o +endif endif
Why don't move IMX_WATCHDOG to drivers/watchdog/Kconfig and enabled this option for the selected SoCs/platforms?
York

Hi York,
I think it's better not to affect the original i.mx SoCs. If not in i.mx SoCs, we can enable it by define CONFIG_IMX_WATCHDOG in config file. Or do you think it's better to use "select IMX_WATCHDOG" to enable it in default for our LSCH2 SoCs/platforms?
Here is the patch I have changed:
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 86cf94b..ea47ccf 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -7,8 +7,12 @@
obj-$(CONFIG_AT91SAM9_WATCHDOG) += at91sam9_wdt.o obj-$(CONFIG_FTWDT010_WATCHDOG) += ftwdt010_wdt.o -ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610 fsl-layerscape)) +ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610)) obj-y += imx_watchdog.o +else +obj-$(CONFIG_IMX_WATCHDOG) += imx_watchdog.o endif
Regards, Xiaoliang Yang
-----Original Message----- From: York Sun Sent: 2018年6月1日 0:03 To: Xiaoliang Yang xiaoliang.yang_1@nxp.com; u-boot@lists.denx.de Subject: Re: [PATCH 1/2] watchdog: driver support for layerscape
Why don't move IMX_WATCHDOG to drivers/watchdog/Kconfig and enabled this option for the selected SoCs/platforms?
York

On 05/31/2018 08:16 PM, Xiaoliang Yang wrote:
Hi York,
I think it's better not to affect the original i.mx SoCs. If not in i.mx SoCs, we can enable it by define CONFIG_IMX_WATCHDOG in config file. Or do you think it's better to use "select IMX_WATCHDOG" to enable it in default for our LSCH2 SoCs/platforms?
It is a trend to use Kconfig instead of CONFIG_ macros. If you don't convert today, make sure you make it easy to convert.
If you expect this watchdog to be enabled for all LS2 platforms, you can enable it in LS2 config file. Otherwise, only enable it for the platforms you need.
York

Hi York,
Sure, thanks for your suggestion. I'll add IMX_WATCHDOG in Kconfig, users can enable it for the platforms they needed. I will push v2 patch later, please help to review it, thanks.
Regards, Xiaoliang Yang
-----Original Message----- From: York Sun Sent: 2018年6月1日 11:20 To: Xiaoliang Yang xiaoliang.yang_1@nxp.com; u-boot@lists.denx.de Subject: Re: [PATCH 1/2] watchdog: driver support for layerscape
On 05/31/2018 08:16 PM, Xiaoliang Yang wrote:
Hi York,
I think it's better not to affect the original i.mx SoCs. If not in i.mx SoCs, we can enable it by define CONFIG_IMX_WATCHDOG in config file. Or do you think it's better to use "select IMX_WATCHDOG" to enable it in default for our LSCH2 SoCs/platforms?
It is a trend to use Kconfig instead of CONFIG_ macros. If you don't convert today, make sure you make it easy to convert.
If you expect this watchdog to be enabled for all LS2 platforms, you can enable it in LS2 config file. Otherwise, only enable it for the platforms you need.
York
participants (2)
-
Xiaoliang Yang
-
York Sun