@@ -109,6 +109,9 @@
#define CSR_MIP 0x344
#define CSR_PMPCFG0 0x3a0
#define CSR_PMPADDR0 0x3b0
+#define CSR_MVENDORID 0xf11
+#define CSR_MARCHID 0xf12
+#define CSR_MIMPID 0xf13
#define CSR_MHARTID 0xf14
#ifdef CONFIG_RISCV_M_MODE
@@ -44,6 +44,12 @@ bool __riscv_isa_extension_available(const unsigned long *isa_bitmap, int bit);
#define riscv_isa_extension_available(isa_bitmap, ext) \
__riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_##ext)
+struct cpu_manufacturer_info_t {
+ unsigned long vendor_id;
+ unsigned long arch_id;
+ unsigned long imp_id;
+};
+
#endif
#endif /* _ASM_RISCV_HWCAP_H */
@@ -71,6 +71,8 @@ int riscv_of_parent_hartid(struct device_node *node);
extern void riscv_fill_hwcap(void);
+void riscv_fill_cpu_manufacturer_info(void);
+
#endif /* __ASSEMBLY__ */
#endif /* _ASM_RISCV_PROCESSOR_H */
@@ -10,6 +10,7 @@
#include <linux/of.h>
#include <linux/linkage.h>
#include <linux/types.h>
+#include <asm/hwcap.h>
#define SOC_EARLY_INIT_DECLARE(name, compat, fn) \
static const struct of_device_id __soc_early_init__##name \
@@ -12,6 +12,8 @@
#include <asm/hwcap.h>
#include <asm/smp.h>
#include <asm/switch_to.h>
+#include <asm/sbi.h>
+#include <asm/csr.h>
unsigned long elf_hwcap __read_mostly;
@@ -22,6 +24,8 @@ static DECLARE_BITMAP(riscv_isa, RISCV_ISA_EXT_MAX) __read_mostly;
bool has_fpu __read_mostly;
#endif
+struct cpu_manufacturer_info_t cpu_mfr_info;
+
/**
* riscv_isa_extension_base() - Get base extension word
*
@@ -149,3 +153,16 @@ void riscv_fill_hwcap(void)
has_fpu = true;
#endif
}
+
+void riscv_fill_cpu_manufacturer_info(void)
+{
+#ifndef CONFIG_RISCV_M_MODE
+ cpu_mfr_info.vendor_id = sbi_get_vendorid();
+ cpu_mfr_info.arch_id = sbi_get_archid();
+ cpu_mfr_info.imp_id = sbi_get_impid();
+#else
+ cpu_mfr_info.vendor_id = csr_read(CSR_MVENDORID);
+ cpu_mfr_info.arch_id = csr_read(CSR_MARCHID);
+ cpu_mfr_info.imp_id = csr_read(CSR_MIMPID);
+#endif
+}
@@ -271,6 +271,8 @@ void __init setup_arch(char **cmdline_p)
#endif
riscv_fill_hwcap();
+
+ riscv_fill_cpu_manufacturer_info();
}
static int __init topology_init(void)
@@ -6,6 +6,7 @@
#include <linux/libfdt.h>
#include <linux/pgtable.h>
#include <asm/soc.h>
+#include <asm/hwcap.h>
/*
* This is called extremly early, before parse_dtb(), to allow initializing