Loading...
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>
14
15void (*pm_power_off)(void);
16EXPORT_SYMBOL(pm_power_off);
17
18#ifdef CONFIG_SUPERH32
19static void watchdog_trigger_immediate(void)
20{
21 sh_wdt_write_cnt(0xFF);
22 sh_wdt_write_csr(0xC2);
23}
24#endif
25
26static void native_machine_restart(char * __unused)
27{
28 local_irq_disable();
29
30 /* Destroy all of the TLBs in preparation for reset by MMU */
31 __flush_tlb_global();
32
33 /* Address error with SR.BL=1 first. */
34 trigger_address_error();
35
36#ifdef CONFIG_SUPERH32
37 /* If that fails or is unsupported, go for the watchdog next. */
38 watchdog_trigger_immediate();
39#endif
40
41 /*
42 * Give up and sleep.
43 */
44 while (1)
45 cpu_sleep();
46}
47
48static void native_machine_shutdown(void)
49{
50 smp_send_stop();
51}
52
53static void native_machine_power_off(void)
54{
55 if (pm_power_off)
56 pm_power_off();
57}
58
59static void native_machine_halt(void)
60{
61 /* stop other cpus */
62 machine_shutdown();
63
64 /* stop this cpu */
65 stop_this_cpu(NULL);
66}
67
68struct 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
76};
77
78void machine_power_off(void)
79{
80 machine_ops.power_off();
81}
82
83void machine_shutdown(void)
84{
85 machine_ops.shutdown();
86}
87
88void machine_restart(char *cmd)
89{
90 machine_ops.restart(cmd);
91}
92
93void machine_halt(void)
94{
95 machine_ops.halt();
96}
97
98#ifdef CONFIG_KEXEC
99void machine_crash_shutdown(struct pt_regs *regs)
100{
101 machine_ops.crash_shutdown(regs);
102}
103#endif
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>
12
13void (*pm_power_off)(void);
14EXPORT_SYMBOL(pm_power_off);
15
16static void watchdog_trigger_immediate(void)
17{
18 sh_wdt_write_cnt(0xFF);
19 sh_wdt_write_csr(0xC2);
20}
21
22static void native_machine_restart(char * __unused)
23{
24 local_irq_disable();
25
26 /* Destroy all of the TLBs in preparation for reset by MMU */
27 __flush_tlb_global();
28
29 /* Address error with SR.BL=1 first. */
30 trigger_address_error();
31
32 /* If that fails or is unsupported, go for the watchdog next. */
33 watchdog_trigger_immediate();
34
35 /*
36 * Give up and sleep.
37 */
38 while (1)
39 cpu_sleep();
40}
41
42static void native_machine_shutdown(void)
43{
44 smp_send_stop();
45}
46
47static void native_machine_power_off(void)
48{
49 if (pm_power_off)
50 pm_power_off();
51}
52
53static void native_machine_halt(void)
54{
55 /* stop other cpus */
56 machine_shutdown();
57
58 /* stop this cpu */
59 stop_this_cpu(NULL);
60}
61
62struct 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
70};
71
72void machine_power_off(void)
73{
74 machine_ops.power_off();
75}
76
77void machine_shutdown(void)
78{
79 machine_ops.shutdown();
80}
81
82void machine_restart(char *cmd)
83{
84 machine_ops.restart(cmd);
85}
86
87void machine_halt(void)
88{
89 machine_ops.halt();
90}
91
92#ifdef CONFIG_KEXEC
93void machine_crash_shutdown(struct pt_regs *regs)
94{
95 machine_ops.crash_shutdown(regs);
96}
97#endif