]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
PCI/ACPI: Provide acpi_get_rc_resources() for ARM64 platform
authorDongdong Liu <liudongdong3@huawei.com>
Thu, 1 Dec 2016 06:33:42 +0000 (00:33 -0600)
committerBjorn Helgaas <helgaas@kernel.org>
Tue, 6 Dec 2016 19:45:49 +0000 (13:45 -0600)
The acpi_get_rc_resources() is used to get the RC register address that can
not be described in MCFG.  It takes the _HID & segment to look for and
outputs the RC address resource.  Use PNP0C02 devices to describe such RC
address resource.  Use _UID to match segment to tell which root bus the
PNP0C02 resource belongs to.

[bhelgaas: add dev argument, wrap in #ifdef CONFIG_PCI_QUIRKS]
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
Signed-off-by: Tomasz Nowicki <tn@semihalf.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pci-acpi.c
drivers/pci/pci.h

index d966d47c9e80fbccbf904ed8c546db6645ca5be5..92384dece4b4319681bb7bf877dcd94216f59b33 100644 (file)
@@ -29,6 +29,82 @@ const u8 pci_acpi_dsm_uuid[] = {
        0x91, 0x17, 0xea, 0x4d, 0x19, 0xc3, 0x43, 0x4d
 };
 
+#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, "_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;
+       }
+
+       ret = acpi_bus_get_device(handle, &adev);
+       if (ret)
+               return ret;
+
+       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)
 {
        acpi_status status = AE_NOT_EXIST;
index 451856210e1816b4cf3932e5e32675199353b2cd..72b128efa344dcbf510b9ed5d024fbd349009e90 100644 (file)
@@ -356,4 +356,9 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 }
 #endif
 
+#if defined(CONFIG_PCI_QUIRKS) && defined(CONFIG_ARM64)
+int acpi_get_rc_resources(struct device *dev, const char *hid, u16 segment,
+                         struct resource *res);
+#endif
+
 #endif /* DRIVERS_PCI_H */