Skip to content

Commit f5a5c89

Browse files
jaustinRussell King
authored andcommitted
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>
1 parent 296909e commit f5a5c89

3 files changed

Lines changed: 30 additions & 9 deletions

File tree

‎arch/arm/include/asm/cachetype.h‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ static inline unsigned int __attribute__((pure)) cacheid_is(unsigned int mask)
6767
#define CSSELR_L6 (5 << 1)
6868
#define CSSELR_L7 (6 << 1)
6969

70+
#ifndef CONFIG_CPU_V7M
7071
static inline void set_csselr(unsigned int cache_selector)
7172
{
7273
asm volatile("mcr p15, 2, %0, c0, c0, 0" : : "r" (cache_selector));
@@ -79,5 +80,19 @@ static inline unsigned int read_ccsidr(void)
7980
asm volatile("mrc p15, 1, %0, c0, c0, 0" : "=r" (val));
8081
return val;
8182
}
83+
#else /* CONFIG_CPU_V7M */
84+
#include <linux/io.h>
85+
#include "asm/v7m.h"
86+
87+
static inline void set_csselr(unsigned int cache_selector)
88+
{
89+
writel(cache_selector, BASEADDR_V7M_SCB + V7M_SCB_CTR);
90+
}
91+
92+
static inline unsigned int read_ccsidr(void)
93+
{
94+
return readl(BASEADDR_V7M_SCB + V7M_SCB_CCSIDR);
95+
}
96+
#endif
8297

8398
#endif

‎arch/arm/include/asm/cputype.h‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,23 @@ static inline unsigned int __attribute_const__ read_cpuid_id(void)
164164
return read_cpuid(CPUID_ID);
165165
}
166166

167+
static inline unsigned int __attribute_const__ read_cpuid_cachetype(void)
168+
{
169+
return read_cpuid(CPUID_CACHETYPE);
170+
}
171+
167172
#elif defined(CONFIG_CPU_V7M)
168173

169174
static inline unsigned int __attribute_const__ read_cpuid_id(void)
170175
{
171176
return readl(BASEADDR_V7M_SCB + V7M_SCB_CPUID);
172177
}
173178

179+
static inline unsigned int __attribute_const__ read_cpuid_cachetype(void)
180+
{
181+
return readl(BASEADDR_V7M_SCB + V7M_SCB_CTR);
182+
}
183+
174184
#else /* ifdef CONFIG_CPU_CP15 / elif defined(CONFIG_CPU_V7M) */
175185

176186
static inline unsigned int __attribute_const__ read_cpuid_id(void)
@@ -210,11 +220,6 @@ static inline unsigned int __attribute_const__ xscale_cpu_arch_version(void)
210220
return read_cpuid_id() & ARM_CPU_XSCALE_ARCH_MASK;
211221
}
212222

213-
static inline unsigned int __attribute_const__ read_cpuid_cachetype(void)
214-
{
215-
return read_cpuid(CPUID_CACHETYPE);
216-
}
217-
218223
static inline unsigned int __attribute_const__ read_cpuid_tcmstatus(void)
219224
{
220225
return read_cpuid(CPUID_TCM);

‎arch/arm/kernel/setup.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,12 @@ static void __init cacheid_init(void)
312312
{
313313
unsigned int arch = cpu_architecture();
314314

315-
if (arch == CPU_ARCH_ARMv7M) {
316-
cacheid = 0;
317-
} else if (arch >= CPU_ARCH_ARMv6) {
315+
if (arch >= CPU_ARCH_ARMv6) {
318316
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) {
320321
/* ARMv7 register format */
321322
arch = CPU_ARCH_ARMv7;
322323
cacheid = CACHEID_VIPT_NONALIASING;

0 commit comments

Comments
 (0)