blob: c1d612435939a5d62abb832d1f620faeeac7dc20 [file] [log] [blame]
Aaron Durbin4d387042008-07-16 23:27:08 +02001
2#include <linux/pci.h>
3#include <linux/acpi.h>
4#include <acpi/reboot.h>
5
6void acpi_reboot(void)
7{
8 struct acpi_generic_address *rr;
9 struct pci_bus *bus0;
10 u8 reset_value;
11 unsigned int devfn;
12
13 if (acpi_disabled)
14 return;
15
16 rr = &acpi_gbl_FADT.reset_register;
17
Matthew Garrett95cf3e12011-03-11 16:12:20 -050018 /* ACPI reset register was only introduced with v2 of the FADT */
19
20 if (acpi_gbl_FADT.header.revision < 2)
21 return;
22
Matthew Garrett6734fe52011-03-11 16:12:19 -050023 /* Is the reset register supported? The spec says we should be
24 * checking the bit width and bit offset, but Windows ignores
25 * these fields */
Len Browncf450132011-07-31 13:23:49 -040026 /* Ignore also acpi_gbl_FADT.flags.ACPI_FADT_RESET_REGISTER */
Aaron Durbin4d387042008-07-16 23:27:08 +020027
28 reset_value = acpi_gbl_FADT.reset_value;
29
30 /* The reset register can only exist in I/O, Memory or PCI config space
31 * on a device on bus 0. */
32 switch (rr->space_id) {
33 case ACPI_ADR_SPACE_PCI_CONFIG:
34 /* The reset register can only live on bus 0. */
35 bus0 = pci_find_bus(0, 0);
36 if (!bus0)
37 return;
38 /* Form PCI device/function pair. */
39 devfn = PCI_DEVFN((rr->address >> 32) & 0xffff,
40 (rr->address >> 16) & 0xffff);
41 printk(KERN_DEBUG "Resetting with ACPI PCI RESET_REG.");
42 /* Write the value that resets us. */
43 pci_bus_write_config_byte(bus0, devfn,
44 (rr->address & 0xffff), reset_value);
45 break;
46
47 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
48 case ACPI_ADR_SPACE_SYSTEM_IO:
49 printk(KERN_DEBUG "ACPI MEMORY or I/O RESET_REG.\n");
Lin Ming2ee62612008-12-16 16:40:31 +080050 acpi_reset();
Aaron Durbin4d387042008-07-16 23:27:08 +020051 break;
52 }
Aaron Durbin4d387042008-07-16 23:27:08 +020053}