| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Routines for tracking a legacy ISA bridge |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 6 | 7 | * Some bits and pieces moved over from pci_64.c |
|---|
| 7 | 8 | * |
|---|
| 8 | 9 | * Copyrigh 2003 Anton Blanchard <anton@au.ibm.com>, IBM Corp. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is free software; you can redistribute it and/or |
|---|
| 11 | | - * modify it under the terms of the GNU General Public License |
|---|
| 12 | | - * as published by the Free Software Foundation; either version |
|---|
| 13 | | - * 2 of the License, or (at your option) any later version. |
|---|
| 14 | 10 | */ |
|---|
| 15 | 11 | |
|---|
| 16 | 12 | #define DEBUG |
|---|
| .. | .. |
|---|
| 22 | 18 | #include <linux/init.h> |
|---|
| 23 | 19 | #include <linux/mm.h> |
|---|
| 24 | 20 | #include <linux/notifier.h> |
|---|
| 21 | +#include <linux/vmalloc.h> |
|---|
| 25 | 22 | |
|---|
| 26 | 23 | #include <asm/processor.h> |
|---|
| 27 | 24 | #include <asm/io.h> |
|---|
| .. | .. |
|---|
| 41 | 38 | |
|---|
| 42 | 39 | #define ISA_SPACE_MASK 0x1 |
|---|
| 43 | 40 | #define ISA_SPACE_IO 0x1 |
|---|
| 41 | + |
|---|
| 42 | +static void remap_isa_base(phys_addr_t pa, unsigned long size) |
|---|
| 43 | +{ |
|---|
| 44 | + WARN_ON_ONCE(ISA_IO_BASE & ~PAGE_MASK); |
|---|
| 45 | + WARN_ON_ONCE(pa & ~PAGE_MASK); |
|---|
| 46 | + WARN_ON_ONCE(size & ~PAGE_MASK); |
|---|
| 47 | + |
|---|
| 48 | + if (slab_is_available()) { |
|---|
| 49 | + if (ioremap_page_range(ISA_IO_BASE, ISA_IO_BASE + size, pa, |
|---|
| 50 | + pgprot_noncached(PAGE_KERNEL))) |
|---|
| 51 | + unmap_kernel_range(ISA_IO_BASE, size); |
|---|
| 52 | + } else { |
|---|
| 53 | + early_ioremap_range(ISA_IO_BASE, pa, size, |
|---|
| 54 | + pgprot_noncached(PAGE_KERNEL)); |
|---|
| 55 | + } |
|---|
| 56 | +} |
|---|
| 44 | 57 | |
|---|
| 45 | 58 | static void pci_process_ISA_OF_ranges(struct device_node *isa_node, |
|---|
| 46 | 59 | unsigned long phb_io_base_phys) |
|---|
| .. | .. |
|---|
| 109 | 122 | if (size > 0x10000) |
|---|
| 110 | 123 | size = 0x10000; |
|---|
| 111 | 124 | |
|---|
| 112 | | - __ioremap_at(phb_io_base_phys, (void *)ISA_IO_BASE, |
|---|
| 113 | | - size, pgprot_val(pgprot_noncached(__pgprot(0)))); |
|---|
| 125 | + remap_isa_base(phb_io_base_phys, size); |
|---|
| 114 | 126 | return; |
|---|
| 115 | 127 | |
|---|
| 116 | 128 | inval_range: |
|---|
| 117 | 129 | printk(KERN_ERR "no ISA IO ranges or unexpected isa range, " |
|---|
| 118 | 130 | "mapping 64k\n"); |
|---|
| 119 | | - __ioremap_at(phb_io_base_phys, (void *)ISA_IO_BASE, |
|---|
| 120 | | - 0x10000, pgprot_val(pgprot_noncached(__pgprot(0)))); |
|---|
| 131 | + remap_isa_base(phb_io_base_phys, 0x10000); |
|---|
| 121 | 132 | } |
|---|
| 122 | 133 | |
|---|
| 123 | 134 | |
|---|
| .. | .. |
|---|
| 252 | 263 | * and map it |
|---|
| 253 | 264 | */ |
|---|
| 254 | 265 | isa_io_base = ISA_IO_BASE; |
|---|
| 255 | | - __ioremap_at(pbase, (void *)ISA_IO_BASE, |
|---|
| 256 | | - size, pgprot_val(pgprot_noncached(__pgprot(0)))); |
|---|
| 266 | + remap_isa_base(pbase, size); |
|---|
| 257 | 267 | |
|---|
| 258 | 268 | pr_debug("ISA: Non-PCI bridge is %pOF\n", np); |
|---|
| 259 | 269 | } |
|---|
| .. | .. |
|---|
| 301 | 311 | isa_bridge_pcidev = NULL; |
|---|
| 302 | 312 | |
|---|
| 303 | 313 | /* Unmap the ISA area */ |
|---|
| 304 | | - __iounmap_at((void *)ISA_IO_BASE, 0x10000); |
|---|
| 314 | + unmap_kernel_range(ISA_IO_BASE, 0x10000); |
|---|
| 305 | 315 | } |
|---|
| 306 | 316 | |
|---|
| 307 | 317 | /** |
|---|
| .. | .. |
|---|
| 327 | 337 | /* Check if we have no ISA device, and this happens to be one, |
|---|
| 328 | 338 | * register it as such if it has an OF device |
|---|
| 329 | 339 | */ |
|---|
| 330 | | - if (!isa_bridge_devnode && devnode && devnode->type && |
|---|
| 331 | | - !strcmp(devnode->type, "isa")) |
|---|
| 340 | + if (!isa_bridge_devnode && of_node_is_type(devnode, "isa")) |
|---|
| 332 | 341 | isa_bridge_find_late(pdev, devnode); |
|---|
| 333 | 342 | |
|---|
| 334 | 343 | return 0; |
|---|