cpu-probe.c 18 KB

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