All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v1 0/6] This patch series contains the the changes related to
@ 2018-06-29 21:51 Shreenidhi Shedi
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 1/6] microblaze: Use default implementation from include/linux/io.h Shreenidhi Shedi
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Shreenidhi Shedi @ 2018-06-29 21:51 UTC (permalink / raw)
  To: u-boot

Xilinx Axi Watchdog driver conversion to driver model.
All other changes are necessary for getting this done.

[PATCH 1/6] We no more need redundant io related macros
[PATCH 2/6] Guard the board specific do_reset based on configuartions
[PATCH 3/6] Cosmetic changes, based on checkpatch results
[PATCH 4/6] Removed a bunch of WATCHDOG related macros
[PATCH 5/6] Support for watchdog_reset function for Microblaze
[PATCH 6/6] Last one, contains the Xilinx Axi watchdog driver to DM

Changes in v1:
- Removed few macros which aren't needed anymore
- Few cosmetic changes
- Converted Xilinx Axi Watchdog driver to driver model

Shreenidhi Shedi (6):
  microblaze: Use default implementation from include/linux/io.h
  microblaze: Guard do_reset by CONFIG_SYSRESET
  microblaze: Cosmetic changes in Microblaze related files
  microblaze: Delete Xilinx watchdog related macros
  microblaze: Support for watchdog_reset in Microblaze init
  watchdog: Convert Xilinx Axi watchdog driver to driver model

 arch/microblaze/include/asm/io.h              |  95 +++++++++-------
 .../microblaze-generic/microblaze-generic.c   |  53 +++++++--
 board/xilinx/microblaze-generic/xparameters.h |   8 +-
 drivers/watchdog/Kconfig                      |   8 ++
 drivers/watchdog/xilinx_tb_wdt.c              | 107 ++++++++++++++----
 include/configs/microblaze-generic.h          |  12 +-
 6 files changed, 193 insertions(+), 90 deletions(-)

--
2.17.1

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v1 1/6] microblaze: Use default implementation from include/linux/io.h
  2018-06-29 21:51 [U-Boot] [PATCH v1 0/6] This patch series contains the the changes related to Shreenidhi Shedi
@ 2018-06-29 21:51 ` Shreenidhi Shedi
  2018-07-11  8:12   ` Michal Simek
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 2/6] microblaze: Guard do_reset by CONFIG_SYSRESET Shreenidhi Shedi
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Shreenidhi Shedi @ 2018-06-29 21:51 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
---

Changes in v1:
- Removed few macros which aren't needed anymore
- Few cosmetic changes
- Converted Xilinx Axi Watchdog driver to driver model

 arch/microblaze/include/asm/io.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/microblaze/include/asm/io.h b/arch/microblaze/include/asm/io.h
index c7516a47e8..26a437c248 100644
--- a/arch/microblaze/include/asm/io.h
+++ b/arch/microblaze/include/asm/io.h
@@ -120,9 +120,6 @@ io_outsl (unsigned long port, const void *src, unsigned long count)
 #define insw(a,b,l) io_insw(a,b,l)
 #define insl(a,b,l) io_insl(a,b,l)
 
-
-#define iounmap(addr)				((void)0)
-#define ioremap(physaddr, size)			(physaddr)
 #define ioremap_nocache(physaddr, size)		(physaddr)
 #define ioremap_writethrough(physaddr, size)	(physaddr)
 #define ioremap_fullcache(physaddr, size)	(physaddr)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v1 2/6] microblaze: Guard do_reset by CONFIG_SYSRESET
  2018-06-29 21:51 [U-Boot] [PATCH v1 0/6] This patch series contains the the changes related to Shreenidhi Shedi
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 1/6] microblaze: Use default implementation from include/linux/io.h Shreenidhi Shedi
@ 2018-06-29 21:51 ` Shreenidhi Shedi
  2018-07-11  8:13   ` Michal Simek
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 3/6] microblaze: Cosmetic changes in Microblaze related files Shreenidhi Shedi
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Shreenidhi Shedi @ 2018-06-29 21:51 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
---

Changes in v1: None

 board/xilinx/microblaze-generic/microblaze-generic.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/board/xilinx/microblaze-generic/microblaze-generic.c b/board/xilinx/microblaze-generic/microblaze-generic.c
index 58ca1d715d..fb89276c4f 100644
--- a/board/xilinx/microblaze-generic/microblaze-generic.c
+++ b/board/xilinx/microblaze-generic/microblaze-generic.c
@@ -58,6 +58,7 @@ int dram_init(void)
 	return 0;
 };
 
+#if !defined(CONFIG_SYSRESET) || defined(CONFIG_SPL_BUILD)
 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 #ifndef CONFIG_SPL_BUILD
@@ -76,6 +77,7 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	return 0;
 }
+#endif /* !CONFIG_SYSRESET || CONFIG_SPL_BUILD */
 
 static int gpio_init(void)
 {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v1 3/6] microblaze: Cosmetic changes in Microblaze related files
  2018-06-29 21:51 [U-Boot] [PATCH v1 0/6] This patch series contains the the changes related to Shreenidhi Shedi
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 1/6] microblaze: Use default implementation from include/linux/io.h Shreenidhi Shedi
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 2/6] microblaze: Guard do_reset by CONFIG_SYSRESET Shreenidhi Shedi
@ 2018-06-29 21:51 ` Shreenidhi Shedi
  2018-07-11  8:14   ` Michal Simek
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 4/6] microblaze: Delete Xilinx watchdog related macros Shreenidhi Shedi
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Shreenidhi Shedi @ 2018-06-29 21:51 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
---

Changes in v1: None

 arch/microblaze/include/asm/io.h              | 92 +++++++++++--------
 .../microblaze-generic/microblaze-generic.c   |  8 +-
 board/xilinx/microblaze-generic/xparameters.h |  4 +-
 include/configs/microblaze-generic.h          |  2 +-
 4 files changed, 61 insertions(+), 45 deletions(-)

diff --git a/arch/microblaze/include/asm/io.h b/arch/microblaze/include/asm/io.h
index 26a437c248..2de3c3b6a3 100644
--- a/arch/microblaze/include/asm/io.h
+++ b/arch/microblaze/include/asm/io.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * include/asm-microblaze/io.h -- Misc I/O operations
  *
@@ -21,39 +22,42 @@
 #define IO_SPACE_LIMIT 0xFFFFFFFF
 
 #define readb(addr) \
