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 | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 7 | * Copyright (C) 2001, 2004, 2011, 2012 MIPS Technologies, 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> |
Paul Gortmaker | 73bc256 | 2011-07-23 16:30:40 -0400 | [diff] [blame] | 19 | #include <linux/export.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> |
Maciej W. Rozycki | f684362 | 2015-04-03 23:27:26 +0100 | [diff] [blame] | 23 | #include <asm/cpu-features.h> |
Ralf Baechle | 69f24d1 | 2013-09-17 10:25:47 +0200 | [diff] [blame] | 24 | #include <asm/cpu-type.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <asm/fpu.h> |
| 26 | #include <asm/mipsregs.h> |
Paul Burton | 30ee615 | 2014-03-27 10:57:30 +0000 | [diff] [blame] | 27 | #include <asm/mipsmtregs.h> |
Paul Burton | a5e9a69 | 2014-01-27 15:23:10 +0000 | [diff] [blame] | 28 | #include <asm/msa.h> |
David Daney | 654f57b | 2008-09-23 00:07:16 -0700 | [diff] [blame] | 29 | #include <asm/watch.h> |
Paul Gortmaker | 06372a6 | 2011-07-23 16:26:41 -0400 | [diff] [blame] | 30 | #include <asm/elf.h> |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 31 | #include <asm/pgtable-bits.h> |
Chris Dearman | a074f0e | 2009-07-10 01:51:27 -0700 | [diff] [blame] | 32 | #include <asm/spram.h> |
David Daney | 949e51b | 2010-10-14 11:32:33 -0700 | [diff] [blame] | 33 | #include <asm/uaccess.h> |
| 34 | |
Maciej W. Rozycki | f684362 | 2015-04-03 23:27:26 +0100 | [diff] [blame] | 35 | /* |
Maciej W. Rozycki | 7aecd5c | 2015-04-03 23:27:54 +0100 | [diff] [blame] | 36 | * Get the FPU Implementation/Revision. |
| 37 | */ |
| 38 | static inline unsigned long cpu_get_fpu_id(void) |
| 39 | { |
| 40 | unsigned long tmp, fpu_id; |
| 41 | |
| 42 | tmp = read_c0_status(); |
| 43 | __enable_fpu(FPU_AS_IS); |
| 44 | fpu_id = read_32bit_cp1_register(CP1_REVISION); |
| 45 | write_c0_status(tmp); |
| 46 | return fpu_id; |
| 47 | } |
| 48 | |
| 49 | /* |
| 50 | * Check if the CPU has an external FPU. |
| 51 | */ |
| 52 | static inline int __cpu_has_fpu(void) |
| 53 | { |
| 54 | return (cpu_get_fpu_id() & FPIR_IMP_MASK) != FPIR_IMP_NONE; |
| 55 | } |
| 56 | |
| 57 | static inline unsigned long cpu_get_msa_id(void) |
| 58 | { |
| 59 | unsigned long status, msa_id; |
| 60 | |
| 61 | status = read_c0_status(); |
| 62 | __enable_fpu(FPU_64BIT); |
| 63 | enable_msa(); |
| 64 | msa_id = read_msa_ir(); |
| 65 | disable_msa(); |
| 66 | write_c0_status(status); |
| 67 | return msa_id; |
| 68 | } |
| 69 | |
| 70 | /* |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 71 | * Determine the FCSR mask for FPU hardware. |
| 72 | */ |
| 73 | static inline void cpu_set_fpu_fcsr_mask(struct cpuinfo_mips *c) |
| 74 | { |
| 75 | unsigned long sr, mask, fcsr, fcsr0, fcsr1; |
| 76 | |
Maciej W. Rozycki | 90b712d | 2015-06-02 17:50:59 +0100 | [diff] [blame] | 77 | fcsr = c->fpu_csr31; |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 78 | mask = FPU_CSR_ALL_X | FPU_CSR_ALL_E | FPU_CSR_ALL_S | FPU_CSR_RM; |
| 79 | |
| 80 | sr = read_c0_status(); |
| 81 | __enable_fpu(FPU_AS_IS); |
| 82 | |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 83 | fcsr0 = fcsr & mask; |
| 84 | write_32bit_cp1_register(CP1_STATUS, fcsr0); |
| 85 | fcsr0 = read_32bit_cp1_register(CP1_STATUS); |
| 86 | |
| 87 | fcsr1 = fcsr | ~mask; |
| 88 | write_32bit_cp1_register(CP1_STATUS, fcsr1); |
| 89 | fcsr1 = read_32bit_cp1_register(CP1_STATUS); |
| 90 | |
| 91 | write_32bit_cp1_register(CP1_STATUS, fcsr); |
| 92 | |
| 93 | write_c0_status(sr); |
| 94 | |
| 95 | c->fpu_msk31 = ~(fcsr0 ^ fcsr1) & ~mask; |
| 96 | } |
| 97 | |
| 98 | /* |
Maciej W. Rozycki | f684362 | 2015-04-03 23:27:26 +0100 | [diff] [blame] | 99 | * Set the FIR feature flags for the FPU emulator. |
| 100 | */ |
| 101 | static void cpu_set_nofpu_id(struct cpuinfo_mips *c) |
| 102 | { |
| 103 | u32 value; |
| 104 | |
| 105 | value = 0; |
| 106 | if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 | |
| 107 | MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 | |
| 108 | MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6)) |
| 109 | value |= MIPS_FPIR_D | MIPS_FPIR_S; |
| 110 | if (c->isa_level & (MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 | |
| 111 | MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6)) |
| 112 | value |= MIPS_FPIR_F64 | MIPS_FPIR_L | MIPS_FPIR_W; |
| 113 | c->fpu_id = value; |
| 114 | } |
| 115 | |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 116 | /* Determined FPU emulator mask to use for the boot CPU with "nofpu". */ |
| 117 | static unsigned int mips_nofpu_msk31; |
| 118 | |
Maciej W. Rozycki | 7aecd5c | 2015-04-03 23:27:54 +0100 | [diff] [blame] | 119 | /* |
| 120 | * Set options for FPU hardware. |
| 121 | */ |
| 122 | static void cpu_set_fpu_opts(struct cpuinfo_mips *c) |
| 123 | { |
| 124 | c->fpu_id = cpu_get_fpu_id(); |
| 125 | mips_nofpu_msk31 = c->fpu_msk31; |
| 126 | |
| 127 | if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 | |
| 128 | MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 | |
| 129 | MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6)) { |
| 130 | if (c->fpu_id & MIPS_FPIR_3D) |
| 131 | c->ases |= MIPS_ASE_MIPS3D; |
| 132 | if (c->fpu_id & MIPS_FPIR_FREP) |
| 133 | c->options |= MIPS_CPU_FRE; |
| 134 | } |
| 135 | |
| 136 | cpu_set_fpu_fcsr_mask(c); |
| 137 | } |
| 138 | |
| 139 | /* |
| 140 | * Set options for the FPU emulator. |
| 141 | */ |
| 142 | static void cpu_set_nofpu_opts(struct cpuinfo_mips *c) |
| 143 | { |
| 144 | c->options &= ~MIPS_CPU_FPU; |
| 145 | c->fpu_msk31 = mips_nofpu_msk31; |
| 146 | |
| 147 | cpu_set_nofpu_id(c); |
| 148 | } |
| 149 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 150 | static int mips_fpu_disabled; |
Kevin Cernekee | 0103d23 | 2010-05-02 14:43:52 -0700 | [diff] [blame] | 151 | |
| 152 | static int __init fpu_disable(char *s) |
| 153 | { |
Maciej W. Rozycki | 7aecd5c | 2015-04-03 23:27:54 +0100 | [diff] [blame] | 154 | cpu_set_nofpu_opts(&boot_cpu_data); |
Kevin Cernekee | 0103d23 | 2010-05-02 14:43:52 -0700 | [diff] [blame] | 155 | mips_fpu_disabled = 1; |
| 156 | |
| 157 | return 1; |
| 158 | } |
| 159 | |
| 160 | __setup("nofpu", fpu_disable); |
| 161 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 162 | int mips_dsp_disabled; |
Kevin Cernekee | 0103d23 | 2010-05-02 14:43:52 -0700 | [diff] [blame] | 163 | |
| 164 | static int __init dsp_disable(char *s) |
| 165 | { |
Steven J. Hill | ee80f7c7 | 2012-08-03 10:26:04 -0500 | [diff] [blame] | 166 | cpu_data[0].ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P); |
Kevin Cernekee | 0103d23 | 2010-05-02 14:43:52 -0700 | [diff] [blame] | 167 | mips_dsp_disabled = 1; |
| 168 | |
| 169 | return 1; |
| 170 | } |
| 171 | |
| 172 | __setup("nodsp", dsp_disable); |
| 173 | |
Markos Chandras | 3d528b3 | 2014-07-14 12:46:13 +0100 | [diff] [blame] | 174 | static int mips_htw_disabled; |
| 175 | |
| 176 | static int __init htw_disable(char *s) |
| 177 | { |
| 178 | mips_htw_disabled = 1; |
| 179 | cpu_data[0].options &= ~MIPS_CPU_HTW; |
| 180 | write_c0_pwctl(read_c0_pwctl() & |
| 181 | ~(1 << MIPS_PWCTL_PWEN_SHIFT)); |
| 182 | |
| 183 | return 1; |
| 184 | } |
| 185 | |
| 186 | __setup("nohtw", htw_disable); |
| 187 | |
Markos Chandras | 97f4ad2 | 2014-08-29 09:37:26 +0100 | [diff] [blame] | 188 | static int mips_ftlb_disabled; |
| 189 | static int mips_has_ftlb_configured; |
| 190 | |
| 191 | static void set_ftlb_enable(struct cpuinfo_mips *c, int enable); |
| 192 | |
| 193 | static int __init ftlb_disable(char *s) |
| 194 | { |
| 195 | unsigned int config4, mmuextdef; |
| 196 | |
| 197 | /* |
| 198 | * If the core hasn't done any FTLB configuration, there is nothing |
| 199 | * for us to do here. |
| 200 | */ |
| 201 | if (!mips_has_ftlb_configured) |
| 202 | return 1; |
| 203 | |
| 204 | /* Disable it in the boot cpu */ |
| 205 | set_ftlb_enable(&cpu_data[0], 0); |
| 206 | |
| 207 | back_to_back_c0_hazard(); |
| 208 | |
| 209 | config4 = read_c0_config4(); |
| 210 | |
| 211 | /* Check that FTLB has been disabled */ |
| 212 | mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF; |
| 213 | /* MMUSIZEEXT == VTLB ON, FTLB OFF */ |
| 214 | if (mmuextdef == MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT) { |
| 215 | /* This should never happen */ |
| 216 | pr_warn("FTLB could not be disabled!\n"); |
| 217 | return 1; |
| 218 | } |
| 219 | |
| 220 | mips_ftlb_disabled = 1; |
| 221 | mips_has_ftlb_configured = 0; |
| 222 | |
| 223 | /* |
| 224 | * noftlb is mainly used for debug purposes so print |
| 225 | * an informative message instead of using pr_debug() |
| 226 | */ |
| 227 | pr_info("FTLB has been disabled\n"); |
| 228 | |
| 229 | /* |
| 230 | * Some of these bits are duplicated in the decode_config4. |
| 231 | * MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT is the only possible case |
| 232 | * once FTLB has been disabled so undo what decode_config4 did. |
| 233 | */ |
| 234 | cpu_data[0].tlbsize -= cpu_data[0].tlbsizeftlbways * |
| 235 | cpu_data[0].tlbsizeftlbsets; |
| 236 | cpu_data[0].tlbsizeftlbsets = 0; |
| 237 | cpu_data[0].tlbsizeftlbways = 0; |
| 238 | |
| 239 | return 1; |
| 240 | } |
| 241 | |
| 242 | __setup("noftlb", ftlb_disable); |
| 243 | |
| 244 | |
Marc St-Jean | 9267a30 | 2007-06-14 15:55:31 -0600 | [diff] [blame] | 245 | static inline void check_errata(void) |
| 246 | { |
| 247 | struct cpuinfo_mips *c = ¤t_cpu_data; |
| 248 | |
Ralf Baechle | 69f24d1 | 2013-09-17 10:25:47 +0200 | [diff] [blame] | 249 | switch (current_cpu_type()) { |
Marc St-Jean | 9267a30 | 2007-06-14 15:55:31 -0600 | [diff] [blame] | 250 | case CPU_34K: |
| 251 | /* |
| 252 | * Erratum "RPS May Cause Incorrect Instruction Execution" |
Ralf Baechle | b633648c5 | 2014-05-23 16:29:44 +0200 | [diff] [blame] | 253 | * This code only handles VPE0, any SMP/RTOS code |
Marc St-Jean | 9267a30 | 2007-06-14 15:55:31 -0600 | [diff] [blame] | 254 | * making use of VPE1 will be responsable for that VPE. |
| 255 | */ |
| 256 | if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2) |
| 257 | write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS); |
| 258 | break; |
| 259 | default: |
| 260 | break; |
| 261 | } |
| 262 | } |
| 263 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | void __init check_bugs32(void) |
| 265 | { |
Marc St-Jean | 9267a30 | 2007-06-14 15:55:31 -0600 | [diff] [blame] | 266 | check_errata(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | /* |
| 270 | * Probe whether cpu has config register by trying to play with |
| 271 | * alternate cache bit and see whether it matters. |
| 272 | * It's used by cpu_probe to distinguish between R3000A and R3081. |
| 273 | */ |
| 274 | static inline int cpu_has_confreg(void) |
| 275 | { |
| 276 | #ifdef CONFIG_CPU_R3000 |
| 277 | extern unsigned long r3k_cache_size(unsigned long); |
| 278 | unsigned long size1, size2; |
| 279 | unsigned long cfg = read_c0_conf(); |
| 280 | |
| 281 | size1 = r3k_cache_size(ST0_ISC); |
| 282 | write_c0_conf(cfg ^ R30XX_CONF_AC); |
| 283 | size2 = r3k_cache_size(ST0_ISC); |
| 284 | write_c0_conf(cfg); |
| 285 | return size1 != size2; |
| 286 | #else |
| 287 | return 0; |
| 288 | #endif |
| 289 | } |
| 290 | |
Robert Millan | c094c99 | 2011-04-18 11:37:55 -0700 | [diff] [blame] | 291 | static inline void set_elf_platform(int cpu, const char *plat) |
| 292 | { |
| 293 | if (cpu == 0) |
| 294 | __elf_platform = plat; |
| 295 | } |
| 296 | |
Guenter Roeck | 91dfc42 | 2010-02-02 08:52:20 -0800 | [diff] [blame] | 297 | static inline void cpu_probe_vmbits(struct cpuinfo_mips *c) |
| 298 | { |
| 299 | #ifdef __NEED_VMBITS_PROBE |
David Daney | 5b7efa8 | 2010-02-08 12:27:00 -0800 | [diff] [blame] | 300 | write_c0_entryhi(0x3fffffffffffe000ULL); |
Guenter Roeck | 91dfc42 | 2010-02-02 08:52:20 -0800 | [diff] [blame] | 301 | back_to_back_c0_hazard(); |
David Daney | 5b7efa8 | 2010-02-08 12:27:00 -0800 | [diff] [blame] | 302 | c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL); |
Guenter Roeck | 91dfc42 | 2010-02-02 08:52:20 -0800 | [diff] [blame] | 303 | #endif |
| 304 | } |
| 305 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 306 | static void set_isa(struct cpuinfo_mips *c, unsigned int isa) |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 307 | { |
| 308 | switch (isa) { |
| 309 | case MIPS_CPU_ISA_M64R2: |
| 310 | c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2; |
| 311 | case MIPS_CPU_ISA_M64R1: |
| 312 | c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1; |
| 313 | case MIPS_CPU_ISA_V: |
| 314 | c->isa_level |= MIPS_CPU_ISA_V; |
| 315 | case MIPS_CPU_ISA_IV: |
| 316 | c->isa_level |= MIPS_CPU_ISA_IV; |
| 317 | case MIPS_CPU_ISA_III: |
Ralf Baechle | 1990e54 | 2013-06-26 17:06:34 +0200 | [diff] [blame] | 318 | c->isa_level |= MIPS_CPU_ISA_II | MIPS_CPU_ISA_III; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 319 | break; |
| 320 | |
Leonid Yegoshin | 8b8aa63 | 2014-11-13 13:51:51 +0000 | [diff] [blame] | 321 | /* R6 incompatible with everything else */ |
| 322 | case MIPS_CPU_ISA_M64R6: |
| 323 | c->isa_level |= MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6; |
| 324 | case MIPS_CPU_ISA_M32R6: |
| 325 | c->isa_level |= MIPS_CPU_ISA_M32R6; |
| 326 | /* Break here so we don't add incompatible ISAs */ |
| 327 | break; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 328 | case MIPS_CPU_ISA_M32R2: |
| 329 | c->isa_level |= MIPS_CPU_ISA_M32R2; |
| 330 | case MIPS_CPU_ISA_M32R1: |
| 331 | c->isa_level |= MIPS_CPU_ISA_M32R1; |
| 332 | case MIPS_CPU_ISA_II: |
| 333 | c->isa_level |= MIPS_CPU_ISA_II; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 334 | break; |
| 335 | } |
| 336 | } |
| 337 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 338 | static char unknown_isa[] = KERN_ERR \ |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 339 | "Unsupported ISA type, c0.config0: %d."; |
| 340 | |
Markos Chandras | cf0a8aa | 2014-11-10 12:25:34 +0000 | [diff] [blame] | 341 | static unsigned int calculate_ftlb_probability(struct cpuinfo_mips *c) |
| 342 | { |
| 343 | |
| 344 | unsigned int probability = c->tlbsize / c->tlbsizevtlb; |
| 345 | |
| 346 | /* |
| 347 | * 0 = All TLBWR instructions go to FTLB |
| 348 | * 1 = 15:1: For every 16 TBLWR instructions, 15 go to the |
| 349 | * FTLB and 1 goes to the VTLB. |
| 350 | * 2 = 7:1: As above with 7:1 ratio. |
| 351 | * 3 = 3:1: As above with 3:1 ratio. |
| 352 | * |
| 353 | * Use the linear midpoint as the probability threshold. |
| 354 | */ |
| 355 | if (probability >= 12) |
| 356 | return 1; |
| 357 | else if (probability >= 6) |
| 358 | return 2; |
| 359 | else |
| 360 | /* |
| 361 | * So FTLB is less than 4 times bigger than VTLB. |
| 362 | * A 3:1 ratio can still be useful though. |
| 363 | */ |
| 364 | return 3; |
| 365 | } |
| 366 | |
Leonid Yegoshin | 75b5b5e | 2013-11-14 16:12:31 +0000 | [diff] [blame] | 367 | static void set_ftlb_enable(struct cpuinfo_mips *c, int enable) |
| 368 | { |
| 369 | unsigned int config6; |
James Hogan | d83b0e8 | 2014-01-22 16:19:40 +0000 | [diff] [blame] | 370 | |
| 371 | /* It's implementation dependent how the FTLB can be enabled */ |
| 372 | switch (c->cputype) { |
| 373 | case CPU_PROAPTIV: |
| 374 | case CPU_P5600: |
| 375 | /* proAptiv & related cores use Config6 to enable the FTLB */ |
Leonid Yegoshin | 75b5b5e | 2013-11-14 16:12:31 +0000 | [diff] [blame] | 376 | config6 = read_c0_config6(); |
Markos Chandras | cf0a8aa | 2014-11-10 12:25:34 +0000 | [diff] [blame] | 377 | /* Clear the old probability value */ |
| 378 | config6 &= ~(3 << MIPS_CONF6_FTLBP_SHIFT); |
Leonid Yegoshin | 75b5b5e | 2013-11-14 16:12:31 +0000 | [diff] [blame] | 379 | if (enable) |
| 380 | /* Enable FTLB */ |
Markos Chandras | cf0a8aa | 2014-11-10 12:25:34 +0000 | [diff] [blame] | 381 | write_c0_config6(config6 | |
| 382 | (calculate_ftlb_probability(c) |
| 383 | << MIPS_CONF6_FTLBP_SHIFT) |
| 384 | | MIPS_CONF6_FTLBEN); |
Leonid Yegoshin | 75b5b5e | 2013-11-14 16:12:31 +0000 | [diff] [blame] | 385 | else |
| 386 | /* Disable FTLB */ |
| 387 | write_c0_config6(config6 & ~MIPS_CONF6_FTLBEN); |
| 388 | back_to_back_c0_hazard(); |
James Hogan | d83b0e8 | 2014-01-22 16:19:40 +0000 | [diff] [blame] | 389 | break; |
Leonid Yegoshin | 75b5b5e | 2013-11-14 16:12:31 +0000 | [diff] [blame] | 390 | } |
| 391 | } |
| 392 | |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 393 | static inline unsigned int decode_config0(struct cpuinfo_mips *c) |
| 394 | { |
| 395 | unsigned int config0; |
| 396 | int isa; |
| 397 | |
| 398 | config0 = read_c0_config(); |
| 399 | |
Leonid Yegoshin | 75b5b5e | 2013-11-14 16:12:31 +0000 | [diff] [blame] | 400 | /* |
| 401 | * Look for Standard TLB or Dual VTLB and FTLB |
| 402 | */ |
| 403 | if ((((config0 & MIPS_CONF_MT) >> 7) == 1) || |
| 404 | (((config0 & MIPS_CONF_MT) >> 7) == 4)) |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 405 | c->options |= MIPS_CPU_TLB; |
Leonid Yegoshin | 75b5b5e | 2013-11-14 16:12:31 +0000 | [diff] [blame] | 406 | |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 407 | isa = (config0 & MIPS_CONF_AT) >> 13; |
| 408 | switch (isa) { |
| 409 | case 0: |
| 410 | switch ((config0 & MIPS_CONF_AR) >> 10) { |
| 411 | case 0: |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 412 | set_isa(c, MIPS_CPU_ISA_M32R1); |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 413 | break; |
| 414 | case 1: |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 415 | set_isa(c, MIPS_CPU_ISA_M32R2); |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 416 | break; |
Leonid Yegoshin | 8b8aa63 | 2014-11-13 13:51:51 +0000 | [diff] [blame] | 417 | case 2: |
| 418 | set_isa(c, MIPS_CPU_ISA_M32R6); |
| 419 | break; |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 420 | default: |
| 421 | goto unknown; |
| 422 | } |
| 423 | break; |
| 424 | case 2: |
| 425 | switch ((config0 & MIPS_CONF_AR) >> 10) { |
| 426 | case 0: |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 427 | set_isa(c, MIPS_CPU_ISA_M64R1); |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 428 | break; |
| 429 | case 1: |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 430 | set_isa(c, MIPS_CPU_ISA_M64R2); |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 431 | break; |
Leonid Yegoshin | 8b8aa63 | 2014-11-13 13:51:51 +0000 | [diff] [blame] | 432 | case 2: |
| 433 | set_isa(c, MIPS_CPU_ISA_M64R6); |
| 434 | break; |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 435 | default: |
| 436 | goto unknown; |
| 437 | } |
| 438 | break; |
| 439 | default: |
| 440 | goto unknown; |
| 441 | } |
| 442 | |
| 443 | return config0 & MIPS_CONF_M; |
| 444 | |
| 445 | unknown: |
| 446 | panic(unknown_isa, config0); |
| 447 | } |
| 448 | |
| 449 | static inline unsigned int decode_config1(struct cpuinfo_mips *c) |
| 450 | { |
| 451 | unsigned int config1; |
| 452 | |
| 453 | config1 = read_c0_config1(); |
| 454 | |
| 455 | if (config1 & MIPS_CONF1_MD) |
| 456 | c->ases |= MIPS_ASE_MDMX; |
| 457 | if (config1 & MIPS_CONF1_WR) |
| 458 | c->options |= MIPS_CPU_WATCH; |
| 459 | if (config1 & MIPS_CONF1_CA) |
| 460 | c->ases |= MIPS_ASE_MIPS16; |
| 461 | if (config1 & MIPS_CONF1_EP) |
| 462 | c->options |= MIPS_CPU_EJTAG; |
| 463 | if (config1 & MIPS_CONF1_FP) { |
| 464 | c->options |= MIPS_CPU_FPU; |
| 465 | c->options |= MIPS_CPU_32FPR; |
| 466 | } |
Leonid Yegoshin | 75b5b5e | 2013-11-14 16:12:31 +0000 | [diff] [blame] | 467 | if (cpu_has_tlb) { |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 468 | c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1; |
Leonid Yegoshin | 75b5b5e | 2013-11-14 16:12:31 +0000 | [diff] [blame] | 469 | c->tlbsizevtlb = c->tlbsize; |
| 470 | c->tlbsizeftlbsets = 0; |
| 471 | } |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 472 | |
| 473 | return config1 & MIPS_CONF_M; |
| 474 | } |
| 475 | |
| 476 | static inline unsigned int decode_config2(struct cpuinfo_mips *c) |
| 477 | { |
| 478 | unsigned int config2; |
| 479 | |
| 480 | config2 = read_c0_config2(); |
| 481 | |
| 482 | if (config2 & MIPS_CONF2_SL) |
| 483 | c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT; |
| 484 | |
| 485 | return config2 & MIPS_CONF_M; |
| 486 | } |
| 487 | |
| 488 | static inline unsigned int decode_config3(struct cpuinfo_mips *c) |
| 489 | { |
| 490 | unsigned int config3; |
| 491 | |
| 492 | config3 = read_c0_config3(); |
| 493 | |
Steven J. Hill | b2ab4f0 | 2012-09-13 16:47:58 -0500 | [diff] [blame] | 494 | if (config3 & MIPS_CONF3_SM) { |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 495 | c->ases |= MIPS_ASE_SMARTMIPS; |
Steven J. Hill | b2ab4f0 | 2012-09-13 16:47:58 -0500 | [diff] [blame] | 496 | c->options |= MIPS_CPU_RIXI; |
| 497 | } |
| 498 | if (config3 & MIPS_CONF3_RXI) |
| 499 | c->options |= MIPS_CPU_RIXI; |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 500 | if (config3 & MIPS_CONF3_DSP) |
| 501 | c->ases |= MIPS_ASE_DSP; |
Steven J. Hill | ee80f7c7 | 2012-08-03 10:26:04 -0500 | [diff] [blame] | 502 | if (config3 & MIPS_CONF3_DSP2P) |
| 503 | c->ases |= MIPS_ASE_DSP2P; |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 504 | if (config3 & MIPS_CONF3_VINT) |
| 505 | c->options |= MIPS_CPU_VINT; |
| 506 | if (config3 & MIPS_CONF3_VEIC) |
| 507 | c->options |= MIPS_CPU_VEIC; |
| 508 | if (config3 & MIPS_CONF3_MT) |
| 509 | c->ases |= MIPS_ASE_MIPSMT; |
| 510 | if (config3 & MIPS_CONF3_ULRI) |
| 511 | c->options |= MIPS_CPU_ULRI; |
Steven J. Hill | f8fa481 | 2012-12-07 03:51:35 +0000 | [diff] [blame] | 512 | if (config3 & MIPS_CONF3_ISA) |
| 513 | c->options |= MIPS_CPU_MICROMIPS; |
David Daney | 1e7decd | 2013-02-16 23:42:43 +0100 | [diff] [blame] | 514 | if (config3 & MIPS_CONF3_VZ) |
| 515 | c->ases |= MIPS_ASE_VZ; |
Steven J. Hill | 4a0156f | 2013-11-14 16:12:24 +0000 | [diff] [blame] | 516 | if (config3 & MIPS_CONF3_SC) |
| 517 | c->options |= MIPS_CPU_SEGMENTS; |
Paul Burton | a5e9a69 | 2014-01-27 15:23:10 +0000 | [diff] [blame] | 518 | if (config3 & MIPS_CONF3_MSA) |
| 519 | c->ases |= MIPS_ASE_MSA; |
Markos Chandras | 3d528b3 | 2014-07-14 12:46:13 +0100 | [diff] [blame] | 520 | /* Only tested on 32-bit cores */ |
Markos Chandras | ed4cbc8 | 2015-01-26 13:04:33 +0000 | [diff] [blame] | 521 | if ((config3 & MIPS_CONF3_PW) && config_enabled(CONFIG_32BIT)) { |
| 522 | c->htw_seq = 0; |
Markos Chandras | 3d528b3 | 2014-07-14 12:46:13 +0100 | [diff] [blame] | 523 | c->options |= MIPS_CPU_HTW; |
Markos Chandras | ed4cbc8 | 2015-01-26 13:04:33 +0000 | [diff] [blame] | 524 | } |
James Hogan | 9b3274b | 2015-02-02 11:45:08 +0000 | [diff] [blame] | 525 | if (config3 & MIPS_CONF3_CDMM) |
| 526 | c->options |= MIPS_CPU_CDMM; |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 527 | |
| 528 | return config3 & MIPS_CONF_M; |
| 529 | } |
| 530 | |
| 531 | static inline unsigned int decode_config4(struct cpuinfo_mips *c) |
| 532 | { |
| 533 | unsigned int config4; |
Leonid Yegoshin | 75b5b5e | 2013-11-14 16:12:31 +0000 | [diff] [blame] | 534 | unsigned int newcf4; |
| 535 | unsigned int mmuextdef; |
| 536 | unsigned int ftlb_page = MIPS_CONF4_FTLBPAGESIZE; |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 537 | |
| 538 | config4 = read_c0_config4(); |
| 539 | |
Leonid Yegoshin | 1745c1e | 2013-11-14 16:12:23 +0000 | [diff] [blame] | 540 | if (cpu_has_tlb) { |
| 541 | if (((config4 & MIPS_CONF4_IE) >> 29) == 2) |
| 542 | c->options |= MIPS_CPU_TLBINV; |
Leonid Yegoshin | 75b5b5e | 2013-11-14 16:12:31 +0000 | [diff] [blame] | 543 | mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF; |
| 544 | switch (mmuextdef) { |
| 545 | case MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT: |
| 546 | c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40; |
| 547 | c->tlbsizevtlb = c->tlbsize; |
| 548 | break; |
| 549 | case MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT: |
| 550 | c->tlbsizevtlb += |
| 551 | ((config4 & MIPS_CONF4_VTLBSIZEEXT) >> |
| 552 | MIPS_CONF4_VTLBSIZEEXT_SHIFT) * 0x40; |
| 553 | c->tlbsize = c->tlbsizevtlb; |
| 554 | ftlb_page = MIPS_CONF4_VFTLBPAGESIZE; |
| 555 | /* fall through */ |
| 556 | case MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT: |
Markos Chandras | 97f4ad2 | 2014-08-29 09:37:26 +0100 | [diff] [blame] | 557 | if (mips_ftlb_disabled) |
| 558 | break; |
Leonid Yegoshin | 75b5b5e | 2013-11-14 16:12:31 +0000 | [diff] [blame] | 559 | newcf4 = (config4 & ~ftlb_page) | |
| 560 | (page_size_ftlb(mmuextdef) << |
| 561 | MIPS_CONF4_FTLBPAGESIZE_SHIFT); |
| 562 | write_c0_config4(newcf4); |
| 563 | back_to_back_c0_hazard(); |
| 564 | config4 = read_c0_config4(); |
| 565 | if (config4 != newcf4) { |
| 566 | pr_err("PAGE_SIZE 0x%lx is not supported by FTLB (config4=0x%x)\n", |
| 567 | PAGE_SIZE, config4); |
| 568 | /* Switch FTLB off */ |
| 569 | set_ftlb_enable(c, 0); |
| 570 | break; |
| 571 | } |
| 572 | c->tlbsizeftlbsets = 1 << |
| 573 | ((config4 & MIPS_CONF4_FTLBSETS) >> |
| 574 | MIPS_CONF4_FTLBSETS_SHIFT); |
| 575 | c->tlbsizeftlbways = ((config4 & MIPS_CONF4_FTLBWAYS) >> |
| 576 | MIPS_CONF4_FTLBWAYS_SHIFT) + 2; |
| 577 | c->tlbsize += c->tlbsizeftlbways * c->tlbsizeftlbsets; |
Markos Chandras | 97f4ad2 | 2014-08-29 09:37:26 +0100 | [diff] [blame] | 578 | mips_has_ftlb_configured = 1; |
Leonid Yegoshin | 75b5b5e | 2013-11-14 16:12:31 +0000 | [diff] [blame] | 579 | break; |
| 580 | } |
Leonid Yegoshin | 1745c1e | 2013-11-14 16:12:23 +0000 | [diff] [blame] | 581 | } |
| 582 | |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 583 | c->kscratch_mask = (config4 >> 16) & 0xff; |
| 584 | |
| 585 | return config4 & MIPS_CONF_M; |
| 586 | } |
| 587 | |
Ralf Baechle | 8b8a7634 | 2013-09-19 11:15:49 +0200 | [diff] [blame] | 588 | static inline unsigned int decode_config5(struct cpuinfo_mips *c) |
| 589 | { |
| 590 | unsigned int config5; |
| 591 | |
| 592 | config5 = read_c0_config5(); |
Paul Burton | d175ed2 | 2014-09-11 08:30:19 +0100 | [diff] [blame] | 593 | config5 &= ~(MIPS_CONF5_UFR | MIPS_CONF5_UFE); |
Ralf Baechle | 8b8a7634 | 2013-09-19 11:15:49 +0200 | [diff] [blame] | 594 | write_c0_config5(config5); |
| 595 | |
Markos Chandras | 4901674 | 2014-01-09 16:04:51 +0000 | [diff] [blame] | 596 | if (config5 & MIPS_CONF5_EVA) |
| 597 | c->options |= MIPS_CPU_EVA; |
Paul Burton | 1f6c52f | 2014-07-14 10:32:14 +0100 | [diff] [blame] | 598 | if (config5 & MIPS_CONF5_MRP) |
| 599 | c->options |= MIPS_CPU_MAAR; |
Markos Chandras | 5aed9da | 2014-12-02 09:46:19 +0000 | [diff] [blame] | 600 | if (config5 & MIPS_CONF5_LLB) |
| 601 | c->options |= MIPS_CPU_RW_LLB; |
Steven J. Hill | c5b3678 | 2015-02-26 18:16:38 -0600 | [diff] [blame] | 602 | #ifdef CONFIG_XPA |
| 603 | if (config5 & MIPS_CONF5_MVH) |
| 604 | c->options |= MIPS_CPU_XPA; |
| 605 | #endif |
Markos Chandras | 4901674 | 2014-01-09 16:04:51 +0000 | [diff] [blame] | 606 | |
Ralf Baechle | 8b8a7634 | 2013-09-19 11:15:49 +0200 | [diff] [blame] | 607 | return config5 & MIPS_CONF_M; |
| 608 | } |
| 609 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 610 | static void decode_configs(struct cpuinfo_mips *c) |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 611 | { |
| 612 | int ok; |
| 613 | |
| 614 | /* MIPS32 or MIPS64 compliant CPU. */ |
| 615 | c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER | |
| 616 | MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK; |
| 617 | |
| 618 | c->scache.flags = MIPS_CACHE_NOT_PRESENT; |
| 619 | |
Markos Chandras | 97f4ad2 | 2014-08-29 09:37:26 +0100 | [diff] [blame] | 620 | /* Enable FTLB if present and not disabled */ |
| 621 | set_ftlb_enable(c, !mips_ftlb_disabled); |
Leonid Yegoshin | 75b5b5e | 2013-11-14 16:12:31 +0000 | [diff] [blame] | 622 | |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 623 | ok = decode_config0(c); /* Read Config registers. */ |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 624 | BUG_ON(!ok); /* Arch spec violation! */ |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 625 | if (ok) |
| 626 | ok = decode_config1(c); |
| 627 | if (ok) |
| 628 | ok = decode_config2(c); |
| 629 | if (ok) |
| 630 | ok = decode_config3(c); |
| 631 | if (ok) |
| 632 | ok = decode_config4(c); |
Ralf Baechle | 8b8a7634 | 2013-09-19 11:15:49 +0200 | [diff] [blame] | 633 | if (ok) |
| 634 | ok = decode_config5(c); |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 635 | |
| 636 | mips_probe_watch_registers(c); |
| 637 | |
Leonid Yegoshin | 6575b1d | 2014-07-15 14:09:57 +0100 | [diff] [blame] | 638 | if (cpu_has_rixi) { |
| 639 | /* Enable the RIXI exceptions */ |
Steven J. Hill | a5770df | 2015-02-19 10:18:52 -0600 | [diff] [blame] | 640 | set_c0_pagegrain(PG_IEC); |
Leonid Yegoshin | 6575b1d | 2014-07-15 14:09:57 +0100 | [diff] [blame] | 641 | back_to_back_c0_hazard(); |
| 642 | /* Verify the IEC bit is set */ |
| 643 | if (read_c0_pagegrain() & PG_IEC) |
| 644 | c->options |= MIPS_CPU_RIXIEX; |
| 645 | } |
| 646 | |
Paul Burton | 0ee958e | 2014-01-15 10:31:53 +0000 | [diff] [blame] | 647 | #ifndef CONFIG_MIPS_CPS |
Leonid Yegoshin | 8b8aa63 | 2014-11-13 13:51:51 +0000 | [diff] [blame] | 648 | if (cpu_has_mips_r2_r6) { |
David Daney | 45b585c | 2014-05-28 23:52:10 +0200 | [diff] [blame] | 649 | c->core = get_ebase_cpunum(); |
Paul Burton | 30ee615 | 2014-03-27 10:57:30 +0000 | [diff] [blame] | 650 | if (cpu_has_mipsmt) |
| 651 | c->core >>= fls(core_nvpes()) - 1; |
| 652 | } |
Paul Burton | 0ee958e | 2014-01-15 10:31:53 +0000 | [diff] [blame] | 653 | #endif |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 654 | } |
| 655 | |
Ralf Baechle | 02cf211 | 2005-10-01 13:06:32 +0100 | [diff] [blame] | 656 | #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] | 657 | | MIPS_CPU_COUNTER) |
| 658 | |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 659 | 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] | 660 | { |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 661 | switch (c->processor_id & PRID_IMP_MASK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | case PRID_IMP_R2000: |
| 663 | c->cputype = CPU_R2000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 664 | __cpu_name[cpu] = "R2000"; |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 665 | c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS; |
Ralf Baechle | 02cf211 | 2005-10-01 13:06:32 +0100 | [diff] [blame] | 666 | c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 667 | MIPS_CPU_NOFPUEX; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | if (__cpu_has_fpu()) |
| 669 | c->options |= MIPS_CPU_FPU; |
| 670 | c->tlbsize = 64; |
| 671 | break; |
| 672 | case PRID_IMP_R3000: |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 673 | if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A) { |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 674 | if (cpu_has_confreg()) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | c->cputype = CPU_R3081E; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 676 | __cpu_name[cpu] = "R3081"; |
| 677 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | c->cputype = CPU_R3000A; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 679 | __cpu_name[cpu] = "R3000A"; |
| 680 | } |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 681 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | c->cputype = CPU_R3000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 683 | __cpu_name[cpu] = "R3000"; |
| 684 | } |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 685 | c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS; |
Ralf Baechle | 02cf211 | 2005-10-01 13:06:32 +0100 | [diff] [blame] | 686 | c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 687 | MIPS_CPU_NOFPUEX; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | if (__cpu_has_fpu()) |
| 689 | c->options |= MIPS_CPU_FPU; |
| 690 | c->tlbsize = 64; |
| 691 | break; |
| 692 | case PRID_IMP_R4000: |
| 693 | if (read_c0_config() & CONF_SC) { |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 694 | if ((c->processor_id & PRID_REV_MASK) >= |
| 695 | PRID_REV_R4400) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | c->cputype = CPU_R4400PC; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 697 | __cpu_name[cpu] = "R4400PC"; |
| 698 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | c->cputype = CPU_R4000PC; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 700 | __cpu_name[cpu] = "R4000PC"; |
| 701 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | } else { |
Maciej W. Rozycki | 7f177a5 | 2013-09-23 14:01:53 +0100 | [diff] [blame] | 703 | int cca = read_c0_config() & CONF_CM_CMASK; |
| 704 | int mc; |
| 705 | |
| 706 | /* |
| 707 | * SC and MC versions can't be reliably told apart, |
| 708 | * but only the latter support coherent caching |
| 709 | * modes so assume the firmware has set the KSEG0 |
| 710 | * coherency attribute reasonably (if uncached, we |
| 711 | * assume SC). |
| 712 | */ |
| 713 | switch (cca) { |
| 714 | case CONF_CM_CACHABLE_CE: |
| 715 | case CONF_CM_CACHABLE_COW: |
| 716 | case CONF_CM_CACHABLE_CUW: |
| 717 | mc = 1; |
| 718 | break; |
| 719 | default: |
| 720 | mc = 0; |
| 721 | break; |
| 722 | } |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 723 | if ((c->processor_id & PRID_REV_MASK) >= |
| 724 | PRID_REV_R4400) { |
Maciej W. Rozycki | 7f177a5 | 2013-09-23 14:01:53 +0100 | [diff] [blame] | 725 | c->cputype = mc ? CPU_R4400MC : CPU_R4400SC; |
| 726 | __cpu_name[cpu] = mc ? "R4400MC" : "R4400SC"; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 727 | } else { |
Maciej W. Rozycki | 7f177a5 | 2013-09-23 14:01:53 +0100 | [diff] [blame] | 728 | c->cputype = mc ? CPU_R4000MC : CPU_R4000SC; |
| 729 | __cpu_name[cpu] = mc ? "R4000MC" : "R4000SC"; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 730 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 731 | } |
| 732 | |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 733 | set_isa(c, MIPS_CPU_ISA_III); |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 734 | c->fpu_msk31 |= FPU_CSR_CONDX; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 735 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 736 | MIPS_CPU_WATCH | MIPS_CPU_VCE | |
| 737 | MIPS_CPU_LLSC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | c->tlbsize = 48; |
| 739 | break; |
| 740 | case PRID_IMP_VR41XX: |
Yoichi Yuasa | 9f91e50 | 2013-02-21 15:38:19 +0900 | [diff] [blame] | 741 | set_isa(c, MIPS_CPU_ISA_III); |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 742 | c->fpu_msk31 |= FPU_CSR_CONDX; |
Yoichi Yuasa | 9f91e50 | 2013-02-21 15:38:19 +0900 | [diff] [blame] | 743 | c->options = R4K_OPTS; |
| 744 | c->tlbsize = 32; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | switch (c->processor_id & 0xf0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 746 | case PRID_REV_VR4111: |
| 747 | c->cputype = CPU_VR4111; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 748 | __cpu_name[cpu] = "NEC VR4111"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 750 | case PRID_REV_VR4121: |
| 751 | c->cputype = CPU_VR4121; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 752 | __cpu_name[cpu] = "NEC VR4121"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 753 | break; |
| 754 | case PRID_REV_VR4122: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 755 | if ((c->processor_id & 0xf) < 0x3) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | c->cputype = CPU_VR4122; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 757 | __cpu_name[cpu] = "NEC VR4122"; |
| 758 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | c->cputype = CPU_VR4181A; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 760 | __cpu_name[cpu] = "NEC VR4181A"; |
| 761 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | break; |
| 763 | case PRID_REV_VR4130: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 764 | if ((c->processor_id & 0xf) < 0x4) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | c->cputype = CPU_VR4131; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 766 | __cpu_name[cpu] = "NEC VR4131"; |
| 767 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 768 | c->cputype = CPU_VR4133; |
Yoichi Yuasa | 9f91e50 | 2013-02-21 15:38:19 +0900 | [diff] [blame] | 769 | c->options |= MIPS_CPU_LLSC; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 770 | __cpu_name[cpu] = "NEC VR4133"; |
| 771 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | break; |
| 773 | default: |
| 774 | printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n"); |
| 775 | c->cputype = CPU_VR41XX; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 776 | __cpu_name[cpu] = "NEC Vr41xx"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | break; |
| 778 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | break; |
| 780 | case PRID_IMP_R4300: |
| 781 | c->cputype = CPU_R4300; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 782 | __cpu_name[cpu] = "R4300"; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 783 | set_isa(c, MIPS_CPU_ISA_III); |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 784 | c->fpu_msk31 |= FPU_CSR_CONDX; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 785 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 786 | MIPS_CPU_LLSC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | c->tlbsize = 32; |
| 788 | break; |
| 789 | case PRID_IMP_R4600: |
| 790 | c->cputype = CPU_R4600; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 791 | __cpu_name[cpu] = "R4600"; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 792 | set_isa(c, MIPS_CPU_ISA_III); |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 793 | c->fpu_msk31 |= FPU_CSR_CONDX; |
Thiemo Seufer | 075e750 | 2005-07-27 21:48:12 +0000 | [diff] [blame] | 794 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
| 795 | MIPS_CPU_LLSC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | c->tlbsize = 48; |
| 797 | break; |
| 798 | #if 0 |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 799 | case PRID_IMP_R4650: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | /* |
| 801 | * This processor doesn't have an MMU, so it's not |
| 802 | * "real easy" to run Linux on it. It is left purely |
| 803 | * for documentation. Commented out because it shares |
| 804 | * it's c0_prid id number with the TX3900. |
| 805 | */ |
Ralf Baechle | a3dddd5 | 2006-03-11 08:18:41 +0000 | [diff] [blame] | 806 | c->cputype = CPU_R4650; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 807 | __cpu_name[cpu] = "R4650"; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 808 | set_isa(c, MIPS_CPU_ISA_III); |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 809 | c->fpu_msk31 |= FPU_CSR_CONDX; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC; |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 811 | c->tlbsize = 48; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 812 | break; |
| 813 | #endif |
| 814 | case PRID_IMP_TX39: |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 815 | c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS; |
Ralf Baechle | 02cf211 | 2005-10-01 13:06:32 +0100 | [diff] [blame] | 816 | c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | |
| 818 | if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) { |
| 819 | c->cputype = CPU_TX3927; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 820 | __cpu_name[cpu] = "TX3927"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | c->tlbsize = 64; |
| 822 | } else { |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 823 | switch (c->processor_id & PRID_REV_MASK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 824 | case PRID_REV_TX3912: |
| 825 | c->cputype = CPU_TX3912; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 826 | __cpu_name[cpu] = "TX3912"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | c->tlbsize = 32; |
| 828 | break; |
| 829 | case PRID_REV_TX3922: |
| 830 | c->cputype = CPU_TX3922; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 831 | __cpu_name[cpu] = "TX3922"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | c->tlbsize = 64; |
| 833 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | } |
| 835 | } |
| 836 | break; |
| 837 | case PRID_IMP_R4700: |
| 838 | c->cputype = CPU_R4700; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 839 | __cpu_name[cpu] = "R4700"; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 840 | set_isa(c, MIPS_CPU_ISA_III); |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 841 | c->fpu_msk31 |= FPU_CSR_CONDX; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 842 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 843 | MIPS_CPU_LLSC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | c->tlbsize = 48; |
| 845 | break; |
| 846 | case PRID_IMP_TX49: |
| 847 | c->cputype = CPU_TX49XX; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 848 | __cpu_name[cpu] = "R49XX"; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 849 | set_isa(c, MIPS_CPU_ISA_III); |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 850 | c->fpu_msk31 |= FPU_CSR_CONDX; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 851 | c->options = R4K_OPTS | MIPS_CPU_LLSC; |
| 852 | if (!(c->processor_id & 0x08)) |
| 853 | c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR; |
| 854 | c->tlbsize = 48; |
| 855 | break; |
| 856 | case PRID_IMP_R5000: |
| 857 | c->cputype = CPU_R5000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 858 | __cpu_name[cpu] = "R5000"; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 859 | set_isa(c, MIPS_CPU_ISA_IV); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 860 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 861 | MIPS_CPU_LLSC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | c->tlbsize = 48; |
| 863 | break; |
| 864 | case PRID_IMP_R5432: |
| 865 | c->cputype = CPU_R5432; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 866 | __cpu_name[cpu] = "R5432"; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 867 | set_isa(c, MIPS_CPU_ISA_IV); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 868 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 869 | MIPS_CPU_WATCH | MIPS_CPU_LLSC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | c->tlbsize = 48; |
| 871 | break; |
| 872 | case PRID_IMP_R5500: |
| 873 | c->cputype = CPU_R5500; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 874 | __cpu_name[cpu] = "R5500"; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 875 | set_isa(c, MIPS_CPU_ISA_IV); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 876 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 877 | MIPS_CPU_WATCH | MIPS_CPU_LLSC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | c->tlbsize = 48; |
| 879 | break; |
| 880 | case PRID_IMP_NEVADA: |
| 881 | c->cputype = CPU_NEVADA; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 882 | __cpu_name[cpu] = "Nevada"; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 883 | set_isa(c, MIPS_CPU_ISA_IV); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 885 | MIPS_CPU_DIVEC | MIPS_CPU_LLSC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 886 | c->tlbsize = 48; |
| 887 | break; |
| 888 | case PRID_IMP_R6000: |
| 889 | c->cputype = CPU_R6000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 890 | __cpu_name[cpu] = "R6000"; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 891 | set_isa(c, MIPS_CPU_ISA_II); |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 892 | c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 893 | c->options = MIPS_CPU_TLB | MIPS_CPU_FPU | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 894 | MIPS_CPU_LLSC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | c->tlbsize = 32; |
| 896 | break; |
| 897 | case PRID_IMP_R6000A: |
| 898 | c->cputype = CPU_R6000A; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 899 | __cpu_name[cpu] = "R6000A"; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 900 | set_isa(c, MIPS_CPU_ISA_II); |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 901 | c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 902 | c->options = MIPS_CPU_TLB | MIPS_CPU_FPU | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 903 | MIPS_CPU_LLSC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 904 | c->tlbsize = 32; |
| 905 | break; |
| 906 | case PRID_IMP_RM7000: |
| 907 | c->cputype = CPU_RM7000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 908 | __cpu_name[cpu] = "RM7000"; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 909 | set_isa(c, MIPS_CPU_ISA_IV); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 910 | c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 911 | MIPS_CPU_LLSC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 912 | /* |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 913 | * Undocumented RM7000: Bit 29 in the info register of |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 | * the RM7000 v2.0 indicates if the TLB has 48 or 64 |
| 915 | * entries. |
| 916 | * |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 917 | * 29 1 => 64 entry JTLB |
| 918 | * 0 => 48 entry JTLB |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | */ |
| 920 | c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48; |
| 921 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | case PRID_IMP_R8000: |
| 923 | c->cputype = CPU_R8000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 924 | __cpu_name[cpu] = "RM8000"; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 925 | set_isa(c, MIPS_CPU_ISA_IV); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 927 | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
| 928 | MIPS_CPU_LLSC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | c->tlbsize = 384; /* has weird TLB: 3-way x 128 */ |
| 930 | break; |
| 931 | case PRID_IMP_R10000: |
| 932 | c->cputype = CPU_R10000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 933 | __cpu_name[cpu] = "R10000"; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 934 | set_isa(c, MIPS_CPU_ISA_IV); |
Ralf Baechle | 8b36612 | 2005-11-22 17:53:59 +0000 | [diff] [blame] | 935 | c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 936 | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 937 | MIPS_CPU_COUNTER | MIPS_CPU_WATCH | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 938 | MIPS_CPU_LLSC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 939 | c->tlbsize = 64; |
| 940 | break; |
| 941 | case PRID_IMP_R12000: |
| 942 | c->cputype = CPU_R12000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 943 | __cpu_name[cpu] = "R12000"; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 944 | set_isa(c, MIPS_CPU_ISA_IV); |
Ralf Baechle | 8b36612 | 2005-11-22 17:53:59 +0000 | [diff] [blame] | 945 | c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 946 | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | MIPS_CPU_COUNTER | MIPS_CPU_WATCH | |
Joshua Kinard | 8d5ded1 | 2015-06-02 18:21:33 -0400 | [diff] [blame^] | 948 | MIPS_CPU_LLSC | MIPS_CPU_BP_GHIST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | c->tlbsize = 64; |
| 950 | break; |
Kumba | 44d921b | 2006-05-16 22:23:59 -0400 | [diff] [blame] | 951 | case PRID_IMP_R14000: |
Joshua Kinard | 3057739 | 2015-01-21 07:59:45 -0500 | [diff] [blame] | 952 | if (((c->processor_id >> 4) & 0x0f) > 2) { |
| 953 | c->cputype = CPU_R16000; |
| 954 | __cpu_name[cpu] = "R16000"; |
| 955 | } else { |
| 956 | c->cputype = CPU_R14000; |
| 957 | __cpu_name[cpu] = "R14000"; |
| 958 | } |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 959 | set_isa(c, MIPS_CPU_ISA_IV); |
Kumba | 44d921b | 2006-05-16 22:23:59 -0400 | [diff] [blame] | 960 | c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX | |
Steven J. Hill | 03751e7 | 2012-05-10 23:21:18 -0500 | [diff] [blame] | 961 | MIPS_CPU_FPU | MIPS_CPU_32FPR | |
Kumba | 44d921b | 2006-05-16 22:23:59 -0400 | [diff] [blame] | 962 | MIPS_CPU_COUNTER | MIPS_CPU_WATCH | |
Joshua Kinard | 8d5ded1 | 2015-06-02 18:21:33 -0400 | [diff] [blame^] | 963 | MIPS_CPU_LLSC | MIPS_CPU_BP_GHIST; |
Kumba | 44d921b | 2006-05-16 22:23:59 -0400 | [diff] [blame] | 964 | c->tlbsize = 64; |
| 965 | break; |
Huacai Chen | 2685919 | 2014-02-16 16:01:18 +0800 | [diff] [blame] | 966 | case PRID_IMP_LOONGSON_64: /* Loongson-2/3 */ |
Robert Millan | 5aac1e8 | 2011-04-16 11:29:29 -0700 | [diff] [blame] | 967 | switch (c->processor_id & PRID_REV_MASK) { |
| 968 | case PRID_REV_LOONGSON2E: |
Huacai Chen | c579d31 | 2014-03-21 18:44:00 +0800 | [diff] [blame] | 969 | c->cputype = CPU_LOONGSON2; |
| 970 | __cpu_name[cpu] = "ICT Loongson-2"; |
Robert Millan | 5aac1e8 | 2011-04-16 11:29:29 -0700 | [diff] [blame] | 971 | set_elf_platform(cpu, "loongson2e"); |
Huacai Chen | 7352c8b | 2014-11-04 14:13:23 +0800 | [diff] [blame] | 972 | set_isa(c, MIPS_CPU_ISA_III); |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 973 | c->fpu_msk31 |= FPU_CSR_CONDX; |
Robert Millan | 5aac1e8 | 2011-04-16 11:29:29 -0700 | [diff] [blame] | 974 | break; |
| 975 | case PRID_REV_LOONGSON2F: |
Huacai Chen | c579d31 | 2014-03-21 18:44:00 +0800 | [diff] [blame] | 976 | c->cputype = CPU_LOONGSON2; |
| 977 | __cpu_name[cpu] = "ICT Loongson-2"; |
Robert Millan | 5aac1e8 | 2011-04-16 11:29:29 -0700 | [diff] [blame] | 978 | set_elf_platform(cpu, "loongson2f"); |
Huacai Chen | 7352c8b | 2014-11-04 14:13:23 +0800 | [diff] [blame] | 979 | set_isa(c, MIPS_CPU_ISA_III); |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 980 | c->fpu_msk31 |= FPU_CSR_CONDX; |
Robert Millan | 5aac1e8 | 2011-04-16 11:29:29 -0700 | [diff] [blame] | 981 | break; |
Huacai Chen | c579d31 | 2014-03-21 18:44:00 +0800 | [diff] [blame] | 982 | case PRID_REV_LOONGSON3A: |
| 983 | c->cputype = CPU_LOONGSON3; |
| 984 | __cpu_name[cpu] = "ICT Loongson-3"; |
| 985 | set_elf_platform(cpu, "loongson3a"); |
Huacai Chen | 7352c8b | 2014-11-04 14:13:23 +0800 | [diff] [blame] | 986 | set_isa(c, MIPS_CPU_ISA_M64R1); |
Huacai Chen | c579d31 | 2014-03-21 18:44:00 +0800 | [diff] [blame] | 987 | break; |
Huacai Chen | e7841be | 2014-06-26 11:41:30 +0800 | [diff] [blame] | 988 | case PRID_REV_LOONGSON3B_R1: |
| 989 | case PRID_REV_LOONGSON3B_R2: |
| 990 | c->cputype = CPU_LOONGSON3; |
| 991 | __cpu_name[cpu] = "ICT Loongson-3"; |
| 992 | set_elf_platform(cpu, "loongson3b"); |
Huacai Chen | 7352c8b | 2014-11-04 14:13:23 +0800 | [diff] [blame] | 993 | set_isa(c, MIPS_CPU_ISA_M64R1); |
Huacai Chen | e7841be | 2014-06-26 11:41:30 +0800 | [diff] [blame] | 994 | break; |
Robert Millan | 5aac1e8 | 2011-04-16 11:29:29 -0700 | [diff] [blame] | 995 | } |
| 996 | |
Fuxin Zhang | 2a21c73 | 2007-06-06 14:52:43 +0800 | [diff] [blame] | 997 | c->options = R4K_OPTS | |
| 998 | MIPS_CPU_FPU | MIPS_CPU_LLSC | |
| 999 | MIPS_CPU_32FPR; |
| 1000 | c->tlbsize = 64; |
Huacai Chen | cc94ea3 | 2014-11-04 14:13:22 +0800 | [diff] [blame] | 1001 | c->writecombine = _CACHE_UNCACHED_ACCELERATED; |
Fuxin Zhang | 2a21c73 | 2007-06-06 14:52:43 +0800 | [diff] [blame] | 1002 | break; |
Huacai Chen | 2685919 | 2014-02-16 16:01:18 +0800 | [diff] [blame] | 1003 | case PRID_IMP_LOONGSON_32: /* Loongson-1 */ |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 1004 | decode_configs(c); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 1006 | c->cputype = CPU_LOONGSON1; |
Ralf Baechle | b4672d3 | 2005-12-08 14:04:24 +0000 | [diff] [blame] | 1007 | |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 1008 | switch (c->processor_id & PRID_REV_MASK) { |
| 1009 | case PRID_REV_LOONGSON1B: |
| 1010 | __cpu_name[cpu] = "Loongson 1B"; |
Ralf Baechle | b4672d3 | 2005-12-08 14:04:24 +0000 | [diff] [blame] | 1011 | break; |
Ralf Baechle | b4672d3 | 2005-12-08 14:04:24 +0000 | [diff] [blame] | 1012 | } |
Kelvin Cheung | 2fa3639 | 2012-06-20 20:05:32 +0100 | [diff] [blame] | 1013 | |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 1014 | break; |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 1015 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1016 | } |
| 1017 | |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1018 | 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] | 1019 | { |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1020 | c->writecombine = _CACHE_UNCACHED_ACCELERATED; |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 1021 | switch (c->processor_id & PRID_IMP_MASK) { |
Leonid Yegoshin | b2498af | 2014-11-24 12:59:44 +0000 | [diff] [blame] | 1022 | case PRID_IMP_QEMU_GENERIC: |
| 1023 | c->writecombine = _CACHE_UNCACHED; |
| 1024 | c->cputype = CPU_QEMU_GENERIC; |
| 1025 | __cpu_name[cpu] = "MIPS GENERIC QEMU"; |
| 1026 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | case PRID_IMP_4KC: |
| 1028 | c->cputype = CPU_4KC; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1029 | c->writecombine = _CACHE_UNCACHED; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1030 | __cpu_name[cpu] = "MIPS 4Kc"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | break; |
| 1032 | case PRID_IMP_4KEC: |
Ralf Baechle | 2b07bd0 | 2005-04-08 20:36:05 +0000 | [diff] [blame] | 1033 | case PRID_IMP_4KECR2: |
| 1034 | c->cputype = CPU_4KEC; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1035 | c->writecombine = _CACHE_UNCACHED; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1036 | __cpu_name[cpu] = "MIPS 4KEc"; |
Ralf Baechle | 2b07bd0 | 2005-04-08 20:36:05 +0000 | [diff] [blame] | 1037 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1038 | case PRID_IMP_4KSC: |
Ralf Baechle | 8afcb5d | 2005-10-04 15:01:26 +0100 | [diff] [blame] | 1039 | case PRID_IMP_4KSD: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1040 | c->cputype = CPU_4KSC; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1041 | c->writecombine = _CACHE_UNCACHED; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1042 | __cpu_name[cpu] = "MIPS 4KSc"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1043 | break; |
| 1044 | case PRID_IMP_5KC: |
| 1045 | c->cputype = CPU_5KC; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1046 | c->writecombine = _CACHE_UNCACHED; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1047 | __cpu_name[cpu] = "MIPS 5Kc"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | break; |
Leonid Yegoshin | 78d4803 | 2012-07-06 21:56:01 +0200 | [diff] [blame] | 1049 | case PRID_IMP_5KE: |
| 1050 | c->cputype = CPU_5KE; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1051 | c->writecombine = _CACHE_UNCACHED; |
Leonid Yegoshin | 78d4803 | 2012-07-06 21:56:01 +0200 | [diff] [blame] | 1052 | __cpu_name[cpu] = "MIPS 5KE"; |
| 1053 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | case PRID_IMP_20KC: |
| 1055 | c->cputype = CPU_20KC; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1056 | c->writecombine = _CACHE_UNCACHED; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1057 | __cpu_name[cpu] = "MIPS 20Kc"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1058 | break; |
| 1059 | case PRID_IMP_24K: |
| 1060 | c->cputype = CPU_24K; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1061 | c->writecombine = _CACHE_UNCACHED; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1062 | __cpu_name[cpu] = "MIPS 24Kc"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | break; |
John Crispin | 42f3cae | 2013-01-11 22:44:10 +0100 | [diff] [blame] | 1064 | case PRID_IMP_24KE: |
| 1065 | c->cputype = CPU_24K; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1066 | c->writecombine = _CACHE_UNCACHED; |
John Crispin | 42f3cae | 2013-01-11 22:44:10 +0100 | [diff] [blame] | 1067 | __cpu_name[cpu] = "MIPS 24KEc"; |
| 1068 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | case PRID_IMP_25KF: |
| 1070 | c->cputype = CPU_25KF; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1071 | c->writecombine = _CACHE_UNCACHED; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1072 | __cpu_name[cpu] = "MIPS 25Kc"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | break; |
Ralf Baechle | bbc7f22 | 2005-07-12 16:12:05 +0000 | [diff] [blame] | 1074 | case PRID_IMP_34K: |
| 1075 | c->cputype = CPU_34K; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1076 | c->writecombine = _CACHE_UNCACHED; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1077 | __cpu_name[cpu] = "MIPS 34Kc"; |
Ralf Baechle | bbc7f22 | 2005-07-12 16:12:05 +0000 | [diff] [blame] | 1078 | break; |
Chris Dearman | c620953 | 2006-05-02 14:08:46 +0100 | [diff] [blame] | 1079 | case PRID_IMP_74K: |
| 1080 | c->cputype = CPU_74K; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1081 | c->writecombine = _CACHE_UNCACHED; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1082 | __cpu_name[cpu] = "MIPS 74Kc"; |
Chris Dearman | c620953 | 2006-05-02 14:08:46 +0100 | [diff] [blame] | 1083 | break; |
Steven J. Hill | 113c62d | 2012-07-06 23:56:00 +0200 | [diff] [blame] | 1084 | case PRID_IMP_M14KC: |
| 1085 | c->cputype = CPU_M14KC; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1086 | c->writecombine = _CACHE_UNCACHED; |
Steven J. Hill | 113c62d | 2012-07-06 23:56:00 +0200 | [diff] [blame] | 1087 | __cpu_name[cpu] = "MIPS M14Kc"; |
| 1088 | break; |
Steven J. Hill | f8fa481 | 2012-12-07 03:51:35 +0000 | [diff] [blame] | 1089 | case PRID_IMP_M14KEC: |
| 1090 | c->cputype = CPU_M14KEC; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1091 | c->writecombine = _CACHE_UNCACHED; |
Steven J. Hill | f8fa481 | 2012-12-07 03:51:35 +0000 | [diff] [blame] | 1092 | __cpu_name[cpu] = "MIPS M14KEc"; |
| 1093 | break; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 1094 | case PRID_IMP_1004K: |
| 1095 | c->cputype = CPU_1004K; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1096 | c->writecombine = _CACHE_UNCACHED; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1097 | __cpu_name[cpu] = "MIPS 1004Kc"; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 1098 | break; |
Steven J. Hill | 006a851 | 2012-06-26 04:11:03 +0000 | [diff] [blame] | 1099 | case PRID_IMP_1074K: |
Steven J. Hill | 442e14a | 2014-01-17 15:03:50 -0600 | [diff] [blame] | 1100 | c->cputype = CPU_1074K; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1101 | c->writecombine = _CACHE_UNCACHED; |
Steven J. Hill | 006a851 | 2012-06-26 04:11:03 +0000 | [diff] [blame] | 1102 | __cpu_name[cpu] = "MIPS 1074Kc"; |
| 1103 | break; |
Leonid Yegoshin | b5f065e | 2013-11-20 10:46:02 +0000 | [diff] [blame] | 1104 | case PRID_IMP_INTERAPTIV_UP: |
| 1105 | c->cputype = CPU_INTERAPTIV; |
| 1106 | __cpu_name[cpu] = "MIPS interAptiv"; |
| 1107 | break; |
| 1108 | case PRID_IMP_INTERAPTIV_MP: |
| 1109 | c->cputype = CPU_INTERAPTIV; |
| 1110 | __cpu_name[cpu] = "MIPS interAptiv (multi)"; |
| 1111 | break; |
Leonid Yegoshin | b0d4d30 | 2013-11-14 16:12:28 +0000 | [diff] [blame] | 1112 | case PRID_IMP_PROAPTIV_UP: |
| 1113 | c->cputype = CPU_PROAPTIV; |
| 1114 | __cpu_name[cpu] = "MIPS proAptiv"; |
| 1115 | break; |
| 1116 | case PRID_IMP_PROAPTIV_MP: |
| 1117 | c->cputype = CPU_PROAPTIV; |
| 1118 | __cpu_name[cpu] = "MIPS proAptiv (multi)"; |
| 1119 | break; |
James Hogan | 829dcc0 | 2014-01-22 16:19:39 +0000 | [diff] [blame] | 1120 | case PRID_IMP_P5600: |
| 1121 | c->cputype = CPU_P5600; |
| 1122 | __cpu_name[cpu] = "MIPS P5600"; |
| 1123 | break; |
Leonid Yegoshin | 9943ed9 | 2014-03-04 13:34:44 +0000 | [diff] [blame] | 1124 | case PRID_IMP_M5150: |
| 1125 | c->cputype = CPU_M5150; |
| 1126 | __cpu_name[cpu] = "MIPS M5150"; |
| 1127 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1128 | } |
Chris Dearman | 0b6d497 | 2007-09-13 12:32:02 +0100 | [diff] [blame] | 1129 | |
Leonid Yegoshin | 75b5b5e | 2013-11-14 16:12:31 +0000 | [diff] [blame] | 1130 | decode_configs(c); |
| 1131 | |
Chris Dearman | 0b6d497 | 2007-09-13 12:32:02 +0100 | [diff] [blame] | 1132 | spram_config(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1133 | } |
| 1134 | |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1135 | 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] | 1136 | { |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 1137 | decode_configs(c); |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 1138 | switch (c->processor_id & PRID_IMP_MASK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1139 | case PRID_IMP_AU1_REV1: |
| 1140 | case PRID_IMP_AU1_REV2: |
Manuel Lauss | 270717a | 2009-03-25 17:49:28 +0100 | [diff] [blame] | 1141 | c->cputype = CPU_ALCHEMY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1142 | switch ((c->processor_id >> 24) & 0xff) { |
| 1143 | case 0: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1144 | __cpu_name[cpu] = "Au1000"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1145 | break; |
| 1146 | case 1: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1147 | __cpu_name[cpu] = "Au1500"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1148 | break; |
| 1149 | case 2: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1150 | __cpu_name[cpu] = "Au1100"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1151 | break; |
| 1152 | case 3: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1153 | __cpu_name[cpu] = "Au1550"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1154 | break; |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 1155 | case 4: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1156 | __cpu_name[cpu] = "Au1200"; |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 1157 | if ((c->processor_id & PRID_REV_MASK) == 2) |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1158 | __cpu_name[cpu] = "Au1250"; |
Manuel Lauss | 237cfee | 2007-12-06 09:07:55 +0100 | [diff] [blame] | 1159 | break; |
| 1160 | case 5: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1161 | __cpu_name[cpu] = "Au1210"; |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 1162 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1163 | default: |
Manuel Lauss | 270717a | 2009-03-25 17:49:28 +0100 | [diff] [blame] | 1164 | __cpu_name[cpu] = "Au1xxx"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1165 | break; |
| 1166 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1167 | break; |
| 1168 | } |
| 1169 | } |
| 1170 | |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1171 | 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] | 1172 | { |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 1173 | decode_configs(c); |
Ralf Baechle | 02cf211 | 2005-10-01 13:06:32 +0100 | [diff] [blame] | 1174 | |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1175 | c->writecombine = _CACHE_UNCACHED_ACCELERATED; |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 1176 | switch (c->processor_id & PRID_IMP_MASK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1177 | case PRID_IMP_SB1: |
| 1178 | c->cputype = CPU_SB1; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1179 | __cpu_name[cpu] = "SiByte SB1"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1180 | /* FPU in pass1 is known to have issues. */ |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 1181 | if ((c->processor_id & PRID_REV_MASK) < 0x02) |
Ralf Baechle | 010b853 | 2006-01-29 18:42:08 +0000 | [diff] [blame] | 1182 | c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1183 | break; |
Andrew Isaacson | 93ce2f52 | 2005-10-19 23:56:20 -0700 | [diff] [blame] | 1184 | case PRID_IMP_SB1A: |
| 1185 | c->cputype = CPU_SB1A; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1186 | __cpu_name[cpu] = "SiByte SB1A"; |
Andrew Isaacson | 93ce2f52 | 2005-10-19 23:56:20 -0700 | [diff] [blame] | 1187 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1188 | } |
| 1189 | } |
| 1190 | |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1191 | 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] | 1192 | { |
Ralf Baechle | 4194318 | 2005-05-05 16:45:59 +0000 | [diff] [blame] | 1193 | decode_configs(c); |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 1194 | switch (c->processor_id & PRID_IMP_MASK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1195 | case PRID_IMP_SR71000: |
| 1196 | c->cputype = CPU_SR71000; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1197 | __cpu_name[cpu] = "Sandcraft SR71000"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1198 | c->scache.ways = 8; |
| 1199 | c->tlbsize = 64; |
| 1200 | break; |
| 1201 | } |
| 1202 | } |
| 1203 | |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1204 | 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] | 1205 | { |
| 1206 | decode_configs(c); |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 1207 | switch (c->processor_id & PRID_IMP_MASK) { |
Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 1208 | case PRID_IMP_PR4450: |
| 1209 | c->cputype = CPU_PR4450; |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1210 | __cpu_name[cpu] = "Philips PR4450"; |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 1211 | set_isa(c, MIPS_CPU_ISA_M32R1); |
Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 1212 | break; |
Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 1213 | } |
| 1214 | } |
| 1215 | |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1216 | 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] | 1217 | { |
| 1218 | decode_configs(c); |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 1219 | switch (c->processor_id & PRID_IMP_MASK) { |
Kevin Cernekee | 190fca3 | 2010-11-23 10:26:45 -0800 | [diff] [blame] | 1220 | case PRID_IMP_BMIPS32_REV4: |
| 1221 | case PRID_IMP_BMIPS32_REV8: |
Kevin Cernekee | 602977b | 2010-10-16 14:22:30 -0700 | [diff] [blame] | 1222 | c->cputype = CPU_BMIPS32; |
| 1223 | __cpu_name[cpu] = "Broadcom BMIPS32"; |
Kevin Cernekee | 06785df | 2011-04-16 11:29:28 -0700 | [diff] [blame] | 1224 | set_elf_platform(cpu, "bmips32"); |
Aurelien Jarno | 1c0c13e | 2007-09-25 15:40:12 +0200 | [diff] [blame] | 1225 | break; |
Kevin Cernekee | 602977b | 2010-10-16 14:22:30 -0700 | [diff] [blame] | 1226 | case PRID_IMP_BMIPS3300: |
| 1227 | case PRID_IMP_BMIPS3300_ALT: |
| 1228 | case PRID_IMP_BMIPS3300_BUG: |
| 1229 | c->cputype = CPU_BMIPS3300; |
| 1230 | __cpu_name[cpu] = "Broadcom BMIPS3300"; |
Kevin Cernekee | 06785df | 2011-04-16 11:29:28 -0700 | [diff] [blame] | 1231 | set_elf_platform(cpu, "bmips3300"); |
Aurelien Jarno | 1c0c13e | 2007-09-25 15:40:12 +0200 | [diff] [blame] | 1232 | break; |
Kevin Cernekee | 602977b | 2010-10-16 14:22:30 -0700 | [diff] [blame] | 1233 | case PRID_IMP_BMIPS43XX: { |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 1234 | int rev = c->processor_id & PRID_REV_MASK; |
Kevin Cernekee | 602977b | 2010-10-16 14:22:30 -0700 | [diff] [blame] | 1235 | |
| 1236 | if (rev >= PRID_REV_BMIPS4380_LO && |
| 1237 | rev <= PRID_REV_BMIPS4380_HI) { |
| 1238 | c->cputype = CPU_BMIPS4380; |
| 1239 | __cpu_name[cpu] = "Broadcom BMIPS4380"; |
Kevin Cernekee | 06785df | 2011-04-16 11:29:28 -0700 | [diff] [blame] | 1240 | set_elf_platform(cpu, "bmips4380"); |
Kevin Cernekee | 602977b | 2010-10-16 14:22:30 -0700 | [diff] [blame] | 1241 | } else { |
| 1242 | c->cputype = CPU_BMIPS4350; |
| 1243 | __cpu_name[cpu] = "Broadcom BMIPS4350"; |
Kevin Cernekee | 06785df | 2011-04-16 11:29:28 -0700 | [diff] [blame] | 1244 | set_elf_platform(cpu, "bmips4350"); |
Maxime Bizon | 0de663e | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 1245 | } |
| 1246 | break; |
Aurelien Jarno | 1c0c13e | 2007-09-25 15:40:12 +0200 | [diff] [blame] | 1247 | } |
Kevin Cernekee | 602977b | 2010-10-16 14:22:30 -0700 | [diff] [blame] | 1248 | case PRID_IMP_BMIPS5000: |
Kevin Cernekee | 68e6a78 | 2014-10-20 21:28:01 -0700 | [diff] [blame] | 1249 | case PRID_IMP_BMIPS5200: |
Kevin Cernekee | 602977b | 2010-10-16 14:22:30 -0700 | [diff] [blame] | 1250 | c->cputype = CPU_BMIPS5000; |
| 1251 | __cpu_name[cpu] = "Broadcom BMIPS5000"; |
Kevin Cernekee | 06785df | 2011-04-16 11:29:28 -0700 | [diff] [blame] | 1252 | set_elf_platform(cpu, "bmips5000"); |
Kevin Cernekee | 602977b | 2010-10-16 14:22:30 -0700 | [diff] [blame] | 1253 | c->options |= MIPS_CPU_ULRI; |
| 1254 | break; |
Kevin Cernekee | 602977b | 2010-10-16 14:22:30 -0700 | [diff] [blame] | 1255 | } |
Aurelien Jarno | 1c0c13e | 2007-09-25 15:40:12 +0200 | [diff] [blame] | 1256 | } |
| 1257 | |
David Daney | 0dd4781 | 2008-12-11 15:33:26 -0800 | [diff] [blame] | 1258 | static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu) |
| 1259 | { |
| 1260 | decode_configs(c); |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 1261 | switch (c->processor_id & PRID_IMP_MASK) { |
David Daney | 0dd4781 | 2008-12-11 15:33:26 -0800 | [diff] [blame] | 1262 | case PRID_IMP_CAVIUM_CN38XX: |
| 1263 | case PRID_IMP_CAVIUM_CN31XX: |
| 1264 | case PRID_IMP_CAVIUM_CN30XX: |
David Daney | 6f32946 | 2010-02-10 15:12:48 -0800 | [diff] [blame] | 1265 | c->cputype = CPU_CAVIUM_OCTEON; |
| 1266 | __cpu_name[cpu] = "Cavium Octeon"; |
| 1267 | goto platform; |
David Daney | 0dd4781 | 2008-12-11 15:33:26 -0800 | [diff] [blame] | 1268 | case PRID_IMP_CAVIUM_CN58XX: |
| 1269 | case PRID_IMP_CAVIUM_CN56XX: |
| 1270 | case PRID_IMP_CAVIUM_CN50XX: |
| 1271 | case PRID_IMP_CAVIUM_CN52XX: |
David Daney | 6f32946 | 2010-02-10 15:12:48 -0800 | [diff] [blame] | 1272 | c->cputype = CPU_CAVIUM_OCTEON_PLUS; |
| 1273 | __cpu_name[cpu] = "Cavium Octeon+"; |
| 1274 | platform: |
Robert Millan | c094c99 | 2011-04-18 11:37:55 -0700 | [diff] [blame] | 1275 | set_elf_platform(cpu, "octeon"); |
David Daney | 0dd4781 | 2008-12-11 15:33:26 -0800 | [diff] [blame] | 1276 | break; |
David Daney | a1431b6 | 2011-09-24 02:29:54 +0200 | [diff] [blame] | 1277 | case PRID_IMP_CAVIUM_CN61XX: |
David Daney | 0e56b38 | 2010-10-07 16:03:45 -0700 | [diff] [blame] | 1278 | case PRID_IMP_CAVIUM_CN63XX: |
David Daney | a1431b6 | 2011-09-24 02:29:54 +0200 | [diff] [blame] | 1279 | case PRID_IMP_CAVIUM_CN66XX: |
| 1280 | case PRID_IMP_CAVIUM_CN68XX: |
David Daney | af04bb8 | 2013-07-29 15:07:01 -0700 | [diff] [blame] | 1281 | case PRID_IMP_CAVIUM_CNF71XX: |
David Daney | 0e56b38 | 2010-10-07 16:03:45 -0700 | [diff] [blame] | 1282 | c->cputype = CPU_CAVIUM_OCTEON2; |
| 1283 | __cpu_name[cpu] = "Cavium Octeon II"; |
Robert Millan | c094c99 | 2011-04-18 11:37:55 -0700 | [diff] [blame] | 1284 | set_elf_platform(cpu, "octeon2"); |
David Daney | 0e56b38 | 2010-10-07 16:03:45 -0700 | [diff] [blame] | 1285 | break; |
David Daney | af04bb8 | 2013-07-29 15:07:01 -0700 | [diff] [blame] | 1286 | case PRID_IMP_CAVIUM_CN70XX: |
| 1287 | case PRID_IMP_CAVIUM_CN78XX: |
| 1288 | c->cputype = CPU_CAVIUM_OCTEON3; |
| 1289 | __cpu_name[cpu] = "Cavium Octeon III"; |
| 1290 | set_elf_platform(cpu, "octeon3"); |
| 1291 | break; |
David Daney | 0dd4781 | 2008-12-11 15:33:26 -0800 | [diff] [blame] | 1292 | default: |
| 1293 | printk(KERN_INFO "Unknown Octeon chip!\n"); |
| 1294 | c->cputype = CPU_UNKNOWN; |
| 1295 | break; |
| 1296 | } |
| 1297 | } |
| 1298 | |
Lars-Peter Clausen | 83ccf69 | 2010-07-17 11:07:51 +0000 | [diff] [blame] | 1299 | static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu) |
| 1300 | { |
| 1301 | decode_configs(c); |
| 1302 | /* JZRISC does not implement the CP0 counter. */ |
| 1303 | c->options &= ~MIPS_CPU_COUNTER; |
Maciej W. Rozycki | 06947aa | 2014-04-06 21:31:29 +0100 | [diff] [blame] | 1304 | BUG_ON(!__builtin_constant_p(cpu_has_counter) || cpu_has_counter); |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 1305 | switch (c->processor_id & PRID_IMP_MASK) { |
Lars-Peter Clausen | 83ccf69 | 2010-07-17 11:07:51 +0000 | [diff] [blame] | 1306 | case PRID_IMP_JZRISC: |
| 1307 | c->cputype = CPU_JZRISC; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1308 | c->writecombine = _CACHE_UNCACHED_ACCELERATED; |
Lars-Peter Clausen | 83ccf69 | 2010-07-17 11:07:51 +0000 | [diff] [blame] | 1309 | __cpu_name[cpu] = "Ingenic JZRISC"; |
| 1310 | break; |
| 1311 | default: |
| 1312 | panic("Unknown Ingenic Processor ID!"); |
| 1313 | break; |
| 1314 | } |
| 1315 | } |
| 1316 | |
Jayachandran C | a7117c6 | 2011-05-11 12:04:58 +0530 | [diff] [blame] | 1317 | static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu) |
| 1318 | { |
| 1319 | decode_configs(c); |
| 1320 | |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 1321 | if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_NETLOGIC_AU13XX) { |
Manuel Lauss | 809f36c | 2011-11-01 20:03:30 +0100 | [diff] [blame] | 1322 | c->cputype = CPU_ALCHEMY; |
| 1323 | __cpu_name[cpu] = "Au1300"; |
| 1324 | /* following stuff is not for Alchemy */ |
| 1325 | return; |
| 1326 | } |
| 1327 | |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 1328 | c->options = (MIPS_CPU_TLB | |
| 1329 | MIPS_CPU_4KEX | |
Jayachandran C | a7117c6 | 2011-05-11 12:04:58 +0530 | [diff] [blame] | 1330 | MIPS_CPU_COUNTER | |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 1331 | MIPS_CPU_DIVEC | |
| 1332 | MIPS_CPU_WATCH | |
| 1333 | MIPS_CPU_EJTAG | |
Jayachandran C | a7117c6 | 2011-05-11 12:04:58 +0530 | [diff] [blame] | 1334 | MIPS_CPU_LLSC); |
| 1335 | |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 1336 | switch (c->processor_id & PRID_IMP_MASK) { |
Jayachandran C | 4ca86a2 | 2013-08-11 14:43:54 +0530 | [diff] [blame] | 1337 | case PRID_IMP_NETLOGIC_XLP2XX: |
Jayachandran C | 8907c55 | 2013-12-21 16:52:20 +0530 | [diff] [blame] | 1338 | case PRID_IMP_NETLOGIC_XLP9XX: |
Yonghong Song | 1c98398 | 2014-04-29 20:07:53 +0530 | [diff] [blame] | 1339 | case PRID_IMP_NETLOGIC_XLP5XX: |
Jayachandran C | 4ca86a2 | 2013-08-11 14:43:54 +0530 | [diff] [blame] | 1340 | c->cputype = CPU_XLP; |
| 1341 | __cpu_name[cpu] = "Broadcom XLPII"; |
| 1342 | break; |
| 1343 | |
Jayachandran C | 2aa54b2 | 2011-11-16 00:21:29 +0000 | [diff] [blame] | 1344 | case PRID_IMP_NETLOGIC_XLP8XX: |
| 1345 | case PRID_IMP_NETLOGIC_XLP3XX: |
Jayachandran C | a3d4fb2 | 2011-11-16 00:21:20 +0000 | [diff] [blame] | 1346 | c->cputype = CPU_XLP; |
| 1347 | __cpu_name[cpu] = "Netlogic XLP"; |
| 1348 | break; |
| 1349 | |
Jayachandran C | a7117c6 | 2011-05-11 12:04:58 +0530 | [diff] [blame] | 1350 | case PRID_IMP_NETLOGIC_XLR732: |
| 1351 | case PRID_IMP_NETLOGIC_XLR716: |
| 1352 | case PRID_IMP_NETLOGIC_XLR532: |
| 1353 | case PRID_IMP_NETLOGIC_XLR308: |
| 1354 | case PRID_IMP_NETLOGIC_XLR532C: |
| 1355 | case PRID_IMP_NETLOGIC_XLR516C: |
| 1356 | case PRID_IMP_NETLOGIC_XLR508C: |
| 1357 | case PRID_IMP_NETLOGIC_XLR308C: |
| 1358 | c->cputype = CPU_XLR; |
| 1359 | __cpu_name[cpu] = "Netlogic XLR"; |
| 1360 | break; |
| 1361 | |
| 1362 | case PRID_IMP_NETLOGIC_XLS608: |
| 1363 | case PRID_IMP_NETLOGIC_XLS408: |
| 1364 | case PRID_IMP_NETLOGIC_XLS404: |
| 1365 | case PRID_IMP_NETLOGIC_XLS208: |
| 1366 | case PRID_IMP_NETLOGIC_XLS204: |
| 1367 | case PRID_IMP_NETLOGIC_XLS108: |
| 1368 | case PRID_IMP_NETLOGIC_XLS104: |
| 1369 | case PRID_IMP_NETLOGIC_XLS616B: |
| 1370 | case PRID_IMP_NETLOGIC_XLS608B: |
| 1371 | case PRID_IMP_NETLOGIC_XLS416B: |
| 1372 | case PRID_IMP_NETLOGIC_XLS412B: |
| 1373 | case PRID_IMP_NETLOGIC_XLS408B: |
| 1374 | case PRID_IMP_NETLOGIC_XLS404B: |
| 1375 | c->cputype = CPU_XLR; |
| 1376 | __cpu_name[cpu] = "Netlogic XLS"; |
| 1377 | break; |
| 1378 | |
| 1379 | default: |
Jayachandran C | a3d4fb2 | 2011-11-16 00:21:20 +0000 | [diff] [blame] | 1380 | pr_info("Unknown Netlogic chip id [%02x]!\n", |
Jayachandran C | a7117c6 | 2011-05-11 12:04:58 +0530 | [diff] [blame] | 1381 | c->processor_id); |
| 1382 | c->cputype = CPU_XLR; |
| 1383 | break; |
| 1384 | } |
| 1385 | |
Jayachandran C | a3d4fb2 | 2011-11-16 00:21:20 +0000 | [diff] [blame] | 1386 | if (c->cputype == CPU_XLP) { |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 1387 | set_isa(c, MIPS_CPU_ISA_M64R2); |
Jayachandran C | a3d4fb2 | 2011-11-16 00:21:20 +0000 | [diff] [blame] | 1388 | c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK); |
| 1389 | /* This will be updated again after all threads are woken up */ |
| 1390 | c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1; |
| 1391 | } else { |
Steven J. Hill | a96102b | 2012-12-07 04:31:36 +0000 | [diff] [blame] | 1392 | set_isa(c, MIPS_CPU_ISA_M64R1); |
Jayachandran C | a3d4fb2 | 2011-11-16 00:21:20 +0000 | [diff] [blame] | 1393 | c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1; |
| 1394 | } |
Jayachandran C | 7777b93 | 2013-06-11 14:41:35 +0000 | [diff] [blame] | 1395 | c->kscratch_mask = 0xf; |
Jayachandran C | a7117c6 | 2011-05-11 12:04:58 +0530 | [diff] [blame] | 1396 | } |
| 1397 | |
David Daney | 949e51b | 2010-10-14 11:32:33 -0700 | [diff] [blame] | 1398 | #ifdef CONFIG_64BIT |
| 1399 | /* For use by uaccess.h */ |
| 1400 | u64 __ua_limit; |
| 1401 | EXPORT_SYMBOL(__ua_limit); |
| 1402 | #endif |
| 1403 | |
Ralf Baechle | 9966db25 | 2007-10-11 23:46:17 +0100 | [diff] [blame] | 1404 | const char *__cpu_name[NR_CPUS]; |
David Daney | 874fd3b | 2010-01-28 16:52:12 -0800 | [diff] [blame] | 1405 | const char *__elf_platform; |
Ralf Baechle | 9966db25 | 2007-10-11 23:46:17 +0100 | [diff] [blame] | 1406 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 1407 | void cpu_probe(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1408 | { |
| 1409 | struct cpuinfo_mips *c = ¤t_cpu_data; |
Ralf Baechle | 9966db25 | 2007-10-11 23:46:17 +0100 | [diff] [blame] | 1410 | unsigned int cpu = smp_processor_id(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1411 | |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 1412 | c->processor_id = PRID_IMP_UNKNOWN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1413 | c->fpu_id = FPIR_IMP_NONE; |
| 1414 | c->cputype = CPU_UNKNOWN; |
Markos Chandras | 4f12b91 | 2014-07-18 10:51:32 +0100 | [diff] [blame] | 1415 | c->writecombine = _CACHE_UNCACHED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1416 | |
Maciej W. Rozycki | 9b26616 | 2015-04-03 23:27:48 +0100 | [diff] [blame] | 1417 | c->fpu_csr31 = FPU_CSR_RN; |
| 1418 | c->fpu_msk31 = FPU_CSR_RSVD | FPU_CSR_ABS2008 | FPU_CSR_NAN2008; |
| 1419 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1420 | c->processor_id = read_c0_prid(); |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 1421 | switch (c->processor_id & PRID_COMP_MASK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1422 | case PRID_COMP_LEGACY: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1423 | cpu_probe_legacy(c, cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1424 | break; |
| 1425 | case PRID_COMP_MIPS: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1426 | cpu_probe_mips(c, cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1427 | break; |
| 1428 | case PRID_COMP_ALCHEMY: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1429 | cpu_probe_alchemy(c, cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1430 | break; |
| 1431 | case PRID_COMP_SIBYTE: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1432 | cpu_probe_sibyte(c, cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1433 | break; |
Aurelien Jarno | 1c0c13e | 2007-09-25 15:40:12 +0200 | [diff] [blame] | 1434 | case PRID_COMP_BROADCOM: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1435 | cpu_probe_broadcom(c, cpu); |
Aurelien Jarno | 1c0c13e | 2007-09-25 15:40:12 +0200 | [diff] [blame] | 1436 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1437 | case PRID_COMP_SANDCRAFT: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1438 | cpu_probe_sandcraft(c, cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1439 | break; |
Daniel Laird | a92b058 | 2008-03-06 09:07:18 +0000 | [diff] [blame] | 1440 | case PRID_COMP_NXP: |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1441 | cpu_probe_nxp(c, cpu); |
Ralf Baechle | a3dddd5 | 2006-03-11 08:18:41 +0000 | [diff] [blame] | 1442 | break; |
David Daney | 0dd4781 | 2008-12-11 15:33:26 -0800 | [diff] [blame] | 1443 | case PRID_COMP_CAVIUM: |
| 1444 | cpu_probe_cavium(c, cpu); |
| 1445 | break; |
Paul Burton | 252617a | 2015-05-24 16:11:14 +0100 | [diff] [blame] | 1446 | case PRID_COMP_INGENIC_D0: |
| 1447 | case PRID_COMP_INGENIC_D1: |
| 1448 | case PRID_COMP_INGENIC_E1: |
Lars-Peter Clausen | 83ccf69 | 2010-07-17 11:07:51 +0000 | [diff] [blame] | 1449 | cpu_probe_ingenic(c, cpu); |
| 1450 | break; |
Jayachandran C | a7117c6 | 2011-05-11 12:04:58 +0530 | [diff] [blame] | 1451 | case PRID_COMP_NETLOGIC: |
| 1452 | cpu_probe_netlogic(c, cpu); |
| 1453 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1454 | } |
Franck Bui-Huu | dec8b1c | 2007-10-08 16:11:51 +0200 | [diff] [blame] | 1455 | |
Ralf Baechle | cea7e2d | 2008-10-30 13:38:45 +0000 | [diff] [blame] | 1456 | BUG_ON(!__cpu_name[cpu]); |
| 1457 | BUG_ON(c->cputype == CPU_UNKNOWN); |
| 1458 | |
Franck Bui-Huu | dec8b1c | 2007-10-08 16:11:51 +0200 | [diff] [blame] | 1459 | /* |
| 1460 | * Platform code can force the cpu type to optimize code |
| 1461 | * generation. In that case be sure the cpu type is correctly |
| 1462 | * manually setup otherwise it could trigger some nasty bugs. |
| 1463 | */ |
| 1464 | BUG_ON(current_cpu_type() != c->cputype); |
| 1465 | |
Kevin Cernekee | 0103d23 | 2010-05-02 14:43:52 -0700 | [diff] [blame] | 1466 | if (mips_fpu_disabled) |
| 1467 | c->options &= ~MIPS_CPU_FPU; |
| 1468 | |
| 1469 | if (mips_dsp_disabled) |
Steven J. Hill | ee80f7c7 | 2012-08-03 10:26:04 -0500 | [diff] [blame] | 1470 | c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P); |
Kevin Cernekee | 0103d23 | 2010-05-02 14:43:52 -0700 | [diff] [blame] | 1471 | |
Markos Chandras | 3d528b3 | 2014-07-14 12:46:13 +0100 | [diff] [blame] | 1472 | if (mips_htw_disabled) { |
| 1473 | c->options &= ~MIPS_CPU_HTW; |
| 1474 | write_c0_pwctl(read_c0_pwctl() & |
| 1475 | ~(1 << MIPS_PWCTL_PWEN_SHIFT)); |
| 1476 | } |
| 1477 | |
Maciej W. Rozycki | 7aecd5c | 2015-04-03 23:27:54 +0100 | [diff] [blame] | 1478 | if (c->options & MIPS_CPU_FPU) |
| 1479 | cpu_set_fpu_opts(c); |
| 1480 | else |
| 1481 | cpu_set_nofpu_opts(c); |
Ralf Baechle | 9966db25 | 2007-10-11 23:46:17 +0100 | [diff] [blame] | 1482 | |
Joshua Kinard | 8d5ded1 | 2015-06-02 18:21:33 -0400 | [diff] [blame^] | 1483 | if (cpu_has_bp_ghist) |
| 1484 | write_c0_r10k_diag(read_c0_r10k_diag() | |
| 1485 | R10K_DIAG_E_GHIST); |
| 1486 | |
Leonid Yegoshin | 8b8aa63 | 2014-11-13 13:51:51 +0000 | [diff] [blame] | 1487 | if (cpu_has_mips_r2_r6) { |
Ralf Baechle | f6771db | 2007-11-08 18:02:29 +0000 | [diff] [blame] | 1488 | c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1; |
Al Cooper | da4b62c | 2012-07-13 16:44:51 -0400 | [diff] [blame] | 1489 | /* R2 has Performance Counter Interrupt indicator */ |
| 1490 | c->options |= MIPS_CPU_PCI; |
| 1491 | } |
Ralf Baechle | f6771db | 2007-11-08 18:02:29 +0000 | [diff] [blame] | 1492 | else |
| 1493 | c->srsets = 1; |
Guenter Roeck | 91dfc42 | 2010-02-02 08:52:20 -0800 | [diff] [blame] | 1494 | |
Paul Burton | a8ad136 | 2014-01-28 14:28:43 +0000 | [diff] [blame] | 1495 | if (cpu_has_msa) { |
Paul Burton | a5e9a69 | 2014-01-27 15:23:10 +0000 | [diff] [blame] | 1496 | c->msa_id = cpu_get_msa_id(); |
Paul Burton | a8ad136 | 2014-01-28 14:28:43 +0000 | [diff] [blame] | 1497 | WARN(c->msa_id & MSA_IR_WRPF, |
| 1498 | "Vector register partitioning unimplemented!"); |
| 1499 | } |
Paul Burton | a5e9a69 | 2014-01-27 15:23:10 +0000 | [diff] [blame] | 1500 | |
Guenter Roeck | 91dfc42 | 2010-02-02 08:52:20 -0800 | [diff] [blame] | 1501 | cpu_probe_vmbits(c); |
David Daney | 949e51b | 2010-10-14 11:32:33 -0700 | [diff] [blame] | 1502 | |
| 1503 | #ifdef CONFIG_64BIT |
| 1504 | if (cpu == 0) |
| 1505 | __ua_limit = ~((1ull << cpu_vmbits) - 1); |
| 1506 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1507 | } |
| 1508 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 1509 | void cpu_report(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1510 | { |
| 1511 | struct cpuinfo_mips *c = ¤t_cpu_data; |
| 1512 | |
Leonid Yegoshin | d9f897c | 2013-10-07 10:43:32 +0100 | [diff] [blame] | 1513 | pr_info("CPU%d revision is: %08x (%s)\n", |
| 1514 | smp_processor_id(), c->processor_id, cpu_name_string()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1515 | if (c->options & MIPS_CPU_FPU) |
Ralf Baechle | 9966db25 | 2007-10-11 23:46:17 +0100 | [diff] [blame] | 1516 | printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id); |
Paul Burton | a5e9a69 | 2014-01-27 15:23:10 +0000 | [diff] [blame] | 1517 | if (cpu_has_msa) |
| 1518 | pr_info("MSA revision is: %08x\n", c->msa_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1519 | } |