1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
5 #include <linux/kernel.h>
6 #include <linux/acpi.h>
8 #include <linux/export.h>
10 #include <linux/types.h>
11 #include <linux/reboot.h>
12 #include <linux/delay.h>
13 #include <linux/console.h>
15 #include <acpi/reboot.h>
17 #include <asm/loongarch.h>
18 #include <asm/reboot.h>
20 static void default_halt(void)
23 clear_csr_ecfg(ECFG0_IM);
25 pr_notice("\n\n** You can safely turn off the power now **\n\n");
26 console_flush_on_panic(CONSOLE_FLUSH_PENDING);
33 static void default_poweroff(void)
36 efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL);
43 static void default_restart(void)
46 if (efi_capsule_pending(NULL))
47 efi_reboot(REBOOT_WARM, NULL);
49 efi_reboot(REBOOT_COLD, NULL);
59 void (*pm_restart)(void);
60 EXPORT_SYMBOL(pm_restart);
62 void (*pm_power_off)(void);
63 EXPORT_SYMBOL(pm_power_off);
65 void machine_halt(void)
74 void machine_power_off(void)
83 void machine_restart(char *command)
89 do_kernel_restart(command);
93 static int __init loongarch_reboot_setup(void)
95 pm_restart = default_restart;
96 pm_power_off = default_poweroff;
101 arch_initcall(loongarch_reboot_setup);