1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Author: Huacai Chen, chenhuacai@loongson.cn 4 * Copyright (C) 2020 Loongson Technology Co., Ltd. 5 */ 6 #include <linux/acpi.h> 7 #include <linux/cpu.h> 8 #include <linux/delay.h> 9 #include <linux/efi.h> 10 #include <linux/init.h> 11 #include <linux/pm.h> 12 #include <linux/slab.h> 13 #include <acpi/reboot.h> 14 #include <asm/bootinfo.h> 15 #include <asm/delay.h> 16 #include <asm/idle.h> 17 #include <asm/reboot.h> 18 loongson_restart(void)19static void loongson_restart(void) 20 { 21 #ifdef CONFIG_EFI 22 if (efi_capsule_pending(NULL)) 23 efi_reboot(REBOOT_WARM, NULL); 24 else 25 efi_reboot(REBOOT_COLD, NULL); 26 #endif 27 if (!acpi_disabled) 28 acpi_reboot(); 29 30 while (1) { 31 __arch_cpu_idle(); 32 } 33 } 34 loongson_poweroff(void)35static void loongson_poweroff(void) 36 { 37 #ifdef CONFIG_EFI 38 efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL); 39 #endif 40 while (1) { 41 __arch_cpu_idle(); 42 } 43 } 44 loongarch_reboot_setup(void)45static int __init loongarch_reboot_setup(void) 46 { 47 pm_restart = loongson_restart; 48 pm_power_off = loongson_poweroff; 49 50 return 0; 51 } 52 53 arch_initcall(loongarch_reboot_setup); 54