2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2011-11-28 06:37:32 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2011
|
|
|
|
* Ilya Yanok, EmCraft Systems
|
|
|
|
*/
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <common.h>
|
|
|
|
|
|
|
|
#ifndef CONFIG_SYS_DCACHE_OFF
|
2012-03-15 18:33:17 +00:00
|
|
|
void invalidate_dcache_all(void)
|
2011-11-28 06:37:32 +00:00
|
|
|
{
|
2012-04-06 03:25:07 +00:00
|
|
|
asm volatile("mcr p15, 0, %0, c7, c6, 0\n" : : "r"(0));
|
2011-11-28 06:37:32 +00:00
|
|
|
}
|
|
|
|
|
2012-03-15 18:33:17 +00:00
|
|
|
void flush_dcache_all(void)
|
2011-11-28 06:37:32 +00:00
|
|
|
{
|
2012-03-15 18:33:17 +00:00
|
|
|
asm volatile(
|
|
|
|
"0:"
|
|
|
|
"mrc p15, 0, r15, c7, c14, 3\n"
|
|
|
|
"bne 0b\n"
|
|
|
|
"mcr p15, 0, %0, c7, c10, 4\n"
|
2012-04-06 03:25:07 +00:00
|
|
|
: : "r"(0) : "memory"
|
2012-03-15 18:33:17 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-11-28 06:37:32 +00:00
|
|
|
void invalidate_dcache_range(unsigned long start, unsigned long stop)
|
|
|
|
{
|
2012-03-15 18:33:17 +00:00
|
|
|
if (!check_cache_range(start, stop))
|
|
|
|
return;
|
|
|
|
|
|
|
|
while (start < stop) {
|
2012-04-06 03:25:07 +00:00
|
|
|
asm volatile("mcr p15, 0, %0, c7, c6, 1\n" : : "r"(start));
|
2012-03-15 18:33:17 +00:00
|
|
|
start += CONFIG_SYS_CACHELINE_SIZE;
|
|
|
|
}
|
2011-11-28 06:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void flush_dcache_range(unsigned long start, unsigned long stop)
|
|
|
|
{
|
2012-03-15 18:33:17 +00:00
|
|
|
if (!check_cache_range(start, stop))
|
|
|
|
return;
|
|
|
|
|
|
|
|
while (start < stop) {
|
2012-04-06 03:25:07 +00:00
|
|
|
asm volatile("mcr p15, 0, %0, c7, c14, 1\n" : : "r"(start));
|
2012-03-15 18:33:17 +00:00
|
|
|
start += CONFIG_SYS_CACHELINE_SIZE;
|
|
|
|
}
|
|
|
|
|
2012-04-06 03:25:07 +00:00
|
|
|
asm volatile("mcr p15, 0, %0, c7, c10, 4\n" : : "r"(0));
|
2012-03-15 18:33:17 +00:00
|
|
|
}
|
2011-11-28 06:37:32 +00:00
|
|
|
#else /* #ifndef CONFIG_SYS_DCACHE_OFF */
|
|
|
|
void invalidate_dcache_all(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void flush_dcache_all(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif /* #ifndef CONFIG_SYS_DCACHE_OFF */
|
2012-02-06 17:12:10 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Stub implementations for l2 cache operations
|
|
|
|
*/
|
2015-10-23 16:06:40 +00:00
|
|
|
|
2014-10-27 19:10:06 +00:00
|
|
|
__weak void l2_cache_disable(void) {}
|
2015-10-23 16:06:40 +00:00
|
|
|
|
2017-03-18 13:01:44 +00:00
|
|
|
#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
|
2015-10-23 16:06:40 +00:00
|
|
|
__weak void invalidate_l2_cache(void) {}
|
|
|
|
#endif
|
2018-08-16 18:23:11 +00:00
|
|
|
|
|
|
|
#ifndef CONFIG_SYS_ICACHE_OFF
|
|
|
|
/* Invalidate entire I-cache and branch predictor array */
|
|
|
|
void invalidate_icache_all(void)
|
|
|
|
{
|
|
|
|
unsigned long i = 0;
|
|
|
|
|
|
|
|
asm ("mcr p15, 0, %0, c7, c5, 0" : : "r" (i));
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
void invalidate_icache_all(void) {}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void enable_caches(void)
|
|
|
|
{
|
|
|
|
#ifndef CONFIG_SYS_ICACHE_OFF
|
|
|
|
icache_enable();
|
|
|
|
#endif
|
|
|
|
#ifndef CONFIG_SYS_DCACHE_OFF
|
|
|
|
dcache_enable();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|