blob: be5bb16be4e0a01df31ba41c21298367780eff97 [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>
Ralf Baechle631330f2009-06-19 14:05:26 +010017#include <linux/smp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/stddef.h>
Wu Zhangjinf8ede0f2009-11-17 01:32:59 +080019#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Ralf Baechle57599062007-02-18 19:07:31 +000021#include <asm/bugs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <asm/cpu.h>
23#include <asm/fpu.h>
24#include <asm/mipsregs.h>
25#include <asm/system.h>
David Daney654f57b2008-09-23 00:07:16 -070026#include <asm/watch.h>
Chris Dearmana074f0e2009-07-10 01:51:27 -070027#include <asm/spram.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028/*
29 * Not all of the MIPS CPUs have the "wait" instruction available. Moreover,
30 * the implementation of the "wait" feature differs between CPU families. This
31 * points to the function that implements CPU specific wait.
32 * The wait instruction stops the pipeline and reduces the power consumption of
33 * the CPU very much.
34 */
Ralf Baechle982f6ff2009-09-17 02:25:07 +020035void (*cpu_wait)(void);
Wu Zhangjinf8ede0f2009-11-17 01:32:59 +080036EXPORT_SYMBOL(cpu_wait);
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
38static void r3081_wait(void)
39{
40 unsigned long cfg = read_c0_conf();
41 write_c0_conf(cfg | R30XX_CONF_HALT);
42}
43
44static void r39xx_wait(void)
45{
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090046 local_irq_disable();
47 if (!need_resched())
48 write_c0_conf(read_c0_conf() | TX39_CONF_HALT);
49 local_irq_enable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070050}
51
Atsushi Nemotoc65a5482007-11-12 02:05:18 +090052extern void r4k_wait(void);
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090053
54/*
55 * This variant is preferable as it allows testing need_resched and going to
56 * sleep depending on the outcome atomically. Unfortunately the "It is
57 * implementation-dependent whether the pipeline restarts when a non-enabled
58 * interrupt is requested" restriction in the MIPS32/MIPS64 architecture makes
59 * using this version a gamble.
60 */
Kevin D. Kissell8531a352008-09-09 21:48:52 +020061void r4k_wait_irqoff(void)
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090062{
63 local_irq_disable();
64 if (!need_resched())
Kevin D. Kissell8531a352008-09-09 21:48:52 +020065 __asm__(" .set push \n"
66 " .set mips3 \n"
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090067 " wait \n"
Kevin D. Kissell8531a352008-09-09 21:48:52 +020068 " .set pop \n");
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090069 local_irq_enable();
Kevin D. Kissell8531a352008-09-09 21:48:52 +020070 __asm__(" .globl __pastwait \n"
71 "__pastwait: \n");
72 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073}
74
Ralf Baechle5a812992007-07-17 18:49:48 +010075/*
76 * The RM7000 variant has to handle erratum 38. The workaround is to not
77 * have any pending stores when the WAIT instruction is executed.
78 */
79static void rm7k_wait_irqoff(void)
80{
81 local_irq_disable();
82 if (!need_resched())
83 __asm__(
84 " .set push \n"
85 " .set mips3 \n"
86 " .set noat \n"
87 " mfc0 $1, $12 \n"
88 " sync \n"
89 " mtc0 $1, $12 # stalls until W stage \n"
90 " wait \n"
91 " mtc0 $1, $12 # stalls until W stage \n"
92 " .set pop \n");
93 local_irq_enable();
94}
95
Manuel Lauss2882b0c2009-08-22 18:09:27 +020096/*
97 * The Au1xxx wait is available only if using 32khz counter or
98 * external timer source, but specifically not CP0 Counter.
99 * alchemy/common/time.c may override cpu_wait!
100 */
Pete Popov494900a2005-04-07 00:42:10 +0000101static void au1k_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102{
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 Baechle982f6ff2009-09-17 02:25:07 +0200117static int __initdata nowait;
Ralf Baechle55d04df2005-07-13 19:22:45 +0000118
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:
Maxime Bizon0de663e2009-08-18 13:23:37 +0100161 case CPU_BCM6338:
162 case CPU_BCM6348:
163 case CPU_BCM6358:
David Daney0dd47812008-12-11 15:33:26 -0800164 case CPU_CAVIUM_OCTEON:
David Daney6f329462010-02-10 15:12:48 -0800165 case CPU_CAVIUM_OCTEON_PLUS:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 cpu_wait = r4k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167 break;
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100168
Ralf Baechle5a812992007-07-17 18:49:48 +0100169 case CPU_RM7000:
170 cpu_wait = rm7k_wait_irqoff;
171 break;
172
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100173 case CPU_24K:
174 case CPU_34K:
Ralf Baechle39b8d522008-04-28 17:14:26 +0100175 case CPU_1004K:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100176 cpu_wait = r4k_wait;
177 if (read_c0_config7() & MIPS_CONF7_WII)
178 cpu_wait = r4k_wait_irqoff;
179 break;
180
181 case CPU_74K:
182 cpu_wait = r4k_wait;
183 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
184 cpu_wait = r4k_wait_irqoff;
185 break;
186
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900187 case CPU_TX49XX:
188 cpu_wait = r4k_wait_irqoff;
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900189 break;
Manuel Lauss270717a2009-03-25 17:49:28 +0100190 case CPU_ALCHEMY:
Manuel Lauss0c694de2008-12-21 09:26:23 +0100191 cpu_wait = au1k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 break;
Ralf Baechlec8eae712007-06-12 13:04:09 +0100193 case CPU_20KC:
194 /*
195 * WAIT on Rev1.0 has E1, E2, E3 and E16.
196 * WAIT on Rev2.0 and Rev3.0 has E16.
197 * Rev3.1 WAIT is nop, why bother
198 */
199 if ((c->processor_id & 0xff) <= 0x64)
200 break;
201
Ralf Baechle50da4692007-09-14 19:08:43 +0100202 /*
203 * Another rev is incremeting c0_count at a reduced clock
204 * rate while in WAIT mode. So we basically have the choice
205 * between using the cp0 timer as clocksource or avoiding
206 * the WAIT instruction. Until more details are known,
207 * disable the use of WAIT for 20Kc entirely.
208 cpu_wait = r4k_wait;
209 */
Ralf Baechlec8eae712007-06-12 13:04:09 +0100210 break;
Ralf Baechle441ee342006-06-02 11:48:11 +0100211 case CPU_RM9000:
Ralf Baechlec2379232006-11-30 01:14:44 +0000212 if ((c->processor_id & 0x00ff) >= 0x40)
Ralf Baechle441ee342006-06-02 11:48:11 +0100213 cpu_wait = r4k_wait;
Ralf Baechle441ee342006-06-02 11:48:11 +0100214 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 break;
217 }
218}
219
Marc St-Jean9267a302007-06-14 15:55:31 -0600220static inline void check_errata(void)
221{
222 struct cpuinfo_mips *c = &current_cpu_data;
223
224 switch (c->cputype) {
225 case CPU_34K:
226 /*
227 * Erratum "RPS May Cause Incorrect Instruction Execution"
228 * This code only handles VPE0, any SMP/SMTC/RTOS code
229 * making use of VPE1 will be responsable for that VPE.
230 */
231 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
232 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
233 break;
234 default:
235 break;
236 }
237}
238
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239void __init check_bugs32(void)
240{
Marc St-Jean9267a302007-06-14 15:55:31 -0600241 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242}
243
244/*
245 * Probe whether cpu has config register by trying to play with
246 * alternate cache bit and see whether it matters.
247 * It's used by cpu_probe to distinguish between R3000A and R3081.
248 */
249static inline int cpu_has_confreg(void)
250{
251#ifdef CONFIG_CPU_R3000
252 extern unsigned long r3k_cache_size(unsigned long);
253 unsigned long size1, size2;
254 unsigned long cfg = read_c0_conf();
255
256 size1 = r3k_cache_size(ST0_ISC);
257 write_c0_conf(cfg ^ R30XX_CONF_AC);
258 size2 = r3k_cache_size(ST0_ISC);
259 write_c0_conf(cfg);
260 return size1 != size2;
261#else
262 return 0;
263#endif
264}
265
266/*
267 * Get the FPU Implementation/Revision.
268 */
269static inline unsigned long cpu_get_fpu_id(void)
270{
271 unsigned long tmp, fpu_id;
272
273 tmp = read_c0_status();
274 __enable_fpu();
275 fpu_id = read_32bit_cp1_register(CP1_REVISION);
276 write_c0_status(tmp);
277 return fpu_id;
278}
279
280/*
281 * Check the CPU has an FPU the official way.
282 */
283static inline int __cpu_has_fpu(void)
284{
285 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
286}
287
Guenter Roeck91dfc422010-02-02 08:52:20 -0800288static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
289{
290#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800291 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800292 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800293 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800294#endif
295}
296
Ralf Baechle02cf2112005-10-01 13:06:32 +0100297#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 | MIPS_CPU_COUNTER)
299
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000300static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301{
302 switch (c->processor_id & 0xff00) {
303 case PRID_IMP_R2000:
304 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000305 __cpu_name[cpu] = "R2000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100307 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
308 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 if (__cpu_has_fpu())
310 c->options |= MIPS_CPU_FPU;
311 c->tlbsize = 64;
312 break;
313 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000314 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
315 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000317 __cpu_name[cpu] = "R3081";
318 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000320 __cpu_name[cpu] = "R3000A";
321 }
322 break;
323 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000325 __cpu_name[cpu] = "R3000";
326 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100328 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
329 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 if (__cpu_has_fpu())
331 c->options |= MIPS_CPU_FPU;
332 c->tlbsize = 64;
333 break;
334 case PRID_IMP_R4000:
335 if (read_c0_config() & CONF_SC) {
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_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000338 __cpu_name[cpu] = "R4400PC";
339 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000341 __cpu_name[cpu] = "R4000PC";
342 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 } else {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000344 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 c->cputype = CPU_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000346 __cpu_name[cpu] = "R4400SC";
347 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000349 __cpu_name[cpu] = "R4000SC";
350 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 }
352
353 c->isa_level = MIPS_CPU_ISA_III;
354 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
355 MIPS_CPU_WATCH | MIPS_CPU_VCE |
356 MIPS_CPU_LLSC;
357 c->tlbsize = 48;
358 break;
359 case PRID_IMP_VR41XX:
360 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 case PRID_REV_VR4111:
362 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000363 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 case PRID_REV_VR4121:
366 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000367 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 break;
369 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000370 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000372 __cpu_name[cpu] = "NEC VR4122";
373 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000375 __cpu_name[cpu] = "NEC VR4181A";
376 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 break;
378 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000379 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000381 __cpu_name[cpu] = "NEC VR4131";
382 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 c->cputype = CPU_VR4133;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000384 __cpu_name[cpu] = "NEC VR4133";
385 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 break;
387 default:
388 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
389 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000390 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 break;
392 }
393 c->isa_level = MIPS_CPU_ISA_III;
394 c->options = R4K_OPTS;
395 c->tlbsize = 32;
396 break;
397 case PRID_IMP_R4300:
398 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000399 __cpu_name[cpu] = "R4300";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 c->isa_level = MIPS_CPU_ISA_III;
401 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
402 MIPS_CPU_LLSC;
403 c->tlbsize = 32;
404 break;
405 case PRID_IMP_R4600:
406 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000407 __cpu_name[cpu] = "R4600";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 c->isa_level = MIPS_CPU_ISA_III;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000409 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
410 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 c->tlbsize = 48;
412 break;
413 #if 0
414 case PRID_IMP_R4650:
415 /*
416 * This processor doesn't have an MMU, so it's not
417 * "real easy" to run Linux on it. It is left purely
418 * for documentation. Commented out because it shares
419 * it's c0_prid id number with the TX3900.
420 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000421 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000422 __cpu_name[cpu] = "R4650";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 c->isa_level = MIPS_CPU_ISA_III;
424 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
425 c->tlbsize = 48;
426 break;
427 #endif
428 case PRID_IMP_TX39:
429 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100430 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
432 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
433 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000434 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 c->tlbsize = 64;
436 } else {
437 switch (c->processor_id & 0xff) {
438 case PRID_REV_TX3912:
439 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000440 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 c->tlbsize = 32;
442 break;
443 case PRID_REV_TX3922:
444 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000445 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 c->tlbsize = 64;
447 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 }
449 }
450 break;
451 case PRID_IMP_R4700:
452 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000453 __cpu_name[cpu] = "R4700";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 c->isa_level = MIPS_CPU_ISA_III;
455 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
456 MIPS_CPU_LLSC;
457 c->tlbsize = 48;
458 break;
459 case PRID_IMP_TX49:
460 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000461 __cpu_name[cpu] = "R49XX";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 c->isa_level = MIPS_CPU_ISA_III;
463 c->options = R4K_OPTS | MIPS_CPU_LLSC;
464 if (!(c->processor_id & 0x08))
465 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
466 c->tlbsize = 48;
467 break;
468 case PRID_IMP_R5000:
469 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000470 __cpu_name[cpu] = "R5000";
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_LLSC;
474 c->tlbsize = 48;
475 break;
476 case PRID_IMP_R5432:
477 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000478 __cpu_name[cpu] = "R5432";
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_R5500:
485 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000486 __cpu_name[cpu] = "R5500";
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_WATCH | MIPS_CPU_LLSC;
490 c->tlbsize = 48;
491 break;
492 case PRID_IMP_NEVADA:
493 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000494 __cpu_name[cpu] = "Nevada";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 c->isa_level = MIPS_CPU_ISA_IV;
496 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
497 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
498 c->tlbsize = 48;
499 break;
500 case PRID_IMP_R6000:
501 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000502 __cpu_name[cpu] = "R6000";
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_R6000A:
509 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000510 __cpu_name[cpu] = "R6000A";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 c->isa_level = MIPS_CPU_ISA_II;
512 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
513 MIPS_CPU_LLSC;
514 c->tlbsize = 32;
515 break;
516 case PRID_IMP_RM7000:
517 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000518 __cpu_name[cpu] = "RM7000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 c->isa_level = MIPS_CPU_ISA_IV;
520 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
521 MIPS_CPU_LLSC;
522 /*
523 * Undocumented RM7000: Bit 29 in the info register of
524 * the RM7000 v2.0 indicates if the TLB has 48 or 64
525 * entries.
526 *
527 * 29 1 => 64 entry JTLB
528 * 0 => 48 entry JTLB
529 */
530 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
531 break;
532 case PRID_IMP_RM9000:
533 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000534 __cpu_name[cpu] = "RM9000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 c->isa_level = MIPS_CPU_ISA_IV;
536 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
537 MIPS_CPU_LLSC;
538 /*
539 * Bit 29 in the info register of the RM9000
540 * indicates if the TLB has 48 or 64 entries.
541 *
542 * 29 1 => 64 entry JTLB
543 * 0 => 48 entry JTLB
544 */
545 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
546 break;
547 case PRID_IMP_R8000:
548 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000549 __cpu_name[cpu] = "RM8000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 c->isa_level = MIPS_CPU_ISA_IV;
551 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
552 MIPS_CPU_FPU | MIPS_CPU_32FPR |
553 MIPS_CPU_LLSC;
554 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
555 break;
556 case PRID_IMP_R10000:
557 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000558 __cpu_name[cpu] = "R10000";
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;
566 case PRID_IMP_R12000:
567 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000568 __cpu_name[cpu] = "R12000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000570 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 MIPS_CPU_FPU | MIPS_CPU_32FPR |
572 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
573 MIPS_CPU_LLSC;
574 c->tlbsize = 64;
575 break;
Kumba44d921b2006-05-16 22:23:59 -0400576 case PRID_IMP_R14000:
577 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000578 __cpu_name[cpu] = "R14000";
Kumba44d921b2006-05-16 22:23:59 -0400579 c->isa_level = MIPS_CPU_ISA_IV;
580 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
581 MIPS_CPU_FPU | MIPS_CPU_32FPR |
582 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
583 MIPS_CPU_LLSC;
584 c->tlbsize = 64;
585 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800586 case PRID_IMP_LOONGSON2:
587 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000588 __cpu_name[cpu] = "ICT Loongson-2";
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800589 c->isa_level = MIPS_CPU_ISA_III;
590 c->options = R4K_OPTS |
591 MIPS_CPU_FPU | MIPS_CPU_LLSC |
592 MIPS_CPU_32FPR;
593 c->tlbsize = 64;
594 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 }
596}
597
Ralf Baechle234fcd12008-03-08 09:56:28 +0000598static char unknown_isa[] __cpuinitdata = KERN_ERR \
Ralf Baechleb4672d32005-12-08 14:04:24 +0000599 "Unsupported ISA type, c0.config0: %d.";
600
Ralf Baechle41943182005-05-05 16:45:59 +0000601static inline unsigned int decode_config0(struct cpuinfo_mips *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602{
Ralf Baechle41943182005-05-05 16:45:59 +0000603 unsigned int config0;
604 int isa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605
Ralf Baechle41943182005-05-05 16:45:59 +0000606 config0 = read_c0_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607
Ralf Baechle41943182005-05-05 16:45:59 +0000608 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
Ralf Baechle02cf2112005-10-01 13:06:32 +0100609 c->options |= MIPS_CPU_TLB;
Ralf Baechle41943182005-05-05 16:45:59 +0000610 isa = (config0 & MIPS_CONF_AT) >> 13;
611 switch (isa) {
612 case 0:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100613 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000614 case 0:
615 c->isa_level = MIPS_CPU_ISA_M32R1;
616 break;
617 case 1:
618 c->isa_level = MIPS_CPU_ISA_M32R2;
619 break;
620 default:
621 goto unknown;
622 }
Ralf Baechle41943182005-05-05 16:45:59 +0000623 break;
624 case 2:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100625 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000626 case 0:
627 c->isa_level = MIPS_CPU_ISA_M64R1;
628 break;
629 case 1:
630 c->isa_level = MIPS_CPU_ISA_M64R2;
631 break;
632 default:
633 goto unknown;
634 }
Ralf Baechle41943182005-05-05 16:45:59 +0000635 break;
636 default:
Ralf Baechleb4672d32005-12-08 14:04:24 +0000637 goto unknown;
Ralf Baechle41943182005-05-05 16:45:59 +0000638 }
639
640 return config0 & MIPS_CONF_M;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000641
642unknown:
643 panic(unknown_isa, config0);
Ralf Baechle41943182005-05-05 16:45:59 +0000644}
645
646static inline unsigned int decode_config1(struct cpuinfo_mips *c)
647{
648 unsigned int config1;
649
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 config1 = read_c0_config1();
Ralf Baechle41943182005-05-05 16:45:59 +0000651
652 if (config1 & MIPS_CONF1_MD)
653 c->ases |= MIPS_ASE_MDMX;
654 if (config1 & MIPS_CONF1_WR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 c->options |= MIPS_CPU_WATCH;
Ralf Baechle41943182005-05-05 16:45:59 +0000656 if (config1 & MIPS_CONF1_CA)
657 c->ases |= MIPS_ASE_MIPS16;
658 if (config1 & MIPS_CONF1_EP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 c->options |= MIPS_CPU_EJTAG;
Ralf Baechle41943182005-05-05 16:45:59 +0000660 if (config1 & MIPS_CONF1_FP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 c->options |= MIPS_CPU_FPU;
662 c->options |= MIPS_CPU_32FPR;
663 }
Ralf Baechle41943182005-05-05 16:45:59 +0000664 if (cpu_has_tlb)
665 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
666
667 return config1 & MIPS_CONF_M;
668}
669
670static inline unsigned int decode_config2(struct cpuinfo_mips *c)
671{
672 unsigned int config2;
673
674 config2 = read_c0_config2();
675
676 if (config2 & MIPS_CONF2_SL)
677 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
678
679 return config2 & MIPS_CONF_M;
680}
681
682static inline unsigned int decode_config3(struct cpuinfo_mips *c)
683{
684 unsigned int config3;
685
686 config3 = read_c0_config3();
687
688 if (config3 & MIPS_CONF3_SM)
689 c->ases |= MIPS_ASE_SMARTMIPS;
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000690 if (config3 & MIPS_CONF3_DSP)
691 c->ases |= MIPS_ASE_DSP;
Ralf Baechle8f406112005-07-14 07:34:18 +0000692 if (config3 & MIPS_CONF3_VINT)
693 c->options |= MIPS_CPU_VINT;
694 if (config3 & MIPS_CONF3_VEIC)
695 c->options |= MIPS_CPU_VEIC;
696 if (config3 & MIPS_CONF3_MT)
Ralf Baechlee0daad42007-02-05 00:10:11 +0000697 c->ases |= MIPS_ASE_MIPSMT;
Ralf Baechlea3692022007-07-10 17:33:02 +0100698 if (config3 & MIPS_CONF3_ULRI)
699 c->options |= MIPS_CPU_ULRI;
Ralf Baechle41943182005-05-05 16:45:59 +0000700
701 return config3 & MIPS_CONF_M;
702}
703
David Daney1b362e32010-01-22 14:41:15 -0800704static inline unsigned int decode_config4(struct cpuinfo_mips *c)
705{
706 unsigned int config4;
707
708 config4 = read_c0_config4();
709
710 if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
711 && cpu_has_tlb)
712 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
713
714 return config4 & MIPS_CONF_M;
715}
716
Ralf Baechle234fcd12008-03-08 09:56:28 +0000717static void __cpuinit decode_configs(struct cpuinfo_mips *c)
Ralf Baechle41943182005-05-05 16:45:59 +0000718{
Ralf Baechle558ce122008-10-29 12:33:34 +0000719 int ok;
720
Ralf Baechle41943182005-05-05 16:45:59 +0000721 /* MIPS32 or MIPS64 compliant CPU. */
Ralf Baechle02cf2112005-10-01 13:06:32 +0100722 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
723 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
Ralf Baechle41943182005-05-05 16:45:59 +0000724
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
726
Ralf Baechle558ce122008-10-29 12:33:34 +0000727 ok = decode_config0(c); /* Read Config registers. */
728 BUG_ON(!ok); /* Arch spec violation! */
729 if (ok)
730 ok = decode_config1(c);
731 if (ok)
732 ok = decode_config2(c);
733 if (ok)
734 ok = decode_config3(c);
David Daney1b362e32010-01-22 14:41:15 -0800735 if (ok)
736 ok = decode_config4(c);
Ralf Baechle558ce122008-10-29 12:33:34 +0000737
738 mips_probe_watch_registers(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739}
740
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000741static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742{
Ralf Baechle41943182005-05-05 16:45:59 +0000743 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 switch (c->processor_id & 0xff00) {
745 case PRID_IMP_4KC:
746 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000747 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 break;
749 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000750 case PRID_IMP_4KECR2:
751 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000752 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000753 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100755 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000757 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 break;
759 case PRID_IMP_5KC:
760 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000761 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 break;
763 case PRID_IMP_20KC:
764 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000765 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766 break;
767 case PRID_IMP_24K:
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000768 case PRID_IMP_24KE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000770 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 break;
772 case PRID_IMP_25KF:
773 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000774 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000776 case PRID_IMP_34K:
777 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000778 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000779 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100780 case PRID_IMP_74K:
781 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000782 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100783 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100784 case PRID_IMP_1004K:
785 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000786 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100787 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100789
790 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791}
792
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000793static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794{
Ralf Baechle41943182005-05-05 16:45:59 +0000795 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 switch (c->processor_id & 0xff00) {
797 case PRID_IMP_AU1_REV1:
798 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100799 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 switch ((c->processor_id >> 24) & 0xff) {
801 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000802 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 break;
804 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000805 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 break;
807 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000808 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 break;
810 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000811 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000813 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000814 __cpu_name[cpu] = "Au1200";
Manuel Lauss270717a2009-03-25 17:49:28 +0100815 if ((c->processor_id & 0xff) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000816 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100817 break;
818 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000819 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000820 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100822 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823 break;
824 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 break;
826 }
827}
828
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000829static inline void cpu_probe_sibyte(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);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100832
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833 switch (c->processor_id & 0xff00) {
834 case PRID_IMP_SB1:
835 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000836 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100838 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000839 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700841 case PRID_IMP_SB1A:
842 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000843 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700844 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 }
846}
847
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000848static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849{
Ralf Baechle41943182005-05-05 16:45:59 +0000850 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851 switch (c->processor_id & 0xff00) {
852 case PRID_IMP_SR71000:
853 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000854 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855 c->scache.ways = 8;
856 c->tlbsize = 64;
857 break;
858 }
859}
860
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000861static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000862{
863 decode_configs(c);
864 switch (c->processor_id & 0xff00) {
865 case PRID_IMP_PR4450:
866 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000867 __cpu_name[cpu] = "Philips PR4450";
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000868 c->isa_level = MIPS_CPU_ISA_M32R1;
Pete Popovbdf21b12005-07-14 17:47:57 +0000869 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000870 }
871}
872
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000873static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200874{
875 decode_configs(c);
876 switch (c->processor_id & 0xff00) {
877 case PRID_IMP_BCM3302:
Maxime Bizon0de663e2009-08-18 13:23:37 +0100878 /* same as PRID_IMP_BCM6338 */
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200879 c->cputype = CPU_BCM3302;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000880 __cpu_name[cpu] = "Broadcom BCM3302";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200881 break;
882 case PRID_IMP_BCM4710:
883 c->cputype = CPU_BCM4710;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000884 __cpu_name[cpu] = "Broadcom BCM4710";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200885 break;
Maxime Bizon0de663e2009-08-18 13:23:37 +0100886 case PRID_IMP_BCM6345:
887 c->cputype = CPU_BCM6345;
888 __cpu_name[cpu] = "Broadcom BCM6345";
889 break;
890 case PRID_IMP_BCM6348:
891 c->cputype = CPU_BCM6348;
892 __cpu_name[cpu] = "Broadcom BCM6348";
893 break;
894 case PRID_IMP_BCM4350:
895 switch (c->processor_id & 0xf0) {
896 case PRID_REV_BCM6358:
897 c->cputype = CPU_BCM6358;
898 __cpu_name[cpu] = "Broadcom BCM6358";
899 break;
900 default:
901 c->cputype = CPU_UNKNOWN;
902 break;
903 }
904 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200905 }
906}
907
David Daney0dd47812008-12-11 15:33:26 -0800908static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
909{
910 decode_configs(c);
911 switch (c->processor_id & 0xff00) {
912 case PRID_IMP_CAVIUM_CN38XX:
913 case PRID_IMP_CAVIUM_CN31XX:
914 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -0800915 c->cputype = CPU_CAVIUM_OCTEON;
916 __cpu_name[cpu] = "Cavium Octeon";
917 goto platform;
David Daney0dd47812008-12-11 15:33:26 -0800918 case PRID_IMP_CAVIUM_CN58XX:
919 case PRID_IMP_CAVIUM_CN56XX:
920 case PRID_IMP_CAVIUM_CN50XX:
921 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -0800922 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
923 __cpu_name[cpu] = "Cavium Octeon+";
924platform:
David Daney368bf8e2010-01-28 16:52:13 -0800925 if (cpu == 0)
926 __elf_platform = "octeon";
David Daney0dd47812008-12-11 15:33:26 -0800927 break;
928 default:
929 printk(KERN_INFO "Unknown Octeon chip!\n");
930 c->cputype = CPU_UNKNOWN;
931 break;
932 }
933}
934
Ralf Baechle9966db252007-10-11 23:46:17 +0100935const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -0800936const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +0100937
Ralf Baechle234fcd12008-03-08 09:56:28 +0000938__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939{
940 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +0100941 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700942
943 c->processor_id = PRID_IMP_UNKNOWN;
944 c->fpu_id = FPIR_IMP_NONE;
945 c->cputype = CPU_UNKNOWN;
946
947 c->processor_id = read_c0_prid();
948 switch (c->processor_id & 0xff0000) {
949 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000950 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951 break;
952 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000953 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700954 break;
955 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000956 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957 break;
958 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000959 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700960 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200961 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000962 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200963 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000965 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966 break;
Daniel Lairda92b0582008-03-06 09:07:18 +0000967 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000968 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000969 break;
David Daney0dd47812008-12-11 15:33:26 -0800970 case PRID_COMP_CAVIUM:
971 cpu_probe_cavium(c, cpu);
972 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200974
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000975 BUG_ON(!__cpu_name[cpu]);
976 BUG_ON(c->cputype == CPU_UNKNOWN);
977
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200978 /*
979 * Platform code can force the cpu type to optimize code
980 * generation. In that case be sure the cpu type is correctly
981 * manually setup otherwise it could trigger some nasty bugs.
982 */
983 BUG_ON(current_cpu_type() != c->cputype);
984
Ralf Baechle41943182005-05-05 16:45:59 +0000985 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700986 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +0000987
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000988 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
Ralf Baechleb4672d32005-12-08 14:04:24 +0000989 c->isa_level == MIPS_CPU_ISA_M32R2 ||
990 c->isa_level == MIPS_CPU_ISA_M64R1 ||
991 c->isa_level == MIPS_CPU_ISA_M64R2) {
Ralf Baechle41943182005-05-05 16:45:59 +0000992 if (c->fpu_id & MIPS_FPIR_3D)
993 c->ases |= MIPS_ASE_MIPS3D;
994 }
995 }
Ralf Baechle9966db252007-10-11 23:46:17 +0100996
Ralf Baechlef6771db2007-11-08 18:02:29 +0000997 if (cpu_has_mips_r2)
998 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
999 else
1000 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001001
1002 cpu_probe_vmbits(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001003}
1004
Ralf Baechle234fcd12008-03-08 09:56:28 +00001005__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006{
1007 struct cpuinfo_mips *c = &current_cpu_data;
1008
Ralf Baechle9966db252007-10-11 23:46:17 +01001009 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
1010 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001012 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013}