Skip to contentSkip to conversation

Watchdog: Add support for sunxi hardware watchdog

PATCH New Chris Blake 2 participants 5 messages Sep 4, 2018 – Sep 7, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Watchdog: Add support for sunxi hardware watchdog

The following patches are needed to add support for the hardware watchdog found in most sunxi SoC's.

The patches below have only been tested on a sun50i device (H5 SoC) and work as expected. The actual sunxi_wdt.c was roughly based off of the mainline linux driver, and is enabled by adding CONFIG_SUNXI_WDT to your config. It is not enabled by default.

Chris Blake (2):
watchdog: Fix SPL builds when watchdog is enabled
watchdog: Add sunxi watchdog driver

 common/board_f.c             |   3 +-
 drivers/watchdog/Kconfig     |  18 ++++++++
 drivers/watchdog/Makefile    |   1 +
 drivers/watchdog/sunxi_wdt.c | 103 +++++++++++++++++++++++++++++++++++++++++++
 include/watchdog.h           |   4 +-
 5 files changed, 126 insertions(+), 3 deletions(-)
 create mode 100644 drivers/watchdog/sunxi_wdt.c
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 watchdog: Fix SPL builds when watchdog is enabled

Without this fix, u-boot fails to comple as it tries to load watchdog.h during an SPL build. This breaks support for things such as the sunxi arch.

---
 include/watchdog.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/watchdog.h +2 -2
index 14073cf..555f058 100644
@@ -20,7 +20,7 @@
 int init_func_watchdog_reset(void);
 #endif
 
-#if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
+#if (defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)) && !defined(CONFIG_SPL_BUILD)
 #define INIT_FUNC_WATCHDOG_INIT	init_func_watchdog_init,
 #define INIT_FUNC_WATCHDOG_RESET	init_func_watchdog_reset,
 #else
@@ -47,7 +47,7 @@ int init_func_watchdog_reset(void);
 	/*
 	 * Maybe a software watchdog?
 	 */
-	#if defined(CONFIG_WATCHDOG)
+	#if defined(CONFIG_WATCHDOG) && !defined(CONFIG_SPL_BUILD)
 		#if defined(__ASSEMBLY__)
 			#define WATCHDOG_RESET bl watchdog_reset
 		#else
Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/2 watchdog: Fix SPL builds when watchdog is enabled

Quoted 3 lines · Chris Blake

Without this fix, u-boot fails to comple as it tries to load watchdog.h during an SPL build. This breaks support for things such as the sunxi arch.

I'm not quite clear about the issue, was it a build break or functionality? better to paste the log or elaborate more can helpful.

#3 lore raw

PATCH 2/2 watchdog: Add sunxi watchdog driver

In reply to Chris Blake

Based on the linux mainline driver, this adds support for the hardware watchdog timer found on some sunxi boards.

---
 common/board_f.c             |   3 +-
 drivers/watchdog/Kconfig     |  18 ++++++++
 drivers/watchdog/Makefile    |   1 +
 drivers/watchdog/sunxi_wdt.c | 103 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 124 insertions(+), 1 deletion(-)
 create mode 100644 drivers/watchdog/sunxi_wdt.c
common/board_f.c +2 -1
index 88d7700..7b0d912 100644
@@ -91,7 +91,8 @@ 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_SUNXI_WDT))
 	hw_watchdog_init();
 	puts("       Watchdog enabled\n");
 # endif
drivers/watchdog/Kconfig +18 -0
index d545b3e..bd09dad 100644
@@ -20,6 +20,24 @@ config BCM2835_WDT
 	  This provides basic infrastructure to support BCM2835/2836 watchdog
 	  hardware, with a max timeout of ~15secs.
 
+config SUNXI_WDT
+	bool "SUNXI watchdog timer support"
+	select HW_WATCHDOG
+	help
+	   Select this to enable the SUNXI watchdog timer.
+
+if SUNXI_WDT
+
+config SUNXI_WDT_TIMEOUT
+	int "SUNXI watchdog timeout setting"
+	default 10
+	range 1 16
+	depends on SUNXI_WDT
+	help
+	  Adjust the timeout window for the SUNXI watchdog timer.
+
+endif
+
 config OMAP_WATCHDOG
 	bool "TI OMAP watchdog driver"
 	depends on ARCH_OMAP2PLUS
drivers/watchdog/Makefile +1 -0
index f405f51..ce27bb5 100644
@@ -23,3 +23,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_SUNXI_WDT) += sunxi_wdt.o
drivers/watchdog/sunxi_wdt.c new file +103 -0

103 lines not on this page · raw message

Signature · 1 line
2.7.4
#4 lore raw

PATCH 2/2 watchdog: Add sunxi watchdog driver

Quoted 2 lines · Chris Blake

Based on the linux mainline driver, this adds support for the hardware watchdog timer found on some sunxi boards.

This has to do it via UCLASS_WDT and there is enough sunxi code using watchdog so update the same accordingly.