1 // SPDX-License-Identifier: GPL-2.0
4 #include <linux/acpi.h>
5 #include <acpi/reboot.h>
6 #include <linux/delay.h>
9 static void acpi_pci_reboot(struct acpi_generic_address
*rr
, u8 reset_value
)
14 /* The reset register can only live on bus 0. */
15 bus0
= pci_find_bus(0, 0);
18 /* Form PCI device/function pair. */
19 devfn
= PCI_DEVFN((rr
->address
>> 32) & 0xffff,
20 (rr
->address
>> 16) & 0xffff);
21 pr_debug("Resetting with ACPI PCI RESET_REG.\n");
22 /* Write the value that resets us. */
23 pci_bus_write_config_byte(bus0
, devfn
,
24 (rr
->address
& 0xffff), reset_value
);
27 static inline void acpi_pci_reboot(struct acpi_generic_address
*rr
,
30 pr_warn_once("PCI configuration space access is not supported\n");
34 void acpi_reboot(void)
36 struct acpi_generic_address
*rr
;
42 rr
= &acpi_gbl_FADT
.reset_register
;
44 /* ACPI reset register was only introduced with v2 of the FADT */
46 if (acpi_gbl_FADT
.header
.revision
< 2)
49 /* Is the reset register supported? The spec says we should be
50 * checking the bit width and bit offset, but Windows ignores
52 if (!(acpi_gbl_FADT
.flags
& ACPI_FADT_RESET_REGISTER
))
55 reset_value
= acpi_gbl_FADT
.reset_value
;
57 /* The reset register can only exist in I/O, Memory or PCI config space
58 * on a device on bus 0. */
59 switch (rr
->space_id
) {
60 case ACPI_ADR_SPACE_PCI_CONFIG
:
61 acpi_pci_reboot(rr
, reset_value
);
64 case ACPI_ADR_SPACE_SYSTEM_MEMORY
:
65 case ACPI_ADR_SPACE_SYSTEM_IO
:
66 printk(KERN_DEBUG
"ACPI MEMORY or I/O RESET_REG.\n");
72 * Some platforms do not shut down immediately after writing to the
73 * ACPI reset register, and this results in racing with the
74 * subsequent reboot mechanism.
76 * The 15ms delay has been found to be long enough for the system
77 * to reboot on the affected platforms.