pcie_pme_acpi.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * PCIe Native PME support, ACPI-related part
  3. *
  4. * Copyright (C) 2009 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc.
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License V2. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/pci.h>
  11. #include <linux/kernel.h>
  12. #include <linux/errno.h>
  13. #include <linux/acpi.h>
  14. #include <linux/pci-acpi.h>
  15. #include <linux/pcieport_if.h>
  16. /**
  17. * pcie_pme_acpi_setup - Request the ACPI BIOS to release control over PCIe PME.
  18. * @srv - PCIe PME service for a root port or event collector.
  19. *
  20. * Invoked when the PCIe bus type loads PCIe PME service driver. To avoid
  21. * conflict with the BIOS PCIe support requires the BIOS to yield PCIe PME
  22. * control to the kernel.
  23. */
  24. int pcie_pme_acpi_setup(struct pcie_device *srv)
  25. {
  26. acpi_status status = AE_NOT_FOUND;
  27. struct pci_dev *port = srv->port;
  28. acpi_handle handle;
  29. int error = 0;
  30. if (acpi_pci_disabled)
  31. return -ENOSYS;
  32. dev_info(&port->dev, "Requesting control of PCIe PME from ACPI BIOS\n");
  33. handle = acpi_find_root_bridge_handle(port);
  34. if (!handle)
  35. return -EINVAL;
  36. status = acpi_pci_osc_control_set(handle,
  37. OSC_PCI_EXPRESS_PME_CONTROL |
  38. OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
  39. if (ACPI_FAILURE(status)) {
  40. dev_info(&port->dev,
  41. "Failed to receive control of PCIe PME service: %s\n",
  42. (status == AE_SUPPORT || status == AE_NOT_FOUND) ?
  43. "no _OSC support" : "ACPI _OSC failed");
  44. error = -ENODEV;
  45. }
  46. return error;
  47. }