162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
362306a36Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
462306a36Sopenharmony_ci * for more details.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Copyright (C) 2003, 2004 Ralf Baechle
762306a36Sopenharmony_ci * Copyright (C) 2004  Maciej W. Rozycki
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci#ifndef __ASM_CPU_FEATURES_H
1062306a36Sopenharmony_ci#define __ASM_CPU_FEATURES_H
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#include <asm/cpu.h>
1362306a36Sopenharmony_ci#include <asm/cpu-info.h>
1462306a36Sopenharmony_ci#include <asm/isa-rev.h>
1562306a36Sopenharmony_ci#include <cpu-feature-overrides.h>
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci#define __ase(ase)			(cpu_data[0].ases & (ase))
1862306a36Sopenharmony_ci#define __isa(isa)			(cpu_data[0].isa_level & (isa))
1962306a36Sopenharmony_ci#define __opt(opt)			(cpu_data[0].options & (opt))
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci/*
2262306a36Sopenharmony_ci * Check if MIPS_ISA_REV is >= isa *and* an option or ASE is detected during
2362306a36Sopenharmony_ci * boot (typically by cpu_probe()).
2462306a36Sopenharmony_ci *
2562306a36Sopenharmony_ci * Note that these should only be used in cases where a kernel built for an
2662306a36Sopenharmony_ci * older ISA *cannot* run on a CPU which supports the feature in question. For
2762306a36Sopenharmony_ci * example this may be used for features introduced with MIPSr6, since a kernel
2862306a36Sopenharmony_ci * built for an older ISA cannot run on a MIPSr6 CPU. This should not be used
2962306a36Sopenharmony_ci * for MIPSr2 features however, since a MIPSr1 or earlier kernel might run on a
3062306a36Sopenharmony_ci * MIPSr2 CPU.
3162306a36Sopenharmony_ci */
3262306a36Sopenharmony_ci#define __isa_ge_and_ase(isa, ase)	((MIPS_ISA_REV >= (isa)) && __ase(ase))
3362306a36Sopenharmony_ci#define __isa_ge_and_opt(isa, opt)	((MIPS_ISA_REV >= (isa)) && __opt(opt))
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci/*
3662306a36Sopenharmony_ci * Check if MIPS_ISA_REV is >= isa *or* an option or ASE is detected during
3762306a36Sopenharmony_ci * boot (typically by cpu_probe()).
3862306a36Sopenharmony_ci *
3962306a36Sopenharmony_ci * These are for use with features that are optional up until a particular ISA
4062306a36Sopenharmony_ci * revision & then become required.
4162306a36Sopenharmony_ci */
4262306a36Sopenharmony_ci#define __isa_ge_or_ase(isa, ase)	((MIPS_ISA_REV >= (isa)) || __ase(ase))
4362306a36Sopenharmony_ci#define __isa_ge_or_opt(isa, opt)	((MIPS_ISA_REV >= (isa)) || __opt(opt))
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci/*
4662306a36Sopenharmony_ci * Check if MIPS_ISA_REV is < isa *and* an option or ASE is detected during
4762306a36Sopenharmony_ci * boot (typically by cpu_probe()).
4862306a36Sopenharmony_ci *
4962306a36Sopenharmony_ci * These are for use with features that are optional up until a particular ISA
5062306a36Sopenharmony_ci * revision & are then removed - ie. no longer present in any CPU implementing
5162306a36Sopenharmony_ci * the given ISA revision.
5262306a36Sopenharmony_ci */
5362306a36Sopenharmony_ci#define __isa_lt_and_ase(isa, ase)	((MIPS_ISA_REV < (isa)) && __ase(ase))
5462306a36Sopenharmony_ci#define __isa_lt_and_opt(isa, opt)	((MIPS_ISA_REV < (isa)) && __opt(opt))
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/*
5762306a36Sopenharmony_ci * Similarly allow for ISA level checks that take into account knowledge of the
5862306a36Sopenharmony_ci * ISA targeted by the kernel build, provided by MIPS_ISA_REV.
5962306a36Sopenharmony_ci */
6062306a36Sopenharmony_ci#define __isa_ge_and_flag(isa, flag)	((MIPS_ISA_REV >= (isa)) && __isa(flag))
6162306a36Sopenharmony_ci#define __isa_ge_or_flag(isa, flag)	((MIPS_ISA_REV >= (isa)) || __isa(flag))
6262306a36Sopenharmony_ci#define __isa_lt_and_flag(isa, flag)	((MIPS_ISA_REV < (isa)) && __isa(flag))
6362306a36Sopenharmony_ci#define __isa_range(ge, lt) \
6462306a36Sopenharmony_ci	((MIPS_ISA_REV >= (ge)) && (MIPS_ISA_REV < (lt)))
6562306a36Sopenharmony_ci#define __isa_range_or_flag(ge, lt, flag) \
6662306a36Sopenharmony_ci	(__isa_range(ge, lt) || ((MIPS_ISA_REV < (lt)) && __isa(flag)))
6762306a36Sopenharmony_ci#define __isa_range_and_ase(ge, lt, ase) \
6862306a36Sopenharmony_ci	(__isa_range(ge, lt) && __ase(ase))
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci/*
7162306a36Sopenharmony_ci * SMP assumption: Options of CPU 0 are a superset of all processors.
7262306a36Sopenharmony_ci * This is true for all known MIPS systems.
7362306a36Sopenharmony_ci */
7462306a36Sopenharmony_ci#ifndef cpu_has_tlb
7562306a36Sopenharmony_ci#define cpu_has_tlb		__opt(MIPS_CPU_TLB)
7662306a36Sopenharmony_ci#endif
7762306a36Sopenharmony_ci#ifndef cpu_has_ftlb
7862306a36Sopenharmony_ci#define cpu_has_ftlb		__opt(MIPS_CPU_FTLB)
7962306a36Sopenharmony_ci#endif
8062306a36Sopenharmony_ci#ifndef cpu_has_tlbinv
8162306a36Sopenharmony_ci#define cpu_has_tlbinv		__opt(MIPS_CPU_TLBINV)
8262306a36Sopenharmony_ci#endif
8362306a36Sopenharmony_ci#ifndef cpu_has_segments
8462306a36Sopenharmony_ci#define cpu_has_segments	__opt(MIPS_CPU_SEGMENTS)
8562306a36Sopenharmony_ci#endif
8662306a36Sopenharmony_ci#ifndef cpu_has_eva
8762306a36Sopenharmony_ci#define cpu_has_eva		__opt(MIPS_CPU_EVA)
8862306a36Sopenharmony_ci#endif
8962306a36Sopenharmony_ci#ifndef cpu_has_htw
9062306a36Sopenharmony_ci#define cpu_has_htw		__opt(MIPS_CPU_HTW)
9162306a36Sopenharmony_ci#endif
9262306a36Sopenharmony_ci#ifndef cpu_has_ldpte
9362306a36Sopenharmony_ci#define cpu_has_ldpte		__opt(MIPS_CPU_LDPTE)
9462306a36Sopenharmony_ci#endif
9562306a36Sopenharmony_ci#ifndef cpu_has_rixiex
9662306a36Sopenharmony_ci#define cpu_has_rixiex		__isa_ge_or_opt(6, MIPS_CPU_RIXIEX)
9762306a36Sopenharmony_ci#endif
9862306a36Sopenharmony_ci#ifndef cpu_has_maar
9962306a36Sopenharmony_ci#define cpu_has_maar		__opt(MIPS_CPU_MAAR)
10062306a36Sopenharmony_ci#endif
10162306a36Sopenharmony_ci#ifndef cpu_has_rw_llb
10262306a36Sopenharmony_ci#define cpu_has_rw_llb		__isa_ge_or_opt(6, MIPS_CPU_RW_LLB)
10362306a36Sopenharmony_ci#endif
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci/*
10662306a36Sopenharmony_ci * For the moment we don't consider R6000 and R8000 so we can assume that
10762306a36Sopenharmony_ci * anything that doesn't support R4000-style exceptions and interrupts is
10862306a36Sopenharmony_ci * R3000-like.  Users should still treat these two macro definitions as
10962306a36Sopenharmony_ci * opaque.
11062306a36Sopenharmony_ci */
11162306a36Sopenharmony_ci#ifndef cpu_has_3kex
11262306a36Sopenharmony_ci#define cpu_has_3kex		(!cpu_has_4kex)
11362306a36Sopenharmony_ci#endif
11462306a36Sopenharmony_ci#ifndef cpu_has_4kex
11562306a36Sopenharmony_ci#define cpu_has_4kex		__isa_ge_or_opt(1, MIPS_CPU_4KEX)
11662306a36Sopenharmony_ci#endif
11762306a36Sopenharmony_ci#ifndef cpu_has_3k_cache
11862306a36Sopenharmony_ci#define cpu_has_3k_cache	__isa_lt_and_opt(1, MIPS_CPU_3K_CACHE)
11962306a36Sopenharmony_ci#endif
12062306a36Sopenharmony_ci#ifndef cpu_has_4k_cache
12162306a36Sopenharmony_ci#define cpu_has_4k_cache	__opt(MIPS_CPU_4K_CACHE)
12262306a36Sopenharmony_ci#endif
12362306a36Sopenharmony_ci#ifndef cpu_has_octeon_cache
12462306a36Sopenharmony_ci#define cpu_has_octeon_cache						\
12562306a36Sopenharmony_ci({									\
12662306a36Sopenharmony_ci	int __res;							\
12762306a36Sopenharmony_ci									\
12862306a36Sopenharmony_ci	switch (boot_cpu_type()) {					\
12962306a36Sopenharmony_ci	case CPU_CAVIUM_OCTEON:						\
13062306a36Sopenharmony_ci	case CPU_CAVIUM_OCTEON_PLUS:					\
13162306a36Sopenharmony_ci	case CPU_CAVIUM_OCTEON2:					\
13262306a36Sopenharmony_ci	case CPU_CAVIUM_OCTEON3:					\
13362306a36Sopenharmony_ci		__res = 1;						\
13462306a36Sopenharmony_ci		break;							\
13562306a36Sopenharmony_ci									\
13662306a36Sopenharmony_ci	default:							\
13762306a36Sopenharmony_ci		__res = 0;						\
13862306a36Sopenharmony_ci	}								\
13962306a36Sopenharmony_ci									\
14062306a36Sopenharmony_ci	__res;								\
14162306a36Sopenharmony_ci})
14262306a36Sopenharmony_ci#endif
14362306a36Sopenharmony_ci/* Don't override `cpu_has_fpu' to 1 or the "nofpu" option won't work.  */
14462306a36Sopenharmony_ci#ifndef cpu_has_fpu
14562306a36Sopenharmony_ci# ifdef CONFIG_MIPS_FP_SUPPORT
14662306a36Sopenharmony_ci#  define cpu_has_fpu		(current_cpu_data.options & MIPS_CPU_FPU)
14762306a36Sopenharmony_ci#  define raw_cpu_has_fpu	(raw_current_cpu_data.options & MIPS_CPU_FPU)
14862306a36Sopenharmony_ci# else
14962306a36Sopenharmony_ci#  define cpu_has_fpu		0
15062306a36Sopenharmony_ci#  define raw_cpu_has_fpu	0
15162306a36Sopenharmony_ci# endif
15262306a36Sopenharmony_ci#else
15362306a36Sopenharmony_ci# if cpu_has_fpu
15462306a36Sopenharmony_ci#  error "Forcing `cpu_has_fpu' to non-zero is not supported"
15562306a36Sopenharmony_ci# endif
15662306a36Sopenharmony_ci# define raw_cpu_has_fpu	cpu_has_fpu
15762306a36Sopenharmony_ci#endif
15862306a36Sopenharmony_ci#ifndef cpu_has_32fpr
15962306a36Sopenharmony_ci#define cpu_has_32fpr		__isa_ge_or_opt(1, MIPS_CPU_32FPR)
16062306a36Sopenharmony_ci#endif
16162306a36Sopenharmony_ci#ifndef cpu_has_counter
16262306a36Sopenharmony_ci#define cpu_has_counter		__opt(MIPS_CPU_COUNTER)
16362306a36Sopenharmony_ci#endif
16462306a36Sopenharmony_ci#ifndef cpu_has_watch
16562306a36Sopenharmony_ci#define cpu_has_watch		__opt(MIPS_CPU_WATCH)
16662306a36Sopenharmony_ci#endif
16762306a36Sopenharmony_ci#ifndef cpu_has_divec
16862306a36Sopenharmony_ci#define cpu_has_divec		__isa_ge_or_opt(1, MIPS_CPU_DIVEC)
16962306a36Sopenharmony_ci#endif
17062306a36Sopenharmony_ci#ifndef cpu_has_vce
17162306a36Sopenharmony_ci#define cpu_has_vce		__opt(MIPS_CPU_VCE)
17262306a36Sopenharmony_ci#endif
17362306a36Sopenharmony_ci#ifndef cpu_has_cache_cdex_p
17462306a36Sopenharmony_ci#define cpu_has_cache_cdex_p	__opt(MIPS_CPU_CACHE_CDEX_P)
17562306a36Sopenharmony_ci#endif
17662306a36Sopenharmony_ci#ifndef cpu_has_cache_cdex_s
17762306a36Sopenharmony_ci#define cpu_has_cache_cdex_s	__opt(MIPS_CPU_CACHE_CDEX_S)
17862306a36Sopenharmony_ci#endif
17962306a36Sopenharmony_ci#ifndef cpu_has_prefetch
18062306a36Sopenharmony_ci#define cpu_has_prefetch	__isa_ge_or_opt(1, MIPS_CPU_PREFETCH)
18162306a36Sopenharmony_ci#endif
18262306a36Sopenharmony_ci#ifndef cpu_has_mcheck
18362306a36Sopenharmony_ci#define cpu_has_mcheck		__isa_ge_or_opt(1, MIPS_CPU_MCHECK)
18462306a36Sopenharmony_ci#endif
18562306a36Sopenharmony_ci#ifndef cpu_has_ejtag
18662306a36Sopenharmony_ci#define cpu_has_ejtag		__opt(MIPS_CPU_EJTAG)
18762306a36Sopenharmony_ci#endif
18862306a36Sopenharmony_ci#ifndef cpu_has_llsc
18962306a36Sopenharmony_ci#define cpu_has_llsc		__isa_ge_or_opt(1, MIPS_CPU_LLSC)
19062306a36Sopenharmony_ci#endif
19162306a36Sopenharmony_ci#ifndef kernel_uses_llsc
19262306a36Sopenharmony_ci#define kernel_uses_llsc	cpu_has_llsc
19362306a36Sopenharmony_ci#endif
19462306a36Sopenharmony_ci#ifndef cpu_has_guestctl0ext
19562306a36Sopenharmony_ci#define cpu_has_guestctl0ext	__opt(MIPS_CPU_GUESTCTL0EXT)
19662306a36Sopenharmony_ci#endif
19762306a36Sopenharmony_ci#ifndef cpu_has_guestctl1
19862306a36Sopenharmony_ci#define cpu_has_guestctl1	__opt(MIPS_CPU_GUESTCTL1)
19962306a36Sopenharmony_ci#endif
20062306a36Sopenharmony_ci#ifndef cpu_has_guestctl2
20162306a36Sopenharmony_ci#define cpu_has_guestctl2	__opt(MIPS_CPU_GUESTCTL2)
20262306a36Sopenharmony_ci#endif
20362306a36Sopenharmony_ci#ifndef cpu_has_guestid
20462306a36Sopenharmony_ci#define cpu_has_guestid		__opt(MIPS_CPU_GUESTID)
20562306a36Sopenharmony_ci#endif
20662306a36Sopenharmony_ci#ifndef cpu_has_drg
20762306a36Sopenharmony_ci#define cpu_has_drg		__opt(MIPS_CPU_DRG)
20862306a36Sopenharmony_ci#endif
20962306a36Sopenharmony_ci#ifndef cpu_has_mips16
21062306a36Sopenharmony_ci#define cpu_has_mips16		__isa_lt_and_ase(6, MIPS_ASE_MIPS16)
21162306a36Sopenharmony_ci#endif
21262306a36Sopenharmony_ci#ifndef cpu_has_mips16e2
21362306a36Sopenharmony_ci#define cpu_has_mips16e2	__isa_lt_and_ase(6, MIPS_ASE_MIPS16E2)
21462306a36Sopenharmony_ci#endif
21562306a36Sopenharmony_ci#ifndef cpu_has_mdmx
21662306a36Sopenharmony_ci#define cpu_has_mdmx		__isa_lt_and_ase(6, MIPS_ASE_MDMX)
21762306a36Sopenharmony_ci#endif
21862306a36Sopenharmony_ci#ifndef cpu_has_mips3d
21962306a36Sopenharmony_ci#define cpu_has_mips3d		__isa_lt_and_ase(6, MIPS_ASE_MIPS3D)
22062306a36Sopenharmony_ci#endif
22162306a36Sopenharmony_ci#ifndef cpu_has_smartmips
22262306a36Sopenharmony_ci#define cpu_has_smartmips	__isa_lt_and_ase(6, MIPS_ASE_SMARTMIPS)
22362306a36Sopenharmony_ci#endif
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_ci#ifndef cpu_has_rixi
22662306a36Sopenharmony_ci#define cpu_has_rixi		__isa_ge_or_opt(6, MIPS_CPU_RIXI)
22762306a36Sopenharmony_ci#endif
22862306a36Sopenharmony_ci
22962306a36Sopenharmony_ci#ifndef cpu_has_mmips
23062306a36Sopenharmony_ci# if defined(__mips_micromips)
23162306a36Sopenharmony_ci#  define cpu_has_mmips		1
23262306a36Sopenharmony_ci# elif defined(CONFIG_SYS_SUPPORTS_MICROMIPS)
23362306a36Sopenharmony_ci#  define cpu_has_mmips		__opt(MIPS_CPU_MICROMIPS)
23462306a36Sopenharmony_ci# else
23562306a36Sopenharmony_ci#  define cpu_has_mmips		0
23662306a36Sopenharmony_ci# endif
23762306a36Sopenharmony_ci#endif
23862306a36Sopenharmony_ci
23962306a36Sopenharmony_ci#ifndef cpu_has_lpa
24062306a36Sopenharmony_ci#define cpu_has_lpa		__opt(MIPS_CPU_LPA)
24162306a36Sopenharmony_ci#endif
24262306a36Sopenharmony_ci#ifndef cpu_has_mvh
24362306a36Sopenharmony_ci#define cpu_has_mvh		__opt(MIPS_CPU_MVH)
24462306a36Sopenharmony_ci#endif
24562306a36Sopenharmony_ci#ifndef cpu_has_xpa
24662306a36Sopenharmony_ci#define cpu_has_xpa		(cpu_has_lpa && cpu_has_mvh)
24762306a36Sopenharmony_ci#endif
24862306a36Sopenharmony_ci#ifndef cpu_has_vtag_icache
24962306a36Sopenharmony_ci#define cpu_has_vtag_icache	(cpu_data[0].icache.flags & MIPS_CACHE_VTAG)
25062306a36Sopenharmony_ci#endif
25162306a36Sopenharmony_ci#ifndef cpu_has_dc_aliases
25262306a36Sopenharmony_ci#define cpu_has_dc_aliases	(cpu_data[0].dcache.flags & MIPS_CACHE_ALIASES)
25362306a36Sopenharmony_ci#endif
25462306a36Sopenharmony_ci#ifndef cpu_has_ic_fills_f_dc
25562306a36Sopenharmony_ci#define cpu_has_ic_fills_f_dc	(cpu_data[0].icache.flags & MIPS_CACHE_IC_F_DC)
25662306a36Sopenharmony_ci#endif
25762306a36Sopenharmony_ci#ifndef cpu_has_pindexed_dcache
25862306a36Sopenharmony_ci#define cpu_has_pindexed_dcache	(cpu_data[0].dcache.flags & MIPS_CACHE_PINDEX)
25962306a36Sopenharmony_ci#endif
26062306a36Sopenharmony_ci
26162306a36Sopenharmony_ci/*
26262306a36Sopenharmony_ci * I-Cache snoops remote store.	 This only matters on SMP.  Some multiprocessors
26362306a36Sopenharmony_ci * such as the R10000 have I-Caches that snoop local stores; the embedded ones
26462306a36Sopenharmony_ci * don't.  For maintaining I-cache coherency this means we need to flush the
26562306a36Sopenharmony_ci * D-cache all the way back to whever the I-cache does refills from, so the
26662306a36Sopenharmony_ci * I-cache has a chance to see the new data at all.  Then we have to flush the
26762306a36Sopenharmony_ci * I-cache also.
26862306a36Sopenharmony_ci * Note we may have been rescheduled and may no longer be running on the CPU
26962306a36Sopenharmony_ci * that did the store so we can't optimize this into only doing the flush on
27062306a36Sopenharmony_ci * the local CPU.
27162306a36Sopenharmony_ci */
27262306a36Sopenharmony_ci#ifndef cpu_icache_snoops_remote_store
27362306a36Sopenharmony_ci#ifdef CONFIG_SMP
27462306a36Sopenharmony_ci#define cpu_icache_snoops_remote_store	(cpu_data[0].icache.flags & MIPS_IC_SNOOPS_REMOTE)
27562306a36Sopenharmony_ci#else
27662306a36Sopenharmony_ci#define cpu_icache_snoops_remote_store	1
27762306a36Sopenharmony_ci#endif
27862306a36Sopenharmony_ci#endif
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ci#ifndef cpu_has_mips_1
28162306a36Sopenharmony_ci# define cpu_has_mips_1		(MIPS_ISA_REV < 6)
28262306a36Sopenharmony_ci#endif
28362306a36Sopenharmony_ci#ifndef cpu_has_mips_2
28462306a36Sopenharmony_ci# define cpu_has_mips_2		__isa_lt_and_flag(6, MIPS_CPU_ISA_II)
28562306a36Sopenharmony_ci#endif
28662306a36Sopenharmony_ci#ifndef cpu_has_mips_3
28762306a36Sopenharmony_ci# define cpu_has_mips_3		__isa_lt_and_flag(6, MIPS_CPU_ISA_III)
28862306a36Sopenharmony_ci#endif
28962306a36Sopenharmony_ci#ifndef cpu_has_mips_4
29062306a36Sopenharmony_ci# define cpu_has_mips_4		__isa_lt_and_flag(6, MIPS_CPU_ISA_IV)
29162306a36Sopenharmony_ci#endif
29262306a36Sopenharmony_ci#ifndef cpu_has_mips_5
29362306a36Sopenharmony_ci# define cpu_has_mips_5		__isa_lt_and_flag(6, MIPS_CPU_ISA_V)
29462306a36Sopenharmony_ci#endif
29562306a36Sopenharmony_ci#ifndef cpu_has_mips32r1
29662306a36Sopenharmony_ci# define cpu_has_mips32r1	__isa_range_or_flag(1, 6, MIPS_CPU_ISA_M32R1)
29762306a36Sopenharmony_ci#endif
29862306a36Sopenharmony_ci#ifndef cpu_has_mips32r2
29962306a36Sopenharmony_ci# define cpu_has_mips32r2	__isa_range_or_flag(2, 6, MIPS_CPU_ISA_M32R2)
30062306a36Sopenharmony_ci#endif
30162306a36Sopenharmony_ci#ifndef cpu_has_mips32r5
30262306a36Sopenharmony_ci# define cpu_has_mips32r5	__isa_range_or_flag(5, 6, MIPS_CPU_ISA_M32R5)
30362306a36Sopenharmony_ci#endif
30462306a36Sopenharmony_ci#ifndef cpu_has_mips32r6
30562306a36Sopenharmony_ci# define cpu_has_mips32r6	__isa_ge_or_flag(6, MIPS_CPU_ISA_M32R6)
30662306a36Sopenharmony_ci#endif
30762306a36Sopenharmony_ci#ifndef cpu_has_mips64r1
30862306a36Sopenharmony_ci# define cpu_has_mips64r1	(cpu_has_64bits && \
30962306a36Sopenharmony_ci				 __isa_range_or_flag(1, 6, MIPS_CPU_ISA_M64R1))
31062306a36Sopenharmony_ci#endif
31162306a36Sopenharmony_ci#ifndef cpu_has_mips64r2
31262306a36Sopenharmony_ci# define cpu_has_mips64r2	(cpu_has_64bits && \
31362306a36Sopenharmony_ci				 __isa_range_or_flag(2, 6, MIPS_CPU_ISA_M64R2))
31462306a36Sopenharmony_ci#endif
31562306a36Sopenharmony_ci#ifndef cpu_has_mips64r5
31662306a36Sopenharmony_ci# define cpu_has_mips64r5	(cpu_has_64bits && \
31762306a36Sopenharmony_ci				 __isa_range_or_flag(5, 6, MIPS_CPU_ISA_M64R5))
31862306a36Sopenharmony_ci#endif
31962306a36Sopenharmony_ci#ifndef cpu_has_mips64r6
32062306a36Sopenharmony_ci# define cpu_has_mips64r6	__isa_ge_and_flag(6, MIPS_CPU_ISA_M64R6)
32162306a36Sopenharmony_ci#endif
32262306a36Sopenharmony_ci
32362306a36Sopenharmony_ci/*
32462306a36Sopenharmony_ci * Shortcuts ...
32562306a36Sopenharmony_ci */
32662306a36Sopenharmony_ci#define cpu_has_mips_2_3_4_5	(cpu_has_mips_2 | cpu_has_mips_3_4_5)
32762306a36Sopenharmony_ci#define cpu_has_mips_3_4_5	(cpu_has_mips_3 | cpu_has_mips_4_5)
32862306a36Sopenharmony_ci#define cpu_has_mips_4_5	(cpu_has_mips_4 | cpu_has_mips_5)
32962306a36Sopenharmony_ci
33062306a36Sopenharmony_ci#define cpu_has_mips_2_3_4_5_r	(cpu_has_mips_2 | cpu_has_mips_3_4_5_r)
33162306a36Sopenharmony_ci#define cpu_has_mips_3_4_5_r	(cpu_has_mips_3 | cpu_has_mips_4_5_r)
33262306a36Sopenharmony_ci#define cpu_has_mips_4_5_r	(cpu_has_mips_4 | cpu_has_mips_5_r)
33362306a36Sopenharmony_ci#define cpu_has_mips_5_r	(cpu_has_mips_5 | cpu_has_mips_r)
33462306a36Sopenharmony_ci
33562306a36Sopenharmony_ci#define cpu_has_mips_3_4_5_64_r2_r6					\
33662306a36Sopenharmony_ci				(cpu_has_mips_3 | cpu_has_mips_4_5_64_r2_r6)
33762306a36Sopenharmony_ci#define cpu_has_mips_4_5_64_r2_r6					\
33862306a36Sopenharmony_ci				(cpu_has_mips_4_5 | cpu_has_mips64r1 |	\
33962306a36Sopenharmony_ci				 cpu_has_mips_r2 | cpu_has_mips_r5 | \
34062306a36Sopenharmony_ci				 cpu_has_mips_r6)
34162306a36Sopenharmony_ci
34262306a36Sopenharmony_ci#define cpu_has_mips32	(cpu_has_mips32r1 | cpu_has_mips32r2 | \
34362306a36Sopenharmony_ci			 cpu_has_mips32r5 | cpu_has_mips32r6)
34462306a36Sopenharmony_ci#define cpu_has_mips64	(cpu_has_mips64r1 | cpu_has_mips64r2 | \
34562306a36Sopenharmony_ci			 cpu_has_mips64r5 | cpu_has_mips64r6)
34662306a36Sopenharmony_ci#define cpu_has_mips_r1 (cpu_has_mips32r1 | cpu_has_mips64r1)
34762306a36Sopenharmony_ci#define cpu_has_mips_r2 (cpu_has_mips32r2 | cpu_has_mips64r2)
34862306a36Sopenharmony_ci#define cpu_has_mips_r5	(cpu_has_mips32r5 | cpu_has_mips64r5)
34962306a36Sopenharmony_ci#define cpu_has_mips_r6	(cpu_has_mips32r6 | cpu_has_mips64r6)
35062306a36Sopenharmony_ci#define cpu_has_mips_r	(cpu_has_mips32r1 | cpu_has_mips32r2 | \
35162306a36Sopenharmony_ci			 cpu_has_mips32r5 | cpu_has_mips32r6 | \
35262306a36Sopenharmony_ci			 cpu_has_mips64r1 | cpu_has_mips64r2 | \
35362306a36Sopenharmony_ci			 cpu_has_mips64r5 | cpu_has_mips64r6)
35462306a36Sopenharmony_ci
35562306a36Sopenharmony_ci/* MIPSR2 - MIPSR6 have a lot of similarities */
35662306a36Sopenharmony_ci#define cpu_has_mips_r2_r6	(cpu_has_mips_r2 | cpu_has_mips_r5 | \
35762306a36Sopenharmony_ci				 cpu_has_mips_r6)
35862306a36Sopenharmony_ci
35962306a36Sopenharmony_ci/*
36062306a36Sopenharmony_ci * cpu_has_mips_r2_exec_hazard - return if IHB is required on current processor
36162306a36Sopenharmony_ci *
36262306a36Sopenharmony_ci * Returns non-zero value if the current processor implementation requires
36362306a36Sopenharmony_ci * an IHB instruction to deal with an instruction hazard as per MIPS R2
36462306a36Sopenharmony_ci * architecture specification, zero otherwise.
36562306a36Sopenharmony_ci */
36662306a36Sopenharmony_ci#ifndef cpu_has_mips_r2_exec_hazard
36762306a36Sopenharmony_ci#define cpu_has_mips_r2_exec_hazard					\
36862306a36Sopenharmony_ci({									\
36962306a36Sopenharmony_ci	int __res;							\
37062306a36Sopenharmony_ci									\
37162306a36Sopenharmony_ci	switch (boot_cpu_type()) {					\
37262306a36Sopenharmony_ci	case CPU_M14KC:							\
37362306a36Sopenharmony_ci	case CPU_74K:							\
37462306a36Sopenharmony_ci	case CPU_1074K:							\
37562306a36Sopenharmony_ci	case CPU_PROAPTIV:						\
37662306a36Sopenharmony_ci	case CPU_P5600:							\
37762306a36Sopenharmony_ci	case CPU_M5150:							\
37862306a36Sopenharmony_ci	case CPU_QEMU_GENERIC:						\
37962306a36Sopenharmony_ci	case CPU_CAVIUM_OCTEON:						\
38062306a36Sopenharmony_ci	case CPU_CAVIUM_OCTEON_PLUS:					\
38162306a36Sopenharmony_ci	case CPU_CAVIUM_OCTEON2:					\
38262306a36Sopenharmony_ci	case CPU_CAVIUM_OCTEON3:					\
38362306a36Sopenharmony_ci		__res = 0;						\
38462306a36Sopenharmony_ci		break;							\
38562306a36Sopenharmony_ci									\
38662306a36Sopenharmony_ci	default:							\
38762306a36Sopenharmony_ci		__res = 1;						\
38862306a36Sopenharmony_ci	}								\
38962306a36Sopenharmony_ci									\
39062306a36Sopenharmony_ci	__res;								\
39162306a36Sopenharmony_ci})
39262306a36Sopenharmony_ci#endif
39362306a36Sopenharmony_ci
39462306a36Sopenharmony_ci/*
39562306a36Sopenharmony_ci * MIPS32, MIPS64, VR5500, IDT32332, IDT32334 and maybe a few other
39662306a36Sopenharmony_ci * pre-MIPS32/MIPS64 processors have CLO, CLZ.	The IDT RC64574 is 64-bit and
39762306a36Sopenharmony_ci * has CLO and CLZ but not DCLO nor DCLZ.  For 64-bit kernels
39862306a36Sopenharmony_ci * cpu_has_clo_clz also indicates the availability of DCLO and DCLZ.
39962306a36Sopenharmony_ci */
40062306a36Sopenharmony_ci#ifndef cpu_has_clo_clz
40162306a36Sopenharmony_ci#define cpu_has_clo_clz	cpu_has_mips_r
40262306a36Sopenharmony_ci#endif
40362306a36Sopenharmony_ci
40462306a36Sopenharmony_ci/*
40562306a36Sopenharmony_ci * MIPS32 R2, MIPS64 R2, Loongson 3A and Octeon have WSBH.
40662306a36Sopenharmony_ci * MIPS64 R2, Loongson 3A and Octeon have WSBH, DSBH and DSHD.
40762306a36Sopenharmony_ci * This indicates the availability of WSBH and in case of 64 bit CPUs also
40862306a36Sopenharmony_ci * DSBH and DSHD.
40962306a36Sopenharmony_ci */
41062306a36Sopenharmony_ci#ifndef cpu_has_wsbh
41162306a36Sopenharmony_ci#define cpu_has_wsbh		cpu_has_mips_r2
41262306a36Sopenharmony_ci#endif
41362306a36Sopenharmony_ci
41462306a36Sopenharmony_ci#ifndef cpu_has_dsp
41562306a36Sopenharmony_ci#define cpu_has_dsp		__ase(MIPS_ASE_DSP)
41662306a36Sopenharmony_ci#endif
41762306a36Sopenharmony_ci
41862306a36Sopenharmony_ci#ifndef cpu_has_dsp2
41962306a36Sopenharmony_ci#define cpu_has_dsp2		__ase(MIPS_ASE_DSP2P)
42062306a36Sopenharmony_ci#endif
42162306a36Sopenharmony_ci
42262306a36Sopenharmony_ci#ifndef cpu_has_dsp3
42362306a36Sopenharmony_ci#define cpu_has_dsp3		__ase(MIPS_ASE_DSP3)
42462306a36Sopenharmony_ci#endif
42562306a36Sopenharmony_ci
42662306a36Sopenharmony_ci#ifndef cpu_has_loongson_mmi
42762306a36Sopenharmony_ci#define cpu_has_loongson_mmi		__ase(MIPS_ASE_LOONGSON_MMI)
42862306a36Sopenharmony_ci#endif
42962306a36Sopenharmony_ci
43062306a36Sopenharmony_ci#ifndef cpu_has_loongson_cam
43162306a36Sopenharmony_ci#define cpu_has_loongson_cam		__ase(MIPS_ASE_LOONGSON_CAM)
43262306a36Sopenharmony_ci#endif
43362306a36Sopenharmony_ci
43462306a36Sopenharmony_ci#ifndef cpu_has_loongson_ext
43562306a36Sopenharmony_ci#define cpu_has_loongson_ext		__ase(MIPS_ASE_LOONGSON_EXT)
43662306a36Sopenharmony_ci#endif
43762306a36Sopenharmony_ci
43862306a36Sopenharmony_ci#ifndef cpu_has_loongson_ext2
43962306a36Sopenharmony_ci#define cpu_has_loongson_ext2		__ase(MIPS_ASE_LOONGSON_EXT2)
44062306a36Sopenharmony_ci#endif
44162306a36Sopenharmony_ci
44262306a36Sopenharmony_ci#ifndef cpu_has_mipsmt
44362306a36Sopenharmony_ci#define cpu_has_mipsmt		__isa_range_and_ase(2, 6, MIPS_ASE_MIPSMT)
44462306a36Sopenharmony_ci#endif
44562306a36Sopenharmony_ci
44662306a36Sopenharmony_ci#ifndef cpu_has_vp
44762306a36Sopenharmony_ci#define cpu_has_vp		__isa_ge_and_opt(6, MIPS_CPU_VP)
44862306a36Sopenharmony_ci#endif
44962306a36Sopenharmony_ci
45062306a36Sopenharmony_ci#ifndef cpu_has_userlocal
45162306a36Sopenharmony_ci#define cpu_has_userlocal	__isa_ge_or_opt(6, MIPS_CPU_ULRI)
45262306a36Sopenharmony_ci#endif
45362306a36Sopenharmony_ci
45462306a36Sopenharmony_ci#ifdef CONFIG_32BIT
45562306a36Sopenharmony_ci# ifndef cpu_has_nofpuex
45662306a36Sopenharmony_ci# define cpu_has_nofpuex	__isa_lt_and_opt(1, MIPS_CPU_NOFPUEX)
45762306a36Sopenharmony_ci# endif
45862306a36Sopenharmony_ci# ifndef cpu_has_64bits
45962306a36Sopenharmony_ci# define cpu_has_64bits		(cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
46062306a36Sopenharmony_ci# endif
46162306a36Sopenharmony_ci# ifndef cpu_has_64bit_zero_reg
46262306a36Sopenharmony_ci# define cpu_has_64bit_zero_reg	(cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
46362306a36Sopenharmony_ci# endif
46462306a36Sopenharmony_ci# ifndef cpu_has_64bit_gp_regs
46562306a36Sopenharmony_ci# define cpu_has_64bit_gp_regs		0
46662306a36Sopenharmony_ci# endif
46762306a36Sopenharmony_ci# ifndef cpu_vmbits
46862306a36Sopenharmony_ci# define cpu_vmbits 31
46962306a36Sopenharmony_ci# endif
47062306a36Sopenharmony_ci#endif
47162306a36Sopenharmony_ci
47262306a36Sopenharmony_ci#ifdef CONFIG_64BIT
47362306a36Sopenharmony_ci# ifndef cpu_has_nofpuex
47462306a36Sopenharmony_ci# define cpu_has_nofpuex		0
47562306a36Sopenharmony_ci# endif
47662306a36Sopenharmony_ci# ifndef cpu_has_64bits
47762306a36Sopenharmony_ci# define cpu_has_64bits			1
47862306a36Sopenharmony_ci# endif
47962306a36Sopenharmony_ci# ifndef cpu_has_64bit_zero_reg
48062306a36Sopenharmony_ci# define cpu_has_64bit_zero_reg		1
48162306a36Sopenharmony_ci# endif
48262306a36Sopenharmony_ci# ifndef cpu_has_64bit_gp_regs
48362306a36Sopenharmony_ci# define cpu_has_64bit_gp_regs		1
48462306a36Sopenharmony_ci# endif
48562306a36Sopenharmony_ci# ifndef cpu_vmbits
48662306a36Sopenharmony_ci# define cpu_vmbits cpu_data[0].vmbits
48762306a36Sopenharmony_ci# define __NEED_VMBITS_PROBE
48862306a36Sopenharmony_ci# endif
48962306a36Sopenharmony_ci#endif
49062306a36Sopenharmony_ci
49162306a36Sopenharmony_ci#if defined(CONFIG_CPU_MIPSR2_IRQ_VI) && !defined(cpu_has_vint)
49262306a36Sopenharmony_ci# define cpu_has_vint		__opt(MIPS_CPU_VINT)
49362306a36Sopenharmony_ci#elif !defined(cpu_has_vint)
49462306a36Sopenharmony_ci# define cpu_has_vint			0
49562306a36Sopenharmony_ci#endif
49662306a36Sopenharmony_ci
49762306a36Sopenharmony_ci#if defined(CONFIG_CPU_MIPSR2_IRQ_EI) && !defined(cpu_has_veic)
49862306a36Sopenharmony_ci# define cpu_has_veic		__opt(MIPS_CPU_VEIC)
49962306a36Sopenharmony_ci#elif !defined(cpu_has_veic)
50062306a36Sopenharmony_ci# define cpu_has_veic			0
50162306a36Sopenharmony_ci#endif
50262306a36Sopenharmony_ci
50362306a36Sopenharmony_ci#ifndef cpu_has_inclusive_pcaches
50462306a36Sopenharmony_ci#define cpu_has_inclusive_pcaches	__opt(MIPS_CPU_INCLUSIVE_CACHES)
50562306a36Sopenharmony_ci#endif
50662306a36Sopenharmony_ci
50762306a36Sopenharmony_ci#ifndef cpu_dcache_line_size
50862306a36Sopenharmony_ci#define cpu_dcache_line_size()	cpu_data[0].dcache.linesz
50962306a36Sopenharmony_ci#endif
51062306a36Sopenharmony_ci#ifndef cpu_icache_line_size
51162306a36Sopenharmony_ci#define cpu_icache_line_size()	cpu_data[0].icache.linesz
51262306a36Sopenharmony_ci#endif
51362306a36Sopenharmony_ci#ifndef cpu_scache_line_size
51462306a36Sopenharmony_ci#define cpu_scache_line_size()	cpu_data[0].scache.linesz
51562306a36Sopenharmony_ci#endif
51662306a36Sopenharmony_ci#ifndef cpu_tcache_line_size
51762306a36Sopenharmony_ci#define cpu_tcache_line_size()	cpu_data[0].tcache.linesz
51862306a36Sopenharmony_ci#endif
51962306a36Sopenharmony_ci
52062306a36Sopenharmony_ci#ifndef cpu_hwrena_impl_bits
52162306a36Sopenharmony_ci#define cpu_hwrena_impl_bits		0
52262306a36Sopenharmony_ci#endif
52362306a36Sopenharmony_ci
52462306a36Sopenharmony_ci#ifndef cpu_has_perf_cntr_intr_bit
52562306a36Sopenharmony_ci#define cpu_has_perf_cntr_intr_bit	__opt(MIPS_CPU_PCI)
52662306a36Sopenharmony_ci#endif
52762306a36Sopenharmony_ci
52862306a36Sopenharmony_ci#ifndef cpu_has_vz
52962306a36Sopenharmony_ci#define cpu_has_vz		__ase(MIPS_ASE_VZ)
53062306a36Sopenharmony_ci#endif
53162306a36Sopenharmony_ci
53262306a36Sopenharmony_ci#if defined(CONFIG_CPU_HAS_MSA) && !defined(cpu_has_msa)
53362306a36Sopenharmony_ci# define cpu_has_msa		__ase(MIPS_ASE_MSA)
53462306a36Sopenharmony_ci#elif !defined(cpu_has_msa)
53562306a36Sopenharmony_ci# define cpu_has_msa		0
53662306a36Sopenharmony_ci#endif
53762306a36Sopenharmony_ci
53862306a36Sopenharmony_ci#ifndef cpu_has_ufr
53962306a36Sopenharmony_ci# define cpu_has_ufr		__opt(MIPS_CPU_UFR)
54062306a36Sopenharmony_ci#endif
54162306a36Sopenharmony_ci
54262306a36Sopenharmony_ci#ifndef cpu_has_fre
54362306a36Sopenharmony_ci# define cpu_has_fre		__opt(MIPS_CPU_FRE)
54462306a36Sopenharmony_ci#endif
54562306a36Sopenharmony_ci
54662306a36Sopenharmony_ci#ifndef cpu_has_cdmm
54762306a36Sopenharmony_ci# define cpu_has_cdmm		__opt(MIPS_CPU_CDMM)
54862306a36Sopenharmony_ci#endif
54962306a36Sopenharmony_ci
55062306a36Sopenharmony_ci#ifndef cpu_has_small_pages
55162306a36Sopenharmony_ci# define cpu_has_small_pages	__opt(MIPS_CPU_SP)
55262306a36Sopenharmony_ci#endif
55362306a36Sopenharmony_ci
55462306a36Sopenharmony_ci#ifndef cpu_has_nan_legacy
55562306a36Sopenharmony_ci#define cpu_has_nan_legacy	__isa_lt_and_opt(6, MIPS_CPU_NAN_LEGACY)
55662306a36Sopenharmony_ci#endif
55762306a36Sopenharmony_ci#ifndef cpu_has_nan_2008
55862306a36Sopenharmony_ci#define cpu_has_nan_2008	__isa_ge_or_opt(6, MIPS_CPU_NAN_2008)
55962306a36Sopenharmony_ci#endif
56062306a36Sopenharmony_ci
56162306a36Sopenharmony_ci#ifndef cpu_has_ebase_wg
56262306a36Sopenharmony_ci# define cpu_has_ebase_wg	__opt(MIPS_CPU_EBASE_WG)
56362306a36Sopenharmony_ci#endif
56462306a36Sopenharmony_ci
56562306a36Sopenharmony_ci#ifndef cpu_has_badinstr
56662306a36Sopenharmony_ci# define cpu_has_badinstr	__isa_ge_or_opt(6, MIPS_CPU_BADINSTR)
56762306a36Sopenharmony_ci#endif
56862306a36Sopenharmony_ci
56962306a36Sopenharmony_ci#ifndef cpu_has_badinstrp
57062306a36Sopenharmony_ci# define cpu_has_badinstrp	__isa_ge_or_opt(6, MIPS_CPU_BADINSTRP)
57162306a36Sopenharmony_ci#endif
57262306a36Sopenharmony_ci
57362306a36Sopenharmony_ci#ifndef cpu_has_contextconfig
57462306a36Sopenharmony_ci# define cpu_has_contextconfig	__opt(MIPS_CPU_CTXTC)
57562306a36Sopenharmony_ci#endif
57662306a36Sopenharmony_ci
57762306a36Sopenharmony_ci#ifndef cpu_has_perf
57862306a36Sopenharmony_ci# define cpu_has_perf		__opt(MIPS_CPU_PERF)
57962306a36Sopenharmony_ci#endif
58062306a36Sopenharmony_ci
58162306a36Sopenharmony_ci#ifndef cpu_has_mac2008_only
58262306a36Sopenharmony_ci# define cpu_has_mac2008_only	__opt(MIPS_CPU_MAC_2008_ONLY)
58362306a36Sopenharmony_ci#endif
58462306a36Sopenharmony_ci
58562306a36Sopenharmony_ci#ifndef cpu_has_ftlbparex
58662306a36Sopenharmony_ci# define cpu_has_ftlbparex	__opt(MIPS_CPU_FTLBPAREX)
58762306a36Sopenharmony_ci#endif
58862306a36Sopenharmony_ci
58962306a36Sopenharmony_ci#ifndef cpu_has_gsexcex
59062306a36Sopenharmony_ci# define cpu_has_gsexcex	__opt(MIPS_CPU_GSEXCEX)
59162306a36Sopenharmony_ci#endif
59262306a36Sopenharmony_ci
59362306a36Sopenharmony_ci#ifdef CONFIG_SMP
59462306a36Sopenharmony_ci/*
59562306a36Sopenharmony_ci * Some systems share FTLB RAMs between threads within a core (siblings in
59662306a36Sopenharmony_ci * kernel parlance). This means that FTLB entries may become invalid at almost
59762306a36Sopenharmony_ci * any point when an entry is evicted due to a sibling thread writing an entry
59862306a36Sopenharmony_ci * to the shared FTLB RAM.
59962306a36Sopenharmony_ci *
60062306a36Sopenharmony_ci * This is only relevant to SMP systems, and the only systems that exhibit this
60162306a36Sopenharmony_ci * property implement MIPSr6 or higher so we constrain support for this to
60262306a36Sopenharmony_ci * kernels that will run on such systems.
60362306a36Sopenharmony_ci */
60462306a36Sopenharmony_ci# ifndef cpu_has_shared_ftlb_ram
60562306a36Sopenharmony_ci#  define cpu_has_shared_ftlb_ram \
60662306a36Sopenharmony_ci	__isa_ge_and_opt(6, MIPS_CPU_SHARED_FTLB_RAM)
60762306a36Sopenharmony_ci# endif
60862306a36Sopenharmony_ci
60962306a36Sopenharmony_ci/*
61062306a36Sopenharmony_ci * Some systems take this a step further & share FTLB entries between siblings.
61162306a36Sopenharmony_ci * This is implemented as TLB writes happening as usual, but if an entry
61262306a36Sopenharmony_ci * written by a sibling exists in the shared FTLB for a translation which would
61362306a36Sopenharmony_ci * otherwise cause a TLB refill exception then the CPU will use the entry
61462306a36Sopenharmony_ci * written by its sibling rather than triggering a refill & writing a matching
61562306a36Sopenharmony_ci * TLB entry for itself.
61662306a36Sopenharmony_ci *
61762306a36Sopenharmony_ci * This is naturally only valid if a TLB entry is known to be suitable for use
61862306a36Sopenharmony_ci * on all siblings in a CPU, and so it only takes effect when MMIDs are in use
61962306a36Sopenharmony_ci * rather than ASIDs or when a TLB entry is marked global.
62062306a36Sopenharmony_ci */
62162306a36Sopenharmony_ci# ifndef cpu_has_shared_ftlb_entries
62262306a36Sopenharmony_ci#  define cpu_has_shared_ftlb_entries \
62362306a36Sopenharmony_ci	__isa_ge_and_opt(6, MIPS_CPU_SHARED_FTLB_ENTRIES)
62462306a36Sopenharmony_ci# endif
62562306a36Sopenharmony_ci#endif /* SMP */
62662306a36Sopenharmony_ci
62762306a36Sopenharmony_ci#ifndef cpu_has_shared_ftlb_ram
62862306a36Sopenharmony_ci# define cpu_has_shared_ftlb_ram 0
62962306a36Sopenharmony_ci#endif
63062306a36Sopenharmony_ci#ifndef cpu_has_shared_ftlb_entries
63162306a36Sopenharmony_ci# define cpu_has_shared_ftlb_entries 0
63262306a36Sopenharmony_ci#endif
63362306a36Sopenharmony_ci
63462306a36Sopenharmony_ci#ifdef CONFIG_MIPS_MT_SMP
63562306a36Sopenharmony_ci# define cpu_has_mipsmt_pertccounters \
63662306a36Sopenharmony_ci	__isa_lt_and_opt(6, MIPS_CPU_MT_PER_TC_PERF_COUNTERS)
63762306a36Sopenharmony_ci#else
63862306a36Sopenharmony_ci# define cpu_has_mipsmt_pertccounters 0
63962306a36Sopenharmony_ci#endif /* CONFIG_MIPS_MT_SMP */
64062306a36Sopenharmony_ci
64162306a36Sopenharmony_ci/*
64262306a36Sopenharmony_ci * We only enable MMID support for configurations which natively support 64 bit
64362306a36Sopenharmony_ci * atomics because getting good performance from the allocator relies upon
64462306a36Sopenharmony_ci * efficient atomic64_*() functions.
64562306a36Sopenharmony_ci */
64662306a36Sopenharmony_ci#ifndef cpu_has_mmid
64762306a36Sopenharmony_ci# ifdef CONFIG_GENERIC_ATOMIC64
64862306a36Sopenharmony_ci#  define cpu_has_mmid		0
64962306a36Sopenharmony_ci# else
65062306a36Sopenharmony_ci#  define cpu_has_mmid		__isa_ge_and_opt(6, MIPS_CPU_MMID)
65162306a36Sopenharmony_ci# endif
65262306a36Sopenharmony_ci#endif
65362306a36Sopenharmony_ci
65462306a36Sopenharmony_ci#ifndef cpu_has_mm_sysad
65562306a36Sopenharmony_ci# define cpu_has_mm_sysad	__opt(MIPS_CPU_MM_SYSAD)
65662306a36Sopenharmony_ci#endif
65762306a36Sopenharmony_ci
65862306a36Sopenharmony_ci#ifndef cpu_has_mm_full
65962306a36Sopenharmony_ci# define cpu_has_mm_full	__opt(MIPS_CPU_MM_FULL)
66062306a36Sopenharmony_ci#endif
66162306a36Sopenharmony_ci
66262306a36Sopenharmony_ci/*
66362306a36Sopenharmony_ci * Guest capabilities
66462306a36Sopenharmony_ci */
66562306a36Sopenharmony_ci#ifndef cpu_guest_has_conf1
66662306a36Sopenharmony_ci#define cpu_guest_has_conf1	(cpu_data[0].guest.conf & (1 << 1))
66762306a36Sopenharmony_ci#endif
66862306a36Sopenharmony_ci#ifndef cpu_guest_has_conf2
66962306a36Sopenharmony_ci#define cpu_guest_has_conf2	(cpu_data[0].guest.conf & (1 << 2))
67062306a36Sopenharmony_ci#endif
67162306a36Sopenharmony_ci#ifndef cpu_guest_has_conf3
67262306a36Sopenharmony_ci#define cpu_guest_has_conf3	(cpu_data[0].guest.conf & (1 << 3))
67362306a36Sopenharmony_ci#endif
67462306a36Sopenharmony_ci#ifndef cpu_guest_has_conf4
67562306a36Sopenharmony_ci#define cpu_guest_has_conf4	(cpu_data[0].guest.conf & (1 << 4))
67662306a36Sopenharmony_ci#endif
67762306a36Sopenharmony_ci#ifndef cpu_guest_has_conf5
67862306a36Sopenharmony_ci#define cpu_guest_has_conf5	(cpu_data[0].guest.conf & (1 << 5))
67962306a36Sopenharmony_ci#endif
68062306a36Sopenharmony_ci#ifndef cpu_guest_has_conf6
68162306a36Sopenharmony_ci#define cpu_guest_has_conf6	(cpu_data[0].guest.conf & (1 << 6))
68262306a36Sopenharmony_ci#endif
68362306a36Sopenharmony_ci#ifndef cpu_guest_has_conf7
68462306a36Sopenharmony_ci#define cpu_guest_has_conf7	(cpu_data[0].guest.conf & (1 << 7))
68562306a36Sopenharmony_ci#endif
68662306a36Sopenharmony_ci#ifndef cpu_guest_has_fpu
68762306a36Sopenharmony_ci#define cpu_guest_has_fpu	(cpu_data[0].guest.options & MIPS_CPU_FPU)
68862306a36Sopenharmony_ci#endif
68962306a36Sopenharmony_ci#ifndef cpu_guest_has_watch
69062306a36Sopenharmony_ci#define cpu_guest_has_watch	(cpu_data[0].guest.options & MIPS_CPU_WATCH)
69162306a36Sopenharmony_ci#endif
69262306a36Sopenharmony_ci#ifndef cpu_guest_has_contextconfig
69362306a36Sopenharmony_ci#define cpu_guest_has_contextconfig (cpu_data[0].guest.options & MIPS_CPU_CTXTC)
69462306a36Sopenharmony_ci#endif
69562306a36Sopenharmony_ci#ifndef cpu_guest_has_segments
69662306a36Sopenharmony_ci#define cpu_guest_has_segments	(cpu_data[0].guest.options & MIPS_CPU_SEGMENTS)
69762306a36Sopenharmony_ci#endif
69862306a36Sopenharmony_ci#ifndef cpu_guest_has_badinstr
69962306a36Sopenharmony_ci#define cpu_guest_has_badinstr	(cpu_data[0].guest.options & MIPS_CPU_BADINSTR)
70062306a36Sopenharmony_ci#endif
70162306a36Sopenharmony_ci#ifndef cpu_guest_has_badinstrp
70262306a36Sopenharmony_ci#define cpu_guest_has_badinstrp	(cpu_data[0].guest.options & MIPS_CPU_BADINSTRP)
70362306a36Sopenharmony_ci#endif
70462306a36Sopenharmony_ci#ifndef cpu_guest_has_htw
70562306a36Sopenharmony_ci#define cpu_guest_has_htw	(cpu_data[0].guest.options & MIPS_CPU_HTW)
70662306a36Sopenharmony_ci#endif
70762306a36Sopenharmony_ci#ifndef cpu_guest_has_ldpte
70862306a36Sopenharmony_ci#define cpu_guest_has_ldpte	(cpu_data[0].guest.options & MIPS_CPU_LDPTE)
70962306a36Sopenharmony_ci#endif
71062306a36Sopenharmony_ci#ifndef cpu_guest_has_mvh
71162306a36Sopenharmony_ci#define cpu_guest_has_mvh	(cpu_data[0].guest.options & MIPS_CPU_MVH)
71262306a36Sopenharmony_ci#endif
71362306a36Sopenharmony_ci#ifndef cpu_guest_has_msa
71462306a36Sopenharmony_ci#define cpu_guest_has_msa	(cpu_data[0].guest.ases & MIPS_ASE_MSA)
71562306a36Sopenharmony_ci#endif
71662306a36Sopenharmony_ci#ifndef cpu_guest_has_kscr
71762306a36Sopenharmony_ci#define cpu_guest_has_kscr(n)	(cpu_data[0].guest.kscratch_mask & (1u << (n)))
71862306a36Sopenharmony_ci#endif
71962306a36Sopenharmony_ci#ifndef cpu_guest_has_rw_llb
72062306a36Sopenharmony_ci#define cpu_guest_has_rw_llb	(cpu_has_mips_r6 || (cpu_data[0].guest.options & MIPS_CPU_RW_LLB))
72162306a36Sopenharmony_ci#endif
72262306a36Sopenharmony_ci#ifndef cpu_guest_has_perf
72362306a36Sopenharmony_ci#define cpu_guest_has_perf	(cpu_data[0].guest.options & MIPS_CPU_PERF)
72462306a36Sopenharmony_ci#endif
72562306a36Sopenharmony_ci#ifndef cpu_guest_has_maar
72662306a36Sopenharmony_ci#define cpu_guest_has_maar	(cpu_data[0].guest.options & MIPS_CPU_MAAR)
72762306a36Sopenharmony_ci#endif
72862306a36Sopenharmony_ci#ifndef cpu_guest_has_userlocal
72962306a36Sopenharmony_ci#define cpu_guest_has_userlocal	(cpu_data[0].guest.options & MIPS_CPU_ULRI)
73062306a36Sopenharmony_ci#endif
73162306a36Sopenharmony_ci
73262306a36Sopenharmony_ci/*
73362306a36Sopenharmony_ci * Guest dynamic capabilities
73462306a36Sopenharmony_ci */
73562306a36Sopenharmony_ci#ifndef cpu_guest_has_dyn_fpu
73662306a36Sopenharmony_ci#define cpu_guest_has_dyn_fpu	(cpu_data[0].guest.options_dyn & MIPS_CPU_FPU)
73762306a36Sopenharmony_ci#endif
73862306a36Sopenharmony_ci#ifndef cpu_guest_has_dyn_watch
73962306a36Sopenharmony_ci#define cpu_guest_has_dyn_watch	(cpu_data[0].guest.options_dyn & MIPS_CPU_WATCH)
74062306a36Sopenharmony_ci#endif
74162306a36Sopenharmony_ci#ifndef cpu_guest_has_dyn_contextconfig
74262306a36Sopenharmony_ci#define cpu_guest_has_dyn_contextconfig (cpu_data[0].guest.options_dyn & MIPS_CPU_CTXTC)
74362306a36Sopenharmony_ci#endif
74462306a36Sopenharmony_ci#ifndef cpu_guest_has_dyn_perf
74562306a36Sopenharmony_ci#define cpu_guest_has_dyn_perf	(cpu_data[0].guest.options_dyn & MIPS_CPU_PERF)
74662306a36Sopenharmony_ci#endif
74762306a36Sopenharmony_ci#ifndef cpu_guest_has_dyn_msa
74862306a36Sopenharmony_ci#define cpu_guest_has_dyn_msa	(cpu_data[0].guest.ases_dyn & MIPS_ASE_MSA)
74962306a36Sopenharmony_ci#endif
75062306a36Sopenharmony_ci#ifndef cpu_guest_has_dyn_maar
75162306a36Sopenharmony_ci#define cpu_guest_has_dyn_maar	(cpu_data[0].guest.options_dyn & MIPS_CPU_MAAR)
75262306a36Sopenharmony_ci#endif
75362306a36Sopenharmony_ci
75462306a36Sopenharmony_ci#endif /* __ASM_CPU_FEATURES_H */
755