blob: b13b8eb3059631c732479aa4da8ed35c4cb48c5c [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{
Manuel Lauss0c694de2008-12-21 09:26:23 +010099 if (!allow_au1k_wait)
100 return;
101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 /* using the wait instruction makes CP0 counter unusable */
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900103 __asm__(" .set mips3 \n"
104 " cache 0x14, 0(%0) \n"
105 " cache 0x14, 32(%0) \n"
106 " sync \n"
107 " nop \n"
108 " wait \n"
109 " nop \n"
110 " nop \n"
111 " nop \n"
112 " nop \n"
113 " .set mips0 \n"
Ralf Baechle10f650d2005-05-25 13:32:49 +0000114 : : "r" (au1k_wait));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115}
116
Ralf Baechle55d04df2005-07-13 19:22:45 +0000117static int __initdata nowait = 0;
118
Atsushi Nemotof49a7472007-02-18 01:02:14 +0900119static int __init wait_disable(char *s)
Ralf Baechle55d04df2005-07-13 19:22:45 +0000120{
121 nowait = 1;
122
123 return 1;
124}
125
126__setup("nowait", wait_disable);
127
Atsushi Nemotoc65a5482007-11-12 02:05:18 +0900128void __init check_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129{
130 struct cpuinfo_mips *c = &current_cpu_data;
131
Ralf Baechle55d04df2005-07-13 19:22:45 +0000132 if (nowait) {
Ralf Baechlec2379232006-11-30 01:14:44 +0000133 printk("Wait instruction disabled.\n");
Ralf Baechle55d04df2005-07-13 19:22:45 +0000134 return;
135 }
136
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 switch (c->cputype) {
138 case CPU_R3081:
139 case CPU_R3081E:
140 cpu_wait = r3081_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 break;
142 case CPU_TX3927:
143 cpu_wait = r39xx_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 break;
145 case CPU_R4200:
146/* case CPU_R4300: */
147 case CPU_R4600:
148 case CPU_R4640:
149 case CPU_R4650:
150 case CPU_R4700:
151 case CPU_R5000:
Shinya Kuribayashia644b272009-03-03 18:05:51 +0900152 case CPU_R5500:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 case CPU_NEVADA:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 case CPU_4KC:
155 case CPU_4KEC:
156 case CPU_4KSC:
157 case CPU_5KC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 case CPU_25KF:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100159 case CPU_PR4450:
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200160 case CPU_BCM3302:
David Daney0dd47812008-12-11 15:33:26 -0800161 case CPU_CAVIUM_OCTEON:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 cpu_wait = r4k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 break;
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100164
Ralf Baechle5a812992007-07-17 18:49:48 +0100165 case CPU_RM7000:
166 cpu_wait = rm7k_wait_irqoff;
167 break;
168
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100169 case CPU_24K:
170 case CPU_34K:
Ralf Baechle39b8d522008-04-28 17:14:26 +0100171 case CPU_1004K:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100172 cpu_wait = r4k_wait;
173 if (read_c0_config7() & MIPS_CONF7_WII)
174 cpu_wait = r4k_wait_irqoff;
175 break;
176
177 case CPU_74K:
178 cpu_wait = r4k_wait;
179 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
180 cpu_wait = r4k_wait_irqoff;
181 break;
182
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900183 case CPU_TX49XX:
184 cpu_wait = r4k_wait_irqoff;
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900185 break;
Manuel Lauss270717a2009-03-25 17:49:28 +0100186 case CPU_ALCHEMY:
Manuel Lauss0c694de2008-12-21 09:26:23 +0100187 cpu_wait = au1k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 break;
Ralf Baechlec8eae712007-06-12 13:04:09 +0100189 case CPU_20KC:
190 /*
191 * WAIT on Rev1.0 has E1, E2, E3 and E16.
192 * WAIT on Rev2.0 and Rev3.0 has E16.
193 * Rev3.1 WAIT is nop, why bother
194 */
195 if ((c->processor_id & 0xff) <= 0x64)
196 break;
197
Ralf Baechle50da4692007-09-14 19:08:43 +0100198 /*
199 * Another rev is incremeting c0_count at a reduced clock
200 * rate while in WAIT mode. So we basically have the choice
201 * between using the cp0 timer as clocksource or avoiding
202 * the WAIT instruction. Until more details are known,
203 * disable the use of WAIT for 20Kc entirely.
204 cpu_wait = r4k_wait;
205 */
Ralf Baechlec8eae712007-06-12 13:04:09 +0100206 break;
Ralf Baechle441ee342006-06-02 11:48:11 +0100207 case CPU_RM9000:
Ralf Baechlec2379232006-11-30 01:14:44 +0000208 if ((c->processor_id & 0x00ff) >= 0x40)
Ralf Baechle441ee342006-06-02 11:48:11 +0100209 cpu_wait = r4k_wait;
Ralf Baechle441ee342006-06-02 11:48:11 +0100210 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 break;
213 }
214}
215
Marc St-Jean9267a302007-06-14 15:55:31 -0600216static inline void check_errata(void)
217{
218 struct cpuinfo_mips *c = &current_cpu_data;
219
220 switch (c->cputype) {
221 case CPU_34K:
222 /*
223 * Erratum "RPS May Cause Incorrect Instruction Execution"
224 * This code only handles VPE0, any SMP/SMTC/RTOS code
225 * making use of VPE1 will be responsable for that VPE.
226 */
227 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
228 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
229 break;
230 default:
231 break;
232 }
233}
234
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235void __init check_bugs32(void)
236{
Marc St-Jean9267a302007-06-14 15:55:31 -0600237 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238}
239
240/*
241 * Probe whether cpu has config register by trying to play with
242 * alternate cache bit and see whether it matters.
243 * It's used by cpu_probe to distinguish between R3000A and R3081.
244 */
245static inline int cpu_has_confreg(void)
246{
247#ifdef CONFIG_CPU_R3000
248 extern unsigned long r3k_cache_size(unsigned long);
249 unsigned long size1, size2;
250 unsigned long cfg = read_c0_conf();
251
252 size1 = r3k_cache_size(ST0_ISC);
253 write_c0_conf(cfg ^ R30XX_CONF_AC);
254 size2 = r3k_cache_size(ST0_ISC);
255 write_c0_conf(cfg);
256 return size1 != size2;
257#else
258 return 0;
259#endif
260}
261
262/*
263 * Get the FPU Implementation/Revision.
264 */
265static inline unsigned long cpu_get_fpu_id(void)
266{
267 unsigned long tmp, fpu_id;
268
269 tmp = read_c0_status();
270 __enable_fpu();
271 fpu_id = read_32bit_cp1_register(CP1_REVISION);
272 write_c0_status(tmp);
273 return fpu_id;
274}
275
276/*
277 * Check the CPU has an FPU the official way.
278 */
279static inline int __cpu_has_fpu(void)
280{
281 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
282}
283
Ralf Baechle02cf2112005-10-01 13:06:32 +0100284#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 | MIPS_CPU_COUNTER)
286
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000287static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288{
289 switch (c->processor_id & 0xff00) {
290 case PRID_IMP_R2000:
291 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000292 __cpu_name[cpu] = "R2000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100294 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
295 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 if (__cpu_has_fpu())
297 c->options |= MIPS_CPU_FPU;
298 c->tlbsize = 64;
299 break;
300 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000301 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
302 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000304 __cpu_name[cpu] = "R3081";
305 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000307 __cpu_name[cpu] = "R3000A";
308 }
309 break;
310 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000312 __cpu_name[cpu] = "R3000";
313 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100315 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
316 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 if (__cpu_has_fpu())
318 c->options |= MIPS_CPU_FPU;
319 c->tlbsize = 64;
320 break;
321 case PRID_IMP_R4000:
322 if (read_c0_config() & CONF_SC) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000323 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000325 __cpu_name[cpu] = "R4400PC";
326 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000328 __cpu_name[cpu] = "R4000PC";
329 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 } else {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000331 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 c->cputype = CPU_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000333 __cpu_name[cpu] = "R4400SC";
334 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000336 __cpu_name[cpu] = "R4000SC";
337 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 }
339
340 c->isa_level = MIPS_CPU_ISA_III;
341 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
342 MIPS_CPU_WATCH | MIPS_CPU_VCE |
343 MIPS_CPU_LLSC;
344 c->tlbsize = 48;
345 break;
346 case PRID_IMP_VR41XX:
347 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 case PRID_REV_VR4111:
349 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000350 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 case PRID_REV_VR4121:
353 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000354 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 break;
356 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000357 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000359 __cpu_name[cpu] = "NEC VR4122";
360 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000362 __cpu_name[cpu] = "NEC VR4181A";
363 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 break;
365 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000366 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000368 __cpu_name[cpu] = "NEC VR4131";
369 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 c->cputype = CPU_VR4133;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000371 __cpu_name[cpu] = "NEC VR4133";
372 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 break;
374 default:
375 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
376 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000377 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 break;
379 }
380 c->isa_level = MIPS_CPU_ISA_III;
381 c->options = R4K_OPTS;
382 c->tlbsize = 32;
383 break;
384 case PRID_IMP_R4300:
385 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000386 __cpu_name[cpu] = "R4300";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 c->isa_level = MIPS_CPU_ISA_III;
388 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
389 MIPS_CPU_LLSC;
390 c->tlbsize = 32;
391 break;
392 case PRID_IMP_R4600:
393 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000394 __cpu_name[cpu] = "R4600";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 c->isa_level = MIPS_CPU_ISA_III;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000396 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
397 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 c->tlbsize = 48;
399 break;
400 #if 0
401 case PRID_IMP_R4650:
402 /*
403 * This processor doesn't have an MMU, so it's not
404 * "real easy" to run Linux on it. It is left purely
405 * for documentation. Commented out because it shares
406 * it's c0_prid id number with the TX3900.
407 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000408 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000409 __cpu_name[cpu] = "R4650";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 c->isa_level = MIPS_CPU_ISA_III;
411 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
412 c->tlbsize = 48;
413 break;
414 #endif
415 case PRID_IMP_TX39:
416 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100417 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418
419 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
420 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000421 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 c->tlbsize = 64;
423 } else {
424 switch (c->processor_id & 0xff) {
425 case PRID_REV_TX3912:
426 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000427 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 c->tlbsize = 32;
429 break;
430 case PRID_REV_TX3922:
431 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000432 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 c->tlbsize = 64;
434 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 }
436 }
437 break;
438 case PRID_IMP_R4700:
439 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000440 __cpu_name[cpu] = "R4700";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 c->isa_level = MIPS_CPU_ISA_III;
442 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
443 MIPS_CPU_LLSC;
444 c->tlbsize = 48;
445 break;
446 case PRID_IMP_TX49:
447 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000448 __cpu_name[cpu] = "R49XX";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 c->isa_level = MIPS_CPU_ISA_III;
450 c->options = R4K_OPTS | MIPS_CPU_LLSC;
451 if (!(c->processor_id & 0x08))
452 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
453 c->tlbsize = 48;
454 break;
455 case PRID_IMP_R5000:
456 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000457 __cpu_name[cpu] = "R5000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 c->isa_level = MIPS_CPU_ISA_IV;
459 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
460 MIPS_CPU_LLSC;
461 c->tlbsize = 48;
462 break;
463 case PRID_IMP_R5432:
464 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000465 __cpu_name[cpu] = "R5432";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 c->isa_level = MIPS_CPU_ISA_IV;
467 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
468 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
469 c->tlbsize = 48;
470 break;
471 case PRID_IMP_R5500:
472 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000473 __cpu_name[cpu] = "R5500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 c->isa_level = MIPS_CPU_ISA_IV;
475 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
476 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
477 c->tlbsize = 48;
478 break;
479 case PRID_IMP_NEVADA:
480 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000481 __cpu_name[cpu] = "Nevada";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 c->isa_level = MIPS_CPU_ISA_IV;
483 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
484 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
485 c->tlbsize = 48;
486 break;
487 case PRID_IMP_R6000:
488 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000489 __cpu_name[cpu] = "R6000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 c->isa_level = MIPS_CPU_ISA_II;
491 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
492 MIPS_CPU_LLSC;
493 c->tlbsize = 32;
494 break;
495 case PRID_IMP_R6000A:
496 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000497 __cpu_name[cpu] = "R6000A";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 c->isa_level = MIPS_CPU_ISA_II;
499 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
500 MIPS_CPU_LLSC;
501 c->tlbsize = 32;
502 break;
503 case PRID_IMP_RM7000:
504 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000505 __cpu_name[cpu] = "RM7000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 c->isa_level = MIPS_CPU_ISA_IV;
507 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
508 MIPS_CPU_LLSC;
509 /*
510 * Undocumented RM7000: Bit 29 in the info register of
511 * the RM7000 v2.0 indicates if the TLB has 48 or 64
512 * entries.
513 *
514 * 29 1 => 64 entry JTLB
515 * 0 => 48 entry JTLB
516 */
517 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
518 break;
519 case PRID_IMP_RM9000:
520 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000521 __cpu_name[cpu] = "RM9000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 c->isa_level = MIPS_CPU_ISA_IV;
523 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
524 MIPS_CPU_LLSC;
525 /*
526 * Bit 29 in the info register of the RM9000
527 * indicates if the TLB has 48 or 64 entries.
528 *
529 * 29 1 => 64 entry JTLB
530 * 0 => 48 entry JTLB
531 */
532 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
533 break;
534 case PRID_IMP_R8000:
535 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000536 __cpu_name[cpu] = "RM8000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 c->isa_level = MIPS_CPU_ISA_IV;
538 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
539 MIPS_CPU_FPU | MIPS_CPU_32FPR |
540 MIPS_CPU_LLSC;
541 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
542 break;
543 case PRID_IMP_R10000:
544 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000545 __cpu_name[cpu] = "R10000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000547 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 MIPS_CPU_FPU | MIPS_CPU_32FPR |
549 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
550 MIPS_CPU_LLSC;
551 c->tlbsize = 64;
552 break;
553 case PRID_IMP_R12000:
554 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000555 __cpu_name[cpu] = "R12000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000557 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 MIPS_CPU_FPU | MIPS_CPU_32FPR |
559 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
560 MIPS_CPU_LLSC;
561 c->tlbsize = 64;
562 break;
Kumba44d921b2006-05-16 22:23:59 -0400563 case PRID_IMP_R14000:
564 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000565 __cpu_name[cpu] = "R14000";
Kumba44d921b2006-05-16 22:23:59 -0400566 c->isa_level = MIPS_CPU_ISA_IV;
567 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
568 MIPS_CPU_FPU | MIPS_CPU_32FPR |
569 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
570 MIPS_CPU_LLSC;
571 c->tlbsize = 64;
572 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800573 case PRID_IMP_LOONGSON2:
574 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000575 __cpu_name[cpu] = "ICT Loongson-2";
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800576 c->isa_level = MIPS_CPU_ISA_III;
577 c->options = R4K_OPTS |
578 MIPS_CPU_FPU | MIPS_CPU_LLSC |
579 MIPS_CPU_32FPR;
580 c->tlbsize = 64;
581 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 }
583}
584
Ralf Baechle234fcd12008-03-08 09:56:28 +0000585static char unknown_isa[] __cpuinitdata = KERN_ERR \
Ralf Baechleb4672d32005-12-08 14:04:24 +0000586 "Unsupported ISA type, c0.config0: %d.";
587
Ralf Baechle41943182005-05-05 16:45:59 +0000588static inline unsigned int decode_config0(struct cpuinfo_mips *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589{
Ralf Baechle41943182005-05-05 16:45:59 +0000590 unsigned int config0;
591 int isa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592
Ralf Baechle41943182005-05-05 16:45:59 +0000593 config0 = read_c0_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594
Ralf Baechle41943182005-05-05 16:45:59 +0000595 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
Ralf Baechle02cf2112005-10-01 13:06:32 +0100596 c->options |= MIPS_CPU_TLB;
Ralf Baechle41943182005-05-05 16:45:59 +0000597 isa = (config0 & MIPS_CONF_AT) >> 13;
598 switch (isa) {
599 case 0:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100600 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000601 case 0:
602 c->isa_level = MIPS_CPU_ISA_M32R1;
603 break;
604 case 1:
605 c->isa_level = MIPS_CPU_ISA_M32R2;
606 break;
607 default:
608 goto unknown;
609 }
Ralf Baechle41943182005-05-05 16:45:59 +0000610 break;
611 case 2:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100612 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000613 case 0:
614 c->isa_level = MIPS_CPU_ISA_M64R1;
615 break;
616 case 1:
617 c->isa_level = MIPS_CPU_ISA_M64R2;
618 break;
619 default:
620 goto unknown;
621 }
Ralf Baechle41943182005-05-05 16:45:59 +0000622 break;
623 default:
Ralf Baechleb4672d32005-12-08 14:04:24 +0000624 goto unknown;
Ralf Baechle41943182005-05-05 16:45:59 +0000625 }
626
627 return config0 & MIPS_CONF_M;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000628
629unknown:
630 panic(unknown_isa, config0);
Ralf Baechle41943182005-05-05 16:45:59 +0000631}
632
633static inline unsigned int decode_config1(struct cpuinfo_mips *c)
634{
635 unsigned int config1;
636
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 config1 = read_c0_config1();
Ralf Baechle41943182005-05-05 16:45:59 +0000638
639 if (config1 & MIPS_CONF1_MD)
640 c->ases |= MIPS_ASE_MDMX;
641 if (config1 & MIPS_CONF1_WR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 c->options |= MIPS_CPU_WATCH;
Ralf Baechle41943182005-05-05 16:45:59 +0000643 if (config1 & MIPS_CONF1_CA)
644 c->ases |= MIPS_ASE_MIPS16;
645 if (config1 & MIPS_CONF1_EP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 c->options |= MIPS_CPU_EJTAG;
Ralf Baechle41943182005-05-05 16:45:59 +0000647 if (config1 & MIPS_CONF1_FP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 c->options |= MIPS_CPU_FPU;
649 c->options |= MIPS_CPU_32FPR;
650 }
Ralf Baechle41943182005-05-05 16:45:59 +0000651 if (cpu_has_tlb)
652 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
653
654 return config1 & MIPS_CONF_M;
655}
656
657static inline unsigned int decode_config2(struct cpuinfo_mips *c)
658{
659 unsigned int config2;
660
661 config2 = read_c0_config2();
662
663 if (config2 & MIPS_CONF2_SL)
664 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
665
666 return config2 & MIPS_CONF_M;
667}
668
669static inline unsigned int decode_config3(struct cpuinfo_mips *c)
670{
671 unsigned int config3;
672
673 config3 = read_c0_config3();
674
675 if (config3 & MIPS_CONF3_SM)
676 c->ases |= MIPS_ASE_SMARTMIPS;
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000677 if (config3 & MIPS_CONF3_DSP)
678 c->ases |= MIPS_ASE_DSP;
Ralf Baechle8f406112005-07-14 07:34:18 +0000679 if (config3 & MIPS_CONF3_VINT)
680 c->options |= MIPS_CPU_VINT;
681 if (config3 & MIPS_CONF3_VEIC)
682 c->options |= MIPS_CPU_VEIC;
683 if (config3 & MIPS_CONF3_MT)
Ralf Baechlee0daad42007-02-05 00:10:11 +0000684 c->ases |= MIPS_ASE_MIPSMT;
Ralf Baechlea3692022007-07-10 17:33:02 +0100685 if (config3 & MIPS_CONF3_ULRI)
686 c->options |= MIPS_CPU_ULRI;
Ralf Baechle41943182005-05-05 16:45:59 +0000687
688 return config3 & MIPS_CONF_M;
689}
690
Ralf Baechle234fcd12008-03-08 09:56:28 +0000691static void __cpuinit decode_configs(struct cpuinfo_mips *c)
Ralf Baechle41943182005-05-05 16:45:59 +0000692{
Ralf Baechle558ce122008-10-29 12:33:34 +0000693 int ok;
694
Ralf Baechle41943182005-05-05 16:45:59 +0000695 /* MIPS32 or MIPS64 compliant CPU. */
Ralf Baechle02cf2112005-10-01 13:06:32 +0100696 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
697 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
Ralf Baechle41943182005-05-05 16:45:59 +0000698
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
700
Ralf Baechle558ce122008-10-29 12:33:34 +0000701 ok = decode_config0(c); /* Read Config registers. */
702 BUG_ON(!ok); /* Arch spec violation! */
703 if (ok)
704 ok = decode_config1(c);
705 if (ok)
706 ok = decode_config2(c);
707 if (ok)
708 ok = decode_config3(c);
709
710 mips_probe_watch_registers(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711}
712
Chris Dearman0b6d4972007-09-13 12:32:02 +0100713#ifdef CONFIG_CPU_MIPSR2
714extern void spram_config(void);
715#else
716static inline void spram_config(void) {}
717#endif
718
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000719static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720{
Ralf Baechle41943182005-05-05 16:45:59 +0000721 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 switch (c->processor_id & 0xff00) {
723 case PRID_IMP_4KC:
724 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000725 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 break;
727 case PRID_IMP_4KEC:
728 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000729 __cpu_name[cpu] = "MIPS 4KEc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 break;
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000731 case PRID_IMP_4KECR2:
732 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000733 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000734 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100736 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000738 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 break;
740 case PRID_IMP_5KC:
741 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000742 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 break;
744 case PRID_IMP_20KC:
745 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000746 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 break;
748 case PRID_IMP_24K:
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000749 case PRID_IMP_24KE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000751 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 break;
753 case PRID_IMP_25KF:
754 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000755 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000757 case PRID_IMP_34K:
758 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000759 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000760 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100761 case PRID_IMP_74K:
762 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000763 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100764 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100765 case PRID_IMP_1004K:
766 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000767 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100768 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100770
771 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772}
773
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000774static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775{
Ralf Baechle41943182005-05-05 16:45:59 +0000776 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 switch (c->processor_id & 0xff00) {
778 case PRID_IMP_AU1_REV1:
779 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100780 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 switch ((c->processor_id >> 24) & 0xff) {
782 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000783 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784 break;
785 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000786 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 break;
788 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000789 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 break;
791 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000792 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000794 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000795 __cpu_name[cpu] = "Au1200";
Manuel Lauss270717a2009-03-25 17:49:28 +0100796 if ((c->processor_id & 0xff) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000797 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100798 break;
799 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000800 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000801 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100803 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804 break;
805 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 break;
807 }
808}
809
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000810static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811{
Ralf Baechle41943182005-05-05 16:45:59 +0000812 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100813
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 switch (c->processor_id & 0xff00) {
815 case PRID_IMP_SB1:
816 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000817 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100819 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000820 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700822 case PRID_IMP_SB1A:
823 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000824 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700825 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826 }
827}
828
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000829static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830{
Ralf Baechle41943182005-05-05 16:45:59 +0000831 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 switch (c->processor_id & 0xff00) {
833 case PRID_IMP_SR71000:
834 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000835 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 c->scache.ways = 8;
837 c->tlbsize = 64;
838 break;
839 }
840}
841
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000842static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000843{
844 decode_configs(c);
845 switch (c->processor_id & 0xff00) {
846 case PRID_IMP_PR4450:
847 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000848 __cpu_name[cpu] = "Philips PR4450";
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000849 c->isa_level = MIPS_CPU_ISA_M32R1;
Pete Popovbdf21b12005-07-14 17:47:57 +0000850 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000851 }
852}
853
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000854static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200855{
856 decode_configs(c);
857 switch (c->processor_id & 0xff00) {
858 case PRID_IMP_BCM3302:
859 c->cputype = CPU_BCM3302;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000860 __cpu_name[cpu] = "Broadcom BCM3302";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200861 break;
862 case PRID_IMP_BCM4710:
863 c->cputype = CPU_BCM4710;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000864 __cpu_name[cpu] = "Broadcom BCM4710";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200865 break;
866 }
867}
868
David Daney0dd47812008-12-11 15:33:26 -0800869static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
870{
871 decode_configs(c);
872 switch (c->processor_id & 0xff00) {
873 case PRID_IMP_CAVIUM_CN38XX:
874 case PRID_IMP_CAVIUM_CN31XX:
875 case PRID_IMP_CAVIUM_CN30XX:
876 case PRID_IMP_CAVIUM_CN58XX:
877 case PRID_IMP_CAVIUM_CN56XX:
878 case PRID_IMP_CAVIUM_CN50XX:
879 case PRID_IMP_CAVIUM_CN52XX:
880 c->cputype = CPU_CAVIUM_OCTEON;
881 __cpu_name[cpu] = "Cavium Octeon";
882 break;
883 default:
884 printk(KERN_INFO "Unknown Octeon chip!\n");
885 c->cputype = CPU_UNKNOWN;
886 break;
887 }
888}
889
Ralf Baechle9966db252007-10-11 23:46:17 +0100890const char *__cpu_name[NR_CPUS];
891
Ralf Baechle234fcd12008-03-08 09:56:28 +0000892__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893{
894 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +0100895 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896
897 c->processor_id = PRID_IMP_UNKNOWN;
898 c->fpu_id = FPIR_IMP_NONE;
899 c->cputype = CPU_UNKNOWN;
900
901 c->processor_id = read_c0_prid();
902 switch (c->processor_id & 0xff0000) {
903 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000904 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905 break;
906 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000907 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908 break;
909 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000910 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911 break;
912 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000913 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200915 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000916 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200917 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000919 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920 break;
Daniel Lairda92b0582008-03-06 09:07:18 +0000921 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000922 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000923 break;
David Daney0dd47812008-12-11 15:33:26 -0800924 case PRID_COMP_CAVIUM:
925 cpu_probe_cavium(c, cpu);
926 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200928
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000929 BUG_ON(!__cpu_name[cpu]);
930 BUG_ON(c->cputype == CPU_UNKNOWN);
931
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200932 /*
933 * Platform code can force the cpu type to optimize code
934 * generation. In that case be sure the cpu type is correctly
935 * manually setup otherwise it could trigger some nasty bugs.
936 */
937 BUG_ON(current_cpu_type() != c->cputype);
938
Ralf Baechle41943182005-05-05 16:45:59 +0000939 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700940 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +0000941
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000942 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
Ralf Baechleb4672d32005-12-08 14:04:24 +0000943 c->isa_level == MIPS_CPU_ISA_M32R2 ||
944 c->isa_level == MIPS_CPU_ISA_M64R1 ||
945 c->isa_level == MIPS_CPU_ISA_M64R2) {
Ralf Baechle41943182005-05-05 16:45:59 +0000946 if (c->fpu_id & MIPS_FPIR_3D)
947 c->ases |= MIPS_ASE_MIPS3D;
948 }
949 }
Ralf Baechle9966db252007-10-11 23:46:17 +0100950
Ralf Baechlef6771db2007-11-08 18:02:29 +0000951 if (cpu_has_mips_r2)
952 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
953 else
954 c->srsets = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955}
956
Ralf Baechle234fcd12008-03-08 09:56:28 +0000957__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958{
959 struct cpuinfo_mips *c = &current_cpu_data;
960
Ralf Baechle9966db252007-10-11 23:46:17 +0100961 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
962 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -0700963 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +0100964 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700965}