-
Notifications
You must be signed in to change notification settings - Fork 8k
arch: riscv: introduce common layer for RISC-V custom CSRs #93697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
config CPU_HAS_ANDES_EXECIT | ||
bool | ||
help | ||
The AndesCore supports EXEC.IT instruction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
help text indent is 1x tab followed by 2x spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it, thanks.
The AndesCore supports EXEC.IT instruction. | ||
|
||
config RISCV_CUSTOM_CSR_ANDES_EXECIT | ||
bool "Andes V5 EXEC.IT extension" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do any of these have prompts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This remains the original design from andestech/ae350 and telink/tlsr/tlsr951x.
The SoC selects Andes extensions through CPU_HAS_ANDES_XXX
, while applications can decide whether to use them or not.
For example, a SoC may support the Andes HWDSP or PFT extension, but if the application doesn’t use them, the user can disable these features via these options.
dfc6db4
to
9ed0e2a
Compare
Removed old Kconfig option in adp_xc7k_ae350_clic_defconfig. Hi @kevinwang821020 , there are some issues with the dma_andes_atcdmac300 driver check or the adp_xc7k_ae350.conf in tests/drivers/dma. |
I wonder if Either this is vendor specific in which case this should be in |
Based on the current atcdmac driver codebase, it need to do the cache operations(CONFIG_CACHE_MANAGEMENT) for chain_block when DCACHE is enabled, even CONFIG_NOCACHE_MEMORY is enable. I have already prepared a previous PR ( PR #85272 ) which includes fixing this problem. |
9ed0e2a
to
3f7bb7c
Compare
Right, custom CSR is RISC-V feature, I think placing these in Moved the custom CSR common code to |
Rebased to main and enabled Andes custom CSR support for Egis ET171. Andes specific toolchain options currently in soc/egis/et171/CMakeLists.txt will be moved to cmake/compiler/andes in #96833. ping @jackylee-go. |
0ebe37a
to
6cf34e3
Compare
|
||
if DT_HAS_ANDESTECH_ANDESCORE_V5_ENABLED | ||
|
||
rsource "andes/Kconfig" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is ahead of its time - the file is only available in the next commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise
6cf34e3
to
d8f2bd1
Compare
RISC-V allows custom CSR implementation. Some SoCs from different vendors may share the same core or the same custom CSR definitions and drivers. This patch introduces 'arch/riscv/custom', which centralizes support for custom CSRs, allowing code reuse across SoCs that come from different vendors. Currently supported thess custom CSR: 1. Andes 2. Nuclei 3. OpenHWGroup CVA6 4. OpenISA RI5CY 5. OpenISA Zero-riscy 6. T-Head Xuantie Signed-off-by: Jimmy Zheng <[email protected]>
759a141
to
3e90903
Compare
I add arch/riscv/custom for RISC-V custom CSR originally, while I think it also fit for RISC-V custom instruction. Move arch/riscv/xuantie to arch/riscv/custom/thead.
|
soc/andestech/ae350/CMakeLists.txt
Outdated
if(CONFIG_SOC_SERIES_ANDES_AE350) | ||
set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld CACHE INTERNAL "") | ||
if(CONFIG_RISCV_CUSTOM_CSR_ANDES_NEXECIT) | ||
zephyr_ld_options(-Wl,--mnexecitop) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no place for these in this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it.
soc/egis/et171/CMakeLists.txt
Outdated
|
||
# Note: AndeStar V5 DSP needs custom Andes V5 toolchain | ||
if(CONFIG_RISCV_CUSTOM_CSR_ANDES_HWDSP) | ||
zephyr_cc_option(-mext-dsp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or here
Rework Andes-specific CSR to use RISC-V custom CSR common code. Move these stuff to 'arch/riscv/custom/andes': 1. Rename 'soc_v5.h' to 'andes_csr.h' for CSR definitions. 2. Replace '_start' with '__reset' hook for low-level CSR initialization. 3. Move CSR context to common macro '__custom_csr_save/restore_context'. 4. Move 'EXECIT' CSR support to common code. 5. Move PMA CSR driver to common code. 6. Use RISC-V common linker.ld instead of SoC-specific linker.ld. Signed-off-by: Jimmy Zheng <[email protected]>
TLSR951x also supports Andes extended CSR. Reworks the following CSR handling to use the RISC-V custom CSR common code: 1. Use common macros for HWDSP CSR context save/restore. 2. Use common macros for PFT CSR context save/restore. 3. Use common low-level CSR initialization via __reset hook. Signed-off-by: Jimmy Zheng <[email protected]>
Egis ET171 implements Andes custom CSRs. Enable the following features: 1. Low level initialization of Andes CSRs 2. HWDSP and PowerBrake extensions with context save/restore 3. EXEC.IT extension Signed-off-by: Jimmy Zheng <[email protected]>
GD32VF103 uses Nuclei-specific CSR. Move 'nuclei_csr.h' to 'arch/riscv/custom' to allow reuse across SoCs with the same Nuclei core. Signed-off-by: Jimmy Zheng <[email protected]>
CVA6 supports custom CSR. Move 'cva6.h' to 'arch/riscv/custom/cva6_csr.h', allowing other SoCs using the CVA6 core to reuse the same CSR definitions. Signed-off-by: Jimmy Zheng <[email protected]>
Update OpenISA RI5CY and Zero-RISCY CSR handling to use RISC-V custom CSR common code. Move these stuff to 'arch/riscv/custom/openisa': 1. Rename 'soc_ri5cy.h' to 'ri5cy_csr.h' for CSR definitions. 2. Rename 'soc_zero_riscy.h' to 'zero_riscy_csr.h' for CSR definitions. 3. Move CSR context to common macro '__custom_csr_save/restore_context'. 4. Move compiler option '-march=rv32imcxpulpv2' to common code. Signed-off-by: Jimmy Zheng <[email protected]>
Move Xuantie supprot from arch/riscv/core/xuantie to the custom common layer arch/riscv/custom/thead, with the following changes: 1. Rename Kconfig name CACHE_XTHEADCMO -> RISCV_CUSTOM_CSR_THEAD_CMO 2. Split the original arch/riscv/core/xuantie/Kconfig to a. arch/riscv/custom/thead/Kconfig: for T-Head extension b. arch/riscv/custom/thead/Kconfig.core: for T-Head CPU series (e.g. Xuantie E907) 3. Move cache line size defaults to SoC devicetree Signed-off-by: Jimmy Zheng <[email protected]>
3e90903
to
de100db
Compare
|
Remove the newly add Andes specific toolchain options in soc/egis/et171 and soc/andestech/ae350. |
This PR is inspired by #91940.
RISC-V allows custom CSR implementation. Some SoCs from different SoC vendors may share the same core or the same custom CSR definitions and drivers.
For example, Andes AE350, Telink TLSR9518, and Egis ET171 all support Andes-specific CSRs.
This PR introduces
soc/common/riscv-custom
zephyr/arch/riscv/custom
, which centralizes support for custom CSRs, allowing code reuse across SoCs that come from different vendors.Currently supported these custom CSR: