watchdog: add sp805 watchdog support
PATCH 1/2 watchdog: add sp805 watchdog support
sp805 is watchdog on some NXP layerscape SoCs, Now add its driver in uboot.
--- MAINTAINERS | 1 + common/board_f.c | 2 +- drivers/watchdog/Kconfig | 8 +++++ drivers/watchdog/Makefile | 1 + drivers/watchdog/sp805_wdt.c | 70 ++++++++++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 drivers/watchdog/sp805_wdt.c
MAINTAINERS +1 -0
@@ -410,6 +410,7 @@ FREESCALE QORIQ M: York Sun <[email protected]> S: Maintained T: git git://git.denx.de/u-boot-fsl-qoriq.git +F: drivers/watchdog/sp805_wdt.c I2C M: Heiko Schocher <[email protected]>
common/board_f.c +1 -1
@@ -91,7 +91,7 @@ static int init_func_watchdog_init(void) (defined (CONFIG_M68K ) ||defined (CONFIG_MICROBLAZE ) || \defined (CONFIG_SH ) ||defined (CONFIG_AT91SAM9_WATCHDOG ) || \defined (CONFIG_DESIGNWARE_WATCHDOG ) || \ - defined(CONFIG_IMX_WATCHDOG)) + defined(CONFIG_IMX_WATCHDOG) || defined(CONFIG_WDT_SP805))hw_watchdog_init ();puts (" Watchdog enabled\n" );# endif
drivers/watchdog/Kconfig +8 -0
@@ -95,6 +95,14 @@ config WDT_ORION Select this to enable Orion watchdog timer, which can be found on some Marvell Armada chips. +config WDT_SP805 + bool "SP805 watchdog timer support" + depends on FSL_LAYERSCAPE + select HW_WATCHDOG + help + Select this to enable SP805 watchdog timer, which can be found on some + nxp layerscape chips. + config WDT_CDNS bool "Cadence watchdog timer support" depends on WDT
drivers/watchdog/Makefile +1 -0
@@ -25,3 +25,4 @@ obj-$(CONFIG_BCM2835_WDT) += bcm2835_wdt.o obj-$(CONFIG_WDT_ORION) += orion_wdt.o obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o obj-$(CONFIG_MPC8xx_WATCHDOG) += mpc8xx_wdt.o +obj-$(CONFIG_WDT_SP805) += sp805_wdt.o
drivers/watchdog/sp805_wdt.c new file +70 -0
70 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 2/2 ls1028a: enable watchdog for ls1028a SoC
--- include/configs/ls1028a_common.h | 2 ++ 1 file changed, 2 insertions(+)
include/configs/ls1028a_common.h +2 -0
@@ -29,6 +29,8 @@#define CONFIG_REMAKE_ELF #define CONFIG_FSL_LAYERSCAPE #define CONFIG_MP +#define CONFIG_WDT_SP805 +#define CONFIG_HW_WATCHDOG #include <asm/arch/stream_id_lsch3.h> #include <asm/arch/config.h>
Signature · 1 line
2.17.1
PATCH 2/2 ls1028a: enable watchdog for ls1028a SoC
Quoted 11 lines · Qiang Zhao
Signed-off-by Zhao Qiang <[email protected]>--- include/configs/ls1028a_common.h | 2 ++ 1 file changed, 2 insertions(+)include/configs/ls1028a_common.h +0
-0
include/configs/ls1028a_common.h line 34
Quoted 6 lines
include/configs/ls1028a_common.h +2
-0@@ -29,6 +29,8 @@#define CONFIG_REMAKE_ELF #define CONFIG_FSL_LAYERSCAPE #define CONFIG_MP +#define CONFIG_WDT_SP805 +#define CONFIG_HW_WATCHDOG
Could you please stop adding ad-hoc CONFIG_XXX in config.h file, instead create Kconfig options, and/or converting driver to DM?
include/configs/ls1028a_common.h line 36
Quoted 2 lines
include/configs/ls1028a_common.h +0
-0#include <asm/arch/stream_id_lsch3.h> #include <asm/arch/config.h>
Regards,
Bin
PATCH 2/2 ls1028a: enable watchdog for ls1028a SoC
In reply to Qiang ZhaoQuoted 10 lines · Qiang Zhao
Signed-off-by Zhao Qiang <[email protected]>--- include/configs/ls1028a_common.h | 2 ++ 1 file changed, 2 insertions(+)include/configs/ls1028a_common.h +0
-0
include/configs/ls1028a_common.h line 33
Quoted 5 lines
include/configs/ls1028a_common.h +2
-0@@ -29,6 +29,8 @@#define CONFIG_REMAKE_ELF #define CONFIG_FSL_LAYERSCAPE #define CONFIG_MP +#define CONFIG_WDT_SP805 +#define CONFIG_HW_WATCHDOG
Please see my last reply. CONFIG_HW_WATCHDOG should not be needed. I plan to work on a patchset to remove this option completely.
And as Bin also mentioned, the CONFIG options should be added to the board defconfig file instead.
Thanks,
Stefan
PATCH 1/2 watchdog: add sp805 watchdog support
In reply to Qiang ZhaoQuoted 29 lines · Qiang Zhao
sp805 is watchdog on some NXP layerscape SoCs, Now add its driver in uboot.
Signed-off-by Zhao Qiang <[email protected]>--- MAINTAINERS | 1 + common/board_f.c | 2 +- drivers/watchdog/Kconfig | 8 +++++ drivers/watchdog/Makefile | 1 + drivers/watchdog/sp805_wdt.c | 70 ++++++++++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+), 1 deletion(-)create mode 100644
drivers/watchdog/sp805_wdt.cMAINTAINERS +1
-0@@ -410,6 +410,7 @@ FREESCALE QORIQ M: York Sun <[email protected]> S: Maintained T: git git://git.denx.de/u-boot-fsl-qoriq.git +F: drivers/watchdog/sp805_wdt.c I2C M: Heiko Schocher <[email protected]>common/board_f.c +0
-0
common/board_f.c static int init_func_watchdog_init(void) · line 97
Quoted 8 lines
common/board_f.c +1
-1@@ -91,7 +91,7 @@ static int init_func_watchdog_init(void) (defined (CONFIG_M68K ) ||defined (CONFIG_MICROBLAZE ) || \defined (CONFIG_SH ) ||defined (CONFIG_AT91SAM9_WATCHDOG ) || \defined (CONFIG_DESIGNWARE_WATCHDOG ) || \ - defined(CONFIG_IMX_WATCHDOG)) + defined(CONFIG_IMX_WATCHDOG) || defined(CONFIG_WDT_SP805))hw_watchdog_init ();puts (" Watchdog enabled\n" );# endif
Please don't add new entries to this deprecated (non DM) watchdog support (see below).
Quoted 95 lines
drivers/watchdog/Kconfig +8
-0@@ -95,6 +95,14 @@ config WDT_ORION Select this to enable Orion watchdog timer, which can be found on some Marvell Armada chips. +config WDT_SP805 + bool "SP805 watchdog timer support" + depends on FSL_LAYERSCAPE + select HW_WATCHDOG + help + Select this to enable SP805 watchdog timer, which can be found on some + nxp layerscape chips. + config WDT_CDNS bool "Cadence watchdog timer support" depends on WDTdrivers/watchdog/Makefile +1
-0@@ -25,3 +25,4 @@ obj-$(CONFIG_BCM2835_WDT) += bcm2835_wdt.o obj-$(CONFIG_WDT_ORION) += orion_wdt.o obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o obj-$(CONFIG_MPC8xx_WATCHDOG) += mpc8xx_wdt.o +obj-$(CONFIG_WDT_SP805) += sp805_wdt.odrivers/watchdog/sp805_wdt.c new file +60
-0@@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Watchdog driver for SP805 on some Layerscape SoC +* +* Copyright 2019 NXP +*/ + +#include <asm/io.h> +#include <common.h> +#include <linux/bitops.h> +#include <watchdog.h> + +#define SP805_WDT_ADDR_BASE 0xc000000 +#define WDTLOAD 0x000 +#define WDTCONTROL 0x008 +#define WDTINTCLR 0x00C +#define WDTLOCK 0xC00 + +#define TIME_OUT_SECS 15 +#define SYS_FSL_WDT_CLK_DIV 16 +#define INT_ENABLE BIT(0) +#define RESET_ENABLE BIT(1) +#define UNLOCK 0x1ACCE551 +#define LOCK 0x00000001 +#define INT_MASK BIT(0) + +DECLARE_GLOBAL_DATA_PTR ; + +void hw_watchdog_reset (void ) +{ +writel (UNLOCK ,SP805_WDT_ADDR_BASE +WDTLOCK ); +writel (INT_MASK ,SP805_WDT_ADDR_BASE +WDTINTCLR ); +writel (LOCK ,SP805_WDT_ADDR_BASE +WDTLOCK ); +readl (SP805_WDT_ADDR_BASE +WDTLOCK ); +} + +void hw_watchdog_init (void ) +{ +u32 load_value; +/* sp805 runs counter with given value twice, so when the timeout is +* set 15s, the gd->bus_clk is less than 9162MHz, the load_value will +* not overflow. +*/ + load_value = (TIME_OUT_SECS /2 ) * (gd->bus_clk /SYS_FSL_WDT_CLK_DIV ); + +writel (UNLOCK ,SP805_WDT_ADDR_BASE +WDTLOCK ); +writel (load_value,SP805_WDT_ADDR_BASE +WDTLOAD ); +writel (INT_MASK ,SP805_WDT_ADDR_BASE +WDTINTCLR ); +writel (INT_ENABLE |RESET_ENABLE ,SP805_WDT_ADDR_BASE +WDTCONTROL ); +writel (LOCK ,SP805_WDT_ADDR_BASE +WDTLOCK ); +readl (SP805_WDT_ADDR_BASE +WDTLOCK ); +} + +static int do_wdt_test (cmd_tbl_t *cmdtp,int flag,int argc, +char *const argv[]) +{ +writel (UNLOCK ,SP805_WDT_ADDR_BASE +WDTLOCK ); +writel (INT_MASK ,SP805_WDT_ADDR_BASE +WDTINTCLR ); +writel (LOCK ,SP805_WDT_ADDR_BASE +WDTLOCK ); +readl (SP805_WDT_ADDR_BASE +WDTLOCK );
drivers/watchdog/sp805_wdt.c line 70
Quoted 10 lines
drivers/watchdog/sp805_wdt.c new file +10
-0+while (1 ) { +/* +* spin to test watchdog +*/ + } +return 0 ; +} + +U_BOOT_CMD (wdt_test,1 ,1 , do_wdt_test,"test watchdog" , +"when run this command, the uboot will reset" );
Please add a DM based watchdog driver instead (should be pretty easy to do). And please take a look at this patch:
http://patchwork.ozlabs.org/patch/1090622/
Once this patch series has been applied, its easy to generally support all DM based watchdog drivers in U-Boot. Either being services or not in U-Boot by selecting CONFIG_WATCHDOG or not.
Thanks,
Stefan