]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/pci/host/pcie-xilinx-nwl.c
Merge branch 'pci/host-rockchip' into next
[karo-tx-linux.git] / drivers / pci / host / pcie-xilinx-nwl.c
index 4b16b26ae9090cdf2042e4b8a7a32bdfbc8f4f4b..d1f7e4ca5a5a38de3bb4729a1db89402e3a64d1b 100644 (file)
@@ -530,7 +530,7 @@ static int nwl_pcie_init_irq_domain(struct nwl_pcie *pcie)
        return 0;
 }
 
-static int nwl_pcie_enable_msi(struct nwl_pcie *pcie, struct pci_bus *bus)
+static int nwl_pcie_enable_msi(struct nwl_pcie *pcie)
 {
        struct device *dev = pcie->dev;
        struct platform_device *pdev = to_platform_device(dev);
@@ -791,13 +791,16 @@ static int nwl_pcie_probe(struct platform_device *pdev)
        struct nwl_pcie *pcie;
        struct pci_bus *bus;
        struct pci_bus *child;
+       struct pci_host_bridge *bridge;
        int err;
        resource_size_t iobase = 0;
        LIST_HEAD(res);
 
-       pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
-       if (!pcie)
-               return -ENOMEM;
+       bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
+       if (!bridge)
+               return -ENODEV;
+
+       pcie = pci_host_bridge_priv(bridge);
 
        pcie->dev = dev;
        pcie->ecam_value = NWL_ECAM_VALUE_DEFAULT;
@@ -830,21 +833,28 @@ static int nwl_pcie_probe(struct platform_device *pdev)
                goto error;
        }
 
-       bus = pci_create_root_bus(dev, pcie->root_busno,
-                                 &nwl_pcie_ops, pcie, &res);
-       if (!bus) {
-               err = -ENOMEM;
-               goto error;
-       }
+       list_splice_init(&res, &bridge->windows);
+       bridge->dev.parent = dev;
+       bridge->sysdata = pcie;
+       bridge->busnr = pcie->root_busno;
+       bridge->ops = &nwl_pcie_ops;
+       bridge->map_irq = of_irq_parse_and_map_pci;
+       bridge->swizzle_irq = pci_common_swizzle;
 
        if (IS_ENABLED(CONFIG_PCI_MSI)) {
-               err = nwl_pcie_enable_msi(pcie, bus);
+               err = nwl_pcie_enable_msi(pcie);
                if (err < 0) {
                        dev_err(dev, "failed to enable MSI support: %d\n", err);
                        goto error;
                }
        }
-       pci_scan_child_bus(bus);
+
+       err = pci_scan_root_bus_bridge(bridge);
+       if (err)
+               goto error;
+
+       bus = bridge->bus;
+
        pci_assign_unassigned_bus_resources(bus);
        list_for_each_entry(child, &bus->children, node)
                pcie_bus_configure_settings(child);