PCI: rockchip: Use pci_parse_request_of_pci_ranges()
Convert the Rockchip host bridge to use the common pci_parse_request_of_pci_ranges(). There's no need to assign the resources to a temporary list first. Just use bridge->windows directly and remove all the temporary list handling. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: Shawn Lin <shawn.lin@rock-chips.com> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: Andrew Murray <andrew.murray@arm.com> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Heiko Stuebner <heiko@sntech.de> Cc: linux-rockchip@lists.infradead.org
This commit is contained in:
Родитель
6c6a0dff06
Коммит
5c1306a0fd
|
@ -950,14 +950,10 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct pci_bus *bus, *child;
|
struct pci_bus *bus, *child;
|
||||||
struct pci_host_bridge *bridge;
|
struct pci_host_bridge *bridge;
|
||||||
|
struct resource *bus_res;
|
||||||
struct resource_entry *win;
|
struct resource_entry *win;
|
||||||
resource_size_t io_base;
|
|
||||||
struct resource *mem;
|
|
||||||
struct resource *io;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
LIST_HEAD(res);
|
|
||||||
|
|
||||||
if (!dev->of_node)
|
if (!dev->of_node)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
@ -995,29 +991,20 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto err_deinit_port;
|
goto err_deinit_port;
|
||||||
|
|
||||||
err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff,
|
err = pci_parse_request_of_pci_ranges(dev, &bridge->windows, &bus_res);
|
||||||
&res, &io_base);
|
|
||||||
if (err)
|
if (err)
|
||||||
goto err_remove_irq_domain;
|
goto err_remove_irq_domain;
|
||||||
|
|
||||||
err = devm_request_pci_bus_resources(dev, &res);
|
rockchip->root_bus_nr = bus_res->start;
|
||||||
if (err)
|
|
||||||
goto err_free_res;
|
|
||||||
|
|
||||||
/* Get the I/O and memory ranges from DT */
|
/* Get the I/O and memory ranges from DT */
|
||||||
resource_list_for_each_entry(win, &res) {
|
resource_list_for_each_entry(win, &bridge->windows) {
|
||||||
switch (resource_type(win->res)) {
|
switch (resource_type(win->res)) {
|
||||||
case IORESOURCE_IO:
|
case IORESOURCE_IO:
|
||||||
io = win->res;
|
io = win->res;
|
||||||
io->name = "I/O";
|
io->name = "I/O";
|
||||||
rockchip->io_size = resource_size(io);
|
rockchip->io_size = resource_size(io);
|
||||||
rockchip->io_bus_addr = io->start - win->offset;
|
rockchip->io_bus_addr = io->start - win->offset;
|
||||||
err = pci_remap_iospace(io, io_base);
|
|
||||||
if (err) {
|
|
||||||
dev_warn(dev, "error %d: failed to map resource %pR\n",
|
|
||||||
err, io);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
rockchip->io = io;
|
rockchip->io = io;
|
||||||
break;
|
break;
|
||||||
case IORESOURCE_MEM:
|
case IORESOURCE_MEM:
|
||||||
|
@ -1026,9 +1013,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
|
||||||
rockchip->mem_size = resource_size(mem);
|
rockchip->mem_size = resource_size(mem);
|
||||||
rockchip->mem_bus_addr = mem->start - win->offset;
|
rockchip->mem_bus_addr = mem->start - win->offset;
|
||||||
break;
|
break;
|
||||||
case IORESOURCE_BUS:
|
|
||||||
rockchip->root_bus_nr = win->res->start;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1036,15 +1020,14 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
err = rockchip_pcie_cfg_atu(rockchip);
|
err = rockchip_pcie_cfg_atu(rockchip);
|
||||||
if (err)
|
if (err)
|
||||||
goto err_unmap_iospace;
|
goto err_remove_irq_domain;
|
||||||
|
|
||||||
rockchip->msg_region = devm_ioremap(dev, rockchip->msg_bus_addr, SZ_1M);
|
rockchip->msg_region = devm_ioremap(dev, rockchip->msg_bus_addr, SZ_1M);
|
||||||
if (!rockchip->msg_region) {
|
if (!rockchip->msg_region) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto err_unmap_iospace;
|
goto err_remove_irq_domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
list_splice_init(&res, &bridge->windows);
|
|
||||||
bridge->dev.parent = dev;
|
bridge->dev.parent = dev;
|
||||||
bridge->sysdata = rockchip;
|
bridge->sysdata = rockchip;
|
||||||
bridge->busnr = 0;
|
bridge->busnr = 0;
|
||||||
|
@ -1054,7 +1037,7 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
err = pci_scan_root_bus_bridge(bridge);
|
err = pci_scan_root_bus_bridge(bridge);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto err_unmap_iospace;
|
goto err_remove_irq_domain;
|
||||||
|
|
||||||
bus = bridge->bus;
|
bus = bridge->bus;
|
||||||
|
|
||||||
|
@ -1068,10 +1051,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
|
||||||
pci_bus_add_devices(bus);
|
pci_bus_add_devices(bus);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_unmap_iospace:
|
|
||||||
pci_unmap_iospace(rockchip->io);
|
|
||||||
err_free_res:
|
|
||||||
pci_free_resource_list(&res);
|
|
||||||
err_remove_irq_domain:
|
err_remove_irq_domain:
|
||||||
irq_domain_remove(rockchip->irq_domain);
|
irq_domain_remove(rockchip->irq_domain);
|
||||||
err_deinit_port:
|
err_deinit_port:
|
||||||
|
@ -1097,7 +1076,6 @@ static int rockchip_pcie_remove(struct platform_device *pdev)
|
||||||
|
|
||||||
pci_stop_root_bus(rockchip->root_bus);
|
pci_stop_root_bus(rockchip->root_bus);
|
||||||
pci_remove_root_bus(rockchip->root_bus);
|
pci_remove_root_bus(rockchip->root_bus);
|
||||||
pci_unmap_iospace(rockchip->io);
|
|
||||||
irq_domain_remove(rockchip->irq_domain);
|
irq_domain_remove(rockchip->irq_domain);
|
||||||
|
|
||||||
rockchip_pcie_deinit_phys(rockchip);
|
rockchip_pcie_deinit_phys(rockchip);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче