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