1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2009 Lemote Inc.
4 * Author: Wu Zhangjin, wuzhangjin@gmail.com
7 #include <linux/irqchip.h>
8 #include <linux/logic_pio.h>
9 #include <linux/memblock.h>
11 #include <linux/of_address.h>
12 #include <asm/bootinfo.h>
13 #include <asm/traps.h>
14 #include <asm/smp-ops.h>
15 #include <asm/cacheflush.h>
16 #include <asm/fw/fw.h>
19 #include <boot_param.h>
21 #define NODE_ID_OFFSET_ADDR ((void __iomem *)TO_UNCAC(0x1001041c))
25 static void __init
mips_nmi_setup(void)
28 extern char except_vec_nmi
[];
30 base
= (void *)(CAC_BASE
+ 0x380);
31 memcpy(base
, except_vec_nmi
, 0x80);
32 flush_icache_range((unsigned long)base
, (unsigned long)base
+ 0x80);
35 void ls7a_early_config(void)
37 node_id_offset
= ((readl(NODE_ID_OFFSET_ADDR
) >> 8) & 0x1f) + 36;
40 void rs780e_early_config(void)
45 void virtual_early_config(void)
50 void __init
prom_init(void)
55 /* init base address of io space */
56 set_io_port_base(PCI_IOBASE
);
58 loongson_sysconf
.early_config();
60 prom_init_numa_memory();
62 /* Hardcode to CPU UART 0 */
63 setup_8250_early_printk_port(TO_UNCAC(LOONGSON_REG_BASE
+ 0x1e0), 0, 1024);
65 register_smp_ops(&loongson3_smp_ops
);
66 board_nmi_handler_setup
= mips_nmi_setup
;
69 void __init
prom_free_prom_memory(void)
73 static int __init
add_legacy_isa_io(struct fwnode_handle
*fwnode
, resource_size_t hw_start
,
77 struct logic_pio_hwaddr
*range
;
80 range
= kzalloc(sizeof(*range
), GFP_ATOMIC
);
84 range
->fwnode
= fwnode
;
86 range
->hw_start
= hw_start
;
87 range
->flags
= LOGIC_PIO_CPU_MMIO
;
89 ret
= logic_pio_register_range(range
);
95 /* Legacy ISA must placed at the start of PCI_IOBASE */
96 if (range
->io_start
!= 0) {
97 logic_pio_unregister_range(range
);
102 vaddr
= PCI_IOBASE
+ range
->io_start
;
104 ioremap_page_range(vaddr
, vaddr
+ size
, hw_start
, pgprot_device(PAGE_KERNEL
));
109 static __init
void reserve_pio_range(void)
111 struct device_node
*np
;
113 for_each_node_by_name(np
, "isa") {
114 struct of_range range
;
115 struct of_range_parser parser
;
117 pr_info("ISA Bridge: %pOF\n", np
);
119 if (of_range_parser_init(&parser
, np
)) {
120 pr_info("Failed to parse resources.\n");
124 for_each_of_range(&parser
, &range
) {
125 switch (range
.flags
& IORESOURCE_TYPE_BITS
) {
127 pr_info(" IO 0x%016llx..0x%016llx -> 0x%016llx\n",
129 range
.cpu_addr
+ range
.size
- 1,
131 if (add_legacy_isa_io(&np
->fwnode
, range
.cpu_addr
, range
.size
))
132 pr_warn("Failed to reserve legacy IO in Logic PIO\n");
135 pr_info(" MEM 0x%016llx..0x%016llx -> 0x%016llx\n",
137 range
.cpu_addr
+ range
.size
- 1,
145 void __init
arch_init_irq(void)