-  ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
+	({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
+
 #define readw(addr) \
-  ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
+	({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
+
 #define readl(addr) \
 	({ unsigned int __v = (*(volatile unsigned int *) (addr)); __v; })
 
 #define writeb(b, addr) \
-  (void)((*(volatile unsigned char *) (addr)) = (b))
+	(void)((*(volatile unsigned char *) (addr)) = (b))
+
 #define writew(b, addr) \
-  (void)((*(volatile unsigned short *) (addr)) = (b))
+	(void)((*(volatile unsigned short *) (addr)) = (b))
+
 #define writel(b, addr) \
-  (void)((*(volatile unsigned int *) (addr)) = (b))
+	(void)((*(volatile unsigned int *) (addr)) = (b))
 
-#define memset_io(a,b,c)        memset((void *)(a),(b),(c))
-#define memcpy_fromio(a,b,c)    memcpy((a),(void *)(b),(c))
-#define memcpy_toio(a,b,c)      memcpy((void *)(a),(b),(c))
+#define memset_io(a, b, c)        memset((void *)(a), (b), (c))
+#define memcpy_fromio(a, b, c)    memcpy((a), (void *)(b), (c))
+#define memcpy_toio(a, b, c)      memcpy((void *)(a), (b), (c))
 
-#define inb(addr)	readb (addr)
-#define inw(addr)	readw (addr)
-#define inl(addr)	readl (addr)
-#define outb(x, addr)	((void) writeb (x, addr))
-#define outw(x, addr)	((void) writew (x, addr))
-#define outl(x, addr)	((void) writel (x, addr))
+#define inb(addr)	readb(addr)
+#define inw(addr)	readw(addr)
+#define inl(addr)	readl(addr)
+#define outb(x, addr)	((void)writeb(x, addr))
+#define outw(x, addr)	((void)writew(x, addr))
+#define outl(x, addr)	((void)writel(x, addr))
 
 /* Some #definitions to keep strange Xilinx code happy */
-#define in_8(addr)	readb (addr)
-#define in_be16(addr)	readw (addr)
-#define in_be32(addr)	readl (addr)
-
-#define out_8(addr,x )	outb (x,addr)
-#define out_be16(addr,x )	outw (x,addr)
-#define out_be32(addr,x )	outl (x,addr)
+#define in_8(addr)	readb(addr)
+#define in_be16(addr)	readw(addr)
+#define in_be32(addr)	readl(addr)
 
+#define out_8(addr, x)		outb(x, addr)
+#define out_be16(addr, x)	outw(x, addr)
+#define out_be32(addr, x)	outl(x, addr)
 
 #define inb_p(port)		inb((port))
 #define outb_p(val, port)	outb((val), (port))
@@ -71,54 +75,64 @@
 #define __raw_writew writew
 #define __raw_writel writel
 
-static inline void io_insb (unsigned long port, void *dst, unsigned long count)
+static inline void io_insb(unsigned long port, void *dst, unsigned long count)
 {
 	unsigned char *p = dst;
+
 	while (count--)
-		*p++ = inb (port);
+		*p++ = inb(port);
 }
-static inline void io_insw (unsigned long port, void *dst, unsigned long count)
+
+static inline void io_insw(unsigned long port, void *dst, unsigned long count)
 {
 	unsigned short *p = dst;
+
 	while (count--)
-		*p++ = inw (port);
+		*p++ = inw(port);
 }
-static inline void io_insl (unsigned long port, void *dst, unsigned long count)
+
+static inline void io_insl(unsigned long port, void *dst, unsigned long count)
 {
 	unsigned long *p = dst;
+
 	while (count--)
-		*p++ = inl (port);
+		*p++ = inl(port);
 }
 
 static inline void
-io_outsb (unsigned long port, const void *src, unsigned long count)
+io_outsb(unsigned long port, const void *src, unsigned long count)
 {
 	const unsigned char *p = src;
+
 	while (count--)
-		outb (*p++, port);
+		outb(*p++, port);
 }
+
 static inline void
-io_outsw (unsigned long port, const void *src, unsigned long count)
+io_outsw(unsigned long port, const void *src, unsigned long count)
 {
 	const unsigned short *p = src;
+
 	while (count--)
-		outw (*p++, port);
+		outw(*p++, port);
 }
+
 static inline void
-io_outsl (unsigned long port, const void *src, unsigned long count)
+io_outsl(unsigned long port, const void *src, unsigned long count)
 {
 	const unsigned long *p = src;
+
 	while (count--)
-		outl (*p++, port);
+		outl(*p++, port);
 }
 
-#define outsb(a,b,l) io_outsb(a,b,l)
-#define outsw(a,b,l) io_outsw(a,b,l)
-#define outsl(a,b,l) io_outsl(a,b,l)
+#define outsb(a, b, l) io_outsb(a, b, l)
+#define outsw(a, b, l) io_outsw(a, b, l)
+#define outsl(a, b, l) io_outsl(a, b, l)
 
-#define insb(a,b,l) io_insb(a,b,l)
-#define insw(a,b,l) io_insw(a,b,l)
-#define insl(a,b,l) io_insl(a,b,l)
+#define insb(a, b, l) io_insb(a, b, l)
+#define insw(a, b, l) io_insw(a, b, l)
+#define insl(a, b, l) io_insl(a, b, l)
 
 #define ioremap_nocache(physaddr, size)		(physaddr)
 #define ioremap_writethrough(physaddr, size)	(physaddr)
diff --git a/board/xilinx/microblaze-generic/microblaze-generic.c b/board/xilinx/microblaze-generic/microblaze-generic.c
index fb89276c4f..7d8f247fa9 100644
--- a/board/xilinx/microblaze-generic/microblaze-generic.c
+++ b/board/xilinx/microblaze-generic/microblaze-generic.c
@@ -5,8 +5,10 @@
  * Michal  SIMEK <monstr@monstr.eu>
  */
 
-/* This is a board specific file.  It's OK to include board specific
- * header files */
+/*
+ * This is a board specific file.  It's OK to include board specific
+ * header files
+ */
 
 #include <common.h>
 #include <config.h>
@@ -71,7 +73,7 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	hw_watchdog_disable();
 #endif
 #endif
-	puts ("Reseting board\n");
+	puts("Resetting board\n");
 	__asm__ __volatile__ ("	mts rmsr, r0;" \
 				"bra r0");
 
diff --git a/board/xilinx/microblaze-generic/xparameters.h b/board/xilinx/microblaze-generic/xparameters.h
index 51bca40e34..501a23454d 100644
--- a/board/xilinx/microblaze-generic/xparameters.h
+++ b/board/xilinx/microblaze-generic/xparameters.h
@@ -10,7 +10,7 @@
  *          the generated file from your Xilinx design flow.
  */
 
-#define XILINX_BOARD_NAME	microblaze-generic
+#define XILINX_BOARD_NAME	"microblaze-generic"
 
 /* Microblaze is microblaze_0 */
 #define XILINX_FSL_NUMBER	3
@@ -19,7 +19,7 @@
 #define XILINX_GPIO_BASEADDR	0x40000000
 
 /* Flash Memory is FLASH_2Mx32 */
-#define XILINX_FLASH_START	0x2c000000
+#define XILINX_FLASH_START	0x2C000000
 #define XILINX_FLASH_SIZE	0x00800000
 
 /* Watchdog IP is wxi_timebase_wdt_0 */
diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h
index 966feeeafd..7f16700d4f 100644
--- a/include/configs/microblaze-generic.h
+++ b/include/configs/microblaze-generic.h
@@ -217,7 +217,7 @@
 
 #define CONFIG_SYS_FDT_BASE		(CONFIG_SYS_FLASH_BASE + \
 					 0x40000)
-#define CONFIG_SYS_FDT_SIZE		(16<<10)
+#define CONFIG_SYS_FDT_SIZE		(16 << 10)
 #define CONFIG_SYS_SPL_ARGS_ADDR	(CONFIG_SYS_TEXT_BASE + \
 					 0x1000000)
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v1 4/6] microblaze: Delete Xilinx watchdog related macros
  2018-06-29 21:51 [U-Boot] [PATCH v1 0/6] This patch series contains the the changes related to Shreenidhi Shedi
                   ` (2 preceding siblings ...)
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 3/6] microblaze: Cosmetic changes in Microblaze related files Shreenidhi Shedi
@ 2018-06-29 21:51 ` Shreenidhi Shedi
  2018-07-11  8:15   ` Michal Simek
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 5/6] microblaze: Support for watchdog_reset in Microblaze init Shreenidhi Shedi
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 6/6] watchdog: Convert Xilinx Axi watchdog driver to driver model Shreenidhi Shedi
  5 siblings, 1 reply; 13+ messages in thread
From: Shreenidhi Shedi @ 2018-06-29 21:51 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
---

Changes in v1: None

 board/xilinx/microblaze-generic/xparameters.h |  4 ----
 include/configs/microblaze-generic.h          | 10 ----------
 2 files changed, 14 deletions(-)

diff --git a/board/xilinx/microblaze-generic/xparameters.h b/board/xilinx/microblaze-generic/xparameters.h
index 501a23454d..ce1ec4c17a 100644
--- a/board/xilinx/microblaze-generic/xparameters.h
+++ b/board/xilinx/microblaze-generic/xparameters.h
@@ -21,7 +21,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
diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h
index 7f16700d4f..6a049cf2af 100644
--- a/include/configs/microblaze-generic.h
+++ b/include/configs/microblaze-generic.h
@@ -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 */
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v1 5/6] microblaze: Support for watchdog_reset in Microblaze init
  2018-06-29 21:51 [U-Boot] [PATCH v1 0/6] This patch series contains the the changes related to Shreenidhi Shedi
                   ` (3 preceding siblings ...)
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 4/6] microblaze: Delete Xilinx watchdog related macros Shreenidhi Shedi
@ 2018-06-29 21:51 ` Shreenidhi Shedi
  2018-07-11 14:29   ` Michal Simek
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 6/6] watchdog: Convert Xilinx Axi watchdog driver to driver model Shreenidhi Shedi
  5 siblings, 1 reply; 13+ messages in thread
