diff options
Diffstat (limited to 'arch/sh/kernel/reboot.c')
-rw-r--r-- | arch/sh/kernel/reboot.c | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/arch/sh/kernel/reboot.c b/arch/sh/kernel/reboot.c new file mode 100644 index 000000000000..b1fca66bb92e --- /dev/null +++ b/arch/sh/kernel/reboot.c | |||
@@ -0,0 +1,98 @@ | |||
1 | #include <linux/pm.h> | ||
2 | #include <linux/kexec.h> | ||
3 | #include <linux/kernel.h> | ||
4 | #include <linux/reboot.h> | ||
5 | #include <linux/module.h> | ||
6 | #ifdef CONFIG_SUPERH32 | ||
7 | #include <asm/watchdog.h> | ||
8 | #endif | ||
9 | #include <asm/addrspace.h> | ||
10 | #include <asm/reboot.h> | ||
11 | #include <asm/system.h> | ||
12 | |||
13 | void (*pm_power_off)(void); | ||
14 | EXPORT_SYMBOL(pm_power_off); | ||
15 | |||
16 | #ifdef CONFIG_SUPERH32 | ||
17 | static void watchdog_trigger_immediate(void) | ||
18 | { | ||
19 | sh_wdt_write_cnt(0xFF); | ||
20 | sh_wdt_write_csr(0xC2); | ||
21 | } | ||
22 | #endif | ||
23 | |||
24 | static void native_machine_restart(char * __unused) | ||
25 | { | ||
26 | local_irq_disable(); | ||
27 | |||
28 | /* Address error with SR.BL=1 first. */ | ||
29 | trigger_address_error(); | ||
30 | |||
31 | #ifdef CONFIG_SUPERH32 | ||
32 | /* If that fails or is unsupported, go for the watchdog next. */ | ||
33 | watchdog_trigger_immediate(); | ||
34 | #endif | ||
35 | |||
36 | /* | ||
37 | * Give up and sleep. | ||
38 | */ | ||
39 | while (1) | ||
40 | cpu_sleep(); | ||
41 | } | ||
42 | |||
43 | static void native_machine_shutdown(void) | ||
44 | { | ||
45 | smp_send_stop(); | ||
46 | } | ||
47 | |||
48 | static void native_machine_power_off(void) | ||
49 | { | ||
50 | if (pm_power_off) | ||
51 | pm_power_off(); | ||
52 | } | ||
53 | |||
54 | static void native_machine_halt(void) | ||
55 | { | ||
56 | /* stop other cpus */ | ||
57 | machine_shutdown(); | ||
58 | |||
59 | /* stop this cpu */ | ||
60 | stop_this_cpu(NULL); | ||
61 | } | ||
62 | |||
63 | struct machine_ops machine_ops = { | ||
64 | .power_off = native_machine_power_off, | ||
65 | .shutdown = native_machine_shutdown, | ||
66 | .restart = native_machine_restart, | ||
67 | .halt = native_machine_halt, | ||
68 | #ifdef CONFIG_KEXEC | ||
69 | .crash_shutdown = native_machine_crash_shutdown, | ||
70 | #endif | ||
71 | }; | ||
72 | |||
73 | void machine_power_off(void) | ||
74 | { | ||
75 | machine_ops.power_off(); | ||
76 | } | ||
77 | |||
78 | void machine_shutdown(void) | ||
79 | { | ||
80 | machine_ops.shutdown(); | ||
81 | } | ||
82 | |||
83 | void machine_restart(char *cmd) | ||
84 | { | ||
85 | machine_ops.restart(cmd); | ||
86 | } | ||
87 | |||
88 | void machine_halt(void) | ||
89 | { | ||
90 | machine_ops.halt(); | ||
91 | } | ||
92 | |||
93 | #ifdef CONFIG_KEXEC | ||
94 | void machine_crash_shutdown(struct pt_regs *regs) | ||
95 | { | ||
96 | machine_ops.crash_shutdown(regs); | ||
97 | } | ||
98 | #endif | ||