cpu-probe.c 42 KB

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