···894894 prompt "CPU type"895895 default CPU_R4X00896896897897+config CPU_LOONGSON2898898+ bool "Loongson 2"899899+ depends on SYS_HAS_CPU_LOONGSON2900900+ select CPU_SUPPORTS_32BIT_KERNEL901901+ select CPU_SUPPORTS_64BIT_KERNEL902902+ select CPU_SUPPORTS_HIGHMEM903903+ help904904+ The Loongson 2E processor implements the MIPS III instruction set905905+ with many extensions.906906+897907config CPU_MIPS32_R1898908 bool "MIPS32 Release 1"899909 depends on SYS_HAS_CPU_MIPS32_R1···11131103 select WEAK_ORDERING1114110411151105endchoice11061106+11071107+config SYS_HAS_CPU_LOONGSON211081108+ bool1116110911171110config SYS_HAS_CPU_MIPS32_R111181111 bool···1450143714511438config CPU_HAS_WB14521439 bool14401440+14411441+config 64BIT_CONTEXT14421442+ bool "Save 64bit integer registers"14431443+ depends on 32BIT && CPU_LOONGSON214441444+ help14451445+ Loongson2 CPU is 64bit , when used in 32BIT mode, its integer14461446+ registers can still be accessed as 64bit, mainly for multimedia14471447+ instructions. We must have all 64bit save/restored to make sure14481448+ those instructions to get correct result.1453144914541450#14551451# Vectored interrupt mode is an R2 feature
···335335336336static inline void local_r4k___flush_cache_all(void * args)337337{338338+#if defined(CONFIG_CPU_LOONGSON2)339339+ r4k_blast_scache();340340+ return;341341+#endif338342 r4k_blast_dcache();339343 r4k_blast_icache();340344···852848 c->options |= MIPS_CPU_PREFETCH;853849 break;854850851851+ case CPU_LOONGSON2:852852+ icache_size = 1 << (12 + ((config & CONF_IC) >> 9));853853+ c->icache.linesz = 16 << ((config & CONF_IB) >> 5);854854+ if (prid & 0x3)855855+ c->icache.ways = 4;856856+ else857857+ c->icache.ways = 2;858858+ c->icache.waybit = 0;859859+860860+ dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));861861+ c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);862862+ if (prid & 0x3)863863+ c->dcache.ways = 4;864864+ else865865+ c->dcache.ways = 2;866866+ c->dcache.waybit = 0;867867+ break;868868+855869 default:856870 if (!(config & MIPS_CONF_M))857871 panic("Don't know how to probe P-caches on this cpu.");···985963 break;986964 }987965966966+#ifdef CONFIG_CPU_LOONGSON2967967+ /*968968+ * LOONGSON2 has 4 way icache, but when using indexed cache op,969969+ * one op will act on all 4 ways970970+ */971971+ c->icache.ways = 1;972972+#endif973973+988974 printk("Primary instruction cache %ldkB, %s, %s, linesize %d bytes.\n",989975 icache_size >> 10,990976 cpu_has_vtag_icache ? "virtually tagged" : "physically tagged",···10661036 return 1;10671037}1068103810391039+#if defined(CONFIG_CPU_LOONGSON2)10401040+static void __init loongson2_sc_init(void)10411041+{10421042+ struct cpuinfo_mips *c = ¤t_cpu_data;10431043+10441044+ scache_size = 512*1024;10451045+ c->scache.linesz = 32;10461046+ c->scache.ways = 4;10471047+ c->scache.waybit = 0;10481048+ c->scache.waysize = scache_size / (c->scache.ways);10491049+ c->scache.sets = scache_size / (c->scache.linesz * c->scache.ways);10501050+ pr_info("Unified secondary cache %ldkB %s, linesize %d bytes.\n",10511051+ scache_size >> 10, way_string[c->scache.ways], c->scache.linesz);10521052+10531053+ c->options |= MIPS_CPU_INCLUSIVE_CACHES;10541054+}10551055+#endif10561056+10691057extern int r5k_sc_init(void);10701058extern int rm7k_sc_init(void);10711059extern int mips_sc_init(void);···11321084 rm7k_sc_init();11331085#endif11341086 return;10871087+10881088+#if defined(CONFIG_CPU_LOONGSON2)10891089+ case CPU_LOONGSON2:10901090+ loongson2_sc_init();10911091+ return;10921092+#endif1135109311361094 default:11371095 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
+22-1
arch/mips/mm/tlb-r4k.c
···48484949#endif /* CONFIG_MIPS_MT_SMTC */50505151+#if defined(CONFIG_CPU_LOONGSON2)5252+/*5353+ * LOONGSON2 has a 4 entry itlb which is a subset of dtlb,5454+ * unfortrunately, itlb is not totally transparent to software.5555+ */5656+#define FLUSH_ITLB write_c0_diag(4);5757+5858+#define FLUSH_ITLB_VM(vma) { if ((vma)->vm_flags & VM_EXEC) write_c0_diag(4); }5959+6060+#else6161+6262+#define FLUSH_ITLB6363+#define FLUSH_ITLB_VM(vma)6464+6565+#endif6666+5167void local_flush_tlb_all(void)5268{5369 unsigned long flags;···8973 }9074 tlbw_use_hazard();9175 write_c0_entryhi(old_ctx);7676+ FLUSH_ITLB;9277 EXIT_CRITICAL(flags);9378}9479···153136 } else {154137 drop_mmu_context(mm, cpu);155138 }139139+ FLUSH_ITLB;156140 EXIT_CRITICAL(flags);157141 }158142}···196178 } else {197179 local_flush_tlb_all();198180 }181181+ FLUSH_ITLB;199182 EXIT_CRITICAL(flags);200183}201184···229210230211 finish:231212 write_c0_entryhi(oldpid);213213+ FLUSH_ITLB_VM(vma);232214 EXIT_CRITICAL(flags);233215 }234216}···261241 tlbw_use_hazard();262242 }263243 write_c0_entryhi(oldpid);264264-244244+ FLUSH_ITLB;265245 EXIT_CRITICAL(flags);266246}267247···313293 else314294 tlb_write_indexed();315295 tlbw_use_hazard();296296+ FLUSH_ITLB_VM(vma);316297 EXIT_CRITICAL(flags);317298}318299
+5-3
arch/mips/mm/tlbex.c
···893893 case CPU_4KSC:894894 case CPU_20KC:895895 case CPU_25KF:896896+ case CPU_LOONGSON2:896897 tlbw(p);897898 break;898899···12771276 * need three, with the second nop'ed and the third being12781277 * unused.12791278 */12801280-#ifdef CONFIG_32BIT12791279+ /* Loongson2 ebase is different than r4k, we have more space */12801280+#if defined(CONFIG_32BIT) || defined(CONFIG_CPU_LOONGSON2)12811281 if ((p - tlb_handler) > 64)12821282 panic("TLB refill handler space exceeded");12831283#else···12911289 /*12921290 * Now fold the handler in the TLB refill handler space.12931291 */12941294-#ifdef CONFIG_32BIT12921292+#if defined(CONFIG_32BIT) || defined(CONFIG_CPU_LOONGSON2)12951293 f = final_handler;12961294 /* Simplest case, just copy the handler. */12971295 copy_handler(relocs, labels, tlb_handler, p, f);···13381336 final_len);1339133713401338 f = final_handler;13411341-#ifdef CONFIG_64BIT13391339+#if defined(CONFIG_64BIT) && !defined(CONFIG_CPU_LOONGSON2)13421340 if (final_len > 32)13431341 final_len = 64;13441342 else
···8989#define PRID_IMP_34K 0x95009090#define PRID_IMP_24KE 0x96009191#define PRID_IMP_74K 0x97009292+#define PRID_IMP_LOONGSON1 0x42009393+#define PRID_IMP_LOONGSON2 0x630092949395/*9496 * These are the PRID's for when 23:16 == PRID_COMP_SIBYTE···213211#define CPU_SB1A 62214212#define CPU_74K 63215213#define CPU_R14000 64216216-#define CPU_LAST 64214214+#define CPU_LOONGSON1 65215215+#define CPU_LOONGSON2 66216216+217217+#define CPU_LAST 66217218218219/*219220 * ISA Level encodings
+2
include/asm-mips/module.h
···112112#define MODULE_PROC_FAMILY "RM9000 "113113#elif defined CONFIG_CPU_SB1114114#define MODULE_PROC_FAMILY "SB1 "115115+#elif defined CONFIG_CPU_LOONGSON2116116+#define MODULE_PROC_FAMILY "LOONGSON2 "115117#else116118#error MODULE_PROC_FAMILY undefined for your processor configuration117119#endif