cpu-probe.c 29 KB

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