This patch series contains the the changes related to
cover This patch series contains the the changes related to
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
PATCH 1/6 microblaze: Use default implementation from include/linux/io.h
---
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(-)
arch/microblaze/include/asm/io.h +0 -3
@@ -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)
Signature · 1 line
2.17.1
PATCH 1/6 microblaze: Use default implementation from include/linux/io.h
Quoted 17 lines · Shreenidhi Shedi
Signed-off-by Shreenidhi Shedi <[email protected]>---
Changes in v1:
- Removed few macros which aren't needed anymore
- Few cosmetic changes
- Converted Xilinx Axi Watchdog driver to driver modelarch/microblaze/include/asm/io.h | 3 --- 1 file changed, 3 deletions(-)arch/microblaze/include/asm/io.h +0
-0
arch/microblaze/include/asm/io.h io_outsl (unsigned long port, const void *src, unsigned long count) · line 125
Quoted 9 lines
arch/microblaze/include/asm/io.h +0
-3@@ -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
PATCH 2/6 microblaze: Guard do_reset by CONFIG_SYSRESET
In reply to Shreenidhi Shedi---
Changes in v1: None
board/xilinx/microblaze-generic/microblaze-generic.c | 2 ++ 1 file changed, 2 insertions(+)
board/xilinx/microblaze-generic/microblaze-generic.c +2 -0
@@ -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 ) {
Signature · 1 line
2.17.1
PATCH 2/6 microblaze: Guard do_reset by CONFIG_SYSRESET
Quoted 22 lines · Shreenidhi Shedi
Signed-off-by Shreenidhi Shedi <[email protected]>---
Changes in v1: None
board/xilinx/microblaze-generic/microblaze-generic.c | 2 ++ 1 file changed, 2 insertions(+)board/xilinx/microblaze-generic/microblaze-generic.c +1
-0@@ -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
board/xilinx/microblaze-generic/microblaze-generic.c int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 83
Quoted 7 lines
board/xilinx/microblaze-generic/microblaze-generic.c +1
-0@@ -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
PATCH 3/6 microblaze: Cosmetic changes in Microblaze related files
In reply to Shreenidhi Shedi---
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(-)
arch/microblaze/include/asm/io.h +53 -39
@@ -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)
board/xilinx/microblaze-generic/microblaze-generic.c +5 -3
@@ -5,8 +5,10 @@* Michal SIMEK <[email protected]> */ -/* 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" );
board/xilinx/microblaze-generic/xparameters.h +2 -2
@@ -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 */
include/configs/microblaze-generic.h +1 -1
@@ -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)
Signature · 1 line
2.17.1
PATCH 3/6 microblaze: Cosmetic changes in Microblaze related files
Here should be a description what you are changing. And you can send this out of this watchdog series.
Thanks,
Michal
Quoted 229 lines · Shreenidhi Shedi
Signed-off-by Shreenidhi Shedi <[email protected]>---
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(-)arch/microblaze/include/asm/io.h +53
-39@@ -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)board/xilinx/microblaze-generic/microblaze-generic.c +5
-3@@ -5,8 +5,10 @@* Michal SIMEK <[email protected]> */ -/* 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" );board/xilinx/microblaze-generic/xparameters.h +2
-2@@ -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 */ include/configs/microblaze-generic.h +1
-1@@ -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)
PATCH 4/6 microblaze: Delete Xilinx watchdog related macros
In reply to Shreenidhi Shedi---
Changes in v1: None
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
@@ -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
include/configs/microblaze-generic.h +0 -10
@@ -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
2.17.1
PATCH 4/6 microblaze: Delete Xilinx watchdog related macros
please put here proper description.
patch itself is fine.
M
Quoted 43 lines · Shreenidhi Shedi
Signed-off-by Shreenidhi Shedi <[email protected]>---
Changes in v1: None
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@@ -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 1include/configs/microblaze-generic.h +0
-10@@ -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 */
PATCH 5/6 microblaze: Support for watchdog_reset in Microblaze init
In reply to Shreenidhi Shedi---
Changes in v1: None
.../microblaze-generic/microblaze-generic.c | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-)
board/xilinx/microblaze-generic/microblaze-generic.c +39 -4
@@ -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 ; }
Signature · 1 line
2.17.1
PATCH 5/6 microblaze: Support for watchdog_reset in Microblaze init
Quoted 21 lines · Shreenidhi Shedi
Signed-off-by Shreenidhi Shedi <[email protected]>---
Changes in v1: None
.../microblaze-generic/microblaze-generic.c | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-)board/xilinx/microblaze-generic/microblaze-generic.c +1
-0@@ -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 ;
board/xilinx/microblaze-generic/microblaze-generic.c DECLARE_GLOBAL_DATA_PTR; · line 28
Quoted 4 lines
board/xilinx/microblaze-generic/microblaze-generic.c +1
-0@@ -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.
board/xilinx/microblaze-generic/microblaze-generic.c DECLARE_GLOBAL_DATA_PTR; · line 29
Quoted 1 line
board/xilinx/microblaze-generic/microblaze-generic.c +1
-0+#include <wdt.h>
Please move this header out of if - it is not needed.
Quoted 19 lines
board/xilinx/microblaze-generic/microblaze-generic.c +4
-4+ +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;" \
board/xilinx/microblaze-generic/microblaze-generic.c static int gpio_init(void) · line 97
Quoted 4 lines
board/xilinx/microblaze-generic/microblaze-generic.c +1
-0@@ -91,9 +94,41 @@ static int gpio_init(void)return 0 ; } +#ifdef CONFIG_XILINX_TB_WATCHDOG
CONFIG_WATCHDOG here.
Quoted 16 lines
board/xilinx/microblaze-generic/microblaze-generic.c +16
-0+/* 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 ;
board/xilinx/microblaze-generic/microblaze-generic.c static int gpio_init(void) · line 123
Quoted 10 lines
board/xilinx/microblaze-generic/microblaze-generic.c +6
-0+ } +#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.
board/xilinx/microblaze-generic/microblaze-generic.c static int gpio_init(void) · line 130
Quoted 7 lines
board/xilinx/microblaze-generic/microblaze-generic.c +7
-0+ 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");board/xilinx/microblaze-generic/microblaze-generic.c static int gpio_init(void) · line 134
Quoted 5 lines
board/xilinx/microblaze-generic/microblaze-generic.c +2
-0+#endif /* !CONFIG_SPL_BUILD && CONFIG_XILINX_TB_WATCHDOG */ +return 0 ; }
Thanks,
Michal
PATCH 6/6 watchdog: Convert Xilinx Axi watchdog driver to driver model
In reply to Shreenidhi Shedi---
Changes in v1: None
drivers/watchdog/Kconfig | 8 +++ drivers/watchdog/xilinx_tb_wdt.c | 107 ++++++++++++++++++++++++------- 2 files changed, 91 insertions(+), 24 deletions(-)
drivers/watchdog/Kconfig +8 -0
@@ -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 +83 -24
145 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 6/6 watchdog: Convert Xilinx Axi watchdog driver to driver model
please fill commit message.
Quoted 81 lines · Shreenidhi Shedi
Signed-off-by Shreenidhi Shedi <[email protected]>---
Changes in v1: None
drivers/watchdog/Kconfig | 8 +++ drivers/watchdog/xilinx_tb_wdt.c | 107 ++++++++++++++++++++++++------- 2 files changed, 91 insertions(+), 24 deletions(-)drivers/watchdog/Kconfig +8
-0@@ -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. + endmenudrivers/watchdog/xilinx_tb_wdt.c +20
-9@@ -1,13 +1,17 @@// SPDX-License-Identifier: GPL-2.0+ /* +* Xilinx Axi platforms watchdog timer driver. +* +* Author(s): Michal Å imek <[email protected]> +* Shreenidhi Shedi <[email protected]> +* * 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 ;
drivers/watchdog/xilinx_tb_wdt.c struct watchdog_regs { · line 55
Quoted 10 lines
drivers/watchdog/xilinx_tb_wdt.c +5
-1} -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.
Quoted 31 lines
drivers/watchdog/xilinx_tb_wdt.c +16
-5+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 ; }
drivers/watchdog/xilinx_tb_wdt.c struct watchdog_regs { · line 86
Quoted 10 lines
drivers/watchdog/xilinx_tb_wdt.c +3
-5-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.
Quoted 36 lines
drivers/watchdog/xilinx_tb_wdt.c +30
-4- 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" , }, + {}, +}; +
drivers/watchdog/xilinx_tb_wdt.c struct watchdog_regs {
Quoted 10 lines
drivers/watchdog/xilinx_tb_wdt.c +9
-0+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