Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / sh / kernel / reboot.c
blob11001a8a5fe0e325e854743aa1d4b678a0e43310
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/pm.h>
3 #include <linux/kexec.h>
4 #include <linux/kernel.h>
5 #include <linux/reboot.h>
6 #include <linux/module.h>
7 #ifdef CONFIG_SUPERH32
8 #include <asm/watchdog.h>
9 #endif
10 #include <asm/addrspace.h>
11 #include <asm/reboot.h>
12 #include <asm/tlbflush.h>
13 #include <asm/traps.h>
15 void (*pm_power_off)(void);
16 EXPORT_SYMBOL(pm_power_off);
18 #ifdef CONFIG_SUPERH32
19 static void watchdog_trigger_immediate(void)
21 sh_wdt_write_cnt(0xFF);
22 sh_wdt_write_csr(0xC2);
24 #endif
26 static void native_machine_restart(char * __unused)
28 local_irq_disable();
30 /* Destroy all of the TLBs in preparation for reset by MMU */
31 __flush_tlb_global();
33 /* Address error with SR.BL=1 first. */
34 trigger_address_error();
36 #ifdef CONFIG_SUPERH32
37 /* If that fails or is unsupported, go for the watchdog next. */
38 watchdog_trigger_immediate();
39 #endif
42 * Give up and sleep.
44 while (1)
45 cpu_sleep();
48 static void native_machine_shutdown(void)
50 smp_send_stop();
53 static void native_machine_power_off(void)
55 if (pm_power_off)
56 pm_power_off();
59 static void native_machine_halt(void)
61 /* stop other cpus */
62 machine_shutdown();
64 /* stop this cpu */
65 stop_this_cpu(NULL);
68 struct machine_ops machine_ops = {
69 .power_off = native_machine_power_off,
70 .shutdown = native_machine_shutdown,
71 .restart = native_machine_restart,
72 .halt = native_machine_halt,
73 #ifdef CONFIG_KEXEC
74 .crash_shutdown = native_machine_crash_shutdown,
75 #endif
78 void machine_power_off(void)
80 machine_ops.power_off();
83 void machine_shutdown(void)
85 machine_ops.shutdown();
88 void machine_restart(char *cmd)
90 machine_ops.restart(cmd);
93 void machine_halt(void)
95 machine_ops.halt();
98 #ifdef CONFIG_KEXEC
99 void machine_crash_shutdown(struct pt_regs *regs)
101 machine_ops.crash_shutdown(regs);
103 #endif