WIP FPC-III support
[linux/fpc-iii.git] / arch / sh / kernel / reboot.c
blob5c33f036418be2e00d3de5516d2a3a3e9eb9333b
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 #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)
24 local_irq_disable();
26 /* Destroy all of the TLBs in preparation for reset by MMU */
27 __flush_tlb_global();
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();
36 * Give up and sleep.
38 while (1)
39 cpu_sleep();
42 static void native_machine_shutdown(void)
44 smp_send_stop();
47 static void native_machine_power_off(void)
49 if (pm_power_off)
50 pm_power_off();
53 static void native_machine_halt(void)
55 /* stop other cpus */
56 machine_shutdown();
58 /* stop this cpu */
59 stop_this_cpu(NULL);
62 struct machine_ops machine_ops = {
63 .power_off = native_machine_power_off,
64 .shutdown = native_machine_shutdown,
65 .restart = native_machine_restart,
66 .halt = native_machine_halt,
67 #ifdef CONFIG_KEXEC
68 .crash_shutdown = native_machine_crash_shutdown,
69 #endif
72 void machine_power_off(void)
74 machine_ops.power_off();
77 void machine_shutdown(void)
79 machine_ops.shutdown();
82 void machine_restart(char *cmd)
84 machine_ops.restart(cmd);
87 void machine_halt(void)
89 machine_ops.halt();
92 #ifdef CONFIG_KEXEC
93 void machine_crash_shutdown(struct pt_regs *regs)
95 machine_ops.crash_shutdown(regs);
97 #endif