aerdrv_acpi.c 1.5 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. *
  22. * Return:
  23. * Zero if success. Nonzero for 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 pci_dev *dev)
  29. {
  30. int retval = OSC_METHOD_RUN_SUCCESS;
  31. acpi_status status;
  32. acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev);
  33. struct pci_dev *pdev = dev;
  34. struct pci_bus *parent;
  35. while (!handle) {
  36. if (!pdev || !pdev->bus->parent)
  37. break;
  38. parent = pdev->bus->parent;
  39. if (!parent->self)
  40. /* Parent must be a host bridge */
  41. handle = acpi_get_pci_rootbridge_handle(
  42. pci_domain_nr(parent),
  43. parent->number);
  44. else
  45. handle = DEVICE_ACPI_HANDLE(
  46. &(parent->self->dev));
  47. pdev = parent->self;
  48. }
  49. if (!handle)
  50. return OSC_METHOD_NOT_SUPPORTED;
  51. pci_osc_support_set(OSC_EXT_PCI_CONFIG_SUPPORT);
  52. status = pci_osc_control_set(handle, OSC_PCI_EXPRESS_AER_CONTROL |
  53. OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
  54. if (ACPI_FAILURE(status)) {
  55. if (status == AE_SUPPORT)
  56. retval = OSC_METHOD_NOT_SUPPORTED;
  57. else
  58. retval = OSC_METHOD_RUN_FAILURE;
  59. }
  60. return retval;
  61. }