2 * This file is subject to the terms and conditions of the GNU General
3 * Public License. See the file "COPYING" in the main directory of this
4 * archive for more details.
6 * Copyright (C) 2000 - 2001 by Kanoj Sarcar (kanoj@sgi.com)
7 * Copyright (C) 2000 - 2001 by Silicon Graphics, Inc.
9 #include <linux/kernel.h>
10 #include <linux/init.h>
11 #include <linux/sched.h>
12 #include <linux/smp.h>
14 #include <linux/export.h>
15 #include <linux/cpumask.h>
16 #include <asm/bootinfo.h>
19 #include <asm/pgtable.h>
20 #include <asm/sgialib.h>
22 #include <asm/sn/types.h>
23 #include <asm/sn/sn0/addrs.h>
24 #include <asm/sn/sn0/hubni.h>
25 #include <asm/sn/sn0/hubio.h>
26 #include <asm/sn/klconfig.h>
27 #include <asm/sn/ioc3.h>
28 #include <asm/mipsregs.h>
29 #include <asm/sn/gda.h>
30 #include <asm/sn/hub.h>
31 #include <asm/sn/intr.h>
32 #include <asm/current.h>
33 #include <asm/processor.h>
34 #include <asm/mmu_context.h>
35 #include <asm/thread_info.h>
36 #include <asm/sn/launch.h>
37 #include <asm/sn/sn_private.h>
38 #include <asm/sn/sn0/ip27.h>
39 #include <asm/sn/mapped_kernel.h>
41 #include "ip27-common.h"
43 #define CPU_NONE (cpuid_t)-1
45 static DECLARE_BITMAP(hub_init_mask, MAX_NUMNODES);
46 nasid_t master_nasid = INVALID_NASID;
48 struct cpuinfo_ip27 sn_cpu_info[NR_CPUS];
49 EXPORT_SYMBOL_GPL(sn_cpu_info);
51 static void per_hub_init(nasid_t nasid)
53 struct hub_data *hub = hub_data(nasid);
55 cpumask_set_cpu(smp_processor_id(), &hub->h_cpus);
57 if (test_and_set_bit(nasid, hub_init_mask))
60 * Set CRB timeout at 5ms, (< PI timeout of 10ms)
62 REMOTE_HUB_S(nasid, IIO_ICTP, 0x800);
63 REMOTE_HUB_S(nasid, IIO_ICTO, 0xff);
67 #ifdef CONFIG_REPLICATE_EXHANDLERS
69 * If this is not a headless node initialization,
70 * copy over the caliased exception handlers.
72 if (get_nasid() == nasid) {
73 extern char except_vec2_generic, except_vec3_generic;
74 extern void build_tlb_refill_handler(void);
76 memcpy((void *)(CKSEG0 + 0x100), &except_vec2_generic, 0x80);
77 memcpy((void *)(CKSEG0 + 0x180), &except_vec3_generic, 0x80);
78 build_tlb_refill_handler();
79 memcpy((void *)(CKSEG0 + 0x100), (void *) CKSEG0, 0x80);
80 memcpy((void *)(CKSEG0 + 0x180), &except_vec3_generic, 0x100);
86 void per_cpu_init(void)
88 int cpu = smp_processor_id();
89 int slice = LOCAL_HUB_L(PI_CPU_NUM);
90 nasid_t nasid = get_nasid();
91 struct hub_data *hub = hub_data(nasid);
93 if (test_and_set_bit(slice, &hub->slice_map))
96 clear_c0_status(ST0_IM);
103 /* Install our NMI handler if symmon hasn't installed one. */
104 install_cpu_nmi_handler(cputoslice(cpu));
106 enable_percpu_irq(IP27_HUB_PEND0_IRQ, IRQ_TYPE_NONE);
107 enable_percpu_irq(IP27_HUB_PEND1_IRQ, IRQ_TYPE_NONE);
111 * get_nasid() returns the physical node id number of the caller.
116 return (nasid_t)((LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_NODEID_MASK)
117 >> NSRI_NODEID_SHFT);
120 void __init plat_mem_setup(void)
125 register_smp_ops(&ip27_smp_ops);
130 * hub_rtc init and cpu clock intr enabled for later calibrate_delay.
133 printk("IP27: Running on node %d.\n", nid);
135 p = LOCAL_HUB_L(PI_CPU_PRESENT_A) & 1;
136 e = LOCAL_HUB_L(PI_CPU_ENABLE_A) & 1;
137 printk("Node %d has %s primary CPU%s.\n", nid,
139 e ? ", CPU is running" : "");
141 p = LOCAL_HUB_L(PI_CPU_PRESENT_B) & 1;
142 e = LOCAL_HUB_L(PI_CPU_ENABLE_B) & 1;
143 printk("Node %d has %s secondary CPU%s.\n", nid,
145 e ? ", CPU is running" : "");
148 * Try to catch kernel missconfigurations and give user an
149 * indication what option to select.
151 n_mode = LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_MORENODES_MASK;
152 printk("Machine is in %c mode.\n", n_mode ? 'N' : 'M');
153 #ifdef CONFIG_SGI_SN_N_MODE
155 panic("Kernel compiled for M mode.");
158 panic("Kernel compiled for N mode.");
161 ioport_resource.start = 0;
162 ioport_resource.end = ~0UL;
163 set_io_port_base(IO_BASE);
166 const char *get_system_type(void)
171 void __init prom_init(void)
173 prom_init_cmdline(fw_arg0, (LONG *)fw_arg1);