Commit 90634e85 authored by Lorenzo Pieralisi's avatar Lorenzo Pieralisi Committed by Bjorn Helgaas

PCI: rcar: Convert PCI scan API to pci_scan_root_bus_bridge()

The introduction of pci_scan_root_bus_bridge() provides a PCI core API to
scan a PCI root bus backed by an already initialized struct pci_host_bridge
object, which simplifies the bus scan interface and makes the PCI scan root
bus interface easier to generalize as members are added to the struct
pci_host_bridge.

Convert PCI rcar host code to pci_scan_root_bus_bridge() to improve the PCI
root bus scanning interface.
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Cc: Simon Horman <horms@verge.net.au>
parent 6b6de6af
...@@ -450,28 +450,32 @@ static void rcar_pcie_force_speedup(struct rcar_pcie *pcie) ...@@ -450,28 +450,32 @@ static void rcar_pcie_force_speedup(struct rcar_pcie *pcie)
static int rcar_pcie_enable(struct rcar_pcie *pcie) static int rcar_pcie_enable(struct rcar_pcie *pcie)
{ {
struct device *dev = pcie->dev; struct device *dev = pcie->dev;
struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
struct pci_bus *bus, *child; struct pci_bus *bus, *child;
LIST_HEAD(res); int ret;
/* Try setting 5 GT/s link speed */ /* Try setting 5 GT/s link speed */
rcar_pcie_force_speedup(pcie); rcar_pcie_force_speedup(pcie);
rcar_pcie_setup(&res, pcie); rcar_pcie_setup(&bridge->windows, pcie);
pci_add_flags(PCI_REASSIGN_ALL_RSRC | PCI_REASSIGN_ALL_BUS); pci_add_flags(PCI_REASSIGN_ALL_RSRC | PCI_REASSIGN_ALL_BUS);
bridge->dev.parent = dev;
bridge->sysdata = pcie;
bridge->busnr = pcie->root_bus_nr;
bridge->ops = &rcar_pcie_ops;
if (IS_ENABLED(CONFIG_PCI_MSI)) if (IS_ENABLED(CONFIG_PCI_MSI))
bus = pci_scan_root_bus_msi(dev, pcie->root_bus_nr, bridge->msi = &pcie->msi.chip;
&rcar_pcie_ops, pcie, &res, &pcie->msi.chip);
else
bus = pci_scan_root_bus(dev, pcie->root_bus_nr,
&rcar_pcie_ops, pcie, &res);
if (!bus) { ret = pci_scan_root_bus_bridge(bridge);
dev_err(dev, "Scanning rootbus failed"); if (ret < 0) {
return -ENODEV; kfree(bridge);
return ret;
} }
bus = bridge->bus;
pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci); pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci);
pci_bus_size_bridges(bus); pci_bus_size_bridges(bus);
...@@ -1127,11 +1131,14 @@ static int rcar_pcie_probe(struct platform_device *pdev) ...@@ -1127,11 +1131,14 @@ static int rcar_pcie_probe(struct platform_device *pdev)
unsigned int data; unsigned int data;
int err; int err;
int (*hw_init_fn)(struct rcar_pcie *); int (*hw_init_fn)(struct rcar_pcie *);
struct pci_host_bridge *bridge;
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); bridge = pci_alloc_host_bridge(sizeof(*pcie));
if (!pcie) if (!bridge)
return -ENOMEM; return -ENOMEM;
pcie = pci_host_bridge_priv(bridge);
pcie->dev = dev; pcie->dev = dev;
INIT_LIST_HEAD(&pcie->resources); INIT_LIST_HEAD(&pcie->resources);
...@@ -1141,12 +1148,12 @@ static int rcar_pcie_probe(struct platform_device *pdev) ...@@ -1141,12 +1148,12 @@ static int rcar_pcie_probe(struct platform_device *pdev)
err = rcar_pcie_get_resources(pcie); err = rcar_pcie_get_resources(pcie);
if (err < 0) { if (err < 0) {
dev_err(dev, "failed to request resources: %d\n", err); dev_err(dev, "failed to request resources: %d\n", err);
return err; goto err_free_bridge;
} }
err = rcar_pcie_parse_map_dma_ranges(pcie, dev->of_node); err = rcar_pcie_parse_map_dma_ranges(pcie, dev->of_node);
if (err) if (err)
return err; goto err_free_bridge;
pm_runtime_enable(dev); pm_runtime_enable(dev);
err = pm_runtime_get_sync(dev); err = pm_runtime_get_sync(dev);
...@@ -1183,6 +1190,9 @@ static int rcar_pcie_probe(struct platform_device *pdev) ...@@ -1183,6 +1190,9 @@ static int rcar_pcie_probe(struct platform_device *pdev)
return 0; return 0;
err_free_bridge:
pci_free_host_bridge(bridge);
err_pm_put: err_pm_put:
pm_runtime_put(dev); pm_runtime_put(dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment