Skip to contentSkip to conversation

arm: at91: wdt: Convert watchdog driver to dm/dt

PATCH Superseded Prasanthi Chellakumar 2 participants 3 messages Sep 14, 2018 – Sep 22, 2018

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 arm: at91: wdt: Convert watchdog driver to dm/dt

Convert the Watchdog driver for AT91SAM9x processors to support the driver model and device tree.

---
 arch/arm/mach-at91/include/mach/at91_wdt.h |  12 +++-
 drivers/watchdog/Kconfig                   |   7 ++
 drivers/watchdog/Makefile                  |   2 +-
 drivers/watchdog/at91sam9_wdt.c            | 106 +++++++++++++++++++++--------
 4 files changed, 96 insertions(+), 31 deletions(-)
arch/arm/mach-at91/include/mach/at91_wdt.h +9 -3
index 99b0cc8..df9f131 100644
@@ -4,7 +4,7 @@
  *
  * Copyright (C) 2008 Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
  * Copyright (C) 2007 Andrew Victor
- * Copyright (C) 2007 Atmel Corporation.
+ * Copyright (C) 2018 Microchip Technology Inc.
  *
  * Watchdog Timer (WDT) - System peripherals regsters.
  * Based on AT91SAM9261 datasheet revision D.
@@ -27,15 +27,21 @@ typedef struct at91_wdt {
 
 #endif
 
+/* Watchdog Control Register */
+#define AT91_WDT_CR			0x00
 #define AT91_WDT_CR_WDRSTT		1
 #define AT91_WDT_CR_KEY			0xa5000000	/* KEY Password */
 
-#define AT91_WDT_MR_WDV(x)		(x & 0xfff)
+/* Watchdog Mode Register*/
+#define AT91_WDT_MR			0X04
+#define AT91_WDT_MR_WDV			(0xfff << 0)
+#define		AT91_WDT_MR_SET_WDV(x)		((x) & AT91_WDT_MR_WDV)
 #define AT91_WDT_MR_WDFIEN		0x00001000
 #define AT91_WDT_MR_WDRSTEN		0x00002000
 #define AT91_WDT_MR_WDRPROC		0x00004000
 #define AT91_WDT_MR_WDDIS		0x00008000
-#define AT91_WDT_MR_WDD(x)		((x & 0xfff) << 16)
+#define	AT91_WDT_MR_WDD			(0xfff << 16)
+#define		AT91_WDT_MR_SET_WDD(x)		(((x) << 16) & AT91_WDT_MR_WDD)
 #define AT91_WDT_MR_WDDBGHLT		0x10000000
 #define AT91_WDT_MR_WDIDLEHLT		0x20000000
 
drivers/watchdog/Kconfig +7 -0
index d545b3e..001a8d0 100644
@@ -111,4 +111,11 @@ config XILINX_TB_WATCHDOG
 	   Select this to enable Xilinx Axi watchdog timer, which can be found on some
 	   Xilinx Microblaze Platforms.
 
+config WDT_AT91
+	bool "AT91 watchdog timer support"
+	depends on WDT
+	help
+	   Select this to enable Microchip watchdog timer, which can be found on
+	   some AT91 devices.
+
 endmenu
drivers/watchdog/Makefile +1 -1
index 08406ca..a5c27b0 100644
@@ -3,7 +3,7 @@
 # (C) Copyright 2008
 # Wolfgang Denk, DENX Software Engineering, wd at denx.de.
 
-obj-$(CONFIG_AT91SAM9_WATCHDOG) += at91sam9_wdt.o
+obj-$(CONFIG_WDT_AT91) += 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
drivers/watchdog/at91sam9_wdt.c +79 -27

149 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 2/2 arm: at91: wdt: Convert watchdog config to Kconfig

Convert "CONFIG_AT91SAM9_WATCHDOG" to new "CONFIG_WDT_AT91" Kconfig option to support driver model and device tree.

---
 README                                | 3 ---
 arch/arm/dts/at91sam9260-smartweb.dts | 1 +
 arch/arm/dts/at91sam9g20-taurus.dts   | 1 +
 arch/arm/mach-at91/spl.c              | 2 +-
 arch/arm/mach-at91/spl_at91.c         | 2 +-
 arch/arm/mach-at91/spl_atmel.c        | 2 +-
 common/board_f.c                      | 2 +-
 configs/picosam9g45_defconfig         | 2 ++
 configs/smartweb_defconfig            | 2 ++
 configs/taurus_defconfig              | 2 ++
 doc/README.at91                       | 2 +-
 doc/README.watchdog                   | 2 +-
 include/configs/picosam9g45.h         | 4 ----
 include/configs/smartweb.h            | 7 -------
 include/configs/taurus.h              | 7 -------
 scripts/config_whitelist.txt          | 2 --
 16 files changed, 14 insertions(+), 29 deletions(-)
README +0 -3
index 09822a3..07b2be1 100644
@@ -802,9 +802,6 @@ The following options need to be configured:
 		SoC, then define this variable and provide board
 		specific code for the "hw_watchdog_reset" function.
 
-		CONFIG_AT91_HW_WDT_TIMEOUT
-		specify the timeout in seconds. default 2 seconds.
-
 - Real-Time Clock:
 
 		When CONFIG_CMD_DATE is selected, the type of the RTC
arch/arm/dts/at91sam9260-smartweb.dts +1 -0
index e59781b..a22de2d 100644
@@ -89,6 +89,7 @@
 			};
 
 			watchdog at fffffd40 {
+				timeout-sec = <15>;
 				status = "okay";
 			};
 
