hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/arch/nds32/kernel/setup.c
....@@ -2,9 +2,8 @@
22 // Copyright (C) 2005-2017 Andes Technology Corporation
33
44 #include <linux/cpu.h>
5
-#include <linux/bootmem.h>
6
-#include <linux/seq_file.h>
75 #include <linux/memblock.h>
6
+#include <linux/seq_file.h>
87 #include <linux/console.h>
98 #include <linux/screen_info.h>
109 #include <linux/delay.h>
....@@ -16,6 +15,7 @@
1615 #include <asm/proc-fns.h>
1716 #include <asm/cache_info.h>
1817 #include <asm/elf.h>
18
+#include <asm/fpu.h>
1919 #include <nds32_intrinsic.h>
2020
2121 #define HWCAP_MFUSR_PC 0x000001
....@@ -39,8 +39,10 @@
3939 #define HWCAP_FPU_DP 0x040000
4040 #define HWCAP_V2 0x080000
4141 #define HWCAP_DX_REGS 0x100000
42
+#define HWCAP_HWPRE 0x200000
4243
4344 unsigned long cpu_id, cpu_rev, cpu_cfgid;
45
+bool has_fpu = false;
4446 char cpu_series;
4547 char *endianness = NULL;
4648
....@@ -74,6 +76,7 @@
7476 "fpu_dp",
7577 "v2",
7678 "dx_regs",
79
+ "hw_pre",
7780 NULL,
7881 };
7982
....@@ -138,6 +141,11 @@
138141 (aliasing_num - 1) << PAGE_SHIFT;
139142 }
140143 #endif
144
+#ifdef CONFIG_FPU
145
+ /* Disable fpu and enable when it is used. */
146
+ if (has_fpu)
147
+ disable_fpu();
148
+#endif
141149 }
142150
143151 static void __init setup_cpuinfo(void)
....@@ -182,9 +190,10 @@
182190 if (cpu_cfgid & 0x0004)
183191 elf_hwcap |= HWCAP_EXT2;
184192
185
- if (cpu_cfgid & 0x0008)
193
+ if (cpu_cfgid & 0x0008) {
186194 elf_hwcap |= HWCAP_FPU;
187
-
195
+ has_fpu = true;
196
+ }
188197 if (cpu_cfgid & 0x0010)
189198 elf_hwcap |= HWCAP_STRING;
190199
....@@ -214,6 +223,11 @@
214223 if (__nds32__mfsr(NDS32_SR_MSC_CFG) & MSC_CFG_mskL2C)
215224 elf_hwcap |= HWCAP_L2C;
216225
226
+#ifdef CONFIG_HW_PRE
227
+ if (__nds32__mfsr(NDS32_SR_MISC_CTL) & MISC_CTL_makHWPRE_EN)
228
+ elf_hwcap |= HWCAP_HWPRE;
229
+#endif
230
+
217231 tmp = __nds32__mfsr(NDS32_SR_CACHE_CTL);
218232 if (!IS_ENABLED(CONFIG_CPU_DCACHE_DISABLE))
219233 tmp |= CACHE_CTL_mskDC_EN;
....@@ -235,12 +249,8 @@
235249 memory_end = memory_start = 0;
236250
237251 /* Find main memory where is the kernel */
238
- for_each_memblock(memory, region) {
239
- memory_start = region->base;
240
- memory_end = region->base + region->size;
241
- pr_info("%s: Memory: 0x%x-0x%x\n", __func__,
242
- memory_start, memory_end);
243
- }
252
+ memory_start = memblock_start_of_DRAM();
253
+ memory_end = memblock_end_of_DRAM();
244254
245255 if (!memory_end) {
246256 panic("No memory!");
....@@ -302,11 +312,6 @@
302312 parse_early_param();
303313
304314 unflatten_and_copy_device_tree();
305
-
306
- if(IS_ENABLED(CONFIG_VT)) {
307
- if(IS_ENABLED(CONFIG_DUMMY_CONSOLE))
308
- conswitchp = &dummy_con;
309
- }
310315
311316 *cmdline_p = boot_command_line;
312317 early_trap_init();