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