Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / drivers / firmware / efi / reboot.c
1 /*
2  * Copyright (C) 2014 Intel Corporation; author Matt Fleming
3  * Copyright (c) 2014 Red Hat, Inc., Mark Salter <msalter@redhat.com>
4  */
5 #include <linux/efi.h>
6 #include <linux/reboot.h>
7
8 int efi_reboot_quirk_mode = -1;
9
10 void efi_reboot(enum reboot_mode reboot_mode, const char *__unused)
11 {
12         int efi_mode;
13
14         if (!efi_enabled(EFI_RUNTIME_SERVICES))
15                 return;
16
17         switch (reboot_mode) {
18         case REBOOT_WARM:
19         case REBOOT_SOFT:
20                 efi_mode = EFI_RESET_WARM;
21                 break;
22         default:
23                 efi_mode = EFI_RESET_COLD;
24                 break;
25         }
26
27         /*
28          * If a quirk forced an EFI reset mode, always use that.
29          */
30         if (efi_reboot_quirk_mode != -1)
31                 efi_mode = efi_reboot_quirk_mode;
32
33         efi.reset_system(efi_mode, EFI_SUCCESS, 0, NULL);
34 }
35
36 bool __weak efi_poweroff_required(void)
37 {
38         return false;
39 }
40
41 static void efi_power_off(void)
42 {
43         efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL);
44 }
45
46 static int __init efi_shutdown_init(void)
47 {
48         if (!efi_enabled(EFI_RUNTIME_SERVICES))
49                 return -ENODEV;
50
51         if (efi_poweroff_required())
52                 pm_power_off = efi_power_off;
53
54         return 0;
55 }
56 late_initcall(efi_shutdown_init);