From: Shreenidhi Shedi @ 2018-06-29 21:51 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
---

Changes in v1: None

 .../microblaze-generic/microblaze-generic.c   | 43 +++++++++++++++++--
 1 file changed, 39 insertions(+), 4 deletions(-)

diff --git a/board/xilinx/microblaze-generic/microblaze-generic.c b/board/xilinx/microblaze-generic/microblaze-generic.c
index 7d8f247fa9..1d48bfb20e 100644
--- a/board/xilinx/microblaze-generic/microblaze-generic.c
+++ b/board/xilinx/microblaze-generic/microblaze-generic.c
@@ -17,6 +17,7 @@
 #include <asm/microblaze_intc.h>
 #include <asm/asm.h>
 #include <asm/gpio.h>
+#include <dm/uclass.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -24,6 +25,12 @@ DECLARE_GLOBAL_DATA_PTR;
 static int reset_pin = -1;
 #endif
 
+#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_XILINX_TB_WATCHDOG)
+#include <wdt.h>
+
+static struct udevice *watchdog_dev;
+#endif /* !CONFIG_SPL_BUILD && CONFIG_XILINX_TB_WATCHDOG */
+
 ulong ram_base;
 
 int dram_init_banksize(void)
@@ -68,10 +75,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 +94,41 @@ static int gpio_init(void)
 	return 0;
 }
 
+#ifdef CONFIG_XILINX_TB_WATCHDOG
+/* 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_XILINX_TB_WATCHDOG */
+
 int board_late_init(void)
 {
 	gpio_init();
 
+#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_XILINX_TB_WATCHDOG)
+	watchdog_dev = NULL;
+	if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) {
+		puts("Watchdog: Not found!\n");
+	} else {
+		wdt_start(watchdog_dev, 0, 0);
+		puts("Watchdog: Started\n");
+	}
+#endif /* !CONFIG_SPL_BUILD && CONFIG_XILINX_TB_WATCHDOG */
+
 	return 0;
 }
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v1 6/6] watchdog: Convert Xilinx Axi watchdog driver to driver model
  2018-06-29 21:51 [U-Boot] [PATCH v1 0/6] This patch series contains the the changes related to Shreenidhi Shedi
                   ` (4 preceding siblings ...)
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 5/6] microblaze: Support for watchdog_reset in Microblaze init Shreenidhi Shedi
@ 2018-06-29 21:51 ` Shreenidhi Shedi
  2018-07-11 14:24   ` Michal Simek
  5 siblings, 1 reply; 13+ messages in thread
From: Shreenidhi Shedi @ 2018-06-29 21:51 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
---

Changes in v1: None

 drivers/watchdog/Kconfig         |   8 +++
 drivers/watchdog/xilinx_tb_wdt.c | 107 ++++++++++++++++++++++++-------
 2 files changed, 91 insertions(+), 24 deletions(-)

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 148c6a0d68..351d2af8d9 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -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
diff --git a/drivers/watchdog/xilinx_tb_wdt.c b/drivers/watchdog/xilinx_tb_wdt.c
index 2274123e49..7f20c2ce2f 100644
--- a/drivers/watchdog/xilinx_tb_wdt.c
+++ b/drivers/watchdog/xilinx_tb_wdt.c
@@ -1,13 +1,17 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
+ * Xilinx Axi platforms watchdog timer driver.
+ *
+ * Author(s):	Michal Å imek <michal.simek@xilinx.com>
+ *		Shreenidhi Shedi <yesshedi@gmail.com>
+ *
  * Copyright (c) 2011-2013 Xilinx Inc.
  */
 
 #include <common.h>
-#include <asm/io.h>
-#include <asm/microblaze_intc.h>
-#include <asm/processor.h>
-#include <watchdog.h>
+#include <dm.h>
+#include <wdt.h>
+#include <linux/io.h>
 
 #define XWT_CSR0_WRS_MASK	0x00000008 /* Reset status Mask */
 #define XWT_CSR0_WDS_MASK	0x00000004 /* Timer state Mask */
@@ -20,49 +24,104 @@ struct watchdog_regs {
 	u32 tbr; /* 0x8 */
 };
 
-static struct watchdog_regs *watchdog_base =
-			(struct watchdog_regs *)CONFIG_WATCHDOG_BASEADDR;
+struct xlnx_wdt_priv {
+	bool enable_once;
+	struct watchdog_regs *regs;
+};
 
-void hw_watchdog_reset(void)
+static int xlnx_wdt_reset(struct udevice *dev)
 {
 	u32 reg;
+	struct xlnx_wdt_priv *priv = dev_get_priv(dev);
+
+	debug("%s\n", __func__);
 
 	/* Read the current contents of TCSR0 */
-	reg = readl(&watchdog_base->twcsr0);
+	reg = readl(&priv->regs->twcsr0);
 
 	/* Clear the watchdog WDS bit */
 	if (reg & (XWT_CSR0_EWDT1_MASK | XWT_CSRX_EWDT2_MASK))
-		writel(reg | XWT_CSR0_WDS_MASK, &watchdog_base->twcsr0);
+		writel(reg | XWT_CSR0_WDS_MASK, &priv->regs->twcsr0);
+
+	return 0;
 }
 
-void hw_watchdog_disable(void)
+static int xlnx_wdt_stop(struct udevice *dev)
 {
 	u32 reg;
+	struct xlnx_wdt_priv *priv = dev_get_priv(dev);
+
+	if (priv->enable_once) {
+		puts("Can't stop Xilinux Axi watchdog.\n");
+		return -1;
+	}
 
 	/* Read the current contents of TCSR0 */
-	reg = readl(&watchdog_base->twcsr0);
+	reg = readl(&priv->regs->twcsr0);
 
-	writel(reg & ~XWT_CSR0_EWDT1_MASK, &watchdog_base->twcsr0);
-	writel(~XWT_CSRX_EWDT2_MASK, &watchdog_base->twcsr1);
+	writel(reg & ~XWT_CSR0_EWDT1_MASK, &priv->regs->twcsr0);
+	writel(~XWT_CSRX_EWDT2_MASK, &priv->regs->twcsr1);
 
 	puts("Watchdog disabled!\n");
+
+	return 0;
 }
 
-static void hw_watchdog_isr(void *arg)
+static int xlnx_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
 {
-	hw_watchdog_reset();
+	struct xlnx_wdt_priv *priv = dev_get_priv(dev);
+
+	writel((XWT_CSR0_WRS_MASK | XWT_CSR0_WDS_MASK | XWT_CSR0_EWDT1_MASK),
+	       &priv->regs->twcsr0);
+
+	writel(XWT_CSRX_EWDT2_MASK, &priv->regs->twcsr1);
+
+	return 0;
 }
 
-void hw_watchdog_init(void)
+static int xlnx_wdt_probe(struct udevice *dev)
 {
-	int ret;
+	debug("%s: Probing wdt%u\n", __func__, dev->seq);
 
-	writel((XWT_CSR0_WRS_MASK | XWT_CSR0_WDS_MASK | XWT_CSR0_EWDT1_MASK),
-	       &watchdog_base->twcsr0);
-	writel(XWT_CSRX_EWDT2_MASK, &watchdog_base->twcsr1);
+	xlnx_wdt_stop(dev);
 
-	ret = install_interrupt_handler(CONFIG_WATCHDOG_IRQ,
-						hw_watchdog_isr, NULL);
-	if (ret)
-		puts("Watchdog IRQ registration failed.");
+	return 0;
 }
+
+static int xlnx_wdt_ofdata_to_platdata(struct udevice *dev)
+{
+	struct xlnx_wdt_priv *priv = dev_get_priv(dev);
+
+	priv->regs = (struct watchdog_regs *)dev_read_addr(dev);
+	if (IS_ERR(priv->regs))
+		return PTR_ERR(priv->regs);
+
+	priv->enable_once = dev_read_u32_default(dev, "xlnx,wdt-enable-once",
+						 0);
+
+	debug("%s: wdt-enable-once %d\n", __func__, priv->enable_once);
+
+	return 0;
+}
+
+static const struct wdt_ops xlnx_wdt_ops = {
+	.start = xlnx_wdt_start,
+	.reset = xlnx_wdt_reset,
+	.stop = xlnx_wdt_stop,
+};
+
+static const struct udevice_id xlnx_wdt_ids[] = {
+	{ .compatible = "xlnx,xps-timebase-wdt-1.00.a", },
+	{ .compatible = "xlnx,xps-timebase-wdt-1.01.a", },
+	{},
+};
+
+U_BOOT_DRIVER(xlnx_wdt) = {
+	.name = "xlnx_wdt",
+	.id = UCLASS_WDT,
+	.of_match = xlnx_wdt_ids,
+	.probe = xlnx_wdt_probe,
+	.priv_auto_alloc_size = sizeof(struct xlnx_wdt_priv),
+	.ofdata_to_platdata = xlnx_wdt_ofdata_to_platdata,
+	.ops = &xlnx_wdt_ops,
+};
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v1 1/6] microblaze: Use default implementation from include/linux/io.h
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 1/6] microblaze: Use default implementation from include/linux/io.h Shreenidhi Shedi
@ 2018-07-11  8:12   ` Michal Simek
  0 siblings, 0 replies; 13+ messages in thread
From: Michal Simek @ 2018-07-11  8:12 UTC (permalink / raw)
  To: u-boot

