20 #include <asm/cacheflush.h>
22 #include <asm/cputype.h>
36 #if __LINUX_ARM_ARCH__ < 7
40 static inline void tauros2_clean_pa(
unsigned long addr)
42 __asm__(
"mcr p15, 1, %0, c7, c11, 3" : :
"r" (addr));
45 static inline void tauros2_clean_inv_pa(
unsigned long addr)
47 __asm__(
"mcr p15, 1, %0, c7, c15, 3" : :
"r" (addr));
50 static inline void tauros2_inv_pa(
unsigned long addr)
52 __asm__(
"mcr p15, 1, %0, c7, c7, 3" : :
"r" (addr));
62 #define CACHE_LINE_SIZE 32
64 static void tauros2_inv_range(
unsigned long start,
unsigned long end)
86 tauros2_inv_pa(start);
93 static void tauros2_clean_range(
unsigned long start,
unsigned long end)
97 tauros2_clean_pa(start);
104 static void tauros2_flush_range(
unsigned long start,
unsigned long end)
107 while (start < end) {
108 tauros2_clean_inv_pa(start);
115 static void tauros2_disable(
void)
118 "mcr p15, 1, %0, c7, c11, 0 @L2 Cache Clean All\n\t"
119 "mrc p15, 0, %0, c1, c0, 0\n\t"
120 "bic %0, %0, #(1 << 26)\n\t"
121 "mcr p15, 0, %0, c1, c0, 0 @Disable L2 Cache\n\t"
125 static void tauros2_resume(
void)
128 "mcr p15, 1, %0, c7, c7, 0 @L2 Cache Invalidate All\n\t"
129 "mrc p15, 0, %0, c1, c0, 0\n\t"
130 "orr %0, %0, #(1 << 26)\n\t"
131 "mcr p15, 0, %0, c1, c0, 0 @Enable L2 Cache\n\t"
136 static inline u32 __init read_extra_features(
void)
140 __asm__(
"mrc p15, 1, %0, c15, c1, 0" :
"=r" (u));
145 static inline void __init write_extra_features(
u32 u)
147 __asm__(
"mcr p15, 1, %0, c15, c1, 0" : :
"r" (u));
150 static inline int __init cpuid_scheme(
void)
155 static inline u32 __init read_mmfr3(
void)
159 __asm__(
"mrc p15, 0, %0, c0, c1, 7\n" :
"=r" (mmfr3));
164 static inline u32 __init read_actlr(
void)
168 __asm__(
"mrc p15, 0, %0, c1, c0, 1\n" :
"=r" (actlr));
173 static inline void __init write_actlr(
u32 actlr)
175 __asm__(
"mcr p15, 0, %0, c1, c0, 1\n" : :
"r" (actlr));
178 static void enable_extra_feature(
unsigned int features)
182 u = read_extra_features();
189 (features & CACHE_TAUROS2_PREFETCH_ON)
190 ?
"Enabling" :
"Disabling");
197 (features & CACHE_TAUROS2_LINEFILL_BURST8)
198 ?
"Enabling" :
"Disabling");
200 write_extra_features(u);
203 static void __init tauros2_internal_init(
unsigned int features)
207 enable_extra_feature(features);
209 #ifdef CONFIG_CPU_32v5
217 feat = read_extra_features();
218 if (!(feat & 0x00400000)) {
220 write_extra_features(feat | 0x00400000);
224 outer_cache.inv_range = tauros2_inv_range;
225 outer_cache.clean_range = tauros2_clean_range;
226 outer_cache.flush_range = tauros2_flush_range;
227 outer_cache.disable = tauros2_disable;
228 outer_cache.resume = tauros2_resume;
232 #ifdef CONFIG_CPU_32v6
239 if (cpuid_scheme() && (read_mmfr3() & 0xf) == 0) {
245 if (!(get_cr() & 0x04000000)) {
251 outer_cache.inv_range = tauros2_inv_range;
252 outer_cache.clean_range = tauros2_clean_range;
253 outer_cache.flush_range = tauros2_flush_range;
254 outer_cache.disable = tauros2_disable;
255 outer_cache.resume = tauros2_resume;
259 #ifdef CONFIG_CPU_32v7
272 if (cpuid_scheme() && (read_mmfr3() & 0xf) == 1) {
281 actlr = read_actlr();
282 if (!(actlr & 0x00000002)) {
284 write_actlr(actlr | 0x00000002);
297 "in %s mode.\n", mode);
302 { .compatible =
"marvell,tauros2-cache"},
316 pr_info(
"Not found marvell,tauros2-cache, disable it\n");
320 ret = of_property_read_u32(node,
"marvell,tauros2-cache-features", &f);
322 pr_info(
"Not found marvell,tauros-cache-features property, "
323 "disable extra features\n");
328 tauros2_internal_init(features);