Skip to content

Commit 2d147d7

Browse files
cyanyang-sifivepalmer-dabbelt
authored andcommitted
riscv: Add SiFive xsfvqmaccdod and xsfvqmaccqoq vendor extensions
Add SiFive vendor extension support to the kernel with the target of "xsfvqmaccdod" and "xsfvqmaccqoq". Signed-off-by: Cyan Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 0f733b5 commit 2d147d7

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed

arch/riscv/Kconfig.vendor

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ config RISCV_ISA_VENDOR_EXT_ANDES
1616
If you don't know what to do here, say Y.
1717
endmenu
1818

19+
menu "SiFive"
20+
config RISCV_ISA_VENDOR_EXT_SIFIVE
21+
bool "SiFive vendor extension support"
22+
select RISCV_ISA_VENDOR_EXT
23+
default y
24+
help
25+
Say N here if you want to disable all SiFive vendor extension
26+
support. This will cause any SiFive vendor extensions that are
27+
requested by hardware probing to be ignored.
28+
29+
If you don't know what to do here, say Y.
30+
endmenu
31+
1932
menu "T-Head"
2033
config RISCV_ISA_VENDOR_EXT_THEAD
2134
bool "T-Head vendor extension support"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _ASM_RISCV_VENDOR_EXTENSIONS_SIFIVE_H
3+
#define _ASM_RISCV_VENDOR_EXTENSIONS_SIFIVE_H
4+
5+
#include <asm/vendor_extensions.h>
6+
7+
#include <linux/types.h>
8+
9+
#define RISCV_ISA_VENDOR_EXT_XSFVQMACCDOD 0
10+
#define RISCV_ISA_VENDOR_EXT_XSFVQMACCQOQ 1
11+
12+
extern struct riscv_isa_vendor_ext_data_list riscv_isa_vendor_ext_list_sifive;
13+
14+
#endif

arch/riscv/kernel/vendor_extensions.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <asm/vendorid_list.h>
77
#include <asm/vendor_extensions.h>
88
#include <asm/vendor_extensions/andes.h>
9+
#include <asm/vendor_extensions/sifive.h>
910
#include <asm/vendor_extensions/thead.h>
1011

1112
#include <linux/array_size.h>
@@ -15,6 +16,9 @@ struct riscv_isa_vendor_ext_data_list *riscv_isa_vendor_ext_list[] = {
1516
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_ANDES
1617
&riscv_isa_vendor_ext_list_andes,
1718
#endif
19+
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE
20+
&riscv_isa_vendor_ext_list_sifive,
21+
#endif
1822
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_THEAD
1923
&riscv_isa_vendor_ext_list_thead,
2024
#endif
@@ -45,6 +49,12 @@ bool __riscv_isa_vendor_extension_available(int cpu, unsigned long vendor, unsig
4549
cpu_bmap = riscv_isa_vendor_ext_list_andes.per_hart_isa_bitmap;
4650
break;
4751
#endif
52+
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE
53+
case SIFIVE_VENDOR_ID:
54+
bmap = &riscv_isa_vendor_ext_list_sifive.all_harts_isa_bitmap;
55+
cpu_bmap = riscv_isa_vendor_ext_list_sifive.per_hart_isa_bitmap;
56+
break;
57+
#endif
4858
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_THEAD
4959
case THEAD_VENDOR_ID:
5060
bmap = &riscv_isa_vendor_ext_list_thead.all_harts_isa_bitmap;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22

33
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_ANDES) += andes.o
4+
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE) += sifive.o
45
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_THEAD) += thead.o
56
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_THEAD) += thead_hwprobe.o
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
3+
#include <asm/cpufeature.h>
4+
#include <asm/vendor_extensions.h>
5+
#include <asm/vendor_extensions/sifive.h>
6+
7+
#include <linux/array_size.h>
8+
#include <linux/types.h>
9+
10+
/* All SiFive vendor extensions supported in Linux */
11+
const struct riscv_isa_ext_data riscv_isa_vendor_ext_sifive[] = {
12+
__RISCV_ISA_EXT_DATA(xsfvqmaccdod, RISCV_ISA_VENDOR_EXT_XSFVQMACCDOD),
13+
__RISCV_ISA_EXT_DATA(xsfvqmaccqoq, RISCV_ISA_VENDOR_EXT_XSFVQMACCQOQ),
14+
};
15+
16+
struct riscv_isa_vendor_ext_data_list riscv_isa_vendor_ext_list_sifive = {
17+
.ext_data_count = ARRAY_SIZE(riscv_isa_vendor_ext_sifive),
18+
.ext_data = riscv_isa_vendor_ext_sifive,
19+
};

0 commit comments

Comments
 (0)