Skip to content

Commit ea4f718

Browse files
robherringLorenzo Pieralisi
authored andcommitted
PCI: ftpci100: Use inbound resources for setup
Now that the helpers provide the inbound resources in the host bridge 'dma_ranges' resource list, convert Faraday ftpci100 host bridge to use the resource list to setup the inbound addresses. Signed-off-by: Rob Herring <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Reviewed-by: Andrew Murray <[email protected]> Acked-by: Linus Walleij <[email protected]> Cc: Lorenzo Pieralisi <[email protected]> Cc: Bjorn Helgaas <[email protected]>
1 parent 331f634 commit ea4f718

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

drivers/pci/controller/pci-ftpci100.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,11 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p)
375375
return 0;
376376
}
377377

378-
static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p,
379-
struct device_node *np)
378+
static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p)
380379
{
381-
struct of_pci_range range;
382-
struct of_pci_range_parser parser;
383380
struct device *dev = p->dev;
381+
struct pci_host_bridge *bridge = pci_host_bridge_from_priv(p);
382+
struct resource_entry *entry;
384383
u32 confreg[3] = {
385384
FARADAY_PCI_MEM1_BASE_SIZE,
386385
FARADAY_PCI_MEM2_BASE_SIZE,
@@ -389,27 +388,21 @@ static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p,
389388
int i = 0;
390389
u32 val;
391390

392-
if (of_pci_dma_range_parser_init(&parser, np)) {
393-
dev_err(dev, "missing dma-ranges property\n");
394-
return -EINVAL;
395-
}
396-
397-
/*
398-
* Get the dma-ranges from the device tree
399-
*/
400-
for_each_of_pci_range(&parser, &range) {
401-
u64 end = range.pci_addr + range.size - 1;
391+
resource_list_for_each_entry(entry, &bridge->dma_ranges) {
392+
u64 pci_addr = entry->res->start - entry->offset;
393+
u64 end = entry->res->end - entry->offset;
402394
int ret;
403395

404-
ret = faraday_res_to_memcfg(range.pci_addr, range.size, &val);
396+
ret = faraday_res_to_memcfg(pci_addr,
397+
resource_size(entry->res), &val);
405398
if (ret) {
406399
dev_err(dev,
407400
"DMA range %d: illegal MEM resource size\n", i);
408401
return -EINVAL;
409402
}
410403

411404
dev_info(dev, "DMA MEM%d BASE: 0x%016llx -> 0x%016llx config %08x\n",
412-
i + 1, range.pci_addr, end, val);
405+
i + 1, pci_addr, end, val);
413406
if (i <= 2) {
414407
faraday_raw_pci_write_config(p, 0, 0, confreg[i],
415408
4, val);
@@ -539,7 +532,7 @@ static int faraday_pci_probe(struct platform_device *pdev)
539532
cur_bus_speed = PCI_SPEED_66MHz;
540533
}
541534

542-
ret = faraday_pci_parse_map_dma_ranges(p, dev->of_node);
535+
ret = faraday_pci_parse_map_dma_ranges(p);
543536
if (ret)
544537
return ret;
545538

0 commit comments

Comments
 (0)