Commit 6d0068ad authored by Jiaxun Yang's avatar Jiaxun Yang Committed by Thomas Bogendoerfer

MIPS: Loongson64: Process ISA Node in DeviceTree

Previously, we're hardcoding reserved ISA I/O Space in, now
we're processing it I/O via DeviceTree directly.
The ranges property if ISA node is used to determine the size and address
of reserved I/O space.
Signed-off-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
parent 2f96593e
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <linux/irqchip.h> #include <linux/irqchip.h>
#include <linux/logic_pio.h> #include <linux/logic_pio.h>
#include <linux/memblock.h> #include <linux/memblock.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <asm/bootinfo.h> #include <asm/bootinfo.h>
#include <asm/traps.h> #include <asm/traps.h>
#include <asm/smp-ops.h> #include <asm/smp-ops.h>
...@@ -63,41 +65,76 @@ void __init prom_free_prom_memory(void) ...@@ -63,41 +65,76 @@ void __init prom_free_prom_memory(void)
{ {
} }
static __init void reserve_pio_range(void) static int __init add_legacy_isa_io(struct fwnode_handle *fwnode, resource_size_t hw_start,
resource_size_t size)
{ {
int ret = 0;
struct logic_pio_hwaddr *range; struct logic_pio_hwaddr *range;
unsigned long vaddr;
range = kzalloc(sizeof(*range), GFP_ATOMIC); range = kzalloc(sizeof(*range), GFP_ATOMIC);
if (!range) if (!range)
return; return -ENOMEM;
range->fwnode = &of_root->fwnode; range->fwnode = fwnode;
range->size = MMIO_LOWER_RESERVED; range->size = size;
range->hw_start = LOONGSON_PCIIO_BASE; range->hw_start = hw_start;
range->flags = LOGIC_PIO_CPU_MMIO; range->flags = LOGIC_PIO_CPU_MMIO;
if (logic_pio_register_range(range)) { ret = logic_pio_register_range(range);
pr_err("Failed to reserve PIO range for legacy ISA\n"); if (ret) {
goto free_range; kfree(range);
return ret;
}
/* Legacy ISA must placed at the start of PCI_IOBASE */
if (range->io_start != 0) {
logic_pio_unregister_range(range);
kfree(range);
return -EINVAL;
} }
if (WARN(range->io_start != 0, vaddr = PCI_IOBASE + range->io_start;
"Reserved PIO range does not start from 0\n"))
goto unregister; ioremap_page_range(vaddr, vaddr + size, hw_start, pgprot_device(PAGE_KERNEL));
/* return 0;
* i8259 would access I/O space, so mapping must be done here. }
* Please remove it when all drivers can be managed by logic_pio.
*/ static __init void reserve_pio_range(void)
ioremap_page_range(PCI_IOBASE, PCI_IOBASE + MMIO_LOWER_RESERVED, {
LOONGSON_PCIIO_BASE, struct device_node *np;
pgprot_device(PAGE_KERNEL));
for_each_node_by_name(np, "isa") {
return; struct of_range range;
unregister: struct of_range_parser parser;
logic_pio_unregister_range(range);
free_range: pr_info("ISA Bridge: %pOF\n", np);
kfree(range);
if (of_range_parser_init(&parser, np)) {
pr_info("Failed to parse resources.\n");
break;
}
for_each_of_range(&parser, &range) {
switch (range.flags & IORESOURCE_TYPE_BITS) {
case IORESOURCE_IO:
pr_info(" IO 0x%016llx..0x%016llx -> 0x%016llx\n",
range.cpu_addr,
range.cpu_addr + range.size - 1,
range.bus_addr);
if (add_legacy_isa_io(&np->fwnode, range.cpu_addr, range.size))
pr_warn("Failed to reserve legacy IO in Logic PIO\n");
break;
case IORESOURCE_MEM:
pr_info(" MEM 0x%016llx..0x%016llx -> 0x%016llx\n",
range.cpu_addr,
range.cpu_addr + range.size - 1,
range.bus_addr);
break;
}
}
}
} }
void __init arch_init_irq(void) void __init arch_init_irq(void)
......
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