On 29.6.2018 23:51, Shreenidhi Shedi wrote:
> Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
> ---
> 
> Changes in v1:
> - Removed few macros which aren't needed anymore
> - Few cosmetic changes
> - Converted Xilinx Axi Watchdog driver to driver model
> 
>  arch/microblaze/include/asm/io.h | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/arch/microblaze/include/asm/io.h b/arch/microblaze/include/asm/io.h
> index c7516a47e8..26a437c248 100644
> --- a/arch/microblaze/include/asm/io.h
> +++ b/arch/microblaze/include/asm/io.h
> @@ -120,9 +120,6 @@ io_outsl (unsigned long port, const void *src, unsigned long count)
>  #define insw(a,b,l) io_insw(a,b,l)
>  #define insl(a,b,l) io_insl(a,b,l)
>  
> -
> -#define iounmap(addr)				((void)0)
> -#define ioremap(physaddr, size)			(physaddr)
>  #define ioremap_nocache(physaddr, size)		(physaddr)
>  #define ioremap_writethrough(physaddr, size)	(physaddr)
>  #define ioremap_fullcache(physaddr, size)	(physaddr)
> 

This is already in my queue.

M

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v1 2/6] microblaze: Guard do_reset by CONFIG_SYSRESET
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 2/6] microblaze: Guard do_reset by CONFIG_SYSRESET Shreenidhi Shedi
@ 2018-07-11  8:13   ` Michal Simek
  0 siblings, 0 replies; 13+ messages in thread
From: Michal Simek @ 2018-07-11  8:13 UTC (permalink / raw)
  To: u-boot

On 29.6.2018 23:51, Shreenidhi Shedi wrote:
> Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
> ---
> 
> Changes in v1: None
> 
>  board/xilinx/microblaze-generic/microblaze-generic.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/board/xilinx/microblaze-generic/microblaze-generic.c b/board/xilinx/microblaze-generic/microblaze-generic.c
> index 58ca1d715d..fb89276c4f 100644
> --- a/board/xilinx/microblaze-generic/microblaze-generic.c
> +++ b/board/xilinx/microblaze-generic/microblaze-generic.c
> @@ -58,6 +58,7 @@ int dram_init(void)
>  	return 0;
>  };
>  
> +#if !defined(CONFIG_SYSRESET) || defined(CONFIG_SPL_BUILD)
>  int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  {
>  #ifndef CONFIG_SPL_BUILD
> @@ -76,6 +77,7 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  
>  	return 0;
>  }
> +#endif /* !CONFIG_SYSRESET || CONFIG_SPL_BUILD */
>  
>  static int gpio_init(void)
>  {
> 

This is also in my queue already that's why ignoring it.

M

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v1 3/6] microblaze: Cosmetic changes in Microblaze related files
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 3/6] microblaze: Cosmetic changes in Microblaze related files Shreenidhi Shedi
@ 2018-07-11  8:14   ` Michal Simek
  0 siblings, 0 replies; 13+ messages in thread
From: Michal Simek @ 2018-07-11  8:14 UTC (permalink / raw)
  To: u-boot


Here should be a description what you are changing.
And you can send this out of this watchdog series.

Thanks,
Michal

