cpu.c revision 1.9.2.6 1 1.9.2.6 nathanw /* $NetBSD: cpu.c,v 1.9.2.6 2002/06/20 03:38:03 nathanw Exp $ */
2 1.9.2.2 nathanw
3 1.9.2.2 nathanw /*
4 1.9.2.2 nathanw * Copyright (c) 1995 Mark Brinicombe.
5 1.9.2.2 nathanw * Copyright (c) 1995 Brini.
6 1.9.2.2 nathanw * All rights reserved.
7 1.9.2.2 nathanw *
8 1.9.2.2 nathanw * Redistribution and use in source and binary forms, with or without
9 1.9.2.2 nathanw * modification, are permitted provided that the following conditions
10 1.9.2.2 nathanw * are met:
11 1.9.2.2 nathanw * 1. Redistributions of source code must retain the above copyright
12 1.9.2.2 nathanw * notice, this list of conditions and the following disclaimer.
13 1.9.2.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
14 1.9.2.2 nathanw * notice, this list of conditions and the following disclaimer in the
15 1.9.2.2 nathanw * documentation and/or other materials provided with the distribution.
16 1.9.2.2 nathanw * 3. All advertising materials mentioning features or use of this software
17 1.9.2.2 nathanw * must display the following acknowledgement:
18 1.9.2.2 nathanw * This product includes software developed by Brini.
19 1.9.2.2 nathanw * 4. The name of the company nor the name of the author may be used to
20 1.9.2.2 nathanw * endorse or promote products derived from this software without specific
21 1.9.2.2 nathanw * prior written permission.
22 1.9.2.2 nathanw *
23 1.9.2.2 nathanw * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
24 1.9.2.2 nathanw * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 1.9.2.2 nathanw * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.9.2.2 nathanw * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 1.9.2.2 nathanw * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 1.9.2.2 nathanw * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 1.9.2.2 nathanw * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.9.2.2 nathanw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.9.2.2 nathanw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.9.2.2 nathanw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.9.2.2 nathanw * SUCH DAMAGE.
34 1.9.2.2 nathanw *
35 1.9.2.2 nathanw * RiscBSD kernel project
36 1.9.2.2 nathanw *
37 1.9.2.2 nathanw * cpu.c
38 1.9.2.2 nathanw *
39 1.9.2.2 nathanw * Probing and configuration for the master cpu
40 1.9.2.2 nathanw *
41 1.9.2.2 nathanw * Created : 10/10/95
42 1.9.2.2 nathanw */
43 1.9.2.2 nathanw
44 1.9.2.2 nathanw #include "opt_armfpe.h"
45 1.9.2.2 nathanw
46 1.9.2.2 nathanw #include <sys/param.h>
47 1.9.2.4 nathanw
48 1.9.2.6 nathanw __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.9.2.6 2002/06/20 03:38:03 nathanw Exp $");
49 1.9.2.4 nathanw
50 1.9.2.2 nathanw #include <sys/systm.h>
51 1.9.2.2 nathanw #include <sys/malloc.h>
52 1.9.2.2 nathanw #include <sys/device.h>
53 1.9.2.2 nathanw #include <sys/proc.h>
54 1.9.2.2 nathanw #include <uvm/uvm_extern.h>
55 1.9.2.2 nathanw #include <machine/conf.h>
56 1.9.2.2 nathanw #include <machine/cpu.h>
57 1.9.2.5 nathanw
58 1.9.2.5 nathanw #include <arm/cpuconf.h>
59 1.9.2.2 nathanw #include <arm/undefined.h>
60 1.9.2.2 nathanw
61 1.9.2.2 nathanw #ifdef ARMFPE
62 1.9.2.2 nathanw #include <machine/bootconfig.h> /* For boot args */
63 1.9.2.2 nathanw #include <arm/fpe-arm/armfpe.h>
64 1.9.2.2 nathanw #endif
65 1.9.2.2 nathanw
66 1.9.2.4 nathanw char cpu_model[256];
67 1.9.2.2 nathanw
68 1.9.2.2 nathanw /* Prototypes */
69 1.9.2.4 nathanw void identify_arm_cpu(struct device *dv, struct cpu_info *);
70 1.9.2.2 nathanw
71 1.9.2.2 nathanw /*
72 1.9.2.4 nathanw * Identify the master (boot) CPU
73 1.9.2.2 nathanw */
74 1.9.2.2 nathanw
75 1.9.2.2 nathanw void
76 1.9.2.3 nathanw cpu_attach(struct device *dv)
77 1.9.2.2 nathanw {
78 1.9.2.4 nathanw int usearmfpe;
79 1.9.2.3 nathanw
80 1.9.2.4 nathanw usearmfpe = 1; /* when compiled in, its enabled by default */
81 1.9.2.2 nathanw
82 1.9.2.4 nathanw curcpu()->ci_dev = dv;
83 1.9.2.2 nathanw
84 1.9.2.4 nathanw evcnt_attach_dynamic(&curcpu()->ci_arm700bugcount, EVCNT_TYPE_MISC,
85 1.9.2.4 nathanw NULL, dv->dv_xname, "arm700swibug");
86 1.9.2.4 nathanw
87 1.9.2.2 nathanw /* Get the cpu ID from coprocessor 15 */
88 1.9.2.2 nathanw
89 1.9.2.4 nathanw curcpu()->ci_cpuid = cpu_id();
90 1.9.2.4 nathanw curcpu()->ci_cputype = curcpu()->ci_cpuid & CPU_ID_CPU_MASK;
91 1.9.2.4 nathanw curcpu()->ci_cpurev = curcpu()->ci_cpuid & CPU_ID_REVISION_MASK;
92 1.9.2.2 nathanw
93 1.9.2.4 nathanw identify_arm_cpu(dv, curcpu());
94 1.9.2.2 nathanw
95 1.9.2.4 nathanw if (curcpu()->ci_cputype == CPU_ID_SA110 && curcpu()->ci_cpurev < 3) {
96 1.9.2.2 nathanw printf("%s: SA-110 with bugged STM^ instruction\n",
97 1.9.2.2 nathanw dv->dv_xname);
98 1.9.2.2 nathanw }
99 1.9.2.2 nathanw
100 1.9.2.2 nathanw #ifdef CPU_ARM8
101 1.9.2.4 nathanw if ((curcpu()->ci_cpuid & CPU_ID_CPU_MASK) == CPU_ID_ARM810) {
102 1.9.2.2 nathanw int clock = arm8_clock_config(0, 0);
103 1.9.2.2 nathanw char *fclk;
104 1.9.2.2 nathanw printf("%s: ARM810 cp15=%02x", dv->dv_xname, clock);
105 1.9.2.2 nathanw printf(" clock:%s", (clock & 1) ? " dynamic" : "");
106 1.9.2.2 nathanw printf("%s", (clock & 2) ? " sync" : "");
107 1.9.2.2 nathanw switch ((clock >> 2) & 3) {
108 1.9.2.3 nathanw case 0:
109 1.9.2.2 nathanw fclk = "bus clock";
110 1.9.2.2 nathanw break;
111 1.9.2.3 nathanw case 1:
112 1.9.2.2 nathanw fclk = "ref clock";
113 1.9.2.2 nathanw break;
114 1.9.2.3 nathanw case 3:
115 1.9.2.2 nathanw fclk = "pll";
116 1.9.2.2 nathanw break;
117 1.9.2.3 nathanw default:
118 1.9.2.2 nathanw fclk = "illegal";
119 1.9.2.2 nathanw break;
120 1.9.2.2 nathanw }
121 1.9.2.2 nathanw printf(" fclk source=%s\n", fclk);
122 1.9.2.2 nathanw }
123 1.9.2.2 nathanw #endif
124 1.9.2.2 nathanw
125 1.9.2.4 nathanw #ifdef ARMFPE
126 1.9.2.2 nathanw /*
127 1.9.2.2 nathanw * Ok now we test for an FPA
128 1.9.2.2 nathanw * At this point no floating point emulator has been installed.
129 1.9.2.2 nathanw * This means any FP instruction will cause undefined exception.
130 1.9.2.2 nathanw * We install a temporay coproc 1 handler which will modify
131 1.9.2.2 nathanw * undefined_test if it is called.
132 1.9.2.2 nathanw * We then try to read the FP status register. If undefined_test
133 1.9.2.2 nathanw * has been decremented then the instruction was not handled by
134 1.9.2.2 nathanw * an FPA so we know the FPA is missing. If undefined_test is
135 1.9.2.2 nathanw * still 1 then we know the instruction was handled by an FPA.
136 1.9.2.2 nathanw * We then remove our test handler and look at the
137 1.9.2.2 nathanw * FP status register for identification.
138 1.9.2.2 nathanw */
139 1.9.2.2 nathanw
140 1.9.2.4 nathanw /*
141 1.9.2.4 nathanw * Ok if ARMFPE is defined and the boot options request the
142 1.9.2.4 nathanw * ARM FPE then it will be installed as the FPE.
143 1.9.2.4 nathanw * This is just while I work on integrating the new FPE.
144 1.9.2.4 nathanw * It means the new FPE gets installed if compiled int (ARMFPE
145 1.9.2.4 nathanw * defined) and also gives me a on/off option when I boot in
146 1.9.2.4 nathanw * case the new FPE is causing panics.
147 1.9.2.4 nathanw */
148 1.9.2.2 nathanw
149 1.9.2.2 nathanw
150 1.9.2.4 nathanw if (boot_args)
151 1.9.2.4 nathanw get_bootconf_option(boot_args, "armfpe",
152 1.9.2.4 nathanw BOOTOPT_TYPE_BOOLEAN, &usearmfpe);
153 1.9.2.4 nathanw if (usearmfpe)
154 1.9.2.4 nathanw initialise_arm_fpe();
155 1.9.2.2 nathanw #endif
156 1.9.2.2 nathanw }
157 1.9.2.2 nathanw
158 1.9.2.4 nathanw enum cpu_class {
159 1.9.2.4 nathanw CPU_CLASS_NONE,
160 1.9.2.4 nathanw CPU_CLASS_ARM2,
161 1.9.2.4 nathanw CPU_CLASS_ARM2AS,
162 1.9.2.4 nathanw CPU_CLASS_ARM3,
163 1.9.2.4 nathanw CPU_CLASS_ARM6,
164 1.9.2.4 nathanw CPU_CLASS_ARM7,
165 1.9.2.4 nathanw CPU_CLASS_ARM7TDMI,
166 1.9.2.4 nathanw CPU_CLASS_ARM8,
167 1.9.2.4 nathanw CPU_CLASS_ARM9TDMI,
168 1.9.2.4 nathanw CPU_CLASS_ARM9ES,
169 1.9.2.4 nathanw CPU_CLASS_SA1,
170 1.9.2.4 nathanw CPU_CLASS_XSCALE,
171 1.9.2.4 nathanw CPU_CLASS_ARM10E
172 1.9.2.4 nathanw };
173 1.9.2.4 nathanw
174 1.9.2.3 nathanw static const char *generic_steppings[16] = {
175 1.9.2.3 nathanw "rev 0", "rev 1", "rev 2", "rev 3",
176 1.9.2.3 nathanw "rev 4", "rev 5", "rev 6", "rev 7",
177 1.9.2.3 nathanw "rev 8", "rev 9", "rev 10", "rev 11",
178 1.9.2.3 nathanw "rev 12", "rev 13", "rev 14", "rev 15",
179 1.9.2.3 nathanw };
180 1.9.2.3 nathanw
181 1.9.2.3 nathanw static const char *sa110_steppings[16] = {
182 1.9.2.3 nathanw "rev 0", "step J", "step K", "step S",
183 1.9.2.3 nathanw "step T", "rev 5", "rev 6", "rev 7",
184 1.9.2.3 nathanw "rev 8", "rev 9", "rev 10", "rev 11",
185 1.9.2.3 nathanw "rev 12", "rev 13", "rev 14", "rev 15",
186 1.9.2.3 nathanw };
187 1.9.2.3 nathanw
188 1.9.2.3 nathanw static const char *sa1100_steppings[16] = {
189 1.9.2.3 nathanw "rev 0", "step B", "step C", "rev 3",
190 1.9.2.3 nathanw "rev 4", "rev 5", "rev 6", "rev 7",
191 1.9.2.3 nathanw "step D", "step E", "rev 10" "step G",
192 1.9.2.3 nathanw "rev 12", "rev 13", "rev 14", "rev 15",
193 1.9.2.3 nathanw };
194 1.9.2.3 nathanw
195 1.9.2.3 nathanw static const char *sa1110_steppings[16] = {
196 1.9.2.3 nathanw "step A-0", "rev 1", "rev 2", "rev 3",
197 1.9.2.3 nathanw "step B-0", "step B-1", "step B-2", "step B-3",
198 1.9.2.3 nathanw "step B-4", "step B-5", "rev 10", "rev 11",
199 1.9.2.3 nathanw "rev 12", "rev 13", "rev 14", "rev 15",
200 1.9.2.3 nathanw };
201 1.9.2.3 nathanw
202 1.9.2.6 nathanw static const char *ixp12x0_steppings[16] = {
203 1.9.2.6 nathanw "(IXP1200 step A)", "(IXP1200 step B)",
204 1.9.2.6 nathanw "rev 2", "(IXP1200 step C)",
205 1.9.2.6 nathanw "(IXP1200 step D)", "(IXP1240/1250 step A)",
206 1.9.2.6 nathanw "(IXP1240 step B)", "(IXP1250 step B)",
207 1.9.2.6 nathanw "rev 8", "rev 9", "rev 10", "rev 11",
208 1.9.2.6 nathanw "rev 12", "rev 13", "rev 14", "rev 15",
209 1.9.2.6 nathanw };
210 1.9.2.6 nathanw
211 1.9.2.4 nathanw static const char *xscale_steppings[16] = {
212 1.9.2.3 nathanw "step A-0", "step A-1", "step B-0", "step C-0",
213 1.9.2.3 nathanw "rev 4", "rev 5", "rev 6", "rev 7",
214 1.9.2.3 nathanw "rev 8", "rev 9", "rev 10", "rev 11",
215 1.9.2.3 nathanw "rev 12", "rev 13", "rev 14", "rev 15",
216 1.9.2.3 nathanw };
217 1.9.2.3 nathanw
218 1.9.2.6 nathanw static const char *pxa2x0_steppings[16] = {
219 1.9.2.6 nathanw "step A-0", "step A-1", "step B-0", "step B-1",
220 1.9.2.6 nathanw "rev 4", "rev 5", "rev 6", "rev 7",
221 1.9.2.6 nathanw "rev 8", "rev 9", "rev 10", "rev 11",
222 1.9.2.6 nathanw "rev 12", "rev 13", "rev 14", "rev 15",
223 1.9.2.6 nathanw };
224 1.9.2.6 nathanw
225 1.9.2.2 nathanw struct cpuidtab {
226 1.9.2.2 nathanw u_int32_t cpuid;
227 1.9.2.2 nathanw enum cpu_class cpu_class;
228 1.9.2.2 nathanw const char *cpu_name;
229 1.9.2.3 nathanw const char **cpu_steppings;
230 1.9.2.2 nathanw };
231 1.9.2.2 nathanw
232 1.9.2.2 nathanw const struct cpuidtab cpuids[] = {
233 1.9.2.3 nathanw { CPU_ID_ARM2, CPU_CLASS_ARM2, "ARM2",
234 1.9.2.3 nathanw generic_steppings },
235 1.9.2.3 nathanw { CPU_ID_ARM250, CPU_CLASS_ARM2AS, "ARM250",
236 1.9.2.3 nathanw generic_steppings },
237 1.9.2.3 nathanw
238 1.9.2.3 nathanw { CPU_ID_ARM3, CPU_CLASS_ARM3, "ARM3",
239 1.9.2.3 nathanw generic_steppings },
240 1.9.2.3 nathanw
241 1.9.2.3 nathanw { CPU_ID_ARM600, CPU_CLASS_ARM6, "ARM600",
242 1.9.2.3 nathanw generic_steppings },
243 1.9.2.3 nathanw { CPU_ID_ARM610, CPU_CLASS_ARM6, "ARM610",
244 1.9.2.3 nathanw generic_steppings },
245 1.9.2.3 nathanw { CPU_ID_ARM620, CPU_CLASS_ARM6, "ARM620",
246 1.9.2.3 nathanw generic_steppings },
247 1.9.2.3 nathanw
248 1.9.2.3 nathanw { CPU_ID_ARM700, CPU_CLASS_ARM7, "ARM700",
249 1.9.2.3 nathanw generic_steppings },
250 1.9.2.3 nathanw { CPU_ID_ARM710, CPU_CLASS_ARM7, "ARM710",
251 1.9.2.3 nathanw generic_steppings },
252 1.9.2.3 nathanw { CPU_ID_ARM7500, CPU_CLASS_ARM7, "ARM7500",
253 1.9.2.3 nathanw generic_steppings },
254 1.9.2.3 nathanw { CPU_ID_ARM710A, CPU_CLASS_ARM7, "ARM710a",
255 1.9.2.3 nathanw generic_steppings },
256 1.9.2.3 nathanw { CPU_ID_ARM7500FE, CPU_CLASS_ARM7, "ARM7500FE",
257 1.9.2.3 nathanw generic_steppings },
258 1.9.2.3 nathanw { CPU_ID_ARM710T, CPU_CLASS_ARM7TDMI, "ARM710T",
259 1.9.2.3 nathanw generic_steppings },
260 1.9.2.3 nathanw { CPU_ID_ARM720T, CPU_CLASS_ARM7TDMI, "ARM720T",
261 1.9.2.3 nathanw generic_steppings },
262 1.9.2.3 nathanw { CPU_ID_ARM740T8K, CPU_CLASS_ARM7TDMI, "ARM740T (8 KB cache)",
263 1.9.2.3 nathanw generic_steppings },
264 1.9.2.3 nathanw { CPU_ID_ARM740T4K, CPU_CLASS_ARM7TDMI, "ARM740T (4 KB cache)",
265 1.9.2.3 nathanw generic_steppings },
266 1.9.2.3 nathanw
267 1.9.2.3 nathanw { CPU_ID_ARM810, CPU_CLASS_ARM8, "ARM810",
268 1.9.2.3 nathanw generic_steppings },
269 1.9.2.3 nathanw
270 1.9.2.3 nathanw { CPU_ID_ARM920T, CPU_CLASS_ARM9TDMI, "ARM920T",
271 1.9.2.3 nathanw generic_steppings },
272 1.9.2.3 nathanw { CPU_ID_ARM922T, CPU_CLASS_ARM9TDMI, "ARM922T",
273 1.9.2.3 nathanw generic_steppings },
274 1.9.2.3 nathanw { CPU_ID_ARM940T, CPU_CLASS_ARM9TDMI, "ARM940T",
275 1.9.2.3 nathanw generic_steppings },
276 1.9.2.3 nathanw { CPU_ID_ARM946ES, CPU_CLASS_ARM9ES, "ARM946E-S",
277 1.9.2.3 nathanw generic_steppings },
278 1.9.2.3 nathanw { CPU_ID_ARM966ES, CPU_CLASS_ARM9ES, "ARM966E-S",
279 1.9.2.3 nathanw generic_steppings },
280 1.9.2.3 nathanw { CPU_ID_ARM966ESR1, CPU_CLASS_ARM9ES, "ARM966E-S",
281 1.9.2.3 nathanw generic_steppings },
282 1.9.2.3 nathanw
283 1.9.2.3 nathanw { CPU_ID_SA110, CPU_CLASS_SA1, "SA-110",
284 1.9.2.3 nathanw sa110_steppings },
285 1.9.2.3 nathanw { CPU_ID_SA1100, CPU_CLASS_SA1, "SA-1100",
286 1.9.2.3 nathanw sa1100_steppings },
287 1.9.2.3 nathanw { CPU_ID_SA1110, CPU_CLASS_SA1, "SA-1110",
288 1.9.2.3 nathanw sa1110_steppings },
289 1.9.2.3 nathanw
290 1.9.2.6 nathanw { CPU_ID_IXP1200, CPU_CLASS_SA1, "IXP1200",
291 1.9.2.6 nathanw ixp12x0_steppings },
292 1.9.2.6 nathanw
293 1.9.2.4 nathanw { CPU_ID_80200, CPU_CLASS_XSCALE, "i80200",
294 1.9.2.4 nathanw xscale_steppings },
295 1.9.2.4 nathanw
296 1.9.2.6 nathanw { CPU_ID_80321_400, CPU_CLASS_XSCALE, "i80321 400MHz",
297 1.9.2.6 nathanw xscale_steppings },
298 1.9.2.6 nathanw { CPU_ID_80321_600, CPU_CLASS_XSCALE, "i80321 600MHz",
299 1.9.2.4 nathanw xscale_steppings },
300 1.9.2.4 nathanw
301 1.9.2.6 nathanw { CPU_ID_PXA250, CPU_CLASS_XSCALE, "PXA250",
302 1.9.2.6 nathanw pxa2x0_steppings },
303 1.9.2.6 nathanw { CPU_ID_PXA210, CPU_CLASS_XSCALE, "PXA210",
304 1.9.2.6 nathanw pxa2x0_steppings }, /* XXX */
305 1.9.2.6 nathanw
306 1.9.2.4 nathanw { CPU_ID_ARM1022ES, CPU_CLASS_ARM10E, "ARM1022ES",
307 1.9.2.4 nathanw generic_steppings },
308 1.9.2.3 nathanw
309 1.9.2.3 nathanw { 0, CPU_CLASS_NONE, NULL, NULL }
310 1.9.2.2 nathanw };
311 1.9.2.2 nathanw
312 1.9.2.2 nathanw struct cpu_classtab {
313 1.9.2.2 nathanw const char *class_name;
314 1.9.2.2 nathanw const char *class_option;
315 1.9.2.2 nathanw };
316 1.9.2.2 nathanw
317 1.9.2.2 nathanw const struct cpu_classtab cpu_classes[] = {
318 1.9.2.2 nathanw { "unknown", NULL }, /* CPU_CLASS_NONE */
319 1.9.2.2 nathanw { "ARM2", "CPU_ARM2" }, /* CPU_CLASS_ARM2 */
320 1.9.2.2 nathanw { "ARM2as", "CPU_ARM250" }, /* CPU_CLASS_ARM2AS */
321 1.9.2.2 nathanw { "ARM3", "CPU_ARM3" }, /* CPU_CLASS_ARM3 */
322 1.9.2.2 nathanw { "ARM6", "CPU_ARM6" }, /* CPU_CLASS_ARM6 */
323 1.9.2.2 nathanw { "ARM7", "CPU_ARM7" }, /* CPU_CLASS_ARM7 */
324 1.9.2.2 nathanw { "ARM7TDMI", "CPU_ARM7TDMI" }, /* CPU_CLASS_ARM7TDMI */
325 1.9.2.2 nathanw { "ARM8", "CPU_ARM8" }, /* CPU_CLASS_ARM8 */
326 1.9.2.2 nathanw { "ARM9TDMI", NULL }, /* CPU_CLASS_ARM9TDMI */
327 1.9.2.2 nathanw { "ARM9E-S", NULL }, /* CPU_CLASS_ARM9ES */
328 1.9.2.2 nathanw { "SA-1", "CPU_SA110" }, /* CPU_CLASS_SA1 */
329 1.9.2.4 nathanw { "XScale", "CPU_XSCALE_..." }, /* CPU_CLASS_XSCALE */
330 1.9.2.4 nathanw { "ARM10E", NULL }, /* CPU_CLASS_ARM10E */
331 1.9.2.2 nathanw };
332 1.9.2.2 nathanw
333 1.9.2.2 nathanw /*
334 1.9.2.2 nathanw * Report the type of the specifed arm processor. This uses the generic and
335 1.9.2.2 nathanw * arm specific information in the cpu structure to identify the processor.
336 1.9.2.2 nathanw * The remaining fields in the cpu structure are filled in appropriately.
337 1.9.2.2 nathanw */
338 1.9.2.2 nathanw
339 1.9.2.2 nathanw static const char *wtnames[] = {
340 1.9.2.2 nathanw "write-through",
341 1.9.2.2 nathanw "write-back",
342 1.9.2.2 nathanw "write-back",
343 1.9.2.2 nathanw "**unknown 3**",
344 1.9.2.2 nathanw "**unknown 4**",
345 1.9.2.2 nathanw "write-back-locking", /* XXX XScale-specific? */
346 1.9.2.2 nathanw "write-back-locking-A",
347 1.9.2.2 nathanw "write-back-locking-B",
348 1.9.2.2 nathanw "**unknown 8**",
349 1.9.2.2 nathanw "**unknown 9**",
350 1.9.2.2 nathanw "**unknown 10**",
351 1.9.2.2 nathanw "**unknown 11**",
352 1.9.2.2 nathanw "**unknown 12**",
353 1.9.2.2 nathanw "**unknown 13**",
354 1.9.2.2 nathanw "**unknown 14**",
355 1.9.2.2 nathanw "**unknown 15**",
356 1.9.2.2 nathanw };
357 1.9.2.2 nathanw
358 1.9.2.2 nathanw void
359 1.9.2.4 nathanw identify_arm_cpu(struct device *dv, struct cpu_info *ci)
360 1.9.2.2 nathanw {
361 1.9.2.2 nathanw u_int cpuid;
362 1.9.2.4 nathanw enum cpu_class cpu_class;
363 1.9.2.2 nathanw int i;
364 1.9.2.2 nathanw
365 1.9.2.4 nathanw cpuid = ci->ci_cpuid;
366 1.9.2.2 nathanw
367 1.9.2.2 nathanw if (cpuid == 0) {
368 1.9.2.2 nathanw printf("Processor failed probe - no CPU ID\n");
369 1.9.2.2 nathanw return;
370 1.9.2.2 nathanw }
371 1.9.2.2 nathanw
372 1.9.2.2 nathanw for (i = 0; cpuids[i].cpuid != 0; i++)
373 1.9.2.2 nathanw if (cpuids[i].cpuid == (cpuid & CPU_ID_CPU_MASK)) {
374 1.9.2.4 nathanw cpu_class = cpuids[i].cpu_class;
375 1.9.2.4 nathanw sprintf(cpu_model, "%s %s (%s core)",
376 1.9.2.3 nathanw cpuids[i].cpu_name,
377 1.9.2.3 nathanw cpuids[i].cpu_steppings[cpuid &
378 1.9.2.3 nathanw CPU_ID_REVISION_MASK],
379 1.9.2.4 nathanw cpu_classes[cpu_class].class_name);
380 1.9.2.2 nathanw break;
381 1.9.2.2 nathanw }
382 1.9.2.2 nathanw
383 1.9.2.2 nathanw if (cpuids[i].cpuid == 0)
384 1.9.2.4 nathanw sprintf(cpu_model, "unknown CPU (ID = 0x%x)", cpuid);
385 1.9.2.2 nathanw
386 1.9.2.4 nathanw printf(": %s\n", cpu_model);
387 1.9.2.4 nathanw
388 1.9.2.4 nathanw printf("%s:", dv->dv_xname);
389 1.9.2.4 nathanw
390 1.9.2.4 nathanw switch (cpu_class) {
391 1.9.2.2 nathanw case CPU_CLASS_ARM6:
392 1.9.2.2 nathanw case CPU_CLASS_ARM7:
393 1.9.2.2 nathanw case CPU_CLASS_ARM7TDMI:
394 1.9.2.2 nathanw case CPU_CLASS_ARM8:
395 1.9.2.4 nathanw if ((ci->ci_ctrl & CPU_CONTROL_IDC_ENABLE) == 0)
396 1.9.2.4 nathanw printf(" IDC disabled");
397 1.9.2.2 nathanw else
398 1.9.2.4 nathanw printf(" IDC enabled");
399 1.9.2.2 nathanw break;
400 1.9.2.2 nathanw case CPU_CLASS_ARM9TDMI:
401 1.9.2.2 nathanw case CPU_CLASS_SA1:
402 1.9.2.2 nathanw case CPU_CLASS_XSCALE:
403 1.9.2.4 nathanw if ((ci->ci_ctrl & CPU_CONTROL_DC_ENABLE) == 0)
404 1.9.2.4 nathanw printf(" DC disabled");
405 1.9.2.2 nathanw else
406 1.9.2.4 nathanw printf(" DC enabled");
407 1.9.2.4 nathanw if ((ci->ci_ctrl & CPU_CONTROL_IC_ENABLE) == 0)
408 1.9.2.4 nathanw printf(" IC disabled");
409 1.9.2.2 nathanw else
410 1.9.2.4 nathanw printf(" IC enabled");
411 1.9.2.4 nathanw break;
412 1.9.2.4 nathanw default:
413 1.9.2.2 nathanw break;
414 1.9.2.2 nathanw }
415 1.9.2.4 nathanw if ((ci->ci_ctrl & CPU_CONTROL_WBUF_ENABLE) == 0)
416 1.9.2.4 nathanw printf(" WB disabled");
417 1.9.2.2 nathanw else
418 1.9.2.4 nathanw printf(" WB enabled");
419 1.9.2.2 nathanw
420 1.9.2.4 nathanw if (ci->ci_ctrl & CPU_CONTROL_LABT_ENABLE)
421 1.9.2.4 nathanw printf(" LABT");
422 1.9.2.2 nathanw else
423 1.9.2.4 nathanw printf(" EABT");
424 1.9.2.2 nathanw
425 1.9.2.4 nathanw if (ci->ci_ctrl & CPU_CONTROL_BPRD_ENABLE)
426 1.9.2.4 nathanw printf(" branch prediction enabled");
427 1.9.2.2 nathanw
428 1.9.2.4 nathanw printf("\n");
429 1.9.2.2 nathanw
430 1.9.2.2 nathanw /* Print cache info. */
431 1.9.2.2 nathanw if (arm_picache_line_size == 0 && arm_pdcache_line_size == 0)
432 1.9.2.2 nathanw goto skip_pcache;
433 1.9.2.2 nathanw
434 1.9.2.2 nathanw if (arm_pcache_unified) {
435 1.9.2.2 nathanw printf("%s: %dKB/%dB %d-way %s unified cache\n",
436 1.9.2.2 nathanw dv->dv_xname, arm_pdcache_size / 1024,
437 1.9.2.2 nathanw arm_pdcache_line_size, arm_pdcache_ways,
438 1.9.2.2 nathanw wtnames[arm_pcache_type]);
439 1.9.2.2 nathanw } else {
440 1.9.2.2 nathanw printf("%s: %dKB/%dB %d-way Instruction cache\n",
441 1.9.2.2 nathanw dv->dv_xname, arm_picache_size / 1024,
442 1.9.2.2 nathanw arm_picache_line_size, arm_picache_ways);
443 1.9.2.2 nathanw printf("%s: %dKB/%dB %d-way %s Data cache\n",
444 1.9.2.2 nathanw dv->dv_xname, arm_pdcache_size / 1024,
445 1.9.2.2 nathanw arm_pdcache_line_size, arm_pdcache_ways,
446 1.9.2.2 nathanw wtnames[arm_pcache_type]);
447 1.9.2.2 nathanw }
448 1.9.2.2 nathanw
449 1.9.2.2 nathanw skip_pcache:
450 1.9.2.2 nathanw
451 1.9.2.4 nathanw switch (cpu_class) {
452 1.9.2.2 nathanw #ifdef CPU_ARM2
453 1.9.2.2 nathanw case CPU_CLASS_ARM2:
454 1.9.2.2 nathanw #endif
455 1.9.2.2 nathanw #ifdef CPU_ARM250
456 1.9.2.2 nathanw case CPU_CLASS_ARM2AS:
457 1.9.2.2 nathanw #endif
458 1.9.2.2 nathanw #ifdef CPU_ARM3
459 1.9.2.2 nathanw case CPU_CLASS_ARM3:
460 1.9.2.2 nathanw #endif
461 1.9.2.2 nathanw #ifdef CPU_ARM6
462 1.9.2.2 nathanw case CPU_CLASS_ARM6:
463 1.9.2.2 nathanw #endif
464 1.9.2.2 nathanw #ifdef CPU_ARM7
465 1.9.2.2 nathanw case CPU_CLASS_ARM7:
466 1.9.2.2 nathanw #endif
467 1.9.2.2 nathanw #ifdef CPU_ARM7TDMI
468 1.9.2.2 nathanw case CPU_CLASS_ARM7TDMI:
469 1.9.2.2 nathanw #endif
470 1.9.2.2 nathanw #ifdef CPU_ARM8
471 1.9.2.2 nathanw case CPU_CLASS_ARM8:
472 1.9.2.2 nathanw #endif
473 1.9.2.2 nathanw #ifdef CPU_ARM9
474 1.9.2.2 nathanw case CPU_CLASS_ARM9TDMI:
475 1.9.2.2 nathanw #endif
476 1.9.2.6 nathanw #if defined(CPU_SA110) || defined(CPU_SA1100) || \
477 1.9.2.6 nathanw defined(CPU_SA1110) || defined(CPU_IXP12X0)
478 1.9.2.2 nathanw case CPU_CLASS_SA1:
479 1.9.2.2 nathanw #endif
480 1.9.2.6 nathanw #if defined(CPU_XSCALE_80200) || defined(CPU_XSCALE_80321) || \
481 1.9.2.6 nathanw defined(CPU_XSCALE_PXA2X0)
482 1.9.2.2 nathanw case CPU_CLASS_XSCALE:
483 1.9.2.2 nathanw #endif
484 1.9.2.2 nathanw break;
485 1.9.2.2 nathanw default:
486 1.9.2.4 nathanw if (cpu_classes[cpu_class].class_option != NULL)
487 1.9.2.2 nathanw printf("%s: %s does not fully support this CPU."
488 1.9.2.2 nathanw "\n", dv->dv_xname, ostype);
489 1.9.2.2 nathanw else {
490 1.9.2.2 nathanw printf("%s: This kernel does not fully support "
491 1.9.2.2 nathanw "this CPU.\n", dv->dv_xname);
492 1.9.2.2 nathanw printf("%s: Recompile with \"options %s\" to "
493 1.9.2.2 nathanw "correct this.\n", dv->dv_xname,
494 1.9.2.4 nathanw cpu_classes[cpu_class].class_option);
495 1.9.2.2 nathanw }
496 1.9.2.2 nathanw break;
497 1.9.2.2 nathanw }
498 1.9.2.2 nathanw
499 1.9.2.2 nathanw }
500 1.9.2.2 nathanw
501 1.9.2.2 nathanw /* End of cpu.c */
502