Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[MIPS] define Hit_Invalidate_I to Index_Invalidate_I for loongson2

Signed-off-by: Fuxin Zhang <zhangfx@lemote.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Fuxin Zhang and committed by
Ralf Baechle
2a21c730 fee578fa

+134 -11
+22
arch/mips/Kconfig
··· 894 894 prompt "CPU type" 895 895 default CPU_R4X00 896 896 897 + config CPU_LOONGSON2 898 + bool "Loongson 2" 899 + depends on SYS_HAS_CPU_LOONGSON2 900 + select CPU_SUPPORTS_32BIT_KERNEL 901 + select CPU_SUPPORTS_64BIT_KERNEL 902 + select CPU_SUPPORTS_HIGHMEM 903 + help 904 + The Loongson 2E processor implements the MIPS III instruction set 905 + with many extensions. 906 + 897 907 config CPU_MIPS32_R1 898 908 bool "MIPS32 Release 1" 899 909 depends on SYS_HAS_CPU_MIPS32_R1 ··· 1113 1103 select WEAK_ORDERING 1114 1104 1115 1105 endchoice 1106 + 1107 + config SYS_HAS_CPU_LOONGSON2 1108 + bool 1116 1109 1117 1110 config SYS_HAS_CPU_MIPS32_R1 1118 1111 bool ··· 1450 1437 1451 1438 config CPU_HAS_WB 1452 1439 bool 1440 + 1441 + config 64BIT_CONTEXT 1442 + bool "Save 64bit integer registers" 1443 + depends on 32BIT && CPU_LOONGSON2 1444 + help 1445 + Loongson2 CPU is 64bit , when used in 32BIT mode, its integer 1446 + registers can still be accessed as 64bit, mainly for multimedia 1447 + instructions. We must have all 64bit save/restored to make sure 1448 + those instructions to get correct result. 1453 1449 1454 1450 # 1455 1451 # Vectored interrupt mode is an R2 feature
+1
arch/mips/Makefile
··· 118 118 cflags-$(CONFIG_CPU_VR41XX) += -march=r4100 -Wa,--trap 119 119 cflags-$(CONFIG_CPU_R4X00) += -march=r4600 -Wa,--trap 120 120 cflags-$(CONFIG_CPU_TX49XX) += -march=r4600 -Wa,--trap 121 + cflags-$(CONFIG_CPU_LOONGSON2) += -march=r4600 -Wa,--trap 121 122 cflags-$(CONFIG_CPU_MIPS32_R1) += $(call cc-option,-march=mips32,-mips32 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32) \ 122 123 -Wa,-mips32 -Wa,--trap 123 124 cflags-$(CONFIG_CPU_MIPS32_R2) += $(call cc-option,-march=mips32r2,-mips32r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32) \
+7 -6
arch/mips/kernel/Makefile
··· 14 14 obj-$(CONFIG_STACKTRACE) += stacktrace.o 15 15 obj-$(CONFIG_MODULES) += mips_ksyms.o module.o 16 16 17 + obj-$(CONFIG_CPU_LOONGSON2) += r4k_fpu.o r4k_switch.o 18 + obj-$(CONFIG_CPU_MIPS32) += r4k_fpu.o r4k_switch.o 19 + obj-$(CONFIG_CPU_MIPS64) += r4k_fpu.o r4k_switch.o 17 20 obj-$(CONFIG_CPU_R3000) += r2300_fpu.o r2300_switch.o 18 - obj-$(CONFIG_CPU_TX39XX) += r2300_fpu.o r2300_switch.o 19 - obj-$(CONFIG_CPU_TX49XX) += r4k_fpu.o r4k_switch.o 20 21 obj-$(CONFIG_CPU_R4000) += r4k_fpu.o r4k_switch.o 21 - obj-$(CONFIG_CPU_VR41XX) += r4k_fpu.o r4k_switch.o 22 22 obj-$(CONFIG_CPU_R4300) += r4k_fpu.o r4k_switch.o 23 23 obj-$(CONFIG_CPU_R4X00) += r4k_fpu.o r4k_switch.o 24 24 obj-$(CONFIG_CPU_R5000) += r4k_fpu.o r4k_switch.o 25 + obj-$(CONFIG_CPU_R6000) += r6000_fpu.o r4k_switch.o 25 26 obj-$(CONFIG_CPU_R5432) += r4k_fpu.o r4k_switch.o 26 27 obj-$(CONFIG_CPU_R8000) += r4k_fpu.o r4k_switch.o 27 28 obj-$(CONFIG_CPU_RM7000) += r4k_fpu.o r4k_switch.o ··· 30 29 obj-$(CONFIG_CPU_NEVADA) += r4k_fpu.o r4k_switch.o 31 30 obj-$(CONFIG_CPU_R10000) += r4k_fpu.o r4k_switch.o 32 31 obj-$(CONFIG_CPU_SB1) += r4k_fpu.o r4k_switch.o 33 - obj-$(CONFIG_CPU_MIPS32) += r4k_fpu.o r4k_switch.o 34 - obj-$(CONFIG_CPU_MIPS64) += r4k_fpu.o r4k_switch.o 35 - obj-$(CONFIG_CPU_R6000) += r6000_fpu.o r4k_switch.o 32 + obj-$(CONFIG_CPU_TX39XX) += r2300_fpu.o r2300_switch.o 33 + obj-$(CONFIG_CPU_TX49XX) += r4k_fpu.o r4k_switch.o 34 + obj-$(CONFIG_CPU_VR41XX) += r4k_fpu.o r4k_switch.o 36 35 37 36 obj-$(CONFIG_SMP) += smp.o 38 37
+8
arch/mips/kernel/cpu-probe.c
··· 485 485 MIPS_CPU_LLSC; 486 486 c->tlbsize = 64; 487 487 break; 488 + case PRID_IMP_LOONGSON2: 489 + c->cputype = CPU_LOONGSON2; 490 + c->isa_level = MIPS_CPU_ISA_III; 491 + c->options = R4K_OPTS | 492 + MIPS_CPU_FPU | MIPS_CPU_LLSC | 493 + MIPS_CPU_32FPR; 494 + c->tlbsize = 64; 495 + break; 488 496 } 489 497 } 490 498
+1
arch/mips/kernel/proc.c
··· 83 83 [CPU_VR4181A] = "NEC VR4181A", 84 84 [CPU_SR71000] = "Sandcraft SR71000", 85 85 [CPU_PR4450] = "Philips PR4450", 86 + [CPU_LOONGSON2] = "ICT Loongson-2", 86 87 }; 87 88 88 89
+1
arch/mips/lib/Makefile
··· 8 8 obj-y += iomap.o 9 9 obj-$(CONFIG_PCI) += iomap-pci.o 10 10 11 + obj-$(CONFIG_CPU_LOONGSON2) += dump_tlb.o 11 12 obj-$(CONFIG_CPU_MIPS32) += dump_tlb.o 12 13 obj-$(CONFIG_CPU_MIPS64) += dump_tlb.o 13 14 obj-$(CONFIG_CPU_NEVADA) += dump_tlb.o
+1
arch/mips/mm/Makefile
··· 9 9 obj-$(CONFIG_64BIT) += pgtable-64.o 10 10 obj-$(CONFIG_HIGHMEM) += highmem.o 11 11 12 + obj-$(CONFIG_CPU_LOONGSON2) += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o 12 13 obj-$(CONFIG_CPU_MIPS32) += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o 13 14 obj-$(CONFIG_CPU_MIPS64) += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o 14 15 obj-$(CONFIG_CPU_NEVADA) += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o
+54
arch/mips/mm/c-r4k.c
··· 335 335 336 336 static inline void local_r4k___flush_cache_all(void * args) 337 337 { 338 + #if defined(CONFIG_CPU_LOONGSON2) 339 + r4k_blast_scache(); 340 + return; 341 + #endif 338 342 r4k_blast_dcache(); 339 343 r4k_blast_icache(); 340 344 ··· 852 848 c->options |= MIPS_CPU_PREFETCH; 853 849 break; 854 850 851 + case CPU_LOONGSON2: 852 + icache_size = 1 << (12 + ((config & CONF_IC) >> 9)); 853 + c->icache.linesz = 16 << ((config & CONF_IB) >> 5); 854 + if (prid & 0x3) 855 + c->icache.ways = 4; 856 + else 857 + c->icache.ways = 2; 858 + c->icache.waybit = 0; 859 + 860 + dcache_size = 1 << (12 + ((config & CONF_DC) >> 6)); 861 + c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); 862 + if (prid & 0x3) 863 + c->dcache.ways = 4; 864 + else 865 + c->dcache.ways = 2; 866 + c->dcache.waybit = 0; 867 + break; 868 + 855 869 default: 856 870 if (!(config & MIPS_CONF_M)) 857 871 panic("Don't know how to probe P-caches on this cpu."); ··· 985 963 break; 986 964 } 987 965 966 + #ifdef CONFIG_CPU_LOONGSON2 967 + /* 968 + * LOONGSON2 has 4 way icache, but when using indexed cache op, 969 + * one op will act on all 4 ways 970 + */ 971 + c->icache.ways = 1; 972 + #endif 973 + 988 974 printk("Primary instruction cache %ldkB, %s, %s, linesize %d bytes.\n", 989 975 icache_size >> 10, 990 976 cpu_has_vtag_icache ? "virtually tagged" : "physically tagged", ··· 1066 1036 return 1; 1067 1037 } 1068 1038 1039 + #if defined(CONFIG_CPU_LOONGSON2) 1040 + static void __init loongson2_sc_init(void) 1041 + { 1042 + struct cpuinfo_mips *c = &current_cpu_data; 1043 + 1044 + scache_size = 512*1024; 1045 + c->scache.linesz = 32; 1046 + c->scache.ways = 4; 1047 + c->scache.waybit = 0; 1048 + c->scache.waysize = scache_size / (c->scache.ways); 1049 + c->scache.sets = scache_size / (c->scache.linesz * c->scache.ways); 1050 + pr_info("Unified secondary cache %ldkB %s, linesize %d bytes.\n", 1051 + scache_size >> 10, way_string[c->scache.ways], c->scache.linesz); 1052 + 1053 + c->options |= MIPS_CPU_INCLUSIVE_CACHES; 1054 + } 1055 + #endif 1056 + 1069 1057 extern int r5k_sc_init(void); 1070 1058 extern int rm7k_sc_init(void); 1071 1059 extern int mips_sc_init(void); ··· 1132 1084 rm7k_sc_init(); 1133 1085 #endif 1134 1086 return; 1087 + 1088 + #if defined(CONFIG_CPU_LOONGSON2) 1089 + case CPU_LOONGSON2: 1090 + loongson2_sc_init(); 1091 + return; 1092 + #endif 1135 1093 1136 1094 default: 1137 1095 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
+22 -1
arch/mips/mm/tlb-r4k.c
··· 48 48 49 49 #endif /* CONFIG_MIPS_MT_SMTC */ 50 50 51 + #if defined(CONFIG_CPU_LOONGSON2) 52 + /* 53 + * LOONGSON2 has a 4 entry itlb which is a subset of dtlb, 54 + * unfortrunately, itlb is not totally transparent to software. 55 + */ 56 + #define FLUSH_ITLB write_c0_diag(4); 57 + 58 + #define FLUSH_ITLB_VM(vma) { if ((vma)->vm_flags & VM_EXEC) write_c0_diag(4); } 59 + 60 + #else 61 + 62 + #define FLUSH_ITLB 63 + #define FLUSH_ITLB_VM(vma) 64 + 65 + #endif 66 + 51 67 void local_flush_tlb_all(void) 52 68 { 53 69 unsigned long flags; ··· 89 73 } 90 74 tlbw_use_hazard(); 91 75 write_c0_entryhi(old_ctx); 76 + FLUSH_ITLB; 92 77 EXIT_CRITICAL(flags); 93 78 } 94 79 ··· 153 136 } else { 154 137 drop_mmu_context(mm, cpu); 155 138 } 139 + FLUSH_ITLB; 156 140 EXIT_CRITICAL(flags); 157 141 } 158 142 } ··· 196 178 } else { 197 179 local_flush_tlb_all(); 198 180 } 181 + FLUSH_ITLB; 199 182 EXIT_CRITICAL(flags); 200 183 } 201 184 ··· 229 210 230 211 finish: 231 212 write_c0_entryhi(oldpid); 213 + FLUSH_ITLB_VM(vma); 232 214 EXIT_CRITICAL(flags); 233 215 } 234 216 } ··· 261 241 tlbw_use_hazard(); 262 242 } 263 243 write_c0_entryhi(oldpid); 264 - 244 + FLUSH_ITLB; 265 245 EXIT_CRITICAL(flags); 266 246 } 267 247 ··· 313 293 else 314 294 tlb_write_indexed(); 315 295 tlbw_use_hazard(); 296 + FLUSH_ITLB_VM(vma); 316 297 EXIT_CRITICAL(flags); 317 298 } 318 299
+5 -3
arch/mips/mm/tlbex.c
··· 893 893 case CPU_4KSC: 894 894 case CPU_20KC: 895 895 case CPU_25KF: 896 + case CPU_LOONGSON2: 896 897 tlbw(p); 897 898 break; 898 899 ··· 1277 1276 * need three, with the second nop'ed and the third being 1278 1277 * unused. 1279 1278 */ 1280 - #ifdef CONFIG_32BIT 1279 + /* Loongson2 ebase is different than r4k, we have more space */ 1280 + #if defined(CONFIG_32BIT) || defined(CONFIG_CPU_LOONGSON2) 1281 1281 if ((p - tlb_handler) > 64) 1282 1282 panic("TLB refill handler space exceeded"); 1283 1283 #else ··· 1291 1289 /* 1292 1290 * Now fold the handler in the TLB refill handler space. 1293 1291 */ 1294 - #ifdef CONFIG_32BIT 1292 + #if defined(CONFIG_32BIT) || defined(CONFIG_CPU_LOONGSON2) 1295 1293 f = final_handler; 1296 1294 /* Simplest case, just copy the handler. */ 1297 1295 copy_handler(relocs, labels, tlb_handler, p, f); ··· 1338 1336 final_len); 1339 1337 1340 1338 f = final_handler; 1341 - #ifdef CONFIG_64BIT 1339 + #if defined(CONFIG_64BIT) && !defined(CONFIG_CPU_LOONGSON2) 1342 1340 if (final_len > 32) 1343 1341 final_len = 64; 1344 1342 else
+4
include/asm-mips/cacheops.h
··· 20 20 #define Index_Load_Tag_D 0x05 21 21 #define Index_Store_Tag_I 0x08 22 22 #define Index_Store_Tag_D 0x09 23 + #if defined(CONFIG_CPU_LOONGSON2) 24 + #define Hit_Invalidate_I 0x00 25 + #else 23 26 #define Hit_Invalidate_I 0x10 27 + #endif 24 28 #define Hit_Invalidate_D 0x11 25 29 #define Hit_Writeback_Inv_D 0x15 26 30
+6 -1
include/asm-mips/cpu.h
··· 89 89 #define PRID_IMP_34K 0x9500 90 90 #define PRID_IMP_24KE 0x9600 91 91 #define PRID_IMP_74K 0x9700 92 + #define PRID_IMP_LOONGSON1 0x4200 93 + #define PRID_IMP_LOONGSON2 0x6300 92 94 93 95 /* 94 96 * These are the PRID's for when 23:16 == PRID_COMP_SIBYTE ··· 213 211 #define CPU_SB1A 62 214 212 #define CPU_74K 63 215 213 #define CPU_R14000 64 216 - #define CPU_LAST 64 214 + #define CPU_LOONGSON1 65 215 + #define CPU_LOONGSON2 66 216 + 217 + #define CPU_LAST 66 217 218 218 219 /* 219 220 * ISA Level encodings
+2
include/asm-mips/module.h
··· 112 112 #define MODULE_PROC_FAMILY "RM9000 " 113 113 #elif defined CONFIG_CPU_SB1 114 114 #define MODULE_PROC_FAMILY "SB1 " 115 + #elif defined CONFIG_CPU_LOONGSON2 116 + #define MODULE_PROC_FAMILY "LOONGSON2 " 115 117 #else 116 118 #error MODULE_PROC_FAMILY undefined for your processor configuration 117 119 #endif