blob: 494e8ab48d630f086c7ff725d21277b389cf861f [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:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 cpu_wait = r4k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 break;
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100167
Ralf Baechle5a812992007-07-17 18:49:48 +0100168 case CPU_RM7000:
169 cpu_wait = rm7k_wait_irqoff;
170 break;
171
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100172 case CPU_24K:
173 case CPU_34K:
Ralf Baechle39b8d522008-04-28 17:14:26 +0100174 case CPU_1004K:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100175 cpu_wait = r4k_wait;
176 if (read_c0_config7() & MIPS_CONF7_WII)
177 cpu_wait = r4k_wait_irqoff;
178 break;
179
180 case CPU_74K:
181 cpu_wait = r4k_wait;
182 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
183 cpu_wait = r4k_wait_irqoff;
184 break;
185
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900186 case CPU_TX49XX:
187 cpu_wait = r4k_wait_irqoff;
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900188 break;
Manuel Lauss270717a2009-03-25 17:49:28 +0100189 case CPU_ALCHEMY:
Manuel Lauss0c694de2008-12-21 09:26:23 +0100190 cpu_wait = au1k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 break;
Ralf Baechlec8eae712007-06-12 13:04:09 +0100192 case CPU_20KC:
193 /*
194 * WAIT on Rev1.0 has E1, E2, E3 and E16.
195 * WAIT on Rev2.0 and Rev3.0 has E16.
196 * Rev3.1 WAIT is nop, why bother
197 */
198 if ((c->processor_id & 0xff) <= 0x64)
199 break;
200
Ralf Baechle50da4692007-09-14 19:08:43 +0100201 /*
202 * Another rev is incremeting c0_count at a reduced clock
203 * rate while in WAIT mode. So we basically have the choice
204 * between using the cp0 timer as clocksource or avoiding
205 * the WAIT instruction. Until more details are known,
206 * disable the use of WAIT for 20Kc entirely.
207 cpu_wait = r4k_wait;
208 */
Ralf Baechlec8eae712007-06-12 13:04:09 +0100209 break;
Ralf Baechle441ee342006-06-02 11:48:11 +0100210 case CPU_RM9000:
Ralf Baechlec2379232006-11-30 01:14:44 +0000211 if ((c->processor_id & 0x00ff) >= 0x40)
Ralf Baechle441ee342006-06-02 11:48:11 +0100212 cpu_wait = r4k_wait;
Ralf Baechle441ee342006-06-02 11:48:11 +0100213 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 break;
216 }
217}
218
Marc St-Jean9267a302007-06-14 15:55:31 -0600219static inline void check_errata(void)
220{
221 struct cpuinfo_mips *c = &current_cpu_data;
222
223 switch (c->cputype) {
224 case CPU_34K:
225 /*
226 * Erratum "RPS May Cause Incorrect Instruction Execution"
227 * This code only handles VPE0, any SMP/SMTC/RTOS code
228 * making use of VPE1 will be responsable for that VPE.
229 */
230 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
231 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
232 break;
233 default:
234 break;
235 }
236}
237
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238void __init check_bugs32(void)
239{
Marc St-Jean9267a302007-06-14 15:55:31 -0600240 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241}
242
243/*
244 * Probe whether cpu has config register by trying to play with
245 * alternate cache bit and see whether it matters.
246 * It's used by cpu_probe to distinguish between R3000A and R3081.
247 */
248static inline int cpu_has_confreg(void)
249{
250#ifdef CONFIG_CPU_R3000
251 extern unsigned long r3k_cache_size(unsigned long);
252 unsigned long size1, size2;
253 unsigned long cfg = read_c0_conf();
254
255 size1 = r3k_cache_size(ST0_ISC);
256 write_c0_conf(cfg ^ R30XX_CONF_AC);
257 size2 = r3k_cache_size(ST0_ISC);
258 write_c0_conf(cfg);
259 return size1 != size2;
260#else
261 return 0;
262#endif
263}
264
265/*
266 * Get the FPU Implementation/Revision.
267 */
268static inline unsigned long cpu_get_fpu_id(void)
269{
270 unsigned long tmp, fpu_id;
271
272 tmp = read_c0_status();
273 __enable_fpu();
274 fpu_id = read_32bit_cp1_register(CP1_REVISION);
275 write_c0_status(tmp);
276 return fpu_id;
277}
278
279/*
280 * Check the CPU has an FPU the official way.
281 */
282static inline int __cpu_has_fpu(void)
283{
284 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
285}
286
Guenter Roeck91dfc422010-02-02 08:52:20 -0800287static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
288{
289#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800290 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800291 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800292 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800293#endif
294}
295
Ralf Baechle02cf2112005-10-01 13:06:32 +0100296#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 | MIPS_CPU_COUNTER)
298
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000299static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300{
301 switch (c->processor_id & 0xff00) {
302 case PRID_IMP_R2000:
303 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000304 __cpu_name[cpu] = "R2000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100306 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
307 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 if (__cpu_has_fpu())
309 c->options |= MIPS_CPU_FPU;
310 c->tlbsize = 64;
311 break;
312 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000313 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
314 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000316 __cpu_name[cpu] = "R3081";
317 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000319 __cpu_name[cpu] = "R3000A";
320 }
321 break;
322 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000324 __cpu_name[cpu] = "R3000";
325 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100327 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
328 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 if (__cpu_has_fpu())
330 c->options |= MIPS_CPU_FPU;
331 c->tlbsize = 64;
332 break;
333 case PRID_IMP_R4000:
334 if (read_c0_config() & CONF_SC) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000335 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000337 __cpu_name[cpu] = "R4400PC";
338 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000340 __cpu_name[cpu] = "R4000PC";
341 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 } else {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000343 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344 c->cputype = CPU_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000345 __cpu_name[cpu] = "R4400SC";
346 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000348 __cpu_name[cpu] = "R4000SC";
349 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 }
351
352 c->isa_level = MIPS_CPU_ISA_III;
353 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
354 MIPS_CPU_WATCH | MIPS_CPU_VCE |
355 MIPS_CPU_LLSC;
356 c->tlbsize = 48;
357 break;
358 case PRID_IMP_VR41XX:
359 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 case PRID_REV_VR4111:
361 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000362 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 case PRID_REV_VR4121:
365 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000366 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 break;
368 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000369 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000371 __cpu_name[cpu] = "NEC VR4122";
372 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000374 __cpu_name[cpu] = "NEC VR4181A";
375 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 break;
377 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000378 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000380 __cpu_name[cpu] = "NEC VR4131";
381 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382 c->cputype = CPU_VR4133;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000383 __cpu_name[cpu] = "NEC VR4133";
384 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 break;
386 default:
387 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
388 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000389 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 break;
391 }
392 c->isa_level = MIPS_CPU_ISA_III;
393 c->options = R4K_OPTS;
394 c->tlbsize = 32;
395 break;
396 case PRID_IMP_R4300:
397 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000398 __cpu_name[cpu] = "R4300";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 c->isa_level = MIPS_CPU_ISA_III;
400 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
401 MIPS_CPU_LLSC;
402 c->tlbsize = 32;
403 break;
404 case PRID_IMP_R4600:
405 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000406 __cpu_name[cpu] = "R4600";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 c->isa_level = MIPS_CPU_ISA_III;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000408 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
409 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 c->tlbsize = 48;
411 break;
412 #if 0
413 case PRID_IMP_R4650:
414 /*
415 * This processor doesn't have an MMU, so it's not
416 * "real easy" to run Linux on it. It is left purely
417 * for documentation. Commented out because it shares
418 * it's c0_prid id number with the TX3900.
419 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000420 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000421 __cpu_name[cpu] = "R4650";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 c->isa_level = MIPS_CPU_ISA_III;
423 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
424 c->tlbsize = 48;
425 break;
426 #endif
427 case PRID_IMP_TX39:
428 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100429 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430
431 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
432 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000433 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 c->tlbsize = 64;
435 } else {
436 switch (c->processor_id & 0xff) {
437 case PRID_REV_TX3912:
438 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000439 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 c->tlbsize = 32;
441 break;
442 case PRID_REV_TX3922:
443 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000444 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 c->tlbsize = 64;
446 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 }
448 }
449 break;
450 case PRID_IMP_R4700:
451 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000452 __cpu_name[cpu] = "R4700";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 c->isa_level = MIPS_CPU_ISA_III;
454 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
455 MIPS_CPU_LLSC;
456 c->tlbsize = 48;
457 break;
458 case PRID_IMP_TX49:
459 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000460 __cpu_name[cpu] = "R49XX";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 c->isa_level = MIPS_CPU_ISA_III;
462 c->options = R4K_OPTS | MIPS_CPU_LLSC;
463 if (!(c->processor_id & 0x08))
464 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
465 c->tlbsize = 48;
466 break;
467 case PRID_IMP_R5000:
468 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000469 __cpu_name[cpu] = "R5000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 c->isa_level = MIPS_CPU_ISA_IV;
471 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
472 MIPS_CPU_LLSC;
473 c->tlbsize = 48;
474 break;
475 case PRID_IMP_R5432:
476 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000477 __cpu_name[cpu] = "R5432";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 c->isa_level = MIPS_CPU_ISA_IV;
479 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
480 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
481 c->tlbsize = 48;
482 break;
483 case PRID_IMP_R5500:
484 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000485 __cpu_name[cpu] = "R5500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 c->isa_level = MIPS_CPU_ISA_IV;
487 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
488 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
489 c->tlbsize = 48;
490 break;
491 case PRID_IMP_NEVADA:
492 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000493 __cpu_name[cpu] = "Nevada";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 c->isa_level = MIPS_CPU_ISA_IV;
495 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
496 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
497 c->tlbsize = 48;
498 break;
499 case PRID_IMP_R6000:
500 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000501 __cpu_name[cpu] = "R6000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 c->isa_level = MIPS_CPU_ISA_II;
503 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
504 MIPS_CPU_LLSC;
505 c->tlbsize = 32;
506 break;
507 case PRID_IMP_R6000A:
508 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000509 __cpu_name[cpu] = "R6000A";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 c->isa_level = MIPS_CPU_ISA_II;
511 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
512 MIPS_CPU_LLSC;
513 c->tlbsize = 32;
514 break;
515 case PRID_IMP_RM7000:
516 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000517 __cpu_name[cpu] = "RM7000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 c->isa_level = MIPS_CPU_ISA_IV;
519 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
520 MIPS_CPU_LLSC;
521 /*
522 * Undocumented RM7000: Bit 29 in the info register of
523 * the RM7000 v2.0 indicates if the TLB has 48 or 64
524 * entries.
525 *
526 * 29 1 => 64 entry JTLB
527 * 0 => 48 entry JTLB
528 */
529 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
530 break;
531 case PRID_IMP_RM9000:
532 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000533 __cpu_name[cpu] = "RM9000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 c->isa_level = MIPS_CPU_ISA_IV;
535 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
536 MIPS_CPU_LLSC;
537 /*
538 * Bit 29 in the info register of the RM9000
539 * indicates if the TLB has 48 or 64 entries.
540 *
541 * 29 1 => 64 entry JTLB
542 * 0 => 48 entry JTLB
543 */
544 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
545 break;
546 case PRID_IMP_R8000:
547 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000548 __cpu_name[cpu] = "RM8000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 c->isa_level = MIPS_CPU_ISA_IV;
550 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
551 MIPS_CPU_FPU | MIPS_CPU_32FPR |
552 MIPS_CPU_LLSC;
553 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
554 break;
555 case PRID_IMP_R10000:
556 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000557 __cpu_name[cpu] = "R10000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000559 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 MIPS_CPU_FPU | MIPS_CPU_32FPR |
561 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
562 MIPS_CPU_LLSC;
563 c->tlbsize = 64;
564 break;
565 case PRID_IMP_R12000:
566 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000567 __cpu_name[cpu] = "R12000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000569 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 MIPS_CPU_FPU | MIPS_CPU_32FPR |
571 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
572 MIPS_CPU_LLSC;
573 c->tlbsize = 64;
574 break;
Kumba44d921b2006-05-16 22:23:59 -0400575 case PRID_IMP_R14000:
576 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000577 __cpu_name[cpu] = "R14000";
Kumba44d921b2006-05-16 22:23:59 -0400578 c->isa_level = MIPS_CPU_ISA_IV;
579 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
580 MIPS_CPU_FPU | MIPS_CPU_32FPR |
581 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
582 MIPS_CPU_LLSC;
583 c->tlbsize = 64;
584 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800585 case PRID_IMP_LOONGSON2:
586 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000587 __cpu_name[cpu] = "ICT Loongson-2";
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800588 c->isa_level = MIPS_CPU_ISA_III;
589 c->options = R4K_OPTS |
590 MIPS_CPU_FPU | MIPS_CPU_LLSC |
591 MIPS_CPU_32FPR;
592 c->tlbsize = 64;
593 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 }
595}
596
Ralf Baechle234fcd12008-03-08 09:56:28 +0000597static char unknown_isa[] __cpuinitdata = KERN_ERR \
Ralf Baechleb4672d32005-12-08 14:04:24 +0000598 "Unsupported ISA type, c0.config0: %d.";
599
Ralf Baechle41943182005-05-05 16:45:59 +0000600static inline unsigned int decode_config0(struct cpuinfo_mips *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601{
Ralf Baechle41943182005-05-05 16:45:59 +0000602 unsigned int config0;
603 int isa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604
Ralf Baechle41943182005-05-05 16:45:59 +0000605 config0 = read_c0_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606
Ralf Baechle41943182005-05-05 16:45:59 +0000607 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
Ralf Baechle02cf2112005-10-01 13:06:32 +0100608 c->options |= MIPS_CPU_TLB;
Ralf Baechle41943182005-05-05 16:45:59 +0000609 isa = (config0 & MIPS_CONF_AT) >> 13;
610 switch (isa) {
611 case 0:
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_M32R1;
615 break;
616 case 1:
617 c->isa_level = MIPS_CPU_ISA_M32R2;
618 break;
619 default:
620 goto unknown;
621 }
Ralf Baechle41943182005-05-05 16:45:59 +0000622 break;
623 case 2:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100624 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000625 case 0:
626 c->isa_level = MIPS_CPU_ISA_M64R1;
627 break;
628 case 1:
629 c->isa_level = MIPS_CPU_ISA_M64R2;
630 break;
631 default:
632 goto unknown;
633 }
Ralf Baechle41943182005-05-05 16:45:59 +0000634 break;
635 default:
Ralf Baechleb4672d32005-12-08 14:04:24 +0000636 goto unknown;
Ralf Baechle41943182005-05-05 16:45:59 +0000637 }
638
639 return config0 & MIPS_CONF_M;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000640
641unknown:
642 panic(unknown_isa, config0);
Ralf Baechle41943182005-05-05 16:45:59 +0000643}
644
645static inline unsigned int decode_config1(struct cpuinfo_mips *c)
646{
647 unsigned int config1;
648
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 config1 = read_c0_config1();
Ralf Baechle41943182005-05-05 16:45:59 +0000650
651 if (config1 & MIPS_CONF1_MD)
652 c->ases |= MIPS_ASE_MDMX;
653 if (config1 & MIPS_CONF1_WR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 c->options |= MIPS_CPU_WATCH;
Ralf Baechle41943182005-05-05 16:45:59 +0000655 if (config1 & MIPS_CONF1_CA)
656 c->ases |= MIPS_ASE_MIPS16;
657 if (config1 & MIPS_CONF1_EP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 c->options |= MIPS_CPU_EJTAG;
Ralf Baechle41943182005-05-05 16:45:59 +0000659 if (config1 & MIPS_CONF1_FP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 c->options |= MIPS_CPU_FPU;
661 c->options |= MIPS_CPU_32FPR;
662 }
Ralf Baechle41943182005-05-05 16:45:59 +0000663 if (cpu_has_tlb)
664 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
665
666 return config1 & MIPS_CONF_M;
667}
668
669static inline unsigned int decode_config2(struct cpuinfo_mips *c)
670{
671 unsigned int config2;
672
673 config2 = read_c0_config2();
674
675 if (config2 & MIPS_CONF2_SL)
676 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
677
678 return config2 & MIPS_CONF_M;
679}
680
681static inline unsigned int decode_config3(struct cpuinfo_mips *c)
682{
683 unsigned int config3;
684
685 config3 = read_c0_config3();
686
687 if (config3 & MIPS_CONF3_SM)
688 c->ases |= MIPS_ASE_SMARTMIPS;
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000689 if (config3 & MIPS_CONF3_DSP)
690 c->ases |= MIPS_ASE_DSP;
Ralf Baechle8f406112005-07-14 07:34:18 +0000691 if (config3 & MIPS_CONF3_VINT)
692 c->options |= MIPS_CPU_VINT;
693 if (config3 & MIPS_CONF3_VEIC)
694 c->options |= MIPS_CPU_VEIC;
695 if (config3 & MIPS_CONF3_MT)
Ralf Baechlee0daad42007-02-05 00:10:11 +0000696 c->ases |= MIPS_ASE_MIPSMT;
Ralf Baechlea3692022007-07-10 17:33:02 +0100697 if (config3 & MIPS_CONF3_ULRI)
698 c->options |= MIPS_CPU_ULRI;
Ralf Baechle41943182005-05-05 16:45:59 +0000699
700 return config3 & MIPS_CONF_M;
701}
702
David Daney1b362e32010-01-22 14:41:15 -0800703static inline unsigned int decode_config4(struct cpuinfo_mips *c)
704{
705 unsigned int config4;
706
707 config4 = read_c0_config4();
708
709 if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
710 && cpu_has_tlb)
711 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
712
713 return config4 & MIPS_CONF_M;
714}
715
Ralf Baechle234fcd12008-03-08 09:56:28 +0000716static void __cpuinit decode_configs(struct cpuinfo_mips *c)
Ralf Baechle41943182005-05-05 16:45:59 +0000717{
Ralf Baechle558ce122008-10-29 12:33:34 +0000718 int ok;
719
Ralf Baechle41943182005-05-05 16:45:59 +0000720 /* MIPS32 or MIPS64 compliant CPU. */
Ralf Baechle02cf2112005-10-01 13:06:32 +0100721 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
722 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
Ralf Baechle41943182005-05-05 16:45:59 +0000723
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
725
Ralf Baechle558ce122008-10-29 12:33:34 +0000726 ok = decode_config0(c); /* Read Config registers. */
727 BUG_ON(!ok); /* Arch spec violation! */
728 if (ok)
729 ok = decode_config1(c);
730 if (ok)
731 ok = decode_config2(c);
732 if (ok)
733 ok = decode_config3(c);
David Daney1b362e32010-01-22 14:41:15 -0800734 if (ok)
735 ok = decode_config4(c);
Ralf Baechle558ce122008-10-29 12:33:34 +0000736
737 mips_probe_watch_registers(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738}
739
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000740static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741{
Ralf Baechle41943182005-05-05 16:45:59 +0000742 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 switch (c->processor_id & 0xff00) {
744 case PRID_IMP_4KC:
745 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000746 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 break;
748 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000749 case PRID_IMP_4KECR2:
750 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000751 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000752 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100754 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000756 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 break;
758 case PRID_IMP_5KC:
759 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000760 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 break;
762 case PRID_IMP_20KC:
763 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000764 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 break;
766 case PRID_IMP_24K:
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000767 case PRID_IMP_24KE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000769 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 break;
771 case PRID_IMP_25KF:
772 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000773 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000775 case PRID_IMP_34K:
776 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000777 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000778 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100779 case PRID_IMP_74K:
780 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000781 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100782 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100783 case PRID_IMP_1004K:
784 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000785 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100786 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100788
789 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790}
791
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000792static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793{
Ralf Baechle41943182005-05-05 16:45:59 +0000794 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 switch (c->processor_id & 0xff00) {
796 case PRID_IMP_AU1_REV1:
797 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100798 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 switch ((c->processor_id >> 24) & 0xff) {
800 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000801 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 break;
803 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000804 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 break;
806 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000807 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 break;
809 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000810 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000812 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000813 __cpu_name[cpu] = "Au1200";
Manuel Lauss270717a2009-03-25 17:49:28 +0100814 if ((c->processor_id & 0xff) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000815 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100816 break;
817 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000818 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000819 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100821 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 break;
823 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824 break;
825 }
826}
827
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000828static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829{
Ralf Baechle41943182005-05-05 16:45:59 +0000830 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100831
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 switch (c->processor_id & 0xff00) {
833 case PRID_IMP_SB1:
834 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000835 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100837 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000838 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700840 case PRID_IMP_SB1A:
841 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000842 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700843 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 }
845}
846
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000847static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848{
Ralf Baechle41943182005-05-05 16:45:59 +0000849 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 switch (c->processor_id & 0xff00) {
851 case PRID_IMP_SR71000:
852 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000853 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854 c->scache.ways = 8;
855 c->tlbsize = 64;
856 break;
857 }
858}
859
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000860static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000861{
862 decode_configs(c);
863 switch (c->processor_id & 0xff00) {
864 case PRID_IMP_PR4450:
865 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000866 __cpu_name[cpu] = "Philips PR4450";
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000867 c->isa_level = MIPS_CPU_ISA_M32R1;
Pete Popovbdf21b12005-07-14 17:47:57 +0000868 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000869 }
870}
871
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000872static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200873{
874 decode_configs(c);
875 switch (c->processor_id & 0xff00) {
876 case PRID_IMP_BCM3302:
Maxime Bizon0de663e2009-08-18 13:23:37 +0100877 /* same as PRID_IMP_BCM6338 */
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200878 c->cputype = CPU_BCM3302;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000879 __cpu_name[cpu] = "Broadcom BCM3302";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200880 break;
881 case PRID_IMP_BCM4710:
882 c->cputype = CPU_BCM4710;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000883 __cpu_name[cpu] = "Broadcom BCM4710";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200884 break;
Maxime Bizon0de663e2009-08-18 13:23:37 +0100885 case PRID_IMP_BCM6345:
886 c->cputype = CPU_BCM6345;
887 __cpu_name[cpu] = "Broadcom BCM6345";
888 break;
889 case PRID_IMP_BCM6348:
890 c->cputype = CPU_BCM6348;
891 __cpu_name[cpu] = "Broadcom BCM6348";
892 break;
893 case PRID_IMP_BCM4350:
894 switch (c->processor_id & 0xf0) {
895 case PRID_REV_BCM6358:
896 c->cputype = CPU_BCM6358;
897 __cpu_name[cpu] = "Broadcom BCM6358";
898 break;
899 default:
900 c->cputype = CPU_UNKNOWN;
901 break;
902 }
903 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200904 }
905}
906
David Daney0dd47812008-12-11 15:33:26 -0800907static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
908{
909 decode_configs(c);
910 switch (c->processor_id & 0xff00) {
911 case PRID_IMP_CAVIUM_CN38XX:
912 case PRID_IMP_CAVIUM_CN31XX:
913 case PRID_IMP_CAVIUM_CN30XX:
914 case PRID_IMP_CAVIUM_CN58XX:
915 case PRID_IMP_CAVIUM_CN56XX:
916 case PRID_IMP_CAVIUM_CN50XX:
917 case PRID_IMP_CAVIUM_CN52XX:
918 c->cputype = CPU_CAVIUM_OCTEON;
919 __cpu_name[cpu] = "Cavium Octeon";
920 break;
921 default:
922 printk(KERN_INFO "Unknown Octeon chip!\n");
923 c->cputype = CPU_UNKNOWN;
924 break;
925 }
926}
927
Ralf Baechle9966db252007-10-11 23:46:17 +0100928const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -0800929const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +0100930
Ralf Baechle234fcd12008-03-08 09:56:28 +0000931__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932{
933 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +0100934 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700935
936 c->processor_id = PRID_IMP_UNKNOWN;
937 c->fpu_id = FPIR_IMP_NONE;
938 c->cputype = CPU_UNKNOWN;
939
940 c->processor_id = read_c0_prid();
941 switch (c->processor_id & 0xff0000) {
942 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000943 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944 break;
945 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000946 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947 break;
948 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000949 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950 break;
951 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000952 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200954 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000955 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200956 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000958 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700959 break;
Daniel Lairda92b0582008-03-06 09:07:18 +0000960 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000961 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000962 break;
David Daney0dd47812008-12-11 15:33:26 -0800963 case PRID_COMP_CAVIUM:
964 cpu_probe_cavium(c, cpu);
965 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200967
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000968 BUG_ON(!__cpu_name[cpu]);
969 BUG_ON(c->cputype == CPU_UNKNOWN);
970
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200971 /*
972 * Platform code can force the cpu type to optimize code
973 * generation. In that case be sure the cpu type is correctly
974 * manually setup otherwise it could trigger some nasty bugs.
975 */
976 BUG_ON(current_cpu_type() != c->cputype);
977
Ralf Baechle41943182005-05-05 16:45:59 +0000978 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +0000980
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000981 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
Ralf Baechleb4672d32005-12-08 14:04:24 +0000982 c->isa_level == MIPS_CPU_ISA_M32R2 ||
983 c->isa_level == MIPS_CPU_ISA_M64R1 ||
984 c->isa_level == MIPS_CPU_ISA_M64R2) {
Ralf Baechle41943182005-05-05 16:45:59 +0000985 if (c->fpu_id & MIPS_FPIR_3D)
986 c->ases |= MIPS_ASE_MIPS3D;
987 }
988 }
Ralf Baechle9966db252007-10-11 23:46:17 +0100989
Ralf Baechlef6771db2007-11-08 18:02:29 +0000990 if (cpu_has_mips_r2)
991 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
992 else
993 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -0800994
995 cpu_probe_vmbits(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996}
997
Ralf Baechle234fcd12008-03-08 09:56:28 +0000998__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700999{
1000 struct cpuinfo_mips *c = &current_cpu_data;
1001
Ralf Baechle9966db252007-10-11 23:46:17 +01001002 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
1003 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001004 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001005 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006}