Linux Audio

Check our new training course

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