cpu-probe.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  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 MIPS 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/stddef.h>
  18. #include <asm/cpu.h>
  19. #include <asm/fpu.h>
  20. #include <asm/mipsregs.h>
  21. #include <asm/system.h>
  22. /*
  23. * Not all of the MIPS CPUs have the "wait" instruction available. Moreover,
  24. * the implementation of the "wait" feature differs between CPU families. This
  25. * points to the function that implements CPU specific wait.
  26. * The wait instruction stops the pipeline and reduces the power consumption of
  27. * the CPU very much.
  28. */
  29. void (*cpu_wait)(void) = NULL;
  30. static void r3081_wait(void)
  31. {
  32. unsigned long cfg = read_c0_conf();
  33. write_c0_conf(cfg | R30XX_CONF_HALT);
  34. }
  35. static void r39xx_wait(void)
  36. {
  37. local_irq_disable();
  38. if (!need_resched())
  39. write_c0_conf(read_c0_conf() | TX39_CONF_HALT);
  40. local_irq_enable();
  41. }
  42. /*
  43. * There is a race when WAIT instruction executed with interrupt
  44. * enabled.
  45. * But it is implementation-dependent wheter the pipelie restarts when
  46. * a non-enabled interrupt is requested.
  47. */
  48. static void r4k_wait(void)
  49. {
  50. __asm__(" .set mips3 \n"
  51. " wait \n"
  52. " .set mips0 \n");
  53. }
  54. /*
  55. * This variant is preferable as it allows testing need_resched and going to
  56. * sleep depending on the outcome atomically. Unfortunately the "It is
  57. * implementation-dependent whether the pipeline restarts when a non-enabled
  58. * interrupt is requested" restriction in the MIPS32/MIPS64 architecture makes
  59. * using this version a gamble.
  60. */
  61. static void r4k_wait_irqoff(void)
  62. {
  63. local_irq_disable();
  64. if (!need_resched())
  65. __asm__(" .set mips3 \n"
  66. " wait \n"
  67. " .set mips0 \n");
  68. local_irq_enable();
  69. }
  70. /* The Au1xxx wait is available only if using 32khz counter or
  71. * external timer source, but specifically not CP0 Counter. */
  72. int allow_au1k_wait;
  73. static void au1k_wait(void)
  74. {
  75. /* using the wait instruction makes CP0 counter unusable */
  76. __asm__(" .set mips3 \n"
  77. " cache 0x14, 0(%0) \n"
  78. " cache 0x14, 32(%0) \n"
  79. " sync \n"
  80. " nop \n"
  81. " wait \n"
  82. " nop \n"
  83. " nop \n"
  84. " nop \n"
  85. " nop \n"
  86. " .set mips0 \n"
  87. : : "r" (au1k_wait));
  88. }
  89. static int __initdata nowait = 0;
  90. int __init wait_disable(char *s)
  91. {
  92. nowait = 1;
  93. return 1;
  94. }
  95. __setup("nowait", wait_disable);
  96. static inline void check_wait(void)
  97. {
  98. struct cpuinfo_mips *c = &current_cpu_data;
  99. printk("Checking for 'wait' instruction... ");
  100. if (nowait) {
  101. printk (" disabled.\n");
  102. return;
  103. }
  104. switch (c->cputype) {
  105. case CPU_R3081:
  106. case CPU_R3081E:
  107. cpu_wait = r3081_wait;
  108. printk(" available.\n");
  109. break;
  110. case CPU_TX3927:
  111. cpu_wait = r39xx_wait;
  112. printk(" available.\n");
  113. break;
  114. case CPU_R4200:
  115. /* case CPU_R4300: */
  116. case CPU_R4600:
  117. case CPU_R4640:
  118. case CPU_R4650:
  119. case CPU_R4700:
  120. case CPU_R5000:
  121. case CPU_NEVADA:
  122. case CPU_RM7000:
  123. case CPU_RM9000:
  124. case CPU_4KC:
  125. case CPU_4KEC:
  126. case CPU_4KSC:
  127. case CPU_5KC:
  128. /* case CPU_20KC:*/
  129. case CPU_24K:
  130. case CPU_25KF:
  131. case CPU_34K:
  132. case CPU_74K:
  133. case CPU_PR4450:
  134. cpu_wait = r4k_wait;
  135. printk(" available.\n");
  136. break;
  137. case CPU_TX49XX:
  138. cpu_wait = r4k_wait_irqoff;
  139. printk(" available.\n");
  140. break;
  141. case CPU_AU1000:
  142. case CPU_AU1100:
  143. case CPU_AU1500:
  144. case CPU_AU1550:
  145. case CPU_AU1200:
  146. if (allow_au1k_wait) {
  147. cpu_wait = au1k_wait;
  148. printk(" available.\n");
  149. } else
  150. printk(" unavailable.\n");
  151. break;
  152. default:
  153. printk(" unavailable.\n");
  154. break;
  155. }
  156. }
  157. void __init check_bugs32(void)
  158. {
  159. check_wait();
  160. }
  161. /*
  162. * Probe whether cpu has config register by trying to play with
  163. * alternate cache bit and see whether it matters.
  164. * It's used by cpu_probe to distinguish between R3000A and R3081.
  165. */
  166. static inline int cpu_has_confreg(void)
  167. {
  168. #ifdef CONFIG_CPU_R3000
  169. extern unsigned long r3k_cache_size(unsigned long);
  170. unsigned long size1, size2;
  171. unsigned long cfg = read_c0_conf();
  172. size1 = r3k_cache_size(ST0_ISC);
  173. write_c0_conf(cfg ^ R30XX_CONF_AC);
  174. size2 = r3k_cache_size(ST0_ISC);
  175. write_c0_conf(cfg);
  176. return size1 != size2;
  177. #else
  178. return 0;
  179. #endif
  180. }
  181. /*
  182. * Get the FPU Implementation/Revision.
  183. */
  184. static inline unsigned long cpu_get_fpu_id(void)
  185. {
  186. unsigned long tmp, fpu_id;
  187. tmp = read_c0_status();
  188. __enable_fpu();
  189. fpu_id = read_32bit_cp1_register(CP1_REVISION);
  190. write_c0_status(tmp);
  191. return fpu_id;
  192. }
  193. /*
  194. * Check the CPU has an FPU the official way.
  195. */
  196. static inline int __cpu_has_fpu(void)
  197. {
  198. return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
  199. }
  200. #define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
  201. | MIPS_CPU_COUNTER)
  202. static inline void cpu_probe_legacy(struct cpuinfo_mips *c)
  203. {
  204. switch (c->processor_id & 0xff00) {
  205. case PRID_IMP_R2000:
  206. c->cputype = CPU_R2000;
  207. c->isa_level = MIPS_CPU_ISA_I;
  208. c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
  209. MIPS_CPU_NOFPUEX;
  210. if (__cpu_has_fpu())
  211. c->options |= MIPS_CPU_FPU;
  212. c->tlbsize = 64;
  213. break;
  214. case PRID_IMP_R3000:
  215. if ((c->processor_id & 0xff) == PRID_REV_R3000A)
  216. if (cpu_has_confreg())
  217. c->cputype = CPU_R3081E;
  218. else
  219. c->cputype = CPU_R3000A;
  220. else
  221. c->cputype = CPU_R3000;
  222. c->isa_level = MIPS_CPU_ISA_I;
  223. c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
  224. MIPS_CPU_NOFPUEX;
  225. if (__cpu_has_fpu())
  226. c->options |= MIPS_CPU_FPU;
  227. c->tlbsize = 64;
  228. break;
  229. case PRID_IMP_R4000:
  230. if (read_c0_config() & CONF_SC) {
  231. if ((c->processor_id & 0xff) >= PRID_REV_R4400)
  232. c->cputype = CPU_R4400PC;
  233. else
  234. c->cputype = CPU_R4000PC;
  235. } else {
  236. if ((c->processor_id & 0xff) >= PRID_REV_R4400)
  237. c->cputype = CPU_R4400SC;
  238. else
  239. c->cputype = CPU_R4000SC;
  240. }
  241. c->isa_level = MIPS_CPU_ISA_III;
  242. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  243. MIPS_CPU_WATCH | MIPS_CPU_VCE |
  244. MIPS_CPU_LLSC;
  245. c->tlbsize = 48;
  246. break;
  247. case PRID_IMP_VR41XX:
  248. switch (c->processor_id & 0xf0) {
  249. case PRID_REV_VR4111:
  250. c->cputype = CPU_VR4111;
  251. break;
  252. case PRID_REV_VR4121:
  253. c->cputype = CPU_VR4121;
  254. break;
  255. case PRID_REV_VR4122:
  256. if ((c->processor_id & 0xf) < 0x3)
  257. c->cputype = CPU_VR4122;
  258. else
  259. c->cputype = CPU_VR4181A;
  260. break;
  261. case PRID_REV_VR4130:
  262. if ((c->processor_id & 0xf) < 0x4)
  263. c->cputype = CPU_VR4131;
  264. else
  265. c->cputype = CPU_VR4133;
  266. break;
  267. default:
  268. printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
  269. c->cputype = CPU_VR41XX;
  270. break;
  271. }
  272. c->isa_level = MIPS_CPU_ISA_III;
  273. c->options = R4K_OPTS;
  274. c->tlbsize = 32;
  275. break;
  276. case PRID_IMP_R4300:
  277. c->cputype = CPU_R4300;
  278. c->isa_level = MIPS_CPU_ISA_III;
  279. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  280. MIPS_CPU_LLSC;
  281. c->tlbsize = 32;
  282. break;
  283. case PRID_IMP_R4600:
  284. c->cputype = CPU_R4600;
  285. c->isa_level = MIPS_CPU_ISA_III;
  286. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  287. MIPS_CPU_LLSC;
  288. c->tlbsize = 48;
  289. break;
  290. #if 0
  291. case PRID_IMP_R4650:
  292. /*
  293. * This processor doesn't have an MMU, so it's not
  294. * "real easy" to run Linux on it. It is left purely
  295. * for documentation. Commented out because it shares
  296. * it's c0_prid id number with the TX3900.
  297. */
  298. c->cputype = CPU_R4650;
  299. c->isa_level = MIPS_CPU_ISA_III;
  300. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
  301. c->tlbsize = 48;
  302. break;
  303. #endif
  304. case PRID_IMP_TX39:
  305. c->isa_level = MIPS_CPU_ISA_I;
  306. c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
  307. if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
  308. c->cputype = CPU_TX3927;
  309. c->tlbsize = 64;
  310. } else {
  311. switch (c->processor_id & 0xff) {
  312. case PRID_REV_TX3912:
  313. c->cputype = CPU_TX3912;
  314. c->tlbsize = 32;
  315. break;
  316. case PRID_REV_TX3922:
  317. c->cputype = CPU_TX3922;
  318. c->tlbsize = 64;
  319. break;
  320. default:
  321. c->cputype = CPU_UNKNOWN;
  322. break;
  323. }
  324. }
  325. break;
  326. case PRID_IMP_R4700:
  327. c->cputype = CPU_R4700;
  328. c->isa_level = MIPS_CPU_ISA_III;
  329. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  330. MIPS_CPU_LLSC;
  331. c->tlbsize = 48;
  332. break;
  333. case PRID_IMP_TX49:
  334. c->cputype = CPU_TX49XX;
  335. c->isa_level = MIPS_CPU_ISA_III;
  336. c->options = R4K_OPTS | MIPS_CPU_LLSC;
  337. if (!(c->processor_id & 0x08))
  338. c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
  339. c->tlbsize = 48;
  340. break;
  341. case PRID_IMP_R5000:
  342. c->cputype = CPU_R5000;
  343. c->isa_level = MIPS_CPU_ISA_IV;
  344. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  345. MIPS_CPU_LLSC;
  346. c->tlbsize = 48;
  347. break;
  348. case PRID_IMP_R5432:
  349. c->cputype = CPU_R5432;
  350. c->isa_level = MIPS_CPU_ISA_IV;
  351. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  352. MIPS_CPU_WATCH | MIPS_CPU_LLSC;
  353. c->tlbsize = 48;
  354. break;
  355. case PRID_IMP_R5500:
  356. c->cputype = CPU_R5500;
  357. c->isa_level = MIPS_CPU_ISA_IV;
  358. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  359. MIPS_CPU_WATCH | MIPS_CPU_LLSC;
  360. c->tlbsize = 48;
  361. break;
  362. case PRID_IMP_NEVADA:
  363. c->cputype = CPU_NEVADA;
  364. c->isa_level = MIPS_CPU_ISA_IV;
  365. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  366. MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
  367. c->tlbsize = 48;
  368. break;
  369. case PRID_IMP_R6000:
  370. c->cputype = CPU_R6000;
  371. c->isa_level = MIPS_CPU_ISA_II;
  372. c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
  373. MIPS_CPU_LLSC;
  374. c->tlbsize = 32;
  375. break;
  376. case PRID_IMP_R6000A:
  377. c->cputype = CPU_R6000A;
  378. c->isa_level = MIPS_CPU_ISA_II;
  379. c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
  380. MIPS_CPU_LLSC;
  381. c->tlbsize = 32;
  382. break;
  383. case PRID_IMP_RM7000:
  384. c->cputype = CPU_RM7000;
  385. c->isa_level = MIPS_CPU_ISA_IV;
  386. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  387. MIPS_CPU_LLSC;
  388. /*
  389. * Undocumented RM7000: Bit 29 in the info register of
  390. * the RM7000 v2.0 indicates if the TLB has 48 or 64
  391. * entries.
  392. *
  393. * 29 1 => 64 entry JTLB
  394. * 0 => 48 entry JTLB
  395. */
  396. c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
  397. break;
  398. case PRID_IMP_RM9000:
  399. c->cputype = CPU_RM9000;
  400. c->isa_level = MIPS_CPU_ISA_IV;
  401. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  402. MIPS_CPU_LLSC;
  403. /*
  404. * Bit 29 in the info register of the RM9000
  405. * indicates if the TLB has 48 or 64 entries.
  406. *
  407. * 29 1 => 64 entry JTLB
  408. * 0 => 48 entry JTLB
  409. */
  410. c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
  411. break;
  412. case PRID_IMP_R8000:
  413. c->cputype = CPU_R8000;
  414. c->isa_level = MIPS_CPU_ISA_IV;
  415. c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
  416. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  417. MIPS_CPU_LLSC;
  418. c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
  419. break;
  420. case PRID_IMP_R10000:
  421. c->cputype = CPU_R10000;
  422. c->isa_level = MIPS_CPU_ISA_IV;
  423. c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
  424. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  425. MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
  426. MIPS_CPU_LLSC;
  427. c->tlbsize = 64;
  428. break;
  429. case PRID_IMP_R12000:
  430. c->cputype = CPU_R12000;
  431. c->isa_level = MIPS_CPU_ISA_IV;
  432. c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
  433. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  434. MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
  435. MIPS_CPU_LLSC;
  436. c->tlbsize = 64;
  437. break;
  438. case PRID_IMP_R14000:
  439. c->cputype = CPU_R14000;
  440. c->isa_level = MIPS_CPU_ISA_IV;
  441. c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
  442. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  443. MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
  444. MIPS_CPU_LLSC;
  445. c->tlbsize = 64;
  446. break;
  447. }
  448. }
  449. static char unknown_isa[] __initdata = KERN_ERR \
  450. "Unsupported ISA type, c0.config0: %d.";
  451. static inline unsigned int decode_config0(struct cpuinfo_mips *c)
  452. {
  453. unsigned int config0;
  454. int isa;
  455. config0 = read_c0_config();
  456. if (((config0 & MIPS_CONF_MT) >> 7) == 1)
  457. c->options |= MIPS_CPU_TLB;
  458. isa = (config0 & MIPS_CONF_AT) >> 13;
  459. switch (isa) {
  460. case 0:
  461. switch ((config0 & MIPS_CONF_AR) >> 10) {
  462. case 0:
  463. c->isa_level = MIPS_CPU_ISA_M32R1;
  464. break;
  465. case 1:
  466. c->isa_level = MIPS_CPU_ISA_M32R2;
  467. break;
  468. default:
  469. goto unknown;
  470. }
  471. break;
  472. case 2:
  473. switch ((config0 & MIPS_CONF_AR) >> 10) {
  474. case 0:
  475. c->isa_level = MIPS_CPU_ISA_M64R1;
  476. break;
  477. case 1:
  478. c->isa_level = MIPS_CPU_ISA_M64R2;
  479. break;
  480. default:
  481. goto unknown;
  482. }
  483. break;
  484. default:
  485. goto unknown;
  486. }
  487. return config0 & MIPS_CONF_M;
  488. unknown:
  489. panic(unknown_isa, config0);
  490. }
  491. static inline unsigned int decode_config1(struct cpuinfo_mips *c)
  492. {
  493. unsigned int config1;
  494. config1 = read_c0_config1();
  495. if (config1 & MIPS_CONF1_MD)
  496. c->ases |= MIPS_ASE_MDMX;
  497. if (config1 & MIPS_CONF1_WR)
  498. c->options |= MIPS_CPU_WATCH;
  499. if (config1 & MIPS_CONF1_CA)
  500. c->ases |= MIPS_ASE_MIPS16;
  501. if (config1 & MIPS_CONF1_EP)
  502. c->options |= MIPS_CPU_EJTAG;
  503. if (config1 & MIPS_CONF1_FP) {
  504. c->options |= MIPS_CPU_FPU;
  505. c->options |= MIPS_CPU_32FPR;
  506. }
  507. if (cpu_has_tlb)
  508. c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
  509. return config1 & MIPS_CONF_M;
  510. }
  511. static inline unsigned int decode_config2(struct cpuinfo_mips *c)
  512. {
  513. unsigned int config2;
  514. config2 = read_c0_config2();
  515. if (config2 & MIPS_CONF2_SL)
  516. c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
  517. return config2 & MIPS_CONF_M;
  518. }
  519. static inline unsigned int decode_config3(struct cpuinfo_mips *c)
  520. {
  521. unsigned int config3;
  522. config3 = read_c0_config3();
  523. if (config3 & MIPS_CONF3_SM)
  524. c->ases |= MIPS_ASE_SMARTMIPS;
  525. if (config3 & MIPS_CONF3_DSP)
  526. c->ases |= MIPS_ASE_DSP;
  527. if (config3 & MIPS_CONF3_VINT)
  528. c->options |= MIPS_CPU_VINT;
  529. if (config3 & MIPS_CONF3_VEIC)
  530. c->options |= MIPS_CPU_VEIC;
  531. if (config3 & MIPS_CONF3_MT)
  532. c->ases |= MIPS_ASE_MIPSMT;
  533. return config3 & MIPS_CONF_M;
  534. }
  535. static void __init decode_configs(struct cpuinfo_mips *c)
  536. {
  537. /* MIPS32 or MIPS64 compliant CPU. */
  538. c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
  539. MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
  540. c->scache.flags = MIPS_CACHE_NOT_PRESENT;
  541. /* Read Config registers. */
  542. if (!decode_config0(c))
  543. return; /* actually worth a panic() */
  544. if (!decode_config1(c))
  545. return;
  546. if (!decode_config2(c))
  547. return;
  548. if (!decode_config3(c))
  549. return;
  550. }
  551. static inline void cpu_probe_mips(struct cpuinfo_mips *c)
  552. {
  553. decode_configs(c);
  554. switch (c->processor_id & 0xff00) {
  555. case PRID_IMP_4KC:
  556. c->cputype = CPU_4KC;
  557. break;
  558. case PRID_IMP_4KEC:
  559. c->cputype = CPU_4KEC;
  560. break;
  561. case PRID_IMP_4KECR2:
  562. c->cputype = CPU_4KEC;
  563. break;
  564. case PRID_IMP_4KSC:
  565. case PRID_IMP_4KSD:
  566. c->cputype = CPU_4KSC;
  567. break;
  568. case PRID_IMP_5KC:
  569. c->cputype = CPU_5KC;
  570. break;
  571. case PRID_IMP_20KC:
  572. c->cputype = CPU_20KC;
  573. break;
  574. case PRID_IMP_24K:
  575. case PRID_IMP_24KE:
  576. c->cputype = CPU_24K;
  577. break;
  578. case PRID_IMP_25KF:
  579. c->cputype = CPU_25KF;
  580. break;
  581. case PRID_IMP_34K:
  582. c->cputype = CPU_34K;
  583. break;
  584. case PRID_IMP_74K:
  585. c->cputype = CPU_74K;
  586. break;
  587. }
  588. }
  589. static inline void cpu_probe_alchemy(struct cpuinfo_mips *c)
  590. {
  591. decode_configs(c);
  592. switch (c->processor_id & 0xff00) {
  593. case PRID_IMP_AU1_REV1:
  594. case PRID_IMP_AU1_REV2:
  595. switch ((c->processor_id >> 24) & 0xff) {
  596. case 0:
  597. c->cputype = CPU_AU1000;
  598. break;
  599. case 1:
  600. c->cputype = CPU_AU1500;
  601. break;
  602. case 2:
  603. c->cputype = CPU_AU1100;
  604. break;
  605. case 3:
  606. c->cputype = CPU_AU1550;
  607. break;
  608. case 4:
  609. c->cputype = CPU_AU1200;
  610. break;
  611. default:
  612. panic("Unknown Au Core!");
  613. break;
  614. }
  615. break;
  616. }
  617. }
  618. static inline void cpu_probe_sibyte(struct cpuinfo_mips *c)
  619. {
  620. decode_configs(c);
  621. /*
  622. * For historical reasons the SB1 comes with it's own variant of
  623. * cache code which eventually will be folded into c-r4k.c. Until
  624. * then we pretend it's got it's own cache architecture.
  625. */
  626. c->options &= ~MIPS_CPU_4K_CACHE;
  627. c->options |= MIPS_CPU_SB1_CACHE;
  628. switch (c->processor_id & 0xff00) {
  629. case PRID_IMP_SB1:
  630. c->cputype = CPU_SB1;
  631. /* FPU in pass1 is known to have issues. */
  632. if ((c->processor_id & 0xff) < 0x02)
  633. c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
  634. break;
  635. case PRID_IMP_SB1A:
  636. c->cputype = CPU_SB1A;
  637. break;
  638. }
  639. }
  640. static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c)
  641. {
  642. decode_configs(c);
  643. switch (c->processor_id & 0xff00) {
  644. case PRID_IMP_SR71000:
  645. c->cputype = CPU_SR71000;
  646. c->scache.ways = 8;
  647. c->tlbsize = 64;
  648. break;
  649. }
  650. }
  651. static inline void cpu_probe_philips(struct cpuinfo_mips *c)
  652. {
  653. decode_configs(c);
  654. switch (c->processor_id & 0xff00) {
  655. case PRID_IMP_PR4450:
  656. c->cputype = CPU_PR4450;
  657. c->isa_level = MIPS_CPU_ISA_M32R1;
  658. break;
  659. default:
  660. panic("Unknown Philips Core!"); /* REVISIT: die? */
  661. break;
  662. }
  663. }
  664. __init void cpu_probe(void)
  665. {
  666. struct cpuinfo_mips *c = &current_cpu_data;
  667. c->processor_id = PRID_IMP_UNKNOWN;
  668. c->fpu_id = FPIR_IMP_NONE;
  669. c->cputype = CPU_UNKNOWN;
  670. c->processor_id = read_c0_prid();
  671. switch (c->processor_id & 0xff0000) {
  672. case PRID_COMP_LEGACY:
  673. cpu_probe_legacy(c);
  674. break;
  675. case PRID_COMP_MIPS:
  676. cpu_probe_mips(c);
  677. break;
  678. case PRID_COMP_ALCHEMY:
  679. cpu_probe_alchemy(c);
  680. break;
  681. case PRID_COMP_SIBYTE:
  682. cpu_probe_sibyte(c);
  683. break;
  684. case PRID_COMP_SANDCRAFT:
  685. cpu_probe_sandcraft(c);
  686. break;
  687. case PRID_COMP_PHILIPS:
  688. cpu_probe_philips(c);
  689. break;
  690. default:
  691. c->cputype = CPU_UNKNOWN;
  692. }
  693. if (c->options & MIPS_CPU_FPU) {
  694. c->fpu_id = cpu_get_fpu_id();
  695. if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
  696. c->isa_level == MIPS_CPU_ISA_M32R2 ||
  697. c->isa_level == MIPS_CPU_ISA_M64R1 ||
  698. c->isa_level == MIPS_CPU_ISA_M64R2) {
  699. if (c->fpu_id & MIPS_FPIR_3D)
  700. c->ases |= MIPS_ASE_MIPS3D;
  701. }
  702. }
  703. }
  704. __init void cpu_report(void)
  705. {
  706. struct cpuinfo_mips *c = &current_cpu_data;
  707. printk("CPU revision is: %08x\n", c->processor_id);
  708. if (c->options & MIPS_CPU_FPU)
  709. printk("FPU revision is: %08x\n", c->fpu_id);
  710. }