.. | .. |
---|
3 | 3 | #include <linux/pci.h> |
---|
4 | 4 | #include <linux/acpi.h> |
---|
5 | 5 | #include <acpi/reboot.h> |
---|
| 6 | +#include <linux/delay.h> |
---|
| 7 | + |
---|
| 8 | +#ifdef CONFIG_PCI |
---|
| 9 | +static void acpi_pci_reboot(struct acpi_generic_address *rr, u8 reset_value) |
---|
| 10 | +{ |
---|
| 11 | + unsigned int devfn; |
---|
| 12 | + struct pci_bus *bus0; |
---|
| 13 | + |
---|
| 14 | + /* The reset register can only live on bus 0. */ |
---|
| 15 | + bus0 = pci_find_bus(0, 0); |
---|
| 16 | + if (!bus0) |
---|
| 17 | + return; |
---|
| 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); |
---|
| 25 | +} |
---|
| 26 | +#else |
---|
| 27 | +static inline void acpi_pci_reboot(struct acpi_generic_address *rr, |
---|
| 28 | + u8 reset_value) |
---|
| 29 | +{ |
---|
| 30 | + pr_warn_once("PCI configuration space access is not supported\n"); |
---|
| 31 | +} |
---|
| 32 | +#endif |
---|
6 | 33 | |
---|
7 | 34 | void acpi_reboot(void) |
---|
8 | 35 | { |
---|
9 | 36 | struct acpi_generic_address *rr; |
---|
10 | | - struct pci_bus *bus0; |
---|
11 | | - unsigned int devfn; |
---|
12 | 37 | u8 reset_value; |
---|
13 | 38 | |
---|
14 | 39 | if (acpi_disabled) |
---|
.. | .. |
---|
33 | 58 | * on a device on bus 0. */ |
---|
34 | 59 | switch (rr->space_id) { |
---|
35 | 60 | case ACPI_ADR_SPACE_PCI_CONFIG: |
---|
36 | | - /* The reset register can only live on bus 0. */ |
---|
37 | | - bus0 = pci_find_bus(0, 0); |
---|
38 | | - if (!bus0) |
---|
39 | | - return; |
---|
40 | | - /* Form PCI device/function pair. */ |
---|
41 | | - devfn = PCI_DEVFN((rr->address >> 32) & 0xffff, |
---|
42 | | - (rr->address >> 16) & 0xffff); |
---|
43 | | - printk(KERN_DEBUG "Resetting with ACPI PCI RESET_REG.\n"); |
---|
44 | | - /* Write the value that resets us. */ |
---|
45 | | - pci_bus_write_config_byte(bus0, devfn, |
---|
46 | | - (rr->address & 0xffff), reset_value); |
---|
| 61 | + acpi_pci_reboot(rr, reset_value); |
---|
47 | 62 | break; |
---|
48 | 63 | |
---|
49 | 64 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: |
---|
.. | .. |
---|
52 | 67 | acpi_reset(); |
---|
53 | 68 | break; |
---|
54 | 69 | } |
---|
| 70 | + |
---|
| 71 | + /* |
---|
| 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. |
---|
| 75 | + * |
---|
| 76 | + * The 15ms delay has been found to be long enough for the system |
---|
| 77 | + * to reboot on the affected platforms. |
---|
| 78 | + */ |
---|
| 79 | + mdelay(15); |
---|
55 | 80 | } |
---|