cpu-probe.c 18 KB

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