Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 8604/1: V7M: Add support for reading the CTR with read_cpuid_cachetype()

With the addition of caches to the V7M Architecture a new Cache Type
Register (CTR) is defined at 0xE000ED7C. This register serves the same
purpose as the V7A/R version and accessed via the read_cpuid_cachetype.

Signed-off-by: Jonathan Austin <jonathan.austin@arm.com>
Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
Tested-by: Andras Szemzo <sza@esh.hu>
Tested-by: Joachim Eastwood <manabian@gmail.com>
Tested-by: Alexandre TORGUE <alexandre.torgue@st.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Jonathan Austin and committed by
Russell King
f5a5c89e 296909ee

+30 -9
+15
arch/arm/include/asm/cachetype.h
··· 67 67 #define CSSELR_L6 (5 << 1) 68 68 #define CSSELR_L7 (6 << 1) 69 69 70 + #ifndef CONFIG_CPU_V7M 70 71 static inline void set_csselr(unsigned int cache_selector) 71 72 { 72 73 asm volatile("mcr p15, 2, %0, c0, c0, 0" : : "r" (cache_selector)); ··· 80 79 asm volatile("mrc p15, 1, %0, c0, c0, 0" : "=r" (val)); 81 80 return val; 82 81 } 82 + #else /* CONFIG_CPU_V7M */ 83 + #include <linux/io.h> 84 + #include "asm/v7m.h" 85 + 86 + static inline void set_csselr(unsigned int cache_selector) 87 + { 88 + writel(cache_selector, BASEADDR_V7M_SCB + V7M_SCB_CTR); 89 + } 90 + 91 + static inline unsigned int read_ccsidr(void) 92 + { 93 + return readl(BASEADDR_V7M_SCB + V7M_SCB_CCSIDR); 94 + } 95 + #endif 83 96 84 97 #endif
+10 -5
arch/arm/include/asm/cputype.h
··· 164 164 return read_cpuid(CPUID_ID); 165 165 } 166 166 167 + static inline unsigned int __attribute_const__ read_cpuid_cachetype(void) 168 + { 169 + return read_cpuid(CPUID_CACHETYPE); 170 + } 171 + 167 172 #elif defined(CONFIG_CPU_V7M) 168 173 169 174 static inline unsigned int __attribute_const__ read_cpuid_id(void) 170 175 { 171 176 return readl(BASEADDR_V7M_SCB + V7M_SCB_CPUID); 177 + } 178 + 179 + static inline unsigned int __attribute_const__ read_cpuid_cachetype(void) 180 + { 181 + return readl(BASEADDR_V7M_SCB + V7M_SCB_CTR); 172 182 } 173 183 174 184 #else /* ifdef CONFIG_CPU_CP15 / elif defined(CONFIG_CPU_V7M) */ ··· 218 208 static inline unsigned int __attribute_const__ xscale_cpu_arch_version(void) 219 209 { 220 210 return read_cpuid_id() & ARM_CPU_XSCALE_ARCH_MASK; 221 - } 222 - 223 - static inline unsigned int __attribute_const__ read_cpuid_cachetype(void) 224 - { 225 - return read_cpuid(CPUID_CACHETYPE); 226 211 } 227 212 228 213 static inline unsigned int __attribute_const__ read_cpuid_tcmstatus(void)
+5 -4
arch/arm/kernel/setup.c
··· 312 312 { 313 313 unsigned int arch = cpu_architecture(); 314 314 315 - if (arch == CPU_ARCH_ARMv7M) { 316 - cacheid = 0; 317 - } else if (arch >= CPU_ARCH_ARMv6) { 315 + if (arch >= CPU_ARCH_ARMv6) { 318 316 unsigned int cachetype = read_cpuid_cachetype(); 319 - if ((cachetype & (7 << 29)) == 4 << 29) { 317 + 318 + if ((arch == CPU_ARCH_ARMv7M) && !cachetype) { 319 + cacheid = 0; 320 + } else if ((cachetype & (7 << 29)) == 4 << 29) { 320 321 /* ARMv7 register format */ 321 322 arch = CPU_ARCH_ARMv7; 322 323 cacheid = CACHEID_VIPT_NONALIASING;