cpu-probe.c 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066
  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/fpu.h>
  23. #include <asm/mipsregs.h>
  24. #include <asm/watch.h>
  25. #include <asm/elf.h>
  26. #include <asm/spram.h>
  27. #include <asm/uaccess.h>
  28. static int __cpuinitdata mips_fpu_disabled;
  29. static int __init fpu_disable(char *s)
  30. {
  31. cpu_data[0].options &= ~MIPS_CPU_FPU;
  32. mips_fpu_disabled = 1;
  33. return 1;
  34. }
  35. __setup("nofpu", fpu_disable);
  36. int __cpuinitdata mips_dsp_disabled;
  37. static int __init dsp_disable(char *s)
  38. {
  39. cpu_data[0].ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
  40. mips_dsp_disabled = 1;
  41. return 1;
  42. }
  43. __setup("nodsp", dsp_disable);
  44. static inline void check_errata(void)
  45. {
  46. struct cpuinfo_mips *c = &current_cpu_data;
  47. switch (c->cputype) {
  48. case CPU_34K:
  49. /*
  50. * Erratum "RPS May Cause Incorrect Instruction Execution"
  51. * This code only handles VPE0, any SMP/SMTC/RTOS code
  52. * making use of VPE1 will be responsable for that VPE.
  53. */
  54. if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
  55. write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
  56. break;
  57. default:
  58. break;
  59. }
  60. }
  61. void __init check_bugs32(void)
  62. {
  63. check_errata();
  64. }
  65. /*
  66. * Probe whether cpu has config register by trying to play with
  67. * alternate cache bit and see whether it matters.
  68. * It's used by cpu_probe to distinguish between R3000A and R3081.
  69. */
  70. static inline int cpu_has_confreg(void)
  71. {
  72. #ifdef CONFIG_CPU_R3000
  73. extern unsigned long r3k_cache_size(unsigned long);
  74. unsigned long size1, size2;
  75. unsigned long cfg = read_c0_conf();
  76. size1 = r3k_cache_size(ST0_ISC);
  77. write_c0_conf(cfg ^ R30XX_CONF_AC);
  78. size2 = r3k_cache_size(ST0_ISC);
  79. write_c0_conf(cfg);
  80. return size1 != size2;
  81. #else
  82. return 0;
  83. #endif
  84. }
  85. static inline void set_elf_platform(int cpu, const char *plat)
  86. {
  87. if (cpu == 0)
  88. __elf_platform = plat;
  89. }
  90. /*
  91. * Get the FPU Implementation/Revision.
  92. */
  93. static inline unsigned long cpu_get_fpu_id(void)
  94. {
  95. unsigned long tmp, fpu_id;
  96. tmp = read_c0_status();
  97. __enable_fpu();
  98. fpu_id = read_32bit_cp1_register(CP1_REVISION);
  99. write_c0_status(tmp);
  100. return fpu_id;
  101. }
  102. /*
  103. * Check the CPU has an FPU the official way.
  104. */
  105. static inline int __cpu_has_fpu(void)
  106. {
  107. return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
  108. }
  109. static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
  110. {
  111. #ifdef __NEED_VMBITS_PROBE
  112. write_c0_entryhi(0x3fffffffffffe000ULL);
  113. back_to_back_c0_hazard();
  114. c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
  115. #endif
  116. }
  117. static void __cpuinit set_isa(struct cpuinfo_mips *c, unsigned int isa)
  118. {
  119. switch (isa) {
  120. case MIPS_CPU_ISA_M64R2:
  121. c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2;
  122. case MIPS_CPU_ISA_M64R1:
  123. c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1;
  124. case MIPS_CPU_ISA_V:
  125. c->isa_level |= MIPS_CPU_ISA_V;
  126. case MIPS_CPU_ISA_IV:
  127. c->isa_level |= MIPS_CPU_ISA_IV;
  128. case MIPS_CPU_ISA_III:
  129. c->isa_level |= MIPS_CPU_ISA_I | MIPS_CPU_ISA_II |
  130. MIPS_CPU_ISA_III;
  131. break;
  132. case MIPS_CPU_ISA_M32R2:
  133. c->isa_level |= MIPS_CPU_ISA_M32R2;
  134. case MIPS_CPU_ISA_M32R1:
  135. c->isa_level |= MIPS_CPU_ISA_M32R1;
  136. case MIPS_CPU_ISA_II:
  137. c->isa_level |= MIPS_CPU_ISA_II;
  138. case MIPS_CPU_ISA_I:
  139. c->isa_level |= MIPS_CPU_ISA_I;
  140. break;
  141. }
  142. }
  143. static char unknown_isa[] __cpuinitdata = KERN_ERR \
  144. "Unsupported ISA type, c0.config0: %d.";
  145. static inline unsigned int decode_config0(struct cpuinfo_mips *c)
  146. {
  147. unsigned int config0;
  148. int isa;
  149. config0 = read_c0_config();
  150. if (((config0 & MIPS_CONF_MT) >> 7) == 1)
  151. c->options |= MIPS_CPU_TLB;
  152. isa = (config0 & MIPS_CONF_AT) >> 13;
  153. switch (isa) {
  154. case 0:
  155. switch ((config0 & MIPS_CONF_AR) >> 10) {
  156. case 0:
  157. set_isa(c, MIPS_CPU_ISA_M32R1);
  158. break;
  159. case 1:
  160. set_isa(c, MIPS_CPU_ISA_M32R2);
  161. break;
  162. default:
  163. goto unknown;
  164. }
  165. break;
  166. case 2:
  167. switch ((config0 & MIPS_CONF_AR) >> 10) {
  168. case 0:
  169. set_isa(c, MIPS_CPU_ISA_M64R1);
  170. break;
  171. case 1:
  172. set_isa(c, MIPS_CPU_ISA_M64R2);
  173. break;
  174. default:
  175. goto unknown;
  176. }
  177. break;
  178. default:
  179. goto unknown;
  180. }
  181. return config0 & MIPS_CONF_M;
  182. unknown:
  183. panic(unknown_isa, config0);
  184. }
  185. static inline unsigned int decode_config1(struct cpuinfo_mips *c)
  186. {
  187. unsigned int config1;
  188. config1 = read_c0_config1();
  189. if (config1 & MIPS_CONF1_MD)
  190. c->ases |= MIPS_ASE_MDMX;
  191. if (config1 & MIPS_CONF1_WR)
  192. c->options |= MIPS_CPU_WATCH;
  193. if (config1 & MIPS_CONF1_CA)
  194. c->ases |= MIPS_ASE_MIPS16;
  195. if (config1 & MIPS_CONF1_EP)
  196. c->options |= MIPS_CPU_EJTAG;
  197. if (config1 & MIPS_CONF1_FP) {
  198. c->options |= MIPS_CPU_FPU;
  199. c->options |= MIPS_CPU_32FPR;
  200. }
  201. if (cpu_has_tlb)
  202. c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
  203. return config1 & MIPS_CONF_M;
  204. }
  205. static inline unsigned int decode_config2(struct cpuinfo_mips *c)
  206. {
  207. unsigned int config2;
  208. config2 = read_c0_config2();
  209. if (config2 & MIPS_CONF2_SL)
  210. c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
  211. return config2 & MIPS_CONF_M;
  212. }
  213. static inline unsigned int decode_config3(struct cpuinfo_mips *c)
  214. {
  215. unsigned int config3;
  216. config3 = read_c0_config3();
  217. if (config3 & MIPS_CONF3_SM) {
  218. c->ases |= MIPS_ASE_SMARTMIPS;
  219. c->options |= MIPS_CPU_RIXI;
  220. }
  221. if (config3 & MIPS_CONF3_RXI)
  222. c->options |= MIPS_CPU_RIXI;
  223. if (config3 & MIPS_CONF3_DSP)
  224. c->ases |= MIPS_ASE_DSP;
  225. if (config3 & MIPS_CONF3_DSP2P)
  226. c->ases |= MIPS_ASE_DSP2P;
  227. if (config3 & MIPS_CONF3_VINT)
  228. c->options |= MIPS_CPU_VINT;
  229. if (config3 & MIPS_CONF3_VEIC)
  230. c->options |= MIPS_CPU_VEIC;
  231. if (config3 & MIPS_CONF3_MT)
  232. c->ases |= MIPS_ASE_MIPSMT;
  233. if (config3 & MIPS_CONF3_ULRI)
  234. c->options |= MIPS_CPU_ULRI;
  235. if (config3 & MIPS_CONF3_ISA)
  236. c->options |= MIPS_CPU_MICROMIPS;
  237. #ifdef CONFIG_CPU_MICROMIPS
  238. write_c0_config3(read_c0_config3() | MIPS_CONF3_ISA_OE);
  239. #endif
  240. if (config3 & MIPS_CONF3_VZ)
  241. c->ases |= MIPS_ASE_VZ;
  242. return config3 & MIPS_CONF_M;
  243. }
  244. static inline unsigned int decode_config4(struct cpuinfo_mips *c)
  245. {
  246. unsigned int config4;
  247. config4 = read_c0_config4();
  248. if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
  249. && cpu_has_tlb)
  250. c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
  251. c->kscratch_mask = (config4 >> 16) & 0xff;
  252. return config4 & MIPS_CONF_M;
  253. }
  254. static void __cpuinit decode_configs(struct cpuinfo_mips *c)
  255. {
  256. int ok;
  257. /* MIPS32 or MIPS64 compliant CPU. */
  258. c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
  259. MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
  260. c->scache.flags = MIPS_CACHE_NOT_PRESENT;
  261. ok = decode_config0(c); /* Read Config registers. */
  262. BUG_ON(!ok); /* Arch spec violation! */
  263. if (ok)
  264. ok = decode_config1(c);
  265. if (ok)
  266. ok = decode_config2(c);
  267. if (ok)
  268. ok = decode_config3(c);
  269. if (ok)
  270. ok = decode_config4(c);
  271. mips_probe_watch_registers(c);
  272. if (cpu_has_mips_r2)
  273. c->core = read_c0_ebase() & 0x3ff;
  274. }
  275. #define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
  276. | MIPS_CPU_COUNTER)
  277. static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
  278. {
  279. switch (c->processor_id & 0xff00) {
  280. case PRID_IMP_R2000:
  281. c->cputype = CPU_R2000;
  282. __cpu_name[cpu] = "R2000";
  283. set_isa(c, MIPS_CPU_ISA_I);
  284. c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
  285. MIPS_CPU_NOFPUEX;
  286. if (__cpu_has_fpu())
  287. c->options |= MIPS_CPU_FPU;
  288. c->tlbsize = 64;
  289. break;
  290. case PRID_IMP_R3000:
  291. if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
  292. if (cpu_has_confreg()) {
  293. c->cputype = CPU_R3081E;
  294. __cpu_name[cpu] = "R3081";
  295. } else {
  296. c->cputype = CPU_R3000A;
  297. __cpu_name[cpu] = "R3000A";
  298. }
  299. } else {
  300. c->cputype = CPU_R3000;
  301. __cpu_name[cpu] = "R3000";
  302. }
  303. set_isa(c, MIPS_CPU_ISA_I);
  304. c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
  305. MIPS_CPU_NOFPUEX;
  306. if (__cpu_has_fpu())
  307. c->options |= MIPS_CPU_FPU;
  308. c->tlbsize = 64;
  309. break;
  310. case PRID_IMP_R4000:
  311. if (read_c0_config() & CONF_SC) {
  312. if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
  313. c->cputype = CPU_R4400PC;
  314. __cpu_name[cpu] = "R4400PC";
  315. } else {
  316. c->cputype = CPU_R4000PC;
  317. __cpu_name[cpu] = "R4000PC";
  318. }
  319. } else {
  320. if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
  321. c->cputype = CPU_R4400SC;
  322. __cpu_name[cpu] = "R4400SC";
  323. } else {
  324. c->cputype = CPU_R4000SC;
  325. __cpu_name[cpu] = "R4000SC";
  326. }
  327. }
  328. set_isa(c, MIPS_CPU_ISA_III);
  329. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  330. MIPS_CPU_WATCH | MIPS_CPU_VCE |
  331. MIPS_CPU_LLSC;
  332. c->tlbsize = 48;
  333. break;
  334. case PRID_IMP_VR41XX:
  335. set_isa(c, MIPS_CPU_ISA_III);
  336. c->options = R4K_OPTS;
  337. c->tlbsize = 32;
  338. switch (c->processor_id & 0xf0) {
  339. case PRID_REV_VR4111:
  340. c->cputype = CPU_VR4111;
  341. __cpu_name[cpu] = "NEC VR4111";
  342. break;
  343. case PRID_REV_VR4121:
  344. c->cputype = CPU_VR4121;
  345. __cpu_name[cpu] = "NEC VR4121";
  346. break;
  347. case PRID_REV_VR4122:
  348. if ((c->processor_id & 0xf) < 0x3) {
  349. c->cputype = CPU_VR4122;
  350. __cpu_name[cpu] = "NEC VR4122";
  351. } else {
  352. c->cputype = CPU_VR4181A;
  353. __cpu_name[cpu] = "NEC VR4181A";
  354. }
  355. break;
  356. case PRID_REV_VR4130:
  357. if ((c->processor_id & 0xf) < 0x4) {
  358. c->cputype = CPU_VR4131;
  359. __cpu_name[cpu] = "NEC VR4131";
  360. } else {
  361. c->cputype = CPU_VR4133;
  362. c->options |= MIPS_CPU_LLSC;
  363. __cpu_name[cpu] = "NEC VR4133";
  364. }
  365. break;
  366. default:
  367. printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
  368. c->cputype = CPU_VR41XX;
  369. __cpu_name[cpu] = "NEC Vr41xx";
  370. break;
  371. }
  372. break;
  373. case PRID_IMP_R4300:
  374. c->cputype = CPU_R4300;
  375. __cpu_name[cpu] = "R4300";
  376. set_isa(c, MIPS_CPU_ISA_III);
  377. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  378. MIPS_CPU_LLSC;
  379. c->tlbsize = 32;
  380. break;
  381. case PRID_IMP_R4600:
  382. c->cputype = CPU_R4600;
  383. __cpu_name[cpu] = "R4600";
  384. set_isa(c, MIPS_CPU_ISA_III);
  385. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  386. MIPS_CPU_LLSC;
  387. c->tlbsize = 48;
  388. break;
  389. #if 0
  390. case PRID_IMP_R4650:
  391. /*
  392. * This processor doesn't have an MMU, so it's not
  393. * "real easy" to run Linux on it. It is left purely
  394. * for documentation. Commented out because it shares
  395. * it's c0_prid id number with the TX3900.
  396. */
  397. c->cputype = CPU_R4650;
  398. __cpu_name[cpu] = "R4650";
  399. set_isa(c, MIPS_CPU_ISA_III);
  400. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
  401. c->tlbsize = 48;
  402. break;
  403. #endif
  404. case PRID_IMP_TX39:
  405. set_isa(c, MIPS_CPU_ISA_I);
  406. c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
  407. if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
  408. c->cputype = CPU_TX3927;
  409. __cpu_name[cpu] = "TX3927";
  410. c->tlbsize = 64;
  411. } else {
  412. switch (c->processor_id & 0xff) {
  413. case PRID_REV_TX3912:
  414. c->cputype = CPU_TX3912;
  415. __cpu_name[cpu] = "TX3912";
  416. c->tlbsize = 32;
  417. break;
  418. case PRID_REV_TX3922:
  419. c->cputype = CPU_TX3922;
  420. __cpu_name[cpu] = "TX3922";
  421. c->tlbsize = 64;
  422. break;
  423. }
  424. }
  425. break;
  426. case PRID_IMP_R4700:
  427. c->cputype = CPU_R4700;
  428. __cpu_name[cpu] = "R4700";
  429. set_isa(c, MIPS_CPU_ISA_III);
  430. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  431. MIPS_CPU_LLSC;
  432. c->tlbsize = 48;
  433. break;
  434. case PRID_IMP_TX49:
  435. c->cputype = CPU_TX49XX;
  436. __cpu_name[cpu] = "R49XX";
  437. set_isa(c, MIPS_CPU_ISA_III);
  438. c->options = R4K_OPTS | MIPS_CPU_LLSC;
  439. if (!(c->processor_id & 0x08))
  440. c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
  441. c->tlbsize = 48;
  442. break;
  443. case PRID_IMP_R5000:
  444. c->cputype = CPU_R5000;
  445. __cpu_name[cpu] = "R5000";
  446. set_isa(c, MIPS_CPU_ISA_IV);
  447. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  448. MIPS_CPU_LLSC;
  449. c->tlbsize = 48;
  450. break;
  451. case PRID_IMP_R5432:
  452. c->cputype = CPU_R5432;
  453. __cpu_name[cpu] = "R5432";
  454. set_isa(c, MIPS_CPU_ISA_IV);
  455. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  456. MIPS_CPU_WATCH | MIPS_CPU_LLSC;
  457. c->tlbsize = 48;
  458. break;
  459. case PRID_IMP_R5500:
  460. c->cputype = CPU_R5500;
  461. __cpu_name[cpu] = "R5500";
  462. set_isa(c, MIPS_CPU_ISA_IV);
  463. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  464. MIPS_CPU_WATCH | MIPS_CPU_LLSC;
  465. c->tlbsize = 48;
  466. break;
  467. case PRID_IMP_NEVADA:
  468. c->cputype = CPU_NEVADA;
  469. __cpu_name[cpu] = "Nevada";
  470. set_isa(c, MIPS_CPU_ISA_IV);
  471. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  472. MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
  473. c->tlbsize = 48;
  474. break;
  475. case PRID_IMP_R6000:
  476. c->cputype = CPU_R6000;
  477. __cpu_name[cpu] = "R6000";
  478. set_isa(c, MIPS_CPU_ISA_II);
  479. c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
  480. MIPS_CPU_LLSC;
  481. c->tlbsize = 32;
  482. break;
  483. case PRID_IMP_R6000A:
  484. c->cputype = CPU_R6000A;
  485. __cpu_name[cpu] = "R6000A";
  486. set_isa(c, MIPS_CPU_ISA_II);
  487. c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
  488. MIPS_CPU_LLSC;
  489. c->tlbsize = 32;
  490. break;
  491. case PRID_IMP_RM7000:
  492. c->cputype = CPU_RM7000;
  493. __cpu_name[cpu] = "RM7000";
  494. set_isa(c, MIPS_CPU_ISA_IV);
  495. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  496. MIPS_CPU_LLSC;
  497. /*
  498. * Undocumented RM7000: Bit 29 in the info register of
  499. * the RM7000 v2.0 indicates if the TLB has 48 or 64
  500. * entries.
  501. *
  502. * 29 1 => 64 entry JTLB
  503. * 0 => 48 entry JTLB
  504. */
  505. c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
  506. break;
  507. case PRID_IMP_RM9000:
  508. c->cputype = CPU_RM9000;
  509. __cpu_name[cpu] = "RM9000";
  510. set_isa(c, MIPS_CPU_ISA_IV);
  511. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  512. MIPS_CPU_LLSC;
  513. /*
  514. * Bit 29 in the info register of the RM9000
  515. * indicates if the TLB has 48 or 64 entries.
  516. *
  517. * 29 1 => 64 entry JTLB
  518. * 0 => 48 entry JTLB
  519. */
  520. c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
  521. break;
  522. case PRID_IMP_R8000:
  523. c->cputype = CPU_R8000;
  524. __cpu_name[cpu] = "RM8000";
  525. set_isa(c, MIPS_CPU_ISA_IV);
  526. c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
  527. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  528. MIPS_CPU_LLSC;
  529. c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
  530. break;
  531. case PRID_IMP_R10000:
  532. c->cputype = CPU_R10000;
  533. __cpu_name[cpu] = "R10000";
  534. set_isa(c, MIPS_CPU_ISA_IV);
  535. c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
  536. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  537. MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
  538. MIPS_CPU_LLSC;
  539. c->tlbsize = 64;
  540. break;
  541. case PRID_IMP_R12000:
  542. c->cputype = CPU_R12000;
  543. __cpu_name[cpu] = "R12000";
  544. set_isa(c, MIPS_CPU_ISA_IV);
  545. c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
  546. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  547. MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
  548. MIPS_CPU_LLSC;
  549. c->tlbsize = 64;
  550. break;
  551. case PRID_IMP_R14000:
  552. c->cputype = CPU_R14000;
  553. __cpu_name[cpu] = "R14000";
  554. set_isa(c, MIPS_CPU_ISA_IV);
  555. c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
  556. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  557. MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
  558. MIPS_CPU_LLSC;
  559. c->tlbsize = 64;
  560. break;
  561. case PRID_IMP_LOONGSON2:
  562. c->cputype = CPU_LOONGSON2;
  563. __cpu_name[cpu] = "ICT Loongson-2";
  564. switch (c->processor_id & PRID_REV_MASK) {
  565. case PRID_REV_LOONGSON2E:
  566. set_elf_platform(cpu, "loongson2e");
  567. break;
  568. case PRID_REV_LOONGSON2F:
  569. set_elf_platform(cpu, "loongson2f");
  570. break;
  571. }
  572. set_isa(c, MIPS_CPU_ISA_III);
  573. c->options = R4K_OPTS |
  574. MIPS_CPU_FPU | MIPS_CPU_LLSC |
  575. MIPS_CPU_32FPR;
  576. c->tlbsize = 64;
  577. break;
  578. case PRID_IMP_LOONGSON1:
  579. decode_configs(c);
  580. c->cputype = CPU_LOONGSON1;
  581. switch (c->processor_id & PRID_REV_MASK) {
  582. case PRID_REV_LOONGSON1B:
  583. __cpu_name[cpu] = "Loongson 1B";
  584. break;
  585. }
  586. break;
  587. }
  588. }
  589. static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
  590. {
  591. decode_configs(c);
  592. switch (c->processor_id & 0xff00) {
  593. case PRID_IMP_4KC:
  594. c->cputype = CPU_4KC;
  595. __cpu_name[cpu] = "MIPS 4Kc";
  596. break;
  597. case PRID_IMP_4KEC:
  598. case PRID_IMP_4KECR2:
  599. c->cputype = CPU_4KEC;
  600. __cpu_name[cpu] = "MIPS 4KEc";
  601. break;
  602. case PRID_IMP_4KSC:
  603. case PRID_IMP_4KSD:
  604. c->cputype = CPU_4KSC;
  605. __cpu_name[cpu] = "MIPS 4KSc";
  606. break;
  607. case PRID_IMP_5KC:
  608. c->cputype = CPU_5KC;
  609. __cpu_name[cpu] = "MIPS 5Kc";
  610. break;
  611. case PRID_IMP_5KE:
  612. c->cputype = CPU_5KE;
  613. __cpu_name[cpu] = "MIPS 5KE";
  614. break;
  615. case PRID_IMP_20KC:
  616. c->cputype = CPU_20KC;
  617. __cpu_name[cpu] = "MIPS 20Kc";
  618. break;
  619. case PRID_IMP_24K:
  620. c->cputype = CPU_24K;
  621. __cpu_name[cpu] = "MIPS 24Kc";
  622. break;
  623. case PRID_IMP_24KE:
  624. c->cputype = CPU_24K;
  625. __cpu_name[cpu] = "MIPS 24KEc";
  626. break;
  627. case PRID_IMP_25KF:
  628. c->cputype = CPU_25KF;
  629. __cpu_name[cpu] = "MIPS 25Kc";
  630. break;
  631. case PRID_IMP_34K:
  632. c->cputype = CPU_34K;
  633. __cpu_name[cpu] = "MIPS 34Kc";
  634. break;
  635. case PRID_IMP_74K:
  636. c->cputype = CPU_74K;
  637. __cpu_name[cpu] = "MIPS 74Kc";
  638. break;
  639. case PRID_IMP_M14KC:
  640. c->cputype = CPU_M14KC;
  641. __cpu_name[cpu] = "MIPS M14Kc";
  642. break;
  643. case PRID_IMP_M14KEC:
  644. c->cputype = CPU_M14KEC;
  645. __cpu_name[cpu] = "MIPS M14KEc";
  646. break;
  647. case PRID_IMP_1004K:
  648. c->cputype = CPU_1004K;
  649. __cpu_name[cpu] = "MIPS 1004Kc";
  650. break;
  651. case PRID_IMP_1074K:
  652. c->cputype = CPU_74K;
  653. __cpu_name[cpu] = "MIPS 1074Kc";
  654. break;
  655. }
  656. spram_config();
  657. }
  658. static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
  659. {
  660. decode_configs(c);
  661. switch (c->processor_id & 0xff00) {
  662. case PRID_IMP_AU1_REV1:
  663. case PRID_IMP_AU1_REV2:
  664. c->cputype = CPU_ALCHEMY;
  665. switch ((c->processor_id >> 24) & 0xff) {
  666. case 0:
  667. __cpu_name[cpu] = "Au1000";
  668. break;
  669. case 1:
  670. __cpu_name[cpu] = "Au1500";
  671. break;
  672. case 2:
  673. __cpu_name[cpu] = "Au1100";
  674. break;
  675. case 3:
  676. __cpu_name[cpu] = "Au1550";
  677. break;
  678. case 4:
  679. __cpu_name[cpu] = "Au1200";
  680. if ((c->processor_id & 0xff) == 2)
  681. __cpu_name[cpu] = "Au1250";
  682. break;
  683. case 5:
  684. __cpu_name[cpu] = "Au1210";
  685. break;
  686. default:
  687. __cpu_name[cpu] = "Au1xxx";
  688. break;
  689. }
  690. break;
  691. }
  692. }
  693. static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
  694. {
  695. decode_configs(c);
  696. switch (c->processor_id & 0xff00) {
  697. case PRID_IMP_SB1:
  698. c->cputype = CPU_SB1;
  699. __cpu_name[cpu] = "SiByte SB1";
  700. /* FPU in pass1 is known to have issues. */
  701. if ((c->processor_id & 0xff) < 0x02)
  702. c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
  703. break;
  704. case PRID_IMP_SB1A:
  705. c->cputype = CPU_SB1A;
  706. __cpu_name[cpu] = "SiByte SB1A";
  707. break;
  708. }
  709. }
  710. static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
  711. {
  712. decode_configs(c);
  713. switch (c->processor_id & 0xff00) {
  714. case PRID_IMP_SR71000:
  715. c->cputype = CPU_SR71000;
  716. __cpu_name[cpu] = "Sandcraft SR71000";
  717. c->scache.ways = 8;
  718. c->tlbsize = 64;
  719. break;
  720. }
  721. }
  722. static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
  723. {
  724. decode_configs(c);
  725. switch (c->processor_id & 0xff00) {
  726. case PRID_IMP_PR4450:
  727. c->cputype = CPU_PR4450;
  728. __cpu_name[cpu] = "Philips PR4450";
  729. set_isa(c, MIPS_CPU_ISA_M32R1);
  730. break;
  731. }
  732. }
  733. static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
  734. {
  735. decode_configs(c);
  736. switch (c->processor_id & 0xff00) {
  737. case PRID_IMP_BMIPS32_REV4:
  738. case PRID_IMP_BMIPS32_REV8:
  739. c->cputype = CPU_BMIPS32;
  740. __cpu_name[cpu] = "Broadcom BMIPS32";
  741. set_elf_platform(cpu, "bmips32");
  742. break;
  743. case PRID_IMP_BMIPS3300:
  744. case PRID_IMP_BMIPS3300_ALT:
  745. case PRID_IMP_BMIPS3300_BUG:
  746. c->cputype = CPU_BMIPS3300;
  747. __cpu_name[cpu] = "Broadcom BMIPS3300";
  748. set_elf_platform(cpu, "bmips3300");
  749. break;
  750. case PRID_IMP_BMIPS43XX: {
  751. int rev = c->processor_id & 0xff;
  752. if (rev >= PRID_REV_BMIPS4380_LO &&
  753. rev <= PRID_REV_BMIPS4380_HI) {
  754. c->cputype = CPU_BMIPS4380;
  755. __cpu_name[cpu] = "Broadcom BMIPS4380";
  756. set_elf_platform(cpu, "bmips4380");
  757. } else {
  758. c->cputype = CPU_BMIPS4350;
  759. __cpu_name[cpu] = "Broadcom BMIPS4350";
  760. set_elf_platform(cpu, "bmips4350");
  761. }
  762. break;
  763. }
  764. case PRID_IMP_BMIPS5000:
  765. c->cputype = CPU_BMIPS5000;
  766. __cpu_name[cpu] = "Broadcom BMIPS5000";
  767. set_elf_platform(cpu, "bmips5000");
  768. c->options |= MIPS_CPU_ULRI;
  769. break;
  770. }
  771. }
  772. static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
  773. {
  774. decode_configs(c);
  775. switch (c->processor_id & 0xff00) {
  776. case PRID_IMP_CAVIUM_CN38XX:
  777. case PRID_IMP_CAVIUM_CN31XX:
  778. case PRID_IMP_CAVIUM_CN30XX:
  779. c->cputype = CPU_CAVIUM_OCTEON;
  780. __cpu_name[cpu] = "Cavium Octeon";
  781. goto platform;
  782. case PRID_IMP_CAVIUM_CN58XX:
  783. case PRID_IMP_CAVIUM_CN56XX:
  784. case PRID_IMP_CAVIUM_CN50XX:
  785. case PRID_IMP_CAVIUM_CN52XX:
  786. c->cputype = CPU_CAVIUM_OCTEON_PLUS;
  787. __cpu_name[cpu] = "Cavium Octeon+";
  788. platform:
  789. set_elf_platform(cpu, "octeon");
  790. break;
  791. case PRID_IMP_CAVIUM_CN61XX:
  792. case PRID_IMP_CAVIUM_CN63XX:
  793. case PRID_IMP_CAVIUM_CN66XX:
  794. case PRID_IMP_CAVIUM_CN68XX:
  795. c->cputype = CPU_CAVIUM_OCTEON2;
  796. __cpu_name[cpu] = "Cavium Octeon II";
  797. set_elf_platform(cpu, "octeon2");
  798. break;
  799. default:
  800. printk(KERN_INFO "Unknown Octeon chip!\n");
  801. c->cputype = CPU_UNKNOWN;
  802. break;
  803. }
  804. }
  805. static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
  806. {
  807. decode_configs(c);
  808. /* JZRISC does not implement the CP0 counter. */
  809. c->options &= ~MIPS_CPU_COUNTER;
  810. switch (c->processor_id & 0xff00) {
  811. case PRID_IMP_JZRISC:
  812. c->cputype = CPU_JZRISC;
  813. __cpu_name[cpu] = "Ingenic JZRISC";
  814. break;
  815. default:
  816. panic("Unknown Ingenic Processor ID!");
  817. break;
  818. }
  819. }
  820. static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
  821. {
  822. decode_configs(c);
  823. if ((c->processor_id & 0xff00) == PRID_IMP_NETLOGIC_AU13XX) {
  824. c->cputype = CPU_ALCHEMY;
  825. __cpu_name[cpu] = "Au1300";
  826. /* following stuff is not for Alchemy */
  827. return;
  828. }
  829. c->options = (MIPS_CPU_TLB |
  830. MIPS_CPU_4KEX |
  831. MIPS_CPU_COUNTER |
  832. MIPS_CPU_DIVEC |
  833. MIPS_CPU_WATCH |
  834. MIPS_CPU_EJTAG |
  835. MIPS_CPU_LLSC);
  836. switch (c->processor_id & 0xff00) {
  837. case PRID_IMP_NETLOGIC_XLP8XX:
  838. case PRID_IMP_NETLOGIC_XLP3XX:
  839. c->cputype = CPU_XLP;
  840. __cpu_name[cpu] = "Netlogic XLP";
  841. break;
  842. case PRID_IMP_NETLOGIC_XLR732:
  843. case PRID_IMP_NETLOGIC_XLR716:
  844. case PRID_IMP_NETLOGIC_XLR532:
  845. case PRID_IMP_NETLOGIC_XLR308:
  846. case PRID_IMP_NETLOGIC_XLR532C:
  847. case PRID_IMP_NETLOGIC_XLR516C:
  848. case PRID_IMP_NETLOGIC_XLR508C:
  849. case PRID_IMP_NETLOGIC_XLR308C:
  850. c->cputype = CPU_XLR;
  851. __cpu_name[cpu] = "Netlogic XLR";
  852. break;
  853. case PRID_IMP_NETLOGIC_XLS608:
  854. case PRID_IMP_NETLOGIC_XLS408:
  855. case PRID_IMP_NETLOGIC_XLS404:
  856. case PRID_IMP_NETLOGIC_XLS208:
  857. case PRID_IMP_NETLOGIC_XLS204:
  858. case PRID_IMP_NETLOGIC_XLS108:
  859. case PRID_IMP_NETLOGIC_XLS104:
  860. case PRID_IMP_NETLOGIC_XLS616B:
  861. case PRID_IMP_NETLOGIC_XLS608B:
  862. case PRID_IMP_NETLOGIC_XLS416B:
  863. case PRID_IMP_NETLOGIC_XLS412B:
  864. case PRID_IMP_NETLOGIC_XLS408B:
  865. case PRID_IMP_NETLOGIC_XLS404B:
  866. c->cputype = CPU_XLR;
  867. __cpu_name[cpu] = "Netlogic XLS";
  868. break;
  869. default:
  870. pr_info("Unknown Netlogic chip id [%02x]!\n",
  871. c->processor_id);
  872. c->cputype = CPU_XLR;
  873. break;
  874. }
  875. if (c->cputype == CPU_XLP) {
  876. set_isa(c, MIPS_CPU_ISA_M64R2);
  877. c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
  878. /* This will be updated again after all threads are woken up */
  879. c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
  880. } else {
  881. set_isa(c, MIPS_CPU_ISA_M64R1);
  882. c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
  883. }
  884. }
  885. #ifdef CONFIG_64BIT
  886. /* For use by uaccess.h */
  887. u64 __ua_limit;
  888. EXPORT_SYMBOL(__ua_limit);
  889. #endif
  890. const char *__cpu_name[NR_CPUS];
  891. const char *__elf_platform;
  892. __cpuinit void cpu_probe(void)
  893. {
  894. struct cpuinfo_mips *c = &current_cpu_data;
  895. unsigned int cpu = smp_processor_id();
  896. c->processor_id = PRID_IMP_UNKNOWN;
  897. c->fpu_id = FPIR_IMP_NONE;
  898. c->cputype = CPU_UNKNOWN;
  899. c->processor_id = read_c0_prid();
  900. switch (c->processor_id & 0xff0000) {
  901. case PRID_COMP_LEGACY:
  902. cpu_probe_legacy(c, cpu);
  903. break;
  904. case PRID_COMP_MIPS:
  905. cpu_probe_mips(c, cpu);
  906. break;
  907. case PRID_COMP_ALCHEMY:
  908. cpu_probe_alchemy(c, cpu);
  909. break;
  910. case PRID_COMP_SIBYTE:
  911. cpu_probe_sibyte(c, cpu);
  912. break;
  913. case PRID_COMP_BROADCOM:
  914. cpu_probe_broadcom(c, cpu);
  915. break;
  916. case PRID_COMP_SANDCRAFT:
  917. cpu_probe_sandcraft(c, cpu);
  918. break;
  919. case PRID_COMP_NXP:
  920. cpu_probe_nxp(c, cpu);
  921. break;
  922. case PRID_COMP_CAVIUM:
  923. cpu_probe_cavium(c, cpu);
  924. break;
  925. case PRID_COMP_INGENIC:
  926. cpu_probe_ingenic(c, cpu);
  927. break;
  928. case PRID_COMP_NETLOGIC:
  929. cpu_probe_netlogic(c, cpu);
  930. break;
  931. }
  932. BUG_ON(!__cpu_name[cpu]);
  933. BUG_ON(c->cputype == CPU_UNKNOWN);
  934. /*
  935. * Platform code can force the cpu type to optimize code
  936. * generation. In that case be sure the cpu type is correctly
  937. * manually setup otherwise it could trigger some nasty bugs.
  938. */
  939. BUG_ON(current_cpu_type() != c->cputype);
  940. if (mips_fpu_disabled)
  941. c->options &= ~MIPS_CPU_FPU;
  942. if (mips_dsp_disabled)
  943. c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
  944. if (c->options & MIPS_CPU_FPU) {
  945. c->fpu_id = cpu_get_fpu_id();
  946. if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2 |
  947. MIPS_CPU_ISA_M64R1 | MIPS_CPU_ISA_M64R2)) {
  948. if (c->fpu_id & MIPS_FPIR_3D)
  949. c->ases |= MIPS_ASE_MIPS3D;
  950. }
  951. }
  952. if (cpu_has_mips_r2) {
  953. c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
  954. /* R2 has Performance Counter Interrupt indicator */
  955. c->options |= MIPS_CPU_PCI;
  956. }
  957. else
  958. c->srsets = 1;
  959. cpu_probe_vmbits(c);
  960. #ifdef CONFIG_64BIT
  961. if (cpu == 0)
  962. __ua_limit = ~((1ull << cpu_vmbits) - 1);
  963. #endif
  964. }
  965. __cpuinit void cpu_report(void)
  966. {
  967. struct cpuinfo_mips *c = &current_cpu_data;
  968. printk(KERN_INFO "CPU revision is: %08x (%s)\n",
  969. c->processor_id, cpu_name_string());
  970. if (c->options & MIPS_CPU_FPU)
  971. printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
  972. }