cpu-probe.c 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086
  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. if ((c->processor_id & PRID_REV_MASK) >=
  325. PRID_REV_R4400) {
  326. c->cputype = CPU_R4400SC;
  327. __cpu_name[cpu] = "R4400SC";
  328. } else {
  329. c->cputype = CPU_R4000SC;
  330. __cpu_name[cpu] = "R4000SC";
  331. }
  332. }
  333. set_isa(c, MIPS_CPU_ISA_III);
  334. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  335. MIPS_CPU_WATCH | MIPS_CPU_VCE |
  336. MIPS_CPU_LLSC;
  337. c->tlbsize = 48;
  338. break;
  339. case PRID_IMP_VR41XX:
  340. set_isa(c, MIPS_CPU_ISA_III);
  341. c->options = R4K_OPTS;
  342. c->tlbsize = 32;
  343. switch (c->processor_id & 0xf0) {
  344. case PRID_REV_VR4111:
  345. c->cputype = CPU_VR4111;
  346. __cpu_name[cpu] = "NEC VR4111";
  347. break;
  348. case PRID_REV_VR4121:
  349. c->cputype = CPU_VR4121;
  350. __cpu_name[cpu] = "NEC VR4121";
  351. break;
  352. case PRID_REV_VR4122:
  353. if ((c->processor_id & 0xf) < 0x3) {
  354. c->cputype = CPU_VR4122;
  355. __cpu_name[cpu] = "NEC VR4122";
  356. } else {
  357. c->cputype = CPU_VR4181A;
  358. __cpu_name[cpu] = "NEC VR4181A";
  359. }
  360. break;
  361. case PRID_REV_VR4130:
  362. if ((c->processor_id & 0xf) < 0x4) {
  363. c->cputype = CPU_VR4131;
  364. __cpu_name[cpu] = "NEC VR4131";
  365. } else {
  366. c->cputype = CPU_VR4133;
  367. c->options |= MIPS_CPU_LLSC;
  368. __cpu_name[cpu] = "NEC VR4133";
  369. }
  370. break;
  371. default:
  372. printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
  373. c->cputype = CPU_VR41XX;
  374. __cpu_name[cpu] = "NEC Vr41xx";
  375. break;
  376. }
  377. break;
  378. case PRID_IMP_R4300:
  379. c->cputype = CPU_R4300;
  380. __cpu_name[cpu] = "R4300";
  381. set_isa(c, MIPS_CPU_ISA_III);
  382. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  383. MIPS_CPU_LLSC;
  384. c->tlbsize = 32;
  385. break;
  386. case PRID_IMP_R4600:
  387. c->cputype = CPU_R4600;
  388. __cpu_name[cpu] = "R4600";
  389. set_isa(c, MIPS_CPU_ISA_III);
  390. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  391. MIPS_CPU_LLSC;
  392. c->tlbsize = 48;
  393. break;
  394. #if 0
  395. case PRID_IMP_R4650:
  396. /*
  397. * This processor doesn't have an MMU, so it's not
  398. * "real easy" to run Linux on it. It is left purely
  399. * for documentation. Commented out because it shares
  400. * it's c0_prid id number with the TX3900.
  401. */
  402. c->cputype = CPU_R4650;
  403. __cpu_name[cpu] = "R4650";
  404. set_isa(c, MIPS_CPU_ISA_III);
  405. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
  406. c->tlbsize = 48;
  407. break;
  408. #endif
  409. case PRID_IMP_TX39:
  410. c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
  411. if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
  412. c->cputype = CPU_TX3927;
  413. __cpu_name[cpu] = "TX3927";
  414. c->tlbsize = 64;
  415. } else {
  416. switch (c->processor_id & PRID_REV_MASK) {
  417. case PRID_REV_TX3912:
  418. c->cputype = CPU_TX3912;
  419. __cpu_name[cpu] = "TX3912";
  420. c->tlbsize = 32;
  421. break;
  422. case PRID_REV_TX3922:
  423. c->cputype = CPU_TX3922;
  424. __cpu_name[cpu] = "TX3922";
  425. c->tlbsize = 64;
  426. break;
  427. }
  428. }
  429. break;
  430. case PRID_IMP_R4700:
  431. c->cputype = CPU_R4700;
  432. __cpu_name[cpu] = "R4700";
  433. set_isa(c, MIPS_CPU_ISA_III);
  434. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  435. MIPS_CPU_LLSC;
  436. c->tlbsize = 48;
  437. break;
  438. case PRID_IMP_TX49:
  439. c->cputype = CPU_TX49XX;
  440. __cpu_name[cpu] = "R49XX";
  441. set_isa(c, MIPS_CPU_ISA_III);
  442. c->options = R4K_OPTS | MIPS_CPU_LLSC;
  443. if (!(c->processor_id & 0x08))
  444. c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
  445. c->tlbsize = 48;
  446. break;
  447. case PRID_IMP_R5000:
  448. c->cputype = CPU_R5000;
  449. __cpu_name[cpu] = "R5000";
  450. set_isa(c, MIPS_CPU_ISA_IV);
  451. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  452. MIPS_CPU_LLSC;
  453. c->tlbsize = 48;
  454. break;
  455. case PRID_IMP_R5432:
  456. c->cputype = CPU_R5432;
  457. __cpu_name[cpu] = "R5432";
  458. set_isa(c, MIPS_CPU_ISA_IV);
  459. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  460. MIPS_CPU_WATCH | MIPS_CPU_LLSC;
  461. c->tlbsize = 48;
  462. break;
  463. case PRID_IMP_R5500:
  464. c->cputype = CPU_R5500;
  465. __cpu_name[cpu] = "R5500";
  466. set_isa(c, MIPS_CPU_ISA_IV);
  467. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  468. MIPS_CPU_WATCH | MIPS_CPU_LLSC;
  469. c->tlbsize = 48;
  470. break;
  471. case PRID_IMP_NEVADA:
  472. c->cputype = CPU_NEVADA;
  473. __cpu_name[cpu] = "Nevada";
  474. set_isa(c, MIPS_CPU_ISA_IV);
  475. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  476. MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
  477. c->tlbsize = 48;
  478. break;
  479. case PRID_IMP_R6000:
  480. c->cputype = CPU_R6000;
  481. __cpu_name[cpu] = "R6000";
  482. set_isa(c, MIPS_CPU_ISA_II);
  483. c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
  484. MIPS_CPU_LLSC;
  485. c->tlbsize = 32;
  486. break;
  487. case PRID_IMP_R6000A:
  488. c->cputype = CPU_R6000A;
  489. __cpu_name[cpu] = "R6000A";
  490. set_isa(c, MIPS_CPU_ISA_II);
  491. c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
  492. MIPS_CPU_LLSC;
  493. c->tlbsize = 32;
  494. break;
  495. case PRID_IMP_RM7000:
  496. c->cputype = CPU_RM7000;
  497. __cpu_name[cpu] = "RM7000";
  498. set_isa(c, MIPS_CPU_ISA_IV);
  499. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  500. MIPS_CPU_LLSC;
  501. /*
  502. * Undocumented RM7000: Bit 29 in the info register of
  503. * the RM7000 v2.0 indicates if the TLB has 48 or 64
  504. * entries.
  505. *
  506. * 29 1 => 64 entry JTLB
  507. * 0 => 48 entry JTLB
  508. */
  509. c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
  510. break;
  511. case PRID_IMP_RM9000:
  512. c->cputype = CPU_RM9000;
  513. __cpu_name[cpu] = "RM9000";
  514. set_isa(c, MIPS_CPU_ISA_IV);
  515. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  516. MIPS_CPU_LLSC;
  517. /*
  518. * Bit 29 in the info register of the RM9000
  519. * indicates if the TLB has 48 or 64 entries.
  520. *
  521. * 29 1 => 64 entry JTLB
  522. * 0 => 48 entry JTLB
  523. */
  524. c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
  525. break;
  526. case PRID_IMP_R8000:
  527. c->cputype = CPU_R8000;
  528. __cpu_name[cpu] = "RM8000";
  529. set_isa(c, MIPS_CPU_ISA_IV);
  530. c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
  531. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  532. MIPS_CPU_LLSC;
  533. c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
  534. break;
  535. case PRID_IMP_R10000:
  536. c->cputype = CPU_R10000;
  537. __cpu_name[cpu] = "R10000";
  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_R12000:
  546. c->cputype = CPU_R12000;
  547. __cpu_name[cpu] = "R12000";
  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_R14000:
  556. c->cputype = CPU_R14000;
  557. __cpu_name[cpu] = "R14000";
  558. set_isa(c, MIPS_CPU_ISA_IV);
  559. c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
  560. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  561. MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
  562. MIPS_CPU_LLSC;
  563. c->tlbsize = 64;
  564. break;
  565. case PRID_IMP_LOONGSON2:
  566. c->cputype = CPU_LOONGSON2;
  567. __cpu_name[cpu] = "ICT Loongson-2";
  568. switch (c->processor_id & PRID_REV_MASK) {
  569. case PRID_REV_LOONGSON2E:
  570. set_elf_platform(cpu, "loongson2e");
  571. break;
  572. case PRID_REV_LOONGSON2F:
  573. set_elf_platform(cpu, "loongson2f");
  574. break;
  575. }
  576. set_isa(c, MIPS_CPU_ISA_III);
  577. c->options = R4K_OPTS |
  578. MIPS_CPU_FPU | MIPS_CPU_LLSC |
  579. MIPS_CPU_32FPR;
  580. c->tlbsize = 64;
  581. break;
  582. case PRID_IMP_LOONGSON1:
  583. decode_configs(c);
  584. c->cputype = CPU_LOONGSON1;
  585. switch (c->processor_id & PRID_REV_MASK) {
  586. case PRID_REV_LOONGSON1B:
  587. __cpu_name[cpu] = "Loongson 1B";
  588. break;
  589. }
  590. break;
  591. }
  592. }
  593. static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
  594. {
  595. decode_configs(c);
  596. switch (c->processor_id & PRID_IMP_MASK) {
  597. case PRID_IMP_4KC:
  598. c->cputype = CPU_4KC;
  599. __cpu_name[cpu] = "MIPS 4Kc";
  600. break;
  601. case PRID_IMP_4KEC:
  602. case PRID_IMP_4KECR2:
  603. c->cputype = CPU_4KEC;
  604. __cpu_name[cpu] = "MIPS 4KEc";
  605. break;
  606. case PRID_IMP_4KSC:
  607. case PRID_IMP_4KSD:
  608. c->cputype = CPU_4KSC;
  609. __cpu_name[cpu] = "MIPS 4KSc";
  610. break;
  611. case PRID_IMP_5KC:
  612. c->cputype = CPU_5KC;
  613. __cpu_name[cpu] = "MIPS 5Kc";
  614. break;
  615. case PRID_IMP_5KE:
  616. c->cputype = CPU_5KE;
  617. __cpu_name[cpu] = "MIPS 5KE";
  618. break;
  619. case PRID_IMP_20KC:
  620. c->cputype = CPU_20KC;
  621. __cpu_name[cpu] = "MIPS 20Kc";
  622. break;
  623. case PRID_IMP_24K:
  624. c->cputype = CPU_24K;
  625. __cpu_name[cpu] = "MIPS 24Kc";
  626. break;
  627. case PRID_IMP_24KE:
  628. c->cputype = CPU_24K;
  629. __cpu_name[cpu] = "MIPS 24KEc";
  630. break;
  631. case PRID_IMP_25KF:
  632. c->cputype = CPU_25KF;
  633. __cpu_name[cpu] = "MIPS 25Kc";
  634. break;
  635. case PRID_IMP_34K:
  636. c->cputype = CPU_34K;
  637. __cpu_name[cpu] = "MIPS 34Kc";
  638. break;
  639. case PRID_IMP_74K:
  640. c->cputype = CPU_74K;
  641. __cpu_name[cpu] = "MIPS 74Kc";
  642. break;
  643. case PRID_IMP_M14KC:
  644. c->cputype = CPU_M14KC;
  645. __cpu_name[cpu] = "MIPS M14Kc";
  646. break;
  647. case PRID_IMP_M14KEC:
  648. c->cputype = CPU_M14KEC;
  649. __cpu_name[cpu] = "MIPS M14KEc";
  650. break;
  651. case PRID_IMP_1004K:
  652. c->cputype = CPU_1004K;
  653. __cpu_name[cpu] = "MIPS 1004Kc";
  654. break;
  655. case PRID_IMP_1074K:
  656. c->cputype = CPU_74K;
  657. __cpu_name[cpu] = "MIPS 1074Kc";
  658. break;
  659. }
  660. spram_config();
  661. }
  662. static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
  663. {
  664. decode_configs(c);
  665. switch (c->processor_id & PRID_IMP_MASK) {
  666. case PRID_IMP_AU1_REV1:
  667. case PRID_IMP_AU1_REV2:
  668. c->cputype = CPU_ALCHEMY;
  669. switch ((c->processor_id >> 24) & 0xff) {
  670. case 0:
  671. __cpu_name[cpu] = "Au1000";
  672. break;
  673. case 1:
  674. __cpu_name[cpu] = "Au1500";
  675. break;
  676. case 2:
  677. __cpu_name[cpu] = "Au1100";
  678. break;
  679. case 3:
  680. __cpu_name[cpu] = "Au1550";
  681. break;
  682. case 4:
  683. __cpu_name[cpu] = "Au1200";
  684. if ((c->processor_id & PRID_REV_MASK) == 2)
  685. __cpu_name[cpu] = "Au1250";
  686. break;
  687. case 5:
  688. __cpu_name[cpu] = "Au1210";
  689. break;
  690. default:
  691. __cpu_name[cpu] = "Au1xxx";
  692. break;
  693. }
  694. break;
  695. }
  696. }
  697. static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
  698. {
  699. decode_configs(c);
  700. switch (c->processor_id & PRID_IMP_MASK) {
  701. case PRID_IMP_SB1:
  702. c->cputype = CPU_SB1;
  703. __cpu_name[cpu] = "SiByte SB1";
  704. /* FPU in pass1 is known to have issues. */
  705. if ((c->processor_id & PRID_REV_MASK) < 0x02)
  706. c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
  707. break;
  708. case PRID_IMP_SB1A:
  709. c->cputype = CPU_SB1A;
  710. __cpu_name[cpu] = "SiByte SB1A";
  711. break;
  712. }
  713. }
  714. static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
  715. {
  716. decode_configs(c);
  717. switch (c->processor_id & PRID_IMP_MASK) {
  718. case PRID_IMP_SR71000:
  719. c->cputype = CPU_SR71000;
  720. __cpu_name[cpu] = "Sandcraft SR71000";
  721. c->scache.ways = 8;
  722. c->tlbsize = 64;
  723. break;
  724. }
  725. }
  726. static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
  727. {
  728. decode_configs(c);
  729. switch (c->processor_id & PRID_IMP_MASK) {
  730. case PRID_IMP_PR4450:
  731. c->cputype = CPU_PR4450;
  732. __cpu_name[cpu] = "Philips PR4450";
  733. set_isa(c, MIPS_CPU_ISA_M32R1);
  734. break;
  735. }
  736. }
  737. static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
  738. {
  739. decode_configs(c);
  740. switch (c->processor_id & PRID_IMP_MASK) {
  741. case PRID_IMP_BMIPS32_REV4:
  742. case PRID_IMP_BMIPS32_REV8:
  743. c->cputype = CPU_BMIPS32;
  744. __cpu_name[cpu] = "Broadcom BMIPS32";
  745. set_elf_platform(cpu, "bmips32");
  746. break;
  747. case PRID_IMP_BMIPS3300:
  748. case PRID_IMP_BMIPS3300_ALT:
  749. case PRID_IMP_BMIPS3300_BUG:
  750. c->cputype = CPU_BMIPS3300;
  751. __cpu_name[cpu] = "Broadcom BMIPS3300";
  752. set_elf_platform(cpu, "bmips3300");
  753. break;
  754. case PRID_IMP_BMIPS43XX: {
  755. int rev = c->processor_id & PRID_REV_MASK;
  756. if (rev >= PRID_REV_BMIPS4380_LO &&
  757. rev <= PRID_REV_BMIPS4380_HI) {
  758. c->cputype = CPU_BMIPS4380;
  759. __cpu_name[cpu] = "Broadcom BMIPS4380";
  760. set_elf_platform(cpu, "bmips4380");
  761. } else {
  762. c->cputype = CPU_BMIPS4350;
  763. __cpu_name[cpu] = "Broadcom BMIPS4350";
  764. set_elf_platform(cpu, "bmips4350");
  765. }
  766. break;
  767. }
  768. case PRID_IMP_BMIPS5000:
  769. c->cputype = CPU_BMIPS5000;
  770. __cpu_name[cpu] = "Broadcom BMIPS5000";
  771. set_elf_platform(cpu, "bmips5000");
  772. c->options |= MIPS_CPU_ULRI;
  773. break;
  774. }
  775. }
  776. static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
  777. {
  778. decode_configs(c);
  779. switch (c->processor_id & PRID_IMP_MASK) {
  780. case PRID_IMP_CAVIUM_CN38XX:
  781. case PRID_IMP_CAVIUM_CN31XX:
  782. case PRID_IMP_CAVIUM_CN30XX:
  783. c->cputype = CPU_CAVIUM_OCTEON;
  784. __cpu_name[cpu] = "Cavium Octeon";
  785. goto platform;
  786. case PRID_IMP_CAVIUM_CN58XX:
  787. case PRID_IMP_CAVIUM_CN56XX:
  788. case PRID_IMP_CAVIUM_CN50XX:
  789. case PRID_IMP_CAVIUM_CN52XX:
  790. c->cputype = CPU_CAVIUM_OCTEON_PLUS;
  791. __cpu_name[cpu] = "Cavium Octeon+";
  792. platform:
  793. set_elf_platform(cpu, "octeon");
  794. break;
  795. case PRID_IMP_CAVIUM_CN61XX:
  796. case PRID_IMP_CAVIUM_CN63XX:
  797. case PRID_IMP_CAVIUM_CN66XX:
  798. case PRID_IMP_CAVIUM_CN68XX:
  799. case PRID_IMP_CAVIUM_CNF71XX:
  800. c->cputype = CPU_CAVIUM_OCTEON2;
  801. __cpu_name[cpu] = "Cavium Octeon II";
  802. set_elf_platform(cpu, "octeon2");
  803. break;
  804. case PRID_IMP_CAVIUM_CN70XX:
  805. case PRID_IMP_CAVIUM_CN78XX:
  806. c->cputype = CPU_CAVIUM_OCTEON3;
  807. __cpu_name[cpu] = "Cavium Octeon III";
  808. set_elf_platform(cpu, "octeon3");
  809. break;
  810. default:
  811. printk(KERN_INFO "Unknown Octeon chip!\n");
  812. c->cputype = CPU_UNKNOWN;
  813. break;
  814. }
  815. }
  816. static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
  817. {
  818. decode_configs(c);
  819. /* JZRISC does not implement the CP0 counter. */
  820. c->options &= ~MIPS_CPU_COUNTER;
  821. switch (c->processor_id & PRID_IMP_MASK) {
  822. case PRID_IMP_JZRISC:
  823. c->cputype = CPU_JZRISC;
  824. __cpu_name[cpu] = "Ingenic JZRISC";
  825. break;
  826. default:
  827. panic("Unknown Ingenic Processor ID!");
  828. break;
  829. }
  830. }
  831. static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
  832. {
  833. decode_configs(c);
  834. if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_NETLOGIC_AU13XX) {
  835. c->cputype = CPU_ALCHEMY;
  836. __cpu_name[cpu] = "Au1300";
  837. /* following stuff is not for Alchemy */
  838. return;
  839. }
  840. c->options = (MIPS_CPU_TLB |
  841. MIPS_CPU_4KEX |
  842. MIPS_CPU_COUNTER |
  843. MIPS_CPU_DIVEC |
  844. MIPS_CPU_WATCH |
  845. MIPS_CPU_EJTAG |
  846. MIPS_CPU_LLSC);
  847. switch (c->processor_id & PRID_IMP_MASK) {
  848. case PRID_IMP_NETLOGIC_XLP2XX:
  849. c->cputype = CPU_XLP;
  850. __cpu_name[cpu] = "Broadcom XLPII";
  851. break;
  852. case PRID_IMP_NETLOGIC_XLP8XX:
  853. case PRID_IMP_NETLOGIC_XLP3XX:
  854. c->cputype = CPU_XLP;
  855. __cpu_name[cpu] = "Netlogic XLP";
  856. break;
  857. case PRID_IMP_NETLOGIC_XLR732:
  858. case PRID_IMP_NETLOGIC_XLR716:
  859. case PRID_IMP_NETLOGIC_XLR532:
  860. case PRID_IMP_NETLOGIC_XLR308:
  861. case PRID_IMP_NETLOGIC_XLR532C:
  862. case PRID_IMP_NETLOGIC_XLR516C:
  863. case PRID_IMP_NETLOGIC_XLR508C:
  864. case PRID_IMP_NETLOGIC_XLR308C:
  865. c->cputype = CPU_XLR;
  866. __cpu_name[cpu] = "Netlogic XLR";
  867. break;
  868. case PRID_IMP_NETLOGIC_XLS608:
  869. case PRID_IMP_NETLOGIC_XLS408:
  870. case PRID_IMP_NETLOGIC_XLS404:
  871. case PRID_IMP_NETLOGIC_XLS208:
  872. case PRID_IMP_NETLOGIC_XLS204:
  873. case PRID_IMP_NETLOGIC_XLS108:
  874. case PRID_IMP_NETLOGIC_XLS104:
  875. case PRID_IMP_NETLOGIC_XLS616B:
  876. case PRID_IMP_NETLOGIC_XLS608B:
  877. case PRID_IMP_NETLOGIC_XLS416B:
  878. case PRID_IMP_NETLOGIC_XLS412B:
  879. case PRID_IMP_NETLOGIC_XLS408B:
  880. case PRID_IMP_NETLOGIC_XLS404B:
  881. c->cputype = CPU_XLR;
  882. __cpu_name[cpu] = "Netlogic XLS";
  883. break;
  884. default:
  885. pr_info("Unknown Netlogic chip id [%02x]!\n",
  886. c->processor_id);
  887. c->cputype = CPU_XLR;
  888. break;
  889. }
  890. if (c->cputype == CPU_XLP) {
  891. set_isa(c, MIPS_CPU_ISA_M64R2);
  892. c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
  893. /* This will be updated again after all threads are woken up */
  894. c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
  895. } else {
  896. set_isa(c, MIPS_CPU_ISA_M64R1);
  897. c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
  898. }
  899. c->kscratch_mask = 0xf;
  900. }
  901. #ifdef CONFIG_64BIT
  902. /* For use by uaccess.h */
  903. u64 __ua_limit;
  904. EXPORT_SYMBOL(__ua_limit);
  905. #endif
  906. const char *__cpu_name[NR_CPUS];
  907. const char *__elf_platform;
  908. void cpu_probe(void)
  909. {
  910. struct cpuinfo_mips *c = &current_cpu_data;
  911. unsigned int cpu = smp_processor_id();
  912. c->processor_id = PRID_IMP_UNKNOWN;
  913. c->fpu_id = FPIR_IMP_NONE;
  914. c->cputype = CPU_UNKNOWN;
  915. c->processor_id = read_c0_prid();
  916. switch (c->processor_id & PRID_COMP_MASK) {
  917. case PRID_COMP_LEGACY:
  918. cpu_probe_legacy(c, cpu);
  919. break;
  920. case PRID_COMP_MIPS:
  921. cpu_probe_mips(c, cpu);
  922. break;
  923. case PRID_COMP_ALCHEMY:
  924. cpu_probe_alchemy(c, cpu);
  925. break;
  926. case PRID_COMP_SIBYTE:
  927. cpu_probe_sibyte(c, cpu);
  928. break;
  929. case PRID_COMP_BROADCOM:
  930. cpu_probe_broadcom(c, cpu);
  931. break;
  932. case PRID_COMP_SANDCRAFT:
  933. cpu_probe_sandcraft(c, cpu);
  934. break;
  935. case PRID_COMP_NXP:
  936. cpu_probe_nxp(c, cpu);
  937. break;
  938. case PRID_COMP_CAVIUM:
  939. cpu_probe_cavium(c, cpu);
  940. break;
  941. case PRID_COMP_INGENIC:
  942. cpu_probe_ingenic(c, cpu);
  943. break;
  944. case PRID_COMP_NETLOGIC:
  945. cpu_probe_netlogic(c, cpu);
  946. break;
  947. }
  948. BUG_ON(!__cpu_name[cpu]);
  949. BUG_ON(c->cputype == CPU_UNKNOWN);
  950. /*
  951. * Platform code can force the cpu type to optimize code
  952. * generation. In that case be sure the cpu type is correctly
  953. * manually setup otherwise it could trigger some nasty bugs.
  954. */
  955. BUG_ON(current_cpu_type() != c->cputype);
  956. if (mips_fpu_disabled)
  957. c->options &= ~MIPS_CPU_FPU;
  958. if (mips_dsp_disabled)
  959. c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
  960. if (c->options & MIPS_CPU_FPU) {
  961. c->fpu_id = cpu_get_fpu_id();
  962. if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2 |
  963. MIPS_CPU_ISA_M64R1 | MIPS_CPU_ISA_M64R2)) {
  964. if (c->fpu_id & MIPS_FPIR_3D)
  965. c->ases |= MIPS_ASE_MIPS3D;
  966. }
  967. }
  968. if (cpu_has_mips_r2) {
  969. c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
  970. /* R2 has Performance Counter Interrupt indicator */
  971. c->options |= MIPS_CPU_PCI;
  972. }
  973. else
  974. c->srsets = 1;
  975. cpu_probe_vmbits(c);
  976. #ifdef CONFIG_64BIT
  977. if (cpu == 0)
  978. __ua_limit = ~((1ull << cpu_vmbits) - 1);
  979. #endif
  980. }
  981. void cpu_report(void)
  982. {
  983. struct cpuinfo_mips *c = &current_cpu_data;
  984. printk(KERN_INFO "CPU revision is: %08x (%s)\n",
  985. c->processor_id, cpu_name_string());
  986. if (c->options & MIPS_CPU_FPU)
  987. printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
  988. }