Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
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. | |
5 | * | |
6 | * Copyright (C) 2000 - 2001 by Kanoj Sarcar (kanoj@sgi.com) | |
7 | * Copyright (C) 2000 - 2001 by Silicon Graphics, Inc. | |
8 | */ | |
1da177e4 LT |
9 | #include <linux/kernel.h> |
10 | #include <linux/init.h> | |
11 | #include <linux/sched.h> | |
631330f5 | 12 | #include <linux/smp.h> |
1da177e4 | 13 | #include <linux/mm.h> |
26dd3e4f | 14 | #include <linux/export.h> |
1da177e4 | 15 | #include <linux/cpumask.h> |
e9422427 | 16 | #include <asm/bootinfo.h> |
1da177e4 LT |
17 | #include <asm/cpu.h> |
18 | #include <asm/io.h> | |
19 | #include <asm/pgtable.h> | |
e9422427 | 20 | #include <asm/sgialib.h> |
1da177e4 LT |
21 | #include <asm/time.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> | |
1da177e4 LT |
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> | |
40 | ||
249be563 TB |
41 | #include "ip27-common.h" |
42 | ||
1da177e4 LT |
43 | #define CPU_NONE (cpuid_t)-1 |
44 | ||
c80b4896 | 45 | static DECLARE_BITMAP(hub_init_mask, MAX_NUMNODES); |
1da177e4 LT |
46 | nasid_t master_nasid = INVALID_NASID; |
47 | ||
cc6e8e08 RB |
48 | struct cpuinfo_ip27 sn_cpu_info[NR_CPUS]; |
49 | EXPORT_SYMBOL_GPL(sn_cpu_info); | |
50 | ||
4bf841eb | 51 | static void per_hub_init(nasid_t nasid) |
1da177e4 | 52 | { |
4bf841eb | 53 | struct hub_data *hub = hub_data(nasid); |
1da177e4 | 54 | |
8dd92891 | 55 | cpumask_set_cpu(smp_processor_id(), &hub->h_cpus); |
1da177e4 | 56 | |
4bf841eb | 57 | if (test_and_set_bit(nasid, hub_init_mask)) |
1da177e4 | 58 | return; |
1da177e4 LT |
59 | /* |
60 | * Set CRB timeout at 5ms, (< PI timeout of 10ms) | |
61 | */ | |
62 | REMOTE_HUB_S(nasid, IIO_ICTP, 0x800); | |
63 | REMOTE_HUB_S(nasid, IIO_ICTO, 0xff); | |
64 | ||
4bf841eb | 65 | hub_rtc_init(nasid); |
1da177e4 | 66 | |
63734674 TB |
67 | if (nasid) { |
68 | /* copy exception handlers from first node to current node */ | |
69 | memcpy((void *)NODE_OFFSET_TO_K0(nasid, 0), | |
70 | (void *)CKSEG0, 0x200); | |
1da177e4 | 71 | __flush_cache_all(); |
63734674 TB |
72 | /* switch to node local exception handlers */ |
73 | REMOTE_HUB_S(nasid, PI_CALIAS_SIZE, PI_CALIAS_SIZE_8K); | |
1da177e4 | 74 | } |
1da177e4 LT |
75 | } |
76 | ||
078a55fc | 77 | void per_cpu_init(void) |
1da177e4 LT |
78 | { |
79 | int cpu = smp_processor_id(); | |
80 | int slice = LOCAL_HUB_L(PI_CPU_NUM); | |
4bf841eb TB |
81 | nasid_t nasid = get_nasid(); |
82 | struct hub_data *hub = hub_data(nasid); | |
1da177e4 LT |
83 | |
84 | if (test_and_set_bit(slice, &hub->slice_map)) | |
85 | return; | |
86 | ||
87 | clear_c0_status(ST0_IM); | |
88 | ||
4bf841eb | 89 | per_hub_init(nasid); |
4f12bfe5 | 90 | |
1da177e4 LT |
91 | cpu_time_init(); |
92 | install_ipi(); | |
93 | ||
94 | /* Install our NMI handler if symmon hasn't installed one. */ | |
95 | install_cpu_nmi_handler(cputoslice(cpu)); | |
96 | ||
69a07a41 TB |
97 | enable_percpu_irq(IP27_HUB_PEND0_IRQ, IRQ_TYPE_NONE); |
98 | enable_percpu_irq(IP27_HUB_PEND1_IRQ, IRQ_TYPE_NONE); | |
1da177e4 LT |
99 | } |
100 | ||
101 | /* | |
102 | * get_nasid() returns the physical node id number of the caller. | |
103 | */ | |
104 | nasid_t | |
105 | get_nasid(void) | |
106 | { | |
107 | return (nasid_t)((LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_NODEID_MASK) | |
70342287 | 108 | >> NSRI_NODEID_SHFT); |
1da177e4 LT |
109 | } |
110 | ||
2925aba4 | 111 | void __init plat_mem_setup(void) |
1da177e4 | 112 | { |
db0e7d4e | 113 | u64 p, e, n_mode; |
1da177e4 LT |
114 | nasid_t nid; |
115 | ||
c823f416 TB |
116 | register_smp_ops(&ip27_smp_ops); |
117 | ||
1da177e4 LT |
118 | ip27_reboot_setup(); |
119 | ||
120 | /* | |
121 | * hub_rtc init and cpu clock intr enabled for later calibrate_delay. | |
122 | */ | |
123 | nid = get_nasid(); | |
124 | printk("IP27: Running on node %d.\n", nid); | |
125 | ||
126 | p = LOCAL_HUB_L(PI_CPU_PRESENT_A) & 1; | |
127 | e = LOCAL_HUB_L(PI_CPU_ENABLE_A) & 1; | |
128 | printk("Node %d has %s primary CPU%s.\n", nid, | |
129 | p ? "a" : "no", | |
130 | e ? ", CPU is running" : ""); | |
131 | ||
132 | p = LOCAL_HUB_L(PI_CPU_PRESENT_B) & 1; | |
133 | e = LOCAL_HUB_L(PI_CPU_ENABLE_B) & 1; | |
134 | printk("Node %d has %s secondary CPU%s.\n", nid, | |
135 | p ? "a" : "no", | |
136 | e ? ", CPU is running" : ""); | |
137 | ||
138 | /* | |
139 | * Try to catch kernel missconfigurations and give user an | |
140 | * indication what option to select. | |
141 | */ | |
142 | n_mode = LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_MORENODES_MASK; | |
143 | printk("Machine is in %c mode.\n", n_mode ? 'N' : 'M'); | |
aa9772e3 | 144 | #ifdef CONFIG_SGI_SN_N_MODE |
1da177e4 LT |
145 | if (!n_mode) |
146 | panic("Kernel compiled for M mode."); | |
147 | #else | |
148 | if (n_mode) | |
149 | panic("Kernel compiled for N mode."); | |
150 | #endif | |
151 | ||
a57140e9 TB |
152 | ioport_resource.start = 0; |
153 | ioport_resource.end = ~0UL; | |
1da177e4 | 154 | set_io_port_base(IO_BASE); |
1da177e4 | 155 | } |
e9422427 TB |
156 | |
157 | const char *get_system_type(void) | |
158 | { | |
159 | return "SGI Origin"; | |
160 | } | |
161 | ||
162 | void __init prom_init(void) | |
163 | { | |
164 | prom_init_cmdline(fw_arg0, (LONG *)fw_arg1); | |
165 | prom_meminit(); | |
166 | } | |
167 |