Use a common watchdog driver for all these cpus. Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com> Acked-by: Stefano Babic <sbabic@denx.de>master
parent
17c5ef2007
commit
abbab70363
@ -0,0 +1,29 @@ |
||||
Watchdog driver general info |
||||
|
||||
CONFIG_HW_WATCHDOG |
||||
This enables hw_watchdog_reset to be called during various loops, |
||||
including waiting for a character on a serial port. But it |
||||
does not also call hw_watchdog_init. Boards which want this |
||||
enabled must call this function in their board file. This split |
||||
is useful because some rom's enable the watchdog when downloading |
||||
new code, so it must be serviced, but the board would rather it |
||||
was off. And, it cannot always be turned off once on. |
||||
|
||||
CONFIG_WATCHDOG_TIMEOUT_MSECS |
||||
Can be used to change the timeout for i.mx31/35/5x/6x. |
||||
If not given, will default to maximum timeout. This would |
||||
be 128000 msec for i.mx31/35/5x/6x. |
||||
|
||||
CONFIG_AT91SAM9_WATCHDOG |
||||
Available for AT91SAM9 to service the watchdog. |
||||
|
||||
CONFIG_FTWDT010_WATCHDOG |
||||
Available for FTWDT010 to service the watchdog. |
||||
|
||||
CONFIG_FTWDT010_HW_TIMEOUT |
||||
Can be used to change the timeout for FTWDT010. |
||||
|
||||
CONFIG_IMX_WATCHDOG |
||||
Available for i.mx31/35/5x/6x to service the watchdog. This is not |
||||
automatically set because some boards (vision2) still need to define |
||||
their own hw_watchdog_reset routine. |
@ -0,0 +1,66 @@ |
||||
/*
|
||||
* watchdog.c - driver for i.mx on-chip watchdog |
||||
* |
||||
* Licensed under the GPL-2 or later. |
||||
*/ |
||||
|
||||
#include <common.h> |
||||
#include <asm/io.h> |
||||
#include <watchdog.h> |
||||
#include <asm/arch/imx-regs.h> |
||||
|
||||
struct watchdog_regs { |
||||
u16 wcr; /* Control */ |
||||
u16 wsr; /* Service */ |
||||
u16 wrsr; /* Reset Status */ |
||||
}; |
||||
|
||||
#define WCR_WDZST 0x01 |
||||
#define WCR_WDBG 0x02 |
||||
#define WCR_WDE 0x04 /* WDOG enable */ |
||||
#define WCR_WDT 0x08 |
||||
#define WCR_WDW 0x80 |
||||
#define SET_WCR_WT(x) (x << 8) |
||||
|
||||
#ifdef CONFIG_IMX_WATCHDOG |
||||
void hw_watchdog_reset(void) |
||||
{ |
||||
struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR; |
||||
|
||||
writew(0x5555, &wdog->wsr); |
||||
writew(0xaaaa, &wdog->wsr); |
||||
} |
||||
|
||||
void hw_watchdog_init(void) |
||||
{ |
||||
struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR; |
||||
u16 timeout; |
||||
|
||||
/*
|
||||
* The timer watchdog can be set between |
||||
* 0.5 and 128 Seconds. If not defined |
||||
* in configuration file, sets 128 Seconds |
||||
*/ |
||||
#ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS |
||||
#define CONFIG_WATCHDOG_TIMEOUT_MSECS 128000 |
||||
#endif |
||||
timeout = (CONFIG_WATCHDOG_TIMEOUT_MSECS / 500) - 1; |
||||
writew(WCR_WDZST | WCR_WDBG | WCR_WDE | WCR_WDT | |
||||
WCR_WDW | SET_WCR_WT(timeout), &wdog->wcr); |
||||
hw_watchdog_reset(); |
||||
} |
||||
#endif |
||||
|
||||
void reset_cpu(ulong addr) |
||||
{ |
||||
struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR; |
||||
|
||||
writew(WCR_WDE, &wdog->wcr); |
||||
writew(0x5555, &wdog->wsr); |
||||
writew(0xaaaa, &wdog->wsr); /* load minimum 1/2 second timeout */ |
||||
while (1) { |
||||
/*
|
||||
* spin for .5 seconds before reset |
||||
*/ |
||||
} |
||||
} |
Loading…
Reference in new issue