cpu-probe.c 29 KB

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