Skip to contentSkip to conversation

Xilinx Axi Watchdog driver conversion to driver model

PATCH Superseded Michal Simek 1 participant 5 messages Jul 16, 2018

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Xilinx Axi Watchdog driver conversion to driver model

Hi,

this is moving MB watchdog to DM. I have taken v2 from Shreenidhi and did some changes to speedup upstreaming because I need this for my gpio work. Removing watchdog in the first patch is not big deal because this is generic platform and adresses are fake.

Thanks,
Michal

Changes in v3:
- Fix commit message
- Fix commit message and subject
- Add support for seq aliases
- Fix commit message
- s/Axi/AXI
- Use platdata instead of private data.
- Remove \n from wdt reset to catch logs
- Add debug to wdt_start
- New patch

Changes in v2:
- Added appropriate commit message.
- Moving wdt.h out of ifdef clause
- Using CONFIG_WDT & CONFIG_WATCHDOG based on review comments
- Rectified print message
- Removed stop instruction from probe

Changes in v1:
- Removed reduntant macros.
- Watchdog reset support, inorder to get WATCHDOG_RESET macro working
- Xilinx Axi wdt driver conversion to DM initial version

Michal Simek (1):
microblaze: Enable watchdog via defconfig

Shreenidhi Shedi (3):
microblaze: Delete Xilinx watchdog related macros
microblaze: Support for watchdog_reset in init
watchdog: Convert Xilinx Axi watchdog driver to driver model

 .../xilinx/microblaze-generic/microblaze-generic.c |  47 ++++++++-
 board/xilinx/microblaze-generic/xparameters.h      |   4 -
 configs/microblaze-generic_defconfig               |   2 +
 drivers/watchdog/Kconfig                           |   8 ++
 drivers/watchdog/xilinx_tb_wdt.c                   | 109 ++++++++++++++++-----
 include/configs/microblaze-generic.h               |  10 --
 6 files changed, 137 insertions(+), 43 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v3 1/4 microblaze: Delete Xilinx watchdog related macros

From: Shreenidhi Shedi <[email protected]>

These macros are not required anymore. These will be taken from configuration file.

---

Changes in v3:
- Fix commit message

Changes in v2:
- Added appropriate commit message.

Changes in v1:
- Removed reduntant macros.

 board/xilinx/microblaze-generic/xparameters.h |  4 ----
 include/configs/microblaze-generic.h          | 10 ----------
 2 files changed, 14 deletions(-)
board/xilinx/microblaze-generic/xparameters.h +0 -4
index 57998edba472..01116d827c63 100644
@@ -19,7 +19,3 @@
 /* Flash Memory is FLASH_2Mx32 */
 #define XILINX_FLASH_START	0x2c000000
 #define XILINX_FLASH_SIZE	0x00800000
-
-/* Watchdog IP is wxi_timebase_wdt_0 */
-#define XILINX_WATCHDOG_BASEADDR	0x50000000
-#define XILINX_WATCHDOG_IRQ		1
include/configs/microblaze-generic.h +0 -10
index 7f16700d4f13..6a049cf2af6b 100644
@@ -43,16 +43,6 @@
 # define CONFIG_SYS_GPIO_0_ADDR		XILINX_GPIO_BASEADDR
 #endif
 
-/* watchdog */
-#if defined(XILINX_WATCHDOG_BASEADDR) && defined(XILINX_WATCHDOG_IRQ)
-# define CONFIG_WATCHDOG_BASEADDR	XILINX_WATCHDOG_BASEADDR
-# define CONFIG_WATCHDOG_IRQ		XILINX_WATCHDOG_IRQ
-# ifndef CONFIG_SPL_BUILD
-#  define CONFIG_HW_WATCHDOG
-#  define CONFIG_XILINX_TB_WATCHDOG
-# endif
-#endif
-
 #define CONFIG_SYS_MALLOC_LEN	0xC0000
 
 /* Stack location before relocation */
Signature · 1 line
1.9.1
#2 lore raw

PATCH v3 2/4 microblaze: Support for watchdog_reset in init

In reply to Michal Simek

From: Shreenidhi Shedi <[email protected]>

We should support watchdog reset so that WATCHDOG_RESET will function properly.

---

Changes in v3:
- Fix commit message and subject
- Add support for seq aliases

Changes in v2:
- Moving wdt.h out of ifdef clause
- Using CONFIG_WDT & CONFIG_WATCHDOG based on review comments

Changes in v1:
- Watchdog reset support, inorder to get WATCHDOG_RESET macro working

 .../xilinx/microblaze-generic/microblaze-generic.c | 47 ++++++++++++++++++++--
 1 file changed, 43 insertions(+), 4 deletions(-)
