cpu-probe.c 18 KB

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