On 29.6.2018 23:51, Shreenidhi Shedi wrote:
> Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
> ---
> 
> Changes in v1: None
> 
>  arch/microblaze/include/asm/io.h              | 92 +++++++++++--------
>  .../microblaze-generic/microblaze-generic.c   |  8 +-
>  board/xilinx/microblaze-generic/xparameters.h |  4 +-
>  include/configs/microblaze-generic.h          |  2 +-
>  4 files changed, 61 insertions(+), 45 deletions(-)
> 
> diff --git a/arch/microblaze/include/asm/io.h b/arch/microblaze/include/asm/io.h
> index 26a437c248..2de3c3b6a3 100644
> --- a/arch/microblaze/include/asm/io.h
> +++ b/arch/microblaze/include/asm/io.h
> @@ -1,3 +1,4 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
>  /*
>   * include/asm-microblaze/io.h -- Misc I/O operations
>   *
> @@ -21,39 +22,42 @@
>  #define IO_SPACE_LIMIT 0xFFFFFFFF
>  
>  #define readb(addr) \
> -  ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
> +	({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
> +
>  #define readw(addr) \
> -  ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
> +	({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
> +
>  #define readl(addr) \
>  	({ unsigned int __v = (*(volatile unsigned int *) (addr)); __v; })
>  
>  #define writeb(b, addr) \
> -  (void)((*(volatile unsigned char *) (addr)) = (b))
> +	(void)((*(volatile unsigned char *) (addr)) = (b))
> +
>  #define writew(b, addr) \
> -  (void)((*(volatile unsigned short *) (addr)) = (b))
> +	(void)((*(volatile unsigned short *) (addr)) = (b))
> +
>  #define writel(b, addr) \
> -  (void)((*(volatile unsigned int *) (addr)) = (b))
> +	(void)((*(volatile unsigned int *) (addr)) = (b))
>  
> -#define memset_io(a,b,c)        memset((void *)(a),(b),(c))
> -#define memcpy_fromio(a,b,c)    memcpy((a),(void *)(b),(c))
> -#define memcpy_toio(a,b,c)      memcpy((void *)(a),(b),(c))
> +#define memset_io(a, b, c)        memset((void *)(a), (b), (c))
> +#define memcpy_fromio(a, b, c)    memcpy((a), (void *)(b), (c))
> +#define memcpy_toio(a, b, c)      memcpy((void *)(a), (b), (c))
>  
> -#define inb(addr)	readb (addr)
> -#define inw(addr)	readw (addr)
> -#define inl(addr)	readl (addr)
> -#define outb(x, addr)	((void) writeb (x, addr))
> -#define outw(x, addr)	((void) writew (x, addr))
> -#define outl(x, addr)	((void) writel (x, addr))
> +#define inb(addr)	readb(addr)
> +#define inw(addr)	readw(addr)
> +#define inl(addr)	readl(addr)
> +#define outb(x, addr)	((void)writeb(x, addr))
> +#define outw(x, addr)	((void)writew(x, addr))
> +#define outl(x, addr)	((void)writel(x, addr))
>  
>  /* Some #definitions to keep strange Xilinx code happy */
> -#define in_8(addr)	readb (addr)
> -#define in_be16(addr)	readw (addr)
> -#define in_be32(addr)	readl (addr)
> -
> -#define out_8(addr,x )	outb (x,addr)
> -#define out_be16(addr,x )	outw (x,addr)
> -#define out_be32(addr,x )	outl (x,addr)
> +#define in_8(addr)	readb(addr)
> +#define in_be16(addr)	readw(addr)
> +#define in_be32(addr)	readl(addr)
>  
> +#define out_8(addr, x)		outb(x, addr)
> +#define out_be16(addr, x)	outw(x, addr)
> +#define out_be32(addr, x)	outl(x, addr)
>  
>  #define inb_p(port)		inb((port))
>  #define outb_p(val, port)	outb((val), (port))
> @@ -71,54 +75,64 @@
>  #define __raw_writew writew
>  #define __raw_writel writel
>  
> -static inline void io_insb (unsigned long port, void *dst, unsigned long count)
> +static inline void io_insb(unsigned long port, void *dst, unsigned long count)
>  {
>  	unsigned char *p = dst;
> +
>  	while (count--)
> -		*p++ = inb (port);
> +		*p++ = inb(port);
>  }
> -static inline void io_insw (unsigned long port, void *dst, unsigned long count)
> +
> +static inline void io_insw(unsigned long port, void *dst, unsigned long count)
>  {
>  	unsigned short *p = dst;
> +
>  	while (count--)
> -		*p++ = inw (port);
> +		*p++ = inw(port);
>  }
> -static inline void io_insl (unsigned long port, void *dst, unsigned long count)
> +
> +static inline void io_insl(unsigned long port, void *dst, unsigned long count)
>  {
>  	unsigned long *p = dst;
> +
>  	while (count--)
> -		*p++ = inl (port);
> +		*p++ = inl(port);
>  }
>  
>  static inline void
> -io_outsb (unsigned long port, const void *src, unsigned long count)
> +io_outsb(unsigned long port, const void *src, unsigned long count)
>  {
>  	const unsigned char *p = src;
> +
>  	while (count--)
> -		outb (*p++, port);
> +		outb(*p++, port);
>  }
> +
>  static inline void
> -io_outsw (unsigned long port, const void *src, unsigned long count)
> +io_outsw(unsigned long port, const void *src, unsigned long count)
>  {
>  	const unsigned short *p = src;
> +
>  	while (count--)
> -		outw (*p++, port);
> +		outw(*p++, port);
>  }
> +
>  static inline void
> -io_outsl (unsigned long port, const void *src, unsigned long count)
> +io_outsl(unsigned long port, const void *src, unsigned long count)
>  {
>  	const unsigned long *p = src;
> +
>  	while (count--)
> -		outl (*p++, port);
> +		outl(*p++, port);
>  }
>  
> -#define outsb(a,b,l) io_outsb(a,b,l)
> -#define outsw(a,b,l) io_outsw(a,b,l)
> -#define outsl(a,b,l) io_outsl(a,b,l)
> +#define outsb(a, b, l) io_outsb(a, b, l)
> +#define outsw(a, b, l) io_outsw(a, b, l)
> +#define outsl(a, b, l) io_outsl(a, b, l)
>  
> -#define insb(a,b,l) io_insb(a,b,l)
> -#define insw(a,b,l) io_insw(a,b,l)
> -#define insl(a,b,l) io_insl(a,b,l)
> +#define insb(a, b, l) io_insb(a, b, l)
> +#define insw(a, b, l) io_insw(a, b, l)
> +#define insl(a, b, l) io_insl(a, b, l)
>  
>  #define ioremap_nocache(physaddr, size)		(physaddr)
>  #define ioremap_writethrough(physaddr, size)	(physaddr)
> diff --git a/board/xilinx/microblaze-generic/microblaze-generic.c b/board/xilinx/microblaze-generic/microblaze-generic.c
> index fb89276c4f..7d8f247fa9 100644
> --- a/board/xilinx/microblaze-generic/microblaze-generic.c
> +++ b/board/xilinx/microblaze-generic/microblaze-generic.c
> @@ -5,8 +5,10 @@
>   * Michal  SIMEK <monstr@monstr.eu>
>   */
>  
> -/* This is a board specific file.  It's OK to include board specific
> - * header files */
> +/*
> + * This is a board specific file.  It's OK to include board specific
> + * header files
> + */
>  
>  #include <common.h>
>  #include <config.h>
> @@ -71,7 +73,7 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  	hw_watchdog_disable();
>  #endif
>  #endif
> -	puts ("Reseting board\n");
> +	puts("Resetting board\n");
>  	__asm__ __volatile__ ("	mts rmsr, r0;" \
>  				"bra r0");
>  
> diff --git a/board/xilinx/microblaze-generic/xparameters.h b/board/xilinx/microblaze-generic/xparameters.h
> index 51bca40e34..501a23454d 100644
> --- a/board/xilinx/microblaze-generic/xparameters.h
> +++ b/board/xilinx/microblaze-generic/xparameters.h
> @@ -10,7 +10,7 @@
>   *          the generated file from your Xilinx design flow.
>   */
>  
> -#define XILINX_BOARD_NAME	microblaze-generic
> +#define XILINX_BOARD_NAME	"microblaze-generic"
>  
>  /* Microblaze is microblaze_0 */
>  #define XILINX_FSL_NUMBER	3
> @@ -19,7 +19,7 @@
>  #define XILINX_GPIO_BASEADDR	0x40000000
>  
>  /* Flash Memory is FLASH_2Mx32 */
> -#define XILINX_FLASH_START	0x2c000000
> +#define XILINX_FLASH_START	0x2C000000
>  #define XILINX_FLASH_SIZE	0x00800000
>  
>  /* Watchdog IP is wxi_timebase_wdt_0 */
> diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h
> index 966feeeafd..7f16700d4f 100644
> --- a/include/configs/microblaze-generic.h
> +++ b/include/configs/microblaze-generic.h
> @@ -217,7 +217,7 @@
>  
>  #define CONFIG_SYS_FDT_BASE		(CONFIG_SYS_FLASH_BASE + \
>  					 0x40000)
> -#define CONFIG_SYS_FDT_SIZE		(16<<10)
> +#define CONFIG_SYS_FDT_SIZE		(16 << 10)
>  #define CONFIG_SYS_SPL_ARGS_ADDR	(CONFIG_SYS_TEXT_BASE + \
>  					 0x1000000)
>  
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v1 4/6] microblaze: Delete Xilinx watchdog related macros
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 4/6] microblaze: Delete Xilinx watchdog related macros Shreenidhi Shedi
@ 2018-07-11  8:15   ` Michal Simek
  0 siblings, 0 replies; 13+ messages in thread
From: Michal Simek @ 2018-07-11  8:15 UTC (permalink / raw)
  To: u-boot


please put here proper description.

patch itself is fine.

M


On 29.6.2018 23:51, Shreenidhi Shedi wrote:
> Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
> ---
> 
> Changes in v1: None
> 
>  board/xilinx/microblaze-generic/xparameters.h |  4 ----
>  include/configs/microblaze-generic.h          | 10 ----------
>  2 files changed, 14 deletions(-)
> 
> diff --git a/board/xilinx/microblaze-generic/xparameters.h b/board/xilinx/microblaze-generic/xparameters.h
> index 501a23454d..ce1ec4c17a 100644
> --- a/board/xilinx/microblaze-generic/xparameters.h
> +++ b/board/xilinx/microblaze-generic/xparameters.h
> @@ -21,7 +21,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
> diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h
> index 7f16700d4f..6a049cf2af 100644
> --- a/include/configs/microblaze-generic.h
> +++ b/include/configs/microblaze-generic.h
> @@ -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 */
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v1 6/6] watchdog: Convert Xilinx Axi watchdog driver to driver model
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 6/6] watchdog: Convert Xilinx Axi watchdog driver to driver model Shreenidhi Shedi
@ 2018-07-11 14:24   ` Michal Simek
  0 siblings, 0 replies; 13+ messages in thread
From: Michal Simek @ 2018-07-11 14:24 UTC (permalink / raw)
  To: u-boot


please fill commit message.

On 29.6.2018 23:51, Shreenidhi Shedi wrote:
> Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
> ---
> 
> Changes in v1: None
> 
>  drivers/watchdog/Kconfig         |   8 +++
>  drivers/watchdog/xilinx_tb_wdt.c | 107 ++++++++++++++++++++++++-------
>  2 files changed, 91 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index 148c6a0d68..351d2af8d9 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -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
> diff --git a/drivers/watchdog/xilinx_tb_wdt.c b/drivers/watchdog/xilinx_tb_wdt.c
> index 2274123e49..7f20c2ce2f 100644
> --- a/drivers/watchdog/xilinx_tb_wdt.c
> +++ b/drivers/watchdog/xilinx_tb_wdt.c
> @@ -1,13 +1,17 @@
>  // SPDX-License-Identifier: GPL-2.0+
>  /*
> + * Xilinx Axi platforms watchdog timer driver.
> + *
> + * Author(s):	Michal Å imek <michal.simek@xilinx.com>
> + *		Shreenidhi Shedi <yesshedi@gmail.com>
> + *
>   * Copyright (c) 2011-2013 Xilinx Inc.
>   */
>  
>  #include <common.h>
> -#include <asm/io.h>
> -#include <asm/microblaze_intc.h>
> -#include <asm/processor.h>
> -#include <watchdog.h>
> +#include <dm.h>
> +#include <wdt.h>
> +#include <linux/io.h>
>  
>  #define XWT_CSR0_WRS_MASK	0x00000008 /* Reset status Mask */
>  #define XWT_CSR0_WDS_MASK	0x00000004 /* Timer state Mask */
> @@ -20,49 +24,104 @@ struct watchdog_regs {
>  	u32 tbr; /* 0x8 */
>  };
>  
> -static struct watchdog_regs *watchdog_base =
> -			(struct watchdog_regs *)CONFIG_WATCHDOG_BASEADDR;
> +struct xlnx_wdt_priv {
> +	bool enable_once;
> +	struct watchdog_regs *regs;
> +};
>  
> -void hw_watchdog_reset(void)
> +static int xlnx_wdt_reset(struct udevice *dev)
>  {
>  	u32 reg;
> +	struct xlnx_wdt_priv *priv = dev_get_priv(dev);
> +
> +	debug("%s\n", __func__);
>  
>  	/* Read the current contents of TCSR0 */
> -	reg = readl(&watchdog_base->twcsr0);
> +	reg = readl(&priv->regs->twcsr0);
>  
>  	/* Clear the watchdog WDS bit */
>  	if (reg & (XWT_CSR0_EWDT1_MASK | XWT_CSRX_EWDT2_MASK))
> -		writel(reg | XWT_CSR0_WDS_MASK, &watchdog_base->twcsr0);
> +		writel(reg | XWT_CSR0_WDS_MASK, &priv->regs->twcsr0);
> +
> +	return 0;
>  }
>  
> -void hw_watchdog_disable(void)
> +static int xlnx_wdt_stop(struct udevice *dev)
>  {
>  	u32 reg;
> +	struct xlnx_wdt_priv *priv = dev_get_priv(dev);
> +
> +	if (priv->enable_once) {
> +		puts("Can't stop Xilinux Axi watchdog.\n");

Just Xilinx here.

> +		return -1;
> +	}
>  
>  	/* Read the current contents of TCSR0 */
> -	reg = readl(&watchdog_base->twcsr0);
> +	reg = readl(&priv->regs->twcsr0);
>  
> -	writel(reg & ~XWT_CSR0_EWDT1_MASK, &watchdog_base->twcsr0);
> -	writel(~XWT_CSRX_EWDT2_MASK, &watchdog_base->twcsr1);
> +	writel(reg & ~XWT_CSR0_EWDT1_MASK, &priv->regs->twcsr0);
> +	writel(~XWT_CSRX_EWDT2_MASK, &priv->regs->twcsr1);
>  
>  	puts("Watchdog disabled!\n");
> +
> +	return 0;
>  }
>  
> -static void hw_watchdog_isr(void *arg)
> +static int xlnx_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
>  {
> -	hw_watchdog_reset();
> +	struct xlnx_wdt_priv *priv = dev_get_priv(dev);
> +
> +	writel((XWT_CSR0_WRS_MASK | XWT_CSR0_WDS_MASK | XWT_CSR0_EWDT1_MASK),
> +	       &priv->regs->twcsr0);
> +
> +	writel(XWT_CSRX_EWDT2_MASK, &priv->regs->twcsr1);
> +
> +	return 0;
>  }
>  
> -void hw_watchdog_init(void)
> +static int xlnx_wdt_probe(struct udevice *dev)
>  {
> -	int ret;
> +	debug("%s: Probing wdt%u\n", __func__, dev->seq);
>  
> -	writel((XWT_CSR0_WRS_MASK | XWT_CSR0_WDS_MASK | XWT_CSR0_EWDT1_MASK),
> -	       &watchdog_base->twcsr0);
> -	writel(XWT_CSRX_EWDT2_MASK, &watchdog_base->twcsr1);
> +	xlnx_wdt_stop(dev);

Based on what I see on running microblaze system. Watchdog is started
right after bitstream is loaded. It is weird that you want to stop
watchdog which is not started yet.
Also in case you can disable it because it was enabled in previous code
you are no covering time between probe done and watchdog enabling again.

That's why I think you should remove this line.

>  
> -	ret = install_interrupt_handler(CONFIG_WATCHDOG_IRQ,
> -						hw_watchdog_isr, NULL);
> -	if (ret)
> -		puts("Watchdog IRQ registration failed.");
> +	return 0;
>  }
> +
> +static int xlnx_wdt_ofdata_to_platdata(struct udevice *dev)
> +{
> +	struct xlnx_wdt_priv *priv = dev_get_priv(dev);
> +
> +	priv->regs = (struct watchdog_regs *)dev_read_addr(dev);
> +	if (IS_ERR(priv->regs))
> +		return PTR_ERR(priv->regs);
> +
> +	priv->enable_once = dev_read_u32_default(dev, "xlnx,wdt-enable-once",
> +						 0);
> +
> +	debug("%s: wdt-enable-once %d\n", __func__, priv->enable_once);
> +
> +	return 0;
> +}
> +
> +static const struct wdt_ops xlnx_wdt_ops = {
> +	.start = xlnx_wdt_start,
> +	.reset = xlnx_wdt_reset,
> +	.stop = xlnx_wdt_stop,
> +};
> +
> +static const struct udevice_id xlnx_wdt_ids[] = {
> +	{ .compatible = "xlnx,xps-timebase-wdt-1.00.a", },
> +	{ .compatible = "xlnx,xps-timebase-wdt-1.01.a", },
> +	{},
> +};
> +
> +U_BOOT_DRIVER(xlnx_wdt) = {
> +	.name = "xlnx_wdt",
> +	.id = UCLASS_WDT,
> +	.of_match = xlnx_wdt_ids,
> +	.probe = xlnx_wdt_probe,
> +	.priv_auto_alloc_size = sizeof(struct xlnx_wdt_priv),
> +	.ofdata_to_platdata = xlnx_wdt_ofdata_to_platdata,
> +	.ops = &xlnx_wdt_ops,
> +};
> 

