xref: /openbmc/linux/arch/mips/loongson64/init.c (revision d8242e6a71bac37b6cde52c0add533615eef8c5e)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (C) 2009 Lemote Inc.
4  * Author: Wu Zhangjin, wuzhangjin@gmail.com
5  */
6 
7 #include <linux/irqchip.h>
8 #include <linux/memblock.h>
9 #include <asm/bootinfo.h>
10 #include <asm/traps.h>
11 #include <asm/smp-ops.h>
12 #include <asm/cacheflush.h>
13 #include <asm/fw/fw.h>
14 
15 #include <loongson.h>
16 #include <boot_param.h>
17 
18 #define NODE_ID_OFFSET_ADDR	((void __iomem *)TO_UNCAC(0x1001041c))
19 
20 u32 node_id_offset;
21 
22 static void __init mips_nmi_setup(void)
23 {
24 	void *base;
25 	extern char except_vec_nmi[];
26 
27 	base = (void *)(CAC_BASE + 0x380);
28 	memcpy(base, except_vec_nmi, 0x80);
29 	flush_icache_range((unsigned long)base, (unsigned long)base + 0x80);
30 }
31 
32 void ls7a_early_config(void)
33 {
34 	node_id_offset = ((readl(NODE_ID_OFFSET_ADDR) >> 8) & 0x1f) + 36;
35 }
36 
37 void rs780e_early_config(void)
38 {
39 	node_id_offset = 37;
40 }
41 
42 void __init prom_init(void)
43 {
44 	fw_init_cmdline();
45 	prom_init_env();
46 
47 	/* init base address of io space */
48 	set_io_port_base((unsigned long)
49 		ioremap(LOONGSON_PCIIO_BASE, LOONGSON_PCIIO_SIZE));
50 
51 	loongson_sysconf.early_config();
52 
53 	prom_init_numa_memory();
54 
55 	/* Hardcode to CPU UART 0 */
56 	setup_8250_early_printk_port(TO_UNCAC(LOONGSON_REG_BASE + 0x1e0), 0, 1024);
57 
58 	register_smp_ops(&loongson3_smp_ops);
59 	board_nmi_handler_setup = mips_nmi_setup;
60 }
61 
62 void __init prom_free_prom_memory(void)
63 {
64 }
65 
66 void __init arch_init_irq(void)
67 {
68 	irqchip_init();
69 }
70