2018-05-07 06:58:06 +09:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2011-11-28 15:37:32 +09:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2011
|
|
|
|
* Ilya Yanok, EmCraft Systems
|
|
|
|
*/
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <common.h>
|
|
|
|
|
|
|
|
#ifndef CONFIG_SYS_DCACHE_OFF
|
2012-03-16 03:33:17 +09:00
|
|
|
void invalidate_dcache_all(void)
|
2011-11-28 15:37:32 +09:00
|
|
|
{
|
2012-04-06 12:25:07 +09:00
|
|
|
asm volatile("mcr p15, 0, %0, c7, c6, 0\n" : : "r"(0));
|
2011-11-28 15:37:32 +09:00
|
|
|
}
|
|
|
|
|
2012-03-16 03:33:17 +09:00
|
|
|
void flush_dcache_all(void)
|
2011-11-28 15:37:32 +09:00
|
|
|
{
|
2012-03-16 03:33:17 +09: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 12:25:07 +09:00
|
|
|
: : "r"(0) : "memory"
|
2012-03-16 03:33:17 +09:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-11-28 15:37:32 +09:00
|
|
|
void invalidate_dcache_range(unsigned long start, unsigned long stop)
|
|
|
|
{
|
2012-03-16 03:33:17 +09:00
|
|
|
if (!check_cache_range(start, stop))
|
|
|
|
return;
|
|
|
|
|
|
|
|
while (start < stop) {
|
2012-04-06 12:25:07 +09:00
|
|
|
asm volatile("mcr p15, 0, %0, c7, c6, 1\n" : : "r"(start));
|
2012-03-16 03:33:17 +09:00
|
|
|
start += CONFIG_SYS_CACHELINE_SIZE;
|
|
|
|
}
|
2011-11-28 15:37:32 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
void flush_dcache_range(unsigned long start, unsigned long stop)
|
|
|
|
{
|
2012-03-16 03:33:17 +09:00
|
|
|
if (!check_cache_range(start, stop))
|
|
|
|
return;
|
|
|
|
|
|
|
|
while (start < stop) {
|
2012-04-06 12:25:07 +09:00
|
|
|
asm volatile("mcr p15, 0, %0, c7, c14, 1\n" : : "r"(start));
|
2012-03-16 03:33:17 +09:00
|
|
|
start += CONFIG_SYS_CACHELINE_SIZE;
|
|
|
|
}
|
|
|
|
|
2012-04-06 12:25:07 +09:00
|
|
|
asm volatile("mcr p15, 0, %0, c7, c10, 4\n" : : "r"(0));
|
2012-03-16 03:33:17 +09:00
|
|
|
}
|
2011-11-28 15:37:32 +09: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-07 02:12:10 +09:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Stub implementations for l2 cache operations
|
|
|
|
*/
|
2015-10-24 01:06:40 +09:00
|
|
|
|
2014-10-28 04:10:06 +09:00
|
|
|
__weak void l2_cache_disable(void) {}
|
2015-10-24 01:06:40 +09:00
|
|
|
|
2017-03-18 22:01:44 +09:00
|
|
|
#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
|
2015-10-24 01:06:40 +09:00
|
|
|
__weak void invalidate_l2_cache(void) {}
|
|
|
|
#endif
|