[U-Boot] [PATCH 12/19] riscv: Do some basic architecture level cpu initialization
Bin Meng
bmeng.cn at gmail.com
Tue Nov 13 08:22:00 UTC 2018
Implement arch_cpu_init() to do some basic architecture level cpu
initialization, like FPU enable, etc.
Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
---
arch/riscv/cpu/cpu.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
index d9f820c..4e508cf 100644
--- a/arch/riscv/cpu/cpu.c
+++ b/arch/riscv/cpu/cpu.c
@@ -5,6 +5,7 @@
#include <common.h>
#include <asm/csr.h>
+#include <asm/encoding.h>
/*
* prior_stage_fdt_address must be stored in the data section since it is used
@@ -53,3 +54,23 @@ int print_cpuinfo(void)
return 0;
}
+
+int arch_cpu_init(void)
+{
+ /* Enable FPU */
+ if (supports_extension('d') || supports_extension('f')) {
+ csr_write(mstatus, MSTATUS_FS);
+ csr_write(fcsr, 0);
+ }
+
+ /* Enable user/supervisor use of perf counters */
+ if (supports_extension('s'))
+ csr_write(scounteren, -1);
+ csr_write(mcounteren, -1);
+
+ /* Disable paging */
+ if (supports_extension('s'))
+ csr_write(sptbr, 0);
+
+ return 0;
+}
--
2.7.4
More information about the U-Boot
mailing list