aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Austin <jonathan.austin@arm.com>2016-08-30 12:27:19 -0400
committerRussell King <rmk+kernel@armlinux.org.uk>2016-09-06 10:51:07 -0400
commitf5a5c89e36d0897b65e4e6bc2f646f75f8074263 (patch)
treebeaaf4b52d04056a54fea8fc7d9706f2d01f481b
parent296909ee6d9cf98f68a61d5e9774ff5435df2c6a (diff)
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>
-rw-r--r--arch/arm/include/asm/cachetype.h15
-rw-r--r--arch/arm/include/asm/cputype.h15
-rw-r--r--arch/arm/kernel/setup.c9
3 files changed, 30 insertions, 9 deletions
diff --git a/arch/arm/include/asm/cachetype.h b/arch/arm/include/asm/cachetype.h
index 8609de8e313a..01509ae0bbec 100644
--- a/arch/arm/include/asm/cachetype.h
+++ b/arch/arm/include/asm/cachetype.h
@@ -67,6 +67,7 @@ static inline unsigned int __attribute__((pure)) cacheid_is(unsigned int mask)
67#define CSSELR_L6 (5 << 1) 67#define CSSELR_L6 (5 << 1)
68#define CSSELR_L7 (6 << 1) 68#define CSSELR_L7 (6 << 1)
69 69
70#ifndef CONFIG_CPU_V7M
70static inline void set_csselr(unsigned int cache_selector) 71static inline void set_csselr(unsigned int cache_selector)
71{ 72{
72 asm volatile("mcr p15, 2, %0, c0, c0, 0" : : "r" (cache_selector)); 73 asm volatile("mcr p15, 2, %0, c0, c0, 0" : : "r" (cache_selector));
@@ -79,5 +80,19 @@ static inline unsigned int read_ccsidr(void)
79 asm volatile("mrc p15, 1, %0, c0, c0, 0" : "=r" (val)); 80 asm volatile("mrc p15, 1, %0, c0, c0, 0" : "=r" (val));
80 return val; 81 return val;
81} 82}
83#else /* CONFIG_CPU_V7M */
84#include <linux/io.h>
85#include "asm/v7m.h"
86
87static inline void set_csselr(unsigned int cache_selector)
88{
89 writel(cache_selector, BASEADDR_V7M_SCB + V7M_SCB_CTR);
90}
91
92static inline unsigned int read_ccsidr(void)
93{
94 return readl(BASEADDR_V7M_SCB + V7M_SCB_CCSIDR);
95}
96#endif
82 97
83#endif 98#endif
diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h
index d6a4902a75d7..754f86f667d4 100644
--- a/arch/arm/include/asm/cputype.h
+++ b/arch/arm/include/asm/cputype.h
@@ -164,6 +164,11 @@ static inline unsigned int __attribute_const__ read_cpuid_id(void)
164 return read_cpuid(CPUID_ID); 164 return read_cpuid(CPUID_ID);
165} 165}
166 166
167static inline unsigned int __attribute_const__ read_cpuid_cachetype(void)
168{
169 return read_cpuid(CPUID_CACHETYPE);
170}
171
167#elif defined(CONFIG_CPU_V7M) 172#elif defined(CONFIG_CPU_V7M)
168 173
169static inline unsigned int __attribute_const__ read_cpuid_id(void) 174static inline unsigned int __attribute_const__ read_cpuid_id(void)
@@ -171,6 +176,11 @@ static inline unsigned int __attribute_const__ read_cpuid_id(void)
171 return readl(BASEADDR_V7M_SCB + V7M_SCB_CPUID); 176 return readl(BASEADDR_V7M_SCB + V7M_SCB_CPUID);
172} 177}
173 178
179static inline unsigned int __attribute_const__ read_cpuid_cachetype(void)
180{
181 return readl(BASEADDR_V7M_SCB + V7M_SCB_CTR);
182}
183
174#else /* ifdef CONFIG_CPU_CP15 / elif defined(CONFIG_CPU_V7M) */ 184#else /* ifdef CONFIG_CPU_CP15 / elif defined(CONFIG_CPU_V7M) */
175 185
176static inline unsigned int __attribute_const__ read_cpuid_id(void) 186static inline unsigned int __attribute_const__ read_cpuid_id(void)
@@ -210,11 +220,6 @@ static inline unsigned int __attribute_const__ xscale_cpu_arch_version(void)
210 return read_cpuid_id() & ARM_CPU_XSCALE_ARCH_MASK; 220 return read_cpuid_id() & ARM_CPU_XSCALE_ARCH_MASK;
211} 221}
212 222
213static inline unsigned int __attribute_const__ read_cpuid_cachetype(void)
214{
215 return read_cpuid(CPUID_CACHETYPE);
216}
217
218static inline unsigned int __attribute_const__ read_cpuid_tcmstatus(void) 223static inline unsigned int __attribute_const__ read_cpuid_tcmstatus(void)
219{ 224{
220 return read_cpuid(CPUID_TCM); 225 return read_cpuid(CPUID_TCM);
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index d7568808eb7b..34e3f3c45634 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -312,11 +312,12 @@ static void __init cacheid_init(void)
312{ 312{
313 unsigned int arch = cpu_architecture(); 313 unsigned int arch = cpu_architecture();
314 314
315 if (arch == CPU_ARCH_ARMv7M) { 315 if (arch >= CPU_ARCH_ARMv6) {
316 cacheid = 0;
317 } else if (arch >= CPU_ARCH_ARMv6) {
318 unsigned int cachetype = read_cpuid_cachetype(); 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 /* ARMv7 register format */ 321 /* ARMv7 register format */
321 arch = CPU_ARCH_ARMv7; 322 arch = CPU_ARCH_ARMv7;
322 cacheid = CACHEID_VIPT_NONALIASING; 323 cacheid = CACHEID_VIPT_NONALIASING;