cpu-features.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2003, 2004 Ralf Baechle
  7. * Copyright (C) 2004 Maciej W. Rozycki
  8. */
  9. #ifndef __ASM_CPU_FEATURES_H
  10. #define __ASM_CPU_FEATURES_H
  11. #include <asm/cpu.h>
  12. #include <asm/cpu-info.h>
  13. #include <cpu-feature-overrides.h>
  14. /*
  15. * SMP assumption: Options of CPU 0 are a superset of all processors.
  16. * This is true for all known MIPS systems.
  17. */
  18. #ifndef cpu_has_tlb
  19. #define cpu_has_tlb (cpu_data[0].options & MIPS_CPU_TLB)
  20. #endif
  21. /*
  22. * For the moment we don't consider R6000 and R8000 so we can assume that
  23. * anything that doesn't support R4000-style exceptions and interrupts is
  24. * R3000-like. Users should still treat these two macro definitions as
  25. * opaque.
  26. */
  27. #ifndef cpu_has_3kex
  28. #define cpu_has_3kex (!cpu_has_4kex)
  29. #endif
  30. #ifndef cpu_has_4kex
  31. #define cpu_has_4kex (cpu_data[0].options & MIPS_CPU_4KEX)
  32. #endif
  33. #ifndef cpu_has_3k_cache
  34. #define cpu_has_3k_cache (cpu_data[0].options & MIPS_CPU_3K_CACHE)
  35. #endif
  36. #define cpu_has_6k_cache 0
  37. #define cpu_has_8k_cache 0
  38. #ifndef cpu_has_4k_cache
  39. #define cpu_has_4k_cache (cpu_data[0].options & MIPS_CPU_4K_CACHE)
  40. #endif
  41. #ifndef cpu_has_tx39_cache
  42. #define cpu_has_tx39_cache (cpu_data[0].options & MIPS_CPU_TX39_CACHE)
  43. #endif
  44. #ifndef cpu_has_octeon_cache
  45. #define cpu_has_octeon_cache 0
  46. #endif
  47. #ifndef cpu_has_fpu
  48. #define cpu_has_fpu (current_cpu_data.options & MIPS_CPU_FPU)
  49. #define raw_cpu_has_fpu (raw_current_cpu_data.options & MIPS_CPU_FPU)
  50. #else
  51. #define raw_cpu_has_fpu cpu_has_fpu
  52. #endif
  53. #ifndef cpu_has_32fpr
  54. #define cpu_has_32fpr (cpu_data[0].options & MIPS_CPU_32FPR)
  55. #endif
  56. #ifndef cpu_has_counter
  57. #define cpu_has_counter (cpu_data[0].options & MIPS_CPU_COUNTER)
  58. #endif
  59. #ifndef cpu_has_watch
  60. #define cpu_has_watch (cpu_data[0].options & MIPS_CPU_WATCH)
  61. #endif
  62. #ifndef cpu_has_divec
  63. #define cpu_has_divec (cpu_data[0].options & MIPS_CPU_DIVEC)
  64. #endif
  65. #ifndef cpu_has_vce
  66. #define cpu_has_vce (cpu_data[0].options & MIPS_CPU_VCE)
  67. #endif
  68. #ifndef cpu_has_cache_cdex_p
  69. #define cpu_has_cache_cdex_p (cpu_data[0].options & MIPS_CPU_CACHE_CDEX_P)
  70. #endif
  71. #ifndef cpu_has_cache_cdex_s
  72. #define cpu_has_cache_cdex_s (cpu_data[0].options & MIPS_CPU_CACHE_CDEX_S)
  73. #endif
  74. #ifndef cpu_has_prefetch
  75. #define cpu_has_prefetch (cpu_data[0].options & MIPS_CPU_PREFETCH)
  76. #endif
  77. #ifndef cpu_has_mcheck
  78. #define cpu_has_mcheck (cpu_data[0].options & MIPS_CPU_MCHECK)
  79. #endif
  80. #ifndef cpu_has_ejtag
  81. #define cpu_has_ejtag (cpu_data[0].options & MIPS_CPU_EJTAG)
  82. #endif
  83. #ifndef cpu_has_llsc
  84. #define cpu_has_llsc (cpu_data[0].options & MIPS_CPU_LLSC)
  85. #endif
  86. #ifndef kernel_uses_llsc
  87. #define kernel_uses_llsc cpu_has_llsc
  88. #endif
  89. #ifndef cpu_has_mips16
  90. #define cpu_has_mips16 (cpu_data[0].ases & MIPS_ASE_MIPS16)
  91. #endif
  92. #ifndef cpu_has_mdmx
  93. #define cpu_has_mdmx (cpu_data[0].ases & MIPS_ASE_MDMX)
  94. #endif
  95. #ifndef cpu_has_mips3d
  96. #define cpu_has_mips3d (cpu_data[0].ases & MIPS_ASE_MIPS3D)
  97. #endif
  98. #ifndef cpu_has_smartmips
  99. #define cpu_has_smartmips (cpu_data[0].ases & MIPS_ASE_SMARTMIPS)
  100. #endif
  101. #ifndef cpu_has_rixi
  102. #define cpu_has_rixi (cpu_data[0].options & MIPS_CPU_RIXI)
  103. #endif
  104. #ifndef cpu_has_mmips
  105. # ifdef CONFIG_SYS_SUPPORTS_MICROMIPS
  106. # define cpu_has_mmips (cpu_data[0].options & MIPS_CPU_MICROMIPS)
  107. # else
  108. # define cpu_has_mmips 0
  109. # endif
  110. #endif
  111. #ifndef cpu_has_vtag_icache
  112. #define cpu_has_vtag_icache (cpu_data[0].icache.flags & MIPS_CACHE_VTAG)
  113. #endif
  114. #ifndef cpu_has_dc_aliases
  115. #define cpu_has_dc_aliases (cpu_data[0].dcache.flags & MIPS_CACHE_ALIASES)
  116. #endif
  117. #ifndef cpu_has_ic_fills_f_dc
  118. #define cpu_has_ic_fills_f_dc (cpu_data[0].icache.flags & MIPS_CACHE_IC_F_DC)
  119. #endif
  120. #ifndef cpu_has_pindexed_dcache
  121. #define cpu_has_pindexed_dcache (cpu_data[0].dcache.flags & MIPS_CACHE_PINDEX)
  122. #endif
  123. #ifndef cpu_has_local_ebase
  124. #define cpu_has_local_ebase 1
  125. #endif
  126. /*
  127. * I-Cache snoops remote store. This only matters on SMP. Some multiprocessors
  128. * such as the R10000 have I-Caches that snoop local stores; the embedded ones
  129. * don't. For maintaining I-cache coherency this means we need to flush the
  130. * D-cache all the way back to whever the I-cache does refills from, so the
  131. * I-cache has a chance to see the new data at all. Then we have to flush the
  132. * I-cache also.
  133. * Note we may have been rescheduled and may no longer be running on the CPU
  134. * that did the store so we can't optimize this into only doing the flush on
  135. * the local CPU.
  136. */
  137. #ifndef cpu_icache_snoops_remote_store
  138. #ifdef CONFIG_SMP
  139. #define cpu_icache_snoops_remote_store (cpu_data[0].icache.flags & MIPS_IC_SNOOPS_REMOTE)
  140. #else
  141. #define cpu_icache_snoops_remote_store 1
  142. #endif
  143. #endif
  144. #ifndef cpu_has_mips_2
  145. # define cpu_has_mips_2 (cpu_data[0].isa_level & MIPS_CPU_ISA_II)
  146. #endif
  147. #ifndef cpu_has_mips_3
  148. # define cpu_has_mips_3 (cpu_data[0].isa_level & MIPS_CPU_ISA_III)
  149. #endif
  150. #ifndef cpu_has_mips_4
  151. # define cpu_has_mips_4 (cpu_data[0].isa_level & MIPS_CPU_ISA_IV)
  152. #endif
  153. #ifndef cpu_has_mips_5
  154. # define cpu_has_mips_5 (cpu_data[0].isa_level & MIPS_CPU_ISA_V)
  155. #endif
  156. #ifndef cpu_has_mips32r1
  157. # define cpu_has_mips32r1 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R1)
  158. #endif
  159. #ifndef cpu_has_mips32r2
  160. # define cpu_has_mips32r2 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R2)
  161. #endif
  162. #ifndef cpu_has_mips64r1
  163. # define cpu_has_mips64r1 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R1)
  164. #endif
  165. #ifndef cpu_has_mips64r2
  166. # define cpu_has_mips64r2 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R2)
  167. #endif
  168. /*
  169. * Shortcuts ...
  170. */
  171. #define cpu_has_mips32 (cpu_has_mips32r1 | cpu_has_mips32r2)
  172. #define cpu_has_mips64 (cpu_has_mips64r1 | cpu_has_mips64r2)
  173. #define cpu_has_mips_r1 (cpu_has_mips32r1 | cpu_has_mips64r1)
  174. #define cpu_has_mips_r2 (cpu_has_mips32r2 | cpu_has_mips64r2)
  175. #define cpu_has_mips_r (cpu_has_mips32r1 | cpu_has_mips32r2 | \
  176. cpu_has_mips64r1 | cpu_has_mips64r2)
  177. #ifndef cpu_has_mips_r2_exec_hazard
  178. #define cpu_has_mips_r2_exec_hazard cpu_has_mips_r2
  179. #endif
  180. /*
  181. * MIPS32, MIPS64, VR5500, IDT32332, IDT32334 and maybe a few other
  182. * pre-MIPS32/MIPS53 processors have CLO, CLZ. The IDT RC64574 is 64-bit and
  183. * has CLO and CLZ but not DCLO nor DCLZ. For 64-bit kernels
  184. * cpu_has_clo_clz also indicates the availability of DCLO and DCLZ.
  185. */
  186. #ifndef cpu_has_clo_clz
  187. #define cpu_has_clo_clz cpu_has_mips_r
  188. #endif
  189. #ifndef cpu_has_dsp
  190. #define cpu_has_dsp (cpu_data[0].ases & MIPS_ASE_DSP)
  191. #endif
  192. #ifndef cpu_has_dsp2
  193. #define cpu_has_dsp2 (cpu_data[0].ases & MIPS_ASE_DSP2P)
  194. #endif
  195. #ifndef cpu_has_mipsmt
  196. #define cpu_has_mipsmt (cpu_data[0].ases & MIPS_ASE_MIPSMT)
  197. #endif
  198. #ifndef cpu_has_userlocal
  199. #define cpu_has_userlocal (cpu_data[0].options & MIPS_CPU_ULRI)
  200. #endif
  201. #ifdef CONFIG_32BIT
  202. # ifndef cpu_has_nofpuex
  203. # define cpu_has_nofpuex (cpu_data[0].options & MIPS_CPU_NOFPUEX)
  204. # endif
  205. # ifndef cpu_has_64bits
  206. # define cpu_has_64bits (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
  207. # endif
  208. # ifndef cpu_has_64bit_zero_reg
  209. # define cpu_has_64bit_zero_reg (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
  210. # endif
  211. # ifndef cpu_has_64bit_gp_regs
  212. # define cpu_has_64bit_gp_regs 0
  213. # endif
  214. # ifndef cpu_has_64bit_addresses
  215. # define cpu_has_64bit_addresses 0
  216. # endif
  217. # ifndef cpu_vmbits
  218. # define cpu_vmbits 31
  219. # endif
  220. #endif
  221. #ifdef CONFIG_64BIT
  222. # ifndef cpu_has_nofpuex
  223. # define cpu_has_nofpuex 0
  224. # endif
  225. # ifndef cpu_has_64bits
  226. # define cpu_has_64bits 1
  227. # endif
  228. # ifndef cpu_has_64bit_zero_reg
  229. # define cpu_has_64bit_zero_reg 1
  230. # endif
  231. # ifndef cpu_has_64bit_gp_regs
  232. # define cpu_has_64bit_gp_regs 1
  233. # endif
  234. # ifndef cpu_has_64bit_addresses
  235. # define cpu_has_64bit_addresses 1
  236. # endif
  237. # ifndef cpu_vmbits
  238. # define cpu_vmbits cpu_data[0].vmbits
  239. # define __NEED_VMBITS_PROBE
  240. # endif
  241. #endif
  242. #if defined(CONFIG_CPU_MIPSR2_IRQ_VI) && !defined(cpu_has_vint)
  243. # define cpu_has_vint (cpu_data[0].options & MIPS_CPU_VINT)
  244. #elif !defined(cpu_has_vint)
  245. # define cpu_has_vint 0
  246. #endif
  247. #if defined(CONFIG_CPU_MIPSR2_IRQ_EI) && !defined(cpu_has_veic)
  248. # define cpu_has_veic (cpu_data[0].options & MIPS_CPU_VEIC)
  249. #elif !defined(cpu_has_veic)
  250. # define cpu_has_veic 0
  251. #endif
  252. #ifndef cpu_has_inclusive_pcaches
  253. #define cpu_has_inclusive_pcaches (cpu_data[0].options & MIPS_CPU_INCLUSIVE_CACHES)
  254. #endif
  255. #ifndef cpu_dcache_line_size
  256. #define cpu_dcache_line_size() cpu_data[0].dcache.linesz
  257. #endif
  258. #ifndef cpu_icache_line_size
  259. #define cpu_icache_line_size() cpu_data[0].icache.linesz
  260. #endif
  261. #ifndef cpu_scache_line_size
  262. #define cpu_scache_line_size() cpu_data[0].scache.linesz
  263. #endif
  264. #ifndef cpu_hwrena_impl_bits
  265. #define cpu_hwrena_impl_bits 0
  266. #endif
  267. #ifndef cpu_has_perf_cntr_intr_bit
  268. #define cpu_has_perf_cntr_intr_bit (cpu_data[0].options & MIPS_CPU_PCI)
  269. #endif
  270. #ifndef cpu_has_vz
  271. #define cpu_has_vz (cpu_data[0].ases & MIPS_ASE_VZ)
  272. #endif
  273. #endif /* __ASM_CPU_FEATURES_H */