cpu-probe.c 18 KB

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