3 * Ilya Yanok, EmCraft Systems
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
22 #include <linux/types.h>
25 #ifndef CONFIG_SYS_DCACHE_OFF
27 #ifndef CONFIG_SYS_CACHELINE_SIZE
28 #define CONFIG_SYS_CACHELINE_SIZE 32
31 void invalidate_dcache_all(void)
33 asm volatile("mcr p15, 0, %0, c7, c6, 0\n"::"r"(0));
36 void flush_dcache_all(void)
40 "mrc p15, 0, r15, c7, c14, 3\n"
42 "mcr p15, 0, %0, c7, c10, 4\n"
47 static int check_cache_range(unsigned long start, unsigned long stop)
51 if (start & (CONFIG_SYS_CACHELINE_SIZE - 1))
54 if (stop & (CONFIG_SYS_CACHELINE_SIZE - 1))
58 printf("CACHE: Misaligned operation at range [%08lx, %08lx]\n",
64 void invalidate_dcache_range(unsigned long start, unsigned long stop)
66 if (!check_cache_range(start, stop))
69 while (start < stop) {
70 asm volatile("mcr p15, 0, %0, c7, c6, 1\n"::"r"(start));
71 start += CONFIG_SYS_CACHELINE_SIZE;
75 void flush_dcache_range(unsigned long start, unsigned long stop)
77 if (!check_cache_range(start, stop))
80 while (start < stop) {
81 asm volatile("mcr p15, 0, %0, c7, c14, 1\n"::"r"(start));
82 start += CONFIG_SYS_CACHELINE_SIZE;
85 asm("mcr p15, 0, %0, c7, c10, 4\n"::"r"(0));
88 void flush_cache(unsigned long start, unsigned long size)
90 flush_dcache_range(start, start + size);
92 #else /* #ifndef CONFIG_SYS_DCACHE_OFF */
93 void invalidate_dcache_all(void)
97 void flush_dcache_all(void)
101 void invalidate_dcache_range(unsigned long start, unsigned long stop)
105 void flush_dcache_range(unsigned long start, unsigned long stop)
109 void flush_cache(unsigned long start, unsigned long size)
112 #endif /* #ifndef CONFIG_SYS_DCACHE_OFF */
115 * Stub implementations for l2 cache operations
117 void __l2_cache_disable(void)
120 void l2_cache_disable(void)
121 __attribute__((weak, alias("__l2_cache_disable")));