Russell King | 46097c7 | 2008-08-10 18:10:19 +0100 | [diff] [blame] | 1 | #ifndef __ASM_ARM_CACHETYPE_H |
| 2 | #define __ASM_ARM_CACHETYPE_H |
| 3 | |
Russell King | c0e9587 | 2008-09-25 15:35:28 +0100 | [diff] [blame] | 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) |
Will Deacon | 8925ec4 | 2010-09-13 16:18:30 +0100 | [diff] [blame] | 9 | #define CACHEID_VIPT_I_ALIASING (1 << 4) |
Russell King | 46097c7 | 2008-08-10 18:10:19 +0100 | [diff] [blame] | 10 | |
Russell King | c0e9587 | 2008-09-25 15:35:28 +0100 | [diff] [blame] | 11 | extern unsigned int cacheid; |
Russell King | 46097c7 | 2008-08-10 18:10:19 +0100 | [diff] [blame] | 12 | |
Russell King | c0e9587 | 2008-09-25 15:35:28 +0100 | [diff] [blame] | 13 | #define cache_is_vivt() cacheid_is(CACHEID_VIVT) |
| 14 | #define cache_is_vipt() cacheid_is(CACHEID_VIPT) |
| 15 | #define cache_is_vipt_nonaliasing() cacheid_is(CACHEID_VIPT_NONALIASING) |
| 16 | #define cache_is_vipt_aliasing() cacheid_is(CACHEID_VIPT_ALIASING) |
| 17 | #define icache_is_vivt_asid_tagged() cacheid_is(CACHEID_ASID_TAGGED) |
Will Deacon | 8925ec4 | 2010-09-13 16:18:30 +0100 | [diff] [blame] | 18 | #define icache_is_vipt_aliasing() cacheid_is(CACHEID_VIPT_I_ALIASING) |
Russell King | 46097c7 | 2008-08-10 18:10:19 +0100 | [diff] [blame] | 19 | |
Russell King | 46097c7 | 2008-08-10 18:10:19 +0100 | [diff] [blame] | 20 | /* |
Russell King | c0e9587 | 2008-09-25 15:35:28 +0100 | [diff] [blame] | 21 | * __LINUX_ARM_ARCH__ is the minimum supported CPU architecture |
| 22 | * Mask out support which will never be present on newer CPUs. |
| 23 | * - v6+ is never VIVT |
Will Deacon | 8925ec4 | 2010-09-13 16:18:30 +0100 | [diff] [blame] | 24 | * - v7+ VIPT never aliases on D-side |
Russell King | 46097c7 | 2008-08-10 18:10:19 +0100 | [diff] [blame] | 25 | */ |
Russell King | c0e9587 | 2008-09-25 15:35:28 +0100 | [diff] [blame] | 26 | #if __LINUX_ARM_ARCH__ >= 7 |
Will Deacon | 8925ec4 | 2010-09-13 16:18:30 +0100 | [diff] [blame] | 27 | #define __CACHEID_ARCH_MIN (CACHEID_VIPT_NONALIASING |\ |
| 28 | CACHEID_ASID_TAGGED |\ |
| 29 | CACHEID_VIPT_I_ALIASING) |
Russell King | c0e9587 | 2008-09-25 15:35:28 +0100 | [diff] [blame] | 30 | #elif __LINUX_ARM_ARCH__ >= 6 |
| 31 | #define __CACHEID_ARCH_MIN (~CACHEID_VIVT) |
Russell King | 46097c7 | 2008-08-10 18:10:19 +0100 | [diff] [blame] | 32 | #else |
Russell King | c0e9587 | 2008-09-25 15:35:28 +0100 | [diff] [blame] | 33 | #define __CACHEID_ARCH_MIN (~0) |
Russell King | 46097c7 | 2008-08-10 18:10:19 +0100 | [diff] [blame] | 34 | #endif |
| 35 | |
Russell King | c0e9587 | 2008-09-25 15:35:28 +0100 | [diff] [blame] | 36 | /* |
| 37 | * Mask out support which isn't configured |
| 38 | */ |
| 39 | #if defined(CONFIG_CPU_CACHE_VIVT) && !defined(CONFIG_CPU_CACHE_VIPT) |
| 40 | #define __CACHEID_ALWAYS (CACHEID_VIVT) |
| 41 | #define __CACHEID_NEVER (~CACHEID_VIVT) |
| 42 | #elif !defined(CONFIG_CPU_CACHE_VIVT) && defined(CONFIG_CPU_CACHE_VIPT) |
| 43 | #define __CACHEID_ALWAYS (0) |
| 44 | #define __CACHEID_NEVER (CACHEID_VIVT) |
| 45 | #else |
| 46 | #define __CACHEID_ALWAYS (0) |
| 47 | #define __CACHEID_NEVER (0) |
| 48 | #endif |
| 49 | |
| 50 | static inline unsigned int __attribute__((pure)) cacheid_is(unsigned int mask) |
| 51 | { |
| 52 | return (__CACHEID_ALWAYS & mask) | |
| 53 | (~__CACHEID_NEVER & __CACHEID_ARCH_MIN & mask & cacheid); |
| 54 | } |
| 55 | |
Russell King | 46097c7 | 2008-08-10 18:10:19 +0100 | [diff] [blame] | 56 | #endif |