Skip to content

Commit 482cd90

Browse files
FlyGoattsbogend
authored andcommitted
MIPS: Loongson64: Define PCI_IOBASE
PCI_IOBASE is used to create VM maps for PCI I/O ports, it is required by generic PCI drivers to make memory mapped I/O range work. To deal with legacy drivers that have fixed I/O ports range we reserved 0x10000 in PCI_IOBASE, should be enough for i8259 i8042 stuff. Signed-off-by: Jiaxun Yang <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent a202bf7 commit 482cd90

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

arch/mips/include/asm/mach-loongson64/spaces.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,13 @@
66
#define CAC_BASE _AC(0x9800000000000000, UL)
77
#endif /* CONFIG_64BIT */
88

9+
/* Skip 128k to trap NULL pointer dereferences */
10+
#define PCI_IOBASE _AC(0xc000000000000000 + SZ_128K, UL)
11+
#define PCI_IOSIZE SZ_16M
12+
#define MAP_BASE (PCI_IOBASE + PCI_IOSIZE)
13+
14+
/* Reserved at the start of PCI_IOBASE for legacy drivers */
15+
#define MMIO_LOWER_RESERVED 0x10000
16+
917
#include <asm/mach-generic/spaces.h>
1018
#endif

arch/mips/loongson64/init.c

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#include <linux/irqchip.h>
8+
#include <linux/logic_pio.h>
89
#include <linux/memblock.h>
910
#include <asm/bootinfo.h>
1011
#include <asm/traps.h>
@@ -45,8 +46,7 @@ void __init prom_init(void)
4546
prom_init_env();
4647

4748
/* init base address of io space */
48-
set_io_port_base((unsigned long)
49-
ioremap(LOONGSON_PCIIO_BASE, LOONGSON_PCIIO_SIZE));
49+
set_io_port_base(PCI_IOBASE);
5050

5151
loongson_sysconf.early_config();
5252

@@ -63,7 +63,45 @@ void __init prom_free_prom_memory(void)
6363
{
6464
}
6565

66+
static __init void reserve_pio_range(void)
67+
{
68+
struct logic_pio_hwaddr *range;
69+
70+
range = kzalloc(sizeof(*range), GFP_ATOMIC);
71+
if (!range)
72+
return;
73+
74+
range->fwnode = &of_root->fwnode;
75+
range->size = MMIO_LOWER_RESERVED;
76+
range->hw_start = LOONGSON_PCIIO_BASE;
77+
range->flags = LOGIC_PIO_CPU_MMIO;
78+
79+
if (logic_pio_register_range(range)) {
80+
pr_err("Failed to reserve PIO range for legacy ISA\n");
81+
goto free_range;
82+
}
83+
84+
if (WARN(range->io_start != 0,
85+
"Reserved PIO range does not start from 0\n"))
86+
goto unregister;
87+
88+
/*
89+
* i8259 would access I/O space, so mapping must be done here.
90+
* Please remove it when all drivers can be managed by logic_pio.
91+
*/
92+
ioremap_page_range(PCI_IOBASE, PCI_IOBASE + MMIO_LOWER_RESERVED,
93+
LOONGSON_PCIIO_BASE,
94+
pgprot_device(PAGE_KERNEL));
95+
96+
return;
97+
unregister:
98+
logic_pio_unregister_range(range);
99+
free_range:
100+
kfree(range);
101+
}
102+
66103
void __init arch_init_irq(void)
67104
{
105+
reserve_pio_range();
68106
irqchip_init();
69107
}

0 commit comments

Comments
 (0)