#include <linux/delay.h>
#include <linux/init.h>
#include <linux/irqdomain.h>
#include <linux/pci.h>
#include <linux/msi.h>
#include <linux/pci_hotplug.h>
#include <linux/module.h>
#include <linux/pci-acpi.h>
#include <linux/pm_runtime.h>
#include <linux/pm_qos.h>
#include <linux/rwsem.h>
#include "pci.h"
const guid_t pci_acpi_dsm_guid = …;
#if defined(CONFIG_PCI_QUIRKS) && defined(CONFIG_ARM64)
static int acpi_get_rc_addr(struct acpi_device *adev, struct resource *res)
{
struct device *dev = &adev->dev;
struct resource_entry *entry;
struct list_head list;
unsigned long flags;
int ret;
INIT_LIST_HEAD(&list);
flags = IORESOURCE_MEM;
ret = acpi_dev_get_resources(adev, &list,
acpi_dev_filter_resource_type_cb,
(void *) flags);
if (ret < 0) {
dev_err(dev, "failed to parse _CRS method, error code %d\n",
ret);
return ret;
}
if (ret == 0) {
dev_err(dev, "no IO and memory resources present in _CRS\n");
return -EINVAL;
}
entry = list_first_entry(&list, struct resource_entry, node);
*res = *entry->res;
acpi_dev_free_resource_list(&list);
return 0;
}
static acpi_status acpi_match_rc(acpi_handle handle, u32 lvl, void *context,
void **retval)
{
u16 *segment = context;
unsigned long long uid;
acpi_status status;
status = acpi_evaluate_integer(handle, METHOD_NAME__UID, NULL, &uid);
if (ACPI_FAILURE(status) || uid != *segment)
return AE_CTRL_DEPTH;
*(acpi_handle *)retval = handle;
return AE_CTRL_TERMINATE;
}
int acpi_get_rc_resources(struct device *dev, const char *hid, u16 segment,
struct resource *res)
{
struct acpi_device *adev;
acpi_status status;
acpi_handle handle;
int ret;
status = acpi_get_devices(hid, acpi_match_rc, &segment, &handle);
if (ACPI_FAILURE(status)) {
dev_err(dev, "can't find _HID %s device to locate resources\n",
hid);
return -ENODEV;
}
adev = acpi_fetch_acpi_dev(handle);
if (!adev)
return -ENODEV;
ret = acpi_get_rc_addr(adev, res);
if (ret) {
dev_err(dev, "can't get resource from %s\n",
dev_name(&adev->dev));
return ret;
}
return 0;
}
#endif
phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle)
{ … }
bool pci_acpi_preserve_config(struct pci_host_bridge *host_bridge)
{ … }
struct hpx_type0 { … };
static struct hpx_type0 pci_default_type0 = …;
static void program_hpx_type0(struct pci_dev *dev, struct hpx_type0 *hpx)
{ … }
static acpi_status decode_type0_hpx_record(union acpi_object *record,
struct hpx_type0 *hpx0)
{ … }
struct hpx_type1 { … };
static void program_hpx_type1(struct pci_dev *dev, struct hpx_type1 *hpx)
{ … }
static acpi_status decode_type1_hpx_record(union acpi_object *record,
struct hpx_type1 *hpx1)
{ … }
static bool pcie_root_rcb_set(struct pci_dev *dev)
{ … }
struct hpx_type2 { … };
static void program_hpx_type2(struct pci_dev *dev, struct hpx_type2 *hpx)
{ … }
static acpi_status decode_type2_hpx_record(union acpi_object *record,
struct hpx_type2 *hpx2)
{ … }
struct hpx_type3 { … };
enum hpx_type3_dev_type { … };
static u16 hpx3_device_type(struct pci_dev *dev)
{ … }
enum hpx_type3_fn_type { … };
static u8 hpx3_function_type(struct pci_dev *dev)
{ … }
static bool hpx3_cap_ver_matches(u8 pcie_cap_id, u8 hpx3_cap_id)
{ … }
enum hpx_type3_cfg_loc { … };
static void program_hpx_type3_register(struct pci_dev *dev,
const struct hpx_type3 *reg)
{ … }
static void program_hpx_type3(struct pci_dev *dev, struct hpx_type3 *hpx)
{ … }
static void parse_hpx3_register(struct hpx_type3 *hpx3_reg,
union acpi_object *reg_fields)
{ … }
static acpi_status program_type3_hpx_record(struct pci_dev *dev,
union acpi_object *record)
{ … }
static acpi_status acpi_run_hpx(struct pci_dev *dev, acpi_handle handle)
{ … }
static acpi_status acpi_run_hpp(struct pci_dev *dev, acpi_handle handle)
{ … }
int pci_acpi_program_hp_params(struct pci_dev *dev)
{ … }
bool pciehp_is_native(struct pci_dev *bridge)
{ … }
bool shpchp_is_native(struct pci_dev *bridge)
{ … }
static void pci_acpi_wake_bus(struct acpi_device_wakeup_context *context)
{ … }
static void pci_acpi_wake_dev(struct acpi_device_wakeup_context *context)
{ … }
acpi_status pci_acpi_add_bus_pm_notifier(struct acpi_device *dev)
{ … }
acpi_status pci_acpi_add_pm_notifier(struct acpi_device *dev,
struct pci_dev *pci_dev)
{ … }
pci_power_t acpi_pci_choose_state(struct pci_dev *pdev)
{ … }
static struct acpi_device *acpi_pci_find_companion(struct device *dev);
void pci_set_acpi_fwnode(struct pci_dev *dev)
{ … }
int pci_dev_acpi_reset(struct pci_dev *dev, bool probe)
{ … }
bool acpi_pci_power_manageable(struct pci_dev *dev)
{ … }
bool acpi_pci_bridge_d3(struct pci_dev *dev)
{ … }
static void acpi_pci_config_space_access(struct pci_dev *dev, bool enable)
{ … }
int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
{ … }
pci_power_t acpi_pci_get_power_state(struct pci_dev *dev)
{ … }
void acpi_pci_refresh_power_state(struct pci_dev *dev)
{ … }
static int acpi_pci_propagate_wakeup(struct pci_bus *bus, bool enable)
{ … }
int acpi_pci_wakeup(struct pci_dev *dev, bool enable)
{ … }
bool acpi_pci_need_resume(struct pci_dev *dev)
{ … }
void acpi_pci_add_bus(struct pci_bus *bus)
{ … }
void acpi_pci_remove_bus(struct pci_bus *bus)
{ … }
static DECLARE_RWSEM(pci_acpi_companion_lookup_sem);
static struct acpi_device *(*pci_acpi_find_companion_hook)(struct pci_dev *);
int pci_acpi_set_companion_lookup_hook(struct acpi_device *(*func)(struct pci_dev *))
{ … }
EXPORT_SYMBOL_GPL(…);
void pci_acpi_clear_companion_lookup_hook(void)
{ … }
EXPORT_SYMBOL_GPL(…);
static struct acpi_device *acpi_pci_find_companion(struct device *dev)
{ … }
static void pci_acpi_optimize_delay(struct pci_dev *pdev,
acpi_handle handle)
{ … }
static void pci_acpi_set_external_facing(struct pci_dev *dev)
{ … }
void pci_acpi_setup(struct device *dev, struct acpi_device *adev)
{ … }
void pci_acpi_cleanup(struct device *dev, struct acpi_device *adev)
{ … }
static struct fwnode_handle *(*pci_msi_get_fwnode_cb)(struct device *dev);
void
pci_msi_register_fwnode_provider(struct fwnode_handle *(*fn)(struct device *))
{ … }
struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus)
{ … }
static int __init acpi_pci_init(void)
{ … }
arch_initcall(acpi_pci_init);