arch/arm/dts/at91sam9g20-taurus.dts +1 -0
index 7931c0a..cee228b 100644
@@ -98,6 +98,7 @@
 			};
 
 			watchdog at fffffd40 {
+				timeout-sec = <15>;
 				status = "okay";
 			};
 
arch/arm/mach-at91/spl.c +1 -1
index 8bfb2a4..6da6d41 100644
@@ -11,7 +11,7 @@
 #include <asm/arch/clk.h>
 #include <spl.h>
 
-#if !defined(CONFIG_AT91SAM9_WATCHDOG)
+#if !defined(CONFIG_WDT_AT91)
 void at91_disable_wdt(void)
 {
 	struct at91_wdt *wdt = (struct at91_wdt *)ATMEL_BASE_WDT;
arch/arm/mach-at91/spl_at91.c +1 -1
index 8c36804..23ebaa9 100644
@@ -76,7 +76,7 @@ void __weak spl_board_init(void)
 void board_init_f(ulong dummy)
 {
 	lowlevel_clock_init();
-#if !defined(CONFIG_AT91SAM9_WATCHDOG)
+#if !defined(CONFIG_WDT_AT91)
 	at91_disable_wdt();
 #endif
 
arch/arm/mach-at91/spl_atmel.c +1 -1
index 597ff8c..ef745c9 100644
@@ -98,7 +98,7 @@ void board_init_f(ulong dummy)
 	configure_2nd_sram_as_l2_cache();
 #endif
 
-#if !defined(CONFIG_AT91SAM9_WATCHDOG)
+#if !defined(CONFIG_WDT_AT91)
 	/* disable watchdog */
 	at91_disable_wdt();
 #endif
common/board_f.c +1 -1
index 88d7700..9c0487f 100644
@@ -89,7 +89,7 @@ static int init_func_watchdog_init(void)
 {
 # if defined(CONFIG_HW_WATCHDOG) && \
 	(defined(CONFIG_M68K) || defined(CONFIG_MICROBLAZE) || \
-	defined(CONFIG_SH) || defined(CONFIG_AT91SAM9_WATCHDOG) || \
+	defined(CONFIG_SH) || \
 	defined(CONFIG_DESIGNWARE_WATCHDOG) || \
 	defined(CONFIG_IMX_WATCHDOG))
 	hw_watchdog_init();
configs/picosam9g45_defconfig +2 -0
index 0b6234f..28bb6df 100644
@@ -39,3 +39,5 @@ CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
 CONFIG_LCD=y
 CONFIG_OF_LIBFDT=y
+CONFIG_WDT=y
+CONFIG_WDT_AT91=y
configs/smartweb_defconfig +2 -0
index b0bb18a..0bda9ad 100644
@@ -60,3 +60,5 @@ CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_ETHER_MCS7830=y
 CONFIG_SPL_TINY_MEMSET=y
 # CONFIG_EFI_LOADER is not set
+CONFIG_WDT=y
+CONFIG_WDT_AT91=y
configs/taurus_defconfig +2 -0
index bafd8ab..fc4ac4a 100644
@@ -62,3 +62,5 @@ CONFIG_USB_GADGET_VENDOR_NUM=0x0908
 CONFIG_USB_GADGET_PRODUCT_NUM=0x02d2
 CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_USE_TINY_PRINTF=y
+CONFIG_WDT=y
+CONFIG_WDT_AT91=y
doc/README.at91 +1 -1
index 6741213..39dd563 100644
@@ -171,4 +171,4 @@ III. Watchdog support
 	your code (make sure not to disable it in AT91Bootstrap for instance).
 
 	In the U-Boot configuration, the AT91 watchdog support is enabled using
-	the CONFIG_AT91SAM9_WATCHDOG and CONFIG_HW_WATCHDOG options.
+	the CONFIG_WDT and CONFIG_WDT_AT91 options.
doc/README.watchdog +1 -1
index 7097c87..f23c923 100644
@@ -14,7 +14,7 @@ CONFIG_WATCHDOG_TIMEOUT_MSECS
 	If not given, will default to maximum timeout. This would
 	be 128000 msec for i.mx31/35/5x/6x.
 
-CONFIG_AT91SAM9_WATCHDOG
+CONFIG_WDT_AT91
 	Available for AT91SAM9 to service the watchdog.
 
 CONFIG_FTWDT010_WATCHDOG
include/configs/picosam9g45.h +0 -4
index 0b240e7..c2882e6 100644
@@ -57,10 +57,6 @@
  */
 #define CONFIG_BOOTP_BOOTFILESIZE
 
-/* Enable the watchdog */
-#define CONFIG_AT91SAM9_WATCHDOG
-#define CONFIG_HW_WATCHDOG
-
 /*
  * Command line configuration.
  */
include/configs/smartweb.h +0 -7
index 114b87e..28af575 100644
@@ -112,13 +112,6 @@
 	"root=/dev/nfs ip=dhcp nfsroot=${serverip}:/srv/nfs/rootfs; "	\
 	"dhcp"
 
-/* Enable the watchdog */
-#define CONFIG_AT91SAM9_WATCHDOG
-#if !defined(CONFIG_SPL_BUILD)
-#define CONFIG_HW_WATCHDOG
-#endif
-#define CONFIG_AT91_HW_WDT_TIMEOUT	15
-
 #if !defined(CONFIG_SPL_BUILD)
 /* USB configuration */
 #define CONFIG_USB_ATMEL
include/configs/taurus.h +0 -7
index 4fdb0dd..f283ab7 100644
@@ -85,13 +85,6 @@
 #define CONFIG_RMII
 #define CONFIG_AT91_WANTS_COMMON_PHY
 
-#define CONFIG_AT91SAM9_WATCHDOG
-#define CONFIG_AT91_HW_WDT_TIMEOUT	15
-#if !defined(CONFIG_SPL_BUILD)
-/* Enable the watchdog */
-#define CONFIG_HW_WATCHDOG
-#endif
-
 /* USB */
 #if defined(CONFIG_BOARD_TAURUS)
 #define CONFIG_USB_ATMEL
scripts/config_whitelist.txt +0 -2
index 30c79a6..ee29013 100644
@@ -82,11 +82,9 @@ CONFIG_AT91SAM9G20EK_2MMC
 CONFIG_AT91SAM9G45EKES
 CONFIG_AT91SAM9G45_LCD_BASE
 CONFIG_AT91SAM9M10G45EK
-CONFIG_AT91SAM9_WATCHDOG
 CONFIG_AT91_CAN
 CONFIG_AT91_EFLASH
 CONFIG_AT91_GPIO_PULLUP
-CONFIG_AT91_HW_WDT_TIMEOUT
 CONFIG_AT91_LED
 CONFIG_AT91_WANTS_COMMON_PHY
 CONFIG_ATAPI
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 1/2 arm: at91: wdt: Convert watchdog driver to dm/dt

In reply to Prasanthi Chellakumar

Hi Prasanthi,

Quoted 10 lines

Convert the Watchdog driver for AT91SAM9x processors to support the driver model and device tree.

---
 arch/arm/mach-at91/include/mach/at91_wdt.h |  12 +++-
 drivers/watchdog/Kconfig                   |   7 ++
 drivers/watchdog/Makefile                  |   2 +-
 drivers/watchdog/at91sam9_wdt.c            | 106 +++++++++++++++++++++--------
 4 files changed, 96 insertions(+), 31 deletions(-)

Your patch breaks arm926ejs and atmel.
https://travis-ci.org/pevik/u-boot/builds/430694055

Kind regards,
Petr