blob: a7162a4484cff791612d00d028280aa0132c67e4 [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:
152 case CPU_NEVADA:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 case CPU_4KC:
154 case CPU_4KEC:
155 case CPU_4KSC:
156 case CPU_5KC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 case CPU_25KF:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100158 case CPU_PR4450:
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200159 case CPU_BCM3302:
David Daney0dd47812008-12-11 15:33:26 -0800160 case CPU_CAVIUM_OCTEON:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 cpu_wait = r4k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 break;
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100163
Ralf Baechle5a812992007-07-17 18:49:48 +0100164 case CPU_RM7000:
165 cpu_wait = rm7k_wait_irqoff;
166 break;
167
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100168 case CPU_24K:
169 case CPU_34K:
Ralf Baechle39b8d522008-04-28 17:14:26 +0100170 case CPU_1004K:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100171 cpu_wait = r4k_wait;
172 if (read_c0_config7() & MIPS_CONF7_WII)
173 cpu_wait = r4k_wait_irqoff;
174 break;
175
176 case CPU_74K:
177 cpu_wait = r4k_wait;
178 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
179 cpu_wait = r4k_wait_irqoff;
180 break;
181
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900182 case CPU_TX49XX:
183 cpu_wait = r4k_wait_irqoff;
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900184 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 case CPU_AU1000:
186 case CPU_AU1100:
187 case CPU_AU1500:
Pete Popove3ad1c22005-03-01 06:33:16 +0000188 case CPU_AU1550:
189 case CPU_AU1200:
Manuel Lauss237cfee2007-12-06 09:07:55 +0100190 case CPU_AU1210:
191 case CPU_AU1250:
Manuel Lauss0c694de2008-12-21 09:26:23 +0100192 cpu_wait = au1k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 break;
Ralf Baechlec8eae712007-06-12 13:04:09 +0100194 case CPU_20KC:
195 /*
196 * WAIT on Rev1.0 has E1, E2, E3 and E16.
197 * WAIT on Rev2.0 and Rev3.0 has E16.
198 * Rev3.1 WAIT is nop, why bother
199 */
200 if ((c->processor_id & 0xff) <= 0x64)
201 break;
202
Ralf Baechle50da4692007-09-14 19:08:43 +0100203 /*
204 * Another rev is incremeting c0_count at a reduced clock
205 * rate while in WAIT mode. So we basically have the choice
206 * between using the cp0 timer as clocksource or avoiding
207 * the WAIT instruction. Until more details are known,
208 * disable the use of WAIT for 20Kc entirely.
209 cpu_wait = r4k_wait;
210 */
Ralf Baechlec8eae712007-06-12 13:04:09 +0100211 break;
Ralf Baechle441ee342006-06-02 11:48:11 +0100212 case CPU_RM9000:
Ralf Baechlec2379232006-11-30 01:14:44 +0000213 if ((c->processor_id & 0x00ff) >= 0x40)
Ralf Baechle441ee342006-06-02 11:48:11 +0100214 cpu_wait = r4k_wait;
Ralf Baechle441ee342006-06-02 11:48:11 +0100215 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 break;
218 }
219}
220
Marc St-Jean9267a302007-06-14 15:55:31 -0600221static inline void check_errata(void)
222{
223 struct cpuinfo_mips *c = &current_cpu_data;
224
225 switch (c->cputype) {
226 case CPU_34K:
227 /*
228 * Erratum "RPS May Cause Incorrect Instruction Execution"
229 * This code only handles VPE0, any SMP/SMTC/RTOS code
230 * making use of VPE1 will be responsable for that VPE.
231 */
232 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
233 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
234 break;
235 default:
236 break;
237 }
238}
239
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240void __init check_bugs32(void)
241{
Marc St-Jean9267a302007-06-14 15:55:31 -0600242 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243}
244
245/*
246 * Probe whether cpu has config register by trying to play with
247 * alternate cache bit and see whether it matters.
248 * It's used by cpu_probe to distinguish between R3000A and R3081.
249 */
250static inline int cpu_has_confreg(void)
251{
252#ifdef CONFIG_CPU_R3000
253 extern unsigned long r3k_cache_size(unsigned long);
254 unsigned long size1, size2;
255 unsigned long cfg = read_c0_conf();
256
257 size1 = r3k_cache_size(ST0_ISC);
258 write_c0_conf(cfg ^ R30XX_CONF_AC);
259 size2 = r3k_cache_size(ST0_ISC);
260 write_c0_conf(cfg);
261 return size1 != size2;
262#else
263 return 0;
264#endif
265}
266
267/*
268 * Get the FPU Implementation/Revision.
269 */
270static inline unsigned long cpu_get_fpu_id(void)
271{
272 unsigned long tmp, fpu_id;
273
274 tmp = read_c0_status();
275 __enable_fpu();
276 fpu_id = read_32bit_cp1_register(CP1_REVISION);
277 write_c0_status(tmp);
278 return fpu_id;
279}
280
281/*
282 * Check the CPU has an FPU the official way.
283 */
284static inline int __cpu_has_fpu(void)
285{
286 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
287}
288
Ralf Baechle02cf2112005-10-01 13:06:32 +0100289#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 | MIPS_CPU_COUNTER)
291
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000292static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293{
294 switch (c->processor_id & 0xff00) {
295 case PRID_IMP_R2000:
296 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000297 __cpu_name[cpu] = "R2000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100299 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
300 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 if (__cpu_has_fpu())
302 c->options |= MIPS_CPU_FPU;
303 c->tlbsize = 64;
304 break;
305 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000306 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
307 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000309 __cpu_name[cpu] = "R3081";
310 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000312 __cpu_name[cpu] = "R3000A";
313 }
314 break;
315 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000317 __cpu_name[cpu] = "R3000";
318 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100320 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
321 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 if (__cpu_has_fpu())
323 c->options |= MIPS_CPU_FPU;
324 c->tlbsize = 64;
325 break;
326 case PRID_IMP_R4000:
327 if (read_c0_config() & CONF_SC) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000328 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000330 __cpu_name[cpu] = "R4400PC";
331 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000333 __cpu_name[cpu] = "R4000PC";
334 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 } else {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000336 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 c->cputype = CPU_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000338 __cpu_name[cpu] = "R4400SC";
339 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000341 __cpu_name[cpu] = "R4000SC";
342 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 }
344
345 c->isa_level = MIPS_CPU_ISA_III;
346 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
347 MIPS_CPU_WATCH | MIPS_CPU_VCE |
348 MIPS_CPU_LLSC;
349 c->tlbsize = 48;
350 break;
351 case PRID_IMP_VR41XX:
352 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 case PRID_REV_VR4111:
354 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000355 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 case PRID_REV_VR4121:
358 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000359 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 break;
361 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000362 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000364 __cpu_name[cpu] = "NEC VR4122";
365 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000367 __cpu_name[cpu] = "NEC VR4181A";
368 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 break;
370 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000371 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000373 __cpu_name[cpu] = "NEC VR4131";
374 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 c->cputype = CPU_VR4133;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000376 __cpu_name[cpu] = "NEC VR4133";
377 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 break;
379 default:
380 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
381 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000382 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 break;
384 }
385 c->isa_level = MIPS_CPU_ISA_III;
386 c->options = R4K_OPTS;
387 c->tlbsize = 32;
388 break;
389 case PRID_IMP_R4300:
390 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000391 __cpu_name[cpu] = "R4300";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 c->isa_level = MIPS_CPU_ISA_III;
393 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
394 MIPS_CPU_LLSC;
395 c->tlbsize = 32;
396 break;
397 case PRID_IMP_R4600:
398 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000399 __cpu_name[cpu] = "R4600";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 c->isa_level = MIPS_CPU_ISA_III;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000401 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
402 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 c->tlbsize = 48;
404 break;
405 #if 0
406 case PRID_IMP_R4650:
407 /*
408 * This processor doesn't have an MMU, so it's not
409 * "real easy" to run Linux on it. It is left purely
410 * for documentation. Commented out because it shares
411 * it's c0_prid id number with the TX3900.
412 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000413 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000414 __cpu_name[cpu] = "R4650";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415 c->isa_level = MIPS_CPU_ISA_III;
416 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
417 c->tlbsize = 48;
418 break;
419 #endif
420 case PRID_IMP_TX39:
421 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100422 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423
424 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
425 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000426 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 c->tlbsize = 64;
428 } else {
429 switch (c->processor_id & 0xff) {
430 case PRID_REV_TX3912:
431 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000432 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 c->tlbsize = 32;
434 break;
435 case PRID_REV_TX3922:
436 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000437 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 c->tlbsize = 64;
439 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 }
441 }
442 break;
443 case PRID_IMP_R4700:
444 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000445 __cpu_name[cpu] = "R4700";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 c->isa_level = MIPS_CPU_ISA_III;
447 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
448 MIPS_CPU_LLSC;
449 c->tlbsize = 48;
450 break;
451 case PRID_IMP_TX49:
452 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000453 __cpu_name[cpu] = "R49XX";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 c->isa_level = MIPS_CPU_ISA_III;
455 c->options = R4K_OPTS | MIPS_CPU_LLSC;
456 if (!(c->processor_id & 0x08))
457 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
458 c->tlbsize = 48;
459 break;
460 case PRID_IMP_R5000:
461 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000462 __cpu_name[cpu] = "R5000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 c->isa_level = MIPS_CPU_ISA_IV;
464 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
465 MIPS_CPU_LLSC;
466 c->tlbsize = 48;
467 break;
468 case PRID_IMP_R5432:
469 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000470 __cpu_name[cpu] = "R5432";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 c->isa_level = MIPS_CPU_ISA_IV;
472 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
473 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
474 c->tlbsize = 48;
475 break;
476 case PRID_IMP_R5500:
477 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000478 __cpu_name[cpu] = "R5500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 c->isa_level = MIPS_CPU_ISA_IV;
480 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
481 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
482 c->tlbsize = 48;
483 break;
484 case PRID_IMP_NEVADA:
485 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000486 __cpu_name[cpu] = "Nevada";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 c->isa_level = MIPS_CPU_ISA_IV;
488 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
489 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
490 c->tlbsize = 48;
491 break;
492 case PRID_IMP_R6000:
493 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000494 __cpu_name[cpu] = "R6000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 c->isa_level = MIPS_CPU_ISA_II;
496 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
497 MIPS_CPU_LLSC;
498 c->tlbsize = 32;
499 break;
500 case PRID_IMP_R6000A:
501 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000502 __cpu_name[cpu] = "R6000A";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 c->isa_level = MIPS_CPU_ISA_II;
504 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
505 MIPS_CPU_LLSC;
506 c->tlbsize = 32;
507 break;
508 case PRID_IMP_RM7000:
509 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000510 __cpu_name[cpu] = "RM7000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 c->isa_level = MIPS_CPU_ISA_IV;
512 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
513 MIPS_CPU_LLSC;
514 /*
515 * Undocumented RM7000: Bit 29 in the info register of
516 * the RM7000 v2.0 indicates if the TLB has 48 or 64
517 * entries.
518 *
519 * 29 1 => 64 entry JTLB
520 * 0 => 48 entry JTLB
521 */
522 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
523 break;
524 case PRID_IMP_RM9000:
525 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000526 __cpu_name[cpu] = "RM9000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 c->isa_level = MIPS_CPU_ISA_IV;
528 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
529 MIPS_CPU_LLSC;
530 /*
531 * Bit 29 in the info register of the RM9000
532 * indicates if the TLB has 48 or 64 entries.
533 *
534 * 29 1 => 64 entry JTLB
535 * 0 => 48 entry JTLB
536 */
537 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
538 break;
539 case PRID_IMP_R8000:
540 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000541 __cpu_name[cpu] = "RM8000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 c->isa_level = MIPS_CPU_ISA_IV;
543 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
544 MIPS_CPU_FPU | MIPS_CPU_32FPR |
545 MIPS_CPU_LLSC;
546 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
547 break;
548 case PRID_IMP_R10000:
549 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000550 __cpu_name[cpu] = "R10000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000552 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 MIPS_CPU_FPU | MIPS_CPU_32FPR |
554 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
555 MIPS_CPU_LLSC;
556 c->tlbsize = 64;
557 break;
558 case PRID_IMP_R12000:
559 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000560 __cpu_name[cpu] = "R12000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000562 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 MIPS_CPU_FPU | MIPS_CPU_32FPR |
564 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
565 MIPS_CPU_LLSC;
566 c->tlbsize = 64;
567 break;
Kumba44d921b2006-05-16 22:23:59 -0400568 case PRID_IMP_R14000:
569 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000570 __cpu_name[cpu] = "R14000";
Kumba44d921b2006-05-16 22:23:59 -0400571 c->isa_level = MIPS_CPU_ISA_IV;
572 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
573 MIPS_CPU_FPU | MIPS_CPU_32FPR |
574 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
575 MIPS_CPU_LLSC;
576 c->tlbsize = 64;
577 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800578 case PRID_IMP_LOONGSON2:
579 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000580 __cpu_name[cpu] = "ICT Loongson-2";
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800581 c->isa_level = MIPS_CPU_ISA_III;
582 c->options = R4K_OPTS |
583 MIPS_CPU_FPU | MIPS_CPU_LLSC |
584 MIPS_CPU_32FPR;
585 c->tlbsize = 64;
586 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 }
588}
589
Ralf Baechle234fcd12008-03-08 09:56:28 +0000590static char unknown_isa[] __cpuinitdata = KERN_ERR \
Ralf Baechleb4672d32005-12-08 14:04:24 +0000591 "Unsupported ISA type, c0.config0: %d.";
592
Ralf Baechle41943182005-05-05 16:45:59 +0000593static inline unsigned int decode_config0(struct cpuinfo_mips *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594{
Ralf Baechle41943182005-05-05 16:45:59 +0000595 unsigned int config0;
596 int isa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597
Ralf Baechle41943182005-05-05 16:45:59 +0000598 config0 = read_c0_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599
Ralf Baechle41943182005-05-05 16:45:59 +0000600 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
Ralf Baechle02cf2112005-10-01 13:06:32 +0100601 c->options |= MIPS_CPU_TLB;
Ralf Baechle41943182005-05-05 16:45:59 +0000602 isa = (config0 & MIPS_CONF_AT) >> 13;
603 switch (isa) {
604 case 0:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100605 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000606 case 0:
607 c->isa_level = MIPS_CPU_ISA_M32R1;
608 break;
609 case 1:
610 c->isa_level = MIPS_CPU_ISA_M32R2;
611 break;
612 default:
613 goto unknown;
614 }
Ralf Baechle41943182005-05-05 16:45:59 +0000615 break;
616 case 2:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100617 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000618 case 0:
619 c->isa_level = MIPS_CPU_ISA_M64R1;
620 break;
621 case 1:
622 c->isa_level = MIPS_CPU_ISA_M64R2;
623 break;
624 default:
625 goto unknown;
626 }
Ralf Baechle41943182005-05-05 16:45:59 +0000627 break;
628 default:
Ralf Baechleb4672d32005-12-08 14:04:24 +0000629 goto unknown;
Ralf Baechle41943182005-05-05 16:45:59 +0000630 }
631
632 return config0 & MIPS_CONF_M;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000633
634unknown:
635 panic(unknown_isa, config0);
Ralf Baechle41943182005-05-05 16:45:59 +0000636}
637
638static inline unsigned int decode_config1(struct cpuinfo_mips *c)
639{
640 unsigned int config1;
641
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 config1 = read_c0_config1();
Ralf Baechle41943182005-05-05 16:45:59 +0000643
644 if (config1 & MIPS_CONF1_MD)
645 c->ases |= MIPS_ASE_MDMX;
646 if (config1 & MIPS_CONF1_WR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 c->options |= MIPS_CPU_WATCH;
Ralf Baechle41943182005-05-05 16:45:59 +0000648 if (config1 & MIPS_CONF1_CA)
649 c->ases |= MIPS_ASE_MIPS16;
650 if (config1 & MIPS_CONF1_EP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 c->options |= MIPS_CPU_EJTAG;
Ralf Baechle41943182005-05-05 16:45:59 +0000652 if (config1 & MIPS_CONF1_FP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 c->options |= MIPS_CPU_FPU;
654 c->options |= MIPS_CPU_32FPR;
655 }
Ralf Baechle41943182005-05-05 16:45:59 +0000656 if (cpu_has_tlb)
657 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
658
659 return config1 & MIPS_CONF_M;
660}
661
662static inline unsigned int decode_config2(struct cpuinfo_mips *c)
663{
664 unsigned int config2;
665
666 config2 = read_c0_config2();
667
668 if (config2 & MIPS_CONF2_SL)
669 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
670
671 return config2 & MIPS_CONF_M;
672}
673
674static inline unsigned int decode_config3(struct cpuinfo_mips *c)
675{
676 unsigned int config3;
677
678 config3 = read_c0_config3();
679
680 if (config3 & MIPS_CONF3_SM)
681 c->ases |= MIPS_ASE_SMARTMIPS;
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000682 if (config3 & MIPS_CONF3_DSP)
683 c->ases |= MIPS_ASE_DSP;
Ralf Baechle8f406112005-07-14 07:34:18 +0000684 if (config3 & MIPS_CONF3_VINT)
685 c->options |= MIPS_CPU_VINT;
686 if (config3 & MIPS_CONF3_VEIC)
687 c->options |= MIPS_CPU_VEIC;
688 if (config3 & MIPS_CONF3_MT)
Ralf Baechlee0daad42007-02-05 00:10:11 +0000689 c->ases |= MIPS_ASE_MIPSMT;
Ralf Baechlea3692022007-07-10 17:33:02 +0100690 if (config3 & MIPS_CONF3_ULRI)
691 c->options |= MIPS_CPU_ULRI;
Ralf Baechle41943182005-05-05 16:45:59 +0000692
693 return config3 & MIPS_CONF_M;
694}
695
Ralf Baechle234fcd12008-03-08 09:56:28 +0000696static void __cpuinit decode_configs(struct cpuinfo_mips *c)
Ralf Baechle41943182005-05-05 16:45:59 +0000697{
Ralf Baechle558ce122008-10-29 12:33:34 +0000698 int ok;
699
Ralf Baechle41943182005-05-05 16:45:59 +0000700 /* MIPS32 or MIPS64 compliant CPU. */
Ralf Baechle02cf2112005-10-01 13:06:32 +0100701 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
702 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
Ralf Baechle41943182005-05-05 16:45:59 +0000703
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
705
Ralf Baechle558ce122008-10-29 12:33:34 +0000706 ok = decode_config0(c); /* Read Config registers. */
707 BUG_ON(!ok); /* Arch spec violation! */
708 if (ok)
709 ok = decode_config1(c);
710 if (ok)
711 ok = decode_config2(c);
712 if (ok)
713 ok = decode_config3(c);
714
715 mips_probe_watch_registers(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716}
717
Chris Dearman0b6d4972007-09-13 12:32:02 +0100718#ifdef CONFIG_CPU_MIPSR2
719extern void spram_config(void);
720#else
721static inline void spram_config(void) {}
722#endif
723
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000724static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725{
Ralf Baechle41943182005-05-05 16:45:59 +0000726 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 switch (c->processor_id & 0xff00) {
728 case PRID_IMP_4KC:
729 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000730 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 break;
732 case PRID_IMP_4KEC:
733 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000734 __cpu_name[cpu] = "MIPS 4KEc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 break;
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000736 case PRID_IMP_4KECR2:
737 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000738 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000739 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100741 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000743 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 break;
745 case PRID_IMP_5KC:
746 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000747 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 break;
749 case PRID_IMP_20KC:
750 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000751 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 break;
753 case PRID_IMP_24K:
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000754 case PRID_IMP_24KE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000756 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 break;
758 case PRID_IMP_25KF:
759 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000760 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000762 case PRID_IMP_34K:
763 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000764 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000765 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100766 case PRID_IMP_74K:
767 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000768 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100769 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100770 case PRID_IMP_1004K:
771 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000772 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100773 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100775
776 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777}
778
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000779static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780{
Ralf Baechle41943182005-05-05 16:45:59 +0000781 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 switch (c->processor_id & 0xff00) {
783 case PRID_IMP_AU1_REV1:
784 case PRID_IMP_AU1_REV2:
785 switch ((c->processor_id >> 24) & 0xff) {
786 case 0:
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000787 c->cputype = CPU_AU1000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000788 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 break;
790 case 1:
791 c->cputype = CPU_AU1500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000792 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 break;
794 case 2:
795 c->cputype = CPU_AU1100;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000796 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 break;
798 case 3:
799 c->cputype = CPU_AU1550;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000800 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000802 case 4:
803 c->cputype = CPU_AU1200;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000804 __cpu_name[cpu] = "Au1200";
805 if ((c->processor_id & 0xff) == 2) {
Manuel Lauss237cfee2007-12-06 09:07:55 +0100806 c->cputype = CPU_AU1250;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000807 __cpu_name[cpu] = "Au1250";
808 }
Manuel Lauss237cfee2007-12-06 09:07:55 +0100809 break;
810 case 5:
811 c->cputype = CPU_AU1210;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000812 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000813 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 default:
815 panic("Unknown Au Core!");
816 break;
817 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818 break;
819 }
820}
821
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000822static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823{
Ralf Baechle41943182005-05-05 16:45:59 +0000824 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100825
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826 switch (c->processor_id & 0xff00) {
827 case PRID_IMP_SB1:
828 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000829 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100831 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000832 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700834 case PRID_IMP_SB1A:
835 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000836 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700837 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 }
839}
840
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000841static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842{
Ralf Baechle41943182005-05-05 16:45:59 +0000843 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 switch (c->processor_id & 0xff00) {
845 case PRID_IMP_SR71000:
846 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000847 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848 c->scache.ways = 8;
849 c->tlbsize = 64;
850 break;
851 }
852}
853
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000854static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000855{
856 decode_configs(c);
857 switch (c->processor_id & 0xff00) {
858 case PRID_IMP_PR4450:
859 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000860 __cpu_name[cpu] = "Philips PR4450";
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000861 c->isa_level = MIPS_CPU_ISA_M32R1;
Pete Popovbdf21b12005-07-14 17:47:57 +0000862 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000863 }
864}
865
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000866static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200867{
868 decode_configs(c);
869 switch (c->processor_id & 0xff00) {
870 case PRID_IMP_BCM3302:
871 c->cputype = CPU_BCM3302;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000872 __cpu_name[cpu] = "Broadcom BCM3302";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200873 break;
874 case PRID_IMP_BCM4710:
875 c->cputype = CPU_BCM4710;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000876 __cpu_name[cpu] = "Broadcom BCM4710";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200877 break;
878 }
879}
880
David Daney0dd47812008-12-11 15:33:26 -0800881static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
882{
883 decode_configs(c);
884 switch (c->processor_id & 0xff00) {
885 case PRID_IMP_CAVIUM_CN38XX:
886 case PRID_IMP_CAVIUM_CN31XX:
887 case PRID_IMP_CAVIUM_CN30XX:
888 case PRID_IMP_CAVIUM_CN58XX:
889 case PRID_IMP_CAVIUM_CN56XX:
890 case PRID_IMP_CAVIUM_CN50XX:
891 case PRID_IMP_CAVIUM_CN52XX:
892 c->cputype = CPU_CAVIUM_OCTEON;
893 __cpu_name[cpu] = "Cavium Octeon";
894 break;
895 default:
896 printk(KERN_INFO "Unknown Octeon chip!\n");
897 c->cputype = CPU_UNKNOWN;
898 break;
899 }
900}
901
Ralf Baechle9966db252007-10-11 23:46:17 +0100902const char *__cpu_name[NR_CPUS];
903
Ralf Baechle234fcd12008-03-08 09:56:28 +0000904__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905{
906 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +0100907 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908
909 c->processor_id = PRID_IMP_UNKNOWN;
910 c->fpu_id = FPIR_IMP_NONE;
911 c->cputype = CPU_UNKNOWN;
912
913 c->processor_id = read_c0_prid();
914 switch (c->processor_id & 0xff0000) {
915 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000916 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917 break;
918 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000919 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920 break;
921 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000922 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700923 break;
924 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000925 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700926 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200927 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000928 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200929 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000931 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932 break;
Daniel Lairda92b0582008-03-06 09:07:18 +0000933 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000934 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000935 break;
David Daney0dd47812008-12-11 15:33:26 -0800936 case PRID_COMP_CAVIUM:
937 cpu_probe_cavium(c, cpu);
938 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200940
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000941 BUG_ON(!__cpu_name[cpu]);
942 BUG_ON(c->cputype == CPU_UNKNOWN);
943
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200944 /*
945 * Platform code can force the cpu type to optimize code
946 * generation. In that case be sure the cpu type is correctly
947 * manually setup otherwise it could trigger some nasty bugs.
948 */
949 BUG_ON(current_cpu_type() != c->cputype);
950
Ralf Baechle41943182005-05-05 16:45:59 +0000951 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700952 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +0000953
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000954 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
Ralf Baechleb4672d32005-12-08 14:04:24 +0000955 c->isa_level == MIPS_CPU_ISA_M32R2 ||
956 c->isa_level == MIPS_CPU_ISA_M64R1 ||
957 c->isa_level == MIPS_CPU_ISA_M64R2) {
Ralf Baechle41943182005-05-05 16:45:59 +0000958 if (c->fpu_id & MIPS_FPIR_3D)
959 c->ases |= MIPS_ASE_MIPS3D;
960 }
961 }
Ralf Baechle9966db252007-10-11 23:46:17 +0100962
Ralf Baechlef6771db2007-11-08 18:02:29 +0000963 if (cpu_has_mips_r2)
964 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
965 else
966 c->srsets = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700967}
968
Ralf Baechle234fcd12008-03-08 09:56:28 +0000969__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700970{
971 struct cpuinfo_mips *c = &current_cpu_data;
972
Ralf Baechle9966db252007-10-11 23:46:17 +0100973 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
974 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -0700975 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +0100976 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977}