Commit cffe00c0 authored by Andrew Murray's avatar Andrew Murray Committed by Ralf Baechle

MIPS: of/pci: Use of_pci_range_parser

This patch converts the pci_load_of_ranges function to use the new common
of_pci_range_parser.
Signed-off-by: default avatarAndrew Murray <amurray@embedded-bits.co.uk>
Signed-off-by: default avatarAndrew Murray <Andrew.Murray@arm.com>
Signed-off-by: default avatarLiviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: default avatarGabor Juhos <juhosg@openwrt.org>
Reviewed-by: default avatarRob Herring <rob.herring@calxeda.com>
Reviewed-by: default avatarGrant Likely <grant.likely@secretlab.ca>
Tested-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Cc: linux-mips@linux-mips.org
Cc: jason@lakedaemon.net
Patchwork: https://patchwork.linux-mips.org/patch/5625/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 8eae19cc
...@@ -120,51 +120,37 @@ static void pcibios_scanbus(struct pci_controller *hose) ...@@ -120,51 +120,37 @@ static void pcibios_scanbus(struct pci_controller *hose)
#ifdef CONFIG_OF #ifdef CONFIG_OF
void pci_load_of_ranges(struct pci_controller *hose, struct device_node *node) void pci_load_of_ranges(struct pci_controller *hose, struct device_node *node)
{ {
const __be32 *ranges; struct of_pci_range range;
int rlen; struct of_pci_range_parser parser;
int pna = of_n_addr_cells(node);
int np = pna + 5;
pr_info("PCI host bridge %s ranges:\n", node->full_name); pr_info("PCI host bridge %s ranges:\n", node->full_name);
ranges = of_get_property(node, "ranges", &rlen);
if (ranges == NULL)
return;
hose->of_node = node; hose->of_node = node;
while ((rlen -= np * 4) >= 0) { if (of_pci_range_parser_init(&parser, node))
u32 pci_space; return;
for_each_of_pci_range(&parser, &range) {
struct resource *res = NULL; struct resource *res = NULL;
u64 addr, size;
switch (range.flags & IORESOURCE_TYPE_BITS) {
pci_space = be32_to_cpup(&ranges[0]); case IORESOURCE_IO:
addr = of_translate_address(node, ranges + 3);
size = of_read_number(ranges + pna + 3, 2);
ranges += np;
switch ((pci_space >> 24) & 0x3) {
case 1: /* PCI IO space */
pr_info(" IO 0x%016llx..0x%016llx\n", pr_info(" IO 0x%016llx..0x%016llx\n",
addr, addr + size - 1); range.cpu_addr,
range.cpu_addr + range.size - 1);
hose->io_map_base = hose->io_map_base =
(unsigned long)ioremap(addr, size); (unsigned long)ioremap(range.cpu_addr,
range.size);
res = hose->io_resource; res = hose->io_resource;
res->flags = IORESOURCE_IO;
break; break;
case 2: /* PCI Memory space */ case IORESOURCE_MEM:
case 3: /* PCI 64 bits Memory space */
pr_info(" MEM 0x%016llx..0x%016llx\n", pr_info(" MEM 0x%016llx..0x%016llx\n",
addr, addr + size - 1); range.cpu_addr,
range.cpu_addr + range.size - 1);
res = hose->mem_resource; res = hose->mem_resource;
res->flags = IORESOURCE_MEM;
break; break;
} }
if (res != NULL) { if (res != NULL)
res->start = addr; of_pci_range_to_resource(&range, node, res);
res->name = node->full_name;
res->end = res->start + size - 1;
res->parent = NULL;
res->sibling = NULL;
res->child = NULL;
}
} }
} }
......
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