Other then this the patch is fine and I have tested it on microblaze system.

Thanks,
Michal

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v1 5/6] microblaze: Support for watchdog_reset in Microblaze init
  2018-06-29 21:51 ` [U-Boot] [PATCH v1 5/6] microblaze: Support for watchdog_reset in Microblaze init Shreenidhi Shedi
@ 2018-07-11 14:29   ` Michal Simek
  0 siblings, 0 replies; 13+ messages in thread
From: Michal Simek @ 2018-07-11 14:29 UTC (permalink / raw)
  To: u-boot

On 29.6.2018 23:51, Shreenidhi Shedi wrote:
> Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
> ---
> 
> Changes in v1: None
> 
>  .../microblaze-generic/microblaze-generic.c   | 43 +++++++++++++++++--
>  1 file changed, 39 insertions(+), 4 deletions(-)
> 
> diff --git a/board/xilinx/microblaze-generic/microblaze-generic.c b/board/xilinx/microblaze-generic/microblaze-generic.c
> index 7d8f247fa9..1d48bfb20e 100644
> --- a/board/xilinx/microblaze-generic/microblaze-generic.c
> +++ b/board/xilinx/microblaze-generic/microblaze-generic.c
> @@ -17,6 +17,7 @@
>  #include <asm/microblaze_intc.h>
>  #include <asm/asm.h>
>  #include <asm/gpio.h>
> +#include <dm/uclass.h>
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -24,6 +25,12 @@ DECLARE_GLOBAL_DATA_PTR;
>  static int reset_pin = -1;
>  #endif
>  
> +#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_XILINX_TB_WATCHDOG)

CONFIG_WDT here because it doesn't need to be just XILINX_TB.

> +#include <wdt.h>

Please move this header out of if - it is not needed.

> +
> +static struct udevice *watchdog_dev;
> +#endif /* !CONFIG_SPL_BUILD && CONFIG_XILINX_TB_WATCHDOG */
> +
>  ulong ram_base;
>  
>  int dram_init_banksize(void)
> @@ -68,10 +75,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 +94,41 @@ static int gpio_init(void)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_XILINX_TB_WATCHDOG

CONFIG_WATCHDOG here.

> +/* 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_XILINX_TB_WATCHDOG */
> +
>  int board_late_init(void)
>  {
>  	gpio_init();
>  
> +#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_XILINX_TB_WATCHDOG)

CONFIG_WDT here.

> +	watchdog_dev = NULL;
> +	if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) {
> +		puts("Watchdog: Not found!\n");
> +	} else {
> +		wdt_start(watchdog_dev, 0, 0);
> +		puts("Watchdog: Started\n");
> +	}

I have sent today update on this code for zynq and zynqmp. And I hope
that this will be accepted to get this code to work properly.
https://lists.denx.de/pipermail/u-boot/2018-July/334227.html

	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_XILINX_TB_WATCHDOG */
> +
>  	return 0;
>  }
> 

Thanks,
Michal

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-07-11 14:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-29 21:51 [U-Boot] [PATCH v1 0/6] This patch series contains the the changes related to Shreenidhi Shedi
2018-06-29 21:51 ` [U-Boot] [PATCH v1 1/6] microblaze: Use default implementation from include/linux/io.h Shreenidhi Shedi
2018-07-11  8:12   ` Michal Simek
2018-06-29 21:51 ` [U-Boot] [PATCH v1 2/6] microblaze: Guard do_reset by CONFIG_SYSRESET Shreenidhi Shedi
2018-07-11  8:13   ` Michal Simek
2018-06-29 21:51 ` [U-Boot] [PATCH v1 3/6] microblaze: Cosmetic changes in Microblaze related files Shreenidhi Shedi
2018-07-11  8:14   ` Michal Simek
2018-06-29 21:51 ` [U-Boot] [PATCH v1 4/6] microblaze: Delete Xilinx watchdog related macros Shreenidhi Shedi
2018-07-11  8:15   ` Michal Simek
2018-06-29 21:51 ` [U-Boot] [PATCH v1 5/6] microblaze: Support for watchdog_reset in Microblaze init Shreenidhi Shedi
2018-07-11 14:29   ` Michal Simek
2018-06-29 21:51 ` [U-Boot] [PATCH v1 6/6] watchdog: Convert Xilinx Axi watchdog driver to driver model Shreenidhi Shedi
2018-07-11 14:24   ` Michal Simek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.