Lines Matching +full:static +full:- +full:config

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
16 #include <asm/cpu-features.h>
20 #include <asm/pgtable-bits.h>
30 static inline void cpu_set_fpu_fcsr_mask(struct cpuinfo_loongarch *c) in cpu_set_fpu_fcsr_mask()
34 fcsr = c->fpu_csr0; in cpu_set_fpu_fcsr_mask()
52 c->fpu_mask = ~(fcsr0 ^ fcsr1) & ~mask; in cpu_set_fpu_fcsr_mask()
55 /* simd = -1/0/128/256 */
56 static unsigned int simd = -1U;
58 static int __init cpu_setup_simd(char *str) in cpu_setup_simd()
68 static int __init cpu_final_simd(void) in cpu_final_simd()
73 c->options &= ~LOONGARCH_CPU_LSX; in cpu_final_simd()
78 c->options &= ~LOONGARCH_CPU_LASX; in cpu_final_simd()
84 if (c->options & LOONGARCH_CPU_LSX) in cpu_final_simd()
87 if (c->options & LOONGARCH_CPU_LASX) in cpu_final_simd()
97 static inline void set_elf_platform(int cpu, const char *plat) in set_elf_platform()
107 static void cpu_probe_addrbits(struct cpuinfo_loongarch *c) in cpu_probe_addrbits()
110 c->pabits = (read_cpucfg(LOONGARCH_CPUCFG1) & CPUCFG1_PABITS) >> 4; in cpu_probe_addrbits()
111 c->vabits = (read_cpucfg(LOONGARCH_CPUCFG1) & CPUCFG1_VABITS) >> 12; in cpu_probe_addrbits()
112 vm_map_base = 0UL - (1UL << c->vabits); in cpu_probe_addrbits()
116 static void set_isa(struct cpuinfo_loongarch *c, unsigned int isa) in set_isa()
120 c->isa_level |= LOONGARCH_CPU_ISA_LA64; in set_isa()
123 c->isa_level |= LOONGARCH_CPU_ISA_LA32S; in set_isa()
126 c->isa_level |= LOONGARCH_CPU_ISA_LA32R; in set_isa()
131 static void cpu_probe_common(struct cpuinfo_loongarch *c) in cpu_probe_common()
133 unsigned int config; in cpu_probe_common() local
136 c->options = LOONGARCH_CPU_CPUCFG | LOONGARCH_CPU_CSR | LOONGARCH_CPU_VINT; in cpu_probe_common()
140 config = read_cpucfg(LOONGARCH_CPUCFG1); in cpu_probe_common()
142 switch (config & CPUCFG1_ISA) { in cpu_probe_common()
156 if (config & CPUCFG1_PAGING) in cpu_probe_common()
157 c->options |= LOONGARCH_CPU_TLB; in cpu_probe_common()
158 if (config & CPUCFG1_IOCSR) in cpu_probe_common()
159 c->options |= LOONGARCH_CPU_IOCSR; in cpu_probe_common()
160 if (config & CPUCFG1_UAL) { in cpu_probe_common()
161 c->options |= LOONGARCH_CPU_UAL; in cpu_probe_common()
164 if (config & CPUCFG1_CRC32) { in cpu_probe_common()
165 c->options |= LOONGARCH_CPU_CRC32; in cpu_probe_common()
169 config = read_cpucfg(LOONGARCH_CPUCFG2); in cpu_probe_common()
170 if (config & CPUCFG2_LAM) { in cpu_probe_common()
171 c->options |= LOONGARCH_CPU_LAM; in cpu_probe_common()
174 if (config & CPUCFG2_FP) { in cpu_probe_common()
175 c->options |= LOONGARCH_CPU_FPU; in cpu_probe_common()
179 if ((config & CPUCFG2_LSX) && (simd >= 128)) { in cpu_probe_common()
180 c->options |= LOONGARCH_CPU_LSX; in cpu_probe_common()
185 if ((config & CPUCFG2_LASX) && (simd >= 256)) { in cpu_probe_common()
186 c->options |= LOONGARCH_CPU_LASX; in cpu_probe_common()
190 if (config & CPUCFG2_COMPLEX) { in cpu_probe_common()
191 c->options |= LOONGARCH_CPU_COMPLEX; in cpu_probe_common()
194 if (config & CPUCFG2_CRYPTO) { in cpu_probe_common()
195 c->options |= LOONGARCH_CPU_CRYPTO; in cpu_probe_common()
198 if (config & CPUCFG2_PTW) { in cpu_probe_common()
199 c->options |= LOONGARCH_CPU_PTW; in cpu_probe_common()
202 if (config & CPUCFG2_LSPW) { in cpu_probe_common()
203 c->options |= LOONGARCH_CPU_LSPW; in cpu_probe_common()
206 if (config & CPUCFG2_LVZP) { in cpu_probe_common()
207 c->options |= LOONGARCH_CPU_LVZ; in cpu_probe_common()
211 if (config & CPUCFG2_X86BT) { in cpu_probe_common()
212 c->options |= LOONGARCH_CPU_LBT_X86; in cpu_probe_common()
215 if (config & CPUCFG2_ARMBT) { in cpu_probe_common()
216 c->options |= LOONGARCH_CPU_LBT_ARM; in cpu_probe_common()
219 if (config & CPUCFG2_MIPSBT) { in cpu_probe_common()
220 c->options |= LOONGARCH_CPU_LBT_MIPS; in cpu_probe_common()
225 config = read_cpucfg(LOONGARCH_CPUCFG6); in cpu_probe_common()
226 if (config & CPUCFG6_PMP) in cpu_probe_common()
227 c->options |= LOONGARCH_CPU_PMP; in cpu_probe_common()
229 config = csr_read32(LOONGARCH_CSR_ASID); in cpu_probe_common()
230 config = (config & CSR_ASID_BIT) >> CSR_ASID_BIT_SHIFT; in cpu_probe_common()
231 asid_mask = GENMASK(config - 1, 0); in cpu_probe_common()
234 config = read_csr_prcfg1(); in cpu_probe_common()
235 c->timerbits = (config & CSR_CONF1_TMRBITS) >> CSR_CONF1_TMRBITS_SHIFT; in cpu_probe_common()
236 c->ksave_mask = GENMASK((config & CSR_CONF1_KSNUM) - 1, 0); in cpu_probe_common()
237 c->ksave_mask &= ~(EXC_KSAVE_MASK | PERCPU_KSAVE_MASK | KVM_KSAVE_MASK); in cpu_probe_common()
239 config = read_csr_prcfg3(); in cpu_probe_common()
240 switch (config & CSR_CONF3_TLBTYPE) { in cpu_probe_common()
242 c->tlbsizemtlb = 0; in cpu_probe_common()
243 c->tlbsizestlbsets = 0; in cpu_probe_common()
244 c->tlbsizestlbways = 0; in cpu_probe_common()
245 c->tlbsize = 0; in cpu_probe_common()
248 c->tlbsizemtlb = ((config & CSR_CONF3_MTLBSIZE) >> CSR_CONF3_MTLBSIZE_SHIFT) + 1; in cpu_probe_common()
249 c->tlbsizestlbsets = 0; in cpu_probe_common()
250 c->tlbsizestlbways = 0; in cpu_probe_common()
251 c->tlbsize = c->tlbsizemtlb + c->tlbsizestlbsets * c->tlbsizestlbways; in cpu_probe_common()
254 c->tlbsizemtlb = ((config & CSR_CONF3_MTLBSIZE) >> CSR_CONF3_MTLBSIZE_SHIFT) + 1; in cpu_probe_common()
255 c->tlbsizestlbsets = 1 << ((config & CSR_CONF3_STLBIDX) >> CSR_CONF3_STLBIDX_SHIFT); in cpu_probe_common()
256 c->tlbsizestlbways = ((config & CSR_CONF3_STLBWAYS) >> CSR_CONF3_STLBWAYS_SHIFT) + 1; in cpu_probe_common()
257 c->tlbsize = c->tlbsizemtlb + c->tlbsizestlbsets * c->tlbsizestlbways; in cpu_probe_common()
264 c->options |= LOONGARCH_CPU_WATCH; in cpu_probe_common()
271 static char cpu_full_name[MAX_NAME_LEN] = " - ";
273 static inline void cpu_probe_loongson(struct cpuinfo_loongarch *c, unsigned int cpu) in cpu_probe_loongson()
275 uint32_t config; in cpu_probe_loongson() local
280 switch (BIT(fls(c->isa_level) - 1)) { in cpu_probe_loongson()
283 c->cputype = CPU_LOONGSON32; in cpu_probe_loongson()
284 __cpu_family[cpu] = "Loongson-32bit"; in cpu_probe_loongson()
287 c->cputype = CPU_LOONGSON64; in cpu_probe_loongson()
288 __cpu_family[cpu] = "Loongson-64bit"; in cpu_probe_loongson()
292 switch (c->processor_id & PRID_SERIES_MASK) { in cpu_probe_loongson()
321 config = iocsr_read32(LOONGARCH_IOCSR_FEATURES); in cpu_probe_loongson()
322 if (config & IOCSRF_CSRIPI) in cpu_probe_loongson()
323 c->options |= LOONGARCH_CPU_CSRIPI; in cpu_probe_loongson()
324 if (config & IOCSRF_EXTIOI) in cpu_probe_loongson()
325 c->options |= LOONGARCH_CPU_EXTIOI; in cpu_probe_loongson()
326 if (config & IOCSRF_FREQSCALE) in cpu_probe_loongson()
327 c->options |= LOONGARCH_CPU_SCALEFREQ; in cpu_probe_loongson()
328 if (config & IOCSRF_FLATMODE) in cpu_probe_loongson()
329 c->options |= LOONGARCH_CPU_FLATMODE; in cpu_probe_loongson()
330 if (config & IOCSRF_EIODECODE) in cpu_probe_loongson()
331 c->options |= LOONGARCH_CPU_EIODECODE; in cpu_probe_loongson()
332 if (config & IOCSRF_AVEC) in cpu_probe_loongson()
333 c->options |= LOONGARCH_CPU_AVECINT; in cpu_probe_loongson()
334 if (config & IOCSRF_VM) in cpu_probe_loongson()
335 c->options |= LOONGARCH_CPU_HYPERVISOR; in cpu_probe_loongson()
348 static void cpu_report(void) in cpu_report()
353 smp_processor_id(), c->processor_id, cpu_family_string()); in cpu_report()
354 if (c->options & LOONGARCH_CPU_FPU) in cpu_report()
355 pr_info("FPU%d revision is: %08x\n", smp_processor_id(), c->fpu_vers); in cpu_report()
369 c->cputype = CPU_UNKNOWN; in cpu_probe()
370 c->processor_id = read_cpucfg(LOONGARCH_CPUCFG0); in cpu_probe()
371 c->fpu_vers = (read_cpucfg(LOONGARCH_CPUCFG2) & CPUCFG2_FPVERS) >> 3; in cpu_probe()
373 c->fpu_csr0 = FPU_CSR_RN; in cpu_probe()
374 c->fpu_mask = FPU_CSR_RSVD; in cpu_probe()
380 switch (c->processor_id & PRID_COMP_MASK) { in cpu_probe()
387 BUG_ON(c->cputype == CPU_UNKNOWN); in cpu_probe()
393 __ua_limit = ~((1ull << cpu_vabits) - 1); in cpu_probe()