watchdog: Split WDT from SPL_WDT
PATCH v2 1/2 watchdog: Split WDT from SPL_WDT
Use CONFIG_IS_ENABLED(WDT) to permit use of WDT in SPL without DM, while the full U-Boot can use rich DM/DT WDT driver.
---
V2: - Make SPL_WATCHDOG_SUPPORT imply SPL_WDT if !HW_WATCHDOG
- Add SPL_WDT Kconfig entry
--- common/board_r.c | 2 +- common/spl/Kconfig | 1 + common/spl/spl.c | 2 +- drivers/watchdog/Kconfig | 7 +++++++ drivers/watchdog/Makefile | 2 +- include/asm-generic/global_data.h | 2 +- include/wdt.h | 2 +- 7 files changed, 13 insertions(+), 5 deletions(-)
common/board_r.c +1 -1
@@ -678,7 +678,7 @@ static init_fnc_t init_sequence_r[] = {#ifdef CONFIG_DM initr_dm,#endif -#if defined(CONFIG_WDT ) +#if CONFIG_IS_ENABLED (WDT ) initr_watchdog,#endif #if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV) || \
common/spl/Kconfig +1 -0
@@ -876,6 +876,7 @@ endif config SPL_WATCHDOG_SUPPORT bool "Support watchdog drivers" + imply SPL_WDT if !HW_WATCHDOG help Enable support for watchdog drivers in SPL. A watchdog is typically a hardware peripheral which can reset the system when it
common/spl/spl.c +1 -1
@@ -603,7 +603,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)spl_board_init ();#endif -#if defined(CONFIG_SPL_WATCHDOG_SUPPORT ) && defined(CONFIG_WDT ) +#if defined(CONFIG_SPL_WATCHDOG_SUPPORT ) &&CONFIG_IS_ENABLED (WDT )initr_watchdog ();#endif
drivers/watchdog/Kconfig +7 -0
@@ -161,4 +161,11 @@ config WDT_MPC8xx help Select this to enable mpc8xx watchdog timer +config SPL_WDT + bool "Enable driver model for watchdog timer drivers in SPL" + depends on SPL_DM + help + Enable driver model for watchdog timer in SPL. + This is similar to CONFIG_WDT in U-Boot. + endmenu
drivers/watchdog/Makefile +1 -1
@@ -16,7 +16,7 @@ obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o obj-$(CONFIG_DESIGNWARE_WATCHDOG) += designware_wdt.o obj-$(CONFIG_TANGIER_WATCHDOG) += tangier_wdt.o obj-$(CONFIG_ULP_WATCHDOG) += ulp_wdog.o -obj-$(CONFIG_WDT) += wdt-uclass.o +obj-$(CONFIG_$(SPL_TPL_)WDT) += wdt-uclass.o obj-$(CONFIG_WDT_SANDBOX) += sandbox_wdt.o obj-$(CONFIG_WDT_ARMADA_37XX) += armada-37xx-wdt.o obj-$(CONFIG_WDT_ASPEED) += ast_wdt.o
include/asm-generic/global_data.h +1 -1
@@ -137,7 +137,7 @@ typedef struct global_data {#if defined(CONFIG_TRANSLATION_OFFSET )fdt_addr_t translation_offset;/* optional translation offset */ #endif -#if defined(CONFIG_WDT ) +#if CONFIG_IS_ENABLED (WDT )struct udevice *watchdog_dev;#endif } gd_t;
include/wdt.h +1 -1
@@ -106,7 +106,7 @@ struct wdt_ops {int (*expire_now)(struct udevice *dev,ulong flags); }; -#if defined(CONFIG_WDT ) +#if CONFIG_IS_ENABLED (WDT )#ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS #define CONFIG_WATCHDOG_TIMEOUT_MSECS (60 * 1000)#endif
Signature · 1 line
2.20.1
PATCH v2 2/2 watchdog: imx: Add DM support
Add DM and DT probing support to iMX watchdog driver. This should allow boards to move over to this driver, enable SYSRESET_WATCHDOG to handle cpu_reset() if required.
---
V2: No change
--- drivers/watchdog/Kconfig | 2 +- drivers/watchdog/imx_watchdog.c | 119 +++++++++++++++++++++++++++----- 2 files changed, 104 insertions(+), 17 deletions(-)
drivers/watchdog/Kconfig +1 -1
@@ -136,7 +136,7 @@ config XILINX_TB_WATCHDOG config IMX_WATCHDOG bool "Enable Watchdog Timer support for IMX and LSCH2 of NXP" - select HW_WATCHDOG + select HW_WATCHDOG if !WDT help Select this to enable the IMX and LSCH2 of Layerscape watchdog driver.
drivers/watchdog/imx_watchdog.c +103 -16
151 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v2 2/2 watchdog: imx: Add DM support
Hello Marek,
Am 09.06.2019 um 03:46 schrieb Marek Vasut:
Quoted 7 lines
Add DM and DT probing support to iMX watchdog driver. This should allow boards to move over to this driver, enable
SYSRESET_WATCHDOGto handlecpu_reset()if required.Signed-off-by Marek Vasut <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>
Quoted 6 lines
---
V2: No change--- drivers/watchdog/Kconfig | 2 +- drivers/watchdog/imx_watchdog.c | 119 +++++++++++++++++++++++++++----- 2 files changed, 104 insertions(+), 17 deletions(-)
just worked on similiar patch (not ready for mainline) ... patch looks good to me, but I stumbled over a nitpick ...
CONFIG_WATCHDOG_TIMEOUT_MSECS is defined in imx_watchdog to 128000 ms
37 #ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS
38 #define CONFIG_WATCHDOG_TIMEOUT_MSECS 128000
39 #endif
If now using DM approach it is set to 60000 ms, see include/wdt.h
109 #if defined(CONFIG_WDT)
110 #ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS
111 #define CONFIG_WATCHDOG_TIMEOUT_MSECS (60 * 1000)
112 #endif
113 #define WATCHDOG_TIMEOUT_SECS (CONFIG_WATCHDOG_TIMEOUT_MSECS / 1000)
Can you try my patch:
https://github.com/hsdenx/u-boot-test/commit/11503dba89cade8b81ee9d93d503d0bcce868b33
which moves WATCHDOG_TIMEOUT_MSECS to Kconfig ? (Travis build just started, may not mainline ready, also patman
notes in commit messages can now be removed.)
Thanks!
bye,
Heiko
Quoted 173 lines
drivers/watchdog/Kconfig +1
-1@@ -136,7 +136,7 @@ config XILINX_TB_WATCHDOG config IMX_WATCHDOG bool "Enable Watchdog Timer support for IMX and LSCH2 of NXP" - select HW_WATCHDOG + select HW_WATCHDOG if !WDT help Select this to enable the IMX and LSCH2 of Layerscape watchdog driver.drivers/watchdog/imx_watchdog.c +103
-16@@ -5,7 +5,9 @@*/ #include <common.h> +#include <dm.h> #include <asm/io.h> +#include <wdt.h> #include <watchdog.h> #include <asm/arch/imx-regs.h> #ifdef CONFIG_FSL_LSCH2 @@ -13,20 +15,40 @@#endif #include <fsl_wdog.h> -#ifdef CONFIG_IMX_WATCHDOG -void hw_watchdog_reset (void ) +static void imx_watchdog_expire_now (struct watchdog_regs *wdog) +{ +clrsetbits_le16 (&wdog->wcr,WCR_WT_MSK ,WCR_WDE ); + +writew (0x5555 , &wdog->wsr); +writew (0xaaaa , &wdog->wsr);/* load minimum 1/2 second timeout */ +while (1 ) { +/* +* spin for .5 seconds before reset +*/ + } +} + +#if !defined(CONFIG_IMX_WATCHDOG ) || \ + (defined(CONFIG_IMX_WATCHDOG ) && !CONFIG_IS_ENABLED (WDT )) +void __attribute__((weak))reset_cpu (ulong addr) { -#ifndef CONFIG_WATCHDOG_RESET_DISABLE struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR ; +imx_watchdog_expire_now (wdog); +} +#endif + +#if defined(CONFIG_IMX_WATCHDOG ) +static void imx_watchdog_reset (struct watchdog_regs *wdog) +{ +#ifndef CONFIG_WATCHDOG_RESET_DISABLE writew (0x5555 , &wdog->wsr);writew (0xaaaa , &wdog->wsr);#endif /* CONFIG_WATCHDOG_RESET_DISABLE*/ } -void hw_watchdog_init (void ) +static void imx_watchdog_init (struct watchdog_regs *wdog) { -struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR ;u16 timeout;/* @@ -44,21 +66,86 @@ void hw_watchdog_init(void)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(); +imx_watchdog_reset (wdog); } -#endif -void __attribute__((weak))reset_cpu (ulong addr) +#if !CONFIG_IS_ENABLED (WDT ) +void hw_watchdog_reset (void ) {struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR ; -clrsetbits_le16 (&wdog->wcr,WCR_WT_MSK ,WCR_WDE ); +imx_watchdog_reset (wdog); +} -writew (0x5555 , &wdog->wsr); -writew (0xaaaa , &wdog->wsr);/* load minimum 1/2 second timeout */ -while (1 ) { -/* -* spin for .5 seconds before reset -*/ - } +void hw_watchdog_init (void ) +{ +struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR ; + +imx_watchdog_init (wdog); +} +#else +struct imx_wdt_priv { +void __iomem *base; +}; + +static int imx_wdt_reset (struct udevice *dev) +{ +struct imx_wdt_priv *priv =dev_get_priv (dev); + +imx_watchdog_reset (priv->base); + +return 0 ; +} + +static int imx_wdt_expire_now (struct udevice *dev,ulong flags) +{ +struct imx_wdt_priv *priv =dev_get_priv (dev); + +imx_watchdog_expire_now (priv->base); +hang (); + +return 0 ; +} + +static int imx_wdt_start (struct udevice *dev,u64 timeout,ulong flags) +{ +struct imx_wdt_priv *priv =dev_get_priv (dev); + +imx_watchdog_init (priv->base); + +return 0 ; +} + +static int imx_wdt_probe (struct udevice *dev) +{ +struct imx_wdt_priv *priv =dev_get_priv (dev); + + priv->base =dev_read_addr_ptr (dev); +if (!priv->base) +return -ENOENT ; + +return 0 ; } + +static const struct wdt_ops imx_wdt_ops = { + .start = imx_wdt_start, + .reset = imx_wdt_reset, + .expire_now = imx_wdt_expire_now, +}; + +static const struct udevice_id imx_wdt_ids[] = { + { .compatible ="fsl,imx21-wdt" }, + {} +}; + +U_BOOT_DRIVER (imx_wdt) = { + .name ="imx_wdt" , + .id =UCLASS_WDT , + .of_match = imx_wdt_ids, + .probe = imx_wdt_probe, + .ops = &imx_wdt_ops, + .priv_auto_alloc_size =sizeof (struct imx_wdt_priv ), + .flags =DM_FLAG_PRE_RELOC , +}; +#endif +#endif
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH v2 2/2 watchdog: imx: Add DM support
Quoted 34 lines · Heiko Schocher
Hello Marek,
Am 09.06.2019 um 03:46 schrieb Marek Vasut:
Quoted 7 lines
Add DM and DT probing support to iMX watchdog driver. This should allow boards to move over to this driver, enable
SYSRESET_WATCHDOGto handlecpu_reset()if required.Signed-off-by Marek Vasut <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>Quoted 6 lines
---
V2: No change
---
drivers/watchdog/Kconfig | 2 +-drivers/watchdog/imx_watchdog.c| 119 +++++++++++++++++++++++++++-----2 files changed, 104 insertions(+), 17 deletions(-)just worked on similiar patch (not ready for mainline) ... patch looks good to me, but I stumbled over a nitpick ...
CONFIG_WATCHDOG_TIMEOUT_MSECSis defined inimx_watchdogto 128000 ms37 #ifndef
CONFIG_WATCHDOG_TIMEOUT_MSECS
38 #defineCONFIG_WATCHDOG_TIMEOUT_MSECS128000
39 #endifIf now using DM approach it is set to 60000 ms, see
include/wdt.h109 #if
defined(CONFIG_WDT)
110 #ifndefCONFIG_WATCHDOG_TIMEOUT_MSECS
111 #define CONFIG_WATCHDOG_TIMEOUT_MSECS (60 * 1000)
112 #endif
113 #define WATCHDOG_TIMEOUT_SECS (CONFIG_WATCHDOG_TIMEOUT_MSECS/ 1000)
Quoted 7 lines
Can you try my patch:
https://github.com/hsdenx/u-boot-test/commit/11503dba89cade8b81ee9d93d503d0bcce868b33which moves
WATCHDOG_TIMEOUT_MSECStoKconfig? (Travis build just started, may not mainline ready, also patman notes in commit messages can now be removed.)
Looks good to me :)
Signature · 2 lines
Best regards, Marek Vasut
PATCH v2 2/2 watchdog: imx: Add DM support
Hello Marek,
Am 11.06.2019 um 11:55 schrieb Marek Vasut:
Quoted 39 lines · Heiko Schocher
Quoted 38 lines
Hello Marek,
Am 09.06.2019 um 03:46 schrieb Marek Vasut:
Quoted 7 lines
Add DM and DT probing support to iMX watchdog driver. This should allow boards to move over to this driver, enable
SYSRESET_WATCHDOGto handlecpu_reset()if required.Signed-off-by Marek Vasut <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>Quoted 6 lines
---
V2: No change--- drivers/watchdog/Kconfig | 2 +- drivers/watchdog/imx_watchdog.c | 119 +++++++++++++++++++++++++++----- 2 files changed, 104 insertions(+), 17 deletions(-)just worked on similiar patch (not ready for mainline) ... patch looks good to me, but I stumbled over a nitpick ...
CONFIG_WATCHDOG_TIMEOUT_MSECSis defined inimx_watchdogto 128000 ms37 #ifndef
CONFIG_WATCHDOG_TIMEOUT_MSECS
38 #defineCONFIG_WATCHDOG_TIMEOUT_MSECS128000
39 #endifIf now using DM approach it is set to 60000 ms, see
include/wdt.h109 #if
defined(CONFIG_WDT)
110 #ifndefCONFIG_WATCHDOG_TIMEOUT_MSECS
111 #define CONFIG_WATCHDOG_TIMEOUT_MSECS (60 * 1000)
112 #endif
113 #define WATCHDOG_TIMEOUT_SECS (CONFIG_WATCHDOG_TIMEOUT_MSECS/ 1000)Can you try my patch:
https://github.com/hsdenx/u-boot-test/commit/11503dba89cade8b81ee9d93d503d0bcce868b33
Quoted 5 lines
Quoted 3 lines
which moves
WATCHDOG_TIMEOUT_MSECStoKconfig? (Travis build just started, may not mainline ready, also patman
notes in commit messages can now be removed.)Looks good to me :)
Fine, so I rework the commit message and post it.
Thanks!
bye,
Heiko
Signature · 4 lines
-- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH v2 2/2 watchdog: imx: Add DM support
In reply to Marek VasutHello Marek,
Am 09.06.2019 um 03:46 schrieb Marek Vasut:
Quoted 7 lines
Add DM and DT probing support to iMX watchdog driver. This should allow boards to move over to this driver, enable
SYSRESET_WATCHDOGto handlecpu_reset()if required.Signed-off-by Marek Vasut <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>
Quoted 6 lines
---
V2: No change--- drivers/watchdog/Kconfig | 2 +- drivers/watchdog/imx_watchdog.c | 119 +++++++++++++++++++++++++++----- 2 files changed, 104 insertions(+), 17 deletions(-)
Tested on the aristainetos board.
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH v2 2/2 watchdog: imx: Add DM support
In reply to Marek VasutQuoted 7 lines
Add DM and DT probing support to iMX watchdog driver. This should allow boards to move over to this driver, enable
SYSRESET_WATCHDOGto handlecpu_reset()if required.Signed-off-by Marek Vasut <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>Tested-by Heiko Schocher <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v2 1/2 watchdog: Split WDT from SPL_WDT
In reply to Marek VasutHello Marek,
Am 09.06.2019 um 03:46 schrieb Marek Vasut:
Quoted 9 lines
Use
CONFIG_IS_ENABLED(WDT)to permit use of WDT in SPL without DM, while the full U-Boot can use rich DM/DT WDT driver.Signed-off-by Marek Vasut <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>---
V2: - MakeSPL_WATCHDOG_SUPPORTimplySPL_WDTif !HW_WATCHDOG
- AddSPL_WDTKconfigentry
Quoted 9 lines
--- common/board_r.c | 2 +- common/spl/Kconfig | 1 + common/spl/spl.c | 2 +- drivers/watchdog/Kconfig | 7 +++++++ drivers/watchdog/Makefile | 2 +- include/asm-generic/global_data.h | 2 +- include/wdt.h | 2 +- 7 files changed, 13 insertions(+), 5 deletions(-)
Tested on the aristainetos board.
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH v2 1/2 watchdog: Split WDT from SPL_WDT
In reply to Marek VasutHi Marek,
May I know if this patch series is still under review ?
I have converted OMAP3 watchdog driver into driver model for TI AM33XX based SOC and tested corresponding patches on BeagleBone Black board.
Because of SPL size constraints, I have to disable driver model for watchdog in SPL. Some of the changes I have done are in agreement with your work and I thought it would be better to pause until this change set gets accepted(avoiding patch duplication), especially changes in :
common/spl/spl.cdrivers/watchdog/Kconfigdrivers/watchdog/Makefile
These changes are tested on AM335X based BeagleBone Black, and they look good.
Regards
Signature · 6 lines
Suniel Mahesh Embedded Linux, Kernel & U-Boot engineer https://github.com/sunielmahesh www.tuxtrons.com https://github.com/techveda Hyderabad, India
PATCH v2 1/2 watchdog: Split WDT from SPL_WDT
Quoted 3 lines · Suniel Mahesh
Hi Marek,
May I know if this patch series is still under review ?
I guess Stefano is taking them for next ... or ?
Signature · 2 lines
Best regards, Marek Vasut
PATCH v2 1/2 watchdog: Split WDT from SPL_WDT
Quoted 7 lines · Marek Vasut
Quoted 3 lines · Suniel Mahesh
Hi Marek,
May I know if this patch series is still under review ?
I guess Stefano is taking them for next ... or ?
Hi Marek,
Because of this change set applied to u-boot, this patch might not apply, especially changes in common/board_r.c (please verify)
# 84b2416b6a0531a9ad46a4e445e558f183c50171board_r: move initr_watchdog to be called after initr_serial
Reported by: Suniel Mahesh <[email protected]>
Thanks and Regards
Sunil
PATCH v2 1/2 watchdog: Split WDT from SPL_WDT
In reply to Marek VasutQuoted 7 lines · Marek Vasut
Quoted 3 lines · Suniel Mahesh
Hi Marek,
May I know if this patch series is still under review ?
I guess Stefano is taking them for next ... or ?
Hi Marek/Stefano,
Because of this entry "Make SPL_WATCHDOG_SUPPORT imply SPL_WDT if !HW_WATCHDOG", SPL_WDT is getting enabled by default, when board configuration is done.
For AM335X based beaglebone black, we dont need SPL_WDT, as the built image is getting too big to fit into SRAM.
Is it fine if I disable SPL_WDT in board defconfig file ? used the following entry in defconfig # CONFIG_SPL_WDT is not set (couldn't find a proper place to disable it, except in defconfig)
with this the build is fine and board boots.
Tested on the beaglebone black board.
Thanks
Sunil
PATCH v2 1/2 watchdog: Split WDT from SPL_WDT
In reply to Marek VasutQuoted 7 lines
Use
CONFIG_IS_ENABLED(WDT)to permit use of WDT in SPL without DM, while the full U-Boot can use rich DM/DT WDT driver.Signed-off-by Marek Vasut <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>Tested-by Heiko Schocher <[email protected]>Tested-by Suniel Mahesh <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================