blob: 6b3c63dd181867179d879720eb163ced08cf3329 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Processor capabilities determination functions.
3 *
4 * Copyright (C) xxxx the Anonymous
Ralf Baechle010b8532006-01-29 18:42:08 +00005 * Copyright (C) 1994 - 2006 Ralf Baechle
Ralf Baechle41943182005-05-05 16:45:59 +00006 * Copyright (C) 2003, 2004 Maciej W. Rozycki
Ralf Baechle41943182005-05-05 16:45:59 +00007 * Copyright (C) 2001, 2004 MIPS Inc.
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/init.h>
15#include <linux/kernel.h>
16#include <linux/ptrace.h>
17#include <linux/stddef.h>
18
Ralf Baechle57599062007-02-18 19:07:31 +000019#include <asm/bugs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <asm/cpu.h>
21#include <asm/fpu.h>
22#include <asm/mipsregs.h>
23#include <asm/system.h>
David Daney654f57b2008-09-23 00:07:16 -070024#include <asm/watch.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26/*
27 * Not all of the MIPS CPUs have the "wait" instruction available. Moreover,
28 * the implementation of the "wait" feature differs between CPU families. This
29 * points to the function that implements CPU specific wait.
30 * The wait instruction stops the pipeline and reduces the power consumption of
31 * the CPU very much.
32 */
33void (*cpu_wait)(void) = NULL;
34
35static void r3081_wait(void)
36{
37 unsigned long cfg = read_c0_conf();
38 write_c0_conf(cfg | R30XX_CONF_HALT);
39}
40
41static void r39xx_wait(void)
42{
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090043 local_irq_disable();
44 if (!need_resched())
45 write_c0_conf(read_c0_conf() | TX39_CONF_HALT);
46 local_irq_enable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070047}
48
Atsushi Nemotoc65a5482007-11-12 02:05:18 +090049extern void r4k_wait(void);
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090050
51/*
52 * This variant is preferable as it allows testing need_resched and going to
53 * sleep depending on the outcome atomically. Unfortunately the "It is
54 * implementation-dependent whether the pipeline restarts when a non-enabled
55 * interrupt is requested" restriction in the MIPS32/MIPS64 architecture makes
56 * using this version a gamble.
57 */
Kevin D. Kissell8531a352008-09-09 21:48:52 +020058void r4k_wait_irqoff(void)
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090059{
60 local_irq_disable();
61 if (!need_resched())
Kevin D. Kissell8531a352008-09-09 21:48:52 +020062 __asm__(" .set push \n"
63 " .set mips3 \n"
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090064 " wait \n"
Kevin D. Kissell8531a352008-09-09 21:48:52 +020065 " .set pop \n");
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090066 local_irq_enable();
Kevin D. Kissell8531a352008-09-09 21:48:52 +020067 __asm__(" .globl __pastwait \n"
68 "__pastwait: \n");
69 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070}
71
Ralf Baechle5a812992007-07-17 18:49:48 +010072/*
73 * The RM7000 variant has to handle erratum 38. The workaround is to not
74 * have any pending stores when the WAIT instruction is executed.
75 */
76static void rm7k_wait_irqoff(void)
77{
78 local_irq_disable();
79 if (!need_resched())
80 __asm__(
81 " .set push \n"
82 " .set mips3 \n"
83 " .set noat \n"
84 " mfc0 $1, $12 \n"
85 " sync \n"
86 " mtc0 $1, $12 # stalls until W stage \n"
87 " wait \n"
88 " mtc0 $1, $12 # stalls until W stage \n"
89 " .set pop \n");
90 local_irq_enable();
91}
92
Pete Popov494900a2005-04-07 00:42:10 +000093/* The Au1xxx wait is available only if using 32khz counter or
94 * external timer source, but specifically not CP0 Counter. */
Pete Popovfe359bf2005-04-08 08:34:43 +000095int allow_au1k_wait;
Ralf Baechle10f650d2005-05-25 13:32:49 +000096
Pete Popov494900a2005-04-07 00:42:10 +000097static void au1k_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070098{
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 /* using the wait instruction makes CP0 counter unusable */
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900100 __asm__(" .set mips3 \n"
101 " cache 0x14, 0(%0) \n"
102 " cache 0x14, 32(%0) \n"
103 " sync \n"
104 " nop \n"
105 " wait \n"
106 " nop \n"
107 " nop \n"
108 " nop \n"
109 " nop \n"
110 " .set mips0 \n"
Ralf Baechle10f650d2005-05-25 13:32:49 +0000111 : : "r" (au1k_wait));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112}
113
Ralf Baechle55d04df2005-07-13 19:22:45 +0000114static int __initdata nowait = 0;
115
Atsushi Nemotof49a7472007-02-18 01:02:14 +0900116static int __init wait_disable(char *s)
Ralf Baechle55d04df2005-07-13 19:22:45 +0000117{
118 nowait = 1;
119
120 return 1;
121}
122
123__setup("nowait", wait_disable);
124
Atsushi Nemotoc65a5482007-11-12 02:05:18 +0900125void __init check_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126{
127 struct cpuinfo_mips *c = &current_cpu_data;
128
Ralf Baechle55d04df2005-07-13 19:22:45 +0000129 if (nowait) {
Ralf Baechlec2379232006-11-30 01:14:44 +0000130 printk("Wait instruction disabled.\n");
Ralf Baechle55d04df2005-07-13 19:22:45 +0000131 return;
132 }
133
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 switch (c->cputype) {
135 case CPU_R3081:
136 case CPU_R3081E:
137 cpu_wait = r3081_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 break;
139 case CPU_TX3927:
140 cpu_wait = r39xx_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 break;
142 case CPU_R4200:
143/* case CPU_R4300: */
144 case CPU_R4600:
145 case CPU_R4640:
146 case CPU_R4650:
147 case CPU_R4700:
148 case CPU_R5000:
149 case CPU_NEVADA:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 case CPU_4KC:
151 case CPU_4KEC:
152 case CPU_4KSC:
153 case CPU_5KC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 case CPU_25KF:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100155 case CPU_PR4450:
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200156 case CPU_BCM3302:
David Daney0dd47812008-12-11 15:33:26 -0800157 case CPU_CAVIUM_OCTEON:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 cpu_wait = r4k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 break;
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100160
Ralf Baechle5a812992007-07-17 18:49:48 +0100161 case CPU_RM7000:
162 cpu_wait = rm7k_wait_irqoff;
163 break;
164
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100165 case CPU_24K:
166 case CPU_34K:
Ralf Baechle39b8d522008-04-28 17:14:26 +0100167 case CPU_1004K:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100168 cpu_wait = r4k_wait;
169 if (read_c0_config7() & MIPS_CONF7_WII)
170 cpu_wait = r4k_wait_irqoff;
171 break;
172
173 case CPU_74K:
174 cpu_wait = r4k_wait;
175 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
176 cpu_wait = r4k_wait_irqoff;
177 break;
178
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900179 case CPU_TX49XX:
180 cpu_wait = r4k_wait_irqoff;
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900181 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 case CPU_AU1000:
183 case CPU_AU1100:
184 case CPU_AU1500:
Pete Popove3ad1c22005-03-01 06:33:16 +0000185 case CPU_AU1550:
186 case CPU_AU1200:
Manuel Lauss237cfee2007-12-06 09:07:55 +0100187 case CPU_AU1210:
188 case CPU_AU1250:
Ralf Baechlec2379232006-11-30 01:14:44 +0000189 if (allow_au1k_wait)
Pete Popovfe359bf2005-04-08 08:34:43 +0000190 cpu_wait = au1k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 break;
Ralf Baechlec8eae712007-06-12 13:04:09 +0100192 case CPU_20KC:
193 /*
194 * WAIT on Rev1.0 has E1, E2, E3 and E16.
195 * WAIT on Rev2.0 and Rev3.0 has E16.
196 * Rev3.1 WAIT is nop, why bother
197 */
198 if ((c->processor_id & 0xff) <= 0x64)
199 break;
200
Ralf Baechle50da4692007-09-14 19:08:43 +0100201 /*
202 * Another rev is incremeting c0_count at a reduced clock
203 * rate while in WAIT mode. So we basically have the choice
204 * between using the cp0 timer as clocksource or avoiding
205 * the WAIT instruction. Until more details are known,
206 * disable the use of WAIT for 20Kc entirely.
207 cpu_wait = r4k_wait;
208 */
Ralf Baechlec8eae712007-06-12 13:04:09 +0100209 break;
Ralf Baechle441ee342006-06-02 11:48:11 +0100210 case CPU_RM9000:
Ralf Baechlec2379232006-11-30 01:14:44 +0000211 if ((c->processor_id & 0x00ff) >= 0x40)
Ralf Baechle441ee342006-06-02 11:48:11 +0100212 cpu_wait = r4k_wait;
Ralf Baechle441ee342006-06-02 11:48:11 +0100213 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 break;
216 }
217}
218
Marc St-Jean9267a302007-06-14 15:55:31 -0600219static inline void check_errata(void)
220{
221 struct cpuinfo_mips *c = &current_cpu_data;
222
223 switch (c->cputype) {
224 case CPU_34K:
225 /*
226 * Erratum "RPS May Cause Incorrect Instruction Execution"
227 * This code only handles VPE0, any SMP/SMTC/RTOS code
228 * making use of VPE1 will be responsable for that VPE.
229 */
230 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
231 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
232 break;
233 default:
234 break;
235 }
236}
237
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238void __init check_bugs32(void)
239{
Marc St-Jean9267a302007-06-14 15:55:31 -0600240 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241}
242
243/*
244 * Probe whether cpu has config register by trying to play with
245 * alternate cache bit and see whether it matters.
246 * It's used by cpu_probe to distinguish between R3000A and R3081.
247 */
248static inline int cpu_has_confreg(void)
249{
250#ifdef CONFIG_CPU_R3000
251 extern unsigned long r3k_cache_size(unsigned long);
252 unsigned long size1, size2;
253 unsigned long cfg = read_c0_conf();
254
255 size1 = r3k_cache_size(ST0_ISC);
256 write_c0_conf(cfg ^ R30XX_CONF_AC);
257 size2 = r3k_cache_size(ST0_ISC);
258 write_c0_conf(cfg);
259 return size1 != size2;
260#else
261 return 0;
262#endif
263}
264
265/*
266 * Get the FPU Implementation/Revision.
267 */
268static inline unsigned long cpu_get_fpu_id(void)
269{
270 unsigned long tmp, fpu_id;
271
272 tmp = read_c0_status();
273 __enable_fpu();
274 fpu_id = read_32bit_cp1_register(CP1_REVISION);
275 write_c0_status(tmp);
276 return fpu_id;
277}
278
279/*
280 * Check the CPU has an FPU the official way.
281 */
282static inline int __cpu_has_fpu(void)
283{
284 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
285}
286
Ralf Baechle02cf2112005-10-01 13:06:32 +0100287#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 | MIPS_CPU_COUNTER)
289
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000290static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291{
292 switch (c->processor_id & 0xff00) {
293 case PRID_IMP_R2000:
294 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000295 __cpu_name[cpu] = "R2000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100297 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
298 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 if (__cpu_has_fpu())
300 c->options |= MIPS_CPU_FPU;
301 c->tlbsize = 64;
302 break;
303 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000304 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
305 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000307 __cpu_name[cpu] = "R3081";
308 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000310 __cpu_name[cpu] = "R3000A";
311 }
312 break;
313 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000315 __cpu_name[cpu] = "R3000";
316 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100318 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
319 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 if (__cpu_has_fpu())
321 c->options |= MIPS_CPU_FPU;
322 c->tlbsize = 64;
323 break;
324 case PRID_IMP_R4000:
325 if (read_c0_config() & CONF_SC) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000326 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000328 __cpu_name[cpu] = "R4400PC";
329 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000331 __cpu_name[cpu] = "R4000PC";
332 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 } else {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000334 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 c->cputype = CPU_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000336 __cpu_name[cpu] = "R4400SC";
337 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000339 __cpu_name[cpu] = "R4000SC";
340 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 }
342
343 c->isa_level = MIPS_CPU_ISA_III;
344 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
345 MIPS_CPU_WATCH | MIPS_CPU_VCE |
346 MIPS_CPU_LLSC;
347 c->tlbsize = 48;
348 break;
349 case PRID_IMP_VR41XX:
350 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 case PRID_REV_VR4111:
352 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000353 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 case PRID_REV_VR4121:
356 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000357 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 break;
359 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000360 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000362 __cpu_name[cpu] = "NEC VR4122";
363 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000365 __cpu_name[cpu] = "NEC VR4181A";
366 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 break;
368 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000369 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000371 __cpu_name[cpu] = "NEC VR4131";
372 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 c->cputype = CPU_VR4133;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000374 __cpu_name[cpu] = "NEC VR4133";
375 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 break;
377 default:
378 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
379 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000380 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 break;
382 }
383 c->isa_level = MIPS_CPU_ISA_III;
384 c->options = R4K_OPTS;
385 c->tlbsize = 32;
386 break;
387 case PRID_IMP_R4300:
388 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000389 __cpu_name[cpu] = "R4300";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 c->isa_level = MIPS_CPU_ISA_III;
391 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
392 MIPS_CPU_LLSC;
393 c->tlbsize = 32;
394 break;
395 case PRID_IMP_R4600:
396 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000397 __cpu_name[cpu] = "R4600";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 c->isa_level = MIPS_CPU_ISA_III;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000399 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
400 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 c->tlbsize = 48;
402 break;
403 #if 0
404 case PRID_IMP_R4650:
405 /*
406 * This processor doesn't have an MMU, so it's not
407 * "real easy" to run Linux on it. It is left purely
408 * for documentation. Commented out because it shares
409 * it's c0_prid id number with the TX3900.
410 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000411 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000412 __cpu_name[cpu] = "R4650";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 c->isa_level = MIPS_CPU_ISA_III;
414 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
415 c->tlbsize = 48;
416 break;
417 #endif
418 case PRID_IMP_TX39:
419 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100420 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421
422 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
423 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000424 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 c->tlbsize = 64;
426 } else {
427 switch (c->processor_id & 0xff) {
428 case PRID_REV_TX3912:
429 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000430 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 c->tlbsize = 32;
432 break;
433 case PRID_REV_TX3922:
434 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000435 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 c->tlbsize = 64;
437 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 }
439 }
440 break;
441 case PRID_IMP_R4700:
442 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000443 __cpu_name[cpu] = "R4700";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 c->isa_level = MIPS_CPU_ISA_III;
445 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
446 MIPS_CPU_LLSC;
447 c->tlbsize = 48;
448 break;
449 case PRID_IMP_TX49:
450 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000451 __cpu_name[cpu] = "R49XX";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 c->isa_level = MIPS_CPU_ISA_III;
453 c->options = R4K_OPTS | MIPS_CPU_LLSC;
454 if (!(c->processor_id & 0x08))
455 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
456 c->tlbsize = 48;
457 break;
458 case PRID_IMP_R5000:
459 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000460 __cpu_name[cpu] = "R5000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 c->isa_level = MIPS_CPU_ISA_IV;
462 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
463 MIPS_CPU_LLSC;
464 c->tlbsize = 48;
465 break;
466 case PRID_IMP_R5432:
467 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000468 __cpu_name[cpu] = "R5432";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 c->isa_level = MIPS_CPU_ISA_IV;
470 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
471 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
472 c->tlbsize = 48;
473 break;
474 case PRID_IMP_R5500:
475 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000476 __cpu_name[cpu] = "R5500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 c->isa_level = MIPS_CPU_ISA_IV;
478 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
479 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
480 c->tlbsize = 48;
481 break;
482 case PRID_IMP_NEVADA:
483 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000484 __cpu_name[cpu] = "Nevada";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 c->isa_level = MIPS_CPU_ISA_IV;
486 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
487 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
488 c->tlbsize = 48;
489 break;
490 case PRID_IMP_R6000:
491 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000492 __cpu_name[cpu] = "R6000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 c->isa_level = MIPS_CPU_ISA_II;
494 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
495 MIPS_CPU_LLSC;
496 c->tlbsize = 32;
497 break;
498 case PRID_IMP_R6000A:
499 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000500 __cpu_name[cpu] = "R6000A";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 c->isa_level = MIPS_CPU_ISA_II;
502 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
503 MIPS_CPU_LLSC;
504 c->tlbsize = 32;
505 break;
506 case PRID_IMP_RM7000:
507 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000508 __cpu_name[cpu] = "RM7000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 c->isa_level = MIPS_CPU_ISA_IV;
510 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
511 MIPS_CPU_LLSC;
512 /*
513 * Undocumented RM7000: Bit 29 in the info register of
514 * the RM7000 v2.0 indicates if the TLB has 48 or 64
515 * entries.
516 *
517 * 29 1 => 64 entry JTLB
518 * 0 => 48 entry JTLB
519 */
520 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
521 break;
522 case PRID_IMP_RM9000:
523 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000524 __cpu_name[cpu] = "RM9000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 c->isa_level = MIPS_CPU_ISA_IV;
526 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
527 MIPS_CPU_LLSC;
528 /*
529 * Bit 29 in the info register of the RM9000
530 * indicates if the TLB has 48 or 64 entries.
531 *
532 * 29 1 => 64 entry JTLB
533 * 0 => 48 entry JTLB
534 */
535 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
536 break;
537 case PRID_IMP_R8000:
538 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000539 __cpu_name[cpu] = "RM8000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 c->isa_level = MIPS_CPU_ISA_IV;
541 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
542 MIPS_CPU_FPU | MIPS_CPU_32FPR |
543 MIPS_CPU_LLSC;
544 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
545 break;
546 case PRID_IMP_R10000:
547 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000548 __cpu_name[cpu] = "R10000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000550 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 MIPS_CPU_FPU | MIPS_CPU_32FPR |
552 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
553 MIPS_CPU_LLSC;
554 c->tlbsize = 64;
555 break;
556 case PRID_IMP_R12000:
557 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000558 __cpu_name[cpu] = "R12000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000560 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 MIPS_CPU_FPU | MIPS_CPU_32FPR |
562 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
563 MIPS_CPU_LLSC;
564 c->tlbsize = 64;
565 break;
Kumba44d921b2006-05-16 22:23:59 -0400566 case PRID_IMP_R14000:
567 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000568 __cpu_name[cpu] = "R14000";
Kumba44d921b2006-05-16 22:23:59 -0400569 c->isa_level = MIPS_CPU_ISA_IV;
570 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
571 MIPS_CPU_FPU | MIPS_CPU_32FPR |
572 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
573 MIPS_CPU_LLSC;
574 c->tlbsize = 64;
575 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800576 case PRID_IMP_LOONGSON2:
577 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000578 __cpu_name[cpu] = "ICT Loongson-2";
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800579 c->isa_level = MIPS_CPU_ISA_III;
580 c->options = R4K_OPTS |
581 MIPS_CPU_FPU | MIPS_CPU_LLSC |
582 MIPS_CPU_32FPR;
583 c->tlbsize = 64;
584 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 }
586}
587
Ralf Baechle234fcd12008-03-08 09:56:28 +0000588static char unknown_isa[] __cpuinitdata = KERN_ERR \
Ralf Baechleb4672d32005-12-08 14:04:24 +0000589 "Unsupported ISA type, c0.config0: %d.";
590
Ralf Baechle41943182005-05-05 16:45:59 +0000591static inline unsigned int decode_config0(struct cpuinfo_mips *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592{
Ralf Baechle41943182005-05-05 16:45:59 +0000593 unsigned int config0;
594 int isa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595
Ralf Baechle41943182005-05-05 16:45:59 +0000596 config0 = read_c0_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597
Ralf Baechle41943182005-05-05 16:45:59 +0000598 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
Ralf Baechle02cf2112005-10-01 13:06:32 +0100599 c->options |= MIPS_CPU_TLB;
Ralf Baechle41943182005-05-05 16:45:59 +0000600 isa = (config0 & MIPS_CONF_AT) >> 13;
601 switch (isa) {
602 case 0:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100603 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000604 case 0:
605 c->isa_level = MIPS_CPU_ISA_M32R1;
606 break;
607 case 1:
608 c->isa_level = MIPS_CPU_ISA_M32R2;
609 break;
610 default:
611 goto unknown;
612 }
Ralf Baechle41943182005-05-05 16:45:59 +0000613 break;
614 case 2:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100615 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000616 case 0:
617 c->isa_level = MIPS_CPU_ISA_M64R1;
618 break;
619 case 1:
620 c->isa_level = MIPS_CPU_ISA_M64R2;
621 break;
622 default:
623 goto unknown;
624 }
Ralf Baechle41943182005-05-05 16:45:59 +0000625 break;
626 default:
Ralf Baechleb4672d32005-12-08 14:04:24 +0000627 goto unknown;
Ralf Baechle41943182005-05-05 16:45:59 +0000628 }
629
630 return config0 & MIPS_CONF_M;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000631
632unknown:
633 panic(unknown_isa, config0);
Ralf Baechle41943182005-05-05 16:45:59 +0000634}
635
636static inline unsigned int decode_config1(struct cpuinfo_mips *c)
637{
638 unsigned int config1;
639
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 config1 = read_c0_config1();
Ralf Baechle41943182005-05-05 16:45:59 +0000641
642 if (config1 & MIPS_CONF1_MD)
643 c->ases |= MIPS_ASE_MDMX;
644 if (config1 & MIPS_CONF1_WR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 c->options |= MIPS_CPU_WATCH;
Ralf Baechle41943182005-05-05 16:45:59 +0000646 if (config1 & MIPS_CONF1_CA)
647 c->ases |= MIPS_ASE_MIPS16;
648 if (config1 & MIPS_CONF1_EP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 c->options |= MIPS_CPU_EJTAG;
Ralf Baechle41943182005-05-05 16:45:59 +0000650 if (config1 & MIPS_CONF1_FP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 c->options |= MIPS_CPU_FPU;
652 c->options |= MIPS_CPU_32FPR;
653 }
Ralf Baechle41943182005-05-05 16:45:59 +0000654 if (cpu_has_tlb)
655 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
656
657 return config1 & MIPS_CONF_M;
658}
659
660static inline unsigned int decode_config2(struct cpuinfo_mips *c)
661{
662 unsigned int config2;
663
664 config2 = read_c0_config2();
665
666 if (config2 & MIPS_CONF2_SL)
667 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
668
669 return config2 & MIPS_CONF_M;
670}
671
672static inline unsigned int decode_config3(struct cpuinfo_mips *c)
673{
674 unsigned int config3;
675
676 config3 = read_c0_config3();
677
678 if (config3 & MIPS_CONF3_SM)
679 c->ases |= MIPS_ASE_SMARTMIPS;
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000680 if (config3 & MIPS_CONF3_DSP)
681 c->ases |= MIPS_ASE_DSP;
Ralf Baechle8f406112005-07-14 07:34:18 +0000682 if (config3 & MIPS_CONF3_VINT)
683 c->options |= MIPS_CPU_VINT;
684 if (config3 & MIPS_CONF3_VEIC)
685 c->options |= MIPS_CPU_VEIC;
686 if (config3 & MIPS_CONF3_MT)
Ralf Baechlee0daad42007-02-05 00:10:11 +0000687 c->ases |= MIPS_ASE_MIPSMT;
Ralf Baechlea3692022007-07-10 17:33:02 +0100688 if (config3 & MIPS_CONF3_ULRI)
689 c->options |= MIPS_CPU_ULRI;
Ralf Baechle41943182005-05-05 16:45:59 +0000690
691 return config3 & MIPS_CONF_M;
692}
693
Ralf Baechle234fcd12008-03-08 09:56:28 +0000694static void __cpuinit decode_configs(struct cpuinfo_mips *c)
Ralf Baechle41943182005-05-05 16:45:59 +0000695{
Ralf Baechle558ce122008-10-29 12:33:34 +0000696 int ok;
697
Ralf Baechle41943182005-05-05 16:45:59 +0000698 /* MIPS32 or MIPS64 compliant CPU. */
Ralf Baechle02cf2112005-10-01 13:06:32 +0100699 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
700 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
Ralf Baechle41943182005-05-05 16:45:59 +0000701
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
703
Ralf Baechle558ce122008-10-29 12:33:34 +0000704 ok = decode_config0(c); /* Read Config registers. */
705 BUG_ON(!ok); /* Arch spec violation! */
706 if (ok)
707 ok = decode_config1(c);
708 if (ok)
709 ok = decode_config2(c);
710 if (ok)
711 ok = decode_config3(c);
712
713 mips_probe_watch_registers(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714}
715
Chris Dearman0b6d4972007-09-13 12:32:02 +0100716#ifdef CONFIG_CPU_MIPSR2
717extern void spram_config(void);
718#else
719static inline void spram_config(void) {}
720#endif
721
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000722static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723{
Ralf Baechle41943182005-05-05 16:45:59 +0000724 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 switch (c->processor_id & 0xff00) {
726 case PRID_IMP_4KC:
727 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000728 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 break;
730 case PRID_IMP_4KEC:
731 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000732 __cpu_name[cpu] = "MIPS 4KEc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 break;
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000734 case PRID_IMP_4KECR2:
735 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000736 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000737 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100739 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000741 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 break;
743 case PRID_IMP_5KC:
744 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000745 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 break;
747 case PRID_IMP_20KC:
748 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000749 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 break;
751 case PRID_IMP_24K:
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000752 case PRID_IMP_24KE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000754 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 break;
756 case PRID_IMP_25KF:
757 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000758 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000760 case PRID_IMP_34K:
761 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000762 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000763 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100764 case PRID_IMP_74K:
765 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000766 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100767 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100768 case PRID_IMP_1004K:
769 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000770 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100771 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100773
774 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775}
776
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000777static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778{
Ralf Baechle41943182005-05-05 16:45:59 +0000779 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 switch (c->processor_id & 0xff00) {
781 case PRID_IMP_AU1_REV1:
782 case PRID_IMP_AU1_REV2:
783 switch ((c->processor_id >> 24) & 0xff) {
784 case 0:
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000785 c->cputype = CPU_AU1000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000786 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 break;
788 case 1:
789 c->cputype = CPU_AU1500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000790 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 break;
792 case 2:
793 c->cputype = CPU_AU1100;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000794 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 break;
796 case 3:
797 c->cputype = CPU_AU1550;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000798 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000800 case 4:
801 c->cputype = CPU_AU1200;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000802 __cpu_name[cpu] = "Au1200";
803 if ((c->processor_id & 0xff) == 2) {
Manuel Lauss237cfee2007-12-06 09:07:55 +0100804 c->cputype = CPU_AU1250;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000805 __cpu_name[cpu] = "Au1250";
806 }
Manuel Lauss237cfee2007-12-06 09:07:55 +0100807 break;
808 case 5:
809 c->cputype = CPU_AU1210;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000810 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000811 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 default:
813 panic("Unknown Au Core!");
814 break;
815 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 break;
817 }
818}
819
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000820static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821{
Ralf Baechle41943182005-05-05 16:45:59 +0000822 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100823
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824 switch (c->processor_id & 0xff00) {
825 case PRID_IMP_SB1:
826 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000827 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100829 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000830 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700832 case PRID_IMP_SB1A:
833 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000834 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700835 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 }
837}
838
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000839static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840{
Ralf Baechle41943182005-05-05 16:45:59 +0000841 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 switch (c->processor_id & 0xff00) {
843 case PRID_IMP_SR71000:
844 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000845 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846 c->scache.ways = 8;
847 c->tlbsize = 64;
848 break;
849 }
850}
851
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000852static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000853{
854 decode_configs(c);
855 switch (c->processor_id & 0xff00) {
856 case PRID_IMP_PR4450:
857 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000858 __cpu_name[cpu] = "Philips PR4450";
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000859 c->isa_level = MIPS_CPU_ISA_M32R1;
Pete Popovbdf21b12005-07-14 17:47:57 +0000860 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000861 }
862}
863
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000864static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200865{
866 decode_configs(c);
867 switch (c->processor_id & 0xff00) {
868 case PRID_IMP_BCM3302:
869 c->cputype = CPU_BCM3302;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000870 __cpu_name[cpu] = "Broadcom BCM3302";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200871 break;
872 case PRID_IMP_BCM4710:
873 c->cputype = CPU_BCM4710;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000874 __cpu_name[cpu] = "Broadcom BCM4710";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200875 break;
876 }
877}
878
David Daney0dd47812008-12-11 15:33:26 -0800879static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
880{
881 decode_configs(c);
882 switch (c->processor_id & 0xff00) {
883 case PRID_IMP_CAVIUM_CN38XX:
884 case PRID_IMP_CAVIUM_CN31XX:
885 case PRID_IMP_CAVIUM_CN30XX:
886 case PRID_IMP_CAVIUM_CN58XX:
887 case PRID_IMP_CAVIUM_CN56XX:
888 case PRID_IMP_CAVIUM_CN50XX:
889 case PRID_IMP_CAVIUM_CN52XX:
890 c->cputype = CPU_CAVIUM_OCTEON;
891 __cpu_name[cpu] = "Cavium Octeon";
892 break;
893 default:
894 printk(KERN_INFO "Unknown Octeon chip!\n");
895 c->cputype = CPU_UNKNOWN;
896 break;
897 }
898}
899
Ralf Baechle9966db252007-10-11 23:46:17 +0100900const char *__cpu_name[NR_CPUS];
901
Ralf Baechle234fcd12008-03-08 09:56:28 +0000902__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903{
904 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +0100905 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906
907 c->processor_id = PRID_IMP_UNKNOWN;
908 c->fpu_id = FPIR_IMP_NONE;
909 c->cputype = CPU_UNKNOWN;
910
911 c->processor_id = read_c0_prid();
912 switch (c->processor_id & 0xff0000) {
913 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000914 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915 break;
916 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000917 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918 break;
919 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000920 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921 break;
922 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000923 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200925 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000926 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200927 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700928 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000929 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930 break;
Daniel Lairda92b0582008-03-06 09:07:18 +0000931 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000932 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000933 break;
David Daney0dd47812008-12-11 15:33:26 -0800934 case PRID_COMP_CAVIUM:
935 cpu_probe_cavium(c, cpu);
936 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700937 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200938
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000939 BUG_ON(!__cpu_name[cpu]);
940 BUG_ON(c->cputype == CPU_UNKNOWN);
941
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200942 /*
943 * Platform code can force the cpu type to optimize code
944 * generation. In that case be sure the cpu type is correctly
945 * manually setup otherwise it could trigger some nasty bugs.
946 */
947 BUG_ON(current_cpu_type() != c->cputype);
948
Ralf Baechle41943182005-05-05 16:45:59 +0000949 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +0000951
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000952 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
Ralf Baechleb4672d32005-12-08 14:04:24 +0000953 c->isa_level == MIPS_CPU_ISA_M32R2 ||
954 c->isa_level == MIPS_CPU_ISA_M64R1 ||
955 c->isa_level == MIPS_CPU_ISA_M64R2) {
Ralf Baechle41943182005-05-05 16:45:59 +0000956 if (c->fpu_id & MIPS_FPIR_3D)
957 c->ases |= MIPS_ASE_MIPS3D;
958 }
959 }
Ralf Baechle9966db252007-10-11 23:46:17 +0100960
Ralf Baechlef6771db2007-11-08 18:02:29 +0000961 if (cpu_has_mips_r2)
962 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
963 else
964 c->srsets = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700965}
966
Ralf Baechle234fcd12008-03-08 09:56:28 +0000967__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968{
969 struct cpuinfo_mips *c = &current_cpu_data;
970
Ralf Baechle9966db252007-10-11 23:46:17 +0100971 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
972 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +0100974 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700975}