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>
16 #include <asm/compiler.h>
18 #include <asm/loongarch.h>
19 #include <asm/reboot.h>
21 static void default_halt(void)
24 clear_csr_ecfg(ECFG0_IM);
26 pr_notice("\n\n** You can safely turn off the power now **\n\n");
27 console_flush_on_panic(CONSOLE_FLUSH_PENDING);
34 static void default_poweroff(void)
37 efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL);
44 static void default_restart(void)
47 if (efi_capsule_pending(NULL))
48 efi_reboot(REBOOT_WARM, NULL);
50 efi_reboot(REBOOT_COLD, NULL);
60 void (*pm_restart)(void);
61 EXPORT_SYMBOL(pm_restart);
63 void (*pm_power_off)(void);
64 EXPORT_SYMBOL(pm_power_off);
66 void machine_halt(void)
75 void machine_power_off(void)
84 void machine_restart(char *command)
90 do_kernel_restart(command);
94 static int __init loongarch_reboot_setup(void)
96 pm_restart = default_restart;
97 pm_power_off = default_poweroff;
102 arch_initcall(loongarch_reboot_setup);