}
#endif
-size_t __read_mostly cacheline_bytes;
+size_t __read_mostly dcache_line_bytes;
/* Very early check of the CPU cache properties */
void __init setup_cache(void)
{
- uint32_t ccsid;
+ uint32_t ctr;
- /* Read the cache size ID register for the level-0 data cache */
- WRITE_SYSREG32(0, CSSELR_EL1);
- ccsid = READ_SYSREG32(CCSIDR_EL1);
+ /* Read CTR */
+ ctr = READ_SYSREG32(CTR_EL0);
- /* Low 3 bits are log2(cacheline size in words) - 2. */
- cacheline_bytes = 1U << (4 + (ccsid & 0x7));
+ /* Bits 16-19 are the log2 number of words in the cacheline. */
+ dcache_line_bytes = (size_t) (4 << ((ctr >> 16) & 0xf));
}
/* C entry point for boot CPU */
/* CP15 CR0: CPUID and Cache Type Registers */
#define MIDR p15,0,c0,c0,0 /* Main ID Register */
+#define CTR p15,0,c0,c0,1 /* Cache Type Register */
#define MPIDR p15,0,c0,c0,5 /* Multiprocessor Affinity Register */
#define ID_PFR0 p15,0,c0,c1,0 /* Processor Feature Register 0 */
#define ID_PFR1 p15,0,c0,c1,1 /* Processor Feature Register 1 */
#define CPACR_EL1 CPACR
#define CPTR_EL2 HCPTR
#define CSSELR_EL1 CSSELR
+#define CTR_EL0 CTR
#define DACR32_EL2 DACR
#define ESR_EL1 DFSR
#define ESR_EL2 HSR
/* Architectural minimum cacheline size is 4 32-bit words. */
#define MIN_CACHELINE_BYTES 16
-/* Actual cacheline size on the boot CPU. */
-extern size_t cacheline_bytes;
+/* Min dcache line size on the boot CPU. */
+extern size_t dcache_line_bytes;
#define copy_page(dp, sp) memcpy(dp, sp, PAGE_SIZE)
static inline int invalidate_dcache_va_range(const void *p, unsigned long size)
{
const void *end = p + size;
- size_t cacheline_mask = cacheline_bytes - 1;
+ size_t cacheline_mask = dcache_line_bytes - 1;
dsb(sy); /* So the CPU issues all writes to the range */
{
p = (void *)((uintptr_t)p & ~cacheline_mask);
asm volatile (__clean_and_invalidate_dcache_one(0) : : "r" (p));
- p += cacheline_bytes;
+ p += dcache_line_bytes;
}
if ( (uintptr_t)end & cacheline_mask )
{
asm volatile (__clean_and_invalidate_dcache_one(0) : : "r" (end));
}
- for ( ; p < end; p += cacheline_bytes )
+ for ( ; p < end; p += dcache_line_bytes )
asm volatile (__invalidate_dcache_one(0) : : "r" (p));
dsb(sy); /* So we know the flushes happen before continuing */
{
const void *end = p + size;
dsb(sy); /* So the CPU issues all writes to the range */
- p = (void *)((uintptr_t)p & ~(cacheline_bytes - 1));
- for ( ; p < end; p += cacheline_bytes )
+ p = (void *)((uintptr_t)p & ~(dcache_line_bytes - 1));
+ for ( ; p < end; p += dcache_line_bytes )
asm volatile (__clean_dcache_one(0) : : "r" (p));
dsb(sy); /* So we know the flushes happen before continuing */
/* ARM callers assume that dcache_* functions cannot fail. */
{
const void *end = p + size;
dsb(sy); /* So the CPU issues all writes to the range */
- p = (void *)((uintptr_t)p & ~(cacheline_bytes - 1));
- for ( ; p < end; p += cacheline_bytes )
+ p = (void *)((uintptr_t)p & ~(dcache_line_bytes - 1));
+ for ( ; p < end; p += dcache_line_bytes )
asm volatile (__clean_and_invalidate_dcache_one(0) : : "r" (p));
dsb(sy); /* So we know the flushes happen before continuing */
/* ARM callers assume that dcache_* functions cannot fail. */