cpu-probe.c 25 KB

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