aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2008-09-25 10:35:28 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-09-25 10:35:28 -0400
commitc0e9587841a0fd79bbf8296034faefb9afe72fb4 (patch)
treeb82e0e79706f9f63985b4591e1fa02eaa2df73d2 /arch/arm/kernel
parent90f1e084783be9bbff4861fa8e460b76de2787f4 (diff)
[ARM] Introduce new bitmask based cache type macros
Rather than trying to (inaccurately) decode the cache type from the registers each time we need to decide what type of cache we have, use a bitmask initialized early during boot. Since the setup is a one-off initialization, we can be a little more clever and take account of the CPU architecture as well. Note that we continue to achieve the compactness on optimised kernels by forcing tests to always-false or always-true as appropriate, thereby allowing the compiler to do build-time code elimination. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/kernel')
-rw-r--r--arch/arm/kernel/setup.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 1939c904dae3..5b121d81f9eb 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -67,6 +67,8 @@ unsigned int processor_id;
67EXPORT_SYMBOL(processor_id); 67EXPORT_SYMBOL(processor_id);
68unsigned int __machine_arch_type; 68unsigned int __machine_arch_type;
69EXPORT_SYMBOL(__machine_arch_type); 69EXPORT_SYMBOL(__machine_arch_type);
70unsigned int cacheid;
71EXPORT_SYMBOL(cacheid);
70 72
71unsigned int __atags_pointer __initdata; 73unsigned int __atags_pointer __initdata;
72 74
@@ -229,6 +231,25 @@ int cpu_architecture(void)
229 return cpu_arch; 231 return cpu_arch;
230} 232}
231 233
234static void __init cacheid_init(void)
235{
236 unsigned int cachetype = read_cpuid_cachetype();
237 unsigned int arch = cpu_architecture();
238
239 if (arch >= CPU_ARCH_ARMv7) {
240 cacheid = CACHEID_VIPT_NONALIASING;
241 if ((cachetype & (3 << 14)) == 1 << 14)
242 cacheid |= CACHEID_ASID_TAGGED;
243 } else if (arch >= CPU_ARCH_ARMv6) {
244 if (cachetype & (1 << 23))
245 cacheid = CACHEID_VIPT_ALIASING;
246 else
247 cacheid = CACHEID_VIPT_NONALIASING;
248 } else {
249 cacheid = CACHEID_VIVT;
250 }
251}
252
232/* 253/*
233 * These functions re-use the assembly code in head.S, which 254 * These functions re-use the assembly code in head.S, which
234 * already provide the required functionality. 255 * already provide the required functionality.
@@ -278,6 +299,7 @@ static void __init setup_processor(void)
278 elf_hwcap &= ~HWCAP_THUMB; 299 elf_hwcap &= ~HWCAP_THUMB;
279#endif 300#endif
280 301
302 cacheid_init();
281 cpu_proc_init(); 303 cpu_proc_init();
282} 304}
283 305