diff options
Diffstat (limited to 'drivers/pci/pci-acpi.c')
-rw-r--r-- | drivers/pci/pci-acpi.c | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index d966d47c9e80..001860361434 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
@@ -29,6 +29,82 @@ const u8 pci_acpi_dsm_uuid[] = { | |||
29 | 0x91, 0x17, 0xea, 0x4d, 0x19, 0xc3, 0x43, 0x4d | 29 | 0x91, 0x17, 0xea, 0x4d, 0x19, 0xc3, 0x43, 0x4d |
30 | }; | 30 | }; |
31 | 31 | ||
32 | #if defined(CONFIG_PCI_QUIRKS) && defined(CONFIG_ARM64) | ||
33 | static int acpi_get_rc_addr(struct acpi_device *adev, struct resource *res) | ||
34 | { | ||
35 | struct device *dev = &adev->dev; | ||
36 | struct resource_entry *entry; | ||
37 | struct list_head list; | ||
38 | unsigned long flags; | ||
39 | int ret; | ||
40 | |||
41 | INIT_LIST_HEAD(&list); | ||
42 | flags = IORESOURCE_MEM; | ||
43 | ret = acpi_dev_get_resources(adev, &list, | ||
44 | acpi_dev_filter_resource_type_cb, | ||
45 | (void *) flags); | ||
46 | if (ret < 0) { | ||
47 | dev_err(dev, "failed to parse _CRS method, error code %d\n", | ||
48 | ret); | ||
49 | return ret; | ||
50 | } | ||
51 | |||
52 | if (ret == 0) { | ||
53 | dev_err(dev, "no IO and memory resources present in _CRS\n"); | ||
54 | return -EINVAL; | ||
55 | } | ||
56 | |||
57 | entry = list_first_entry(&list, struct resource_entry, node); | ||
58 | *res = *entry->res; | ||
59 | acpi_dev_free_resource_list(&list); | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | static acpi_status acpi_match_rc(acpi_handle handle, u32 lvl, void *context, | ||
64 | void **retval) | ||
65 | { | ||
66 | u16 *segment = context; | ||
67 | unsigned long long uid; | ||
68 | acpi_status status; | ||
69 | |||
70 | status = acpi_evaluate_integer(handle, "_UID", NULL, &uid); | ||
71 | if (ACPI_FAILURE(status) || uid != *segment) | ||
72 | return AE_CTRL_DEPTH; | ||
73 | |||
74 | *(acpi_handle *)retval = handle; | ||
75 | return AE_CTRL_TERMINATE; | ||
76 | } | ||
77 | |||
78 | int acpi_get_rc_resources(struct device *dev, const char *hid, u16 segment, | ||
79 | struct resource *res) | ||
80 | { | ||
81 | struct acpi_device *adev; | ||
82 | acpi_status status; | ||
83 | acpi_handle handle; | ||
84 | int ret; | ||
85 | |||
86 | status = acpi_get_devices(hid, acpi_match_rc, &segment, &handle); | ||
87 | if (ACPI_FAILURE(status)) { | ||
88 | dev_err(dev, "can't find _HID %s device to locate resources\n", | ||
89 | hid); | ||
90 | return -ENODEV; | ||
91 | } | ||
92 | |||
93 | ret = acpi_bus_get_device(handle, &adev); | ||
94 | if (ret) | ||
95 | return ret; | ||
96 | |||
97 | ret = acpi_get_rc_addr(adev, res); | ||
98 | if (ret) { | ||
99 | dev_err(dev, "can't get resource from %s\n", | ||
100 | dev_name(&adev->dev)); | ||
101 | return ret; | ||
102 | } | ||
103 | |||
104 | return 0; | ||
105 | } | ||
106 | #endif | ||
107 | |||
32 | phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle) | 108 | phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle) |
33 | { | 109 | { |
34 | acpi_status status = AE_NOT_EXIST; | 110 | acpi_status status = AE_NOT_EXIST; |
@@ -294,6 +370,30 @@ int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp) | |||
294 | EXPORT_SYMBOL_GPL(pci_get_hp_params); | 370 | EXPORT_SYMBOL_GPL(pci_get_hp_params); |
295 | 371 | ||
296 | /** | 372 | /** |
373 | * pciehp_is_native - Check whether a hotplug port is handled by the OS | ||
374 | * @pdev: Hotplug port to check | ||
375 | * | ||
376 | * Walk up from @pdev to the host bridge, obtain its cached _OSC Control Field | ||
377 | * and return the value of the "PCI Express Native Hot Plug control" bit. | ||
378 | * On failure to obtain the _OSC Control Field return %false. | ||
379 | */ | ||
380 | bool pciehp_is_native(struct pci_dev *pdev) | ||
381 | { | ||
382 | struct acpi_pci_root *root; | ||
383 | acpi_handle handle; | ||
384 | |||
385 | handle = acpi_find_root_bridge_handle(pdev); | ||
386 | if (!handle) | ||
387 | return false; | ||
388 | |||
389 | root = acpi_pci_find_root(handle); | ||
390 | if (!root) | ||
391 | return false; | ||
392 | |||
393 | return root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL; | ||
394 | } | ||
395 | |||
396 | /** | ||
297 | * pci_acpi_wake_bus - Root bus wakeup notification fork function. | 397 | * pci_acpi_wake_bus - Root bus wakeup notification fork function. |
298 | * @work: Work item to handle. | 398 | * @work: Work item to handle. |
299 | */ | 399 | */ |