sh: Add support watchdog for SH4A core
PATCH 1/1 sh: Add support watchdog for SH4A core
Add support watchdog for SH4A core (SH7763, SH7780 and SH7785). And fix some compile warning.
Signed-off-by Nobuhiro Iwamatsu <[email protected]>
--- cpu/sh4/watchdog.c | 48 ++++++++++++++++++++-------- lib_sh/board.c | 89 +++++++++++++++++++++++++++++++--------------------- 2 files changed, 87 insertions(+), 50 deletions(-)
cpu/sh4/watchdog.c +34 -14
@@ -17,32 +17,52 @@#include <common.h> #include <asm/processor.h> +#include <asm/io.h> #define WDT_BASE WTCNT -static unsigned char cnt_read (void ){ -return *((volatile unsigned char *)(WDT_BASE +0x00 )); +#define WDT_WD (1 << 6) +#define WDT_RST_P (0) +#define WDT_RST_M (1 << 5) +#define WDT_ENABLE (1 << 7) + +#if defined(CONFIG_WATCHDOG ) +static unsigned char csr_read (void ) +{ +return inb (WDT_BASE +0x04 ); } -static unsigned char csr_read (void ){ -return *((volatile unsigned char *)(WDT_BASE +0x04 )); +static void cnt_write (unsigned char value) +{ +outl ((unsigned short )value |0x5A00 ,WDT_BASE +0x00 ); } -static void cnt_write (unsigned char value){ -while (csr_read () & (1 <<5 )) { -/* delay */ - } - *((volatile unsigned short *)(WDT_BASE +0x00 )) - = ((unsigned short ) value) |0x5A00 ; +static void csr_write (unsigned char value) +{ +outl ((unsigned short )value |0xA500 ,WDT_BASE +0x04 ); } -static void csr_write (unsigned char value){ - *((volatile unsigned short *)(WDT_BASE +0x04 )) - = ((unsigned short ) value) |0xA500 ; +void watchdog_reset (void ) +{ +outl (0x55000000 ,WDT_BASE +0x08 ); } +int watchdog_init (void ) +{ +/* Set overflow time*/ +cnt_write (0 ); +/* Power on reset */ +csr_write (WDT_WD |WDT_RST_P |WDT_ENABLE ); + +return 0 ; +} -int watchdog_init (void ){return 0 ; } +int watchdog_disable (void ) +{ +csr_write (csr_read () & ~WDT_ENABLE ); +return 0 ; +} +#endif void reset_cpu (unsigned long ignored) {
lib_sh/board.c +53 -36
157 lines not on this page · raw message
Signature · 1 line
1.5.6.3
PATCH v2 1/1 sh: Add support watchdog for SH4A core
Add support watchdog for SH4A core (SH7763, SH7780 and SH7785). And fix some compile warning.
Signed-off-by Nobuhiro Iwamatsu <[email protected]>
---
- Fix checkpatch warning
cpu/sh4/watchdog.c | 53 +++++++++++++++++------- lib_sh/board.c | 115 ++++++++++++++++++++++++++++++---------------------- 2 files changed, 104 insertions(+), 64 deletions(-)
cpu/sh4/watchdog.c +37 -16
@@ -17,34 +17,55 @@#include <common.h> #include <asm/processor.h> +#include <asm/io.h> #define WDT_BASE WTCNT -static unsigned char cnt_read (void ){ -return *((volatile unsigned char *)(WDT_BASE +0x00 )); +#define WDT_WD (1 << 6) +#define WDT_RST_P (0) +#define WDT_RST_M (1 << 5) +#define WDT_ENABLE (1 << 7) + +#if defined(CONFIG_WATCHDOG ) +static unsigned char csr_read (void ) +{ +return inb (WDT_BASE +0x04 ); } -static unsigned char csr_read (void ){ -return *((volatile unsigned char *)(WDT_BASE +0x04 )); +static void cnt_write (unsigned char value) +{ +outl ((unsigned short )value |0x5A00 ,WDT_BASE +0x00 ); } -static void cnt_write (unsigned char value){ -while (csr_read () & (1 <<5 )) { -/* delay */ - } - *((volatile unsigned short *)(WDT_BASE +0x00 )) - = ((unsigned short ) value) |0x5A00 ; +static void csr_write (unsigned char value) +{ +outl ((unsigned short )value |0xA500 ,WDT_BASE +0x04 ); } -static void csr_write (unsigned char value){ - *((volatile unsigned short *)(WDT_BASE +0x04 )) - = ((unsigned short ) value) |0xA500 ; +void watchdog_reset (void ) +{ +outl (0x55000000 ,WDT_BASE +0x08 ); } +int watchdog_init (void ) +{ +/* Set overflow time*/ +cnt_write (0 ); +/* Power on reset */ +csr_write (WDT_WD |WDT_RST_P |WDT_ENABLE ); + +return 0 ; +} -int watchdog_init (void ){return 0 ; } +int watchdog_disable (void ) +{ +csr_write (csr_read () & ~WDT_ENABLE ); +return 0 ; +} +#endif -void reset_cpu (unsigned long ignored) +void reset_cpu (unsigned long ignored) { -while (1 ); +while (1 ) + ; }
lib_sh/board.c +67 -48
220 lines not on this page · raw message
Signature · 1 line
1.5.6.3