cpu-probe.c 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148
  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, 2011, 2012 MIPS Technologies, 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/smp.h>
  18. #include <linux/stddef.h>
  19. #include <linux/export.h>
  20. #include <asm/bugs.h>
  21. #include <asm/cpu.h>
  22. #include <asm/cpu-features.h>
  23. #include <asm/cpu-type.h>
  24. #include <asm/fpu.h>
  25. #include <asm/mipsregs.h>
  26. #include <asm/mipsmtregs.h>
  27. #include <asm/msa.h>
  28. #include <asm/watch.h>
  29. #include <asm/elf.h>
  30. #include <asm/pgtable-bits.h>
  31. #include <asm/spram.h>
  32. #include <linux/uaccess.h>
  33. /* Hardware capabilities */
  34. unsigned int elf_hwcap __read_mostly;
  35. EXPORT_SYMBOL_GPL(elf_hwcap);
  36. /*
  37. * Get the FPU Implementation/Revision.
  38. */
  39. static inline unsigned long cpu_get_fpu_id(void)
  40. {
  41. unsigned long tmp, fpu_id;
  42. tmp = read_c0_status();
  43. __enable_fpu(FPU_AS_IS);
  44. fpu_id = read_32bit_cp1_register(CP1_REVISION);
  45. write_c0_status(tmp);
  46. return fpu_id;
  47. }
  48. /*
  49. * Check if the CPU has an external FPU.
  50. */
  51. static inline int __cpu_has_fpu(void)
  52. {
  53. return (cpu_get_fpu_id() & FPIR_IMP_MASK) != FPIR_IMP_NONE;
  54. }
  55. static inline unsigned long cpu_get_msa_id(void)
  56. {
  57. unsigned long status, msa_id;
  58. status = read_c0_status();
  59. __enable_fpu(FPU_64BIT);
  60. enable_msa();
  61. msa_id = read_msa_ir();
  62. disable_msa();
  63. write_c0_status(status);
  64. return msa_id;
  65. }
  66. /*
  67. * Determine the FCSR mask for FPU hardware.
  68. */
  69. static inline void cpu_set_fpu_fcsr_mask(struct cpuinfo_mips *c)
  70. {
  71. unsigned long sr, mask, fcsr, fcsr0, fcsr1;
  72. fcsr = c->fpu_csr31;
  73. mask = FPU_CSR_ALL_X | FPU_CSR_ALL_E | FPU_CSR_ALL_S | FPU_CSR_RM;
  74. sr = read_c0_status();
  75. __enable_fpu(FPU_AS_IS);
  76. fcsr0 = fcsr & mask;
  77. write_32bit_cp1_register(CP1_STATUS, fcsr0);
  78. fcsr0 = read_32bit_cp1_register(CP1_STATUS);
  79. fcsr1 = fcsr | ~mask;
  80. write_32bit_cp1_register(CP1_STATUS, fcsr1);
  81. fcsr1 = read_32bit_cp1_register(CP1_STATUS);
  82. write_32bit_cp1_register(CP1_STATUS, fcsr);
  83. write_c0_status(sr);
  84. c->fpu_msk31 = ~(fcsr0 ^ fcsr1) & ~mask;
  85. }
  86. /*
  87. * Determine the IEEE 754 NaN encodings and ABS.fmt/NEG.fmt execution modes
  88. * supported by FPU hardware.
  89. */
  90. static void cpu_set_fpu_2008(struct cpuinfo_mips *c)
  91. {
  92. if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
  93. MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
  94. MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6)) {
  95. unsigned long sr, fir, fcsr, fcsr0, fcsr1;
  96. sr = read_c0_status();
  97. __enable_fpu(FPU_AS_IS);
  98. fir = read_32bit_cp1_register(CP1_REVISION);
  99. if (fir & MIPS_FPIR_HAS2008) {
  100. fcsr = read_32bit_cp1_register(CP1_STATUS);
  101. fcsr0 = fcsr & ~(FPU_CSR_ABS2008 | FPU_CSR_NAN2008);
  102. write_32bit_cp1_register(CP1_STATUS, fcsr0);
  103. fcsr0 = read_32bit_cp1_register(CP1_STATUS);
  104. fcsr1 = fcsr | FPU_CSR_ABS2008 | FPU_CSR_NAN2008;
  105. write_32bit_cp1_register(CP1_STATUS, fcsr1);
  106. fcsr1 = read_32bit_cp1_register(CP1_STATUS);
  107. write_32bit_cp1_register(CP1_STATUS, fcsr);
  108. if (!(fcsr0 & FPU_CSR_NAN2008))
  109. c->options |= MIPS_CPU_NAN_LEGACY;
  110. if (fcsr1 & FPU_CSR_NAN2008)
  111. c->options |= MIPS_CPU_NAN_2008;
  112. if ((fcsr0 ^ fcsr1) & FPU_CSR_ABS2008)
  113. c->fpu_msk31 &= ~FPU_CSR_ABS2008;
  114. else
  115. c->fpu_csr31 |= fcsr & FPU_CSR_ABS2008;
  116. if ((fcsr0 ^ fcsr1) & FPU_CSR_NAN2008)
  117. c->fpu_msk31 &= ~FPU_CSR_NAN2008;
  118. else
  119. c->fpu_csr31 |= fcsr & FPU_CSR_NAN2008;
  120. } else {
  121. c->options |= MIPS_CPU_NAN_LEGACY;
  122. }
  123. write_c0_status(sr);
  124. } else {
  125. c->options |= MIPS_CPU_NAN_LEGACY;
  126. }
  127. }
  128. /*
  129. * IEEE 754 conformance mode to use. Affects the NaN encoding and the
  130. * ABS.fmt/NEG.fmt execution mode.
  131. */
  132. static enum { STRICT, LEGACY, STD2008, RELAXED } ieee754 = STRICT;
  133. /*
  134. * Set the IEEE 754 NaN encodings and the ABS.fmt/NEG.fmt execution modes
  135. * to support by the FPU emulator according to the IEEE 754 conformance
  136. * mode selected. Note that "relaxed" straps the emulator so that it
  137. * allows 2008-NaN binaries even for legacy processors.
  138. */
  139. static void cpu_set_nofpu_2008(struct cpuinfo_mips *c)
  140. {
  141. c->options &= ~(MIPS_CPU_NAN_2008 | MIPS_CPU_NAN_LEGACY);
  142. c->fpu_csr31 &= ~(FPU_CSR_ABS2008 | FPU_CSR_NAN2008);
  143. c->fpu_msk31 &= ~(FPU_CSR_ABS2008 | FPU_CSR_NAN2008);
  144. switch (ieee754) {
  145. case STRICT:
  146. if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
  147. MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
  148. MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6)) {
  149. c->options |= MIPS_CPU_NAN_2008 | MIPS_CPU_NAN_LEGACY;
  150. } else {
  151. c->options |= MIPS_CPU_NAN_LEGACY;
  152. c->fpu_msk31 |= FPU_CSR_ABS2008 | FPU_CSR_NAN2008;
  153. }
  154. break;
  155. case LEGACY:
  156. c->options |= MIPS_CPU_NAN_LEGACY;
  157. c->fpu_msk31 |= FPU_CSR_ABS2008 | FPU_CSR_NAN2008;
  158. break;
  159. case STD2008:
  160. c->options |= MIPS_CPU_NAN_2008;
  161. c->fpu_csr31 |= FPU_CSR_ABS2008 | FPU_CSR_NAN2008;
  162. c->fpu_msk31 |= FPU_CSR_ABS2008 | FPU_CSR_NAN2008;
  163. break;
  164. case RELAXED:
  165. c->options |= MIPS_CPU_NAN_2008 | MIPS_CPU_NAN_LEGACY;
  166. break;
  167. }
  168. }
  169. /*
  170. * Override the IEEE 754 NaN encoding and ABS.fmt/NEG.fmt execution mode
  171. * according to the "ieee754=" parameter.
  172. */
  173. static void cpu_set_nan_2008(struct cpuinfo_mips *c)
  174. {
  175. switch (ieee754) {
  176. case STRICT:
  177. mips_use_nan_legacy = !!cpu_has_nan_legacy;
  178. mips_use_nan_2008 = !!cpu_has_nan_2008;
  179. break;
  180. case LEGACY:
  181. mips_use_nan_legacy = !!cpu_has_nan_legacy;
  182. mips_use_nan_2008 = !cpu_has_nan_legacy;
  183. break;
  184. case STD2008:
  185. mips_use_nan_legacy = !cpu_has_nan_2008;
  186. mips_use_nan_2008 = !!cpu_has_nan_2008;
  187. break;
  188. case RELAXED:
  189. mips_use_nan_legacy = true;
  190. mips_use_nan_2008 = true;
  191. break;
  192. }
  193. }
  194. /*
  195. * IEEE 754 NaN encoding and ABS.fmt/NEG.fmt execution mode override
  196. * settings:
  197. *
  198. * strict: accept binaries that request a NaN encoding supported by the FPU
  199. * legacy: only accept legacy-NaN binaries
  200. * 2008: only accept 2008-NaN binaries
  201. * relaxed: accept any binaries regardless of whether supported by the FPU
  202. */
  203. static int __init ieee754_setup(char *s)
  204. {
  205. if (!s)
  206. return -1;
  207. else if (!strcmp(s, "strict"))
  208. ieee754 = STRICT;
  209. else if (!strcmp(s, "legacy"))
  210. ieee754 = LEGACY;
  211. else if (!strcmp(s, "2008"))
  212. ieee754 = STD2008;
  213. else if (!strcmp(s, "relaxed"))
  214. ieee754 = RELAXED;
  215. else
  216. return -1;
  217. if (!(boot_cpu_data.options & MIPS_CPU_FPU))
  218. cpu_set_nofpu_2008(&boot_cpu_data);
  219. cpu_set_nan_2008(&boot_cpu_data);
  220. return 0;
  221. }
  222. early_param("ieee754", ieee754_setup);
  223. /*
  224. * Set the FIR feature flags for the FPU emulator.
  225. */
  226. static void cpu_set_nofpu_id(struct cpuinfo_mips *c)
  227. {
  228. u32 value;
  229. value = 0;
  230. if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
  231. MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
  232. MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6))
  233. value |= MIPS_FPIR_D | MIPS_FPIR_S;
  234. if (c->isa_level & (MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
  235. MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6))
  236. value |= MIPS_FPIR_F64 | MIPS_FPIR_L | MIPS_FPIR_W;
  237. if (c->options & MIPS_CPU_NAN_2008)
  238. value |= MIPS_FPIR_HAS2008;
  239. c->fpu_id = value;
  240. }
  241. /* Determined FPU emulator mask to use for the boot CPU with "nofpu". */
  242. static unsigned int mips_nofpu_msk31;
  243. /*
  244. * Set options for FPU hardware.
  245. */
  246. static void cpu_set_fpu_opts(struct cpuinfo_mips *c)
  247. {
  248. c->fpu_id = cpu_get_fpu_id();
  249. mips_nofpu_msk31 = c->fpu_msk31;
  250. if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
  251. MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
  252. MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6)) {
  253. if (c->fpu_id & MIPS_FPIR_3D)
  254. c->ases |= MIPS_ASE_MIPS3D;
  255. if (c->fpu_id & MIPS_FPIR_UFRP)
  256. c->options |= MIPS_CPU_UFR;
  257. if (c->fpu_id & MIPS_FPIR_FREP)
  258. c->options |= MIPS_CPU_FRE;
  259. }
  260. cpu_set_fpu_fcsr_mask(c);
  261. cpu_set_fpu_2008(c);
  262. cpu_set_nan_2008(c);
  263. }
  264. /*
  265. * Set options for the FPU emulator.
  266. */
  267. static void cpu_set_nofpu_opts(struct cpuinfo_mips *c)
  268. {
  269. c->options &= ~MIPS_CPU_FPU;
  270. c->fpu_msk31 = mips_nofpu_msk31;
  271. cpu_set_nofpu_2008(c);
  272. cpu_set_nan_2008(c);
  273. cpu_set_nofpu_id(c);
  274. }
  275. static int mips_fpu_disabled;
  276. static int __init fpu_disable(char *s)
  277. {
  278. cpu_set_nofpu_opts(&boot_cpu_data);
  279. mips_fpu_disabled = 1;
  280. return 1;
  281. }
  282. __setup("nofpu", fpu_disable);
  283. static int mips_dsp_disabled;
  284. static int __init dsp_disable(char *s)
  285. {
  286. cpu_data[0].ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
  287. mips_dsp_disabled = 1;
  288. return 1;
  289. }
  290. __setup("nodsp", dsp_disable);
  291. static int mips_htw_disabled;
  292. static int __init htw_disable(char *s)
  293. {
  294. mips_htw_disabled = 1;
  295. cpu_data[0].options &= ~MIPS_CPU_HTW;
  296. write_c0_pwctl(read_c0_pwctl() &
  297. ~(1 << MIPS_PWCTL_PWEN_SHIFT));
  298. return 1;
  299. }
  300. __setup("nohtw", htw_disable);
  301. static int mips_ftlb_disabled;
  302. static int mips_has_ftlb_configured;
  303. enum ftlb_flags {
  304. FTLB_EN = 1 << 0,
  305. FTLB_SET_PROB = 1 << 1,
  306. };
  307. static int set_ftlb_enable(struct cpuinfo_mips *c, enum ftlb_flags flags);
  308. static int __init ftlb_disable(char *s)
  309. {
  310. unsigned int config4, mmuextdef;
  311. /*
  312. * If the core hasn't done any FTLB configuration, there is nothing
  313. * for us to do here.
  314. */
  315. if (!mips_has_ftlb_configured)
  316. return 1;
  317. /* Disable it in the boot cpu */
  318. if (set_ftlb_enable(&cpu_data[0], 0)) {
  319. pr_warn("Can't turn FTLB off\n");
  320. return 1;
  321. }
  322. config4 = read_c0_config4();
  323. /* Check that FTLB has been disabled */
  324. mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
  325. /* MMUSIZEEXT == VTLB ON, FTLB OFF */
  326. if (mmuextdef == MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT) {
  327. /* This should never happen */
  328. pr_warn("FTLB could not be disabled!\n");
  329. return 1;
  330. }
  331. mips_ftlb_disabled = 1;
  332. mips_has_ftlb_configured = 0;
  333. /*
  334. * noftlb is mainly used for debug purposes so print
  335. * an informative message instead of using pr_debug()
  336. */
  337. pr_info("FTLB has been disabled\n");
  338. /*
  339. * Some of these bits are duplicated in the decode_config4.
  340. * MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT is the only possible case
  341. * once FTLB has been disabled so undo what decode_config4 did.
  342. */
  343. cpu_data[0].tlbsize -= cpu_data[0].tlbsizeftlbways *
  344. cpu_data[0].tlbsizeftlbsets;
  345. cpu_data[0].tlbsizeftlbsets = 0;
  346. cpu_data[0].tlbsizeftlbways = 0;
  347. return 1;
  348. }
  349. __setup("noftlb", ftlb_disable);
  350. /*
  351. * Check if the CPU has per tc perf counters
  352. */
  353. static inline void cpu_set_mt_per_tc_perf(struct cpuinfo_mips *c)
  354. {
  355. if (read_c0_config7() & MTI_CONF7_PTC)
  356. c->options |= MIPS_CPU_MT_PER_TC_PERF_COUNTERS;
  357. }
  358. static inline void check_errata(void)
  359. {
  360. struct cpuinfo_mips *c = &current_cpu_data;
  361. switch (current_cpu_type()) {
  362. case CPU_34K:
  363. /*
  364. * Erratum "RPS May Cause Incorrect Instruction Execution"
  365. * This code only handles VPE0, any SMP/RTOS code
  366. * making use of VPE1 will be responsable for that VPE.
  367. */
  368. if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
  369. write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
  370. break;
  371. default:
  372. break;
  373. }
  374. }
  375. void __init check_bugs32(void)
  376. {
  377. check_errata();
  378. }
  379. /*
  380. * Probe whether cpu has config register by trying to play with
  381. * alternate cache bit and see whether it matters.
  382. * It's used by cpu_probe to distinguish between R3000A and R3081.
  383. */
  384. static inline int cpu_has_confreg(void)
  385. {
  386. #ifdef CONFIG_CPU_R3000
  387. extern unsigned long r3k_cache_size(unsigned long);
  388. unsigned long size1, size2;
  389. unsigned long cfg = read_c0_conf();
  390. size1 = r3k_cache_size(ST0_ISC);
  391. write_c0_conf(cfg ^ R30XX_CONF_AC);
  392. size2 = r3k_cache_size(ST0_ISC);
  393. write_c0_conf(cfg);
  394. return size1 != size2;
  395. #else
  396. return 0;
  397. #endif
  398. }
  399. static inline void set_elf_platform(int cpu, const char *plat)
  400. {
  401. if (cpu == 0)
  402. __elf_platform = plat;
  403. }
  404. static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
  405. {
  406. #ifdef __NEED_VMBITS_PROBE
  407. write_c0_entryhi(0x3fffffffffffe000ULL);
  408. back_to_back_c0_hazard();
  409. c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
  410. #endif
  411. }
  412. static void set_isa(struct cpuinfo_mips *c, unsigned int isa)
  413. {
  414. switch (isa) {
  415. case MIPS_CPU_ISA_M64R2:
  416. c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2;
  417. case MIPS_CPU_ISA_M64R1:
  418. c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1;
  419. case MIPS_CPU_ISA_V:
  420. c->isa_level |= MIPS_CPU_ISA_V;
  421. case MIPS_CPU_ISA_IV:
  422. c->isa_level |= MIPS_CPU_ISA_IV;
  423. case MIPS_CPU_ISA_III:
  424. c->isa_level |= MIPS_CPU_ISA_II | MIPS_CPU_ISA_III;
  425. break;
  426. /* R6 incompatible with everything else */
  427. case MIPS_CPU_ISA_M64R6:
  428. c->isa_level |= MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6;
  429. case MIPS_CPU_ISA_M32R6:
  430. c->isa_level |= MIPS_CPU_ISA_M32R6;
  431. /* Break here so we don't add incompatible ISAs */
  432. break;
  433. case MIPS_CPU_ISA_M32R2:
  434. c->isa_level |= MIPS_CPU_ISA_M32R2;
  435. case MIPS_CPU_ISA_M32R1:
  436. c->isa_level |= MIPS_CPU_ISA_M32R1;
  437. case MIPS_CPU_ISA_II:
  438. c->isa_level |= MIPS_CPU_ISA_II;
  439. break;
  440. }
  441. }
  442. static char unknown_isa[] = KERN_ERR \
  443. "Unsupported ISA type, c0.config0: %d.";
  444. static unsigned int calculate_ftlb_probability(struct cpuinfo_mips *c)
  445. {
  446. unsigned int probability = c->tlbsize / c->tlbsizevtlb;
  447. /*
  448. * 0 = All TLBWR instructions go to FTLB
  449. * 1 = 15:1: For every 16 TBLWR instructions, 15 go to the
  450. * FTLB and 1 goes to the VTLB.
  451. * 2 = 7:1: As above with 7:1 ratio.
  452. * 3 = 3:1: As above with 3:1 ratio.
  453. *
  454. * Use the linear midpoint as the probability threshold.
  455. */
  456. if (probability >= 12)
  457. return 1;
  458. else if (probability >= 6)
  459. return 2;
  460. else
  461. /*
  462. * So FTLB is less than 4 times bigger than VTLB.
  463. * A 3:1 ratio can still be useful though.
  464. */
  465. return 3;
  466. }
  467. static int set_ftlb_enable(struct cpuinfo_mips *c, enum ftlb_flags flags)
  468. {
  469. unsigned int config;
  470. /* It's implementation dependent how the FTLB can be enabled */
  471. switch (c->cputype) {
  472. case CPU_PROAPTIV:
  473. case CPU_P5600:
  474. case CPU_P6600:
  475. /* proAptiv & related cores use Config6 to enable the FTLB */
  476. config = read_c0_config6();
  477. if (flags & FTLB_EN)
  478. config |= MIPS_CONF6_FTLBEN;
  479. else
  480. config &= ~MIPS_CONF6_FTLBEN;
  481. if (flags & FTLB_SET_PROB) {
  482. config &= ~(3 << MIPS_CONF6_FTLBP_SHIFT);
  483. config |= calculate_ftlb_probability(c)
  484. << MIPS_CONF6_FTLBP_SHIFT;
  485. }
  486. write_c0_config6(config);
  487. back_to_back_c0_hazard();
  488. break;
  489. case CPU_I6400:
  490. case CPU_I6500:
  491. /* There's no way to disable the FTLB */
  492. if (!(flags & FTLB_EN))
  493. return 1;
  494. return 0;
  495. case CPU_LOONGSON3:
  496. /* Flush ITLB, DTLB, VTLB and FTLB */
  497. write_c0_diag(LOONGSON_DIAG_ITLB | LOONGSON_DIAG_DTLB |
  498. LOONGSON_DIAG_VTLB | LOONGSON_DIAG_FTLB);
  499. /* Loongson-3 cores use Config6 to enable the FTLB */
  500. config = read_c0_config6();
  501. if (flags & FTLB_EN)
  502. /* Enable FTLB */
  503. write_c0_config6(config & ~MIPS_CONF6_FTLBDIS);
  504. else
  505. /* Disable FTLB */
  506. write_c0_config6(config | MIPS_CONF6_FTLBDIS);
  507. break;
  508. default:
  509. return 1;
  510. }
  511. return 0;
  512. }
  513. static inline unsigned int decode_config0(struct cpuinfo_mips *c)
  514. {
  515. unsigned int config0;
  516. int isa, mt;
  517. config0 = read_c0_config();
  518. /*
  519. * Look for Standard TLB or Dual VTLB and FTLB
  520. */
  521. mt = config0 & MIPS_CONF_MT;
  522. if (mt == MIPS_CONF_MT_TLB)
  523. c->options |= MIPS_CPU_TLB;
  524. else if (mt == MIPS_CONF_MT_FTLB)
  525. c->options |= MIPS_CPU_TLB | MIPS_CPU_FTLB;
  526. isa = (config0 & MIPS_CONF_AT) >> 13;
  527. switch (isa) {
  528. case 0:
  529. switch ((config0 & MIPS_CONF_AR) >> 10) {
  530. case 0:
  531. set_isa(c, MIPS_CPU_ISA_M32R1);
  532. break;
  533. case 1:
  534. set_isa(c, MIPS_CPU_ISA_M32R2);
  535. break;
  536. case 2:
  537. set_isa(c, MIPS_CPU_ISA_M32R6);
  538. break;
  539. default:
  540. goto unknown;
  541. }
  542. break;
  543. case 2:
  544. switch ((config0 & MIPS_CONF_AR) >> 10) {
  545. case 0:
  546. set_isa(c, MIPS_CPU_ISA_M64R1);
  547. break;
  548. case 1:
  549. set_isa(c, MIPS_CPU_ISA_M64R2);
  550. break;
  551. case 2:
  552. set_isa(c, MIPS_CPU_ISA_M64R6);
  553. break;
  554. default:
  555. goto unknown;
  556. }
  557. break;
  558. default:
  559. goto unknown;
  560. }
  561. return config0 & MIPS_CONF_M;
  562. unknown:
  563. panic(unknown_isa, config0);
  564. }
  565. static inline unsigned int decode_config1(struct cpuinfo_mips *c)
  566. {
  567. unsigned int config1;
  568. config1 = read_c0_config1();
  569. if (config1 & MIPS_CONF1_MD)
  570. c->ases |= MIPS_ASE_MDMX;
  571. if (config1 & MIPS_CONF1_PC)
  572. c->options |= MIPS_CPU_PERF;
  573. if (config1 & MIPS_CONF1_WR)
  574. c->options |= MIPS_CPU_WATCH;
  575. if (config1 & MIPS_CONF1_CA)
  576. c->ases |= MIPS_ASE_MIPS16;
  577. if (config1 & MIPS_CONF1_EP)
  578. c->options |= MIPS_CPU_EJTAG;
  579. if (config1 & MIPS_CONF1_FP) {
  580. c->options |= MIPS_CPU_FPU;
  581. c->options |= MIPS_CPU_32FPR;
  582. }
  583. if (cpu_has_tlb) {
  584. c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
  585. c->tlbsizevtlb = c->tlbsize;
  586. c->tlbsizeftlbsets = 0;
  587. }
  588. return config1 & MIPS_CONF_M;
  589. }
  590. static inline unsigned int decode_config2(struct cpuinfo_mips *c)
  591. {
  592. unsigned int config2;
  593. config2 = read_c0_config2();
  594. if (config2 & MIPS_CONF2_SL)
  595. c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
  596. return config2 & MIPS_CONF_M;
  597. }
  598. static inline unsigned int decode_config3(struct cpuinfo_mips *c)
  599. {
  600. unsigned int config3;
  601. config3 = read_c0_config3();
  602. if (config3 & MIPS_CONF3_SM) {
  603. c->ases |= MIPS_ASE_SMARTMIPS;
  604. c->options |= MIPS_CPU_RIXI | MIPS_CPU_CTXTC;
  605. }
  606. if (config3 & MIPS_CONF3_RXI)
  607. c->options |= MIPS_CPU_RIXI;
  608. if (config3 & MIPS_CONF3_CTXTC)
  609. c->options |= MIPS_CPU_CTXTC;
  610. if (config3 & MIPS_CONF3_DSP)
  611. c->ases |= MIPS_ASE_DSP;
  612. if (config3 & MIPS_CONF3_DSP2P) {
  613. c->ases |= MIPS_ASE_DSP2P;
  614. if (cpu_has_mips_r6)
  615. c->ases |= MIPS_ASE_DSP3;
  616. }
  617. if (config3 & MIPS_CONF3_VINT)
  618. c->options |= MIPS_CPU_VINT;
  619. if (config3 & MIPS_CONF3_VEIC)
  620. c->options |= MIPS_CPU_VEIC;
  621. if (config3 & MIPS_CONF3_LPA)
  622. c->options |= MIPS_CPU_LPA;
  623. if (config3 & MIPS_CONF3_MT)
  624. c->ases |= MIPS_ASE_MIPSMT;
  625. if (config3 & MIPS_CONF3_ULRI)
  626. c->options |= MIPS_CPU_ULRI;
  627. if (config3 & MIPS_CONF3_ISA)
  628. c->options |= MIPS_CPU_MICROMIPS;
  629. if (config3 & MIPS_CONF3_VZ)
  630. c->ases |= MIPS_ASE_VZ;
  631. if (config3 & MIPS_CONF3_SC)
  632. c->options |= MIPS_CPU_SEGMENTS;
  633. if (config3 & MIPS_CONF3_BI)
  634. c->options |= MIPS_CPU_BADINSTR;
  635. if (config3 & MIPS_CONF3_BP)
  636. c->options |= MIPS_CPU_BADINSTRP;
  637. if (config3 & MIPS_CONF3_MSA)
  638. c->ases |= MIPS_ASE_MSA;
  639. if (config3 & MIPS_CONF3_PW) {
  640. c->htw_seq = 0;
  641. c->options |= MIPS_CPU_HTW;
  642. }
  643. if (config3 & MIPS_CONF3_CDMM)
  644. c->options |= MIPS_CPU_CDMM;
  645. if (config3 & MIPS_CONF3_SP)
  646. c->options |= MIPS_CPU_SP;
  647. return config3 & MIPS_CONF_M;
  648. }
  649. static inline unsigned int decode_config4(struct cpuinfo_mips *c)
  650. {
  651. unsigned int config4;
  652. unsigned int newcf4;
  653. unsigned int mmuextdef;
  654. unsigned int ftlb_page = MIPS_CONF4_FTLBPAGESIZE;
  655. unsigned long asid_mask;
  656. config4 = read_c0_config4();
  657. if (cpu_has_tlb) {
  658. if (((config4 & MIPS_CONF4_IE) >> 29) == 2)
  659. c->options |= MIPS_CPU_TLBINV;
  660. /*
  661. * R6 has dropped the MMUExtDef field from config4.
  662. * On R6 the fields always describe the FTLB, and only if it is
  663. * present according to Config.MT.
  664. */
  665. if (!cpu_has_mips_r6)
  666. mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
  667. else if (cpu_has_ftlb)
  668. mmuextdef = MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT;
  669. else
  670. mmuextdef = 0;
  671. switch (mmuextdef) {
  672. case MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT:
  673. c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
  674. c->tlbsizevtlb = c->tlbsize;
  675. break;
  676. case MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT:
  677. c->tlbsizevtlb +=
  678. ((config4 & MIPS_CONF4_VTLBSIZEEXT) >>
  679. MIPS_CONF4_VTLBSIZEEXT_SHIFT) * 0x40;
  680. c->tlbsize = c->tlbsizevtlb;
  681. ftlb_page = MIPS_CONF4_VFTLBPAGESIZE;
  682. /* fall through */
  683. case MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT:
  684. if (mips_ftlb_disabled)
  685. break;
  686. newcf4 = (config4 & ~ftlb_page) |
  687. (page_size_ftlb(mmuextdef) <<
  688. MIPS_CONF4_FTLBPAGESIZE_SHIFT);
  689. write_c0_config4(newcf4);
  690. back_to_back_c0_hazard();
  691. config4 = read_c0_config4();
  692. if (config4 != newcf4) {
  693. pr_err("PAGE_SIZE 0x%lx is not supported by FTLB (config4=0x%x)\n",
  694. PAGE_SIZE, config4);
  695. /* Switch FTLB off */
  696. set_ftlb_enable(c, 0);
  697. mips_ftlb_disabled = 1;
  698. break;
  699. }
  700. c->tlbsizeftlbsets = 1 <<
  701. ((config4 & MIPS_CONF4_FTLBSETS) >>
  702. MIPS_CONF4_FTLBSETS_SHIFT);
  703. c->tlbsizeftlbways = ((config4 & MIPS_CONF4_FTLBWAYS) >>
  704. MIPS_CONF4_FTLBWAYS_SHIFT) + 2;
  705. c->tlbsize += c->tlbsizeftlbways * c->tlbsizeftlbsets;
  706. mips_has_ftlb_configured = 1;
  707. break;
  708. }
  709. }
  710. c->kscratch_mask = (config4 & MIPS_CONF4_KSCREXIST)
  711. >> MIPS_CONF4_KSCREXIST_SHIFT;
  712. asid_mask = MIPS_ENTRYHI_ASID;
  713. if (config4 & MIPS_CONF4_AE)
  714. asid_mask |= MIPS_ENTRYHI_ASIDX;
  715. set_cpu_asid_mask(c, asid_mask);
  716. /*
  717. * Warn if the computed ASID mask doesn't match the mask the kernel
  718. * is built for. This may indicate either a serious problem or an
  719. * easy optimisation opportunity, but either way should be addressed.
  720. */
  721. WARN_ON(asid_mask != cpu_asid_mask(c));
  722. return config4 & MIPS_CONF_M;
  723. }
  724. static inline unsigned int decode_config5(struct cpuinfo_mips *c)
  725. {
  726. unsigned int config5;
  727. config5 = read_c0_config5();
  728. config5 &= ~(MIPS_CONF5_UFR | MIPS_CONF5_UFE);
  729. write_c0_config5(config5);
  730. if (config5 & MIPS_CONF5_EVA)
  731. c->options |= MIPS_CPU_EVA;
  732. if (config5 & MIPS_CONF5_MRP)
  733. c->options |= MIPS_CPU_MAAR;
  734. if (config5 & MIPS_CONF5_LLB)
  735. c->options |= MIPS_CPU_RW_LLB;
  736. if (config5 & MIPS_CONF5_MVH)
  737. c->options |= MIPS_CPU_MVH;
  738. if (cpu_has_mips_r6 && (config5 & MIPS_CONF5_VP))
  739. c->options |= MIPS_CPU_VP;
  740. if (config5 & MIPS_CONF5_CA2)
  741. c->ases |= MIPS_ASE_MIPS16E2;
  742. if (config5 & MIPS_CONF5_CRCP)
  743. elf_hwcap |= HWCAP_MIPS_CRC32;
  744. return config5 & MIPS_CONF_M;
  745. }
  746. static void decode_configs(struct cpuinfo_mips *c)
  747. {
  748. int ok;
  749. /* MIPS32 or MIPS64 compliant CPU. */
  750. c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
  751. MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
  752. c->scache.flags = MIPS_CACHE_NOT_PRESENT;
  753. /* Enable FTLB if present and not disabled */
  754. set_ftlb_enable(c, mips_ftlb_disabled ? 0 : FTLB_EN);
  755. ok = decode_config0(c); /* Read Config registers. */
  756. BUG_ON(!ok); /* Arch spec violation! */
  757. if (ok)
  758. ok = decode_config1(c);
  759. if (ok)
  760. ok = decode_config2(c);
  761. if (ok)
  762. ok = decode_config3(c);
  763. if (ok)
  764. ok = decode_config4(c);
  765. if (ok)
  766. ok = decode_config5(c);
  767. /* Probe the EBase.WG bit */
  768. if (cpu_has_mips_r2_r6) {
  769. u64 ebase;
  770. unsigned int status;
  771. /* {read,write}_c0_ebase_64() may be UNDEFINED prior to r6 */
  772. ebase = cpu_has_mips64r6 ? read_c0_ebase_64()
  773. : (s32)read_c0_ebase();
  774. if (ebase & MIPS_EBASE_WG) {
  775. /* WG bit already set, we can avoid the clumsy probe */
  776. c->options |= MIPS_CPU_EBASE_WG;
  777. } else {
  778. /* Its UNDEFINED to change EBase while BEV=0 */
  779. status = read_c0_status();
  780. write_c0_status(status | ST0_BEV);
  781. irq_enable_hazard();
  782. /*
  783. * On pre-r6 cores, this may well clobber the upper bits
  784. * of EBase. This is hard to avoid without potentially
  785. * hitting UNDEFINED dm*c0 behaviour if EBase is 32-bit.
  786. */
  787. if (cpu_has_mips64r6)
  788. write_c0_ebase_64(ebase | MIPS_EBASE_WG);
  789. else
  790. write_c0_ebase(ebase | MIPS_EBASE_WG);
  791. back_to_back_c0_hazard();
  792. /* Restore BEV */
  793. write_c0_status(status);
  794. if (read_c0_ebase() & MIPS_EBASE_WG) {
  795. c->options |= MIPS_CPU_EBASE_WG;
  796. write_c0_ebase(ebase);
  797. }
  798. }
  799. }
  800. /* configure the FTLB write probability */
  801. set_ftlb_enable(c, (mips_ftlb_disabled ? 0 : FTLB_EN) | FTLB_SET_PROB);
  802. mips_probe_watch_registers(c);
  803. #ifndef CONFIG_MIPS_CPS
  804. if (cpu_has_mips_r2_r6) {
  805. unsigned int core;
  806. core = get_ebase_cpunum();
  807. if (cpu_has_mipsmt)
  808. core >>= fls(core_nvpes()) - 1;
  809. cpu_set_core(c, core);
  810. }
  811. #endif
  812. }
  813. /*
  814. * Probe for certain guest capabilities by writing config bits and reading back.
  815. * Finally write back the original value.
  816. */
  817. #define probe_gc0_config(name, maxconf, bits) \
  818. do { \
  819. unsigned int tmp; \
  820. tmp = read_gc0_##name(); \
  821. write_gc0_##name(tmp | (bits)); \
  822. back_to_back_c0_hazard(); \
  823. maxconf = read_gc0_##name(); \
  824. write_gc0_##name(tmp); \
  825. } while (0)
  826. /*
  827. * Probe for dynamic guest capabilities by changing certain config bits and
  828. * reading back to see if they change. Finally write back the original value.
  829. */
  830. #define probe_gc0_config_dyn(name, maxconf, dynconf, bits) \
  831. do { \
  832. maxconf = read_gc0_##name(); \
  833. write_gc0_##name(maxconf ^ (bits)); \
  834. back_to_back_c0_hazard(); \
  835. dynconf = maxconf ^ read_gc0_##name(); \
  836. write_gc0_##name(maxconf); \
  837. maxconf |= dynconf; \
  838. } while (0)
  839. static inline unsigned int decode_guest_config0(struct cpuinfo_mips *c)
  840. {
  841. unsigned int config0;
  842. probe_gc0_config(config, config0, MIPS_CONF_M);
  843. if (config0 & MIPS_CONF_M)
  844. c->guest.conf |= BIT(1);
  845. return config0 & MIPS_CONF_M;
  846. }
  847. static inline unsigned int decode_guest_config1(struct cpuinfo_mips *c)
  848. {
  849. unsigned int config1, config1_dyn;
  850. probe_gc0_config_dyn(config1, config1, config1_dyn,
  851. MIPS_CONF_M | MIPS_CONF1_PC | MIPS_CONF1_WR |
  852. MIPS_CONF1_FP);
  853. if (config1 & MIPS_CONF1_FP)
  854. c->guest.options |= MIPS_CPU_FPU;
  855. if (config1_dyn & MIPS_CONF1_FP)
  856. c->guest.options_dyn |= MIPS_CPU_FPU;
  857. if (config1 & MIPS_CONF1_WR)
  858. c->guest.options |= MIPS_CPU_WATCH;
  859. if (config1_dyn & MIPS_CONF1_WR)
  860. c->guest.options_dyn |= MIPS_CPU_WATCH;
  861. if (config1 & MIPS_CONF1_PC)
  862. c->guest.options |= MIPS_CPU_PERF;
  863. if (config1_dyn & MIPS_CONF1_PC)
  864. c->guest.options_dyn |= MIPS_CPU_PERF;
  865. if (config1 & MIPS_CONF_M)
  866. c->guest.conf |= BIT(2);
  867. return config1 & MIPS_CONF_M;
  868. }
  869. static inline unsigned int decode_guest_config2(struct cpuinfo_mips *c)
  870. {
  871. unsigned int config2;
  872. probe_gc0_config(config2, config2, MIPS_CONF_M);
  873. if (config2 & MIPS_CONF_M)
  874. c->guest.conf |= BIT(3);
  875. return config2 & MIPS_CONF_M;
  876. }
  877. static inline unsigned int decode_guest_config3(struct cpuinfo_mips *c)
  878. {
  879. unsigned int config3, config3_dyn;
  880. probe_gc0_config_dyn(config3, config3, config3_dyn,
  881. MIPS_CONF_M | MIPS_CONF3_MSA | MIPS_CONF3_ULRI |
  882. MIPS_CONF3_CTXTC);
  883. if (config3 & MIPS_CONF3_CTXTC)
  884. c->guest.options |= MIPS_CPU_CTXTC;
  885. if (config3_dyn & MIPS_CONF3_CTXTC)
  886. c->guest.options_dyn |= MIPS_CPU_CTXTC;
  887. if (config3 & MIPS_CONF3_PW)
  888. c->guest.options |= MIPS_CPU_HTW;
  889. if (config3 & MIPS_CONF3_ULRI)
  890. c->guest.options |= MIPS_CPU_ULRI;
  891. if (config3 & MIPS_CONF3_SC)
  892. c->guest.options |= MIPS_CPU_SEGMENTS;
  893. if (config3 & MIPS_CONF3_BI)
  894. c->guest.options |= MIPS_CPU_BADINSTR;
  895. if (config3 & MIPS_CONF3_BP)
  896. c->guest.options |= MIPS_CPU_BADINSTRP;
  897. if (config3 & MIPS_CONF3_MSA)
  898. c->guest.ases |= MIPS_ASE_MSA;
  899. if (config3_dyn & MIPS_CONF3_MSA)
  900. c->guest.ases_dyn |= MIPS_ASE_MSA;
  901. if (config3 & MIPS_CONF_M)
  902. c->guest.conf |= BIT(4);
  903. return config3 & MIPS_CONF_M;
  904. }
  905. static inline unsigned int decode_guest_config4(struct cpuinfo_mips *c)
  906. {
  907. unsigned int config4;
  908. probe_gc0_config(config4, config4,
  909. MIPS_CONF_M | MIPS_CONF4_KSCREXIST);
  910. c->guest.kscratch_mask = (config4 & MIPS_CONF4_KSCREXIST)
  911. >> MIPS_CONF4_KSCREXIST_SHIFT;
  912. if (config4 & MIPS_CONF_M)
  913. c->guest.conf |= BIT(5);
  914. return config4 & MIPS_CONF_M;
  915. }
  916. static inline unsigned int decode_guest_config5(struct cpuinfo_mips *c)
  917. {
  918. unsigned int config5, config5_dyn;
  919. probe_gc0_config_dyn(config5, config5, config5_dyn,
  920. MIPS_CONF_M | MIPS_CONF5_MVH | MIPS_CONF5_MRP);
  921. if (config5 & MIPS_CONF5_MRP)
  922. c->guest.options |= MIPS_CPU_MAAR;
  923. if (config5_dyn & MIPS_CONF5_MRP)
  924. c->guest.options_dyn |= MIPS_CPU_MAAR;
  925. if (config5 & MIPS_CONF5_LLB)
  926. c->guest.options |= MIPS_CPU_RW_LLB;
  927. if (config5 & MIPS_CONF5_MVH)
  928. c->guest.options |= MIPS_CPU_MVH;
  929. if (config5 & MIPS_CONF_M)
  930. c->guest.conf |= BIT(6);
  931. return config5 & MIPS_CONF_M;
  932. }
  933. static inline void decode_guest_configs(struct cpuinfo_mips *c)
  934. {
  935. unsigned int ok;
  936. ok = decode_guest_config0(c);
  937. if (ok)
  938. ok = decode_guest_config1(c);
  939. if (ok)
  940. ok = decode_guest_config2(c);
  941. if (ok)
  942. ok = decode_guest_config3(c);
  943. if (ok)
  944. ok = decode_guest_config4(c);
  945. if (ok)
  946. decode_guest_config5(c);
  947. }
  948. static inline void cpu_probe_guestctl0(struct cpuinfo_mips *c)
  949. {
  950. unsigned int guestctl0, temp;
  951. guestctl0 = read_c0_guestctl0();
  952. if (guestctl0 & MIPS_GCTL0_G0E)
  953. c->options |= MIPS_CPU_GUESTCTL0EXT;
  954. if (guestctl0 & MIPS_GCTL0_G1)
  955. c->options |= MIPS_CPU_GUESTCTL1;
  956. if (guestctl0 & MIPS_GCTL0_G2)
  957. c->options |= MIPS_CPU_GUESTCTL2;
  958. if (!(guestctl0 & MIPS_GCTL0_RAD)) {
  959. c->options |= MIPS_CPU_GUESTID;
  960. /*
  961. * Probe for Direct Root to Guest (DRG). Set GuestCtl1.RID = 0
  962. * first, otherwise all data accesses will be fully virtualised
  963. * as if they were performed by guest mode.
  964. */
  965. write_c0_guestctl1(0);
  966. tlbw_use_hazard();
  967. write_c0_guestctl0(guestctl0 | MIPS_GCTL0_DRG);
  968. back_to_back_c0_hazard();
  969. temp = read_c0_guestctl0();
  970. if (temp & MIPS_GCTL0_DRG) {
  971. write_c0_guestctl0(guestctl0);
  972. c->options |= MIPS_CPU_DRG;
  973. }
  974. }
  975. }
  976. static inline void cpu_probe_guestctl1(struct cpuinfo_mips *c)
  977. {
  978. if (cpu_has_guestid) {
  979. /* determine the number of bits of GuestID available */
  980. write_c0_guestctl1(MIPS_GCTL1_ID);
  981. back_to_back_c0_hazard();
  982. c->guestid_mask = (read_c0_guestctl1() & MIPS_GCTL1_ID)
  983. >> MIPS_GCTL1_ID_SHIFT;
  984. write_c0_guestctl1(0);
  985. }
  986. }
  987. static inline void cpu_probe_gtoffset(struct cpuinfo_mips *c)
  988. {
  989. /* determine the number of bits of GTOffset available */
  990. write_c0_gtoffset(0xffffffff);
  991. back_to_back_c0_hazard();
  992. c->gtoffset_mask = read_c0_gtoffset();
  993. write_c0_gtoffset(0);
  994. }
  995. static inline void cpu_probe_vz(struct cpuinfo_mips *c)
  996. {
  997. cpu_probe_guestctl0(c);
  998. if (cpu_has_guestctl1)
  999. cpu_probe_guestctl1(c);
  1000. cpu_probe_gtoffset(c);
  1001. decode_guest_configs(c);
  1002. }
  1003. #define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
  1004. | MIPS_CPU_COUNTER)
  1005. static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
  1006. {
  1007. switch (c->processor_id & PRID_IMP_MASK) {
  1008. case PRID_IMP_R2000:
  1009. c->cputype = CPU_R2000;
  1010. __cpu_name[cpu] = "R2000";
  1011. c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
  1012. c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
  1013. MIPS_CPU_NOFPUEX;
  1014. if (__cpu_has_fpu())
  1015. c->options |= MIPS_CPU_FPU;
  1016. c->tlbsize = 64;
  1017. break;
  1018. case PRID_IMP_R3000:
  1019. if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A) {
  1020. if (cpu_has_confreg()) {
  1021. c->cputype = CPU_R3081E;
  1022. __cpu_name[cpu] = "R3081";
  1023. } else {
  1024. c->cputype = CPU_R3000A;
  1025. __cpu_name[cpu] = "R3000A";
  1026. }
  1027. } else {
  1028. c->cputype = CPU_R3000;
  1029. __cpu_name[cpu] = "R3000";
  1030. }
  1031. c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
  1032. c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
  1033. MIPS_CPU_NOFPUEX;
  1034. if (__cpu_has_fpu())
  1035. c->options |= MIPS_CPU_FPU;
  1036. c->tlbsize = 64;
  1037. break;
  1038. case PRID_IMP_R4000:
  1039. if (read_c0_config() & CONF_SC) {
  1040. if ((c->processor_id & PRID_REV_MASK) >=
  1041. PRID_REV_R4400) {
  1042. c->cputype = CPU_R4400PC;
  1043. __cpu_name[cpu] = "R4400PC";
  1044. } else {
  1045. c->cputype = CPU_R4000PC;
  1046. __cpu_name[cpu] = "R4000PC";
  1047. }
  1048. } else {
  1049. int cca = read_c0_config() & CONF_CM_CMASK;
  1050. int mc;
  1051. /*
  1052. * SC and MC versions can't be reliably told apart,
  1053. * but only the latter support coherent caching
  1054. * modes so assume the firmware has set the KSEG0
  1055. * coherency attribute reasonably (if uncached, we
  1056. * assume SC).
  1057. */
  1058. switch (cca) {
  1059. case CONF_CM_CACHABLE_CE:
  1060. case CONF_CM_CACHABLE_COW:
  1061. case CONF_CM_CACHABLE_CUW:
  1062. mc = 1;
  1063. break;
  1064. default:
  1065. mc = 0;
  1066. break;
  1067. }
  1068. if ((c->processor_id & PRID_REV_MASK) >=
  1069. PRID_REV_R4400) {
  1070. c->cputype = mc ? CPU_R4400MC : CPU_R4400SC;
  1071. __cpu_name[cpu] = mc ? "R4400MC" : "R4400SC";
  1072. } else {
  1073. c->cputype = mc ? CPU_R4000MC : CPU_R4000SC;
  1074. __cpu_name[cpu] = mc ? "R4000MC" : "R4000SC";
  1075. }
  1076. }
  1077. set_isa(c, MIPS_CPU_ISA_III);
  1078. c->fpu_msk31 |= FPU_CSR_CONDX;
  1079. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  1080. MIPS_CPU_WATCH | MIPS_CPU_VCE |
  1081. MIPS_CPU_LLSC;
  1082. c->tlbsize = 48;
  1083. break;
  1084. case PRID_IMP_VR41XX:
  1085. set_isa(c, MIPS_CPU_ISA_III);
  1086. c->fpu_msk31 |= FPU_CSR_CONDX;
  1087. c->options = R4K_OPTS;
  1088. c->tlbsize = 32;
  1089. switch (c->processor_id & 0xf0) {
  1090. case PRID_REV_VR4111:
  1091. c->cputype = CPU_VR4111;
  1092. __cpu_name[cpu] = "NEC VR4111";
  1093. break;
  1094. case PRID_REV_VR4121:
  1095. c->cputype = CPU_VR4121;
  1096. __cpu_name[cpu] = "NEC VR4121";
  1097. break;
  1098. case PRID_REV_VR4122:
  1099. if ((c->processor_id & 0xf) < 0x3) {
  1100. c->cputype = CPU_VR4122;
  1101. __cpu_name[cpu] = "NEC VR4122";
  1102. } else {
  1103. c->cputype = CPU_VR4181A;
  1104. __cpu_name[cpu] = "NEC VR4181A";
  1105. }
  1106. break;
  1107. case PRID_REV_VR4130:
  1108. if ((c->processor_id & 0xf) < 0x4) {
  1109. c->cputype = CPU_VR4131;
  1110. __cpu_name[cpu] = "NEC VR4131";
  1111. } else {
  1112. c->cputype = CPU_VR4133;
  1113. c->options |= MIPS_CPU_LLSC;
  1114. __cpu_name[cpu] = "NEC VR4133";
  1115. }
  1116. break;
  1117. default:
  1118. printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
  1119. c->cputype = CPU_VR41XX;
  1120. __cpu_name[cpu] = "NEC Vr41xx";
  1121. break;
  1122. }
  1123. break;
  1124. case PRID_IMP_R4300:
  1125. c->cputype = CPU_R4300;
  1126. __cpu_name[cpu] = "R4300";
  1127. set_isa(c, MIPS_CPU_ISA_III);
  1128. c->fpu_msk31 |= FPU_CSR_CONDX;
  1129. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  1130. MIPS_CPU_LLSC;
  1131. c->tlbsize = 32;
  1132. break;
  1133. case PRID_IMP_R4600:
  1134. c->cputype = CPU_R4600;
  1135. __cpu_name[cpu] = "R4600";
  1136. set_isa(c, MIPS_CPU_ISA_III);
  1137. c->fpu_msk31 |= FPU_CSR_CONDX;
  1138. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  1139. MIPS_CPU_LLSC;
  1140. c->tlbsize = 48;
  1141. break;
  1142. #if 0
  1143. case PRID_IMP_R4650:
  1144. /*
  1145. * This processor doesn't have an MMU, so it's not
  1146. * "real easy" to run Linux on it. It is left purely
  1147. * for documentation. Commented out because it shares
  1148. * it's c0_prid id number with the TX3900.
  1149. */
  1150. c->cputype = CPU_R4650;
  1151. __cpu_name[cpu] = "R4650";
  1152. set_isa(c, MIPS_CPU_ISA_III);
  1153. c->fpu_msk31 |= FPU_CSR_CONDX;
  1154. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
  1155. c->tlbsize = 48;
  1156. break;
  1157. #endif
  1158. case PRID_IMP_TX39:
  1159. c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
  1160. c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
  1161. if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
  1162. c->cputype = CPU_TX3927;
  1163. __cpu_name[cpu] = "TX3927";
  1164. c->tlbsize = 64;
  1165. } else {
  1166. switch (c->processor_id & PRID_REV_MASK) {
  1167. case PRID_REV_TX3912:
  1168. c->cputype = CPU_TX3912;
  1169. __cpu_name[cpu] = "TX3912";
  1170. c->tlbsize = 32;
  1171. break;
  1172. case PRID_REV_TX3922:
  1173. c->cputype = CPU_TX3922;
  1174. __cpu_name[cpu] = "TX3922";
  1175. c->tlbsize = 64;
  1176. break;
  1177. }
  1178. }
  1179. break;
  1180. case PRID_IMP_R4700:
  1181. c->cputype = CPU_R4700;
  1182. __cpu_name[cpu] = "R4700";
  1183. set_isa(c, MIPS_CPU_ISA_III);
  1184. c->fpu_msk31 |= FPU_CSR_CONDX;
  1185. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  1186. MIPS_CPU_LLSC;
  1187. c->tlbsize = 48;
  1188. break;
  1189. case PRID_IMP_TX49:
  1190. c->cputype = CPU_TX49XX;
  1191. __cpu_name[cpu] = "R49XX";
  1192. set_isa(c, MIPS_CPU_ISA_III);
  1193. c->fpu_msk31 |= FPU_CSR_CONDX;
  1194. c->options = R4K_OPTS | MIPS_CPU_LLSC;
  1195. if (!(c->processor_id & 0x08))
  1196. c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
  1197. c->tlbsize = 48;
  1198. break;
  1199. case PRID_IMP_R5000:
  1200. c->cputype = CPU_R5000;
  1201. __cpu_name[cpu] = "R5000";
  1202. set_isa(c, MIPS_CPU_ISA_IV);
  1203. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  1204. MIPS_CPU_LLSC;
  1205. c->tlbsize = 48;
  1206. break;
  1207. case PRID_IMP_R5432:
  1208. c->cputype = CPU_R5432;
  1209. __cpu_name[cpu] = "R5432";
  1210. set_isa(c, MIPS_CPU_ISA_IV);
  1211. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  1212. MIPS_CPU_WATCH | MIPS_CPU_LLSC;
  1213. c->tlbsize = 48;
  1214. break;
  1215. case PRID_IMP_R5500:
  1216. c->cputype = CPU_R5500;
  1217. __cpu_name[cpu] = "R5500";
  1218. set_isa(c, MIPS_CPU_ISA_IV);
  1219. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  1220. MIPS_CPU_WATCH | MIPS_CPU_LLSC;
  1221. c->tlbsize = 48;
  1222. break;
  1223. case PRID_IMP_NEVADA:
  1224. c->cputype = CPU_NEVADA;
  1225. __cpu_name[cpu] = "Nevada";
  1226. set_isa(c, MIPS_CPU_ISA_IV);
  1227. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  1228. MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
  1229. c->tlbsize = 48;
  1230. break;
  1231. case PRID_IMP_RM7000:
  1232. c->cputype = CPU_RM7000;
  1233. __cpu_name[cpu] = "RM7000";
  1234. set_isa(c, MIPS_CPU_ISA_IV);
  1235. c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
  1236. MIPS_CPU_LLSC;
  1237. /*
  1238. * Undocumented RM7000: Bit 29 in the info register of
  1239. * the RM7000 v2.0 indicates if the TLB has 48 or 64
  1240. * entries.
  1241. *
  1242. * 29 1 => 64 entry JTLB
  1243. * 0 => 48 entry JTLB
  1244. */
  1245. c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
  1246. break;
  1247. case PRID_IMP_R8000:
  1248. c->cputype = CPU_R8000;
  1249. __cpu_name[cpu] = "RM8000";
  1250. set_isa(c, MIPS_CPU_ISA_IV);
  1251. c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
  1252. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  1253. MIPS_CPU_LLSC;
  1254. c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
  1255. break;
  1256. case PRID_IMP_R10000:
  1257. c->cputype = CPU_R10000;
  1258. __cpu_name[cpu] = "R10000";
  1259. set_isa(c, MIPS_CPU_ISA_IV);
  1260. c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
  1261. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  1262. MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
  1263. MIPS_CPU_LLSC;
  1264. c->tlbsize = 64;
  1265. break;
  1266. case PRID_IMP_R12000:
  1267. c->cputype = CPU_R12000;
  1268. __cpu_name[cpu] = "R12000";
  1269. set_isa(c, MIPS_CPU_ISA_IV);
  1270. c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
  1271. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  1272. MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
  1273. MIPS_CPU_LLSC | MIPS_CPU_BP_GHIST;
  1274. c->tlbsize = 64;
  1275. break;
  1276. case PRID_IMP_R14000:
  1277. if (((c->processor_id >> 4) & 0x0f) > 2) {
  1278. c->cputype = CPU_R16000;
  1279. __cpu_name[cpu] = "R16000";
  1280. } else {
  1281. c->cputype = CPU_R14000;
  1282. __cpu_name[cpu] = "R14000";
  1283. }
  1284. set_isa(c, MIPS_CPU_ISA_IV);
  1285. c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
  1286. MIPS_CPU_FPU | MIPS_CPU_32FPR |
  1287. MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
  1288. MIPS_CPU_LLSC | MIPS_CPU_BP_GHIST;
  1289. c->tlbsize = 64;
  1290. break;
  1291. case PRID_IMP_LOONGSON_64: /* Loongson-2/3 */
  1292. switch (c->processor_id & PRID_REV_MASK) {
  1293. case PRID_REV_LOONGSON2E:
  1294. c->cputype = CPU_LOONGSON2;
  1295. __cpu_name[cpu] = "ICT Loongson-2";
  1296. set_elf_platform(cpu, "loongson2e");
  1297. set_isa(c, MIPS_CPU_ISA_III);
  1298. c->fpu_msk31 |= FPU_CSR_CONDX;
  1299. break;
  1300. case PRID_REV_LOONGSON2F:
  1301. c->cputype = CPU_LOONGSON2;
  1302. __cpu_name[cpu] = "ICT Loongson-2";
  1303. set_elf_platform(cpu, "loongson2f");
  1304. set_isa(c, MIPS_CPU_ISA_III);
  1305. c->fpu_msk31 |= FPU_CSR_CONDX;
  1306. break;
  1307. case PRID_REV_LOONGSON3A_R1:
  1308. c->cputype = CPU_LOONGSON3;
  1309. __cpu_name[cpu] = "ICT Loongson-3";
  1310. set_elf_platform(cpu, "loongson3a");
  1311. set_isa(c, MIPS_CPU_ISA_M64R1);
  1312. break;
  1313. case PRID_REV_LOONGSON3B_R1:
  1314. case PRID_REV_LOONGSON3B_R2:
  1315. c->cputype = CPU_LOONGSON3;
  1316. __cpu_name[cpu] = "ICT Loongson-3";
  1317. set_elf_platform(cpu, "loongson3b");
  1318. set_isa(c, MIPS_CPU_ISA_M64R1);
  1319. break;
  1320. }
  1321. c->options = R4K_OPTS |
  1322. MIPS_CPU_FPU | MIPS_CPU_LLSC |
  1323. MIPS_CPU_32FPR;
  1324. c->tlbsize = 64;
  1325. c->writecombine = _CACHE_UNCACHED_ACCELERATED;
  1326. break;
  1327. case PRID_IMP_LOONGSON_32: /* Loongson-1 */
  1328. decode_configs(c);
  1329. c->cputype = CPU_LOONGSON1;
  1330. switch (c->processor_id & PRID_REV_MASK) {
  1331. case PRID_REV_LOONGSON1B:
  1332. __cpu_name[cpu] = "Loongson 1B";
  1333. break;
  1334. }
  1335. break;
  1336. }
  1337. }
  1338. static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
  1339. {
  1340. c->writecombine = _CACHE_UNCACHED_ACCELERATED;
  1341. switch (c->processor_id & PRID_IMP_MASK) {
  1342. case PRID_IMP_QEMU_GENERIC:
  1343. c->writecombine = _CACHE_UNCACHED;
  1344. c->cputype = CPU_QEMU_GENERIC;
  1345. __cpu_name[cpu] = "MIPS GENERIC QEMU";
  1346. break;
  1347. case PRID_IMP_4KC:
  1348. c->cputype = CPU_4KC;
  1349. c->writecombine = _CACHE_UNCACHED;
  1350. __cpu_name[cpu] = "MIPS 4Kc";
  1351. break;
  1352. case PRID_IMP_4KEC:
  1353. case PRID_IMP_4KECR2:
  1354. c->cputype = CPU_4KEC;
  1355. c->writecombine = _CACHE_UNCACHED;
  1356. __cpu_name[cpu] = "MIPS 4KEc";
  1357. break;
  1358. case PRID_IMP_4KSC:
  1359. case PRID_IMP_4KSD:
  1360. c->cputype = CPU_4KSC;
  1361. c->writecombine = _CACHE_UNCACHED;
  1362. __cpu_name[cpu] = "MIPS 4KSc";
  1363. break;
  1364. case PRID_IMP_5KC:
  1365. c->cputype = CPU_5KC;
  1366. c->writecombine = _CACHE_UNCACHED;
  1367. __cpu_name[cpu] = "MIPS 5Kc";
  1368. break;
  1369. case PRID_IMP_5KE:
  1370. c->cputype = CPU_5KE;
  1371. c->writecombine = _CACHE_UNCACHED;
  1372. __cpu_name[cpu] = "MIPS 5KE";
  1373. break;
  1374. case PRID_IMP_20KC:
  1375. c->cputype = CPU_20KC;
  1376. c->writecombine = _CACHE_UNCACHED;
  1377. __cpu_name[cpu] = "MIPS 20Kc";
  1378. break;
  1379. case PRID_IMP_24K:
  1380. c->cputype = CPU_24K;
  1381. c->writecombine = _CACHE_UNCACHED;
  1382. __cpu_name[cpu] = "MIPS 24Kc";
  1383. break;
  1384. case PRID_IMP_24KE:
  1385. c->cputype = CPU_24K;
  1386. c->writecombine = _CACHE_UNCACHED;
  1387. __cpu_name[cpu] = "MIPS 24KEc";
  1388. break;
  1389. case PRID_IMP_25KF:
  1390. c->cputype = CPU_25KF;
  1391. c->writecombine = _CACHE_UNCACHED;
  1392. __cpu_name[cpu] = "MIPS 25Kc";
  1393. break;
  1394. case PRID_IMP_34K:
  1395. c->cputype = CPU_34K;
  1396. c->writecombine = _CACHE_UNCACHED;
  1397. __cpu_name[cpu] = "MIPS 34Kc";
  1398. cpu_set_mt_per_tc_perf(c);
  1399. break;
  1400. case PRID_IMP_74K:
  1401. c->cputype = CPU_74K;
  1402. c->writecombine = _CACHE_UNCACHED;
  1403. __cpu_name[cpu] = "MIPS 74Kc";
  1404. break;
  1405. case PRID_IMP_M14KC:
  1406. c->cputype = CPU_M14KC;
  1407. c->writecombine = _CACHE_UNCACHED;
  1408. __cpu_name[cpu] = "MIPS M14Kc";
  1409. break;
  1410. case PRID_IMP_M14KEC:
  1411. c->cputype = CPU_M14KEC;
  1412. c->writecombine = _CACHE_UNCACHED;
  1413. __cpu_name[cpu] = "MIPS M14KEc";
  1414. break;
  1415. case PRID_IMP_1004K:
  1416. c->cputype = CPU_1004K;
  1417. c->writecombine = _CACHE_UNCACHED;
  1418. __cpu_name[cpu] = "MIPS 1004Kc";
  1419. cpu_set_mt_per_tc_perf(c);
  1420. break;
  1421. case PRID_IMP_1074K:
  1422. c->cputype = CPU_1074K;
  1423. c->writecombine = _CACHE_UNCACHED;
  1424. __cpu_name[cpu] = "MIPS 1074Kc";
  1425. break;
  1426. case PRID_IMP_INTERAPTIV_UP:
  1427. c->cputype = CPU_INTERAPTIV;
  1428. __cpu_name[cpu] = "MIPS interAptiv";
  1429. cpu_set_mt_per_tc_perf(c);
  1430. break;
  1431. case PRID_IMP_INTERAPTIV_MP:
  1432. c->cputype = CPU_INTERAPTIV;
  1433. __cpu_name[cpu] = "MIPS interAptiv (multi)";
  1434. cpu_set_mt_per_tc_perf(c);
  1435. break;
  1436. case PRID_IMP_PROAPTIV_UP:
  1437. c->cputype = CPU_PROAPTIV;
  1438. __cpu_name[cpu] = "MIPS proAptiv";
  1439. break;
  1440. case PRID_IMP_PROAPTIV_MP:
  1441. c->cputype = CPU_PROAPTIV;
  1442. __cpu_name[cpu] = "MIPS proAptiv (multi)";
  1443. break;
  1444. case PRID_IMP_P5600:
  1445. c->cputype = CPU_P5600;
  1446. __cpu_name[cpu] = "MIPS P5600";
  1447. break;
  1448. case PRID_IMP_P6600:
  1449. c->cputype = CPU_P6600;
  1450. __cpu_name[cpu] = "MIPS P6600";
  1451. break;
  1452. case PRID_IMP_I6400:
  1453. c->cputype = CPU_I6400;
  1454. __cpu_name[cpu] = "MIPS I6400";
  1455. break;
  1456. case PRID_IMP_I6500:
  1457. c->cputype = CPU_I6500;
  1458. __cpu_name[cpu] = "MIPS I6500";
  1459. break;
  1460. case PRID_IMP_M5150:
  1461. c->cputype = CPU_M5150;
  1462. __cpu_name[cpu] = "MIPS M5150";
  1463. break;
  1464. case PRID_IMP_M6250:
  1465. c->cputype = CPU_M6250;
  1466. __cpu_name[cpu] = "MIPS M6250";
  1467. break;
  1468. }
  1469. decode_configs(c);
  1470. spram_config();
  1471. switch (__get_cpu_type(c->cputype)) {
  1472. case CPU_I6500:
  1473. c->options |= MIPS_CPU_SHARED_FTLB_ENTRIES;
  1474. /* fall-through */
  1475. case CPU_I6400:
  1476. c->options |= MIPS_CPU_SHARED_FTLB_RAM;
  1477. /* fall-through */
  1478. default:
  1479. break;
  1480. }
  1481. }
  1482. static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
  1483. {
  1484. decode_configs(c);
  1485. switch (c->processor_id & PRID_IMP_MASK) {
  1486. case PRID_IMP_AU1_REV1:
  1487. case PRID_IMP_AU1_REV2:
  1488. c->cputype = CPU_ALCHEMY;
  1489. switch ((c->processor_id >> 24) & 0xff) {
  1490. case 0:
  1491. __cpu_name[cpu] = "Au1000";
  1492. break;
  1493. case 1:
  1494. __cpu_name[cpu] = "Au1500";
  1495. break;
  1496. case 2:
  1497. __cpu_name[cpu] = "Au1100";
  1498. break;
  1499. case 3:
  1500. __cpu_name[cpu] = "Au1550";
  1501. break;
  1502. case 4:
  1503. __cpu_name[cpu] = "Au1200";
  1504. if ((c->processor_id & PRID_REV_MASK) == 2)
  1505. __cpu_name[cpu] = "Au1250";
  1506. break;
  1507. case 5:
  1508. __cpu_name[cpu] = "Au1210";
  1509. break;
  1510. default:
  1511. __cpu_name[cpu] = "Au1xxx";
  1512. break;
  1513. }
  1514. break;
  1515. }
  1516. }
  1517. static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
  1518. {
  1519. decode_configs(c);
  1520. c->writecombine = _CACHE_UNCACHED_ACCELERATED;
  1521. switch (c->processor_id & PRID_IMP_MASK) {
  1522. case PRID_IMP_SB1:
  1523. c->cputype = CPU_SB1;
  1524. __cpu_name[cpu] = "SiByte SB1";
  1525. /* FPU in pass1 is known to have issues. */
  1526. if ((c->processor_id & PRID_REV_MASK) < 0x02)
  1527. c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
  1528. break;
  1529. case PRID_IMP_SB1A:
  1530. c->cputype = CPU_SB1A;
  1531. __cpu_name[cpu] = "SiByte SB1A";
  1532. break;
  1533. }
  1534. }
  1535. static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
  1536. {
  1537. decode_configs(c);
  1538. switch (c->processor_id & PRID_IMP_MASK) {
  1539. case PRID_IMP_SR71000:
  1540. c->cputype = CPU_SR71000;
  1541. __cpu_name[cpu] = "Sandcraft SR71000";
  1542. c->scache.ways = 8;
  1543. c->tlbsize = 64;
  1544. break;
  1545. }
  1546. }
  1547. static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
  1548. {
  1549. decode_configs(c);
  1550. switch (c->processor_id & PRID_IMP_MASK) {
  1551. case PRID_IMP_PR4450:
  1552. c->cputype = CPU_PR4450;
  1553. __cpu_name[cpu] = "Philips PR4450";
  1554. set_isa(c, MIPS_CPU_ISA_M32R1);
  1555. break;
  1556. }
  1557. }
  1558. static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
  1559. {
  1560. decode_configs(c);
  1561. switch (c->processor_id & PRID_IMP_MASK) {
  1562. case PRID_IMP_BMIPS32_REV4:
  1563. case PRID_IMP_BMIPS32_REV8:
  1564. c->cputype = CPU_BMIPS32;
  1565. __cpu_name[cpu] = "Broadcom BMIPS32";
  1566. set_elf_platform(cpu, "bmips32");
  1567. break;
  1568. case PRID_IMP_BMIPS3300:
  1569. case PRID_IMP_BMIPS3300_ALT:
  1570. case PRID_IMP_BMIPS3300_BUG:
  1571. c->cputype = CPU_BMIPS3300;
  1572. __cpu_name[cpu] = "Broadcom BMIPS3300";
  1573. set_elf_platform(cpu, "bmips3300");
  1574. break;
  1575. case PRID_IMP_BMIPS43XX: {
  1576. int rev = c->processor_id & PRID_REV_MASK;
  1577. if (rev >= PRID_REV_BMIPS4380_LO &&
  1578. rev <= PRID_REV_BMIPS4380_HI) {
  1579. c->cputype = CPU_BMIPS4380;
  1580. __cpu_name[cpu] = "Broadcom BMIPS4380";
  1581. set_elf_platform(cpu, "bmips4380");
  1582. c->options |= MIPS_CPU_RIXI;
  1583. } else {
  1584. c->cputype = CPU_BMIPS4350;
  1585. __cpu_name[cpu] = "Broadcom BMIPS4350";
  1586. set_elf_platform(cpu, "bmips4350");
  1587. }
  1588. break;
  1589. }
  1590. case PRID_IMP_BMIPS5000:
  1591. case PRID_IMP_BMIPS5200:
  1592. c->cputype = CPU_BMIPS5000;
  1593. if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_BMIPS5200)
  1594. __cpu_name[cpu] = "Broadcom BMIPS5200";
  1595. else
  1596. __cpu_name[cpu] = "Broadcom BMIPS5000";
  1597. set_elf_platform(cpu, "bmips5000");
  1598. c->options |= MIPS_CPU_ULRI | MIPS_CPU_RIXI;
  1599. break;
  1600. }
  1601. }
  1602. static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
  1603. {
  1604. decode_configs(c);
  1605. switch (c->processor_id & PRID_IMP_MASK) {
  1606. case PRID_IMP_CAVIUM_CN38XX:
  1607. case PRID_IMP_CAVIUM_CN31XX:
  1608. case PRID_IMP_CAVIUM_CN30XX:
  1609. c->cputype = CPU_CAVIUM_OCTEON;
  1610. __cpu_name[cpu] = "Cavium Octeon";
  1611. goto platform;
  1612. case PRID_IMP_CAVIUM_CN58XX:
  1613. case PRID_IMP_CAVIUM_CN56XX:
  1614. case PRID_IMP_CAVIUM_CN50XX:
  1615. case PRID_IMP_CAVIUM_CN52XX:
  1616. c->cputype = CPU_CAVIUM_OCTEON_PLUS;
  1617. __cpu_name[cpu] = "Cavium Octeon+";
  1618. platform:
  1619. set_elf_platform(cpu, "octeon");
  1620. break;
  1621. case PRID_IMP_CAVIUM_CN61XX:
  1622. case PRID_IMP_CAVIUM_CN63XX:
  1623. case PRID_IMP_CAVIUM_CN66XX:
  1624. case PRID_IMP_CAVIUM_CN68XX:
  1625. case PRID_IMP_CAVIUM_CNF71XX:
  1626. c->cputype = CPU_CAVIUM_OCTEON2;
  1627. __cpu_name[cpu] = "Cavium Octeon II";
  1628. set_elf_platform(cpu, "octeon2");
  1629. break;
  1630. case PRID_IMP_CAVIUM_CN70XX:
  1631. case PRID_IMP_CAVIUM_CN73XX:
  1632. case PRID_IMP_CAVIUM_CNF75XX:
  1633. case PRID_IMP_CAVIUM_CN78XX:
  1634. c->cputype = CPU_CAVIUM_OCTEON3;
  1635. __cpu_name[cpu] = "Cavium Octeon III";
  1636. set_elf_platform(cpu, "octeon3");
  1637. break;
  1638. default:
  1639. printk(KERN_INFO "Unknown Octeon chip!\n");
  1640. c->cputype = CPU_UNKNOWN;
  1641. break;
  1642. }
  1643. }
  1644. static inline void cpu_probe_loongson(struct cpuinfo_mips *c, unsigned int cpu)
  1645. {
  1646. switch (c->processor_id & PRID_IMP_MASK) {
  1647. case PRID_IMP_LOONGSON_64: /* Loongson-2/3 */
  1648. switch (c->processor_id & PRID_REV_MASK) {
  1649. case PRID_REV_LOONGSON3A_R2:
  1650. c->cputype = CPU_LOONGSON3;
  1651. __cpu_name[cpu] = "ICT Loongson-3";
  1652. set_elf_platform(cpu, "loongson3a");
  1653. set_isa(c, MIPS_CPU_ISA_M64R2);
  1654. break;
  1655. case PRID_REV_LOONGSON3A_R3_0:
  1656. case PRID_REV_LOONGSON3A_R3_1:
  1657. c->cputype = CPU_LOONGSON3;
  1658. __cpu_name[cpu] = "ICT Loongson-3";
  1659. set_elf_platform(cpu, "loongson3a");
  1660. set_isa(c, MIPS_CPU_ISA_M64R2);
  1661. break;
  1662. }
  1663. decode_configs(c);
  1664. c->options |= MIPS_CPU_FTLB | MIPS_CPU_TLBINV | MIPS_CPU_LDPTE;
  1665. c->writecombine = _CACHE_UNCACHED_ACCELERATED;
  1666. break;
  1667. default:
  1668. panic("Unknown Loongson Processor ID!");
  1669. break;
  1670. }
  1671. }
  1672. static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
  1673. {
  1674. decode_configs(c);
  1675. /* JZRISC does not implement the CP0 counter. */
  1676. c->options &= ~MIPS_CPU_COUNTER;
  1677. BUG_ON(!__builtin_constant_p(cpu_has_counter) || cpu_has_counter);
  1678. switch (c->processor_id & PRID_IMP_MASK) {
  1679. case PRID_IMP_JZRISC:
  1680. c->cputype = CPU_JZRISC;
  1681. c->writecombine = _CACHE_UNCACHED_ACCELERATED;
  1682. __cpu_name[cpu] = "Ingenic JZRISC";
  1683. break;
  1684. default:
  1685. panic("Unknown Ingenic Processor ID!");
  1686. break;
  1687. }
  1688. }
  1689. static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
  1690. {
  1691. decode_configs(c);
  1692. if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_NETLOGIC_AU13XX) {
  1693. c->cputype = CPU_ALCHEMY;
  1694. __cpu_name[cpu] = "Au1300";
  1695. /* following stuff is not for Alchemy */
  1696. return;
  1697. }
  1698. c->options = (MIPS_CPU_TLB |
  1699. MIPS_CPU_4KEX |
  1700. MIPS_CPU_COUNTER |
  1701. MIPS_CPU_DIVEC |
  1702. MIPS_CPU_WATCH |
  1703. MIPS_CPU_EJTAG |
  1704. MIPS_CPU_LLSC);
  1705. switch (c->processor_id & PRID_IMP_MASK) {
  1706. case PRID_IMP_NETLOGIC_XLP2XX:
  1707. case PRID_IMP_NETLOGIC_XLP9XX:
  1708. case PRID_IMP_NETLOGIC_XLP5XX:
  1709. c->cputype = CPU_XLP;
  1710. __cpu_name[cpu] = "Broadcom XLPII";
  1711. break;
  1712. case PRID_IMP_NETLOGIC_XLP8XX:
  1713. case PRID_IMP_NETLOGIC_XLP3XX:
  1714. c->cputype = CPU_XLP;
  1715. __cpu_name[cpu] = "Netlogic XLP";
  1716. break;
  1717. case PRID_IMP_NETLOGIC_XLR732:
  1718. case PRID_IMP_NETLOGIC_XLR716:
  1719. case PRID_IMP_NETLOGIC_XLR532:
  1720. case PRID_IMP_NETLOGIC_XLR308:
  1721. case PRID_IMP_NETLOGIC_XLR532C:
  1722. case PRID_IMP_NETLOGIC_XLR516C:
  1723. case PRID_IMP_NETLOGIC_XLR508C:
  1724. case PRID_IMP_NETLOGIC_XLR308C:
  1725. c->cputype = CPU_XLR;
  1726. __cpu_name[cpu] = "Netlogic XLR";
  1727. break;
  1728. case PRID_IMP_NETLOGIC_XLS608:
  1729. case PRID_IMP_NETLOGIC_XLS408:
  1730. case PRID_IMP_NETLOGIC_XLS404:
  1731. case PRID_IMP_NETLOGIC_XLS208:
  1732. case PRID_IMP_NETLOGIC_XLS204:
  1733. case PRID_IMP_NETLOGIC_XLS108:
  1734. case PRID_IMP_NETLOGIC_XLS104:
  1735. case PRID_IMP_NETLOGIC_XLS616B:
  1736. case PRID_IMP_NETLOGIC_XLS608B:
  1737. case PRID_IMP_NETLOGIC_XLS416B:
  1738. case PRID_IMP_NETLOGIC_XLS412B:
  1739. case PRID_IMP_NETLOGIC_XLS408B:
  1740. case PRID_IMP_NETLOGIC_XLS404B:
  1741. c->cputype = CPU_XLR;
  1742. __cpu_name[cpu] = "Netlogic XLS";
  1743. break;
  1744. default:
  1745. pr_info("Unknown Netlogic chip id [%02x]!\n",
  1746. c->processor_id);
  1747. c->cputype = CPU_XLR;
  1748. break;
  1749. }
  1750. if (c->cputype == CPU_XLP) {
  1751. set_isa(c, MIPS_CPU_ISA_M64R2);
  1752. c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
  1753. /* This will be updated again after all threads are woken up */
  1754. c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
  1755. } else {
  1756. set_isa(c, MIPS_CPU_ISA_M64R1);
  1757. c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
  1758. }
  1759. c->kscratch_mask = 0xf;
  1760. }
  1761. #ifdef CONFIG_64BIT
  1762. /* For use by uaccess.h */
  1763. u64 __ua_limit;
  1764. EXPORT_SYMBOL(__ua_limit);
  1765. #endif
  1766. const char *__cpu_name[NR_CPUS];
  1767. const char *__elf_platform;
  1768. void cpu_probe(void)
  1769. {
  1770. struct cpuinfo_mips *c = &current_cpu_data;
  1771. unsigned int cpu = smp_processor_id();
  1772. /*
  1773. * Set a default elf platform, cpu probe may later
  1774. * overwrite it with a more precise value
  1775. */
  1776. set_elf_platform(cpu, "mips");
  1777. c->processor_id = PRID_IMP_UNKNOWN;
  1778. c->fpu_id = FPIR_IMP_NONE;
  1779. c->cputype = CPU_UNKNOWN;
  1780. c->writecombine = _CACHE_UNCACHED;
  1781. c->fpu_csr31 = FPU_CSR_RN;
  1782. c->fpu_msk31 = FPU_CSR_RSVD | FPU_CSR_ABS2008 | FPU_CSR_NAN2008;
  1783. c->processor_id = read_c0_prid();
  1784. switch (c->processor_id & PRID_COMP_MASK) {
  1785. case PRID_COMP_LEGACY:
  1786. cpu_probe_legacy(c, cpu);
  1787. break;
  1788. case PRID_COMP_MIPS:
  1789. cpu_probe_mips(c, cpu);
  1790. break;
  1791. case PRID_COMP_ALCHEMY:
  1792. cpu_probe_alchemy(c, cpu);
  1793. break;
  1794. case PRID_COMP_SIBYTE:
  1795. cpu_probe_sibyte(c, cpu);
  1796. break;
  1797. case PRID_COMP_BROADCOM:
  1798. cpu_probe_broadcom(c, cpu);
  1799. break;
  1800. case PRID_COMP_SANDCRAFT:
  1801. cpu_probe_sandcraft(c, cpu);
  1802. break;
  1803. case PRID_COMP_NXP:
  1804. cpu_probe_nxp(c, cpu);
  1805. break;
  1806. case PRID_COMP_CAVIUM:
  1807. cpu_probe_cavium(c, cpu);
  1808. break;
  1809. case PRID_COMP_LOONGSON:
  1810. cpu_probe_loongson(c, cpu);
  1811. break;
  1812. case PRID_COMP_INGENIC_D0:
  1813. case PRID_COMP_INGENIC_D1:
  1814. case PRID_COMP_INGENIC_E1:
  1815. cpu_probe_ingenic(c, cpu);
  1816. break;
  1817. case PRID_COMP_NETLOGIC:
  1818. cpu_probe_netlogic(c, cpu);
  1819. break;
  1820. }
  1821. BUG_ON(!__cpu_name[cpu]);
  1822. BUG_ON(c->cputype == CPU_UNKNOWN);
  1823. /*
  1824. * Platform code can force the cpu type to optimize code
  1825. * generation. In that case be sure the cpu type is correctly
  1826. * manually setup otherwise it could trigger some nasty bugs.
  1827. */
  1828. BUG_ON(current_cpu_type() != c->cputype);
  1829. if (cpu_has_rixi) {
  1830. /* Enable the RIXI exceptions */
  1831. set_c0_pagegrain(PG_IEC);
  1832. back_to_back_c0_hazard();
  1833. /* Verify the IEC bit is set */
  1834. if (read_c0_pagegrain() & PG_IEC)
  1835. c->options |= MIPS_CPU_RIXIEX;
  1836. }
  1837. if (mips_fpu_disabled)
  1838. c->options &= ~MIPS_CPU_FPU;
  1839. if (mips_dsp_disabled)
  1840. c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
  1841. if (mips_htw_disabled) {
  1842. c->options &= ~MIPS_CPU_HTW;
  1843. write_c0_pwctl(read_c0_pwctl() &
  1844. ~(1 << MIPS_PWCTL_PWEN_SHIFT));
  1845. }
  1846. if (c->options & MIPS_CPU_FPU)
  1847. cpu_set_fpu_opts(c);
  1848. else
  1849. cpu_set_nofpu_opts(c);
  1850. if (cpu_has_bp_ghist)
  1851. write_c0_r10k_diag(read_c0_r10k_diag() |
  1852. R10K_DIAG_E_GHIST);
  1853. if (cpu_has_mips_r2_r6) {
  1854. c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
  1855. /* R2 has Performance Counter Interrupt indicator */
  1856. c->options |= MIPS_CPU_PCI;
  1857. }
  1858. else
  1859. c->srsets = 1;
  1860. if (cpu_has_mips_r6)
  1861. elf_hwcap |= HWCAP_MIPS_R6;
  1862. if (cpu_has_msa) {
  1863. c->msa_id = cpu_get_msa_id();
  1864. WARN(c->msa_id & MSA_IR_WRPF,
  1865. "Vector register partitioning unimplemented!");
  1866. elf_hwcap |= HWCAP_MIPS_MSA;
  1867. }
  1868. if (cpu_has_vz)
  1869. cpu_probe_vz(c);
  1870. cpu_probe_vmbits(c);
  1871. #ifdef CONFIG_64BIT
  1872. if (cpu == 0)
  1873. __ua_limit = ~((1ull << cpu_vmbits) - 1);
  1874. #endif
  1875. }
  1876. void cpu_report(void)
  1877. {
  1878. struct cpuinfo_mips *c = &current_cpu_data;
  1879. pr_info("CPU%d revision is: %08x (%s)\n",
  1880. smp_processor_id(), c->processor_id, cpu_name_string());
  1881. if (c->options & MIPS_CPU_FPU)
  1882. printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
  1883. if (cpu_has_msa)
  1884. pr_info("MSA revision is: %08x\n", c->msa_id);
  1885. }
  1886. void cpu_set_cluster(struct cpuinfo_mips *cpuinfo, unsigned int cluster)
  1887. {
  1888. /* Ensure the core number fits in the field */
  1889. WARN_ON(cluster > (MIPS_GLOBALNUMBER_CLUSTER >>
  1890. MIPS_GLOBALNUMBER_CLUSTER_SHF));
  1891. cpuinfo->globalnumber &= ~MIPS_GLOBALNUMBER_CLUSTER;
  1892. cpuinfo->globalnumber |= cluster << MIPS_GLOBALNUMBER_CLUSTER_SHF;
  1893. }
  1894. void cpu_set_core(struct cpuinfo_mips *cpuinfo, unsigned int core)
  1895. {
  1896. /* Ensure the core number fits in the field */
  1897. WARN_ON(core > (MIPS_GLOBALNUMBER_CORE >> MIPS_GLOBALNUMBER_CORE_SHF));
  1898. cpuinfo->globalnumber &= ~MIPS_GLOBALNUMBER_CORE;
  1899. cpuinfo->globalnumber |= core << MIPS_GLOBALNUMBER_CORE_SHF;
  1900. }
  1901. void cpu_set_vpe_id(struct cpuinfo_mips *cpuinfo, unsigned int vpe)
  1902. {
  1903. /* Ensure the VP(E) ID fits in the field */
  1904. WARN_ON(vpe > (MIPS_GLOBALNUMBER_VP >> MIPS_GLOBALNUMBER_VP_SHF));
  1905. /* Ensure we're not using VP(E)s without support */
  1906. WARN_ON(vpe && !IS_ENABLED(CONFIG_MIPS_MT_SMP) &&
  1907. !IS_ENABLED(CONFIG_CPU_MIPSR6));
  1908. cpuinfo->globalnumber &= ~MIPS_GLOBALNUMBER_VP;
  1909. cpuinfo->globalnumber |= vpe << MIPS_GLOBALNUMBER_VP_SHF;
  1910. }