1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/kexec.h>
4 #include <linux/kernel.h>
5 #include <linux/reboot.h>
6 #include <linux/module.h>
7 #include <asm/watchdog.h>
8 #include <asm/addrspace.h>
9 #include <asm/reboot.h>
10 #include <asm/tlbflush.h>
11 #include <asm/traps.h>
13 void (*pm_power_off
)(void);
14 EXPORT_SYMBOL(pm_power_off
);
16 static void watchdog_trigger_immediate(void)
18 sh_wdt_write_cnt(0xFF);
19 sh_wdt_write_csr(0xC2);
22 static void native_machine_restart(char * __unused
)
26 /* Destroy all of the TLBs in preparation for reset by MMU */
29 /* Address error with SR.BL=1 first. */
30 trigger_address_error();
32 /* If that fails or is unsupported, go for the watchdog next. */
33 watchdog_trigger_immediate();
42 static void native_machine_shutdown(void)
47 static void native_machine_power_off(void)
49 do_kernel_power_off();
52 static void native_machine_halt(void)
61 struct machine_ops machine_ops
= {
62 .power_off
= native_machine_power_off
,
63 .shutdown
= native_machine_shutdown
,
64 .restart
= native_machine_restart
,
65 .halt
= native_machine_halt
,
66 #ifdef CONFIG_KEXEC_CORE
67 .crash_shutdown
= native_machine_crash_shutdown
,
71 void machine_power_off(void)
73 machine_ops
.power_off();
76 void machine_shutdown(void)
78 machine_ops
.shutdown();
81 void machine_restart(char *cmd
)
83 machine_ops
.restart(cmd
);
86 void machine_halt(void)
91 #ifdef CONFIG_KEXEC_CORE
92 void machine_crash_shutdown(struct pt_regs
*regs
)
94 machine_ops
.crash_shutdown(regs
);