loongson-community / linux-wip

Playground for Linux/Loongson upstream work
Other
3 stars 0 forks source link

DeviceTree ISA Node Issue #4

Open FlyGoat opened 4 years ago

FlyGoat commented 4 years ago

DeviceTree ISA Node is currently broken, actually, device drivers can never get proper I/O Port from DeviceTree. That's due to ISA Node is not currently tracked by Logic_PIO subsystem. But OF I/O Port address translation rely on Logic_PIO.

To fix it, we need to replace arch/mips/loongson64/init.c


static __init void reserve_pio_range(void)
{
    struct logic_pio_hwaddr *range;

    range = kzalloc(sizeof(*range), GFP_ATOMIC);
    if (!range)
        return;

    range->fwnode = &of_root->fwnode;
    range->size = MMIO_LOWER_RESERVED;
    range->hw_start = LOONGSON_PCIIO_BASE;
    range->flags = LOGIC_PIO_CPU_MMIO;

    if (logic_pio_register_range(range)) {
        pr_err("Failed to reserve PIO range for legacy ISA\n");
        goto free_range;
    }

    if (WARN(range->io_start != 0,
            "Reserved PIO range does not start from 0\n"))
        goto unregister;

    /*
     * i8259 would access I/O space, so mapping must be done here.
     * Please remove it when all drivers can be managed by logic_pio.
     */
    ioremap_page_range(PCI_IOBASE, PCI_IOBASE + MMIO_LOWER_RESERVED,
                LOONGSON_PCIIO_BASE,
                pgprot_device(PAGE_KERNEL));

    return;
unregister:
    logic_pio_unregister_range(range);
free_range:
    kfree(range);
}

With some sort of code looking for ISA Bridge node and add it to Logic_PIO subsystem.

FlyGoat commented 4 years ago

Blocks: #3