1 #ifndef __ASM_ARM_CACHETYPE_H
2 #define __ASM_ARM_CACHETYPE_H
4 #define CACHEID_VIVT (1 << 0)
5 #define CACHEID_VIPT_NONALIASING (1 << 1)
6 #define CACHEID_VIPT_ALIASING (1 << 2)
7 #define CACHEID_VIPT (CACHEID_VIPT_ALIASING|CACHEID_VIPT_NONALIASING)
8 #define CACHEID_ASID_TAGGED (1 << 3)
10 extern unsigned int cacheid;
12 #define cache_is_vivt() cacheid_is(CACHEID_VIVT)
13 #define cache_is_vipt() cacheid_is(CACHEID_VIPT)
14 #define cache_is_vipt_nonaliasing() cacheid_is(CACHEID_VIPT_NONALIASING)
15 #define cache_is_vipt_aliasing() cacheid_is(CACHEID_VIPT_ALIASING)
16 #define icache_is_vivt_asid_tagged() cacheid_is(CACHEID_ASID_TAGGED)
19 * __LINUX_ARM_ARCH__ is the minimum supported CPU architecture
20 * Mask out support which will never be present on newer CPUs.
22 * - v7+ VIPT never aliases
24 #if __LINUX_ARM_ARCH__ >= 7
25 #define __CACHEID_ARCH_MIN (CACHEID_VIPT_NONALIASING | CACHEID_ASID_TAGGED)
26 #elif __LINUX_ARM_ARCH__ >= 6
27 #define __CACHEID_ARCH_MIN (~CACHEID_VIVT)
29 #define __CACHEID_ARCH_MIN (~0)
33 * Mask out support which isn't configured
35 #if defined(CONFIG_CPU_CACHE_VIVT) && !defined(CONFIG_CPU_CACHE_VIPT)
36 #define __CACHEID_ALWAYS (CACHEID_VIVT)
37 #define __CACHEID_NEVER (~CACHEID_VIVT)
38 #elif !defined(CONFIG_CPU_CACHE_VIVT) && defined(CONFIG_CPU_CACHE_VIPT)
39 #define __CACHEID_ALWAYS (0)
40 #define __CACHEID_NEVER (CACHEID_VIVT)
42 #define __CACHEID_ALWAYS (0)
43 #define __CACHEID_NEVER (0)
46 static inline unsigned int __attribute__((pure)) cacheid_is(unsigned int mask)
48 return (__CACHEID_ALWAYS & mask) |
49 (~__CACHEID_NEVER & __CACHEID_ARCH_MIN & mask & cacheid);