Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Processor capabilities determination functions. |
| 3 | * |
| 4 | * Copyright (C) xxxx the Anonymous |
Ralf Baechle | 010b853 | 2006-01-29 18:42:08 +0000 | [diff] [blame] | 5 | * Copyright (C) 1994 - 2006 Ralf Baechle |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 6 | * Copyright (C) 2003, 2004 Maciej W. Rozycki |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 7 | * Copyright (C) 2001, 2004 MIPS Inc. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/init.h> |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/ptrace.h> |
Ralf Baechle | 631330f | 2009-06-19 14:05:26 +0100 | [diff] [blame] | 17 | #include <linux/smp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/stddef.h> |
Wu Zhangjin | f8ede0f | 2009-11-17 01:32:59 +0800 | [diff] [blame] | 19 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
Ralf Baechle | 5759906 | 2007-02-18 19:07:31 +0000 | [diff] [blame] | 21 | #include <asm/bugs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <asm/cpu.h> |
| 23 | #include <asm/fpu.h> |
| 24 | #include <asm/mipsregs.h> |
| 25 | #include <asm/system.h> |
David Daney | 654f57b | 2008-09-23 00:07:16 -0700 | [diff] [blame] | 26 | #include <asm/watch.h> |
Chris Dearman | a074f0e | 2009-07-10 01:51:27 -0700 | [diff] [blame] | 27 | #include <asm/spram.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | /* |
| 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 Baechle | 982f6ff | 2009-09-17 02:25:07 +0200 | [diff] [blame] | 35 | void (*cpu_wait)(void); |
Wu Zhangjin | f8ede0f | 2009-11-17 01:32:59 +0800 | [diff] [blame] | 36 | EXPORT_SYMBOL(cpu_wait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
| 38 | static void r3081_wait(void) |
| 39 | { |
| 40 | unsigned long cfg = read_c0_conf(); |
| 41 | write_c0_conf(cfg | R30XX_CONF_HALT); |
| 42 | } |
| 43 | |
| 44 | static void r39xx_wait(void) |
| 45 | { |
Atsushi Nemoto | 60a6c37 | 2006-06-08 01:09:01 +0900 | [diff] [blame] | 46 | local_irq_disable(); |
| 47 | if (!need_resched()) |
| 48 | write_c0_conf(read_c0_conf() | TX39_CONF_HALT); |
| 49 | local_irq_enable(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Atsushi Nemoto | c65a548 | 2007-11-12 02:05:18 +0900 | [diff] [blame] | 52 | extern void r4k_wait(void); |
Atsushi Nemoto | 60a6c37 | 2006-06-08 01:09:01 +0900 | [diff] [blame] | 53 | |
| 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. Kissell | 8531a35 | 2008-09-09 21:48:52 +0200 | [diff] [blame] | 61 | void r4k_wait_irqoff(void) |
Atsushi Nemoto | 60a6c37 | 2006-06-08 01:09:01 +0900 | [diff] [blame] | 62 | { |
| 63 | local_irq_disable(); |
| 64 | if (!need_resched()) |
Kevin D. Kissell | 8531a35 | 2008-09-09 21:48:52 +0200 | [diff] [blame] | 65 | __asm__(" .set push \n" |
| 66 | " .set mips3 \n" |
Atsushi Nemoto | 60a6c37 | 2006-06-08 01:09:01 +0900 | [diff] [blame] | 67 | " wait \n" |
Kevin D. Kissell | 8531a35 | 2008-09-09 21:48:52 +0200 | [diff] [blame] | 68 | " .set pop \n"); |
Atsushi Nemoto | 60a6c37 | 2006-06-08 01:09:01 +0900 | [diff] [blame] | 69 | local_irq_enable(); |
Kevin D. Kissell | 8531a35 | 2008-09-09 21:48:52 +0200 | [diff] [blame] | 70 | __asm__(" .globl __pastwait \n" |
| 71 | "__pastwait: \n"); |
| 72 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | } |
| 74 | |
Ralf Baechle | 5a81299 | 2007-07-17 18:49:48 +0100 | [diff] [blame] | 75 | /* |
| 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 | */ |
| 79 | static 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 Lauss | 2882b0c | 2009-08-22 18:09:27 +0200 | [diff] [blame] | 96 | /* |
| 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 Popov | 494900a | 2005-04-07 00:42:10 +0000 | [diff] [blame] | 101 | static void au1k_wait(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | { |
Atsushi Nemoto | 60a6c37 | 2006-06-08 01:09:01 +0900 | [diff] [blame] | 103 | __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 Baechle | 10f650d | 2005-05-25 13:32:49 +0000 | [diff] [blame] | 114 | : : "r" (au1k_wait)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | } |
| 116 | |
Ralf Baechle | 982f6ff | 2009-09-17 02:25:07 +0200 | [diff] [blame] | 117 | static int __initdata nowait; |
Ralf Baechle | 55d04df | 2005-07-13 19:22:45 +0000 | [diff] [blame] | 118 | |
Atsushi Nemoto | f49a747 | 2007-02-18 01:02:14 +0900 | [diff] [blame] | 119 | static int __init wait_disable(char *s) |
Ralf Baechle | 55d04df | 2005-07-13 19:22:45 +0000 | [diff] [blame] | 120 | { |
| 121 | nowait = 1; |
| 122 | |
| 123 | return 1; |
| 124 | } |
| 125 | |
| 126 | __setup("nowait", wait_disable); |
| 127 | |
Kevin Cernekee | 0103d23 | 2010-05-02 14:43:52 -0700 | [diff] [blame] | 128 | static int __cpuinitdata mips_fpu_disabled; |
| 129 | |
| 130 | static int __init fpu_disable(char *s) |
| 131 | { |
| 132 | cpu_data[0].options &= ~MIPS_CPU_FPU; |
| 133 | mips_fpu_disabled = 1; |
| 134 | |
| 135 | return 1; |
| 136 | } |
| 137 | |
| 138 | __setup("nofpu", fpu_disable); |
| 139 | |
| 140 | int __cpuinitdata mips_dsp_disabled; |
| 141 | |
| 142 | static int __init dsp_disable(char *s) |
| 143 | { |
| 144 | cpu_data[0].ases &= ~MIPS_ASE_DSP; |
| 145 | mips_dsp_disabled = 1; |
| 146 | |
| 147 | return 1; |
| 148 | } |
| 149 | |
| 150 | __setup("nodsp", dsp_disable); |
| 151 | |
Atsushi Nemoto | c65a548 | 2007-11-12 02:05:18 +0900 | [diff] [blame] | 152 | void __init check_wait(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | { |
| 154 | struct cpuinfo_mips *c = ¤t_cpu_data; |
| 155 | |
Ralf Baechle | 55d04df | 2005-07-13 19:22:45 +0000 | [diff] [blame] | 156 | if (nowait) { |
Ralf Baechle | c237923 | 2006-11-30 01:14:44 +0000 | [diff] [blame] | 157 | printk("Wait instruction disabled.\n"); |
Ralf Baechle | 55d04df | 2005-07-13 19:22:45 +0000 | [diff] [blame] | 158 | return; |
| 159 | } |
| 160 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | switch (c->cputype) { |
| 162 | case CPU_R3081: |
| 163 | case CPU_R3081E: |
| 164 | cpu_wait = r3081_wait; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | break; |
| 166 | case CPU_TX3927: |
| 167 | cpu_wait = r39xx_wait; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | break; |
| 169 | case CPU_R4200: |
| 170 | /* case CPU_R4300: */ |
| 171 | case CPU_R4600: |
| 172 | case CPU_R4640: |
| 173 | case CPU_R4650: |
| 174 | case CPU_R4700: |
| 175 | case CPU_R5000: |
Shinya Kuribayashi | a644b27 | 2009-03-03 18:05:51 +0900 | [diff] [blame] | 176 | case CPU_R5500: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | case CPU_NEVADA: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | case CPU_4KC: |
| 179 | case CPU_4KEC: |
| 180 | case CPU_4KSC: |
| 181 | case CPU_5KC: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | case CPU_25KF: |
Ralf Baechle | 4b3e975 | 2007-06-21 00:22:34 +0100 | [diff] [blame] | 183 | case CPU_PR4450: |
Aurelien Jarno | 1c0c13e | 2007-09-25 15:40:12 +0200 | [diff] [blame] | 184 | case CPU_BCM3302: |
Maxime Bizon | 0de663e | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 185 | case CPU_BCM6338: |
| 186 | case CPU_BCM6348: |
| 187 | case CPU_BCM6358: |
David Daney | 0dd4781 | 2008-12-11 15:33:26 -0800 | [diff] [blame] | 188 | case CPU_CAVIUM_OCTEON: |
David Daney | 6f32946 | 2010-02-10 15:12:48 -0800 | [diff] [blame] | 189 | case CPU_CAVIUM_OCTEON_PLUS: |
David Daney | 0e56b38 | 2010-10-07 16:03:45 -0700 | [diff] [blame^] | 190 | case CPU_CAVIUM_OCTEON2: |
Lars-Peter Clausen | 83ccf69 | 2010-07-17 11:07:51 +0000 | [diff] [blame] | 191 | case CPU_JZRISC: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | cpu_wait = r4k_wait; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | break; |
Ralf Baechle | 4b3e975 | 2007-06-21 00:22:34 +0100 | [diff] [blame] | 194 | |
Ralf Baechle | 5a81299 | 2007-07-17 18:49:48 +0100 | [diff] [blame] | 195 | case CPU_RM7000: |
| 196 | cpu_wait = rm7k_wait_irqoff; |
| 197 | break; |
| 198 | |
Ralf Baechle | 4b3e975 | 2007-06-21 00:22:34 +0100 | [diff] [blame] | 199 | case CPU_24K: |
| 200 | case CPU_34K: |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 201 | case CPU_1004K: |
Ralf Baechle | 4b3e975 | 2007-06-21 00:22:34 +0100 | [diff] [blame] | 202 | cpu_wait = r4k_wait; |
| 203 | if (read_c0_config7() & MIPS_CONF7_WII) |
| 204 | cpu_wait = r4k_wait_irqoff; |
| 205 | break; |
| 206 | |
| 207 | case CPU_74K: |
| 208 | cpu_wait = r4k_wait; |
| 209 | if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0)) |
| 210 | cpu_wait = r4k_wait_irqoff; |
| 211 | break; |
| 212 | |
Atsushi Nemoto | 60a6c37 | 2006-06-08 01:09:01 +0900 | [diff] [blame] | 213 | case CPU_TX49XX: |
| 214 | cpu_wait = r4k_wait_irqoff; |
Atsushi Nemoto | 60a6c37 | 2006-06-08 01:09:01 +0900 | [diff] [blame] | 215 | break; |
Manuel Lauss | 270717a | 2009-03-25 17:49:28 +0100 | [diff] [blame] | 216 | case CPU_ALCHEMY: |
Manuel Lauss | 0c694de | 2008-12-21 09:26:23 +0100 | [diff] [blame] | 217 | cpu_wait = au1k_wait; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | break; |
Ralf Baechle | c8eae71 | 2007-06-12 13:04:09 +0100 | [diff] [blame] | 219 | case CPU_20KC: |
| 220 | /* |
| 221 | * WAIT on Rev1.0 has E1, E2, E3 and E16. |
| 222 | * WAIT on Rev2.0 and Rev3.0 has E16. |
| 223 | * Rev3.1 WAIT is nop, why bother |
| 224 | */ |
| 225 | if ((c->processor_id & 0xff) <= 0x64) |
| 226 | break; |
| 227 | |
Ralf Baechle | 50da469 | 2007-09-14 19:08:43 +0100 | [diff] [blame] | 228 | /* |
| 229 | * Another rev is incremeting c0_count at a reduced clock |
| 230 | * rate while in WAIT mode. So we basically have the choice |
| 231 | * between using the cp0 timer as clocksource or avoiding |
| 232 | * the WAIT instruction. Until more details are known, |
| 233 | * disable the use of WAIT for 20Kc entirely. |
| 234 | cpu_wait = r4k_wait; |
| 235 | */ |
Ralf Baechle | c8eae71 | 2007-06-12 13:04:09 +0100 | [diff] [blame] | 236 | break; |
Ralf Baechle | 441ee34 | 2006-06-02 11:48:11 +0100 | [diff] [blame] | 237 | case CPU_RM9000: |
Ralf Baechle | c237923 | 2006-11-30 01:14:44 +0000 | [diff] [blame] | 238 | if ((c->processor_id & 0x00ff) >= 0x40) |
Ralf Baechle | 441ee34 | 2006-06-02 11:48:11 +0100 | [diff] [blame] | 239 | cpu_wait = r4k_wait; |
Ralf Baechle | 441ee34 | 2006-06-02 11:48:11 +0100 | [diff] [blame] | 240 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | default: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | break; |
| 243 | } |
| 244 | } |
| 245 | |
Marc St-Jean | 9267a30 | 2007-06-14 15:55:31 -0600 | [diff] [blame] | 246 | static inline void check_errata(void) |
| 247 | { |
| 248 | struct cpuinfo_mips *c = ¤t_cpu_data; |
| 249 | |
| 250 | switch (c->cputype) { |
| 251 | case CPU_34K: |
| 252 | /* |
| 253 | * Erratum "RPS May Cause Incorrect Instruction Execution" |
| 254 | * This code only handles VPE0, any SMP/SMTC/RTOS code |
| 255 | * making use of VPE1 will be responsable for that VPE. |
| 256 | */ |
| 257 | if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2) |
| 258 | write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS); |
| 259 | break; |
| 260 | default: |
| 261 | break; |
| 262 | } |
| 263 | } |
| 264 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | void __init check_bugs32(void) |
| 266 | { |
Marc St-Jean | 9267a30 | 2007-06-14 15:55:31 -0600 | [diff] [blame] | 267 | check_errata(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | /* |
| 271 | * Probe whether cpu has config register by trying to play with |
| 272 | * alternate cache bit and see whether it matters. |
| 273 | * It's used by cpu_probe to distinguish between R3000A and R3081. |
| 274 | */ |
| 275 | static inline int cpu_has_confreg(void) |
| 276 | { |
| 277 | #ifdef CONFIG_CPU_R3000 |
| 278 | extern unsigned long r3k_cache_size(unsigned long); |
| 279 | unsigned long size1, size2; |
| 280 | unsigned long cfg = read_c0_conf(); |
| 281 | |
| 282 | size1 = r3k_cache_size(ST0_ISC); |
| 283 | write_c0_conf(cfg ^ R30XX_CONF_AC); |
| 284 | size2 = r3k_cache_size(ST0_ISC); |
| 285 | write_c0_conf(cfg); |
| 286 | return size1 != size2; |
| 287 | #else |
| 288 | return 0; |
| 289 | #endif |
| 290 | } |
| 291 | |
| 292 | /* |
| 293 | * Get the FPU Implementation/Revision. |
| 294 | */ |
| 295 | static inline unsigned long cpu_get_fpu_id(void) |
| 296 | { |
| 297 | unsigned long tmp, fpu_id; |
| 298 | |
| 299 | tmp = read_c0_status(); |
| 300 | __enable_fpu(); |
| 301 | fpu_id = read_32bit_cp1_register(CP1_REVISION); |
| 302 | write_c0_status(tmp); |
| 303 | return fpu_id; |
| 304 | } |
| 305 | |
| 306 | /* |
| 307 | * Check the CPU has an FPU the official way. |
| 308 | */ |
| 309 | static inline int __cpu_has_fpu(void) |
| 310 | { |
| 311 | return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE); |
| 312 | } |
| 313 | |
Guenter Roeck | 91dfc42 | 2010-02-02 08:52:20 -0800 | [diff] [blame] | 314 | static inline void cpu_probe_vmbits(struct cpuinfo_mips *c) |
| 315 | { |
| 316 | #ifdef __NEED_VMBITS_PROBE |
David Daney | 5b7efa8 | 2010-02-08 12:27:00 -0800 | [diff] [blame] | 317 | write_c0_entryhi(0x3fffffffffffe000ULL); |
Guenter Roeck | 91dfc42 | 2010-02-02 08:52:20 -0800 | [diff] [blame] | 318 | back_to_back_c0_hazard(); |
David Daney | 5b7efa8 | 2010-02-08 12:27:00 -0800 | [diff] [blame] | 319 | c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL); |
Guenter Roeck | 91dfc42 | 2010-02-02 08:52:20 -0800 | [diff] [blame] | 320 | #endif |
| 321 | } |
| 322 | |
Ralf Baechle | 02cf211 | 2005-10-01 13:06:32 +0100 | [diff] [blame] | 323 | #define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | | MIPS_CPU_COUNTER) |
| 325 | |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 326 | static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | { |
| 328 | switch (c->processor_id & 0xff00) { |
| 329 | case PRID_IMP_R2000: |
| 330 | c->cputype = CPU_R2000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 331 | __cpu_name[cpu] = "R2000"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | c->isa_level = MIPS_CPU_ISA_I; |
Ralf Baechle | 02cf211 | 2005-10-01 13:06:32 +0100 | [diff] [blame] | 333 | c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE | |
| 334 | MIPS_CPU_NOFPUEX; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | if (__cpu_has_fpu()) |
| 336 | c->options |= MIPS_CPU_FPU; |
| 337 | c->tlbsize = 64; |
| 338 | break; |
| 339 | case PRID_IMP_R3000: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 340 | if ((c->processor_id & 0xff) == PRID_REV_R3000A) { |
| 341 | if (cpu_has_confreg()) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | c->cputype = CPU_R3081E; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 343 | __cpu_name[cpu] = "R3081"; |
| 344 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | c->cputype = CPU_R3000A; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 346 | __cpu_name[cpu] = "R3000A"; |
| 347 | } |
| 348 | break; |
| 349 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | c->cputype = CPU_R3000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 351 | __cpu_name[cpu] = "R3000"; |
| 352 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | c->isa_level = MIPS_CPU_ISA_I; |
Ralf Baechle | 02cf211 | 2005-10-01 13:06:32 +0100 | [diff] [blame] | 354 | c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE | |
| 355 | MIPS_CPU_NOFPUEX; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | if (__cpu_has_fpu()) |
| 357 | c->options |= MIPS_CPU_FPU; |
| 358 | c->tlbsize = 64; |
| 359 | break; |
| 360 | case PRID_IMP_R4000: |
| 361 | if (read_c0_config() & CONF_SC) { |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 362 | if ((c->processor_id & 0xff) >= PRID_REV_R4400) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | c->cputype = CPU_R4400PC; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 364 | __cpu_name[cpu] = "R4400PC"; |
| 365 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | c->cputype = CPU_R4000PC; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 367 | __cpu_name[cpu] = "R4000PC"; |
| 368 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | } else { |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 370 | if ((c->processor_id & 0xff) >= PRID_REV_R4400) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | c->cputype = CPU_R4400SC; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 372 | __cpu_name[cpu] = "R4400SC"; |
| 373 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | c->cputype = CPU_R4000SC; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 375 | __cpu_name[cpu] = "R4000SC"; |
| 376 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | c->isa_level = MIPS_CPU_ISA_III; |
| 380 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
| 381 | MIPS_CPU_WATCH | MIPS_CPU_VCE | |
| 382 | MIPS_CPU_LLSC; |
| 383 | c->tlbsize = 48; |
| 384 | break; |
| 385 | case PRID_IMP_VR41XX: |
| 386 | switch (c->processor_id & 0xf0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | case PRID_REV_VR4111: |
| 388 | c->cputype = CPU_VR4111; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 389 | __cpu_name[cpu] = "NEC VR4111"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | case PRID_REV_VR4121: |
| 392 | c->cputype = CPU_VR4121; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 393 | __cpu_name[cpu] = "NEC VR4121"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | break; |
| 395 | case PRID_REV_VR4122: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 396 | if ((c->processor_id & 0xf) < 0x3) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | c->cputype = CPU_VR4122; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 398 | __cpu_name[cpu] = "NEC VR4122"; |
| 399 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | c->cputype = CPU_VR4181A; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 401 | __cpu_name[cpu] = "NEC VR4181A"; |
| 402 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | break; |
| 404 | case PRID_REV_VR4130: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 405 | if ((c->processor_id & 0xf) < 0x4) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | c->cputype = CPU_VR4131; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 407 | __cpu_name[cpu] = "NEC VR4131"; |
| 408 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | c->cputype = CPU_VR4133; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 410 | __cpu_name[cpu] = "NEC VR4133"; |
| 411 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | break; |
| 413 | default: |
| 414 | printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n"); |
| 415 | c->cputype = CPU_VR41XX; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 416 | __cpu_name[cpu] = "NEC Vr41xx"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | break; |
| 418 | } |
| 419 | c->isa_level = MIPS_CPU_ISA_III; |
| 420 | c->options = R4K_OPTS; |
| 421 | c->tlbsize = 32; |
| 422 | break; |
| 423 | case PRID_IMP_R4300: |
| 424 | c->cputype = CPU_R4300; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 425 | __cpu_name[cpu] = "R4300"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | c->isa_level = MIPS_CPU_ISA_III; |
| 427 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
| 428 | MIPS_CPU_LLSC; |
| 429 | c->tlbsize = 32; |
| 430 | break; |
| 431 | case PRID_IMP_R4600: |
| 432 | c->cputype = CPU_R4600; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 433 | __cpu_name[cpu] = "R4600"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | c->isa_level = MIPS_CPU_ISA_III; |
Thiemo Seufer | 075e750 | 2005-07-27 21:48:12 +0000 | [diff] [blame] | 435 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
| 436 | MIPS_CPU_LLSC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | c->tlbsize = 48; |
| 438 | break; |
| 439 | #if 0 |
| 440 | case PRID_IMP_R4650: |
| 441 | /* |
| 442 | * This processor doesn't have an MMU, so it's not |
| 443 | * "real easy" to run Linux on it. It is left purely |
| 444 | * for documentation. Commented out because it shares |
| 445 | * it's c0_prid id number with the TX3900. |
| 446 | */ |
Ralf Baechle | a3dddd5 | 2006-03-11 08:18:41 +0000 | [diff] [blame] | 447 | c->cputype = CPU_R4650; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 448 | __cpu_name[cpu] = "R4650"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | c->isa_level = MIPS_CPU_ISA_III; |
| 450 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC; |
| 451 | c->tlbsize = 48; |
| 452 | break; |
| 453 | #endif |
| 454 | case PRID_IMP_TX39: |
| 455 | c->isa_level = MIPS_CPU_ISA_I; |
Ralf Baechle | 02cf211 | 2005-10-01 13:06:32 +0100 | [diff] [blame] | 456 | c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | |
| 458 | if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) { |
| 459 | c->cputype = CPU_TX3927; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 460 | __cpu_name[cpu] = "TX3927"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | c->tlbsize = 64; |
| 462 | } else { |
| 463 | switch (c->processor_id & 0xff) { |
| 464 | case PRID_REV_TX3912: |
| 465 | c->cputype = CPU_TX3912; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 466 | __cpu_name[cpu] = "TX3912"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | c->tlbsize = 32; |
| 468 | break; |
| 469 | case PRID_REV_TX3922: |
| 470 | c->cputype = CPU_TX3922; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 471 | __cpu_name[cpu] = "TX3922"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | c->tlbsize = 64; |
| 473 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | } |
| 475 | } |
| 476 | break; |
| 477 | case PRID_IMP_R4700: |
| 478 | c->cputype = CPU_R4700; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 479 | __cpu_name[cpu] = "R4700"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | c->isa_level = MIPS_CPU_ISA_III; |
| 481 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
| 482 | MIPS_CPU_LLSC; |
| 483 | c->tlbsize = 48; |
| 484 | break; |
| 485 | case PRID_IMP_TX49: |
| 486 | c->cputype = CPU_TX49XX; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 487 | __cpu_name[cpu] = "R49XX"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | c->isa_level = MIPS_CPU_ISA_III; |
| 489 | c->options = R4K_OPTS | MIPS_CPU_LLSC; |
| 490 | if (!(c->processor_id & 0x08)) |
| 491 | c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR; |
| 492 | c->tlbsize = 48; |
| 493 | break; |
| 494 | case PRID_IMP_R5000: |
| 495 | c->cputype = CPU_R5000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 496 | __cpu_name[cpu] = "R5000"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | c->isa_level = MIPS_CPU_ISA_IV; |
| 498 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
| 499 | MIPS_CPU_LLSC; |
| 500 | c->tlbsize = 48; |
| 501 | break; |
| 502 | case PRID_IMP_R5432: |
| 503 | c->cputype = CPU_R5432; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 504 | __cpu_name[cpu] = "R5432"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | c->isa_level = MIPS_CPU_ISA_IV; |
| 506 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
| 507 | MIPS_CPU_WATCH | MIPS_CPU_LLSC; |
| 508 | c->tlbsize = 48; |
| 509 | break; |
| 510 | case PRID_IMP_R5500: |
| 511 | c->cputype = CPU_R5500; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 512 | __cpu_name[cpu] = "R5500"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | c->isa_level = MIPS_CPU_ISA_IV; |
| 514 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
| 515 | MIPS_CPU_WATCH | MIPS_CPU_LLSC; |
| 516 | c->tlbsize = 48; |
| 517 | break; |
| 518 | case PRID_IMP_NEVADA: |
| 519 | c->cputype = CPU_NEVADA; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 520 | __cpu_name[cpu] = "Nevada"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | c->isa_level = MIPS_CPU_ISA_IV; |
| 522 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
| 523 | MIPS_CPU_DIVEC | MIPS_CPU_LLSC; |
| 524 | c->tlbsize = 48; |
| 525 | break; |
| 526 | case PRID_IMP_R6000: |
| 527 | c->cputype = CPU_R6000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 528 | __cpu_name[cpu] = "R6000"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | c->isa_level = MIPS_CPU_ISA_II; |
| 530 | c->options = MIPS_CPU_TLB | MIPS_CPU_FPU | |
| 531 | MIPS_CPU_LLSC; |
| 532 | c->tlbsize = 32; |
| 533 | break; |
| 534 | case PRID_IMP_R6000A: |
| 535 | c->cputype = CPU_R6000A; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 536 | __cpu_name[cpu] = "R6000A"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | c->isa_level = MIPS_CPU_ISA_II; |
| 538 | c->options = MIPS_CPU_TLB | MIPS_CPU_FPU | |
| 539 | MIPS_CPU_LLSC; |
| 540 | c->tlbsize = 32; |
| 541 | break; |
| 542 | case PRID_IMP_RM7000: |
| 543 | c->cputype = CPU_RM7000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 544 | __cpu_name[cpu] = "RM7000"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | c->isa_level = MIPS_CPU_ISA_IV; |
| 546 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
| 547 | MIPS_CPU_LLSC; |
| 548 | /* |
| 549 | * Undocumented RM7000: Bit 29 in the info register of |
| 550 | * the RM7000 v2.0 indicates if the TLB has 48 or 64 |
| 551 | * entries. |
| 552 | * |
| 553 | * 29 1 => 64 entry JTLB |
| 554 | * 0 => 48 entry JTLB |
| 555 | */ |
| 556 | c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48; |
| 557 | break; |
| 558 | case PRID_IMP_RM9000: |
| 559 | c->cputype = CPU_RM9000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 560 | __cpu_name[cpu] = "RM9000"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | c->isa_level = MIPS_CPU_ISA_IV; |
| 562 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
| 563 | MIPS_CPU_LLSC; |
| 564 | /* |
| 565 | * Bit 29 in the info register of the RM9000 |
| 566 | * indicates if the TLB has 48 or 64 entries. |
| 567 | * |
| 568 | * 29 1 => 64 entry JTLB |
| 569 | * 0 => 48 entry JTLB |
| 570 | */ |
| 571 | c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48; |
| 572 | break; |
| 573 | case PRID_IMP_R8000: |
| 574 | c->cputype = CPU_R8000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 575 | __cpu_name[cpu] = "RM8000"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | c->isa_level = MIPS_CPU_ISA_IV; |
| 577 | c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX | |
| 578 | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
| 579 | MIPS_CPU_LLSC; |
| 580 | c->tlbsize = 384; /* has weird TLB: 3-way x 128 */ |
| 581 | break; |
| 582 | case PRID_IMP_R10000: |
| 583 | c->cputype = CPU_R10000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 584 | __cpu_name[cpu] = "R10000"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | c->isa_level = MIPS_CPU_ISA_IV; |
Ralf Baechle | 8b36612 | 2005-11-22 17:53:59 +0000 | [diff] [blame] | 586 | c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
| 588 | MIPS_CPU_COUNTER | MIPS_CPU_WATCH | |
| 589 | MIPS_CPU_LLSC; |
| 590 | c->tlbsize = 64; |
| 591 | break; |
| 592 | case PRID_IMP_R12000: |
| 593 | c->cputype = CPU_R12000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 594 | __cpu_name[cpu] = "R12000"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | c->isa_level = MIPS_CPU_ISA_IV; |
Ralf Baechle | 8b36612 | 2005-11-22 17:53:59 +0000 | [diff] [blame] | 596 | c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
| 598 | MIPS_CPU_COUNTER | MIPS_CPU_WATCH | |
| 599 | MIPS_CPU_LLSC; |
| 600 | c->tlbsize = 64; |
| 601 | break; |
Kumba | 44d921b | 2006-05-16 22:23:59 -0400 | [diff] [blame] | 602 | case PRID_IMP_R14000: |
| 603 | c->cputype = CPU_R14000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 604 | __cpu_name[cpu] = "R14000"; |
Kumba | 44d921b | 2006-05-16 22:23:59 -0400 | [diff] [blame] | 605 | c->isa_level = MIPS_CPU_ISA_IV; |
| 606 | c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX | |
| 607 | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
| 608 | MIPS_CPU_COUNTER | MIPS_CPU_WATCH | |
| 609 | MIPS_CPU_LLSC; |
| 610 | c->tlbsize = 64; |
| 611 | break; |
Fuxin Zhang | 2a21c73 | 2007-06-06 14:52:43 +0800 | [diff] [blame] | 612 | case PRID_IMP_LOONGSON2: |
| 613 | c->cputype = CPU_LOONGSON2; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 614 | __cpu_name[cpu] = "ICT Loongson-2"; |
Fuxin Zhang | 2a21c73 | 2007-06-06 14:52:43 +0800 | [diff] [blame] | 615 | c->isa_level = MIPS_CPU_ISA_III; |
| 616 | c->options = R4K_OPTS | |
| 617 | MIPS_CPU_FPU | MIPS_CPU_LLSC | |
| 618 | MIPS_CPU_32FPR; |
| 619 | c->tlbsize = 64; |
| 620 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | } |
| 622 | } |
| 623 | |
Ralf Baechle | 234fcd1 | 2008-03-08 09:56:28 +0000 | [diff] [blame] | 624 | static char unknown_isa[] __cpuinitdata = KERN_ERR \ |
Ralf Baechle | b4672d3 | 2005-12-08 14:04:24 +0000 | [diff] [blame] | 625 | "Unsupported ISA type, c0.config0: %d."; |
| 626 | |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 627 | static inline unsigned int decode_config0(struct cpuinfo_mips *c) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | { |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 629 | unsigned int config0; |
| 630 | int isa; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 632 | config0 = read_c0_config(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 634 | if (((config0 & MIPS_CONF_MT) >> 7) == 1) |
Ralf Baechle | 02cf211 | 2005-10-01 13:06:32 +0100 | [diff] [blame] | 635 | c->options |= MIPS_CPU_TLB; |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 636 | isa = (config0 & MIPS_CONF_AT) >> 13; |
| 637 | switch (isa) { |
| 638 | case 0: |
Thiemo Seufer | 3a01c49 | 2006-07-03 13:30:01 +0100 | [diff] [blame] | 639 | switch ((config0 & MIPS_CONF_AR) >> 10) { |
Ralf Baechle | b4672d3 | 2005-12-08 14:04:24 +0000 | [diff] [blame] | 640 | case 0: |
| 641 | c->isa_level = MIPS_CPU_ISA_M32R1; |
| 642 | break; |
| 643 | case 1: |
| 644 | c->isa_level = MIPS_CPU_ISA_M32R2; |
| 645 | break; |
| 646 | default: |
| 647 | goto unknown; |
| 648 | } |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 649 | break; |
| 650 | case 2: |
Thiemo Seufer | 3a01c49 | 2006-07-03 13:30:01 +0100 | [diff] [blame] | 651 | switch ((config0 & MIPS_CONF_AR) >> 10) { |
Ralf Baechle | b4672d3 | 2005-12-08 14:04:24 +0000 | [diff] [blame] | 652 | case 0: |
| 653 | c->isa_level = MIPS_CPU_ISA_M64R1; |
| 654 | break; |
| 655 | case 1: |
| 656 | c->isa_level = MIPS_CPU_ISA_M64R2; |
| 657 | break; |
| 658 | default: |
| 659 | goto unknown; |
| 660 | } |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 661 | break; |
| 662 | default: |
Ralf Baechle | b4672d3 | 2005-12-08 14:04:24 +0000 | [diff] [blame] | 663 | goto unknown; |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 664 | } |
| 665 | |
| 666 | return config0 & MIPS_CONF_M; |
Ralf Baechle | b4672d3 | 2005-12-08 14:04:24 +0000 | [diff] [blame] | 667 | |
| 668 | unknown: |
| 669 | panic(unknown_isa, config0); |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 670 | } |
| 671 | |
| 672 | static inline unsigned int decode_config1(struct cpuinfo_mips *c) |
| 673 | { |
| 674 | unsigned int config1; |
| 675 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | config1 = read_c0_config1(); |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 677 | |
| 678 | if (config1 & MIPS_CONF1_MD) |
| 679 | c->ases |= MIPS_ASE_MDMX; |
| 680 | if (config1 & MIPS_CONF1_WR) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | c->options |= MIPS_CPU_WATCH; |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 682 | if (config1 & MIPS_CONF1_CA) |
| 683 | c->ases |= MIPS_ASE_MIPS16; |
| 684 | if (config1 & MIPS_CONF1_EP) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | c->options |= MIPS_CPU_EJTAG; |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 686 | if (config1 & MIPS_CONF1_FP) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | c->options |= MIPS_CPU_FPU; |
| 688 | c->options |= MIPS_CPU_32FPR; |
| 689 | } |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 690 | if (cpu_has_tlb) |
| 691 | c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1; |
| 692 | |
| 693 | return config1 & MIPS_CONF_M; |
| 694 | } |
| 695 | |
| 696 | static inline unsigned int decode_config2(struct cpuinfo_mips *c) |
| 697 | { |
| 698 | unsigned int config2; |
| 699 | |
| 700 | config2 = read_c0_config2(); |
| 701 | |
| 702 | if (config2 & MIPS_CONF2_SL) |
| 703 | c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT; |
| 704 | |
| 705 | return config2 & MIPS_CONF_M; |
| 706 | } |
| 707 | |
| 708 | static inline unsigned int decode_config3(struct cpuinfo_mips *c) |
| 709 | { |
| 710 | unsigned int config3; |
| 711 | |
| 712 | config3 = read_c0_config3(); |
| 713 | |
| 714 | if (config3 & MIPS_CONF3_SM) |
| 715 | c->ases |= MIPS_ASE_SMARTMIPS; |
Ralf Baechle | e50c0a8 | 2005-05-31 11:49:19 +0000 | [diff] [blame] | 716 | if (config3 & MIPS_CONF3_DSP) |
| 717 | c->ases |= MIPS_ASE_DSP; |
Ralf Baechle | 8f40611 | 2005-07-14 07:34:18 +0000 | [diff] [blame] | 718 | if (config3 & MIPS_CONF3_VINT) |
| 719 | c->options |= MIPS_CPU_VINT; |
| 720 | if (config3 & MIPS_CONF3_VEIC) |
| 721 | c->options |= MIPS_CPU_VEIC; |
| 722 | if (config3 & MIPS_CONF3_MT) |
Ralf Baechle | e0daad4 | 2007-02-05 00:10:11 +0000 | [diff] [blame] | 723 | c->ases |= MIPS_ASE_MIPSMT; |
Ralf Baechle | a369202 | 2007-07-10 17:33:02 +0100 | [diff] [blame] | 724 | if (config3 & MIPS_CONF3_ULRI) |
| 725 | c->options |= MIPS_CPU_ULRI; |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 726 | |
| 727 | return config3 & MIPS_CONF_M; |
| 728 | } |
| 729 | |
David Daney | 1b362e3 | 2010-01-22 14:41:15 -0800 | [diff] [blame] | 730 | static inline unsigned int decode_config4(struct cpuinfo_mips *c) |
| 731 | { |
| 732 | unsigned int config4; |
| 733 | |
| 734 | config4 = read_c0_config4(); |
| 735 | |
| 736 | if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT |
| 737 | && cpu_has_tlb) |
| 738 | c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40; |
| 739 | |
| 740 | return config4 & MIPS_CONF_M; |
| 741 | } |
| 742 | |
Ralf Baechle | 234fcd1 | 2008-03-08 09:56:28 +0000 | [diff] [blame] | 743 | static void __cpuinit decode_configs(struct cpuinfo_mips *c) |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 744 | { |
Ralf Baechle | 558ce12 | 2008-10-29 12:33:34 +0000 | [diff] [blame] | 745 | int ok; |
| 746 | |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 747 | /* MIPS32 or MIPS64 compliant CPU. */ |
Ralf Baechle | 02cf211 | 2005-10-01 13:06:32 +0100 | [diff] [blame] | 748 | c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER | |
| 749 | MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK; |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 750 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 751 | c->scache.flags = MIPS_CACHE_NOT_PRESENT; |
| 752 | |
Ralf Baechle | 558ce12 | 2008-10-29 12:33:34 +0000 | [diff] [blame] | 753 | ok = decode_config0(c); /* Read Config registers. */ |
| 754 | BUG_ON(!ok); /* Arch spec violation! */ |
| 755 | if (ok) |
| 756 | ok = decode_config1(c); |
| 757 | if (ok) |
| 758 | ok = decode_config2(c); |
| 759 | if (ok) |
| 760 | ok = decode_config3(c); |
David Daney | 1b362e3 | 2010-01-22 14:41:15 -0800 | [diff] [blame] | 761 | if (ok) |
| 762 | ok = decode_config4(c); |
Ralf Baechle | 558ce12 | 2008-10-29 12:33:34 +0000 | [diff] [blame] | 763 | |
| 764 | mips_probe_watch_registers(c); |
David Daney | 0c2f455 | 2010-07-26 14:29:37 -0700 | [diff] [blame] | 765 | |
| 766 | if (cpu_has_mips_r2) |
| 767 | c->core = read_c0_ebase() & 0x3ff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 768 | } |
| 769 | |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 770 | static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | { |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 772 | decode_configs(c); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 773 | switch (c->processor_id & 0xff00) { |
| 774 | case PRID_IMP_4KC: |
| 775 | c->cputype = CPU_4KC; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 776 | __cpu_name[cpu] = "MIPS 4Kc"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | break; |
| 778 | case PRID_IMP_4KEC: |
Ralf Baechle | 2b07bd0 | 2005-04-08 20:36:05 +0000 | [diff] [blame] | 779 | case PRID_IMP_4KECR2: |
| 780 | c->cputype = CPU_4KEC; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 781 | __cpu_name[cpu] = "MIPS 4KEc"; |
Ralf Baechle | 2b07bd0 | 2005-04-08 20:36:05 +0000 | [diff] [blame] | 782 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | case PRID_IMP_4KSC: |
Ralf Baechle | 8afcb5d | 2005-10-04 15:01:26 +0100 | [diff] [blame] | 784 | case PRID_IMP_4KSD: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 785 | c->cputype = CPU_4KSC; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 786 | __cpu_name[cpu] = "MIPS 4KSc"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | break; |
| 788 | case PRID_IMP_5KC: |
| 789 | c->cputype = CPU_5KC; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 790 | __cpu_name[cpu] = "MIPS 5Kc"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 791 | break; |
| 792 | case PRID_IMP_20KC: |
| 793 | c->cputype = CPU_20KC; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 794 | __cpu_name[cpu] = "MIPS 20Kc"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 795 | break; |
| 796 | case PRID_IMP_24K: |
Ralf Baechle | e50c0a8 | 2005-05-31 11:49:19 +0000 | [diff] [blame] | 797 | case PRID_IMP_24KE: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 798 | c->cputype = CPU_24K; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 799 | __cpu_name[cpu] = "MIPS 24Kc"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | break; |
| 801 | case PRID_IMP_25KF: |
| 802 | c->cputype = CPU_25KF; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 803 | __cpu_name[cpu] = "MIPS 25Kc"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | break; |
Ralf Baechle | bbc7f22 | 2005-07-12 16:12:05 +0000 | [diff] [blame] | 805 | case PRID_IMP_34K: |
| 806 | c->cputype = CPU_34K; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 807 | __cpu_name[cpu] = "MIPS 34Kc"; |
Ralf Baechle | bbc7f22 | 2005-07-12 16:12:05 +0000 | [diff] [blame] | 808 | break; |
Chris Dearman | c620953 | 2006-05-02 14:08:46 +0100 | [diff] [blame] | 809 | case PRID_IMP_74K: |
| 810 | c->cputype = CPU_74K; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 811 | __cpu_name[cpu] = "MIPS 74Kc"; |
Chris Dearman | c620953 | 2006-05-02 14:08:46 +0100 | [diff] [blame] | 812 | break; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 813 | case PRID_IMP_1004K: |
| 814 | c->cputype = CPU_1004K; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 815 | __cpu_name[cpu] = "MIPS 1004Kc"; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 816 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | } |
Chris Dearman | 0b6d497 | 2007-09-13 12:32:02 +0100 | [diff] [blame] | 818 | |
| 819 | spram_config(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 820 | } |
| 821 | |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 822 | static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 823 | { |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 824 | decode_configs(c); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | switch (c->processor_id & 0xff00) { |
| 826 | case PRID_IMP_AU1_REV1: |
| 827 | case PRID_IMP_AU1_REV2: |
Manuel Lauss | 270717a | 2009-03-25 17:49:28 +0100 | [diff] [blame] | 828 | c->cputype = CPU_ALCHEMY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | switch ((c->processor_id >> 24) & 0xff) { |
| 830 | case 0: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 831 | __cpu_name[cpu] = "Au1000"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | break; |
| 833 | case 1: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 834 | __cpu_name[cpu] = "Au1500"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | break; |
| 836 | case 2: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 837 | __cpu_name[cpu] = "Au1100"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 838 | break; |
| 839 | case 3: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 840 | __cpu_name[cpu] = "Au1550"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 841 | break; |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 842 | case 4: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 843 | __cpu_name[cpu] = "Au1200"; |
Manuel Lauss | 270717a | 2009-03-25 17:49:28 +0100 | [diff] [blame] | 844 | if ((c->processor_id & 0xff) == 2) |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 845 | __cpu_name[cpu] = "Au1250"; |
Manuel Lauss | 237cfee | 2007-12-06 09:07:55 +0100 | [diff] [blame] | 846 | break; |
| 847 | case 5: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 848 | __cpu_name[cpu] = "Au1210"; |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 849 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | default: |
Manuel Lauss | 270717a | 2009-03-25 17:49:28 +0100 | [diff] [blame] | 851 | __cpu_name[cpu] = "Au1xxx"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | break; |
| 853 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 854 | break; |
| 855 | } |
| 856 | } |
| 857 | |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 858 | static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 859 | { |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 860 | decode_configs(c); |
Ralf Baechle | 02cf211 | 2005-10-01 13:06:32 +0100 | [diff] [blame] | 861 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | switch (c->processor_id & 0xff00) { |
| 863 | case PRID_IMP_SB1: |
| 864 | c->cputype = CPU_SB1; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 865 | __cpu_name[cpu] = "SiByte SB1"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 866 | /* FPU in pass1 is known to have issues. */ |
Ralf Baechle | aa32374 | 2006-05-29 00:02:12 +0100 | [diff] [blame] | 867 | if ((c->processor_id & 0xff) < 0x02) |
Ralf Baechle | 010b853 | 2006-01-29 18:42:08 +0000 | [diff] [blame] | 868 | c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | break; |
Andrew Isaacson | 93ce2f52 | 2005-10-19 23:56:20 -0700 | [diff] [blame] | 870 | case PRID_IMP_SB1A: |
| 871 | c->cputype = CPU_SB1A; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 872 | __cpu_name[cpu] = "SiByte SB1A"; |
Andrew Isaacson | 93ce2f52 | 2005-10-19 23:56:20 -0700 | [diff] [blame] | 873 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 874 | } |
| 875 | } |
| 876 | |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 877 | static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | { |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 879 | decode_configs(c); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 880 | switch (c->processor_id & 0xff00) { |
| 881 | case PRID_IMP_SR71000: |
| 882 | c->cputype = CPU_SR71000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 883 | __cpu_name[cpu] = "Sandcraft SR71000"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | c->scache.ways = 8; |
| 885 | c->tlbsize = 64; |
| 886 | break; |
| 887 | } |
| 888 | } |
| 889 | |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 890 | static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu) |
Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 891 | { |
| 892 | decode_configs(c); |
| 893 | switch (c->processor_id & 0xff00) { |
| 894 | case PRID_IMP_PR4450: |
| 895 | c->cputype = CPU_PR4450; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 896 | __cpu_name[cpu] = "Philips PR4450"; |
Ralf Baechle | e7958bb | 2005-12-08 13:00:20 +0000 | [diff] [blame] | 897 | c->isa_level = MIPS_CPU_ISA_M32R1; |
Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 898 | break; |
Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 899 | } |
| 900 | } |
| 901 | |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 902 | static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu) |
Aurelien Jarno | 1c0c13e | 2007-09-25 15:40:12 +0200 | [diff] [blame] | 903 | { |
| 904 | decode_configs(c); |
| 905 | switch (c->processor_id & 0xff00) { |
| 906 | case PRID_IMP_BCM3302: |
Maxime Bizon | 0de663e | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 907 | /* same as PRID_IMP_BCM6338 */ |
Aurelien Jarno | 1c0c13e | 2007-09-25 15:40:12 +0200 | [diff] [blame] | 908 | c->cputype = CPU_BCM3302; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 909 | __cpu_name[cpu] = "Broadcom BCM3302"; |
Aurelien Jarno | 1c0c13e | 2007-09-25 15:40:12 +0200 | [diff] [blame] | 910 | break; |
| 911 | case PRID_IMP_BCM4710: |
| 912 | c->cputype = CPU_BCM4710; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 913 | __cpu_name[cpu] = "Broadcom BCM4710"; |
Aurelien Jarno | 1c0c13e | 2007-09-25 15:40:12 +0200 | [diff] [blame] | 914 | break; |
Maxime Bizon | 0de663e | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 915 | case PRID_IMP_BCM6345: |
| 916 | c->cputype = CPU_BCM6345; |
| 917 | __cpu_name[cpu] = "Broadcom BCM6345"; |
| 918 | break; |
| 919 | case PRID_IMP_BCM6348: |
| 920 | c->cputype = CPU_BCM6348; |
| 921 | __cpu_name[cpu] = "Broadcom BCM6348"; |
| 922 | break; |
| 923 | case PRID_IMP_BCM4350: |
| 924 | switch (c->processor_id & 0xf0) { |
| 925 | case PRID_REV_BCM6358: |
| 926 | c->cputype = CPU_BCM6358; |
| 927 | __cpu_name[cpu] = "Broadcom BCM6358"; |
| 928 | break; |
| 929 | default: |
| 930 | c->cputype = CPU_UNKNOWN; |
| 931 | break; |
| 932 | } |
| 933 | break; |
Aurelien Jarno | 1c0c13e | 2007-09-25 15:40:12 +0200 | [diff] [blame] | 934 | } |
| 935 | } |
| 936 | |
David Daney | 0dd4781 | 2008-12-11 15:33:26 -0800 | [diff] [blame] | 937 | static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu) |
| 938 | { |
| 939 | decode_configs(c); |
| 940 | switch (c->processor_id & 0xff00) { |
| 941 | case PRID_IMP_CAVIUM_CN38XX: |
| 942 | case PRID_IMP_CAVIUM_CN31XX: |
| 943 | case PRID_IMP_CAVIUM_CN30XX: |
David Daney | 6f32946 | 2010-02-10 15:12:48 -0800 | [diff] [blame] | 944 | c->cputype = CPU_CAVIUM_OCTEON; |
| 945 | __cpu_name[cpu] = "Cavium Octeon"; |
| 946 | goto platform; |
David Daney | 0dd4781 | 2008-12-11 15:33:26 -0800 | [diff] [blame] | 947 | case PRID_IMP_CAVIUM_CN58XX: |
| 948 | case PRID_IMP_CAVIUM_CN56XX: |
| 949 | case PRID_IMP_CAVIUM_CN50XX: |
| 950 | case PRID_IMP_CAVIUM_CN52XX: |
David Daney | 6f32946 | 2010-02-10 15:12:48 -0800 | [diff] [blame] | 951 | c->cputype = CPU_CAVIUM_OCTEON_PLUS; |
| 952 | __cpu_name[cpu] = "Cavium Octeon+"; |
| 953 | platform: |
David Daney | 368bf8e | 2010-01-28 16:52:13 -0800 | [diff] [blame] | 954 | if (cpu == 0) |
| 955 | __elf_platform = "octeon"; |
David Daney | 0dd4781 | 2008-12-11 15:33:26 -0800 | [diff] [blame] | 956 | break; |
David Daney | 0e56b38 | 2010-10-07 16:03:45 -0700 | [diff] [blame^] | 957 | case PRID_IMP_CAVIUM_CN63XX: |
| 958 | c->cputype = CPU_CAVIUM_OCTEON2; |
| 959 | __cpu_name[cpu] = "Cavium Octeon II"; |
| 960 | if (cpu == 0) |
| 961 | __elf_platform = "octeon2"; |
| 962 | break; |
David Daney | 0dd4781 | 2008-12-11 15:33:26 -0800 | [diff] [blame] | 963 | default: |
| 964 | printk(KERN_INFO "Unknown Octeon chip!\n"); |
| 965 | c->cputype = CPU_UNKNOWN; |
| 966 | break; |
| 967 | } |
| 968 | } |
| 969 | |
Lars-Peter Clausen | 83ccf69 | 2010-07-17 11:07:51 +0000 | [diff] [blame] | 970 | static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu) |
| 971 | { |
| 972 | decode_configs(c); |
| 973 | /* JZRISC does not implement the CP0 counter. */ |
| 974 | c->options &= ~MIPS_CPU_COUNTER; |
| 975 | switch (c->processor_id & 0xff00) { |
| 976 | case PRID_IMP_JZRISC: |
| 977 | c->cputype = CPU_JZRISC; |
| 978 | __cpu_name[cpu] = "Ingenic JZRISC"; |
| 979 | break; |
| 980 | default: |
| 981 | panic("Unknown Ingenic Processor ID!"); |
| 982 | break; |
| 983 | } |
| 984 | } |
| 985 | |
Ralf Baechle | 9966db25 | 2007-10-11 23:46:17 +0100 | [diff] [blame] | 986 | const char *__cpu_name[NR_CPUS]; |
David Daney | 874fd3b | 2010-01-28 16:52:12 -0800 | [diff] [blame] | 987 | const char *__elf_platform; |
Ralf Baechle | 9966db25 | 2007-10-11 23:46:17 +0100 | [diff] [blame] | 988 | |
Ralf Baechle | 234fcd1 | 2008-03-08 09:56:28 +0000 | [diff] [blame] | 989 | __cpuinit void cpu_probe(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | { |
| 991 | struct cpuinfo_mips *c = ¤t_cpu_data; |
Ralf Baechle | 9966db25 | 2007-10-11 23:46:17 +0100 | [diff] [blame] | 992 | unsigned int cpu = smp_processor_id(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | |
| 994 | c->processor_id = PRID_IMP_UNKNOWN; |
| 995 | c->fpu_id = FPIR_IMP_NONE; |
| 996 | c->cputype = CPU_UNKNOWN; |
| 997 | |
| 998 | c->processor_id = read_c0_prid(); |
| 999 | switch (c->processor_id & 0xff0000) { |
| 1000 | case PRID_COMP_LEGACY: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1001 | cpu_probe_legacy(c, cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1002 | break; |
| 1003 | case PRID_COMP_MIPS: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1004 | cpu_probe_mips(c, cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | break; |
| 1006 | case PRID_COMP_ALCHEMY: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1007 | cpu_probe_alchemy(c, cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1008 | break; |
| 1009 | case PRID_COMP_SIBYTE: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1010 | cpu_probe_sibyte(c, cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | break; |
Aurelien Jarno | 1c0c13e | 2007-09-25 15:40:12 +0200 | [diff] [blame] | 1012 | case PRID_COMP_BROADCOM: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1013 | cpu_probe_broadcom(c, cpu); |
Aurelien Jarno | 1c0c13e | 2007-09-25 15:40:12 +0200 | [diff] [blame] | 1014 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 | case PRID_COMP_SANDCRAFT: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1016 | cpu_probe_sandcraft(c, cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1017 | break; |
Daniel Laird | a92b058 | 2008-03-06 09:07:18 +0000 | [diff] [blame] | 1018 | case PRID_COMP_NXP: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1019 | cpu_probe_nxp(c, cpu); |
Ralf Baechle | a3dddd5 | 2006-03-11 08:18:41 +0000 | [diff] [blame] | 1020 | break; |
David Daney | 0dd4781 | 2008-12-11 15:33:26 -0800 | [diff] [blame] | 1021 | case PRID_COMP_CAVIUM: |
| 1022 | cpu_probe_cavium(c, cpu); |
| 1023 | break; |
Lars-Peter Clausen | 83ccf69 | 2010-07-17 11:07:51 +0000 | [diff] [blame] | 1024 | case PRID_COMP_INGENIC: |
| 1025 | cpu_probe_ingenic(c, cpu); |
| 1026 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | } |
Franck Bui-Huu | dec8b1c | 2007-10-08 16:11:51 +0200 | [diff] [blame] | 1028 | |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1029 | BUG_ON(!__cpu_name[cpu]); |
| 1030 | BUG_ON(c->cputype == CPU_UNKNOWN); |
| 1031 | |
Franck Bui-Huu | dec8b1c | 2007-10-08 16:11:51 +0200 | [diff] [blame] | 1032 | /* |
| 1033 | * Platform code can force the cpu type to optimize code |
| 1034 | * generation. In that case be sure the cpu type is correctly |
| 1035 | * manually setup otherwise it could trigger some nasty bugs. |
| 1036 | */ |
| 1037 | BUG_ON(current_cpu_type() != c->cputype); |
| 1038 | |
Kevin Cernekee | 0103d23 | 2010-05-02 14:43:52 -0700 | [diff] [blame] | 1039 | if (mips_fpu_disabled) |
| 1040 | c->options &= ~MIPS_CPU_FPU; |
| 1041 | |
| 1042 | if (mips_dsp_disabled) |
| 1043 | c->ases &= ~MIPS_ASE_DSP; |
| 1044 | |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 1045 | if (c->options & MIPS_CPU_FPU) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1046 | c->fpu_id = cpu_get_fpu_id(); |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 1047 | |
Ralf Baechle | e7958bb | 2005-12-08 13:00:20 +0000 | [diff] [blame] | 1048 | if (c->isa_level == MIPS_CPU_ISA_M32R1 || |
Ralf Baechle | b4672d3 | 2005-12-08 14:04:24 +0000 | [diff] [blame] | 1049 | c->isa_level == MIPS_CPU_ISA_M32R2 || |
| 1050 | c->isa_level == MIPS_CPU_ISA_M64R1 || |
| 1051 | c->isa_level == MIPS_CPU_ISA_M64R2) { |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 1052 | if (c->fpu_id & MIPS_FPIR_3D) |
| 1053 | c->ases |= MIPS_ASE_MIPS3D; |
| 1054 | } |
| 1055 | } |
Ralf Baechle | 9966db25 | 2007-10-11 23:46:17 +0100 | [diff] [blame] | 1056 | |
Ralf Baechle | f6771db | 2007-11-08 18:02:29 +0000 | [diff] [blame] | 1057 | if (cpu_has_mips_r2) |
| 1058 | c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1; |
| 1059 | else |
| 1060 | c->srsets = 1; |
Guenter Roeck | 91dfc42 | 2010-02-02 08:52:20 -0800 | [diff] [blame] | 1061 | |
| 1062 | cpu_probe_vmbits(c); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | } |
| 1064 | |
Ralf Baechle | 234fcd1 | 2008-03-08 09:56:28 +0000 | [diff] [blame] | 1065 | __cpuinit void cpu_report(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | { |
| 1067 | struct cpuinfo_mips *c = ¤t_cpu_data; |
| 1068 | |
Ralf Baechle | 9966db25 | 2007-10-11 23:46:17 +0100 | [diff] [blame] | 1069 | printk(KERN_INFO "CPU revision is: %08x (%s)\n", |
| 1070 | c->processor_id, cpu_name_string()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1071 | if (c->options & MIPS_CPU_FPU) |
Ralf Baechle | 9966db25 | 2007-10-11 23:46:17 +0100 | [diff] [blame] | 1072 | printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | } |