Zhang, Yanmin | 6c2b374 | 2006-07-31 15:21:33 +0800 | [diff] [blame] | 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 |
Zhang, Yanmin | 8d29bfb | 2007-06-06 11:44:16 +0800 | [diff] [blame] | 23 | * @pciedev: pcie_device which AER is being enabled on |
Zhang, Yanmin | 6c2b374 | 2006-07-31 15:21:33 +0800 | [diff] [blame] | 24 | * |
Zhang, Yanmin | 8d29bfb | 2007-06-06 11:44:16 +0800 | [diff] [blame] | 25 | * @return: Zero on success. Nonzero otherwise. |
Zhang, Yanmin | 6c2b374 | 2006-07-31 15:21:33 +0800 | [diff] [blame] | 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 | **/ |
Zhang, Yanmin | 8d29bfb | 2007-06-06 11:44:16 +0800 | [diff] [blame] | 30 | int aer_osc_setup(struct pcie_device *pciedev) |
Zhang, Yanmin | 6c2b374 | 2006-07-31 15:21:33 +0800 | [diff] [blame] | 31 | { |
Zhang, Yanmin | 8d29bfb | 2007-06-06 11:44:16 +0800 | [diff] [blame] | 32 | acpi_status status = AE_NOT_FOUND; |
| 33 | struct pci_dev *pdev = pciedev->port; |
Harvey Harrison | a01e035 | 2008-04-28 16:50:04 -0700 | [diff] [blame] | 34 | acpi_handle handle = NULL; |
Zhang, Yanmin | 6c2b374 | 2006-07-31 15:21:33 +0800 | [diff] [blame] | 35 | |
Yinghai Lu | 4c44bac | 2008-02-02 22:24:47 -0800 | [diff] [blame] | 36 | if (acpi_pci_disabled) |
| 37 | return -1; |
| 38 | |
Andrew Patterson | 3c75e23 | 2008-01-22 17:18:27 -0700 | [diff] [blame] | 39 | /* Find root host bridge */ |
Adrian Bunk | d75b305 | 2008-03-31 01:41:01 +0300 | [diff] [blame] | 40 | while (pdev->bus->self) |
Andrew Patterson | 3c75e23 | 2008-01-22 17:18:27 -0700 | [diff] [blame] | 41 | pdev = pdev->bus->self; |
| 42 | handle = acpi_get_pci_rootbridge_handle( |
| 43 | pci_domain_nr(pdev->bus), pdev->bus->number); |
Zhang, Yanmin | 6c2b374 | 2006-07-31 15:21:33 +0800 | [diff] [blame] | 44 | |
Zhang, Yanmin | 8d29bfb | 2007-06-06 11:44:16 +0800 | [diff] [blame] | 45 | if (handle) { |
Andrew Patterson | d8634dd | 2008-01-22 17:18:17 -0700 | [diff] [blame] | 46 | pcie_osc_support_set(OSC_EXT_PCI_CONFIG_SUPPORT); |
Zhang, Yanmin | 8d29bfb | 2007-06-06 11:44:16 +0800 | [diff] [blame] | 47 | status = pci_osc_control_set(handle, |
| 48 | OSC_PCI_EXPRESS_AER_CONTROL | |
| 49 | OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL); |
Zhang, Yanmin | 6c2b374 | 2006-07-31 15:21:33 +0800 | [diff] [blame] | 50 | } |
| 51 | |
Zhang, Yanmin | 8d29bfb | 2007-06-06 11:44:16 +0800 | [diff] [blame] | 52 | if (ACPI_FAILURE(status)) { |
Bjorn Helgaas | 531f254 | 2008-06-13 10:52:12 -0600 | [diff] [blame] | 53 | dev_printk(KERN_DEBUG, &pciedev->device, "AER service couldn't " |
| 54 | "init device: %s\n", |
| 55 | (status == AE_SUPPORT || status == AE_NOT_FOUND) ? |
| 56 | "no _OSC support" : "_OSC failed"); |
Zhang, Yanmin | 8d29bfb | 2007-06-06 11:44:16 +0800 | [diff] [blame] | 57 | return -1; |
| 58 | } |
Zhang, Yanmin | 6c2b374 | 2006-07-31 15:21:33 +0800 | [diff] [blame] | 59 | |
Zhang, Yanmin | 8d29bfb | 2007-06-06 11:44:16 +0800 | [diff] [blame] | 60 | return 0; |
| 61 | } |