Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b46373e0 authored by Jon Frosdick's avatar Jon Frosdick Committed by Paul Mundt
Browse files

sh: Use internal watchdog timer to perform reset



This patches will trigger a reboot using the watchdog
timer instead of double fault.  Unlike the previous
method, this one actually works in 32 bit mode.

Reset should also be cleaner.

Signed-off-by: default avatarJon Frosdick <jon.frosdick@st.com>
Signed-off-by: default avatarCarl Shaw <carl.shaw@st.com>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 27a30f53
Loading
Loading
Loading
Loading
+20 −0
Original line number Original line Diff line number Diff line
@@ -32,15 +32,35 @@
#include <asm/ubc.h>
#include <asm/ubc.h>
#include <asm/fpu.h>
#include <asm/fpu.h>
#include <asm/syscalls.h>
#include <asm/syscalls.h>
#include <asm/watchdog.h>


int ubc_usercnt = 0;
int ubc_usercnt = 0;


#ifdef CONFIG_32BIT
static void watchdog_trigger_immediate(void)
{
	sh_wdt_write_cnt(0xFF);
	sh_wdt_write_csr(0xC2);
}

void machine_restart(char * __unused)
{
	local_irq_disable();

	/* Use watchdog timer to trigger reset */
	watchdog_trigger_immediate();

	while (1)
		cpu_sleep();
}
#else
void machine_restart(char * __unused)
void machine_restart(char * __unused)
{
{
	/* SR.BL=1 and invoke address error to let CPU reset (manual reset) */
	/* SR.BL=1 and invoke address error to let CPU reset (manual reset) */
	asm volatile("ldc %0, sr\n\t"
	asm volatile("ldc %0, sr\n\t"
		     "mov.l @%1, %0" : : "r" (0x10000000), "r" (0x80000001));
		     "mov.l @%1, %0" : : "r" (0x10000000), "r" (0x80000001));
}
}
#endif


void machine_halt(void)
void machine_halt(void)
{
{