cpu-probe.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950
  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. #include <asm/watch.h>
  24. /*
  25. * Not all of the MIPS CPUs have the "wait" instruction available. Moreover,
  26. * the implementation of the "wait" feature differs between CPU families. This
  27. * points to the function that implements CPU specific wait.
  28. * The wait instruction stops the pipeline and reduces the power consumption of
  29. * the CPU very much.
  30. */
  31. void (*cpu_wait)(void) = NULL;
  32. static void r3081_wait(void)
  33. {
  34. unsigned long cfg = read_c0_conf();
  35. write_c0_conf(cfg | R30XX_CONF_HALT);
  36. }
  37. static void r39xx_wait(void)
  38. {
  39. local_irq_disable();
  40. if (!need_resched())
  41. write_c0_conf(read_c0_conf() | TX39_CONF_HALT);
  42. local_irq_enable();
  43. }
  44. extern void r4k_wait(void);
  45. /*
  46. * This variant is preferable as it allows testing need_resched and going to
  47. * sleep depending on the outcome atomically. Unfortunately the "It is
  48. * implementation-dependent whether the pipeline restarts when a non-enabled
  49. * interrupt is requested" restriction in the MIPS32/MIPS64 architecture makes
  50. * using this version a gamble.
  51. */
  52. void r4k_wait_irqoff(void)
  53. {
  54. local_irq_disable();
  55. if (!need_resched())
  56. __asm__(" .set push \n"
  57. " .set mips3 \n"
  58. " wait \n"
  59. " .set pop \n");
  60. local_irq_enable();
  61. __asm__(" .globl __pastwait \n"
  62. "__pastwait: \n");
  63. return;
  64. }
  65. /*
  66. * The RM7000 variant has to handle erratum 38. The workaround is to not
  67. * have any pending stores when the WAIT instruction is executed.
  68. */
  69. static void rm7k_wait_irqoff(void)
  70. {
  71. local_irq_disable();
  72. if (!need_resched())
  73. __asm__(
  74. " .set push \n"
  75. " .set mips3 \n"
  76. " .set noat \n"
  77. " mfc0 $1, $12 \n"
  78. " sync \n"
  79. " mtc0 $1, $12 # stalls until W stage \n"
  80. " wait \n"
  81. " mtc0 $1, $12 # stalls until W stage \n"
  82. " .set pop \n");
  83. local_irq_enable();
  84. }
  85. /* The Au1xxx wait is available only if using 32khz counter or
  86. * external timer source, but specifically not CP0 Counter. */
  87. int allow_au1k_wait;
  88. static void au1k_wait(void)
  89. {
  90. /* using the wait instruction makes CP0 counter unusable */
  91. __asm__(" .set mips3 \n"
  92. " cache 0x14, 0(%0) \n"
  93. " cache 0x14, 32(%0) \n"
  94. " sync \n"
  95. " nop \n"
  96. " wait \n"
  97. " nop \n"
  98. " nop \n"
  99. " nop \n"
  100. " nop \n"
  101. " .set mips0 \n"
  102. : : "r" (au1k_wait));
  103. }
  104. static int __initdata nowait = 0;
  105. static int __init wait_disable(char *s)
  106. {
  107. nowait = 1;
  108. return 1;
  109. }
  110. __setup("nowait", wait_disable);
  111. void __init check_wait(void)
  112. {
  113. struct cpuinfo_mips *c = &current_cpu_data;
  114. if (nowait) {
  115. printk("Wait instruction disabled.\n");
  116. return;
  117. }
  118. switch (c->cputype) {
  119. case CPU_R3081:
  120. case CPU_R3081E:
  121. cpu_wait = r3081_wait;
  122. break;
  123. case CPU_TX3927:
  124. cpu_wait = r39xx_wait;
  125. break;
  126. case CPU_R4200:
  127. /* case CPU_R4300: */
  128. case CPU_R4600:
  129. case CPU_R4640:
  130. case CPU_R4650:
  131. case CPU_R4700:
  132. case CPU_R5000:
  133. case CPU_NEVADA:
  134. case CPU_4KC:
  135. case CPU_4KEC:
  136. case CPU_4KSC:
  137. case CPU_5KC:
  138. case CPU_25KF:
  139. case CPU_PR4450:
  140. case CPU_BCM3302:
  141. cpu_wait = r4k_wait;
  142. break;
  143. case CPU_RM7000:
  144. cpu_wait = rm7k_wait_irqoff;
  145. break;
  146. case CPU_24K:
  147. case CPU_34K:
  148. case CPU_1004K:
  149. cpu_wait = r4k_wait;
  150. if (read_c0_config7() & MIPS_CONF7_WII)
  151. cpu_wait = r4k_wait_irqoff;
  152. break;
  153. case CPU_74K:
  154. cpu_wait = r4k_wait;
  155. if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
  156. cpu_wait = r4k_wait_irqoff;
  157. break;
  158. case CPU_TX49XX:
  159. cpu_wait = r4k_wait_irqoff;
  160. break;
  161. case CPU_AU1000:
  162. case CPU_AU1100:
  163. case CPU_AU1500:
  164. case CPU_AU1550:
  165. case CPU_AU1200:
  166. case CPU_AU1210:
  167. case CPU_AU1250:
  168. if (allow_au1k_wait)
  169. cpu_wait = au1k_wait;
  170. break;
  171. case CPU_20KC:
  172. /*
  173. * WAIT on Rev1.0 has E1, E2, E3 and E16.
  174. * WAIT on Rev2.0 and Rev3.0 has E16.
  175. * Rev3.1 WAIT is nop, why bother
  176. */
  177. if ((c->processor_id & 0xff) <= 0x64)
  178. break;
  179. /*
  180. * Another rev is incremeting c0_count at a reduced clock
  181. * rate while in WAIT mode. So we basically have the choice
  182. * between using the cp0 timer as clocksource or avoiding
  183. * the WAIT instruction. Until more details are known,
  184. * disable the use of WAIT for 20Kc entirely.
  185. cpu_wait = r4k_wait;
  186. */
  187. break;
  188. case CPU_RM9000:
  189. if ((c->processor_id & 0x00ff) >= 0x40)
  190. cpu_wait = r4k_wait;
  191. break;
  192. default:
  193. break;
  194. }
  195. }
  196. static inline void check_errata(void)
  197. {
  198. struct cpuinfo_mips *c = &current_cpu_data;
  199. switch (c->cputype) {
  200. case CPU_34K:
  201. /*
  202. * Erratum "RPS May Cause Incorrect Instruction Execution"
  203. * This code only handles VPE0, any SMP/SMTC/RTOS code
  204. * making use of VPE1 will be responsable for that VPE.
  205. */
  206. if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
  207. write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
  208. break;
  209. default:
  210. break;
  211. }
  212. }
  213. void __init check_bugs32(void)
  214. {
  215. check_errata();
  216. }
  217. /*
  218. * Probe whether cpu has config register by trying to play with
  219. * alternate cache bit and see whether it matters.
  220. * It's used by cpu_probe to distinguish between R3000A and R3081.
  221. */
  222. static inline int cpu_has_confreg(void)
  223. {
  224. #ifdef CONFIG_CPU_R3000
  225. extern unsigned long r3k_cache_size(unsigned long);
  226. unsigned long size1, size2;
  227. unsigned long cfg = read_c0_conf();
  228. size1 = r3k_cache_size(ST0_ISC);
  229. write_c0_conf(cfg ^ R30XX_CONF_AC);
  230. size2 = r3k_cache_size(ST0_ISC);
  231. write_c0_conf(cfg);
  232. return size1 != size2;
  233. #else
  234. return 0;
  235. #endif
  236. }
  237. /*
  238. * Get the FPU Implementation/Revision.
  239. */
  240. static inline unsigned long cpu_get_fpu_id(void)
  241. {
  242. unsigned long tmp, fpu_id;
  243. tmp = read_c0_status();
  244. __enable_fpu();
  245. fpu_id = read_32bit_cp1_register(CP1_REVISION);
  246. write_c0_status(tmp);
  247. return fpu_id;
  248. }
  249. /*
  250. * Check the CPU has an FPU the official way.
  251. */
  252. static inline int __cpu_has_fpu(void)
  253. {
  254. return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
  255. }
  256. #define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
  257. | MIPS_CPU_COUNTER)
  258. static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
  259. {
  260. switch (c->processor_id & 0xff00) {
  261. case PRID_IMP_R2000:
  262. c->cputype = CPU_R2000;
  263. __cpu_name[cpu] = "R2000";
  264. c->isa_level = MIPS_CPU_ISA_I;
  265. c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
  266. MIPS_CPU_NOFPUEX;
  267. if (__cpu_has_fpu())
  268. c->options |= MIPS_CPU_FPU;
  269. c->tlbsize = 64;
  270. break;
  271. case PRID_IMP_R3000:
  272. if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
  273. if (cpu_has_confreg()) {
  274. c->cputype = CPU_R3081E;
  275. __cpu_name[cpu] = "R3081";
  276. } else {
  277. c->cputype = CPU_R3000A;
  278. __cpu_name[cpu] = "R3000A";
  279. }
  280. break;
  281. } else {
  282. c->cputype = CPU_R3000;
  283. __cpu_name[cpu] = "R3000";
  284. }
  285. c->isa_level = MIPS_CPU_ISA_I;
  286. c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
  287. MIPS_CPU_NOFPUEX;
  288. if (__cpu_has_fpu())
  289. c->options |= MIPS_CPU_FPU;
  290. c->tlbsize = 64;
  291. break;
  292. case PRID_IMP_R4000:
  293. if (read_c0_config() & CONF_SC) {
  294. if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
  295. c->cputype = CPU_R4400PC;
  296. __cpu_name[cpu] = "R4400PC";
  297. } else {
  298. c->cputype = CPU_R4000PC;
  299. __cpu_name[cpu] = "R4000PC";
  300. }
  301. } else {
  302. if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
  303. c->cputype = CPU_R4400SC;
  304. __cpu_name[cpu] = "R4400SC";
  305. } else {
  306. c->cputype = CPU_R4000SC;
  307. __cpu_name[cpu] = "R4000SC";
  308. }
  309. }
  310. c->isa_level = MIPS_CPU_ISA_III;
  311. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  312. MIPS_CPU_WATCH | MIPS_CPU_VCE |
  313. MIPS_CPU_LLSC;
  314. c->tlbsize = 48;
  315. break;
  316. case PRID_IMP_VR41XX:
  317. switch (c->processor_id & 0xf0) {
  318. case PRID_REV_VR4111:
  319. c->cputype = CPU_VR4111;
  320. __cpu_name[cpu] = "NEC VR4111";
  321. break;
  322. case PRID_REV_VR4121:
  323. c->cputype = CPU_VR4121;
  324. __cpu_name[cpu] = "NEC VR4121";
  325. break;
  326. case PRID_REV_VR4122:
  327. if ((c->processor_id & 0xf) < 0x3) {
  328. c->cputype = CPU_VR4122;
  329. __cpu_name[cpu] = "NEC VR4122";
  330. } else {
  331. c->cputype = CPU_VR4181A;
  332. __cpu_name[cpu] = "NEC VR4181A";
  333. }
  334. break;
  335. case PRID_REV_VR4130:
  336. if ((c->processor_id & 0xf) < 0x4) {
  337. c->cputype = CPU_VR4131;
  338. __cpu_name[cpu] = "NEC VR4131";
  339. } else {
  340. c->cputype = CPU_VR4133;
  341. __cpu_name[cpu] = "NEC VR4133";
  342. }
  343. break;
  344. default:
  345. printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
  346. c->cputype = CPU_VR41XX;
  347. __cpu_name[cpu] = "NEC Vr41xx";
  348. break;
  349. }
  350. c->isa_level = MIPS_CPU_ISA_III;
  351. c->options = R4K_OPTS;
  352. c->tlbsize = 32;
  353. break;
  354. case PRID_IMP_R4300:
  355. c->cputype = CPU_R4300;
  356. __cpu_name[cpu] = "R4300";
  357. c->isa_level = MIPS_CPU_ISA_III;
  358. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  359. MIPS_CPU_LLSC;
  360. c->tlbsize = 32;
  361. break;
  362. case PRID_IMP_R4600:
  363. c->cputype = CPU_R4600;
  364. __cpu_name[cpu] = "R4600";
  365. c->isa_level = MIPS_CPU_ISA_III;
  366. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  367. MIPS_CPU_LLSC;
  368. c->tlbsize = 48;
  369. break;
  370. #if 0
  371. case PRID_IMP_R4650:
  372. /*
  373. * This processor doesn't have an MMU, so it's not
  374. * "real easy" to run Linux on it. It is left purely
  375. * for documentation. Commented out because it shares
  376. * it's c0_prid id number with the TX3900.
  377. */
  378. c->cputype = CPU_R4650;
  379. __cpu_name[cpu] = "R4650";
  380. c->isa_level = MIPS_CPU_ISA_III;
  381. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
  382. c->tlbsize = 48;
  383. break;
  384. #endif
  385. case PRID_IMP_TX39:
  386. c->isa_level = MIPS_CPU_ISA_I;
  387. c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
  388. if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
  389. c->cputype = CPU_TX3927;
  390. __cpu_name[cpu] = "TX3927";
  391. c->tlbsize = 64;
  392. } else {
  393. switch (c->processor_id & 0xff) {
  394. case PRID_REV_TX3912:
  395. c->cputype = CPU_TX3912;
  396. __cpu_name[cpu] = "TX3912";
  397. c->tlbsize = 32;
  398. break;
  399. case PRID_REV_TX3922:
  400. c->cputype = CPU_TX3922;
  401. __cpu_name[cpu] = "TX3922";
  402. c->tlbsize = 64;
  403. break;
  404. }
  405. }
  406. break;
  407. case PRID_IMP_R4700:
  408. c->cputype = CPU_R4700;
  409. __cpu_name[cpu] = "R4700";
  410. c->isa_level = MIPS_CPU_ISA_III;
  411. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  412. MIPS_CPU_LLSC;
  413. c->tlbsize = 48;
  414. break;
  415. case PRID_IMP_TX49:
  416. c->cputype = CPU_TX49XX;
  417. __cpu_name[cpu] = "R49XX";
  418. c->isa_level = MIPS_CPU_ISA_III;
  419. c->options = R4K_OPTS | MIPS_CPU_LLSC;
  420. if (!(c->processor_id & 0x08))
  421. c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
  422. c->tlbsize = 48;
  423. break;
  424. case PRID_IMP_R5000:
  425. c->cputype = CPU_R5000;
  426. __cpu_name[cpu] = "R5000";
  427. c->isa_level = MIPS_CPU_ISA_IV;
  428. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  429. MIPS_CPU_LLSC;
  430. c->tlbsize = 48;
  431. break;
  432. case PRID_IMP_R5432:
  433. c->cputype = CPU_R5432;
  434. __cpu_name[cpu] = "R5432";
  435. c->isa_level = MIPS_CPU_ISA_IV;
  436. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  437. MIPS_CPU_WATCH | MIPS_CPU_LLSC;
  438. c->tlbsize = 48;
  439. break;
  440. case PRID_IMP_R5500:
  441. c->cputype = CPU_R5500;
  442. __cpu_name[cpu] = "R5500";
  443. c->isa_level = MIPS_CPU_ISA_IV;
  444. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  445. MIPS_CPU_WATCH | MIPS_CPU_LLSC;
  446. c->tlbsize = 48;
  447. break;
  448. case PRID_IMP_NEVADA:
  449. c->cputype = CPU_NEVADA;
  450. __cpu_name[cpu] = "Nevada";
  451. c->isa_level = MIPS_CPU_ISA_IV;
  452. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  453. MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
  454. c->tlbsize = 48;
  455. break;
  456. case PRID_IMP_R6000:
  457. c->cputype = CPU_R6000;
  458. __cpu_name[cpu] = "R6000";
  459. c->isa_level = MIPS_CPU_ISA_II;
  460. c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
  461. MIPS_CPU_LLSC;
  462. c->tlbsize = 32;
  463. break;
  464. case PRID_IMP_R6000A:
  465. c->cputype = CPU_R6000A;
  466. __cpu_name[cpu] = "R6000A";
  467. c->isa_level = MIPS_CPU_ISA_II;
  468. c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
  469. MIPS_CPU_LLSC;
  470. c->tlbsize = 32;
  471. break;
  472. case PRID_IMP_RM7000:
  473. c->cputype = CPU_RM7000;
  474. __cpu_name[cpu] = "RM7000";
  475. c->isa_level = MIPS_CPU_ISA_IV;
  476. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  477. MIPS_CPU_LLSC;
  478. /*
  479. * Undocumented RM7000: Bit 29 in the info register of
  480. * the RM7000 v2.0 indicates if the TLB has 48 or 64
  481. * entries.
  482. *
  483. * 29 1 => 64 entry JTLB
  484. * 0 => 48 entry JTLB
  485. */
  486. c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
  487. break;
  488. case PRID_IMP_RM9000:
  489. c->cputype = CPU_RM9000;
  490. __cpu_name[cpu] = "RM9000";
  491. c->isa_level = MIPS_CPU_ISA_IV;
  492. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  493. MIPS_CPU_LLSC;
  494. /*
  495. * Bit 29 in the info register of the RM9000
  496. * indicates if the TLB has 48 or 64 entries.
  497. *
  498. * 29 1 => 64 entry JTLB
  499. * 0 => 48 entry JTLB
  500. */
  501. c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
  502. break;
  503. case PRID_IMP_R8000:
  504. c->cputype = CPU_R8000;
  505. __cpu_name[cpu] = "RM8000";
  506. c->isa_level = MIPS_CPU_ISA_IV;
  507. c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
  508. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  509. MIPS_CPU_LLSC;
  510. c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
  511. break;
  512. case PRID_IMP_R10000:
  513. c->cputype = CPU_R10000;
  514. __cpu_name[cpu] = "R10000";
  515. c->isa_level = MIPS_CPU_ISA_IV;
  516. c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
  517. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  518. MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
  519. MIPS_CPU_LLSC;
  520. c->tlbsize = 64;
  521. break;
  522. case PRID_IMP_R12000:
  523. c->cputype = CPU_R12000;
  524. __cpu_name[cpu] = "R12000";
  525. c->isa_level = MIPS_CPU_ISA_IV;
  526. c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
  527. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  528. MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
  529. MIPS_CPU_LLSC;
  530. c->tlbsize = 64;
  531. break;
  532. case PRID_IMP_R14000:
  533. c->cputype = CPU_R14000;
  534. __cpu_name[cpu] = "R14000";
  535. c->isa_level = MIPS_CPU_ISA_IV;
  536. c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
  537. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  538. MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
  539. MIPS_CPU_LLSC;
  540. c->tlbsize = 64;
  541. break;
  542. case PRID_IMP_LOONGSON2:
  543. c->cputype = CPU_LOONGSON2;
  544. __cpu_name[cpu] = "ICT Loongson-2";
  545. c->isa_level = MIPS_CPU_ISA_III;
  546. c->options = R4K_OPTS |
  547. MIPS_CPU_FPU | MIPS_CPU_LLSC |
  548. MIPS_CPU_32FPR;
  549. c->tlbsize = 64;
  550. break;
  551. }
  552. }
  553. static char unknown_isa[] __cpuinitdata = KERN_ERR \
  554. "Unsupported ISA type, c0.config0: %d.";
  555. static inline unsigned int decode_config0(struct cpuinfo_mips *c)
  556. {
  557. unsigned int config0;
  558. int isa;
  559. config0 = read_c0_config();
  560. if (((config0 & MIPS_CONF_MT) >> 7) == 1)
  561. c->options |= MIPS_CPU_TLB;
  562. isa = (config0 & MIPS_CONF_AT) >> 13;
  563. switch (isa) {
  564. case 0:
  565. switch ((config0 & MIPS_CONF_AR) >> 10) {
  566. case 0:
  567. c->isa_level = MIPS_CPU_ISA_M32R1;
  568. break;
  569. case 1:
  570. c->isa_level = MIPS_CPU_ISA_M32R2;
  571. break;
  572. default:
  573. goto unknown;
  574. }
  575. break;
  576. case 2:
  577. switch ((config0 & MIPS_CONF_AR) >> 10) {
  578. case 0:
  579. c->isa_level = MIPS_CPU_ISA_M64R1;
  580. break;
  581. case 1:
  582. c->isa_level = MIPS_CPU_ISA_M64R2;
  583. break;
  584. default:
  585. goto unknown;
  586. }
  587. break;
  588. default:
  589. goto unknown;
  590. }
  591. return config0 & MIPS_CONF_M;
  592. unknown:
  593. panic(unknown_isa, config0);
  594. }
  595. static inline unsigned int decode_config1(struct cpuinfo_mips *c)
  596. {
  597. unsigned int config1;
  598. config1 = read_c0_config1();
  599. if (config1 & MIPS_CONF1_MD)
  600. c->ases |= MIPS_ASE_MDMX;
  601. if (config1 & MIPS_CONF1_WR)
  602. c->options |= MIPS_CPU_WATCH;
  603. if (config1 & MIPS_CONF1_CA)
  604. c->ases |= MIPS_ASE_MIPS16;
  605. if (config1 & MIPS_CONF1_EP)
  606. c->options |= MIPS_CPU_EJTAG;
  607. if (config1 & MIPS_CONF1_FP) {
  608. c->options |= MIPS_CPU_FPU;
  609. c->options |= MIPS_CPU_32FPR;
  610. }
  611. if (cpu_has_tlb)
  612. c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
  613. return config1 & MIPS_CONF_M;
  614. }
  615. static inline unsigned int decode_config2(struct cpuinfo_mips *c)
  616. {
  617. unsigned int config2;
  618. config2 = read_c0_config2();
  619. if (config2 & MIPS_CONF2_SL)
  620. c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
  621. return config2 & MIPS_CONF_M;
  622. }
  623. static inline unsigned int decode_config3(struct cpuinfo_mips *c)
  624. {
  625. unsigned int config3;
  626. config3 = read_c0_config3();
  627. if (config3 & MIPS_CONF3_SM)
  628. c->ases |= MIPS_ASE_SMARTMIPS;
  629. if (config3 & MIPS_CONF3_DSP)
  630. c->ases |= MIPS_ASE_DSP;
  631. if (config3 & MIPS_CONF3_VINT)
  632. c->options |= MIPS_CPU_VINT;
  633. if (config3 & MIPS_CONF3_VEIC)
  634. c->options |= MIPS_CPU_VEIC;
  635. if (config3 & MIPS_CONF3_MT)
  636. c->ases |= MIPS_ASE_MIPSMT;
  637. if (config3 & MIPS_CONF3_ULRI)
  638. c->options |= MIPS_CPU_ULRI;
  639. return config3 & MIPS_CONF_M;
  640. }
  641. static void __cpuinit decode_configs(struct cpuinfo_mips *c)
  642. {
  643. int ok;
  644. /* MIPS32 or MIPS64 compliant CPU. */
  645. c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
  646. MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
  647. c->scache.flags = MIPS_CACHE_NOT_PRESENT;
  648. ok = decode_config0(c); /* Read Config registers. */
  649. BUG_ON(!ok); /* Arch spec violation! */
  650. if (ok)
  651. ok = decode_config1(c);
  652. if (ok)
  653. ok = decode_config2(c);
  654. if (ok)
  655. ok = decode_config3(c);
  656. mips_probe_watch_registers(c);
  657. }
  658. #ifdef CONFIG_CPU_MIPSR2
  659. extern void spram_config(void);
  660. #else
  661. static inline void spram_config(void) {}
  662. #endif
  663. static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
  664. {
  665. decode_configs(c);
  666. switch (c->processor_id & 0xff00) {
  667. case PRID_IMP_4KC:
  668. c->cputype = CPU_4KC;
  669. __cpu_name[cpu] = "MIPS 4Kc";
  670. break;
  671. case PRID_IMP_4KEC:
  672. c->cputype = CPU_4KEC;
  673. __cpu_name[cpu] = "MIPS 4KEc";
  674. break;
  675. case PRID_IMP_4KECR2:
  676. c->cputype = CPU_4KEC;
  677. __cpu_name[cpu] = "MIPS 4KEc";
  678. break;
  679. case PRID_IMP_4KSC:
  680. case PRID_IMP_4KSD:
  681. c->cputype = CPU_4KSC;
  682. __cpu_name[cpu] = "MIPS 4KSc";
  683. break;
  684. case PRID_IMP_5KC:
  685. c->cputype = CPU_5KC;
  686. __cpu_name[cpu] = "MIPS 5Kc";
  687. break;
  688. case PRID_IMP_20KC:
  689. c->cputype = CPU_20KC;
  690. __cpu_name[cpu] = "MIPS 20Kc";
  691. break;
  692. case PRID_IMP_24K:
  693. case PRID_IMP_24KE:
  694. c->cputype = CPU_24K;
  695. __cpu_name[cpu] = "MIPS 24Kc";
  696. break;
  697. case PRID_IMP_25KF:
  698. c->cputype = CPU_25KF;
  699. __cpu_name[cpu] = "MIPS 25Kc";
  700. break;
  701. case PRID_IMP_34K:
  702. c->cputype = CPU_34K;
  703. __cpu_name[cpu] = "MIPS 34Kc";
  704. break;
  705. case PRID_IMP_74K:
  706. c->cputype = CPU_74K;
  707. __cpu_name[cpu] = "MIPS 74Kc";
  708. break;
  709. case PRID_IMP_1004K:
  710. c->cputype = CPU_1004K;
  711. __cpu_name[cpu] = "MIPS 1004Kc";
  712. break;
  713. }
  714. spram_config();
  715. }
  716. static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
  717. {
  718. decode_configs(c);
  719. switch (c->processor_id & 0xff00) {
  720. case PRID_IMP_AU1_REV1:
  721. case PRID_IMP_AU1_REV2:
  722. switch ((c->processor_id >> 24) & 0xff) {
  723. case 0:
  724. c->cputype = CPU_AU1000;
  725. __cpu_name[cpu] = "Au1000";
  726. break;
  727. case 1:
  728. c->cputype = CPU_AU1500;
  729. __cpu_name[cpu] = "Au1500";
  730. break;
  731. case 2:
  732. c->cputype = CPU_AU1100;
  733. __cpu_name[cpu] = "Au1100";
  734. break;
  735. case 3:
  736. c->cputype = CPU_AU1550;
  737. __cpu_name[cpu] = "Au1550";
  738. break;
  739. case 4:
  740. c->cputype = CPU_AU1200;
  741. __cpu_name[cpu] = "Au1200";
  742. if ((c->processor_id & 0xff) == 2) {
  743. c->cputype = CPU_AU1250;
  744. __cpu_name[cpu] = "Au1250";
  745. }
  746. break;
  747. case 5:
  748. c->cputype = CPU_AU1210;
  749. __cpu_name[cpu] = "Au1210";
  750. break;
  751. default:
  752. panic("Unknown Au Core!");
  753. break;
  754. }
  755. break;
  756. }
  757. }
  758. static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
  759. {
  760. decode_configs(c);
  761. switch (c->processor_id & 0xff00) {
  762. case PRID_IMP_SB1:
  763. c->cputype = CPU_SB1;
  764. __cpu_name[cpu] = "SiByte SB1";
  765. /* FPU in pass1 is known to have issues. */
  766. if ((c->processor_id & 0xff) < 0x02)
  767. c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
  768. break;
  769. case PRID_IMP_SB1A:
  770. c->cputype = CPU_SB1A;
  771. __cpu_name[cpu] = "SiByte SB1A";
  772. break;
  773. }
  774. }
  775. static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
  776. {
  777. decode_configs(c);
  778. switch (c->processor_id & 0xff00) {
  779. case PRID_IMP_SR71000:
  780. c->cputype = CPU_SR71000;
  781. __cpu_name[cpu] = "Sandcraft SR71000";
  782. c->scache.ways = 8;
  783. c->tlbsize = 64;
  784. break;
  785. }
  786. }
  787. static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
  788. {
  789. decode_configs(c);
  790. switch (c->processor_id & 0xff00) {
  791. case PRID_IMP_PR4450:
  792. c->cputype = CPU_PR4450;
  793. __cpu_name[cpu] = "Philips PR4450";
  794. c->isa_level = MIPS_CPU_ISA_M32R1;
  795. break;
  796. }
  797. }
  798. static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
  799. {
  800. decode_configs(c);
  801. switch (c->processor_id & 0xff00) {
  802. case PRID_IMP_BCM3302:
  803. c->cputype = CPU_BCM3302;
  804. __cpu_name[cpu] = "Broadcom BCM3302";
  805. break;
  806. case PRID_IMP_BCM4710:
  807. c->cputype = CPU_BCM4710;
  808. __cpu_name[cpu] = "Broadcom BCM4710";
  809. break;
  810. }
  811. }
  812. const char *__cpu_name[NR_CPUS];
  813. __cpuinit void cpu_probe(void)
  814. {
  815. struct cpuinfo_mips *c = &current_cpu_data;
  816. unsigned int cpu = smp_processor_id();
  817. c->processor_id = PRID_IMP_UNKNOWN;
  818. c->fpu_id = FPIR_IMP_NONE;
  819. c->cputype = CPU_UNKNOWN;
  820. c->processor_id = read_c0_prid();
  821. switch (c->processor_id & 0xff0000) {
  822. case PRID_COMP_LEGACY:
  823. cpu_probe_legacy(c, cpu);
  824. break;
  825. case PRID_COMP_MIPS:
  826. cpu_probe_mips(c, cpu);
  827. break;
  828. case PRID_COMP_ALCHEMY:
  829. cpu_probe_alchemy(c, cpu);
  830. break;
  831. case PRID_COMP_SIBYTE:
  832. cpu_probe_sibyte(c, cpu);
  833. break;
  834. case PRID_COMP_BROADCOM:
  835. cpu_probe_broadcom(c, cpu);
  836. break;
  837. case PRID_COMP_SANDCRAFT:
  838. cpu_probe_sandcraft(c, cpu);
  839. break;
  840. case PRID_COMP_NXP:
  841. cpu_probe_nxp(c, cpu);
  842. break;
  843. }
  844. BUG_ON(!__cpu_name[cpu]);
  845. BUG_ON(c->cputype == CPU_UNKNOWN);
  846. /*
  847. * Platform code can force the cpu type to optimize code
  848. * generation. In that case be sure the cpu type is correctly
  849. * manually setup otherwise it could trigger some nasty bugs.
  850. */
  851. BUG_ON(current_cpu_type() != c->cputype);
  852. if (c->options & MIPS_CPU_FPU) {
  853. c->fpu_id = cpu_get_fpu_id();
  854. if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
  855. c->isa_level == MIPS_CPU_ISA_M32R2 ||
  856. c->isa_level == MIPS_CPU_ISA_M64R1 ||
  857. c->isa_level == MIPS_CPU_ISA_M64R2) {
  858. if (c->fpu_id & MIPS_FPIR_3D)
  859. c->ases |= MIPS_ASE_MIPS3D;
  860. }
  861. }
  862. if (cpu_has_mips_r2)
  863. c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
  864. else
  865. c->srsets = 1;
  866. }
  867. __cpuinit void cpu_report(void)
  868. {
  869. struct cpuinfo_mips *c = &current_cpu_data;
  870. printk(KERN_INFO "CPU revision is: %08x (%s)\n",
  871. c->processor_id, cpu_name_string());
  872. if (c->options & MIPS_CPU_FPU)
  873. printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
  874. }