board/xilinx/microblaze-generic/microblaze-generic.c +43 -4
index 9be2cceca705..556d0de7f143 100644
@@ -17,6 +17,8 @@
 #include <asm/microblaze_intc.h>
 #include <asm/asm.h>
 #include <asm/gpio.h>
+#include <dm/uclass.h>
+#include <wdt.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -24,6 +26,10 @@ DECLARE_GLOBAL_DATA_PTR;
 static int reset_pin = -1;
 #endif
 
+#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT)
+static struct udevice *watchdog_dev;
+#endif /* !CONFIG_SPL_BUILD && CONFIG_WDT */
+
 ulong ram_base;
 
 int dram_init_banksize(void)
@@ -68,10 +74,6 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	if (reset_pin != -1)
 		gpio_direction_output(reset_pin, 1);
 #endif
-
-#ifdef CONFIG_XILINX_TB_WATCHDOG
-	hw_watchdog_disable();
-#endif
 #endif
 	puts("Resetting board\n");
 	__asm__ __volatile__ ("	mts rmsr, r0;" \
@@ -91,9 +93,46 @@ static int gpio_init(void)
 	return 0;
 }
 
+#ifdef CONFIG_WDT
+/* Called by macro WATCHDOG_RESET */
+void watchdog_reset(void)
+{
+#if !defined(CONFIG_SPL_BUILD)
+	ulong now;
+	static ulong next_reset;
+
+	if (!watchdog_dev)
+		return;
+
+	now = timer_get_us();
+
+	/* Do not reset the watchdog too often */
+	if (now > next_reset) {
+		wdt_reset(watchdog_dev);
+		next_reset = now + 1000;
+	}
+#endif /* !CONFIG_SPL_BUILD */
+}
+#endif /* CONFIG_WDT */
+
 int board_late_init(void)
 {
 	gpio_init();
 
+#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT)
+	watchdog_dev = NULL;
+
+	if (uclass_get_device_by_seq(UCLASS_WDT, 0, &watchdog_dev)) {
+		debug("Watchdog: Not found by seq!\n");
+		if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) {
+			puts("Watchdog: Not found!\n");
+			return 0;
+		}
+	}
+
+	wdt_start(watchdog_dev, 0, 0);
+	puts("Watchdog: Started\n");
+#endif /* !CONFIG_SPL_BUILD && CONFIG_WDT */
+
 	return 0;
 }
Signature · 1 line
1.9.1
#3 lore raw

PATCH v3 3/4 watchdog: Convert Xilinx Axi watchdog driver to driver model

In reply to Michal Simek

From: Shreenidhi Shedi <[email protected]>

Xilinx Axi wdt driver conversion to driver model & Kconfig update for the same.

---

Changes in v3:
- Fix commit message
- s/Axi/AXI
- Use platdata instead of private data.
- Remove \n from wdt reset to catch logs
- Add debug to wdt_start

Changes in v2:
- Rectified print message
- Removed stop instruction from probe

Changes in v1:
- Xilinx Axi wdt driver conversion to DM initial version

 drivers/watchdog/Kconfig         |   8 +++
 drivers/watchdog/xilinx_tb_wdt.c | 109 ++++++++++++++++++++++++++++++---------
 2 files changed, 92 insertions(+), 25 deletions(-)
drivers/watchdog/Kconfig +8 -0
index 148c6a0d687c..351d2af8d98b 100644
@@ -103,4 +103,12 @@ config WDT_CDNS
 	   Select this to enable Cadence watchdog timer, which can be found on some
 	   Xilinx Microzed Platform.
 
+config XILINX_TB_WATCHDOG
+	bool "Xilinx Axi watchdog timer support"
+	depends on WDT
+	imply WATCHDOG
+	help
+	   Select this to enable Xilinx Axi watchdog timer, which can be found on some
+	   Xilinx Microblaze Platform.
+
 endmenu
drivers/watchdog/xilinx_tb_wdt.c +84 -25

146 lines not on this page · raw message

Signature · 1 line
1.9.1
#4 lore raw

PATCH v3 4/4 microblaze: Enable watchdog via defconfig

In reply to Michal Simek

DM watchdog should be enabled by default.

---

Changes in v3:
- New patch

Changes in v2: None
Changes in v1: None

 configs/microblaze-generic_defconfig | 2 ++
 1 file changed, 2 insertions(+)
configs/microblaze-generic_defconfig +2 -0
index 6ba70223e292..c366a80ed628 100644
@@ -56,3 +56,5 @@ CONFIG_XILINX_AXIEMAC=y
 CONFIG_XILINX_EMACLITE=y
 CONFIG_SYS_NS16550=y
 CONFIG_XILINX_UARTLITE=y
+CONFIG_WDT=y
+CONFIG_XILINX_TB_WATCHDOG=y
Signature · 1 line
1.9.1