aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/include/asm
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2008-08-10 13:10:19 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-09-01 07:06:24 -0400
commit46097c7dd8bfaf9fb86565b6de45ab5a63afdd53 (patch)
treebc9ba1ba3c8e6585704225863663b1b91d75632e /arch/arm/include/asm
parent0ba8b9b273c45dd23f60ff700e265a0069b33758 (diff)
[ARM] cachetype: move definitions to separate header
Rather than pollute asm/cacheflush.h with the cache type definitions, move them to asm/cachetype.h, and include this new header where necessary. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/include/asm')
-rw-r--r--arch/arm/include/asm/cacheflush.h90
-rw-r--r--arch/arm/include/asm/cachetype.h96
-rw-r--r--arch/arm/include/asm/mmu_context.h1
3 files changed, 97 insertions, 90 deletions
diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
index 9073d9c6567e..de6c59f814a1 100644
--- a/arch/arm/include/asm/cacheflush.h
+++ b/arch/arm/include/asm/cacheflush.h
@@ -444,94 +444,4 @@ static inline void flush_ioremap_region(unsigned long phys, void __iomem *virt,
444 dmac_inv_range(start, start + size); 444 dmac_inv_range(start, start + size);
445} 445}
446 446
447#define __cacheid_present(val) (val != read_cpuid(CPUID_ID))
448#define __cacheid_type_v7(val) ((val & (7 << 29)) == (4 << 29))
449
450#define __cacheid_vivt_prev7(val) ((val & (15 << 25)) != (14 << 25))
451#define __cacheid_vipt_prev7(val) ((val & (15 << 25)) == (14 << 25))
452#define __cacheid_vipt_nonaliasing_prev7(val) ((val & (15 << 25 | 1 << 23)) == (14 << 25))
453#define __cacheid_vipt_aliasing_prev7(val) ((val & (15 << 25 | 1 << 23)) == (14 << 25 | 1 << 23))
454
455#define __cacheid_vivt(val) (__cacheid_type_v7(val) ? 0 : __cacheid_vivt_prev7(val))
456#define __cacheid_vipt(val) (__cacheid_type_v7(val) ? 1 : __cacheid_vipt_prev7(val))
457#define __cacheid_vipt_nonaliasing(val) (__cacheid_type_v7(val) ? 1 : __cacheid_vipt_nonaliasing_prev7(val))
458#define __cacheid_vipt_aliasing(val) (__cacheid_type_v7(val) ? 0 : __cacheid_vipt_aliasing_prev7(val))
459#define __cacheid_vivt_asid_tagged_instr(val) (__cacheid_type_v7(val) ? ((val & (3 << 14)) == (1 << 14)) : 0)
460
461#if defined(CONFIG_CPU_CACHE_VIVT) && !defined(CONFIG_CPU_CACHE_VIPT)
462/*
463 * VIVT caches only
464 */
465#define cache_is_vivt() 1
466#define cache_is_vipt() 0
467#define cache_is_vipt_nonaliasing() 0
468#define cache_is_vipt_aliasing() 0
469#define icache_is_vivt_asid_tagged() 0
470
471#elif !defined(CONFIG_CPU_CACHE_VIVT) && defined(CONFIG_CPU_CACHE_VIPT)
472/*
473 * VIPT caches only
474 */
475#define cache_is_vivt() 0
476#define cache_is_vipt() 1
477#define cache_is_vipt_nonaliasing() \
478 ({ \
479 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
480 __cacheid_vipt_nonaliasing(__val); \
481 })
482
483#define cache_is_vipt_aliasing() \
484 ({ \
485 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
486 __cacheid_vipt_aliasing(__val); \
487 })
488
489#define icache_is_vivt_asid_tagged() \
490 ({ \
491 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
492 __cacheid_vivt_asid_tagged_instr(__val); \
493 })
494
495#else
496/*
497 * VIVT or VIPT caches. Note that this is unreliable since ARM926
498 * and V6 CPUs satisfy the "(val & (15 << 25)) == (14 << 25)" test.
499 * There's no way to tell from the CacheType register what type (!)
500 * the cache is.
501 */
502#define cache_is_vivt() \
503 ({ \
504 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
505 (!__cacheid_present(__val)) || __cacheid_vivt(__val); \
506 })
507
508#define cache_is_vipt() \
509 ({ \
510 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
511 __cacheid_present(__val) && __cacheid_vipt(__val); \
512 })
513
514#define cache_is_vipt_nonaliasing() \
515 ({ \
516 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
517 __cacheid_present(__val) && \
518 __cacheid_vipt_nonaliasing(__val); \
519 })
520
521#define cache_is_vipt_aliasing() \
522 ({ \
523 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
524 __cacheid_present(__val) && \
525 __cacheid_vipt_aliasing(__val); \
526 })
527
528#define icache_is_vivt_asid_tagged() \
529 ({ \
530 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
531 __cacheid_present(__val) && \
532 __cacheid_vivt_asid_tagged_instr(__val); \
533 })
534
535#endif
536
537#endif 447#endif
diff --git a/arch/arm/include/asm/cachetype.h b/arch/arm/include/asm/cachetype.h
new file mode 100644
index 000000000000..b52386bfd505
--- /dev/null
+++ b/arch/arm/include/asm/cachetype.h
@@ -0,0 +1,96 @@
1#ifndef __ASM_ARM_CACHETYPE_H
2#define __ASM_ARM_CACHETYPE_H
3
4#include <asm/cputype.h>
5
6#define __cacheid_present(val) (val != read_cpuid_id())
7#define __cacheid_type_v7(val) ((val & (7 << 29)) == (4 << 29))
8
9#define __cacheid_vivt_prev7(val) ((val & (15 << 25)) != (14 << 25))
10#define __cacheid_vipt_prev7(val) ((val & (15 << 25)) == (14 << 25))
11#define __cacheid_vipt_nonaliasing_prev7(val) ((val & (15 << 25 | 1 << 23)) == (14 << 25))
12#define __cacheid_vipt_aliasing_prev7(val) ((val & (15 << 25 | 1 << 23)) == (14 << 25 | 1 << 23))
13
14#define __cacheid_vivt(val) (__cacheid_type_v7(val) ? 0 : __cacheid_vivt_prev7(val))
15#define __cacheid_vipt(val) (__cacheid_type_v7(val) ? 1 : __cacheid_vipt_prev7(val))
16#define __cacheid_vipt_nonaliasing(val) (__cacheid_type_v7(val) ? 1 : __cacheid_vipt_nonaliasing_prev7(val))
17#define __cacheid_vipt_aliasing(val) (__cacheid_type_v7(val) ? 0 : __cacheid_vipt_aliasing_prev7(val))
18#define __cacheid_vivt_asid_tagged_instr(val) (__cacheid_type_v7(val) ? ((val & (3 << 14)) == (1 << 14)) : 0)
19
20#if defined(CONFIG_CPU_CACHE_VIVT) && !defined(CONFIG_CPU_CACHE_VIPT)
21/*
22 * VIVT caches only
23 */
24#define cache_is_vivt() 1
25#define cache_is_vipt() 0
26#define cache_is_vipt_nonaliasing() 0
27#define cache_is_vipt_aliasing() 0
28#define icache_is_vivt_asid_tagged() 0
29
30#elif !defined(CONFIG_CPU_CACHE_VIVT) && defined(CONFIG_CPU_CACHE_VIPT)
31/*
32 * VIPT caches only
33 */
34#define cache_is_vivt() 0
35#define cache_is_vipt() 1
36#define cache_is_vipt_nonaliasing() \
37 ({ \
38 unsigned int __val = read_cpuid_cachetype(); \
39 __cacheid_vipt_nonaliasing(__val); \
40 })
41
42#define cache_is_vipt_aliasing() \
43 ({ \
44 unsigned int __val = read_cpuid_cachetype(); \
45 __cacheid_vipt_aliasing(__val); \
46 })
47
48#define icache_is_vivt_asid_tagged() \
49 ({ \
50 unsigned int __val = read_cpuid_cachetype(); \
51 __cacheid_vivt_asid_tagged_instr(__val); \
52 })
53
54#else
55/*
56 * VIVT or VIPT caches. Note that this is unreliable since ARM926
57 * and V6 CPUs satisfy the "(val & (15 << 25)) == (14 << 25)" test.
58 * There's no way to tell from the CacheType register what type (!)
59 * the cache is.
60 */
61#define cache_is_vivt() \
62 ({ \
63 unsigned int __val = read_cpuid_cachetype(); \
64 (!__cacheid_present(__val)) || __cacheid_vivt(__val); \
65 })
66
67#define cache_is_vipt() \
68 ({ \
69 unsigned int __val = read_cpuid_cachetype(); \
70 __cacheid_present(__val) && __cacheid_vipt(__val); \
71 })
72
73#define cache_is_vipt_nonaliasing() \
74 ({ \
75 unsigned int __val = read_cpuid_cachetype(); \
76 __cacheid_present(__val) && \
77 __cacheid_vipt_nonaliasing(__val); \
78 })
79
80#define cache_is_vipt_aliasing() \
81 ({ \
82 unsigned int __val = read_cpuid_cachetype(); \
83 __cacheid_present(__val) && \
84 __cacheid_vipt_aliasing(__val); \
85 })
86
87#define icache_is_vivt_asid_tagged() \
88 ({ \
89 unsigned int __val = read_cpuid_cachetype(); \
90 __cacheid_present(__val) && \
91 __cacheid_vivt_asid_tagged_instr(__val); \
92 })
93
94#endif
95
96#endif
diff --git a/arch/arm/include/asm/mmu_context.h b/arch/arm/include/asm/mmu_context.h
index a301e446007f..0559f37c2a27 100644
--- a/arch/arm/include/asm/mmu_context.h
+++ b/arch/arm/include/asm/mmu_context.h
@@ -15,6 +15,7 @@
15 15
16#include <linux/compiler.h> 16#include <linux/compiler.h>
17#include <asm/cacheflush.h> 17#include <asm/cacheflush.h>
18#include <asm/cachetype.h>
18#include <asm/proc-fns.h> 19#include <asm/proc-fns.h>
19#include <asm-generic/mm_hooks.h> 20#include <asm-generic/mm_hooks.h>
20 21