PCI/portdrv: Merge pcieport_if.h into portdrv.h
[linux-2.6-microblaze.git] / drivers / pci / pcie / portdrv_acpi.c
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
8 #include <linux/pci.h>
9 #include <linux/kernel.h>
10 #include <linux/errno.h>
11 #include <linux/acpi.h>
12 #include <linux/pci-acpi.h>
13
14 #include "aer/aerdrv.h"
15 #include "../pci.h"
16 #include "portdrv.h"
17
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 void 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
37         if (acpi_pci_disabled)
38                 return;
39
40         handle = acpi_find_root_bridge_handle(port);
41         if (!handle)
42                 return;
43
44         root = acpi_pci_find_root(handle);
45         if (!root)
46                 return;
47
48         flags = root->osc_control_set;
49
50         *srv_mask = PCIE_PORT_SERVICE_VC | PCIE_PORT_SERVICE_DPC;
51         if (flags & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)
52                 *srv_mask |= PCIE_PORT_SERVICE_HP;
53         if (flags & OSC_PCI_EXPRESS_PME_CONTROL)
54                 *srv_mask |= PCIE_PORT_SERVICE_PME;
55         if (flags & OSC_PCI_EXPRESS_AER_CONTROL)
56                 *srv_mask |= PCIE_PORT_SERVICE_AER;
57 }