hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/arch/powerpc/kernel/isa-bridge.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Routines for tracking a legacy ISA bridge
34 *
....@@ -6,11 +7,6 @@
67 * Some bits and pieces moved over from pci_64.c
78 *
89 * 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.
1410 */
1511
1612 #define DEBUG
....@@ -22,6 +18,7 @@
2218 #include <linux/init.h>
2319 #include <linux/mm.h>
2420 #include <linux/notifier.h>
21
+#include <linux/vmalloc.h>
2522
2623 #include <asm/processor.h>
2724 #include <asm/io.h>
....@@ -41,6 +38,22 @@
4138
4239 #define ISA_SPACE_MASK 0x1
4340 #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
+}
4457
4558 static void pci_process_ISA_OF_ranges(struct device_node *isa_node,
4659 unsigned long phb_io_base_phys)
....@@ -109,15 +122,13 @@
109122 if (size > 0x10000)
110123 size = 0x10000;
111124
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);
114126 return;
115127
116128 inval_range:
117129 printk(KERN_ERR "no ISA IO ranges or unexpected isa range, "
118130 "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);
121132 }
122133
123134
....@@ -252,8 +263,7 @@
252263 * and map it
253264 */
254265 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);
257267
258268 pr_debug("ISA: Non-PCI bridge is %pOF\n", np);
259269 }
....@@ -301,7 +311,7 @@
301311 isa_bridge_pcidev = NULL;
302312
303313 /* Unmap the ISA area */
304
- __iounmap_at((void *)ISA_IO_BASE, 0x10000);
314
+ unmap_kernel_range(ISA_IO_BASE, 0x10000);
305315 }
306316
307317 /**
....@@ -327,8 +337,7 @@
327337 /* Check if we have no ISA device, and this happens to be one,
328338 * register it as such if it has an OF device
329339 */
330
- if (!isa_bridge_devnode && devnode && devnode->type &&
331
- !strcmp(devnode->type, "isa"))
340
+ if (!isa_bridge_devnode && of_node_is_type(devnode, "isa"))
332341 isa_bridge_find_late(pdev, devnode);
333342
334343 return 0;