This source file includes following definitions.
- xlp_wakeup_core
- wait_for_cpus
- xlp_enable_secondary_cores
- xlp_wakeup_secondary_cpus
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 #include <linux/kernel.h>
36 #include <linux/threads.h>
37
38 #include <asm/asm.h>
39 #include <asm/asm-offsets.h>
40 #include <asm/mipsregs.h>
41 #include <asm/addrspace.h>
42 #include <asm/string.h>
43
44 #include <asm/netlogic/haldefs.h>
45 #include <asm/netlogic/common.h>
46 #include <asm/netlogic/mips-extns.h>
47
48 #include <asm/netlogic/xlp-hal/iomap.h>
49 #include <asm/netlogic/xlp-hal/xlp.h>
50 #include <asm/netlogic/xlp-hal/pic.h>
51 #include <asm/netlogic/xlp-hal/sys.h>
52
53 static int xlp_wakeup_core(uint64_t sysbase, int node, int core)
54 {
55 uint32_t coremask, value;
56 int count, resetreg;
57
58 coremask = (1 << core);
59
60
61 if (!cpu_is_xlpii()) {
62 value = nlm_read_sys_reg(sysbase, SYS_CORE_DFS_DIS_CTRL);
63 value &= ~coremask;
64 nlm_write_sys_reg(sysbase, SYS_CORE_DFS_DIS_CTRL, value);
65 }
66
67
68 if (cpu_is_xlp9xx()) {
69 value = nlm_read_sys_reg(sysbase, SYS_9XX_CPU_NONCOHERENT_MODE);
70 value &= ~coremask;
71 nlm_write_sys_reg(sysbase, SYS_9XX_CPU_NONCOHERENT_MODE, value);
72 }
73
74
75 resetreg = cpu_is_xlp9xx() ? SYS_9XX_CPU_RESET : SYS_CPU_RESET;
76 value = nlm_read_sys_reg(sysbase, resetreg);
77 value &= ~coremask;
78 nlm_write_sys_reg(sysbase, resetreg, value);
79
80
81 if (cpu_is_xlp9xx())
82 return 1;
83
84
85 count = 100000;
86 do {
87 value = nlm_read_sys_reg(sysbase, SYS_CPU_NONCOHERENT_MODE);
88 } while ((value & coremask) != 0 && --count > 0);
89
90 return count != 0;
91 }
92
93 static int wait_for_cpus(int cpu, int bootcpu)
94 {
95 volatile uint32_t *cpu_ready = nlm_get_boot_data(BOOT_CPU_READY);
96 int i, count, notready;
97
98 count = 0x800000;
99 do {
100 notready = nlm_threads_per_core;
101 for (i = 0; i < nlm_threads_per_core; i++)
102 if (cpu_ready[cpu + i] || (cpu + i) == bootcpu)
103 --notready;
104 } while (notready != 0 && --count > 0);
105
106 return count != 0;
107 }
108
109 static void xlp_enable_secondary_cores(const cpumask_t *wakeup_mask)
110 {
111 struct nlm_soc_info *nodep;
112 uint64_t syspcibase, fusebase;
113 uint32_t syscoremask, mask, fusemask;
114 int core, n, cpu, ncores;
115
116 for (n = 0; n < NLM_NR_NODES; n++) {
117 if (n != 0) {
118
119 if (cpu_is_xlp9xx()) {
120 int b = xlp9xx_get_socbus(n);
121 pr_info("Node %d SoC PCI bus %d.\n", n, b);
122 if (b == 0)
123 break;
124 } else {
125 syspcibase = nlm_get_sys_pcibase(n);
126 if (nlm_read_reg(syspcibase, 0) == 0xffffffff)
127 break;
128 }
129 nlm_node_init(n);
130 }
131
132
133 nodep = nlm_get_node(n);
134
135 if (cpu_is_xlp9xx()) {
136 fusebase = nlm_get_fuse_regbase(n);
137 fusemask = nlm_read_reg(fusebase, FUSE_9XX_DEVCFG6);
138 switch (read_c0_prid() & PRID_IMP_MASK) {
139 case PRID_IMP_NETLOGIC_XLP5XX:
140 mask = 0xff;
141 break;
142 case PRID_IMP_NETLOGIC_XLP9XX:
143 default:
144 mask = 0xfffff;
145 break;
146 }
147 } else {
148 fusemask = nlm_read_sys_reg(nodep->sysbase,
149 SYS_EFUSE_DEVICE_CFG_STATUS0);
150 switch (read_c0_prid() & PRID_IMP_MASK) {
151 case PRID_IMP_NETLOGIC_XLP3XX:
152 mask = 0xf;
153 break;
154 case PRID_IMP_NETLOGIC_XLP2XX:
155 mask = 0x3;
156 break;
157 case PRID_IMP_NETLOGIC_XLP8XX:
158 default:
159 mask = 0xff;
160 break;
161 }
162 }
163
164
165
166
167
168 syscoremask = (1 << hweight32(~fusemask & mask)) - 1;
169
170 pr_info("Node %d - SYS/FUSE coremask %x\n", n, syscoremask);
171 ncores = nlm_cores_per_node();
172 for (core = 0; core < ncores; core++) {
173
174 if (n == 0 && core == 0)
175 continue;
176
177
178 if ((syscoremask & (1 << core)) == 0)
179 continue;
180
181
182 cpu = (n * ncores + core) * NLM_THREADS_PER_CORE;
183 if (!cpumask_test_cpu(cpu, wakeup_mask))
184 continue;
185
186
187 if (!xlp_wakeup_core(nodep->sysbase, n, core))
188 continue;
189
190
191 nodep->coremask |= 1u << core;
192
193
194 if (!wait_for_cpus(cpu, 0))
195 pr_err("Node %d : timeout core %d\n", n, core);
196 }
197 }
198 }
199
200 void xlp_wakeup_secondary_cpus(void)
201 {
202
203
204
205
206 xlp_boot_core0_siblings();
207 if (!wait_for_cpus(0, 0))
208 pr_err("Node 0 : timeout core 0\n");
209
210
211 xlp_enable_secondary_cores(&nlm_cpumask);
212 }