17 #include <asm/cacheflush.h>
39 static inline unsigned long l2_get_va(
unsigned long paddr)
50 return (
unsigned long)vaddr + (paddr & ~
PAGE_MASK);
56 static inline void l2_put_va(
unsigned long vaddr)
63 static inline void l2_clean_pa(
unsigned long addr)
65 __asm__(
"mcr p15, 1, %0, c15, c9, 3" : :
"r" (addr));
68 static inline void l2_clean_pa_range(
unsigned long start,
unsigned long end)
79 va_start = l2_get_va(start);
80 va_end = va_start + (end -
start);
82 __asm__(
"mcr p15, 1, %0, c15, c9, 4\n\t"
83 "mcr p15, 1, %1, c15, c9, 5"
84 : :
"r" (va_start),
"r" (va_end));
89 static inline void l2_clean_inv_pa(
unsigned long addr)
91 __asm__(
"mcr p15, 1, %0, c15, c10, 3" : :
"r" (addr));
94 static inline void l2_inv_pa(
unsigned long addr)
96 __asm__(
"mcr p15, 1, %0, c15, c11, 3" : :
"r" (addr));
99 static inline void l2_inv_pa_range(
unsigned long start,
unsigned long end)
110 va_start = l2_get_va(start);
111 va_end = va_start + (end -
start);
113 __asm__(
"mcr p15, 1, %0, c15, c11, 4\n\t"
114 "mcr p15, 1, %1, c15, c11, 5"
115 : :
"r" (va_start),
"r" (va_end));
120 static inline void l2_inv_all(
void)
122 __asm__(
"mcr p15, 1, %0, c15, c11, 0" : :
"r" (0));
132 #define CACHE_LINE_SIZE 32
133 #define MAX_RANGE_SIZE 1024
135 static int l2_wt_override;
137 static unsigned long calc_range_end(
unsigned long start,
unsigned long end)
139 unsigned long range_end;
160 if (range_end > (start | (
PAGE_SIZE - 1)) + 1)
161 range_end = (start | (
PAGE_SIZE - 1)) + 1;
166 static void feroceon_l2_inv_range(
unsigned long start,
unsigned long end)
187 while (start < end) {
188 unsigned long range_end = calc_range_end(start, end);
196 static void feroceon_l2_clean_range(
unsigned long start,
unsigned long end)
202 if (!l2_wt_override) {
205 while (start != end) {
206 unsigned long range_end = calc_range_end(start, end);
215 static void feroceon_l2_flush_range(
unsigned long start,
unsigned long end)
219 while (start != end) {
220 unsigned long range_end = calc_range_end(start, end);
236 static int __init flush_and_disable_dcache(
void)
261 static void __init __invalidate_icache(
void)
263 __asm__(
"mcr p15, 0, %0, c7, c5, 0" : :
"r" (0));
266 static int __init invalidate_and_disable_icache(
void)
273 __invalidate_icache();
287 static inline u32 read_extra_features(
void)
291 __asm__(
"mrc p15, 1, %0, c15, c1, 0" :
"=r" (u));
296 static inline void write_extra_features(
u32 u)
298 __asm__(
"mcr p15, 1, %0, c15, c1, 0" : :
"r" (u));
301 static void __init disable_l2_prefetch(
void)
309 u = read_extra_features();
310 if (!(u & 0x01000000)) {
312 write_extra_features(u | 0x01000000);
316 static void __init enable_l2(
void)
320 u = read_extra_features();
321 if (!(u & 0x00400000)) {
326 d = flush_and_disable_dcache();
327 i = invalidate_and_disable_icache();
329 write_extra_features(u | 0x00400000);
339 l2_wt_override = __l2_wt_override;
341 disable_l2_prefetch();
343 outer_cache.inv_range = feroceon_l2_inv_range;
344 outer_cache.clean_range = feroceon_l2_clean_range;
345 outer_cache.flush_range = feroceon_l2_flush_range;
350 l2_wt_override ?
", in WT override mode" :
"");