Merge branch 'master' of /home/davem/src/GIT/linux-2.6/
[sfrench/cifs-2.6.git] / drivers / pci / pcie / aer / aerdrv_acpi.c
1 /*
2  * Access ACPI _OSC method
3  *
4  * Copyright (C) 2006 Intel Corp.
5  *      Tom Long Nguyen (tom.l.nguyen@intel.com)
6  *      Zhang Yanmin (yanmin.zhang@intel.com)
7  *
8  */
9
10 #include <linux/module.h>
11 #include <linux/pci.h>
12 #include <linux/kernel.h>
13 #include <linux/errno.h>
14 #include <linux/pm.h>
15 #include <linux/suspend.h>
16 #include <linux/acpi.h>
17 #include <linux/pci-acpi.h>
18 #include <linux/delay.h>
19 #include "aerdrv.h"
20
21 /**
22  * aer_osc_setup - run ACPI _OSC method
23  * @pciedev: pcie_device which AER is being enabled on
24  *
25  * @return: Zero on success. Nonzero otherwise.
26  *
27  * Invoked when PCIe bus loads AER service driver. To avoid conflict with
28  * BIOS AER support requires BIOS to yield AER control to OS native driver.
29  **/
30 int aer_osc_setup(struct pcie_device *pciedev)
31 {
32         acpi_status status = AE_NOT_FOUND;
33         struct pci_dev *pdev = pciedev->port;
34         acpi_handle handle = NULL;
35
36         if (acpi_pci_disabled)
37                 return -1;
38
39         handle = acpi_find_root_bridge_handle(pdev);
40         if (handle) {
41                 status = acpi_pci_osc_control_set(handle,
42                                         OSC_PCI_EXPRESS_AER_CONTROL |
43                                         OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
44         }
45
46         if (ACPI_FAILURE(status)) {
47                 dev_printk(KERN_DEBUG, &pciedev->device, "AER service couldn't "
48                            "init device: %s\n",
49                            (status == AE_SUPPORT || status == AE_NOT_FOUND) ?
50                            "no _OSC support" : "_OSC failed");
51                 return -1;
52         }
53
54         return 0;
55 }