aerdrv_acpi.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #include <linux/module.h>
  10. #include <linux/pci.h>
  11. #include <linux/kernel.h>
  12. #include <linux/errno.h>
  13. #include <linux/pm.h>
  14. #include <linux/suspend.h>
  15. #include <linux/acpi.h>
  16. #include <linux/pci-acpi.h>
  17. #include <linux/delay.h>
  18. #include "aerdrv.h"
  19. /**
  20. * aer_osc_setup - run ACPI _OSC method
  21. * @pciedev: pcie_device which AER is being enabled on
  22. *
  23. * @return: Zero on success. Nonzero otherwise.
  24. *
  25. * Invoked when PCIE bus loads AER service driver. To avoid conflict with
  26. * BIOS AER support requires BIOS to yield AER control to OS native driver.
  27. **/
  28. int aer_osc_setup(struct pcie_device *pciedev)
  29. {
  30. acpi_status status = AE_NOT_FOUND;
  31. struct pci_dev *pdev = pciedev->port;
  32. acpi_handle handle = NULL;
  33. if (acpi_pci_disabled)
  34. return -1;
  35. handle = acpi_find_root_bridge_handle(pdev);
  36. if (handle) {
  37. status = acpi_pci_osc_control_set(handle,
  38. OSC_PCI_EXPRESS_AER_CONTROL |
  39. OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
  40. }
  41. if (ACPI_FAILURE(status)) {
  42. dev_printk(KERN_DEBUG, &pciedev->device, "AER service couldn't "
  43. "init device: %s\n",
  44. (status == AE_SUPPORT || status == AE_NOT_FOUND) ?
  45. "no _OSC support" : "_OSC failed");
  46. return -1;
  47. }
  48. return 0;
  49. }