18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 38c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 48c2ecf20Sopenharmony_ci * for more details. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 2003, 2004 Ralf Baechle 78c2ecf20Sopenharmony_ci * Copyright (C) 2004 Maciej W. Rozycki 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci#ifndef __ASM_CPU_FEATURES_H 108c2ecf20Sopenharmony_ci#define __ASM_CPU_FEATURES_H 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <asm/cpu.h> 138c2ecf20Sopenharmony_ci#include <asm/cpu-info.h> 148c2ecf20Sopenharmony_ci#include <asm/isa-rev.h> 158c2ecf20Sopenharmony_ci#include <cpu-feature-overrides.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define __ase(ase) (cpu_data[0].ases & (ase)) 188c2ecf20Sopenharmony_ci#define __isa(isa) (cpu_data[0].isa_level & (isa)) 198c2ecf20Sopenharmony_ci#define __opt(opt) (cpu_data[0].options & (opt)) 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci/* 228c2ecf20Sopenharmony_ci * Check if MIPS_ISA_REV is >= isa *and* an option or ASE is detected during 238c2ecf20Sopenharmony_ci * boot (typically by cpu_probe()). 248c2ecf20Sopenharmony_ci * 258c2ecf20Sopenharmony_ci * Note that these should only be used in cases where a kernel built for an 268c2ecf20Sopenharmony_ci * older ISA *cannot* run on a CPU which supports the feature in question. For 278c2ecf20Sopenharmony_ci * example this may be used for features introduced with MIPSr6, since a kernel 288c2ecf20Sopenharmony_ci * built for an older ISA cannot run on a MIPSr6 CPU. This should not be used 298c2ecf20Sopenharmony_ci * for MIPSr2 features however, since a MIPSr1 or earlier kernel might run on a 308c2ecf20Sopenharmony_ci * MIPSr2 CPU. 318c2ecf20Sopenharmony_ci */ 328c2ecf20Sopenharmony_ci#define __isa_ge_and_ase(isa, ase) ((MIPS_ISA_REV >= (isa)) && __ase(ase)) 338c2ecf20Sopenharmony_ci#define __isa_ge_and_opt(isa, opt) ((MIPS_ISA_REV >= (isa)) && __opt(opt)) 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci/* 368c2ecf20Sopenharmony_ci * Check if MIPS_ISA_REV is >= isa *or* an option or ASE is detected during 378c2ecf20Sopenharmony_ci * boot (typically by cpu_probe()). 388c2ecf20Sopenharmony_ci * 398c2ecf20Sopenharmony_ci * These are for use with features that are optional up until a particular ISA 408c2ecf20Sopenharmony_ci * revision & then become required. 418c2ecf20Sopenharmony_ci */ 428c2ecf20Sopenharmony_ci#define __isa_ge_or_ase(isa, ase) ((MIPS_ISA_REV >= (isa)) || __ase(ase)) 438c2ecf20Sopenharmony_ci#define __isa_ge_or_opt(isa, opt) ((MIPS_ISA_REV >= (isa)) || __opt(opt)) 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/* 468c2ecf20Sopenharmony_ci * Check if MIPS_ISA_REV is < isa *and* an option or ASE is detected during 478c2ecf20Sopenharmony_ci * boot (typically by cpu_probe()). 488c2ecf20Sopenharmony_ci * 498c2ecf20Sopenharmony_ci * These are for use with features that are optional up until a particular ISA 508c2ecf20Sopenharmony_ci * revision & are then removed - ie. no longer present in any CPU implementing 518c2ecf20Sopenharmony_ci * the given ISA revision. 528c2ecf20Sopenharmony_ci */ 538c2ecf20Sopenharmony_ci#define __isa_lt_and_ase(isa, ase) ((MIPS_ISA_REV < (isa)) && __ase(ase)) 548c2ecf20Sopenharmony_ci#define __isa_lt_and_opt(isa, opt) ((MIPS_ISA_REV < (isa)) && __opt(opt)) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* 578c2ecf20Sopenharmony_ci * Similarly allow for ISA level checks that take into account knowledge of the 588c2ecf20Sopenharmony_ci * ISA targeted by the kernel build, provided by MIPS_ISA_REV. 598c2ecf20Sopenharmony_ci */ 608c2ecf20Sopenharmony_ci#define __isa_ge_and_flag(isa, flag) ((MIPS_ISA_REV >= (isa)) && __isa(flag)) 618c2ecf20Sopenharmony_ci#define __isa_ge_or_flag(isa, flag) ((MIPS_ISA_REV >= (isa)) || __isa(flag)) 628c2ecf20Sopenharmony_ci#define __isa_lt_and_flag(isa, flag) ((MIPS_ISA_REV < (isa)) && __isa(flag)) 638c2ecf20Sopenharmony_ci#define __isa_range(ge, lt) \ 648c2ecf20Sopenharmony_ci ((MIPS_ISA_REV >= (ge)) && (MIPS_ISA_REV < (lt))) 658c2ecf20Sopenharmony_ci#define __isa_range_or_flag(ge, lt, flag) \ 668c2ecf20Sopenharmony_ci (__isa_range(ge, lt) || ((MIPS_ISA_REV < (lt)) && __isa(flag))) 678c2ecf20Sopenharmony_ci#define __isa_range_and_ase(ge, lt, ase) \ 688c2ecf20Sopenharmony_ci (__isa_range(ge, lt) && __ase(ase)) 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci/* 718c2ecf20Sopenharmony_ci * SMP assumption: Options of CPU 0 are a superset of all processors. 728c2ecf20Sopenharmony_ci * This is true for all known MIPS systems. 738c2ecf20Sopenharmony_ci */ 748c2ecf20Sopenharmony_ci#ifndef cpu_has_tlb 758c2ecf20Sopenharmony_ci#define cpu_has_tlb __opt(MIPS_CPU_TLB) 768c2ecf20Sopenharmony_ci#endif 778c2ecf20Sopenharmony_ci#ifndef cpu_has_ftlb 788c2ecf20Sopenharmony_ci#define cpu_has_ftlb __opt(MIPS_CPU_FTLB) 798c2ecf20Sopenharmony_ci#endif 808c2ecf20Sopenharmony_ci#ifndef cpu_has_tlbinv 818c2ecf20Sopenharmony_ci#define cpu_has_tlbinv __opt(MIPS_CPU_TLBINV) 828c2ecf20Sopenharmony_ci#endif 838c2ecf20Sopenharmony_ci#ifndef cpu_has_segments 848c2ecf20Sopenharmony_ci#define cpu_has_segments __opt(MIPS_CPU_SEGMENTS) 858c2ecf20Sopenharmony_ci#endif 868c2ecf20Sopenharmony_ci#ifndef cpu_has_eva 878c2ecf20Sopenharmony_ci#define cpu_has_eva __opt(MIPS_CPU_EVA) 888c2ecf20Sopenharmony_ci#endif 898c2ecf20Sopenharmony_ci#ifndef cpu_has_htw 908c2ecf20Sopenharmony_ci#define cpu_has_htw __opt(MIPS_CPU_HTW) 918c2ecf20Sopenharmony_ci#endif 928c2ecf20Sopenharmony_ci#ifndef cpu_has_ldpte 938c2ecf20Sopenharmony_ci#define cpu_has_ldpte __opt(MIPS_CPU_LDPTE) 948c2ecf20Sopenharmony_ci#endif 958c2ecf20Sopenharmony_ci#ifndef cpu_has_rixiex 968c2ecf20Sopenharmony_ci#define cpu_has_rixiex __isa_ge_or_opt(6, MIPS_CPU_RIXIEX) 978c2ecf20Sopenharmony_ci#endif 988c2ecf20Sopenharmony_ci#ifndef cpu_has_maar 998c2ecf20Sopenharmony_ci#define cpu_has_maar __opt(MIPS_CPU_MAAR) 1008c2ecf20Sopenharmony_ci#endif 1018c2ecf20Sopenharmony_ci#ifndef cpu_has_rw_llb 1028c2ecf20Sopenharmony_ci#define cpu_has_rw_llb __isa_ge_or_opt(6, MIPS_CPU_RW_LLB) 1038c2ecf20Sopenharmony_ci#endif 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci/* 1068c2ecf20Sopenharmony_ci * For the moment we don't consider R6000 and R8000 so we can assume that 1078c2ecf20Sopenharmony_ci * anything that doesn't support R4000-style exceptions and interrupts is 1088c2ecf20Sopenharmony_ci * R3000-like. Users should still treat these two macro definitions as 1098c2ecf20Sopenharmony_ci * opaque. 1108c2ecf20Sopenharmony_ci */ 1118c2ecf20Sopenharmony_ci#ifndef cpu_has_3kex 1128c2ecf20Sopenharmony_ci#define cpu_has_3kex (!cpu_has_4kex) 1138c2ecf20Sopenharmony_ci#endif 1148c2ecf20Sopenharmony_ci#ifndef cpu_has_4kex 1158c2ecf20Sopenharmony_ci#define cpu_has_4kex __isa_ge_or_opt(1, MIPS_CPU_4KEX) 1168c2ecf20Sopenharmony_ci#endif 1178c2ecf20Sopenharmony_ci#ifndef cpu_has_3k_cache 1188c2ecf20Sopenharmony_ci#define cpu_has_3k_cache __isa_lt_and_opt(1, MIPS_CPU_3K_CACHE) 1198c2ecf20Sopenharmony_ci#endif 1208c2ecf20Sopenharmony_ci#define cpu_has_6k_cache 0 1218c2ecf20Sopenharmony_ci#define cpu_has_8k_cache 0 1228c2ecf20Sopenharmony_ci#ifndef cpu_has_4k_cache 1238c2ecf20Sopenharmony_ci#define cpu_has_4k_cache __isa_ge_or_opt(1, MIPS_CPU_4K_CACHE) 1248c2ecf20Sopenharmony_ci#endif 1258c2ecf20Sopenharmony_ci#ifndef cpu_has_tx39_cache 1268c2ecf20Sopenharmony_ci#define cpu_has_tx39_cache __opt(MIPS_CPU_TX39_CACHE) 1278c2ecf20Sopenharmony_ci#endif 1288c2ecf20Sopenharmony_ci#ifndef cpu_has_octeon_cache 1298c2ecf20Sopenharmony_ci#define cpu_has_octeon_cache \ 1308c2ecf20Sopenharmony_ci({ \ 1318c2ecf20Sopenharmony_ci int __res; \ 1328c2ecf20Sopenharmony_ci \ 1338c2ecf20Sopenharmony_ci switch (boot_cpu_type()) { \ 1348c2ecf20Sopenharmony_ci case CPU_CAVIUM_OCTEON: \ 1358c2ecf20Sopenharmony_ci case CPU_CAVIUM_OCTEON_PLUS: \ 1368c2ecf20Sopenharmony_ci case CPU_CAVIUM_OCTEON2: \ 1378c2ecf20Sopenharmony_ci case CPU_CAVIUM_OCTEON3: \ 1388c2ecf20Sopenharmony_ci __res = 1; \ 1398c2ecf20Sopenharmony_ci break; \ 1408c2ecf20Sopenharmony_ci \ 1418c2ecf20Sopenharmony_ci default: \ 1428c2ecf20Sopenharmony_ci __res = 0; \ 1438c2ecf20Sopenharmony_ci } \ 1448c2ecf20Sopenharmony_ci \ 1458c2ecf20Sopenharmony_ci __res; \ 1468c2ecf20Sopenharmony_ci}) 1478c2ecf20Sopenharmony_ci#endif 1488c2ecf20Sopenharmony_ci/* Don't override `cpu_has_fpu' to 1 or the "nofpu" option won't work. */ 1498c2ecf20Sopenharmony_ci#ifndef cpu_has_fpu 1508c2ecf20Sopenharmony_ci# ifdef CONFIG_MIPS_FP_SUPPORT 1518c2ecf20Sopenharmony_ci# define cpu_has_fpu (current_cpu_data.options & MIPS_CPU_FPU) 1528c2ecf20Sopenharmony_ci# define raw_cpu_has_fpu (raw_current_cpu_data.options & MIPS_CPU_FPU) 1538c2ecf20Sopenharmony_ci# else 1548c2ecf20Sopenharmony_ci# define cpu_has_fpu 0 1558c2ecf20Sopenharmony_ci# define raw_cpu_has_fpu 0 1568c2ecf20Sopenharmony_ci# endif 1578c2ecf20Sopenharmony_ci#else 1588c2ecf20Sopenharmony_ci# define raw_cpu_has_fpu cpu_has_fpu 1598c2ecf20Sopenharmony_ci#endif 1608c2ecf20Sopenharmony_ci#ifndef cpu_has_32fpr 1618c2ecf20Sopenharmony_ci#define cpu_has_32fpr __isa_ge_or_opt(1, MIPS_CPU_32FPR) 1628c2ecf20Sopenharmony_ci#endif 1638c2ecf20Sopenharmony_ci#ifndef cpu_has_counter 1648c2ecf20Sopenharmony_ci#define cpu_has_counter __opt(MIPS_CPU_COUNTER) 1658c2ecf20Sopenharmony_ci#endif 1668c2ecf20Sopenharmony_ci#ifndef cpu_has_watch 1678c2ecf20Sopenharmony_ci#define cpu_has_watch __opt(MIPS_CPU_WATCH) 1688c2ecf20Sopenharmony_ci#endif 1698c2ecf20Sopenharmony_ci#ifndef cpu_has_divec 1708c2ecf20Sopenharmony_ci#define cpu_has_divec __isa_ge_or_opt(1, MIPS_CPU_DIVEC) 1718c2ecf20Sopenharmony_ci#endif 1728c2ecf20Sopenharmony_ci#ifndef cpu_has_vce 1738c2ecf20Sopenharmony_ci#define cpu_has_vce __opt(MIPS_CPU_VCE) 1748c2ecf20Sopenharmony_ci#endif 1758c2ecf20Sopenharmony_ci#ifndef cpu_has_cache_cdex_p 1768c2ecf20Sopenharmony_ci#define cpu_has_cache_cdex_p __opt(MIPS_CPU_CACHE_CDEX_P) 1778c2ecf20Sopenharmony_ci#endif 1788c2ecf20Sopenharmony_ci#ifndef cpu_has_cache_cdex_s 1798c2ecf20Sopenharmony_ci#define cpu_has_cache_cdex_s __opt(MIPS_CPU_CACHE_CDEX_S) 1808c2ecf20Sopenharmony_ci#endif 1818c2ecf20Sopenharmony_ci#ifndef cpu_has_prefetch 1828c2ecf20Sopenharmony_ci#define cpu_has_prefetch __isa_ge_or_opt(1, MIPS_CPU_PREFETCH) 1838c2ecf20Sopenharmony_ci#endif 1848c2ecf20Sopenharmony_ci#ifndef cpu_has_mcheck 1858c2ecf20Sopenharmony_ci#define cpu_has_mcheck __isa_ge_or_opt(1, MIPS_CPU_MCHECK) 1868c2ecf20Sopenharmony_ci#endif 1878c2ecf20Sopenharmony_ci#ifndef cpu_has_ejtag 1888c2ecf20Sopenharmony_ci#define cpu_has_ejtag __opt(MIPS_CPU_EJTAG) 1898c2ecf20Sopenharmony_ci#endif 1908c2ecf20Sopenharmony_ci#ifndef cpu_has_llsc 1918c2ecf20Sopenharmony_ci#define cpu_has_llsc __isa_ge_or_opt(1, MIPS_CPU_LLSC) 1928c2ecf20Sopenharmony_ci#endif 1938c2ecf20Sopenharmony_ci#ifndef kernel_uses_llsc 1948c2ecf20Sopenharmony_ci#define kernel_uses_llsc cpu_has_llsc 1958c2ecf20Sopenharmony_ci#endif 1968c2ecf20Sopenharmony_ci#ifndef cpu_has_guestctl0ext 1978c2ecf20Sopenharmony_ci#define cpu_has_guestctl0ext __opt(MIPS_CPU_GUESTCTL0EXT) 1988c2ecf20Sopenharmony_ci#endif 1998c2ecf20Sopenharmony_ci#ifndef cpu_has_guestctl1 2008c2ecf20Sopenharmony_ci#define cpu_has_guestctl1 __opt(MIPS_CPU_GUESTCTL1) 2018c2ecf20Sopenharmony_ci#endif 2028c2ecf20Sopenharmony_ci#ifndef cpu_has_guestctl2 2038c2ecf20Sopenharmony_ci#define cpu_has_guestctl2 __opt(MIPS_CPU_GUESTCTL2) 2048c2ecf20Sopenharmony_ci#endif 2058c2ecf20Sopenharmony_ci#ifndef cpu_has_guestid 2068c2ecf20Sopenharmony_ci#define cpu_has_guestid __opt(MIPS_CPU_GUESTID) 2078c2ecf20Sopenharmony_ci#endif 2088c2ecf20Sopenharmony_ci#ifndef cpu_has_drg 2098c2ecf20Sopenharmony_ci#define cpu_has_drg __opt(MIPS_CPU_DRG) 2108c2ecf20Sopenharmony_ci#endif 2118c2ecf20Sopenharmony_ci#ifndef cpu_has_mips16 2128c2ecf20Sopenharmony_ci#define cpu_has_mips16 __isa_lt_and_ase(6, MIPS_ASE_MIPS16) 2138c2ecf20Sopenharmony_ci#endif 2148c2ecf20Sopenharmony_ci#ifndef cpu_has_mips16e2 2158c2ecf20Sopenharmony_ci#define cpu_has_mips16e2 __isa_lt_and_ase(6, MIPS_ASE_MIPS16E2) 2168c2ecf20Sopenharmony_ci#endif 2178c2ecf20Sopenharmony_ci#ifndef cpu_has_mdmx 2188c2ecf20Sopenharmony_ci#define cpu_has_mdmx __isa_lt_and_ase(6, MIPS_ASE_MDMX) 2198c2ecf20Sopenharmony_ci#endif 2208c2ecf20Sopenharmony_ci#ifndef cpu_has_mips3d 2218c2ecf20Sopenharmony_ci#define cpu_has_mips3d __isa_lt_and_ase(6, MIPS_ASE_MIPS3D) 2228c2ecf20Sopenharmony_ci#endif 2238c2ecf20Sopenharmony_ci#ifndef cpu_has_smartmips 2248c2ecf20Sopenharmony_ci#define cpu_has_smartmips __isa_lt_and_ase(6, MIPS_ASE_SMARTMIPS) 2258c2ecf20Sopenharmony_ci#endif 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci#ifndef cpu_has_rixi 2288c2ecf20Sopenharmony_ci#define cpu_has_rixi __isa_ge_or_opt(6, MIPS_CPU_RIXI) 2298c2ecf20Sopenharmony_ci#endif 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci#ifndef cpu_has_mmips 2328c2ecf20Sopenharmony_ci# if defined(__mips_micromips) 2338c2ecf20Sopenharmony_ci# define cpu_has_mmips 1 2348c2ecf20Sopenharmony_ci# elif defined(CONFIG_SYS_SUPPORTS_MICROMIPS) 2358c2ecf20Sopenharmony_ci# define cpu_has_mmips __opt(MIPS_CPU_MICROMIPS) 2368c2ecf20Sopenharmony_ci# else 2378c2ecf20Sopenharmony_ci# define cpu_has_mmips 0 2388c2ecf20Sopenharmony_ci# endif 2398c2ecf20Sopenharmony_ci#endif 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci#ifndef cpu_has_lpa 2428c2ecf20Sopenharmony_ci#define cpu_has_lpa __opt(MIPS_CPU_LPA) 2438c2ecf20Sopenharmony_ci#endif 2448c2ecf20Sopenharmony_ci#ifndef cpu_has_mvh 2458c2ecf20Sopenharmony_ci#define cpu_has_mvh __opt(MIPS_CPU_MVH) 2468c2ecf20Sopenharmony_ci#endif 2478c2ecf20Sopenharmony_ci#ifndef cpu_has_xpa 2488c2ecf20Sopenharmony_ci#define cpu_has_xpa (cpu_has_lpa && cpu_has_mvh) 2498c2ecf20Sopenharmony_ci#endif 2508c2ecf20Sopenharmony_ci#ifndef cpu_has_vtag_icache 2518c2ecf20Sopenharmony_ci#define cpu_has_vtag_icache (cpu_data[0].icache.flags & MIPS_CACHE_VTAG) 2528c2ecf20Sopenharmony_ci#endif 2538c2ecf20Sopenharmony_ci#ifndef cpu_has_dc_aliases 2548c2ecf20Sopenharmony_ci#define cpu_has_dc_aliases (cpu_data[0].dcache.flags & MIPS_CACHE_ALIASES) 2558c2ecf20Sopenharmony_ci#endif 2568c2ecf20Sopenharmony_ci#ifndef cpu_has_ic_fills_f_dc 2578c2ecf20Sopenharmony_ci#define cpu_has_ic_fills_f_dc (cpu_data[0].icache.flags & MIPS_CACHE_IC_F_DC) 2588c2ecf20Sopenharmony_ci#endif 2598c2ecf20Sopenharmony_ci#ifndef cpu_has_pindexed_dcache 2608c2ecf20Sopenharmony_ci#define cpu_has_pindexed_dcache (cpu_data[0].dcache.flags & MIPS_CACHE_PINDEX) 2618c2ecf20Sopenharmony_ci#endif 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci/* 2648c2ecf20Sopenharmony_ci * I-Cache snoops remote store. This only matters on SMP. Some multiprocessors 2658c2ecf20Sopenharmony_ci * such as the R10000 have I-Caches that snoop local stores; the embedded ones 2668c2ecf20Sopenharmony_ci * don't. For maintaining I-cache coherency this means we need to flush the 2678c2ecf20Sopenharmony_ci * D-cache all the way back to whever the I-cache does refills from, so the 2688c2ecf20Sopenharmony_ci * I-cache has a chance to see the new data at all. Then we have to flush the 2698c2ecf20Sopenharmony_ci * I-cache also. 2708c2ecf20Sopenharmony_ci * Note we may have been rescheduled and may no longer be running on the CPU 2718c2ecf20Sopenharmony_ci * that did the store so we can't optimize this into only doing the flush on 2728c2ecf20Sopenharmony_ci * the local CPU. 2738c2ecf20Sopenharmony_ci */ 2748c2ecf20Sopenharmony_ci#ifndef cpu_icache_snoops_remote_store 2758c2ecf20Sopenharmony_ci#ifdef CONFIG_SMP 2768c2ecf20Sopenharmony_ci#define cpu_icache_snoops_remote_store (cpu_data[0].icache.flags & MIPS_IC_SNOOPS_REMOTE) 2778c2ecf20Sopenharmony_ci#else 2788c2ecf20Sopenharmony_ci#define cpu_icache_snoops_remote_store 1 2798c2ecf20Sopenharmony_ci#endif 2808c2ecf20Sopenharmony_ci#endif 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci#ifndef cpu_has_mips_1 2838c2ecf20Sopenharmony_ci# define cpu_has_mips_1 (MIPS_ISA_REV < 6) 2848c2ecf20Sopenharmony_ci#endif 2858c2ecf20Sopenharmony_ci#ifndef cpu_has_mips_2 2868c2ecf20Sopenharmony_ci# define cpu_has_mips_2 __isa_lt_and_flag(6, MIPS_CPU_ISA_II) 2878c2ecf20Sopenharmony_ci#endif 2888c2ecf20Sopenharmony_ci#ifndef cpu_has_mips_3 2898c2ecf20Sopenharmony_ci# define cpu_has_mips_3 __isa_lt_and_flag(6, MIPS_CPU_ISA_III) 2908c2ecf20Sopenharmony_ci#endif 2918c2ecf20Sopenharmony_ci#ifndef cpu_has_mips_4 2928c2ecf20Sopenharmony_ci# define cpu_has_mips_4 __isa_lt_and_flag(6, MIPS_CPU_ISA_IV) 2938c2ecf20Sopenharmony_ci#endif 2948c2ecf20Sopenharmony_ci#ifndef cpu_has_mips_5 2958c2ecf20Sopenharmony_ci# define cpu_has_mips_5 __isa_lt_and_flag(6, MIPS_CPU_ISA_V) 2968c2ecf20Sopenharmony_ci#endif 2978c2ecf20Sopenharmony_ci#ifndef cpu_has_mips32r1 2988c2ecf20Sopenharmony_ci# define cpu_has_mips32r1 __isa_range_or_flag(1, 6, MIPS_CPU_ISA_M32R1) 2998c2ecf20Sopenharmony_ci#endif 3008c2ecf20Sopenharmony_ci#ifndef cpu_has_mips32r2 3018c2ecf20Sopenharmony_ci# define cpu_has_mips32r2 __isa_range_or_flag(2, 6, MIPS_CPU_ISA_M32R2) 3028c2ecf20Sopenharmony_ci#endif 3038c2ecf20Sopenharmony_ci#ifndef cpu_has_mips32r5 3048c2ecf20Sopenharmony_ci# define cpu_has_mips32r5 __isa_range_or_flag(5, 6, MIPS_CPU_ISA_M32R5) 3058c2ecf20Sopenharmony_ci#endif 3068c2ecf20Sopenharmony_ci#ifndef cpu_has_mips32r6 3078c2ecf20Sopenharmony_ci# define cpu_has_mips32r6 __isa_ge_or_flag(6, MIPS_CPU_ISA_M32R6) 3088c2ecf20Sopenharmony_ci#endif 3098c2ecf20Sopenharmony_ci#ifndef cpu_has_mips64r1 3108c2ecf20Sopenharmony_ci# define cpu_has_mips64r1 (cpu_has_64bits && \ 3118c2ecf20Sopenharmony_ci __isa_range_or_flag(1, 6, MIPS_CPU_ISA_M64R1)) 3128c2ecf20Sopenharmony_ci#endif 3138c2ecf20Sopenharmony_ci#ifndef cpu_has_mips64r2 3148c2ecf20Sopenharmony_ci# define cpu_has_mips64r2 (cpu_has_64bits && \ 3158c2ecf20Sopenharmony_ci __isa_range_or_flag(2, 6, MIPS_CPU_ISA_M64R2)) 3168c2ecf20Sopenharmony_ci#endif 3178c2ecf20Sopenharmony_ci#ifndef cpu_has_mips64r5 3188c2ecf20Sopenharmony_ci# define cpu_has_mips64r5 (cpu_has_64bits && \ 3198c2ecf20Sopenharmony_ci __isa_range_or_flag(5, 6, MIPS_CPU_ISA_M64R5)) 3208c2ecf20Sopenharmony_ci#endif 3218c2ecf20Sopenharmony_ci#ifndef cpu_has_mips64r6 3228c2ecf20Sopenharmony_ci# define cpu_has_mips64r6 __isa_ge_and_flag(6, MIPS_CPU_ISA_M64R6) 3238c2ecf20Sopenharmony_ci#endif 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ci/* 3268c2ecf20Sopenharmony_ci * Shortcuts ... 3278c2ecf20Sopenharmony_ci */ 3288c2ecf20Sopenharmony_ci#define cpu_has_mips_2_3_4_5 (cpu_has_mips_2 | cpu_has_mips_3_4_5) 3298c2ecf20Sopenharmony_ci#define cpu_has_mips_3_4_5 (cpu_has_mips_3 | cpu_has_mips_4_5) 3308c2ecf20Sopenharmony_ci#define cpu_has_mips_4_5 (cpu_has_mips_4 | cpu_has_mips_5) 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_ci#define cpu_has_mips_2_3_4_5_r (cpu_has_mips_2 | cpu_has_mips_3_4_5_r) 3338c2ecf20Sopenharmony_ci#define cpu_has_mips_3_4_5_r (cpu_has_mips_3 | cpu_has_mips_4_5_r) 3348c2ecf20Sopenharmony_ci#define cpu_has_mips_4_5_r (cpu_has_mips_4 | cpu_has_mips_5_r) 3358c2ecf20Sopenharmony_ci#define cpu_has_mips_5_r (cpu_has_mips_5 | cpu_has_mips_r) 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci#define cpu_has_mips_3_4_5_64_r2_r6 \ 3388c2ecf20Sopenharmony_ci (cpu_has_mips_3 | cpu_has_mips_4_5_64_r2_r6) 3398c2ecf20Sopenharmony_ci#define cpu_has_mips_4_5_64_r2_r6 \ 3408c2ecf20Sopenharmony_ci (cpu_has_mips_4_5 | cpu_has_mips64r1 | \ 3418c2ecf20Sopenharmony_ci cpu_has_mips_r2 | cpu_has_mips_r5 | \ 3428c2ecf20Sopenharmony_ci cpu_has_mips_r6) 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_ci#define cpu_has_mips32 (cpu_has_mips32r1 | cpu_has_mips32r2 | \ 3458c2ecf20Sopenharmony_ci cpu_has_mips32r5 | cpu_has_mips32r6) 3468c2ecf20Sopenharmony_ci#define cpu_has_mips64 (cpu_has_mips64r1 | cpu_has_mips64r2 | \ 3478c2ecf20Sopenharmony_ci cpu_has_mips64r5 | cpu_has_mips64r6) 3488c2ecf20Sopenharmony_ci#define cpu_has_mips_r1 (cpu_has_mips32r1 | cpu_has_mips64r1) 3498c2ecf20Sopenharmony_ci#define cpu_has_mips_r2 (cpu_has_mips32r2 | cpu_has_mips64r2) 3508c2ecf20Sopenharmony_ci#define cpu_has_mips_r5 (cpu_has_mips32r5 | cpu_has_mips64r5) 3518c2ecf20Sopenharmony_ci#define cpu_has_mips_r6 (cpu_has_mips32r6 | cpu_has_mips64r6) 3528c2ecf20Sopenharmony_ci#define cpu_has_mips_r (cpu_has_mips32r1 | cpu_has_mips32r2 | \ 3538c2ecf20Sopenharmony_ci cpu_has_mips32r5 | cpu_has_mips32r6 | \ 3548c2ecf20Sopenharmony_ci cpu_has_mips64r1 | cpu_has_mips64r2 | \ 3558c2ecf20Sopenharmony_ci cpu_has_mips64r5 | cpu_has_mips64r6) 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_ci/* MIPSR2 - MIPSR6 have a lot of similarities */ 3588c2ecf20Sopenharmony_ci#define cpu_has_mips_r2_r6 (cpu_has_mips_r2 | cpu_has_mips_r5 | \ 3598c2ecf20Sopenharmony_ci cpu_has_mips_r6) 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci/* 3628c2ecf20Sopenharmony_ci * cpu_has_mips_r2_exec_hazard - return if IHB is required on current processor 3638c2ecf20Sopenharmony_ci * 3648c2ecf20Sopenharmony_ci * Returns non-zero value if the current processor implementation requires 3658c2ecf20Sopenharmony_ci * an IHB instruction to deal with an instruction hazard as per MIPS R2 3668c2ecf20Sopenharmony_ci * architecture specification, zero otherwise. 3678c2ecf20Sopenharmony_ci */ 3688c2ecf20Sopenharmony_ci#ifndef cpu_has_mips_r2_exec_hazard 3698c2ecf20Sopenharmony_ci#define cpu_has_mips_r2_exec_hazard \ 3708c2ecf20Sopenharmony_ci({ \ 3718c2ecf20Sopenharmony_ci int __res; \ 3728c2ecf20Sopenharmony_ci \ 3738c2ecf20Sopenharmony_ci switch (boot_cpu_type()) { \ 3748c2ecf20Sopenharmony_ci case CPU_M14KC: \ 3758c2ecf20Sopenharmony_ci case CPU_74K: \ 3768c2ecf20Sopenharmony_ci case CPU_1074K: \ 3778c2ecf20Sopenharmony_ci case CPU_PROAPTIV: \ 3788c2ecf20Sopenharmony_ci case CPU_P5600: \ 3798c2ecf20Sopenharmony_ci case CPU_M5150: \ 3808c2ecf20Sopenharmony_ci case CPU_QEMU_GENERIC: \ 3818c2ecf20Sopenharmony_ci case CPU_CAVIUM_OCTEON: \ 3828c2ecf20Sopenharmony_ci case CPU_CAVIUM_OCTEON_PLUS: \ 3838c2ecf20Sopenharmony_ci case CPU_CAVIUM_OCTEON2: \ 3848c2ecf20Sopenharmony_ci case CPU_CAVIUM_OCTEON3: \ 3858c2ecf20Sopenharmony_ci __res = 0; \ 3868c2ecf20Sopenharmony_ci break; \ 3878c2ecf20Sopenharmony_ci \ 3888c2ecf20Sopenharmony_ci default: \ 3898c2ecf20Sopenharmony_ci __res = 1; \ 3908c2ecf20Sopenharmony_ci } \ 3918c2ecf20Sopenharmony_ci \ 3928c2ecf20Sopenharmony_ci __res; \ 3938c2ecf20Sopenharmony_ci}) 3948c2ecf20Sopenharmony_ci#endif 3958c2ecf20Sopenharmony_ci 3968c2ecf20Sopenharmony_ci/* 3978c2ecf20Sopenharmony_ci * MIPS32, MIPS64, VR5500, IDT32332, IDT32334 and maybe a few other 3988c2ecf20Sopenharmony_ci * pre-MIPS32/MIPS64 processors have CLO, CLZ. The IDT RC64574 is 64-bit and 3998c2ecf20Sopenharmony_ci * has CLO and CLZ but not DCLO nor DCLZ. For 64-bit kernels 4008c2ecf20Sopenharmony_ci * cpu_has_clo_clz also indicates the availability of DCLO and DCLZ. 4018c2ecf20Sopenharmony_ci */ 4028c2ecf20Sopenharmony_ci#ifndef cpu_has_clo_clz 4038c2ecf20Sopenharmony_ci#define cpu_has_clo_clz cpu_has_mips_r 4048c2ecf20Sopenharmony_ci#endif 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci/* 4078c2ecf20Sopenharmony_ci * MIPS32 R2, MIPS64 R2, Loongson 3A and Octeon have WSBH. 4088c2ecf20Sopenharmony_ci * MIPS64 R2, Loongson 3A and Octeon have WSBH, DSBH and DSHD. 4098c2ecf20Sopenharmony_ci * This indicates the availability of WSBH and in case of 64 bit CPUs also 4108c2ecf20Sopenharmony_ci * DSBH and DSHD. 4118c2ecf20Sopenharmony_ci */ 4128c2ecf20Sopenharmony_ci#ifndef cpu_has_wsbh 4138c2ecf20Sopenharmony_ci#define cpu_has_wsbh cpu_has_mips_r2 4148c2ecf20Sopenharmony_ci#endif 4158c2ecf20Sopenharmony_ci 4168c2ecf20Sopenharmony_ci#ifndef cpu_has_dsp 4178c2ecf20Sopenharmony_ci#define cpu_has_dsp __ase(MIPS_ASE_DSP) 4188c2ecf20Sopenharmony_ci#endif 4198c2ecf20Sopenharmony_ci 4208c2ecf20Sopenharmony_ci#ifndef cpu_has_dsp2 4218c2ecf20Sopenharmony_ci#define cpu_has_dsp2 __ase(MIPS_ASE_DSP2P) 4228c2ecf20Sopenharmony_ci#endif 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_ci#ifndef cpu_has_dsp3 4258c2ecf20Sopenharmony_ci#define cpu_has_dsp3 __ase(MIPS_ASE_DSP3) 4268c2ecf20Sopenharmony_ci#endif 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_ci#ifndef cpu_has_loongson_mmi 4298c2ecf20Sopenharmony_ci#define cpu_has_loongson_mmi __ase(MIPS_ASE_LOONGSON_MMI) 4308c2ecf20Sopenharmony_ci#endif 4318c2ecf20Sopenharmony_ci 4328c2ecf20Sopenharmony_ci#ifndef cpu_has_loongson_cam 4338c2ecf20Sopenharmony_ci#define cpu_has_loongson_cam __ase(MIPS_ASE_LOONGSON_CAM) 4348c2ecf20Sopenharmony_ci#endif 4358c2ecf20Sopenharmony_ci 4368c2ecf20Sopenharmony_ci#ifndef cpu_has_loongson_ext 4378c2ecf20Sopenharmony_ci#define cpu_has_loongson_ext __ase(MIPS_ASE_LOONGSON_EXT) 4388c2ecf20Sopenharmony_ci#endif 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_ci#ifndef cpu_has_loongson_ext2 4418c2ecf20Sopenharmony_ci#define cpu_has_loongson_ext2 __ase(MIPS_ASE_LOONGSON_EXT2) 4428c2ecf20Sopenharmony_ci#endif 4438c2ecf20Sopenharmony_ci 4448c2ecf20Sopenharmony_ci#ifndef cpu_has_mipsmt 4458c2ecf20Sopenharmony_ci#define cpu_has_mipsmt __isa_range_and_ase(2, 6, MIPS_ASE_MIPSMT) 4468c2ecf20Sopenharmony_ci#endif 4478c2ecf20Sopenharmony_ci 4488c2ecf20Sopenharmony_ci#ifndef cpu_has_vp 4498c2ecf20Sopenharmony_ci#define cpu_has_vp __isa_ge_and_opt(6, MIPS_CPU_VP) 4508c2ecf20Sopenharmony_ci#endif 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_ci#ifndef cpu_has_userlocal 4538c2ecf20Sopenharmony_ci#define cpu_has_userlocal __isa_ge_or_opt(6, MIPS_CPU_ULRI) 4548c2ecf20Sopenharmony_ci#endif 4558c2ecf20Sopenharmony_ci 4568c2ecf20Sopenharmony_ci#ifdef CONFIG_32BIT 4578c2ecf20Sopenharmony_ci# ifndef cpu_has_nofpuex 4588c2ecf20Sopenharmony_ci# define cpu_has_nofpuex __isa_lt_and_opt(1, MIPS_CPU_NOFPUEX) 4598c2ecf20Sopenharmony_ci# endif 4608c2ecf20Sopenharmony_ci# ifndef cpu_has_64bits 4618c2ecf20Sopenharmony_ci# define cpu_has_64bits (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT) 4628c2ecf20Sopenharmony_ci# endif 4638c2ecf20Sopenharmony_ci# ifndef cpu_has_64bit_zero_reg 4648c2ecf20Sopenharmony_ci# define cpu_has_64bit_zero_reg (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT) 4658c2ecf20Sopenharmony_ci# endif 4668c2ecf20Sopenharmony_ci# ifndef cpu_has_64bit_gp_regs 4678c2ecf20Sopenharmony_ci# define cpu_has_64bit_gp_regs 0 4688c2ecf20Sopenharmony_ci# endif 4698c2ecf20Sopenharmony_ci# ifndef cpu_vmbits 4708c2ecf20Sopenharmony_ci# define cpu_vmbits 31 4718c2ecf20Sopenharmony_ci# endif 4728c2ecf20Sopenharmony_ci#endif 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT 4758c2ecf20Sopenharmony_ci# ifndef cpu_has_nofpuex 4768c2ecf20Sopenharmony_ci# define cpu_has_nofpuex 0 4778c2ecf20Sopenharmony_ci# endif 4788c2ecf20Sopenharmony_ci# ifndef cpu_has_64bits 4798c2ecf20Sopenharmony_ci# define cpu_has_64bits 1 4808c2ecf20Sopenharmony_ci# endif 4818c2ecf20Sopenharmony_ci# ifndef cpu_has_64bit_zero_reg 4828c2ecf20Sopenharmony_ci# define cpu_has_64bit_zero_reg 1 4838c2ecf20Sopenharmony_ci# endif 4848c2ecf20Sopenharmony_ci# ifndef cpu_has_64bit_gp_regs 4858c2ecf20Sopenharmony_ci# define cpu_has_64bit_gp_regs 1 4868c2ecf20Sopenharmony_ci# endif 4878c2ecf20Sopenharmony_ci# ifndef cpu_vmbits 4888c2ecf20Sopenharmony_ci# define cpu_vmbits cpu_data[0].vmbits 4898c2ecf20Sopenharmony_ci# define __NEED_VMBITS_PROBE 4908c2ecf20Sopenharmony_ci# endif 4918c2ecf20Sopenharmony_ci#endif 4928c2ecf20Sopenharmony_ci 4938c2ecf20Sopenharmony_ci#if defined(CONFIG_CPU_MIPSR2_IRQ_VI) && !defined(cpu_has_vint) 4948c2ecf20Sopenharmony_ci# define cpu_has_vint __opt(MIPS_CPU_VINT) 4958c2ecf20Sopenharmony_ci#elif !defined(cpu_has_vint) 4968c2ecf20Sopenharmony_ci# define cpu_has_vint 0 4978c2ecf20Sopenharmony_ci#endif 4988c2ecf20Sopenharmony_ci 4998c2ecf20Sopenharmony_ci#if defined(CONFIG_CPU_MIPSR2_IRQ_EI) && !defined(cpu_has_veic) 5008c2ecf20Sopenharmony_ci# define cpu_has_veic __opt(MIPS_CPU_VEIC) 5018c2ecf20Sopenharmony_ci#elif !defined(cpu_has_veic) 5028c2ecf20Sopenharmony_ci# define cpu_has_veic 0 5038c2ecf20Sopenharmony_ci#endif 5048c2ecf20Sopenharmony_ci 5058c2ecf20Sopenharmony_ci#ifndef cpu_has_inclusive_pcaches 5068c2ecf20Sopenharmony_ci#define cpu_has_inclusive_pcaches __opt(MIPS_CPU_INCLUSIVE_CACHES) 5078c2ecf20Sopenharmony_ci#endif 5088c2ecf20Sopenharmony_ci 5098c2ecf20Sopenharmony_ci#ifndef cpu_dcache_line_size 5108c2ecf20Sopenharmony_ci#define cpu_dcache_line_size() cpu_data[0].dcache.linesz 5118c2ecf20Sopenharmony_ci#endif 5128c2ecf20Sopenharmony_ci#ifndef cpu_icache_line_size 5138c2ecf20Sopenharmony_ci#define cpu_icache_line_size() cpu_data[0].icache.linesz 5148c2ecf20Sopenharmony_ci#endif 5158c2ecf20Sopenharmony_ci#ifndef cpu_scache_line_size 5168c2ecf20Sopenharmony_ci#define cpu_scache_line_size() cpu_data[0].scache.linesz 5178c2ecf20Sopenharmony_ci#endif 5188c2ecf20Sopenharmony_ci#ifndef cpu_tcache_line_size 5198c2ecf20Sopenharmony_ci#define cpu_tcache_line_size() cpu_data[0].tcache.linesz 5208c2ecf20Sopenharmony_ci#endif 5218c2ecf20Sopenharmony_ci 5228c2ecf20Sopenharmony_ci#ifndef cpu_hwrena_impl_bits 5238c2ecf20Sopenharmony_ci#define cpu_hwrena_impl_bits 0 5248c2ecf20Sopenharmony_ci#endif 5258c2ecf20Sopenharmony_ci 5268c2ecf20Sopenharmony_ci#ifndef cpu_has_perf_cntr_intr_bit 5278c2ecf20Sopenharmony_ci#define cpu_has_perf_cntr_intr_bit __opt(MIPS_CPU_PCI) 5288c2ecf20Sopenharmony_ci#endif 5298c2ecf20Sopenharmony_ci 5308c2ecf20Sopenharmony_ci#ifndef cpu_has_vz 5318c2ecf20Sopenharmony_ci#define cpu_has_vz __ase(MIPS_ASE_VZ) 5328c2ecf20Sopenharmony_ci#endif 5338c2ecf20Sopenharmony_ci 5348c2ecf20Sopenharmony_ci#if defined(CONFIG_CPU_HAS_MSA) && !defined(cpu_has_msa) 5358c2ecf20Sopenharmony_ci# define cpu_has_msa __ase(MIPS_ASE_MSA) 5368c2ecf20Sopenharmony_ci#elif !defined(cpu_has_msa) 5378c2ecf20Sopenharmony_ci# define cpu_has_msa 0 5388c2ecf20Sopenharmony_ci#endif 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_ci#ifndef cpu_has_ufr 5418c2ecf20Sopenharmony_ci# define cpu_has_ufr __opt(MIPS_CPU_UFR) 5428c2ecf20Sopenharmony_ci#endif 5438c2ecf20Sopenharmony_ci 5448c2ecf20Sopenharmony_ci#ifndef cpu_has_fre 5458c2ecf20Sopenharmony_ci# define cpu_has_fre __opt(MIPS_CPU_FRE) 5468c2ecf20Sopenharmony_ci#endif 5478c2ecf20Sopenharmony_ci 5488c2ecf20Sopenharmony_ci#ifndef cpu_has_cdmm 5498c2ecf20Sopenharmony_ci# define cpu_has_cdmm __opt(MIPS_CPU_CDMM) 5508c2ecf20Sopenharmony_ci#endif 5518c2ecf20Sopenharmony_ci 5528c2ecf20Sopenharmony_ci#ifndef cpu_has_small_pages 5538c2ecf20Sopenharmony_ci# define cpu_has_small_pages __opt(MIPS_CPU_SP) 5548c2ecf20Sopenharmony_ci#endif 5558c2ecf20Sopenharmony_ci 5568c2ecf20Sopenharmony_ci#ifndef cpu_has_nan_legacy 5578c2ecf20Sopenharmony_ci#define cpu_has_nan_legacy __isa_lt_and_opt(6, MIPS_CPU_NAN_LEGACY) 5588c2ecf20Sopenharmony_ci#endif 5598c2ecf20Sopenharmony_ci#ifndef cpu_has_nan_2008 5608c2ecf20Sopenharmony_ci#define cpu_has_nan_2008 __isa_ge_or_opt(6, MIPS_CPU_NAN_2008) 5618c2ecf20Sopenharmony_ci#endif 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_ci#ifndef cpu_has_ebase_wg 5648c2ecf20Sopenharmony_ci# define cpu_has_ebase_wg __opt(MIPS_CPU_EBASE_WG) 5658c2ecf20Sopenharmony_ci#endif 5668c2ecf20Sopenharmony_ci 5678c2ecf20Sopenharmony_ci#ifndef cpu_has_badinstr 5688c2ecf20Sopenharmony_ci# define cpu_has_badinstr __isa_ge_or_opt(6, MIPS_CPU_BADINSTR) 5698c2ecf20Sopenharmony_ci#endif 5708c2ecf20Sopenharmony_ci 5718c2ecf20Sopenharmony_ci#ifndef cpu_has_badinstrp 5728c2ecf20Sopenharmony_ci# define cpu_has_badinstrp __isa_ge_or_opt(6, MIPS_CPU_BADINSTRP) 5738c2ecf20Sopenharmony_ci#endif 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_ci#ifndef cpu_has_contextconfig 5768c2ecf20Sopenharmony_ci# define cpu_has_contextconfig __opt(MIPS_CPU_CTXTC) 5778c2ecf20Sopenharmony_ci#endif 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_ci#ifndef cpu_has_perf 5808c2ecf20Sopenharmony_ci# define cpu_has_perf __opt(MIPS_CPU_PERF) 5818c2ecf20Sopenharmony_ci#endif 5828c2ecf20Sopenharmony_ci 5838c2ecf20Sopenharmony_ci#ifndef cpu_has_mac2008_only 5848c2ecf20Sopenharmony_ci# define cpu_has_mac2008_only __opt(MIPS_CPU_MAC_2008_ONLY) 5858c2ecf20Sopenharmony_ci#endif 5868c2ecf20Sopenharmony_ci 5878c2ecf20Sopenharmony_ci#ifndef cpu_has_ftlbparex 5888c2ecf20Sopenharmony_ci# define cpu_has_ftlbparex __opt(MIPS_CPU_FTLBPAREX) 5898c2ecf20Sopenharmony_ci#endif 5908c2ecf20Sopenharmony_ci 5918c2ecf20Sopenharmony_ci#ifndef cpu_has_gsexcex 5928c2ecf20Sopenharmony_ci# define cpu_has_gsexcex __opt(MIPS_CPU_GSEXCEX) 5938c2ecf20Sopenharmony_ci#endif 5948c2ecf20Sopenharmony_ci 5958c2ecf20Sopenharmony_ci#ifdef CONFIG_SMP 5968c2ecf20Sopenharmony_ci/* 5978c2ecf20Sopenharmony_ci * Some systems share FTLB RAMs between threads within a core (siblings in 5988c2ecf20Sopenharmony_ci * kernel parlance). This means that FTLB entries may become invalid at almost 5998c2ecf20Sopenharmony_ci * any point when an entry is evicted due to a sibling thread writing an entry 6008c2ecf20Sopenharmony_ci * to the shared FTLB RAM. 6018c2ecf20Sopenharmony_ci * 6028c2ecf20Sopenharmony_ci * This is only relevant to SMP systems, and the only systems that exhibit this 6038c2ecf20Sopenharmony_ci * property implement MIPSr6 or higher so we constrain support for this to 6048c2ecf20Sopenharmony_ci * kernels that will run on such systems. 6058c2ecf20Sopenharmony_ci */ 6068c2ecf20Sopenharmony_ci# ifndef cpu_has_shared_ftlb_ram 6078c2ecf20Sopenharmony_ci# define cpu_has_shared_ftlb_ram \ 6088c2ecf20Sopenharmony_ci __isa_ge_and_opt(6, MIPS_CPU_SHARED_FTLB_RAM) 6098c2ecf20Sopenharmony_ci# endif 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_ci/* 6128c2ecf20Sopenharmony_ci * Some systems take this a step further & share FTLB entries between siblings. 6138c2ecf20Sopenharmony_ci * This is implemented as TLB writes happening as usual, but if an entry 6148c2ecf20Sopenharmony_ci * written by a sibling exists in the shared FTLB for a translation which would 6158c2ecf20Sopenharmony_ci * otherwise cause a TLB refill exception then the CPU will use the entry 6168c2ecf20Sopenharmony_ci * written by its sibling rather than triggering a refill & writing a matching 6178c2ecf20Sopenharmony_ci * TLB entry for itself. 6188c2ecf20Sopenharmony_ci * 6198c2ecf20Sopenharmony_ci * This is naturally only valid if a TLB entry is known to be suitable for use 6208c2ecf20Sopenharmony_ci * on all siblings in a CPU, and so it only takes effect when MMIDs are in use 6218c2ecf20Sopenharmony_ci * rather than ASIDs or when a TLB entry is marked global. 6228c2ecf20Sopenharmony_ci */ 6238c2ecf20Sopenharmony_ci# ifndef cpu_has_shared_ftlb_entries 6248c2ecf20Sopenharmony_ci# define cpu_has_shared_ftlb_entries \ 6258c2ecf20Sopenharmony_ci __isa_ge_and_opt(6, MIPS_CPU_SHARED_FTLB_ENTRIES) 6268c2ecf20Sopenharmony_ci# endif 6278c2ecf20Sopenharmony_ci#endif /* SMP */ 6288c2ecf20Sopenharmony_ci 6298c2ecf20Sopenharmony_ci#ifndef cpu_has_shared_ftlb_ram 6308c2ecf20Sopenharmony_ci# define cpu_has_shared_ftlb_ram 0 6318c2ecf20Sopenharmony_ci#endif 6328c2ecf20Sopenharmony_ci#ifndef cpu_has_shared_ftlb_entries 6338c2ecf20Sopenharmony_ci# define cpu_has_shared_ftlb_entries 0 6348c2ecf20Sopenharmony_ci#endif 6358c2ecf20Sopenharmony_ci 6368c2ecf20Sopenharmony_ci#ifdef CONFIG_MIPS_MT_SMP 6378c2ecf20Sopenharmony_ci# define cpu_has_mipsmt_pertccounters \ 6388c2ecf20Sopenharmony_ci __isa_lt_and_opt(6, MIPS_CPU_MT_PER_TC_PERF_COUNTERS) 6398c2ecf20Sopenharmony_ci#else 6408c2ecf20Sopenharmony_ci# define cpu_has_mipsmt_pertccounters 0 6418c2ecf20Sopenharmony_ci#endif /* CONFIG_MIPS_MT_SMP */ 6428c2ecf20Sopenharmony_ci 6438c2ecf20Sopenharmony_ci/* 6448c2ecf20Sopenharmony_ci * We only enable MMID support for configurations which natively support 64 bit 6458c2ecf20Sopenharmony_ci * atomics because getting good performance from the allocator relies upon 6468c2ecf20Sopenharmony_ci * efficient atomic64_*() functions. 6478c2ecf20Sopenharmony_ci */ 6488c2ecf20Sopenharmony_ci#ifndef cpu_has_mmid 6498c2ecf20Sopenharmony_ci# ifdef CONFIG_GENERIC_ATOMIC64 6508c2ecf20Sopenharmony_ci# define cpu_has_mmid 0 6518c2ecf20Sopenharmony_ci# else 6528c2ecf20Sopenharmony_ci# define cpu_has_mmid __isa_ge_and_opt(6, MIPS_CPU_MMID) 6538c2ecf20Sopenharmony_ci# endif 6548c2ecf20Sopenharmony_ci#endif 6558c2ecf20Sopenharmony_ci 6568c2ecf20Sopenharmony_ci#ifndef cpu_has_mm_sysad 6578c2ecf20Sopenharmony_ci# define cpu_has_mm_sysad __opt(MIPS_CPU_MM_SYSAD) 6588c2ecf20Sopenharmony_ci#endif 6598c2ecf20Sopenharmony_ci 6608c2ecf20Sopenharmony_ci#ifndef cpu_has_mm_full 6618c2ecf20Sopenharmony_ci# define cpu_has_mm_full __opt(MIPS_CPU_MM_FULL) 6628c2ecf20Sopenharmony_ci#endif 6638c2ecf20Sopenharmony_ci 6648c2ecf20Sopenharmony_ci/* 6658c2ecf20Sopenharmony_ci * Guest capabilities 6668c2ecf20Sopenharmony_ci */ 6678c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_conf1 6688c2ecf20Sopenharmony_ci#define cpu_guest_has_conf1 (cpu_data[0].guest.conf & (1 << 1)) 6698c2ecf20Sopenharmony_ci#endif 6708c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_conf2 6718c2ecf20Sopenharmony_ci#define cpu_guest_has_conf2 (cpu_data[0].guest.conf & (1 << 2)) 6728c2ecf20Sopenharmony_ci#endif 6738c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_conf3 6748c2ecf20Sopenharmony_ci#define cpu_guest_has_conf3 (cpu_data[0].guest.conf & (1 << 3)) 6758c2ecf20Sopenharmony_ci#endif 6768c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_conf4 6778c2ecf20Sopenharmony_ci#define cpu_guest_has_conf4 (cpu_data[0].guest.conf & (1 << 4)) 6788c2ecf20Sopenharmony_ci#endif 6798c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_conf5 6808c2ecf20Sopenharmony_ci#define cpu_guest_has_conf5 (cpu_data[0].guest.conf & (1 << 5)) 6818c2ecf20Sopenharmony_ci#endif 6828c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_conf6 6838c2ecf20Sopenharmony_ci#define cpu_guest_has_conf6 (cpu_data[0].guest.conf & (1 << 6)) 6848c2ecf20Sopenharmony_ci#endif 6858c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_conf7 6868c2ecf20Sopenharmony_ci#define cpu_guest_has_conf7 (cpu_data[0].guest.conf & (1 << 7)) 6878c2ecf20Sopenharmony_ci#endif 6888c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_fpu 6898c2ecf20Sopenharmony_ci#define cpu_guest_has_fpu (cpu_data[0].guest.options & MIPS_CPU_FPU) 6908c2ecf20Sopenharmony_ci#endif 6918c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_watch 6928c2ecf20Sopenharmony_ci#define cpu_guest_has_watch (cpu_data[0].guest.options & MIPS_CPU_WATCH) 6938c2ecf20Sopenharmony_ci#endif 6948c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_contextconfig 6958c2ecf20Sopenharmony_ci#define cpu_guest_has_contextconfig (cpu_data[0].guest.options & MIPS_CPU_CTXTC) 6968c2ecf20Sopenharmony_ci#endif 6978c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_segments 6988c2ecf20Sopenharmony_ci#define cpu_guest_has_segments (cpu_data[0].guest.options & MIPS_CPU_SEGMENTS) 6998c2ecf20Sopenharmony_ci#endif 7008c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_badinstr 7018c2ecf20Sopenharmony_ci#define cpu_guest_has_badinstr (cpu_data[0].guest.options & MIPS_CPU_BADINSTR) 7028c2ecf20Sopenharmony_ci#endif 7038c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_badinstrp 7048c2ecf20Sopenharmony_ci#define cpu_guest_has_badinstrp (cpu_data[0].guest.options & MIPS_CPU_BADINSTRP) 7058c2ecf20Sopenharmony_ci#endif 7068c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_htw 7078c2ecf20Sopenharmony_ci#define cpu_guest_has_htw (cpu_data[0].guest.options & MIPS_CPU_HTW) 7088c2ecf20Sopenharmony_ci#endif 7098c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_ldpte 7108c2ecf20Sopenharmony_ci#define cpu_guest_has_ldpte (cpu_data[0].guest.options & MIPS_CPU_LDPTE) 7118c2ecf20Sopenharmony_ci#endif 7128c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_mvh 7138c2ecf20Sopenharmony_ci#define cpu_guest_has_mvh (cpu_data[0].guest.options & MIPS_CPU_MVH) 7148c2ecf20Sopenharmony_ci#endif 7158c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_msa 7168c2ecf20Sopenharmony_ci#define cpu_guest_has_msa (cpu_data[0].guest.ases & MIPS_ASE_MSA) 7178c2ecf20Sopenharmony_ci#endif 7188c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_kscr 7198c2ecf20Sopenharmony_ci#define cpu_guest_has_kscr(n) (cpu_data[0].guest.kscratch_mask & (1u << (n))) 7208c2ecf20Sopenharmony_ci#endif 7218c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_rw_llb 7228c2ecf20Sopenharmony_ci#define cpu_guest_has_rw_llb (cpu_has_mips_r6 || (cpu_data[0].guest.options & MIPS_CPU_RW_LLB)) 7238c2ecf20Sopenharmony_ci#endif 7248c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_perf 7258c2ecf20Sopenharmony_ci#define cpu_guest_has_perf (cpu_data[0].guest.options & MIPS_CPU_PERF) 7268c2ecf20Sopenharmony_ci#endif 7278c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_maar 7288c2ecf20Sopenharmony_ci#define cpu_guest_has_maar (cpu_data[0].guest.options & MIPS_CPU_MAAR) 7298c2ecf20Sopenharmony_ci#endif 7308c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_userlocal 7318c2ecf20Sopenharmony_ci#define cpu_guest_has_userlocal (cpu_data[0].guest.options & MIPS_CPU_ULRI) 7328c2ecf20Sopenharmony_ci#endif 7338c2ecf20Sopenharmony_ci 7348c2ecf20Sopenharmony_ci/* 7358c2ecf20Sopenharmony_ci * Guest dynamic capabilities 7368c2ecf20Sopenharmony_ci */ 7378c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_dyn_fpu 7388c2ecf20Sopenharmony_ci#define cpu_guest_has_dyn_fpu (cpu_data[0].guest.options_dyn & MIPS_CPU_FPU) 7398c2ecf20Sopenharmony_ci#endif 7408c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_dyn_watch 7418c2ecf20Sopenharmony_ci#define cpu_guest_has_dyn_watch (cpu_data[0].guest.options_dyn & MIPS_CPU_WATCH) 7428c2ecf20Sopenharmony_ci#endif 7438c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_dyn_contextconfig 7448c2ecf20Sopenharmony_ci#define cpu_guest_has_dyn_contextconfig (cpu_data[0].guest.options_dyn & MIPS_CPU_CTXTC) 7458c2ecf20Sopenharmony_ci#endif 7468c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_dyn_perf 7478c2ecf20Sopenharmony_ci#define cpu_guest_has_dyn_perf (cpu_data[0].guest.options_dyn & MIPS_CPU_PERF) 7488c2ecf20Sopenharmony_ci#endif 7498c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_dyn_msa 7508c2ecf20Sopenharmony_ci#define cpu_guest_has_dyn_msa (cpu_data[0].guest.ases_dyn & MIPS_ASE_MSA) 7518c2ecf20Sopenharmony_ci#endif 7528c2ecf20Sopenharmony_ci#ifndef cpu_guest_has_dyn_maar 7538c2ecf20Sopenharmony_ci#define cpu_guest_has_dyn_maar (cpu_data[0].guest.options_dyn & MIPS_CPU_MAAR) 7548c2ecf20Sopenharmony_ci#endif 7558c2ecf20Sopenharmony_ci 7568c2ecf20Sopenharmony_ci#endif /* __ASM_CPU_FEATURES_H */ 757