portdrv_acpi.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * PCIe Port Native Services Support, ACPI-Related Part
  3. *
  4. * Copyright (C) 2010 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. #include "aer/aerdrv.h"
  17. #include "../pci.h"
  18. /**
  19. * pcie_port_acpi_setup - Request the BIOS to release control of PCIe services.
  20. * @port: PCIe Port service for a root port or event collector.
  21. * @srv_mask: Bit mask of services that can be enabled for @port.
  22. *
  23. * Invoked when @port is identified as a PCIe port device. To avoid conflicts
  24. * with the BIOS PCIe port native services support requires the BIOS to yield
  25. * control of these services to the kernel. The mask of services that the BIOS
  26. * allows to be enabled for @port is written to @srv_mask.
  27. *
  28. * NOTE: It turns out that we cannot do that for individual port services
  29. * separately, because that would make some systems work incorrectly.
  30. */
  31. int pcie_port_acpi_setup(struct pci_dev *port, int *srv_mask)
  32. {
  33. struct acpi_pci_root *root;
  34. acpi_handle handle;
  35. u32 flags;
  36. if (acpi_pci_disabled)
  37. return 0;
  38. handle = acpi_find_root_bridge_handle(port);
  39. if (!handle)
  40. return -EINVAL;
  41. root = acpi_pci_find_root(handle);
  42. if (!root)
  43. return -ENODEV;
  44. flags = root->osc_control_set;
  45. *srv_mask = PCIE_PORT_SERVICE_VC;
  46. if (flags & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)
  47. *srv_mask |= PCIE_PORT_SERVICE_HP;
  48. if (flags & OSC_PCI_EXPRESS_PME_CONTROL)
  49. *srv_mask |= PCIE_PORT_SERVICE_PME;
  50. if (flags & OSC_PCI_EXPRESS_AER_CONTROL)
  51. *srv_mask |= PCIE_PORT_SERVICE_AER;
  52. return 0;
  53. }