portdrv_acpi.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * PCIe Port Native Services Support, ACPI-Related Part
  4. *
  5. * Copyright (C) 2010 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc.
  6. */
  7. #include <linux/pci.h>
  8. #include <linux/kernel.h>
  9. #include <linux/errno.h>
  10. #include <linux/acpi.h>
  11. #include <linux/pci-acpi.h>
  12. #include "aer/aerdrv.h"
  13. #include "../pci.h"
  14. #include "portdrv.h"
  15. /**
  16. * pcie_port_acpi_setup - Request the BIOS to release control of PCIe services.
  17. * @port: PCIe Port service for a root port or event collector.
  18. * @srv_mask: Bit mask of services that can be enabled for @port.
  19. *
  20. * Invoked when @port is identified as a PCIe port device. To avoid conflicts
  21. * with the BIOS PCIe port native services support requires the BIOS to yield
  22. * control of these services to the kernel. The mask of services that the BIOS
  23. * allows to be enabled for @port is written to @srv_mask.
  24. *
  25. * NOTE: It turns out that we cannot do that for individual port services
  26. * separately, because that would make some systems work incorrectly.
  27. */
  28. void pcie_port_acpi_setup(struct pci_dev *port, int *srv_mask)
  29. {
  30. struct acpi_pci_root *root;
  31. acpi_handle handle;
  32. u32 flags;
  33. if (acpi_pci_disabled)
  34. return;
  35. handle = acpi_find_root_bridge_handle(port);
  36. if (!handle)
  37. return;
  38. root = acpi_pci_find_root(handle);
  39. if (!root)
  40. return;
  41. flags = root->osc_control_set;
  42. *srv_mask = 0;
  43. if (flags & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)
  44. *srv_mask |= PCIE_PORT_SERVICE_HP;
  45. if (flags & OSC_PCI_EXPRESS_PME_CONTROL)
  46. *srv_mask |= PCIE_PORT_SERVICE_PME;
  47. if (flags & OSC_PCI_EXPRESS_AER_CONTROL)
  48. *srv_mask |= PCIE_PORT_SERVICE_AER | PCIE_PORT_SERVICE_DPC;
  49. }