cpu-probe.c 17 KB

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