2 * Copyright (C) 2014 Intel Corporation; author Matt Fleming
3 * Copyright (c) 2014 Red Hat, Inc., Mark Salter <msalter@redhat.com>
6 #include <linux/reboot.h>
8 int efi_reboot_quirk_mode
= -1;
10 void efi_reboot(enum reboot_mode reboot_mode
, const char *__unused
)
12 const char *str
[] = { "cold", "warm", "shutdown", "platform" };
13 int efi_mode
, cap_reset_mode
;
15 if (!efi_enabled(EFI_RUNTIME_SERVICES
))
18 switch (reboot_mode
) {
21 efi_mode
= EFI_RESET_WARM
;
24 efi_mode
= EFI_RESET_COLD
;
29 * If a quirk forced an EFI reset mode, always use that.
31 if (efi_reboot_quirk_mode
!= -1)
32 efi_mode
= efi_reboot_quirk_mode
;
34 if (efi_capsule_pending(&cap_reset_mode
)) {
35 if (efi_mode
!= cap_reset_mode
)
36 printk(KERN_CRIT
"efi: %s reset requested but pending "
37 "capsule update requires %s reset... Performing "
38 "%s reset.\n", str
[efi_mode
], str
[cap_reset_mode
],
40 efi_mode
= cap_reset_mode
;
43 efi
.reset_system(efi_mode
, EFI_SUCCESS
, 0, NULL
);
46 bool __weak
efi_poweroff_required(void)
51 static void efi_power_off(void)
53 efi
.reset_system(EFI_RESET_SHUTDOWN
, EFI_SUCCESS
, 0, NULL
);
56 static int __init
efi_shutdown_init(void)
58 if (!efi_enabled(EFI_RUNTIME_SERVICES
))
61 if (efi_poweroff_required())
62 pm_power_off
= efi_power_off
;
66 late_initcall(efi_shutdown_init
);