2012-10-22 15:19:01 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
2018-10-18 10:27:45 +00:00
|
|
|
#ifdef CONFIG_FSL_LSCH2
|
|
|
|
#include <asm/arch/immap_lsch2.h>
|
|
|
|
#endif
|
2015-10-03 17:20:59 +00:00
|
|
|
#include <fsl_wdog.h>
|
2012-10-22 15:19:01 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_IMX_WATCHDOG
|
|
|
|
void hw_watchdog_reset(void)
|
|
|
|
{
|
2018-10-18 10:27:46 +00:00
|
|
|
#ifndef CONFIG_WATCHDOG_RESET_DISABLE
|
2012-10-22 15:19:01 +00:00
|
|
|
struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;
|
|
|
|
|
|
|
|
writew(0x5555, &wdog->wsr);
|
|
|
|
writew(0xaaaa, &wdog->wsr);
|
2018-10-18 10:27:46 +00:00
|
|
|
#endif /* CONFIG_WATCHDOG_RESET_DISABLE*/
|
2012-10-22 15:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2018-10-18 10:27:45 +00:00
|
|
|
#ifdef CONFIG_FSL_LSCH2
|
|
|
|
writew((WCR_WDA | WCR_SRS | WCR_WDE) << 8 | timeout, &wdog->wcr);
|
|
|
|
#else
|
2013-09-30 10:52:38 +00:00
|
|
|
writew(WCR_WDZST | WCR_WDBG | WCR_WDE | WCR_WDT | WCR_SRS |
|
2016-08-02 08:08:07 +00:00
|
|
|
WCR_WDA | SET_WCR_WT(timeout), &wdog->wcr);
|
2018-10-18 10:27:45 +00:00
|
|
|
#endif /* CONFIG_FSL_LSCH2*/
|
2012-10-22 15:19:01 +00:00
|
|
|
hw_watchdog_reset();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-07-13 07:25:42 +00:00
|
|
|
void __attribute__((weak)) reset_cpu(ulong addr)
|
2012-10-22 15:19:01 +00:00
|
|
|
{
|
|
|
|
struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;
|
|
|
|
|
2015-12-20 18:09:58 +00:00
|
|
|
clrsetbits_le16(&wdog->wcr, WCR_WT_MSK, WCR_WDE);
|
2015-09-14 05:34:44 +00:00
|
|
|
|
2012-10-22 15:19:01 +00:00
|
|
|
writew(0x5555, &wdog->wsr);
|
|
|
|
writew(0xaaaa, &wdog->wsr); /* load minimum 1/2 second timeout */
|
|
|
|
while (1) {
|
|
|
|
/*
|
|
|
|
* spin for .5 seconds before reset
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|