| 1 |
/* |
|---|
| 2 |
* This file is subject to the terms and conditions of the GNU General Public |
|---|
| 3 |
* License. See the file "COPYING" in the main directory of this archive |
|---|
| 4 |
* for more details. |
|---|
| 5 |
* |
|---|
| 6 |
* Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) |
|---|
| 7 |
* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Ralf Baechle (ralf@gnu.org) |
|---|
| 8 |
* Copyright (C) 1999, 2000 Silicon Graphics, Inc. |
|---|
| 9 |
*/ |
|---|
| 10 |
#include <linux/init.h> |
|---|
| 11 |
#include <linux/kernel.h> |
|---|
| 12 |
#include <linux/sched.h> |
|---|
| 13 |
#include <linux/mm.h> |
|---|
| 14 |
#include <linux/bitops.h> |
|---|
| 15 |
|
|---|
| 16 |
#include <asm/bcache.h> |
|---|
| 17 |
#include <asm/bootinfo.h> |
|---|
| 18 |
#include <asm/cache.h> |
|---|
| 19 |
#include <asm/cacheops.h> |
|---|
| 20 |
#include <asm/cpu.h> |
|---|
| 21 |
#include <asm/cpu-features.h> |
|---|
| 22 |
#include <asm/io.h> |
|---|
| 23 |
#include <asm/page.h> |
|---|
| 24 |
#include <asm/pgtable.h> |
|---|
| 25 |
#include <asm/r4kcache.h> |
|---|
| 26 |
#include <asm/sections.h> |
|---|
| 27 |
#include <asm/system.h> |
|---|
| 28 |
#include <asm/mmu_context.h> |
|---|
| 29 |
#include <asm/war.h> |
|---|
| 30 |
#include <asm/cacheflush.h> /* for run_uncached() */ |
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
/* |
|---|
| 34 |
* Special Variant of smp_call_function for use by cache functions: |
|---|
| 35 |
* |
|---|
| 36 |
* o No return value |
|---|
| 37 |
* o collapses to normal function call on UP kernels |
|---|
| 38 |
* o collapses to normal function call on systems with a single shared |
|---|
| 39 |
* primary cache. |
|---|
| 40 |
*/ |
|---|
| 41 |
static inline void r4k_on_each_cpu(void (*func) (void *info), void *info, |
|---|
| 42 |
int retry, int wait) |
|---|
| 43 |
{ |
|---|
| 44 |
preempt_disable(); |
|---|
| 45 |
|
|---|
| 46 |
#if !defined(CONFIG_MIPS_MT_SMP) && !defined(CONFIG_MIPS_MT_SMTC) |
|---|
| 47 |
smp_call_function(func, info, retry, wait); |
|---|
| 48 |
#endif |
|---|
| 49 |
func(info); |
|---|
| 50 |
preempt_enable(); |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
/* |
|---|
| 54 |
* Must die. |
|---|
| 55 |
*/ |
|---|
| 56 |
static unsigned long icache_size __read_mostly; |
|---|
| 57 |
static unsigned long dcache_size __read_mostly; |
|---|
| 58 |
static unsigned long scache_size __read_mostly; |
|---|
| 59 |
|
|---|
| 60 |
/* |
|---|
| 61 |
* Dummy cache handling routines for machines without boardcaches |
|---|
| 62 |
*/ |
|---|
| 63 |
static void cache_noop(void) {} |
|---|
| 64 |
|
|---|
| 65 |
static struct bcache_ops no_sc_ops = { |
|---|
| 66 |
.bc_enable = (void *)cache_noop, |
|---|
| 67 |
.bc_disable = (void *)cache_noop, |
|---|
| 68 |
.bc_wback_inv = (void *)cache_noop, |
|---|
| 69 |
.bc_inv = (void *)cache_noop |
|---|
| 70 |
}; |
|---|
| 71 |
|
|---|
| 72 |
struct bcache_ops *bcops = &no_sc_ops; |
|---|
| 73 |
|
|---|
| 74 |
#define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010) |
|---|
| 75 |
#define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020) |
|---|
| 76 |
|
|---|
| 77 |
#define R4600_HIT_CACHEOP_WAR_IMPL \ |
|---|
| 78 |
do { \ |
|---|
| 79 |
if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x()) \ |
|---|
| 80 |
*(volatile unsigned long *)CKSEG1; \ |
|---|
| 81 |
if (R4600_V1_HIT_CACHEOP_WAR) \ |
|---|
| 82 |
__asm__ __volatile__("nop;nop;nop;nop"); \ |
|---|
| 83 |
} while (0) |
|---|
| 84 |
|
|---|
| 85 |
static void (*r4k_blast_dcache_page)(unsigned long addr); |
|---|
| 86 |
|
|---|
| 87 |
static inline void r4k_blast_dcache_page_dc32(unsigned long addr) |
|---|
| 88 |
{ |
|---|
| 89 |
R4600_HIT_CACHEOP_WAR_IMPL; |
|---|
| 90 |
blast_dcache32_page(addr); |
|---|
| 91 |
} |
|---|
| 92 |
|
|---|
| 93 |
static void __init r4k_blast_dcache_page_setup(void) |
|---|
| 94 |
{ |
|---|
| 95 |
unsigned long dc_lsize = cpu_dcache_line_size(); |
|---|
| 96 |
|
|---|
| 97 |
if (dc_lsize == 0) |
|---|
| 98 |
r4k_blast_dcache_page = (void *)cache_noop; |
|---|
| 99 |
else if (dc_lsize == 16) |
|---|
| 100 |
r4k_blast_dcache_page = blast_dcache16_page; |
|---|
| 101 |
else if (dc_lsize == 32) |
|---|
| 102 |
r4k_blast_dcache_page = r4k_blast_dcache_page_dc32; |
|---|
| 103 |
} |
|---|
| 104 |
|
|---|
| 105 |
static void (* r4k_blast_dcache_page_indexed)(unsigned long addr); |
|---|
| 106 |
|
|---|
| 107 |
static void __init r4k_blast_dcache_page_indexed_setup(void) |
|---|
| 108 |
{ |
|---|
| 109 |
unsigned long dc_lsize = cpu_dcache_line_size(); |
|---|
| 110 |
|
|---|
| 111 |
if (dc_lsize == 0) |
|---|
| 112 |
r4k_blast_dcache_page_indexed = (void *)cache_noop; |
|---|
| 113 |
else if (dc_lsize == 16) |
|---|
| 114 |
r4k_blast_dcache_page_indexed = blast_dcache16_page_indexed; |
|---|
| 115 |
else if (dc_lsize == 32) |
|---|
| 116 |
r4k_blast_dcache_page_indexed = blast_dcache32_page_indexed; |
|---|
| 117 |
} |
|---|
| 118 |
|
|---|
| 119 |
static void (* r4k_blast_dcache)(void); |
|---|
| 120 |
|
|---|
| 121 |
static void __init r4k_blast_dcache_setup(void) |
|---|
| 122 |
{ |
|---|
| 123 |
unsigned long dc_lsize = cpu_dcache_line_size(); |
|---|
| 124 |
|
|---|
| 125 |
if (dc_lsize == 0) |
|---|
| 126 |
r4k_blast_dcache = (void *)cache_noop; |
|---|
| 127 |
else if (dc_lsize == 16) |
|---|
| 128 |
r4k_blast_dcache = blast_dcache16; |
|---|
| 129 |
else if (dc_lsize == 32) |
|---|
| 130 |
r4k_blast_dcache = blast_dcache32; |
|---|
| 131 |
} |
|---|
| 132 |
|
|---|
| 133 |
/* force code alignment (used for TX49XX_ICACHE_INDEX_INV_WAR) */ |
|---|
| 134 |
#define JUMP_TO_ALIGN(order) \ |
|---|
| 135 |
__asm__ __volatile__( \ |
|---|
| 136 |
"b\t1f\n\t" \ |
|---|
| 137 |
".align\t" #order "\n\t" \ |
|---|
| 138 |
"1:\n\t" \ |
|---|
| 139 |
) |
|---|
| 140 |
#define CACHE32_UNROLL32_ALIGN JUMP_TO_ALIGN(10) /* 32 * 32 = 1024 */ |
|---|
| 141 |
#define CACHE32_UNROLL32_ALIGN2 JUMP_TO_ALIGN(11) |
|---|
| 142 |
|
|---|
| 143 |
static inline void blast_r4600_v1_icache32(void) |
|---|
| 144 |
{ |
|---|
| 145 |
unsigned long flags; |
|---|
| 146 |
|
|---|
| 147 |
local_irq_save(flags); |
|---|
| 148 |
blast_icache32(); |
|---|
| 149 |
local_irq_restore(flags); |
|---|
| 150 |
} |
|---|
| 151 |
|
|---|
| 152 |
static inline void tx49_blast_icache32(void) |
|---|
| 153 |
{ |
|---|
| 154 |
unsigned long start = INDEX_BASE; |
|---|
| 155 |
unsigned long end = start + current_cpu_data.icache.waysize; |
|---|
| 156 |
unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit; |
|---|
| 157 |
unsigned long ws_end = current_cpu_data.icache.ways << |
|---|
| 158 |
current_cpu_data.icache.waybit; |
|---|
| 159 |
unsigned long ws, addr; |
|---|
| 160 |
|
|---|
| 161 |
CACHE32_UNROLL32_ALIGN2; |
|---|
| 162 |
/* I'm in even chunk. blast odd chunks */ |
|---|
| 163 |
for (ws = 0; ws < ws_end; ws += ws_inc) |
|---|
| 164 |
for (addr = start + 0x400; addr < end; addr += 0x400 * 2) |
|---|
| 165 |
cache32_unroll32(addr|ws,Index_Invalidate_I); |
|---|
| 166 |
CACHE32_UNROLL32_ALIGN; |
|---|
| 167 |
/* I'm in odd chunk. blast even chunks */ |
|---|
| 168 |
for (ws = 0; ws < ws_end; ws += ws_inc) |
|---|
| 169 |
for (addr = start; addr < end; addr += 0x400 * 2) |
|---|
| 170 |
cache32_unroll32(addr|ws,Index_Invalidate_I); |
|---|
| 171 |
} |
|---|
| 172 |
|
|---|
| 173 |
static inline void blast_icache32_r4600_v1_page_indexed(unsigned long page) |
|---|
| 174 |
{ |
|---|
| 175 |
unsigned long flags; |
|---|
| 176 |
|
|---|
| 177 |
local_irq_save(flags); |
|---|
| 178 |
blast_icache32_page_indexed(page); |
|---|
| 179 |
local_irq_restore(flags); |
|---|
| 180 |
} |
|---|
| 181 |
|
|---|
| 182 |
static inline void tx49_blast_icache32_page_indexed(unsigned long page) |
|---|
| 183 |
{ |
|---|
| 184 |
unsigned long indexmask = current_cpu_data.icache.waysize - 1; |
|---|
| 185 |
unsigned long start = INDEX_BASE + (page & indexmask); |
|---|
| 186 |
unsigned long end = start + PAGE_SIZE; |
|---|
| 187 |
unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit; |
|---|
| 188 |
unsigned long ws_end = current_cpu_data.icache.ways << |
|---|
| 189 |
current_cpu_data.icache.waybit; |
|---|
| 190 |
unsigned long ws, addr; |
|---|
| 191 |
|
|---|
| 192 |
CACHE32_UNROLL32_ALIGN2; |
|---|
| 193 |
/* I'm in even chunk. blast odd chunks */ |
|---|
| 194 |
for (ws = 0; ws < ws_end; ws += ws_inc) |
|---|
| 195 |
for (addr = start + 0x400; addr < end; addr += 0x400 * 2) |
|---|
| 196 |
cache32_unroll32(addr|ws,Index_Invalidate_I); |
|---|
| 197 |
CACHE32_UNROLL32_ALIGN; |
|---|
| 198 |
/* I'm in odd chunk. blast even chunks */ |
|---|
| 199 |
for (ws = 0; ws < ws_end; ws += ws_inc) |
|---|
| 200 |
for (addr = start; addr < end; addr += 0x400 * 2) |
|---|
| 201 |
cache32_unroll32(addr|ws,Index_Invalidate_I); |
|---|
| 202 |
} |
|---|
| 203 |
|
|---|
| 204 |
static void (* r4k_blast_icache_page)(unsigned long addr); |
|---|
| 205 |
|
|---|
| 206 |
static void __init r4k_blast_icache_page_setup(void) |
|---|
| 207 |
{ |
|---|
| 208 |
unsigned long ic_lsize = cpu_icache_line_size(); |
|---|
| 209 |
|
|---|
| 210 |
if (ic_lsize == 0) |
|---|
| 211 |
r4k_blast_icache_page = (void *)cache_noop; |
|---|
| 212 |
else if (ic_lsize == 16) |
|---|
| 213 |
r4k_blast_icache_page = blast_icache16_page; |
|---|
| 214 |
else if (ic_lsize == 32) |
|---|
| 215 |
r4k_blast_icache_page = blast_icache32_page; |
|---|
| 216 |
else if (ic_lsize == 64) |
|---|
| 217 |
r4k_blast_icache_page = blast_icache64_page; |
|---|
| 218 |
} |
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 |
static void (* r4k_blast_icache_page_indexed)(unsigned long addr); |
|---|
| 222 |
|
|---|
| 223 |
static void __init r4k_blast_icache_page_indexed_setup(void) |
|---|
| 224 |
{ |
|---|
| 225 |
unsigned long ic_lsize = cpu_icache_line_size(); |
|---|
| 226 |
|
|---|
| 227 |
if (ic_lsize == 0) |
|---|
| 228 |
r4k_blast_icache_page_indexed = (void *)cache_noop; |
|---|
| 229 |
else if (ic_lsize == 16) |
|---|
| 230 |
r4k_blast_icache_page_indexed = blast_icache16_page_indexed; |
|---|
| 231 |
else if (ic_lsize == 32) { |
|---|
| 232 |
if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x()) |
|---|
| 233 |
r4k_blast_icache_page_indexed = |
|---|
| 234 |
blast_icache32_r4600_v1_page_indexed; |
|---|
| 235 |
else if (TX49XX_ICACHE_INDEX_INV_WAR) |
|---|
| 236 |
r4k_blast_icache_page_indexed = |
|---|
| 237 |
tx49_blast_icache32_page_indexed; |
|---|
| 238 |
else |
|---|
| 239 |
r4k_blast_icache_page_indexed = |
|---|
| 240 |
blast_icache32_page_indexed; |
|---|
| 241 |
} else if (ic_lsize == 64) |
|---|
| 242 |
r4k_blast_icache_page_indexed = blast_icache64_page_indexed; |
|---|
| 243 |
} |
|---|
| 244 |
|
|---|
| 245 |
static void (* r4k_blast_icache)(void); |
|---|
| 246 |
|
|---|
| 247 |
static void __init r4k_blast_icache_setup(void) |
|---|
| 248 |
{ |
|---|
| 249 |
unsigned long ic_lsize = cpu_icache_line_size(); |
|---|
| 250 |
|
|---|
| 251 |
if (ic_lsize == 0) |
|---|
| 252 |
r4k_blast_icache = (void *)cache_noop; |
|---|
| 253 |
else if (ic_lsize == 16) |
|---|
| 254 |
r4k_blast_icache = blast_icache16; |
|---|
| 255 |
else if (ic_lsize == 32) { |
|---|
| 256 |
if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x()) |
|---|
| 257 |
r4k_blast_icache = blast_r4600_v1_icache32; |
|---|
| 258 |
else if (TX49XX_ICACHE_INDEX_INV_WAR) |
|---|
| 259 |
r4k_blast_icache = tx49_blast_icache32; |
|---|
| 260 |
else |
|---|
| 261 |
r4k_blast_icache = blast_icache32; |
|---|
| 262 |
} else if (ic_lsize == 64) |
|---|
| 263 |
r4k_blast_icache = blast_icache64; |
|---|
| 264 |
} |
|---|
| 265 |
|
|---|
| 266 |
static void (* r4k_blast_scache_page)(unsigned long addr); |
|---|
| 267 |
|
|---|
| 268 |
static void __init r4k_blast_scache_page_setup(void) |
|---|
| 269 |
{ |
|---|
| 270 |
unsigned long sc_lsize = cpu_scache_line_size(); |
|---|
| 271 |
|
|---|
| 272 |
if (scache_size == 0) |
|---|
| 273 |
r4k_blast_scache_page = (void *)cache_noop; |
|---|
| 274 |
else if (sc_lsize == 16) |
|---|
| 275 |
r4k_blast_scache_page = blast_scache16_page; |
|---|
| 276 |
else if (sc_lsize == 32) |
|---|
| 277 |
r4k_blast_scache_page = blast_scache32_page; |
|---|
| 278 |
else if (sc_lsize == 64) |
|---|
| 279 |
r4k_blast_scache_page = blast_scache64_page; |
|---|
| 280 |
else if (sc_lsize == 128) |
|---|
| 281 |
r4k_blast_scache_page = blast_scache128_page; |
|---|
| 282 |
} |
|---|
| 283 |
|
|---|
| 284 |
static void (* r4k_blast_scache_page_indexed)(unsigned long addr); |
|---|
| 285 |
|
|---|
| 286 |
static void __init r4k_blast_scache_page_indexed_setup(void) |
|---|
| 287 |
{ |
|---|
| 288 |
unsigned long sc_lsize = cpu_scache_line_size(); |
|---|
| 289 |
|
|---|
| 290 |
if (scache_size == 0) |
|---|
| 291 |
r4k_blast_scache_page_indexed = (void *)cache_noop; |
|---|
| 292 |
else if (sc_lsize == 16) |
|---|
| 293 |
r4k_blast_scache_page_indexed = blast_scache16_page_indexed; |
|---|
| 294 |
else if (sc_lsize == 32) |
|---|
| 295 |
r4k_blast_scache_page_indexed = blast_scache32_page_indexed; |
|---|
| 296 |
else if (sc_lsize == 64) |
|---|
| 297 |
r4k_blast_scache_page_indexed = blast_scache64_page_indexed; |
|---|
| 298 |
else if (sc_lsize == 128) |
|---|
| 299 |
r4k_blast_scache_page_indexed = blast_scache128_page_indexed; |
|---|
| 300 |
} |
|---|
| 301 |
|
|---|
| 302 |
static void (* r4k_blast_scache)(void); |
|---|
| 303 |
|
|---|
| 304 |
static void __init r4k_blast_scache_setup(void) |
|---|
| 305 |
{ |
|---|
| 306 |
unsigned long sc_lsize = cpu_scache_line_size(); |
|---|
| 307 |
|
|---|
| 308 |
if (scache_size == 0) |
|---|
| 309 |
r4k_blast_scache = (void *)cache_noop; |
|---|
| 310 |
else if (sc_lsize == 16) |
|---|
| 311 |
r4k_blast_scache = blast_scache16; |
|---|
| 312 |
else if (sc_lsize == 32) |
|---|
| 313 |
r4k_blast_scache = blast_scache32; |
|---|
| 314 |
else if (sc_lsize == 64) |
|---|
| 315 |
r4k_blast_scache = blast_scache64; |
|---|
| 316 |
else if (sc_lsize == 128) |
|---|
| 317 |
r4k_blast_scache = blast_scache128; |
|---|
| 318 |
} |
|---|
| 319 |
|
|---|
| 320 |
/* |
|---|
| 321 |
* This is former mm's flush_cache_all() which really should be |
|---|
| 322 |
* flush_cache_vunmap these days ... |
|---|
| 323 |
*/ |
|---|
| 324 |
static inline void local_r4k_flush_cache_all(void * args) |
|---|
| 325 |
{ |
|---|
| 326 |
r4k_blast_dcache(); |
|---|
| 327 |
} |
|---|
| 328 |
|
|---|
| 329 |
static void r4k_flush_cache_all(void) |
|---|
| 330 |
{ |
|---|
| 331 |
if (!cpu_has_dc_aliases) |
|---|
| 332 |
return; |
|---|
| 333 |
|
|---|
| 334 |
r4k_on_each_cpu(local_r4k_flush_cache_all, NULL, 1, 1); |
|---|
| 335 |
} |
|---|
| 336 |
|
|---|
| 337 |
static inline void local_r4k___flush_cache_all(void * args) |
|---|
| 338 |
{ |
|---|
| 339 |
#if defined(CONFIG_CPU_LOONGSON2) |
|---|
| 340 |
r4k_blast_scache(); |
|---|
| 341 |
return; |
|---|
| 342 |
#endif |
|---|
| 343 |
r4k_blast_dcache(); |
|---|
| 344 |
r4k_blast_icache(); |
|---|
| 345 |
|
|---|
| 346 |
switch (current_cpu_data.cputype) { |
|---|
| 347 |
case CPU_R4000SC: |
|---|
| 348 |
case CPU_R4000MC: |
|---|
| 349 |
case CPU_R4400SC: |
|---|
| 350 |
case CPU_R4400MC: |
|---|
| 351 |
case CPU_R10000: |
|---|
| 352 |
case CPU_R12000: |
|---|
| 353 |
case CPU_R14000: |
|---|
| 354 |
r4k_blast_scache(); |
|---|
| 355 |
} |
|---|
| 356 |
} |
|---|
| 357 |
|
|---|
| 358 |
static void r4k___flush_cache_all(void) |
|---|
| 359 |
{ |
|---|
| 360 |
r4k_on_each_cpu(local_r4k___flush_cache_all, NULL, 1, 1); |
|---|
| 361 |
} |
|---|
| 362 |
|
|---|
| 363 |
static inline int has_valid_asid(const struct mm_struct *mm) |
|---|
| 364 |
{ |
|---|
| 365 |
#if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_MIPS_MT_SMTC) |
|---|
| 366 |
int i; |
|---|
| 367 |
|
|---|
| 368 |
for_each_online_cpu(i) |
|---|
| 369 |
if (cpu_context(i, mm)) |
|---|
| 370 |
return 1; |
|---|
| 371 |
|
|---|
| 372 |
return 0; |
|---|
| 373 |
#else |
|---|
| 374 |
return cpu_context(smp_processor_id(), mm); |
|---|
| 375 |
#endif |
|---|
| 376 |
} |
|---|
| 377 |
|
|---|
| 378 |
static inline void local_r4k_flush_cache_range(void * args) |
|---|
| 379 |
{ |
|---|
| 380 |
struct vm_area_struct *vma = args; |
|---|
| 381 |
int exec = vma->vm_flags & VM_EXEC; |
|---|
| 382 |
|
|---|
| 383 |
if (!(has_valid_asid(vma->vm_mm))) |
|---|
| 384 |
return; |
|---|
| 385 |
|
|---|
| 386 |
r4k_blast_dcache(); |
|---|
| 387 |
if (exec) |
|---|
| 388 |
r4k_blast_icache(); |
|---|
| 389 |
} |
|---|
| 390 |
|
|---|
| 391 |
static void r4k_flush_cache_range(struct vm_area_struct *vma, |
|---|
| 392 |
unsigned long start, unsigned long end) |
|---|
| 393 |
{ |
|---|
| 394 |
int exec = vma->vm_flags & VM_EXEC; |
|---|
| 395 |
|
|---|
| 396 |
if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) |
|---|
| 397 |
r4k_on_each_cpu(local_r4k_flush_cache_range, vma, 1, 1); |
|---|
| 398 |
} |
|---|
| 399 |
|
|---|
| 400 |
static inline void local_r4k_flush_cache_mm(void * args) |
|---|
| 401 |
{ |
|---|
| 402 |
struct mm_struct *mm = args; |
|---|
| 403 |
|
|---|
| 404 |
if (!has_valid_asid(mm)) |
|---|
| 405 |
return; |
|---|
| 406 |
|
|---|
| 407 |
/* |
|---|
| 408 |
* Kludge alert. For obscure reasons R4000SC and R4400SC go nuts if we |
|---|
| 409 |
* only flush the primary caches but R10000 and R12000 behave sane ... |
|---|
| 410 |
* R4000SC and R4400SC indexed S-cache ops also invalidate primary |
|---|
| 411 |
* caches, so we can bail out early. |
|---|
| 412 |
*/ |
|---|
| 413 |
if (current_cpu_data.cputype == CPU_R4000SC || |
|---|
| 414 |
current_cpu_data.cputype == CPU_R4000MC || |
|---|
| 415 |
current_cpu_data.cputype == CPU_R4400SC || |
|---|
| 416 |
current_cpu_data.cputype == CPU_R4400MC) { |
|---|
| 417 |
r4k_blast_scache(); |
|---|
| 418 |
return; |
|---|
| 419 |
} |
|---|
| 420 |
|
|---|
| 421 |
r4k_blast_dcache(); |
|---|
| 422 |
} |
|---|
| 423 |
|
|---|
| 424 |
static void r4k_flush_cache_mm(struct mm_struct *mm) |
|---|
| 425 |
{ |
|---|
| 426 |
if (!cpu_has_dc_aliases) |
|---|
| 427 |
return; |
|---|
| 428 |
|
|---|
| 429 |
r4k_on_each_cpu(local_r4k_flush_cache_mm, mm, 1, 1); |
|---|
| 430 |
} |
|---|
| 431 |
|
|---|
| 432 |
struct flush_cache_page_args { |
|---|
| 433 |
struct vm_area_struct *vma; |
|---|
| 434 |
unsigned long addr; |
|---|
| 435 |
unsigned long pfn; |
|---|
| 436 |
}; |
|---|
| 437 |
|
|---|
| 438 |
static inline void local_r4k_flush_cache_page(void *args) |
|---|
| 439 |
{ |
|---|
| 440 |
struct flush_cache_page_args *fcp_args = args; |
|---|
| 441 |
struct vm_area_struct *vma = fcp_args->vma; |
|---|
| 442 |
unsigned long addr = fcp_args->addr; |
|---|
| 443 |
unsigned long paddr = fcp_args->pfn << PAGE_SHIFT; |
|---|
| 444 |
int exec = vma->vm_flags & VM_EXEC; |
|---|
| 445 |
struct mm_struct *mm = vma->vm_mm; |
|---|
| 446 |
pgd_t *pgdp; |
|---|
| 447 |
pud_t *pudp; |
|---|
| 448 |
pmd_t *pmdp; |
|---|
| 449 |
pte_t *ptep; |
|---|
| 450 |
|
|---|
| 451 |
/* |
|---|
| 452 |
* If ownes no valid ASID yet, cannot possibly have gotten |
|---|
| 453 |
* this page into the cache. |
|---|
| 454 |
*/ |
|---|
| 455 |
if (!has_valid_asid(mm)) |
|---|
| 456 |
return; |
|---|
| 457 |
|
|---|
| 458 |
addr &= PAGE_MASK; |
|---|
| 459 |
pgdp = pgd_offset(mm, addr); |
|---|
| 460 |
pudp = pud_offset(pgdp, addr); |
|---|
| 461 |
pmdp = pmd_offset(pudp, addr); |
|---|
| 462 |
ptep = pte_offset(pmdp, addr); |
|---|
| 463 |
|
|---|
| 464 |
/* |
|---|
| 465 |
* If the page isn't marked valid, the page cannot possibly be |
|---|
| 466 |
* in the cache. |
|---|
| 467 |
*/ |
|---|
| 468 |
if (!(pte_val(*ptep) & _PAGE_PRESENT)) |
|---|
| 469 |
return; |
|---|
| 470 |
|
|---|
| 471 |
/* |
|---|
| 472 |
* Doing flushes for another ASID than the current one is |
|---|
| 473 |
* too difficult since stupid R4k caches do a TLB translation |
|---|
| 474 |
* for every cache flush operation. So we do indexed flushes |
|---|
| 475 |
* in that case, which doesn't overly flush the cache too much. |
|---|
| 476 |
*/ |
|---|
| 477 |
if ((mm == current->active_mm) && (pte_val(*ptep) & _PAGE_VALID)) { |
|---|
| 478 |
if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) { |
|---|
| 479 |
r4k_blast_dcache_page(addr); |
|---|
| 480 |
if (exec && !cpu_icache_snoops_remote_store) |
|---|
| 481 |
r4k_blast_scache_page(addr); |
|---|
| 482 |
} |
|---|
| 483 |
if (exec) |
|---|
| 484 |
r4k_blast_icache_page(addr); |
|---|
| 485 |
|
|---|
| 486 |
return; |
|---|
| 487 |
} |
|---|
| 488 |
|
|---|
| 489 |
/* |
|---|
| 490 |
* Do indexed flush, too much work to get the (possible) TLB refills |
|---|
| 491 |
* to work correctly. |
|---|
| 492 |
*/ |
|---|
| 493 |
if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) { |
|---|
| 494 |
r4k_blast_dcache_page_indexed(cpu_has_pindexed_dcache ? |
|---|
| 495 |
paddr : addr); |
|---|
| 496 |
if (exec && !cpu_icache_snoops_remote_store) { |
|---|
| 497 |
r4k_blast_scache_page_indexed(paddr); |
|---|
| 498 |
} |
|---|
| 499 |
} |
|---|
| 500 |
if (exec) { |
|---|
| 501 |
if (cpu_has_vtag_icache && mm == current->active_mm) { |
|---|
| 502 |
int cpu = smp_processor_id(); |
|---|
| 503 |
|
|---|
| 504 |
if (cpu_context(cpu, mm) != 0) |
|---|
| 505 |
drop_mmu_context(mm, cpu); |
|---|
| 506 |
} else |
|---|
| 507 |
r4k_blast_icache_page_indexed(addr); |
|---|
| 508 |
} |
|---|
| 509 |
} |
|---|
| 510 |
|
|---|
| 511 |
static void r4k_flush_cache_page(struct vm_area_struct *vma, |
|---|
| 512 |
unsigned long addr, unsigned long pfn) |
|---|
| 513 |
{ |
|---|
| 514 |
struct flush_cache_page_args args; |
|---|
| 515 |
|
|---|
| 516 |
args.vma = vma; |
|---|
| 517 |
args.addr = addr; |
|---|
| 518 |
args.pfn = pfn; |
|---|
| 519 |
|
|---|
| 520 |
r4k_on_each_cpu(local_r4k_flush_cache_page, &args, 1, 1); |
|---|
| 521 |
} |
|---|
| 522 |
|
|---|
| 523 |
static inline void local_r4k_flush_data_cache_page(void * addr) |
|---|
| 524 |
{ |
|---|
| 525 |
r4k_blast_dcache_page((unsigned long) addr); |
|---|
| 526 |
} |
|---|
| 527 |
|
|---|
| 528 |
static void r4k_flush_data_cache_page(unsigned long addr) |
|---|
| 529 |
{ |
|---|
| 530 |
r4k_on_each_cpu(local_r4k_flush_data_cache_page, (void *) addr, 1, 1); |
|---|
| 531 |
} |
|---|
| 532 |
|
|---|
| 533 |
struct flush_icache_range_args { |
|---|
| 534 |
unsigned long start; |
|---|
| 535 |
unsigned long end; |
|---|
| 536 |
}; |
|---|
| 537 |
|
|---|
| 538 |
static inline void local_r4k_flush_icache_range(void *args) |
|---|
| 539 |
{ |
|---|
| 540 |
struct flush_icache_range_args *fir_args = args; |
|---|
| 541 |
unsigned long start = fir_args->start; |
|---|
| 542 |
unsigned long end = fir_args->end; |
|---|
| 543 |
|
|---|
| 544 |
if (!cpu_has_ic_fills_f_dc) { |
|---|
| 545 |
if (end - start >= dcache_size) { |
|---|
| 546 |
r4k_blast_dcache(); |
|---|
| 547 |
} else { |
|---|
| 548 |
R4600_HIT_CACHEOP_WAR_IMPL; |
|---|
| 549 |
protected_blast_dcache_range(start, end); |
|---|
| 550 |
} |
|---|
| 551 |
|
|---|
| 552 |
if (!cpu_icache_snoops_remote_store && scache_size) { |
|---|
| 553 |
if (end - start > scache_size) |
|---|
| 554 |
r4k_blast_scache(); |
|---|
| 555 |
else |
|---|
| 556 |
protected_blast_scache_range(start, end); |
|---|
| 557 |
} |
|---|
| 558 |
} |
|---|
| 559 |
|
|---|
| 560 |
if (end - start > icache_size) |
|---|
| 561 |
r4k_blast_icache(); |
|---|
| 562 |
else |
|---|
| 563 |
protected_blast_icache_range(start, end); |
|---|
| 564 |
} |
|---|
| 565 |
|
|---|
| 566 |
static void r4k_flush_icache_range(unsigned long start, unsigned long end) |
|---|
| 567 |
{ |
|---|
| 568 |
struct flush_icache_range_args args; |
|---|
| 569 |
|
|---|
| 570 |
args.start = start; |
|---|
| 571 |
args.end = end; |
|---|
| 572 |
|
|---|
| 573 |
r4k_on_each_cpu(local_r4k_flush_icache_range, &args, 1, 1); |
|---|
| 574 |
instruction_hazard(); |
|---|
| 575 |
} |
|---|
| 576 |
|
|---|
| 577 |
#ifdef CONFIG_DMA_NONCOHERENT |
|---|
| 578 |
|
|---|
| 579 |
static void r4k_dma_cache_wback_inv(unsigned long addr, unsigned long size) |
|---|
| 580 |
{ |
|---|
| 581 |
/* Catch bad driver code */ |
|---|
| 582 |
BUG_ON(size == 0); |
|---|
| 583 |
|
|---|
| 584 |
if (cpu_has_inclusive_pcaches) { |
|---|
| 585 |
if (size >= scache_size) |
|---|
| 586 |
r4k_blast_scache(); |
|---|
| 587 |
else |
|---|
| 588 |
blast_scache_range(addr, addr + size); |
|---|
| 589 |
return; |
|---|
| 590 |
} |
|---|
| 591 |
|
|---|
| 592 |
/* |
|---|
| 593 |
* Either no secondary cache or the available caches don't have the |
|---|
| 594 |
* subset property so we have to flush the primary caches |
|---|
| 595 |
* explicitly |
|---|
| 596 |
*/ |
|---|
| 597 |
if (size >= dcache_size) { |
|---|
| 598 |
r4k_blast_dcache(); |
|---|
| 599 |
} else { |
|---|
| 600 |
R4600_HIT_CACHEOP_WAR_IMPL; |
|---|
| 601 |
blast_dcache_range(addr, addr + size); |
|---|
| 602 |
} |
|---|
| 603 |
|
|---|
| 604 |
bc_wback_inv(addr, size); |
|---|
| 605 |
} |
|---|
| 606 |
|
|---|
| 607 |
static void r4k_dma_cache_inv(unsigned long addr, unsigned long size) |
|---|
| 608 |
{ |
|---|
| 609 |
/* Catch bad driver code */ |
|---|
| 610 |
BUG_ON(size == 0); |
|---|
| 611 |
|
|---|
| 612 |
if (cpu_has_inclusive_pcaches) { |
|---|
| 613 |
if (size >= scache_size) |
|---|
| 614 |
r4k_blast_scache(); |
|---|
| 615 |
else |
|---|
| 616 |
blast_scache_range(addr, addr + size); |
|---|
| 617 |
return; |
|---|
| 618 |
} |
|---|
| 619 |
|
|---|
| 620 |
if (size >= dcache_size) { |
|---|
| 621 |
r4k_blast_dcache(); |
|---|
| 622 |
} else { |
|---|
| 623 |
R4600_HIT_CACHEOP_WAR_IMPL; |
|---|
| 624 |
blast_dcache_range(addr, addr + size); |
|---|
| 625 |
} |
|---|
| 626 |
|
|---|
| 627 |
bc_inv(addr, size); |
|---|
| 628 |
} |
|---|
| 629 |
#endif /* CONFIG_DMA_NONCOHERENT */ |
|---|
| 630 |
|
|---|
| 631 |
/* |
|---|
| 632 |
* While we're protected against bad userland addresses we don't care |
|---|
| 633 |
* very much about what happens in that case. Usually a segmentation |
|---|
| 634 |
* fault will dump the process later on anyway ... |
|---|
| 635 |
*/ |
|---|
| 636 |
static void local_r4k_flush_cache_sigtramp(void * arg) |
|---|
| 637 |
{ |
|---|
| 638 |
unsigned long ic_lsize = cpu_icache_line_size(); |
|---|
| 639 |
unsigned long dc_lsize = cpu_dcache_line_size(); |
|---|
| 640 |
unsigned long sc_lsize = cpu_scache_line_size(); |
|---|
| 641 |
unsigned long addr = (unsigned long) arg; |
|---|
| 642 |
|
|---|
| 643 |
R4600_HIT_CACHEOP_WAR_IMPL; |
|---|
| 644 |
if (dc_lsize) |
|---|
| 645 |
protected_writeback_dcache_line(addr & ~(dc_lsize - 1)); |
|---|
| 646 |
if (!cpu_icache_snoops_remote_store && scache_size) |
|---|
| 647 |
protected_writeback_scache_line(addr & ~(sc_lsize - 1)); |
|---|
| 648 |
if (ic_lsize) |
|---|
| 649 |
protected_flush_icache_line(addr & ~(ic_lsize - 1)); |
|---|
| 650 |
if (MIPS4K_ICACHE_REFILL_WAR) { |
|---|
| 651 |
__asm__ __volatile__ ( |
|---|
| 652 |
".set push\n\t" |
|---|
| 653 |
".set noat\n\t" |
|---|
| 654 |
".set mips3\n\t" |
|---|
| 655 |
#ifdef CONFIG_32BIT |
|---|
| 656 |
"la $at,1f\n\t" |
|---|
| 657 |
#endif |
|---|
| 658 |
#ifdef CONFIG_64BIT |
|---|
| 659 |
"dla $at,1f\n\t" |
|---|
| 660 |
#endif |
|---|
| 661 |
"cache %0,($at)\n\t" |
|---|
| 662 |
"nop; nop; nop\n" |
|---|
| 663 |
"1:\n\t" |
|---|
| 664 |
".set pop" |
|---|
| 665 |
: |
|---|
| 666 |
: "i" (Hit_Invalidate_I)); |
|---|
| 667 |
} |
|---|
| 668 |
if (MIPS_CACHE_SYNC_WAR) |
|---|
| 669 |
__asm__ __volatile__ ("sync"); |
|---|
| 670 |
} |
|---|
| 671 |
|
|---|
| 672 |
static void r4k_flush_cache_sigtramp(unsigned long addr) |
|---|
| 673 |
{ |
|---|
| 674 |
r4k_on_each_cpu(local_r4k_flush_cache_sigtramp, (void *) addr, 1, 1); |
|---|
| 675 |
} |
|---|
| 676 |
|
|---|
| 677 |
static void r4k_flush_icache_all(void) |
|---|
| 678 |
{ |
|---|
| 679 |
if (cpu_has_vtag_icache) |
|---|
| 680 |
r4k_blast_icache(); |
|---|
| 681 |
} |
|---|
| 682 |
|
|---|
| 683 |
static inline void rm7k_erratum31(void) |
|---|
| 684 |
{ |
|---|
| 685 |
const unsigned long ic_lsize = 32; |
|---|
| 686 |
unsigned long addr; |
|---|
| 687 |
|
|---|
| 688 |
/* RM7000 erratum #31. The icache is screwed at startup. */ |
|---|
| 689 |
write_c0_taglo(0); |
|---|
| 690 |
write_c0_taghi(0); |
|---|
| 691 |
|
|---|
| 692 |
for (addr = INDEX_BASE; addr <= INDEX_BASE + 4096; addr += ic_lsize) { |
|---|
| 693 |
__asm__ __volatile__ ( |
|---|
| 694 |
".set push\n\t" |
|---|
| 695 |
".set noreorder\n\t" |
|---|
| 696 |
".set mips3\n\t" |
|---|
| 697 |
"cache\t%1, 0(%0)\n\t" |
|---|
| 698 |
"cache\t%1, 0x1000(%0)\n\t" |
|---|
| 699 |
"cache\t%1, 0x2000(%0)\n\t" |
|---|
| 700 |
"cache\t%1, 0x3000(%0)\n\t" |
|---|
| 701 |
"cache\t%2, 0(%0)\n\t" |
|---|
| 702 |
"cache\t%2, 0x1000(%0)\n\t" |
|---|
| 703 |
"cache\t%2, 0x2000(%0)\n\t" |
|---|
| 704 |
"cache\t%2, 0x3000(%0)\n\t" |
|---|
| 705 |
"cache\t%1, 0(%0)\n\t" |
|---|
| 706 |
"cache\t%1, 0x1000(%0)\n\t" |
|---|
| 707 |
"cache\t%1, 0x2000(%0)\n\t" |
|---|
| 708 |
"cache\t%1, 0x3000(%0)\n\t" |
|---|
| 709 |
".set pop\n" |
|---|
| 710 |
: |
|---|
| 711 |
: "r" (addr), "i" (Index_Store_Tag_I), "i" (Fill)); |
|---|
| 712 |
} |
|---|
| 713 |
} |
|---|
| 714 |
|
|---|
| 715 |
static char *way_string[] __initdata = { NULL, "direct mapped", "2-way", |
|---|
| 716 |
"3-way", "4-way", "5-way", "6-way", "7-way", "8-way" |
|---|
| 717 |
}; |
|---|
| 718 |
|
|---|
| 719 |
static void __init probe_pcache(void) |
|---|
| 720 |
{ |
|---|
| 721 |
struct cpuinfo_mips *c = ¤t_cpu_data; |
|---|
| 722 |
unsigned int config = read_c0_config(); |
|---|
| 723 |
unsigned int prid = read_c0_prid(); |
|---|
| 724 |
unsigned long config1; |
|---|
| 725 |
unsigned int lsize; |
|---|
| 726 |
|
|---|
| 727 |
switch (c->cputype) { |
|---|
| 728 |
case CPU_R4600: /* QED style two way caches? */ |
|---|
| 729 |
case CPU_R4700: |
|---|
| 730 |
case CPU_R5000: |
|---|
| 731 |
case CPU_NEVADA: |
|---|
| 732 |
icache_size = 1 << (12 + ((config & CONF_IC) >> 9)); |
|---|
| 733 |
c->icache.linesz = 16 << ((config & CONF_IB) >> 5); |
|---|
| 734 |
c->icache.ways = 2; |
|---|
| 735 |
c->icache.waybit = __ffs(icache_size/2); |
|---|
| 736 |
|
|---|
| 737 |
dcache_size = 1 << (12 + ((config & CONF_DC) >> 6)); |
|---|
| 738 |
c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); |
|---|
| 739 |
c->dcache.ways = 2; |
|---|
| 740 |
c->dcache.waybit= __ffs(dcache_size/2); |
|---|
| 741 |
|
|---|
| 742 |
c->options |= MIPS_CPU_CACHE_CDEX_P; |
|---|
| 743 |
break; |
|---|
| 744 |
|
|---|
| 745 |
case CPU_R5432: |
|---|
| 746 |
case CPU_R5500: |
|---|
| 747 |
icache_size = 1 << (12 + ((config & CONF_IC) >> 9)); |
|---|
| 748 |
c->icache.linesz = 16 << ((config & CONF_IB) >> 5); |
|---|
| 749 |
c->icache.ways = 2; |
|---|
| 750 |
c->icache.waybit= 0; |
|---|
| 751 |
|
|---|
| 752 |
dcache_size = 1 << (12 + ((config & CONF_DC) >> 6)); |
|---|
| 753 |
c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); |
|---|
| 754 |
c->dcache.ways = 2; |
|---|
| 755 |
c->dcache.waybit = 0; |
|---|
| 756 |
|
|---|
| 757 |
c->options |= MIPS_CPU_CACHE_CDEX_P; |
|---|
| 758 |
break; |
|---|
| 759 |
|
|---|
| 760 |
case CPU_TX49XX: |
|---|
| 761 |
icache_size = 1 << (12 + ((config & CONF_IC) >> 9)); |
|---|
| 762 |
c->icache.linesz = 16 << ((config & CONF_IB) >> 5); |
|---|
| 763 |
c->icache.ways = 4; |
|---|
| 764 |
c->icache.waybit= 0; |
|---|
| 765 |
|
|---|
| 766 |
dcache_size = 1 << (12 + ((config & CONF_DC) >> 6)); |
|---|
| 767 |
c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); |
|---|
| 768 |
c->dcache.ways = 4; |
|---|
| 769 |
c->dcache.waybit = 0; |
|---|
| 770 |
|
|---|
| 771 |
c->options |= MIPS_CPU_CACHE_CDEX_P; |
|---|
| 772 |
c->options |= MIPS_CPU_PREFETCH; |
|---|
| 773 |
break; |
|---|
| 774 |
|
|---|
| 775 |
case CPU_R4000PC: |
|---|
| 776 |
case CPU_R4000SC: |
|---|
| 777 |
case CPU_R4000MC: |
|---|
| 778 |
case CPU_R4400PC: |
|---|
| 779 |
case CPU_R4400SC: |
|---|
| 780 |
case CPU_R4400MC: |
|---|
| 781 |
case CPU_R4300: |
|---|
| 782 |
icache_size = 1 << (12 + ((config & CONF_IC) >> 9)); |
|---|
| 783 |
c->icache.linesz = 16 << ((config & CONF_IB) >> 5); |
|---|
| 784 |
c->icache.ways = 1; |
|---|
| 785 |
c->icache.waybit = 0; /* doesn't matter */ |
|---|
| 786 |
|
|---|
| 787 |
dcache_size = 1 << (12 + ((config & CONF_DC) >> 6)); |
|---|
| 788 |
c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); |
|---|
| 789 |
c->dcache.ways = 1; |
|---|
| 790 |
c->dcache.waybit = 0; /* does not matter */ |
|---|
| 791 |
|
|---|
| 792 |
c->options |= MIPS_CPU_CACHE_CDEX_P; |
|---|
| 793 |
break; |
|---|
| 794 |
|
|---|
| 795 |
case CPU_R10000: |
|---|
| 796 |
case CPU_R12000: |
|---|
| 797 |
case CPU_R14000: |
|---|
| 798 |
icache_size = 1 << (12 + ((config & R10K_CONF_IC) >> 29)); |
|---|
| 799 |
c->icache.linesz = 64; |
|---|
| 800 |
c->icache.ways = 2; |
|---|
| 801 |
c->icache.waybit = 0; |
|---|
| 802 |
|
|---|
| 803 |
dcache_size = 1 << (12 + ((config & R10K_CONF_DC) >> 26)); |
|---|
| 804 |
c->dcache.linesz = 32; |
|---|
| 805 |
c->dcache.ways = 2; |
|---|
| 806 |
c->dcache.waybit = 0; |
|---|
| 807 |
|
|---|
| 808 |
c->options |= MIPS_CPU_PREFETCH; |
|---|
| 809 |
break; |
|---|
| 810 |
|
|---|
| 811 |
case CPU_VR4133: |
|---|
| 812 |
write_c0_config(config & ~VR41_CONF_P4K); |
|---|
| 813 |
case CPU_VR4131: |
|---|
| 814 |
/* Workaround for cache instruction bug of VR4131 */ |
|---|
| 815 |
if (c->processor_id == 0x0c80U || c->processor_id == 0x0c81U || |
|---|
| 816 |
c->processor_id == 0x0c82U) { |
|---|
| 817 |
config |= 0x00400000U; |
|---|
| 818 |
if (c->processor_id == 0x0c80U) |
|---|
| 819 |
config |= VR41_CONF_BP; |
|---|
| 820 |
write_c0_config(config); |
|---|
| 821 |
} else |
|---|
| 822 |
c->options |= MIPS_CPU_CACHE_CDEX_P; |
|---|
| 823 |
|
|---|
| 824 |
icache_size = 1 << (10 + ((config & CONF_IC) >> 9)); |
|---|
| 825 |
c->icache.linesz = 16 << ((config & CONF_IB) >> 5); |
|---|
| 826 |
c->icache.ways = 2; |
|---|
| 827 |
c->icache.waybit = __ffs(icache_size/2); |
|---|
| 828 |
|
|---|
| 829 |
dcache_size = 1 << (10 + ((config & CONF_DC) >> 6)); |
|---|
| 830 |
c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); |
|---|
| 831 |
c->dcache.ways = 2; |
|---|
| 832 |
c->dcache.waybit = __ffs(dcache_size/2); |
|---|
| 833 |
break; |
|---|
| 834 |
|
|---|
| 835 |
case CPU_VR41XX: |
|---|
| 836 |
case CPU_VR4111: |
|---|
| 837 |
case CPU_VR4121: |
|---|
| 838 |
case CPU_VR4122: |
|---|
| 839 |
case CPU_VR4181: |
|---|
| 840 |
case CPU_VR4181A: |
|---|
| 841 |
icache_size = 1 << (10 + ((config & CONF_IC) >> 9)); |
|---|
| 842 |
c->icache.linesz = 16 << ((config & CONF_IB) >> 5); |
|---|
| 843 |
c->icache.ways = 1; |
|---|
| 844 |
c->icache.waybit = 0; /* doesn't matter */ |
|---|
| 845 |
|
|---|
| 846 |
dcache_size = 1 << (10 + ((config & CONF_DC) >> 6)); |
|---|
| 847 |
c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); |
|---|
| 848 |
c->dcache.ways = 1; |
|---|
| 849 |
c->dcache.waybit = 0; /* does not matter */ |
|---|
| 850 |
|
|---|
| 851 |
c->options |= MIPS_CPU_CACHE_CDEX_P; |
|---|
| 852 |
break; |
|---|
| 853 |
|
|---|
| 854 |
case CPU_RM7000: |
|---|
| 855 |
rm7k_erratum31(); |
|---|
| 856 |
|
|---|
| 857 |
case CPU_RM9000: |
|---|
| 858 |
icache_size = 1 << (12 + ((config & CONF_IC) >> 9)); |
|---|
| 859 |
c->icache.linesz = 16 << ((config & CONF_IB) >> 5); |
|---|
| 860 |
c->icache.ways = 4; |
|---|
| 861 |
c->icache.waybit = __ffs(icache_size / c->icache.ways); |
|---|
| 862 |
|
|---|
| 863 |
dcache_size = 1 << (12 + ((config & CONF_DC) >> 6)); |
|---|
| 864 |
c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); |
|---|
| 865 |
c->dcache.ways = 4; |
|---|
| 866 |
c->dcache.waybit = __ffs(dcache_size / c->dcache.ways); |
|---|
| 867 |
|
|---|
| 868 |
#if !defined(CONFIG_SMP) || !defined(RM9000_CDEX_SMP_WAR) |
|---|
| 869 |
c->options |= MIPS_CPU_CACHE_CDEX_P; |
|---|
| 870 |
#endif |
|---|
| 871 |
c->options |= MIPS_CPU_PREFETCH; |
|---|
| 872 |
break; |
|---|
| 873 |
|
|---|
| 874 |
case CPU_LOONGSON2: |
|---|
| 875 |
icache_size = 1 << (12 + ((config & CONF_IC) >> 9)); |
|---|
| 876 |
c->icache.linesz = 16 << ((config & CONF_IB) >> 5); |
|---|
| 877 |
if (prid & 0x3) |
|---|
| 878 |
c->icache.ways = 4; |
|---|
| 879 |
else |
|---|
| 880 |
c->icache.ways = 2; |
|---|
| 881 |
c->icache.waybit = 0; |
|---|
| 882 |
|
|---|
| 883 |
dcache_size = 1 << (12 + ((config & CONF_DC) >> 6)); |
|---|
| 884 |
c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); |
|---|
| 885 |
if (prid & 0x3) |
|---|
| 886 |
c->dcache.ways = 4; |
|---|
| 887 |
else |
|---|
| 888 |
c->dcache.ways = 2; |
|---|
| 889 |
c->dcache.waybit = 0; |
|---|
| 890 |
break; |
|---|
| 891 |
|
|---|
| 892 |
default: |
|---|
| 893 |
if (!(config & MIPS_CONF_M)) |
|---|
| 894 |
panic("Don't know how to probe P-caches on this cpu."); |
|---|
| 895 |
|
|---|
| 896 |
/* |
|---|
| 897 |
* So we seem to be a MIPS32 or MIPS64 CPU |
|---|
| 898 |
* So let's probe the I-cache ... |
|---|
| 899 |
*/ |
|---|
| 900 |
config1 = read_c0_config1(); |
|---|
| 901 |
|
|---|
| 902 |
if ((lsize = ((config1 >> 19) & 7))) |
|---|
| 903 |
c->icache.linesz = 2 << lsize; |
|---|
| 904 |
else |
|---|
| 905 |
c->icache.linesz = lsize; |
|---|
| 906 |
c->icache.sets = 64 << ((config1 >> 22) & 7); |
|---|
| 907 |
c->icache.ways = 1 + ((config1 >> 16) & 7); |
|---|
| 908 |
|
|---|
| 909 |
icache_size = c->icache.sets * |
|---|
| 910 |
c->icache.ways * |
|---|
| 911 |
c->icache.linesz; |
|---|
| 912 |
c->icache.waybit = __ffs(icache_size/c->icache.ways); |
|---|
| 913 |
|
|---|
| 914 |
if (config & 0x8) /* VI bit */ |
|---|
| 915 |
c->icache.flags |= MIPS_CACHE_VTAG; |
|---|
| 916 |
|
|---|
| 917 |
/* |
|---|
| 918 |
* Now probe the MIPS32 / MIPS64 data cache. |
|---|
| 919 |
*/ |
|---|
| 920 |
c->dcache.flags = 0; |
|---|
| 921 |
|
|---|
| 922 |
if ((lsize = ((config1 >> 10) & 7))) |
|---|
| 923 |
c->dcache.linesz = 2 << lsize; |
|---|
| 924 |
else |
|---|
| 925 |
c->dcache.linesz= lsize; |
|---|
| 926 |
c->dcache.sets = 64 << ((config1 >> 13) & 7); |
|---|
| 927 |
c->dcache.ways = 1 + ((config1 >> 7) & 7); |
|---|
| 928 |
|
|---|
| 929 |
dcache_size = c->dcache.sets * |
|---|
| 930 |
c->dcache.ways * |
|---|
| 931 |
c->dcache.linesz; |
|---|
| 932 |
c->dcache.waybit = __ffs(dcache_size/c->dcache.ways); |
|---|
| 933 |
|
|---|
| 934 |
#ifdef CONFIG_CPU_HAS_PREFETCH |
|---|
| 935 |
c->options |= MIPS_CPU_PREFETCH; |
|---|
| 936 |
#endif |
|---|
| 937 |
break; |
|---|
| 938 |
} |
|---|
| 939 |
|
|---|
| 940 |
/* |
|---|
| 941 |
* Processor configuration sanity check for the R4000SC erratum |
|---|
| 942 |
* #5. With page sizes larger than 32kB there is no possibility |
|---|
| 943 |
* to get a VCE exception anymore so we don't care about this |
|---|
| 944 |
* misconfiguration. The case is rather theoretical anyway; |
|---|
| 945 |
* presumably no vendor is shipping his hardware in the "bad" |
|---|
| 946 |
* configuration. |
|---|
| 947 |
*/ |
|---|
| 948 |
if ((prid & 0xff00) == PRID_IMP_R4000 && (prid & 0xff) < 0x40 && |
|---|
| 949 |
!(config & CONF_SC) && c->icache.linesz != 16 && |
|---|
| 950 |
PAGE_SIZE <= 0x8000) |
|---|
| 951 |
panic("Improper R4000SC processor configuration detected"); |
|---|
| 952 |
|
|---|
| 953 |
/* compute a couple of other cache variables */ |
|---|
| 954 |
c->icache.waysize = icache_size / c->icache.ways; |
|---|
| 955 |
c->dcache.waysize = dcache_size / c->dcache.ways; |
|---|
| 956 |
|
|---|
| 957 |
c->icache.sets = c->icache.linesz ? |
|---|
| 958 |
icache_size / (c->icache.linesz * c->icache.ways) : 0; |
|---|
| 959 |
c->dcache.sets = c->dcache.linesz ? |
|---|
| 960 |
dcache_size / (c->dcache.linesz * c->dcache.ways) : 0; |
|---|
| 961 |
|
|---|
| 962 |
/* |
|---|
| 963 |
* R10000 and R12000 P-caches are odd in a positive way. They're 32kB |
|---|
| 964 |
* 2-way virtually indexed so normally would suffer from aliases. So |
|---|
| 965 |
* normally they'd suffer from aliases but magic in the hardware deals |
|---|
| 966 |
* with that for us so we don't need to take care ourselves. |
|---|
| 967 |
*/ |
|---|
| 968 |
switch (c->cputype) { |
|---|
| 969 |
case CPU_20KC: |
|---|
| 970 |
case CPU_25KF: |
|---|
| 971 |
c->dcache.flags |= MIPS_CACHE_PINDEX; |
|---|
| 972 |
case CPU_R10000: |
|---|
| 973 |
case CPU_R12000: |
|---|
| 974 |
case CPU_R14000: |
|---|
| 975 |
case CPU_SB1: |
|---|
| 976 |
break; |
|---|
| 977 |
case CPU_24K: |
|---|
| 978 |
case CPU_34K: |
|---|
| 979 |
case CPU_74K: |
|---|
| 980 |
if ((read_c0_config7() & (1 << 16))) { |
|---|
| 981 |
/* effectively physically indexed dcache, |
|---|
| 982 |
thus no virtual aliases. */ |
|---|
| 983 |
c->dcache.flags |= MIPS_CACHE_PINDEX; |
|---|
| 984 |
break; |
|---|
| 985 |
} |
|---|
| 986 |
default: |
|---|
| 987 |
if (c->dcache.waysize > PAGE_SIZE) |
|---|
| 988 |
c->dcache.flags |= MIPS_CACHE_ALIASES; |
|---|
| 989 |
} |
|---|
| 990 |
|
|---|
| 991 |
switch (c->cputype) { |
|---|
| 992 |
case CPU_20KC: |
|---|
| 993 |
/* |
|---|
| 994 |
* Some older 20Kc chips doesn't have the 'VI' bit in |
|---|
| 995 |
* the config register. |
|---|
| 996 |
*/ |
|---|
| 997 |
c->icache.flags |= MIPS_CACHE_VTAG; |
|---|
| 998 |
break; |
|---|
| 999 |
|
|---|
| 1000 |
case CPU_AU1000: |
|---|
| 1001 |
case CPU_AU1500: |
|---|
| 1002 |
case CPU_AU1100: |
|---|
| 1003 |
case CPU_AU1550: |
|---|
| 1004 |
case CPU_AU1200: |
|---|
| 1005 |
c->icache.flags |= MIPS_CACHE_IC_F_DC; |
|---|
| 1006 |
break; |
|---|
| 1007 |
} |
|---|
| 1008 |
|
|---|
| 1009 |
#ifdef CONFIG_CPU_LOONGSON2 |
|---|
| 1010 |
/* |
|---|
| 1011 |
* LOONGSON2 has 4 way icache, but when using indexed cache op, |
|---|
| 1012 |
* one op will act on all 4 ways |
|---|
| 1013 |
*/ |
|---|
| 1014 |
c->icache.ways = 1; |
|---|
| 1015 |
#endif |
|---|
| 1016 |
|
|---|
| 1017 |
printk("Primary instruction cache %ldkB, %s, %s, linesize %d bytes.\n", |
|---|
| 1018 |
icache_size >> 10, |
|---|
| 1019 |
cpu_has_vtag_icache ? "virtually tagged" : "physically tagged", |
|---|
| 1020 |
way_string[c->icache.ways], c->icache.linesz); |
|---|
| 1021 |
|
|---|
| 1022 |
printk("Primary data cache %ldkB, %s, linesize %d bytes.\n", |
|---|
| 1023 |
dcache_size >> 10, way_string[c->dcache.ways], c->dcache.linesz); |
|---|
| 1024 |
} |
|---|
| 1025 |
|
|---|
| 1026 |
/* |
|---|
| 1027 |
* If you even _breathe_ on this function, look at the gcc output and make sure |
|---|
| 1028 |
* it does not pop things on and off the stack for the cache sizing loop that |
|---|
| 1029 |
* executes in KSEG1 space or else you will crash and burn badly. You have |
|---|
| 1030 |
* been warned. |
|---|
| 1031 |
*/ |
|---|
| 1032 |
static int __init probe_scache(void) |
|---|
| 1033 |
{ |
|---|
| 1034 |
unsigned long flags, addr, begin, end, pow2; |
|---|
| 1035 |
unsigned int config = read_c0_config(); |
|---|
| 1036 |
struct cpuinfo_mips *c = ¤t_cpu_data; |
|---|
| 1037 |
int tmp; |
|---|
| 1038 |
|
|---|
| 1039 |
if (config & CONF_SC) |
|---|
| 1040 |
return 0; |
|---|
| 1041 |
|
|---|
| 1042 |
begin = (unsigned long) &_stext; |
|---|
| 1043 |
begin &= ~((4 * 1024 * 1024) - 1); |
|---|
| 1044 |
end = begin + (4 * 1024 * 1024); |
|---|
| 1045 |
|
|---|
| 1046 |
/* |
|---|
| 1047 |
* This is such a bitch, you'd think they would make it easy to do |
|---|
| 1048 |
* this. Away you daemons of stupidity! |
|---|
| 1049 |
*/ |
|---|
| 1050 |
local_irq_save(flags); |
|---|
| 1051 |
|
|---|
| 1052 |
/* Fill each size-multiple cache line with a valid tag. */ |
|---|
| 1053 |
pow2 = (64 * 1024); |
|---|
| 1054 |
for (addr = begin; addr < end; addr = (begin + pow2)) { |
|---|
| 1055 |
unsigned long *p = (unsigned long *) addr; |
|---|
| 1056 |
__asm__ __volatile__("nop" : : "r" (*p)); /* whee... */ |
|---|
| 1057 |
pow2 <<= 1; |
|---|
| 1058 |
} |
|---|
| 1059 |
|
|---|
| 1060 |
/* Load first line with zero (therefore invalid) tag. */ |
|---|
| 1061 |
write_c0_taglo(0); |
|---|
| 1062 |
write_c0_taghi(0); |
|---|
| 1063 |
__asm__ __volatile__("nop; nop; nop; nop;"); /* avoid the hazard */ |
|---|
| 1064 |
cache_op(Index_Store_Tag_I, begin); |
|---|
| 1065 |
cache_op(Index_Store_Tag_D, begin); |
|---|
| 1066 |
cache_op(Index_Store_Tag_SD, begin); |
|---|
| 1067 |
|
|---|
| 1068 |
/* Now search for the wrap around point. */ |
|---|
| 1069 |
pow2 = (128 * 1024); |
|---|
| 1070 |
tmp = 0; |
|---|
| 1071 |
for (addr = begin + (128 * 1024); addr < end; addr = begin + pow2) { |
|---|
| 1072 |
cache_op(Index_Load_Tag_SD, addr); |
|---|
| 1073 |
__asm__ __volatile__("nop; nop; nop; nop;"); /* hazard... */ |
|---|
| 1074 |
if (!read_c0_taglo()) |
|---|
| 1075 |
break; |
|---|
| 1076 |
pow2 <<= 1; |
|---|
| 1077 |
} |
|---|
| 1078 |
local_irq_restore(flags); |
|---|
| 1079 |
addr -= begin; |
|---|
| 1080 |
|
|---|
| 1081 |
scache_size = addr; |
|---|
| 1082 |
c->scache.linesz = 16 << ((config & R4K_CONF_SB) >> 22); |
|---|
| 1083 |
c->scache.ways = 1; |
|---|
| 1084 |
c->dcache.waybit = 0; /* does not matter */ |
|---|
| 1085 |
|
|---|
| 1086 |
return 1; |
|---|
| 1087 |
} |
|---|
| 1088 |
|
|---|
| 1089 |
#if defined(CONFIG_CPU_LOONGSON2) |
|---|
| 1090 |
static void __init loongson2_sc_init(void) |
|---|
| 1091 |
{ |
|---|
| 1092 |
struct cpuinfo_mips *c = ¤t_cpu_data; |
|---|
| 1093 |
|
|---|
| 1094 |
scache_size = 512*1024; |
|---|
| 1095 |
c->scache.linesz = 32; |
|---|
| 1096 |
c->scache.ways = 4; |
|---|
| 1097 |
c->scache.waybit = 0; |
|---|
| 1098 |
c->scache.waysize = scache_size / (c->scache.ways); |
|---|
| 1099 |
c->scache.sets = scache_size / (c->scache.linesz * c->scache.ways); |
|---|
| 1100 |
pr_info("Unified secondary cache %ldkB %s, linesize %d bytes.\n", |
|---|
| 1101 |
scache_size >> 10, way_string[c->scache.ways], c->scache.linesz); |
|---|
| 1102 |
|
|---|
| 1103 |
c->options |= MIPS_CPU_INCLUSIVE_CACHES; |
|---|
| 1104 |
} |
|---|
| 1105 |
#endif |
|---|
| 1106 |
|
|---|
| 1107 |
extern int r5k_sc_init(void); |
|---|
| 1108 |
extern int rm7k_sc_init(void); |
|---|
| 1109 |
extern int mips_sc_init(void); |
|---|
| 1110 |
|
|---|
| 1111 |
static void __init setup_scache(void) |
|---|
| 1112 |
{ |
|---|
| 1113 |
struct cpuinfo_mips *c = ¤t_cpu_data; |
|---|
| 1114 |
unsigned int config = read_c0_config(); |
|---|
| 1115 |
int sc_present = 0; |
|---|
| 1116 |
|
|---|
| 1117 |
/* |
|---|
| 1118 |
* Do the probing thing on R4000SC and R4400SC processors. Other |
|---|
| 1119 |
* processors don't have a S-cache that would be relevant to the |
|---|
| 1120 |
* Linux memory managment. |
|---|
| 1121 |
*/ |
|---|
| 1122 |
switch (c->cputype) { |
|---|
| 1123 |
case CPU_R4000SC: |
|---|
| 1124 |
case CPU_R4000MC: |
|---|
| 1125 |
case CPU_R4400SC: |
|---|
| 1126 |
case CPU_R4400MC: |
|---|
| 1127 |
sc_present = run_uncached(probe_scache); |
|---|
| 1128 |
if (sc_present) |
|---|
| 1129 |
c->options |= MIPS_CPU_CACHE_CDEX_S; |
|---|
| 1130 |
break; |
|---|
| 1131 |
|
|---|
| 1132 |
case CPU_R10000: |
|---|
| 1133 |
case CPU_R12000: |
|---|
| 1134 |
case CPU_R14000: |
|---|
| 1135 |
scache_size = 0x80000 << ((config & R10K_CONF_SS) >> 16); |
|---|
| 1136 |
c->scache.linesz = 64 << ((config >> 13) & 1); |
|---|
| 1137 |
c->scache.ways = 2; |
|---|
| 1138 |
c->scache.waybit= 0; |
|---|
| 1139 |
sc_present = 1; |
|---|
| 1140 |
break; |
|---|
| 1141 |
|
|---|
| 1142 |
case CPU_R5000: |
|---|
| 1143 |
case CPU_NEVADA: |
|---|
| 1144 |
#ifdef CONFIG_R5000_CPU_SCACHE |
|---|
| 1145 |
r5k_sc_init(); |
|---|
| 1146 |
#endif |
|---|
| 1147 |
return; |
|---|
| 1148 |
|
|---|
| 1149 |
case CPU_RM7000: |
|---|
| 1150 |
case CPU_RM9000: |
|---|
| 1151 |
#ifdef CONFIG_RM7000_CPU_SCACHE |
|---|
| 1152 |
rm7k_sc_init(); |
|---|
| 1153 |
#endif |
|---|
| 1154 |
return; |
|---|
| 1155 |
|
|---|
| 1156 |
#if defined(CONFIG_CPU_LOONGSON2) |
|---|
| 1157 |
case CPU_LOONGSON2: |
|---|
| 1158 |
loongson2_sc_init(); |
|---|
| 1159 |
return; |
|---|
| 1160 |
#endif |
|---|
| 1161 |
|
|---|
| 1162 |
default: |
|---|
| 1163 |
if (c->isa_level == MIPS_CPU_ISA_M32R1 || |
|---|
| 1164 |
c->isa_level == MIPS_CPU_ISA_M32R2 || |
|---|
| 1165 |
c->isa_level == MIPS_CPU_ISA_M64R1 || |
|---|
| 1166 |
c->isa_level == MIPS_CPU_ISA_M64R2) { |
|---|
| 1167 |
#ifdef CONFIG_MIPS_CPU_SCACHE |
|---|
| 1168 |
if (mips_sc_init ()) { |
|---|
| 1169 |
scache_size = c->scache.ways * c->scache.sets * c->scache.linesz; |
|---|
| 1170 |
printk("MIPS secondary cache %ldkB, %s, linesize %d bytes.\n", |
|---|
| 1171 |
scache_size >> 10, |
|---|
| 1172 |
way_string[c->scache.ways], c->scache.linesz); |
|---|
| 1173 |
} |
|---|
| 1174 |
#else |
|---|
| 1175 |
if (!(c->scache.flags & MIPS_CACHE_NOT_PRESENT)) |
|---|
| 1176 |
panic("Dunno how to handle MIPS32 / MIPS64 second level cache"); |
|---|
| 1177 |
#endif |
|---|
| 1178 |
return; |
|---|
| 1179 |
} |
|---|
| 1180 |
sc_present = 0; |
|---|
| 1181 |
} |
|---|
| 1182 |
|
|---|
| 1183 |
if (!sc_present) |
|---|
| 1184 |
return; |
|---|
| 1185 |
|
|---|
| 1186 |
/* compute a couple of other cache variables */ |
|---|
| 1187 |
c->scache.waysize = scache_size / c->scache.ways; |
|---|
| 1188 |
|
|---|
| 1189 |
c->scache.sets = scache_size / (c->scache.linesz * c->scache.ways); |
|---|
| 1190 |
|
|---|
| 1191 |
printk("Unified secondary cache %ldkB %s, linesize %d bytes.\n", |
|---|
| 1192 |
scache_size >> 10, way_string[c->scache.ways], c->scache.linesz); |
|---|
| 1193 |
|
|---|
| 1194 |
c->options |= MIPS_CPU_INCLUSIVE_CACHES; |
|---|
| 1195 |
} |
|---|
| 1196 |
|
|---|
| 1197 |
void au1x00_fixup_config_od(void) |
|---|
| 1198 |
{ |
|---|
| 1199 |
/* |
|---|
| 1200 |
* c0_config.od (bit 19) was write only (and read as 0) |
|---|
| 1201 |
* on the early revisions of Alchemy SOCs. It disables the bus |
|---|
| 1202 |
* transaction overlapping and needs to be set to fix various errata. |
|---|
| 1203 |
*/ |
|---|
| 1204 |
switch (read_c0_prid()) { |
|---|
| 1205 |
case 0x00030100: /* Au1000 DA */ |
|---|
| 1206 |
case 0x00030201: /* Au1000 HA */ |
|---|
| 1207 |
case 0x00030202: /* Au1000 HB */ |
|---|
| 1208 |
case 0x01030200: /* Au1500 AB */ |
|---|
| 1209 |
/* |
|---|
| 1210 |
* Au1100 errata actually keeps silence about this bit, so we set it |
|---|
| 1211 |
* just in case for those revisions that require it to be set according |
|---|
| 1212 |
* to arch/mips/au1000/common/cputable.c |
|---|
| 1213 |
*/ |
|---|
| 1214 |
case 0x02030200: /* Au1100 AB */ |
|---|
| 1215 |
case 0x02030201: /* Au1100 BA */ |
|---|
| 1216 |
case 0x02030202: /* Au1100 BC */ |
|---|
| 1217 |
set_c0_config(1 << 19); |
|---|
| 1218 |
break; |
|---|
| 1219 |
} |
|---|
| 1220 |
} |
|---|
| 1221 |
|
|---|
| 1222 |
static void __init coherency_setup(void) |
|---|
| 1223 |
{ |
|---|
| 1224 |
change_c0_config(CONF_CM_CMASK, CONF_CM_DEFAULT); |
|---|
| 1225 |
|
|---|
| 1226 |
/* |
|---|
| 1227 |
* c0_status.cu=0 specifies that updates by the sc instruction use |
|---|
| 1228 |
* the coherency mode specified by the TLB; 1 means cachable |
|---|
| 1229 |
* coherent update on write will be used. Not all processors have |
|---|
| 1230 |
* this bit and; some wire it to zero, others like Toshiba had the |
|---|
| 1231 |
* silly idea of putting something else there ... |
|---|
| 1232 |
*/ |
|---|
| 1233 |
switch (current_cpu_data.cputype) { |
|---|
| 1234 |
case CPU_R4000PC: |
|---|
| 1235 |
case CPU_R4000SC: |
|---|
| 1236 |
case CPU_R4000MC: |
|---|
| 1237 |
case CPU_R4400PC: |
|---|
| 1238 |
case CPU_R4400SC: |
|---|
| 1239 |
case CPU_R4400MC: |
|---|
| 1240 |
clear_c0_config(CONF_CU); |
|---|
| 1241 |
break; |
|---|
| 1242 |
/* |
|---|
| 1243 |
* We need to catch the early Alchemy SOCs with |
|---|
| 1244 |
* the write-only co_config.od bit and set it back to one... |
|---|
| 1245 |
*/ |
|---|
| 1246 |
case CPU_AU1000: /* rev. DA, HA, HB */ |
|---|
| 1247 |
case CPU_AU1100: /* rev. AB, BA, BC ?? */ |
|---|
| 1248 |
case CPU_AU1500: /* rev. AB */ |
|---|
| 1249 |
au1x00_fixup_config_od(); |
|---|
| 1250 |
break; |
|---|
| 1251 |
} |
|---|
| 1252 |
} |
|---|
| 1253 |
|
|---|
| 1254 |
void __init r4k_cache_init(void) |
|---|
| 1255 |
{ |
|---|
| 1256 |
extern void build_clear_page(void); |
|---|
| 1257 |
extern void build_copy_page(void); |
|---|
| 1258 |
extern char except_vec2_generic; |
|---|
| 1259 |
struct cpuinfo_mips *c = ¤t_cpu_data; |
|---|
| 1260 |
|
|---|
| 1261 |
/* Default cache error handler for R4000 and R5000 family */ |
|---|
| 1262 |
set_uncached_handler (0x100, &except_vec2_generic, 0x80); |
|---|
| 1263 |
|
|---|
| 1264 |
probe_pcache(); |
|---|
| 1265 |
setup_scache(); |
|---|
| 1266 |
|
|---|
| 1267 |
r4k_blast_dcache_page_setup(); |
|---|
| 1268 |
r4k_blast_dcache_page_indexed_setup(); |
|---|
| 1269 |
r4k_blast_dcache_setup(); |
|---|
| 1270 |
r4k_blast_icache_page_setup(); |
|---|
| 1271 |
r4k_blast_icache_page_indexed_setup(); |
|---|
| 1272 |
r4k_blast_icache_setup(); |
|---|
| 1273 |
r4k_blast_scache_page_setup(); |
|---|
| 1274 |
r4k_blast_scache_page_indexed_setup(); |
|---|
| 1275 |
r4k_blast_scache_setup(); |
|---|
| 1276 |
|
|---|
| 1277 |
/* |
|---|
| 1278 |
* Some MIPS32 and MIPS64 processors have physically indexed caches. |
|---|
| 1279 |
* This code supports virtually indexed processors and will be |
|---|
| 1280 |
* unnecessarily inefficient on physically indexed processors. |
|---|
| 1281 |
*/ |
|---|
| 1282 |
if (c->dcache.linesz) |
|---|
| 1283 |
shm_align_mask = max_t( unsigned long, |
|---|
| 1284 |
c->dcache.sets * c->dcache.linesz - 1, |
|---|
| 1285 |
PAGE_SIZE - 1); |
|---|
| 1286 |
else |
|---|
| 1287 |
shm_align_mask = PAGE_SIZE-1; |
|---|
| 1288 |
flush_cache_all = r4k_flush_cache_all; |
|---|
| 1289 |
__flush_cache_all = r4k___flush_cache_all; |
|---|
| 1290 |
flush_cache_mm = r4k_flush_cache_mm; |
|---|
| 1291 |
flush_cache_page = r4k_flush_cache_page; |
|---|
| 1292 |
flush_cache_range = r4k_flush_cache_range; |
|---|
| 1293 |
|
|---|
| 1294 |
flush_cache_sigtramp = r4k_flush_cache_sigtramp; |
|---|
| 1295 |
flush_icache_all = r4k_flush_icache_all; |
|---|
| 1296 |
local_flush_data_cache_page = local_r4k_flush_data_cache_page; |
|---|
| 1297 |
flush_data_cache_page = r4k_flush_data_cache_page; |
|---|
| 1298 |
flush_icache_range = r4k_flush_icache_range; |
|---|
| 1299 |
|
|---|
| 1300 |
#ifdef CONFIG_DMA_NONCOHERENT |
|---|
| 1301 |
_dma_cache_wback_inv = r4k_dma_cache_wback_inv; |
|---|
| 1302 |
_dma_cache_wback = r4k_dma_cache_wback_inv; |
|---|
| 1303 |
_dma_cache_inv = r4k_dma_cache_inv; |
|---|
| 1304 |
#endif |
|---|
| 1305 |
|
|---|
| 1306 |
build_clear_page(); |
|---|
| 1307 |
build_copy_page(); |
|---|
| 1308 |
local_r4k___flush_cache_all(NULL); |
|---|
| 1309 |
coherency_setup(); |
|---|
| 1310 |
} |
|---|