cpu-probe.c 26 KB

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