2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2007-05-13 11:58:00 +00:00
|
|
|
|
|
|
|
#include <common.h>
|
2019-12-28 17:45:01 +00:00
|
|
|
#include <cpu_func.h>
|
2007-05-13 11:58:00 +00:00
|
|
|
#include <asm/processor.h>
|
2010-06-16 07:55:26 +00:00
|
|
|
#include <asm/system.h>
|
2008-09-18 10:04:26 +00:00
|
|
|
#include <asm/io.h>
|
2007-05-13 11:58:00 +00:00
|
|
|
|
|
|
|
#define WDT_BASE WTCNT
|
|
|
|
|
2008-09-18 10:04:26 +00:00
|
|
|
#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);
|
2007-05-13 11:58:00 +00:00
|
|
|
}
|
|
|
|
|
2008-09-18 10:04:26 +00:00
|
|
|
static void cnt_write(unsigned char value)
|
|
|
|
{
|
|
|
|
outl((unsigned short)value | 0x5A00, WDT_BASE + 0x00);
|
2007-05-13 11:58:00 +00:00
|
|
|
}
|
|
|
|
|
2008-09-18 10:04:26 +00:00
|
|
|
static void csr_write(unsigned char value)
|
|
|
|
{
|
|
|
|
outl((unsigned short)value | 0xA500, WDT_BASE + 0x04);
|
2007-05-13 11:58:00 +00:00
|
|
|
}
|
|
|
|
|
2008-09-18 10:04:26 +00:00
|
|
|
void watchdog_reset(void)
|
|
|
|
{
|
|
|
|
outl(0x55000000, WDT_BASE + 0x08);
|
2007-05-13 11:58:00 +00:00
|
|
|
}
|
|
|
|
|
2008-09-18 10:04:26 +00:00
|
|
|
int watchdog_init(void)
|
|
|
|
{
|
|
|
|
/* Set overflow time*/
|
|
|
|
cnt_write(0);
|
|
|
|
/* Power on reset */
|
|
|
|
csr_write(WDT_WD|WDT_RST_P|WDT_ENABLE);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-05-13 11:58:00 +00:00
|
|
|
|
2008-09-18 10:04:26 +00:00
|
|
|
int watchdog_disable(void)
|
|
|
|
{
|
|
|
|
csr_write(csr_read() & ~WDT_ENABLE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2007-05-13 11:58:00 +00:00
|
|
|
|
2020-12-15 15:47:52 +00:00
|
|
|
void reset_cpu(void)
|
2007-05-13 11:58:00 +00:00
|
|
|
{
|
2010-06-16 07:55:26 +00:00
|
|
|
/* Address error with SR.BL=1 first. */
|
|
|
|
trigger_address_error();
|
|
|
|
|
2008-09-18 10:04:26 +00:00
|
|
|
while (1)
|
|
|
|
;
|
2007-05-13 11:58:00 +00:00
|
|
|
}
|