aerdrv_acpi.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 = DEVICE_ACPI_HANDLE(&pdev->dev);
  33. struct pci_bus *parent;
  34. while (!handle) {
  35. if (!pdev || !pdev->bus->parent)
  36. break;
  37. parent = pdev->bus->parent;
  38. if (!parent->self)
  39. /* Parent must be a host bridge */
  40. handle = acpi_get_pci_rootbridge_handle(
  41. pci_domain_nr(parent),
  42. parent->number);
  43. else
  44. handle = DEVICE_ACPI_HANDLE(
  45. &(parent->self->dev));
  46. pdev = parent->self;
  47. }
  48. if (handle) {
  49. pci_osc_support_set(OSC_EXT_PCI_CONFIG_SUPPORT);
  50. status = pci_osc_control_set(handle,
  51. OSC_PCI_EXPRESS_AER_CONTROL |
  52. OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
  53. }
  54. if (ACPI_FAILURE(status)) {
  55. printk(KERN_DEBUG "AER service couldn't init device %s - %s\n",
  56. pciedev->device.bus_id,
  57. (status == AE_SUPPORT || status == AE_NOT_FOUND) ?
  58. "no _OSC support" : "Run ACPI _OSC fails");
  59. return -1;
  60. }
  61. return 0;
  62. }