Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* reboot.c: reboot/shutdown/halt/poweroff handling
0003  *
0004  * Copyright (C) 2008 David S. Miller <davem@davemloft.net>
0005  */
0006 #include <linux/kernel.h>
0007 #include <linux/reboot.h>
0008 #include <linux/export.h>
0009 #include <linux/pm.h>
0010 #include <linux/of.h>
0011 
0012 #include <asm/oplib.h>
0013 #include <asm/prom.h>
0014 #include <asm/setup.h>
0015 
0016 /* sysctl - toggle power-off restriction for serial console
0017  * systems in machine_power_off()
0018  */
0019 int scons_pwroff = 1;
0020 
0021 /* This isn't actually used, it exists merely to satisfy the
0022  * reference in kernel/sys.c
0023  */
0024 void (*pm_power_off)(void) = machine_power_off;
0025 EXPORT_SYMBOL(pm_power_off);
0026 
0027 void machine_power_off(void)
0028 {
0029     if (!of_node_is_type(of_console_device, "serial") || scons_pwroff)
0030         prom_halt_power_off();
0031 
0032     prom_halt();
0033 }
0034 
0035 void machine_halt(void)
0036 {
0037     prom_halt();
0038     panic("Halt failed!");
0039 }
0040 
0041 void machine_restart(char *cmd)
0042 {
0043     char *p;
0044 
0045     p = strchr(reboot_command, '\n');
0046     if (p)
0047         *p = 0;
0048     if (cmd)
0049         prom_reboot(cmd);
0050     if (*reboot_command)
0051         prom_reboot(reboot_command);
0052     prom_reboot("");
0053     panic("Reboot failed!");
0054 }
0055