blob: 6b8c2f1d0e71eaa035b4fd0c4c8cadc3c6b3ddef [file] [log] [blame]
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +02001/*
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
11#include <linux/pci.h>
12#include <linux/kernel.h>
13#include <linux/errno.h>
14#include <linux/acpi.h>
15#include <linux/pci-acpi.h>
16#include <linux/pcieport_if.h>
17
18#include "aer/aerdrv.h"
19#include "../pci.h"
Andy Shevchenko139f92512013-04-12 11:17:47 -060020#include "portdrv.h"
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020021
22/**
23 * pcie_port_acpi_setup - Request the BIOS to release control of PCIe services.
24 * @port: PCIe Port service for a root port or event collector.
25 * @srv_mask: Bit mask of services that can be enabled for @port.
26 *
27 * Invoked when @port is identified as a PCIe port device. To avoid conflicts
28 * with the BIOS PCIe port native services support requires the BIOS to yield
29 * control of these services to the kernel. The mask of services that the BIOS
30 * allows to be enabled for @port is written to @srv_mask.
31 *
32 * NOTE: It turns out that we cannot do that for individual port services
33 * separately, because that would make some systems work incorrectly.
34 */
Jon Derrick88a97da2016-04-08 11:35:51 -060035void pcie_port_acpi_setup(struct pci_dev *port, int *srv_mask)
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020036{
Rafael J. Wysocki415e12b2011-01-07 00:55:09 +010037 struct acpi_pci_root *root;
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020038 acpi_handle handle;
39 u32 flags;
40
41 if (acpi_pci_disabled)
Jon Derrick88a97da2016-04-08 11:35:51 -060042 return;
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020043
44 handle = acpi_find_root_bridge_handle(port);
45 if (!handle)
Jon Derrick88a97da2016-04-08 11:35:51 -060046 return;
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020047
Rafael J. Wysocki415e12b2011-01-07 00:55:09 +010048 root = acpi_pci_find_root(handle);
49 if (!root)
Jon Derrick88a97da2016-04-08 11:35:51 -060050 return;
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020051
Rafael J. Wysocki415e12b2011-01-07 00:55:09 +010052 flags = root->osc_control_set;
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020053
Keith Busch10126ac2016-05-02 15:10:31 -050054 *srv_mask = PCIE_PORT_SERVICE_VC | PCIE_PORT_SERVICE_DPC;
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020055 if (flags & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)
56 *srv_mask |= PCIE_PORT_SERVICE_HP;
57 if (flags & OSC_PCI_EXPRESS_PME_CONTROL)
58 *srv_mask |= PCIE_PORT_SERVICE_PME;
59 if (flags & OSC_PCI_EXPRESS_AER_CONTROL)
60 *srv_mask |= PCIE_PORT_SERVICE_AER;
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020061}