soc: telink: tlsr951x: use RISC-V custom CSR common code
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 <jimmyzhe@andestech.com>
This commit is contained in:
committed by
Chris Friedt
parent
679ce42f15
commit
7ee9fd978c
@@ -8,6 +8,3 @@ CONFIG_UART_INTERRUPT_DRIVEN=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_CONSOLE=y
|
||||
CONFIG_UART_CONSOLE=y
|
||||
|
||||
# HW DSP options
|
||||
CONFIG_TELINK_B91_HWDSP=n
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
cpu0: cpu@0 {
|
||||
reg = <0>;
|
||||
clock-frequency = <24000000>;
|
||||
compatible = "telink,b91", "riscv";
|
||||
compatible = "telink,b91", "andestech,andescore-v5", "riscv";
|
||||
riscv,isa = "rv32imac_zicsr_zifencei";
|
||||
|
||||
hlic: interrupt-controller {
|
||||
|
||||
@@ -13,7 +13,7 @@ zephyr_include_directories(.)
|
||||
zephyr_ld_options(-fuse-ld=bfd)
|
||||
|
||||
# Set compile options
|
||||
zephyr_compile_options_ifdef(CONFIG_TELINK_B91_HWDSP -mext-dsp)
|
||||
zephyr_compile_options_ifdef(CONFIG_RISCV_CUSTOM_CSR_ANDES_HWDSP -mext-dsp)
|
||||
zephyr_compile_options_ifndef(CONFIG_RISCV_GP -mno-relax)
|
||||
zephyr_linker_sources(ROM_START SORT_KEY 0x0 init.ld)
|
||||
|
||||
|
||||
@@ -15,19 +15,23 @@ config SOC_SERIES_TLSR951X
|
||||
select RISCV_SOC_HAS_GP_RELATIVE_ADDRESSING
|
||||
select HAS_TELINK_DRIVERS
|
||||
select CPU_HAS_FPU
|
||||
select INCLUDE_RESET_VECTOR
|
||||
select CPU_HAS_DCACHE
|
||||
select CPU_HAS_ICACHE
|
||||
select CPU_HAS_ANDES_HWDSP
|
||||
select CPU_HAS_ANDES_PFT
|
||||
select RISCV_SOC_CONTEXT_SAVE if RISCV_CUSTOM_CSR_ANDES_HWDSP
|
||||
select RISCV_SOC_CONTEXT_SAVE if RISCV_CUSTOM_CSR_ANDES_PFT
|
||||
imply XIP
|
||||
select SOC_EARLY_INIT_HOOK
|
||||
|
||||
if SOC_SERIES_TLSR951X
|
||||
|
||||
config TELINK_B91_HWDSP
|
||||
bool "Support Hardware DSP"
|
||||
select RISCV_SOC_CONTEXT_SAVE
|
||||
bool
|
||||
select DEPRECATED
|
||||
|
||||
config TELINK_B91_PFT_ARCH
|
||||
bool "Support performance throttling"
|
||||
default y
|
||||
select RISCV_SOC_CONTEXT_SAVE
|
||||
bool
|
||||
select DEPRECATED
|
||||
|
||||
endif # SOC_SERIES_TLSR951X
|
||||
|
||||
@@ -30,4 +30,8 @@ config 2ND_LVL_INTR_00_OFFSET
|
||||
config HAS_FLASH_LOAD_OFFSET
|
||||
default y if BOOTLOADER_MCUBOOT
|
||||
|
||||
choice CACHE_TYPE
|
||||
default EXTERNAL_CACHE
|
||||
endchoice
|
||||
|
||||
endif # SOC_SERIES_TLSR951X
|
||||
|
||||
@@ -7,43 +7,16 @@
|
||||
#ifndef SOC_RISCV_TELINK_B91_SOC_CONTEXT_H
|
||||
#define SOC_RISCV_TELINK_B91_SOC_CONTEXT_H
|
||||
|
||||
#include <csr_context.h>
|
||||
|
||||
#ifdef CONFIG_RISCV_SOC_CONTEXT_SAVE
|
||||
|
||||
/* Telink B91 specific registers. */
|
||||
#if defined(CONFIG_TELINK_B91_PFT_ARCH) && defined(__riscv_dsp)
|
||||
#define SOC_ESF_MEMBERS \
|
||||
uint32_t mxstatus; \
|
||||
uint32_t ucode \
|
||||
#define SOC_ESF_MEMBERS \
|
||||
CUSTOM_CSR_ESF_MEMBERS
|
||||
|
||||
#define SOC_ESF_INIT \
|
||||
0xdeadbaad, \
|
||||
0xdeadbaad
|
||||
|
||||
#define SOC_ESF_THREAD_INIT(soc_context) \
|
||||
(soc_context)->mxstatus = 0; \
|
||||
(soc_context)->ucode = 0
|
||||
|
||||
#elif defined(CONFIG_TELINK_B91_PFT_ARCH)
|
||||
#define SOC_ESF_MEMBERS \
|
||||
uint32_t mxstatus
|
||||
|
||||
#define SOC_ESF_INIT \
|
||||
0xdeadbaad
|
||||
|
||||
#define SOC_ESF_THREAD_INIT(soc_context) \
|
||||
(soc_context)->mxstatus = 0
|
||||
|
||||
#elif defined(__riscv_dsp)
|
||||
|
||||
#define SOC_ESF_MEMBERS \
|
||||
uint32_t ucode
|
||||
|
||||
#define SOC_ESF_INIT \
|
||||
0xdeadbaad
|
||||
|
||||
#define SOC_ESF_THREAD_INIT(soc_context) \
|
||||
(soc_context)->ucode = 0
|
||||
#endif
|
||||
#define SOC_ESF_INIT \
|
||||
CUSTOM_CSR_ESF_INIT
|
||||
|
||||
#endif /* CONFIG_RISCV_SOC_CONTEXT_SAVE */
|
||||
|
||||
|
||||
@@ -6,51 +6,24 @@
|
||||
|
||||
#include <zephyr/offsets.h>
|
||||
#include <zephyr/toolchain.h>
|
||||
#include <csr_irq.inc>
|
||||
|
||||
#include <soc.h>
|
||||
|
||||
#define NDS_MXSTATUS 0x7C4
|
||||
#ifdef CONFIG_RISCV_SOC_CONTEXT_SAVE
|
||||
|
||||
/* Exports */
|
||||
#ifdef CONFIG_RISCV_SOC_CONTEXT_SAVE
|
||||
GTEXT(__soc_save_context)
|
||||
GTEXT(__soc_restore_context)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RISCV_SOC_CONTEXT_SAVE
|
||||
|
||||
SECTION_FUNC(exception.other, __soc_save_context)
|
||||
|
||||
#ifdef CONFIG_TELINK_B91_PFT_ARCH
|
||||
csrr t0, NDS_MXSTATUS
|
||||
#endif
|
||||
#ifdef __riscv_dsp
|
||||
csrr t1, ucode
|
||||
#endif
|
||||
__custom_csr_save_context a0, t0
|
||||
|
||||
#ifdef CONFIG_TELINK_B91_PFT_ARCH
|
||||
sw t0, __soc_esf_t_mxstatus_OFFSET(a0)
|
||||
#endif
|
||||
#ifdef __riscv_dsp
|
||||
sw t1, __soc_esf_t_ucode_OFFSET(a0)
|
||||
#endif
|
||||
ret
|
||||
|
||||
SECTION_FUNC(exception.other, __soc_restore_context)
|
||||
|
||||
#ifdef CONFIG_TELINK_B91_PFT_ARCH
|
||||
lw t0, __soc_esf_t_mxstatus_OFFSET(a0)
|
||||
#endif
|
||||
#ifdef __riscv_dsp
|
||||
lw t1, __soc_esf_t_ucode_OFFSET(a0)
|
||||
#endif
|
||||
__custom_csr_restore_context a0, t0
|
||||
|
||||
#ifdef CONFIG_TELINK_B91_PFT_ARCH
|
||||
csrw NDS_MXSTATUS, t0
|
||||
#endif
|
||||
#ifdef __riscv_dsp
|
||||
csrw ucode, t1
|
||||
#endif
|
||||
ret
|
||||
|
||||
#endif /* CONFIG_RISCV_SOC_CONTEXT_SAVE */
|
||||
|
||||
@@ -7,23 +7,13 @@
|
||||
#ifndef SOC_RISCV_TELINK_B91_SOC_OFFSETS_H
|
||||
#define SOC_RISCV_TELINK_B91_SOC_OFFSETS_H
|
||||
|
||||
#include <csr_offsets.h>
|
||||
|
||||
#ifdef CONFIG_RISCV_SOC_OFFSETS
|
||||
|
||||
/* Telink B91 specific registers. */
|
||||
#if defined(CONFIG_TELINK_B91_PFT_ARCH) && defined(__riscv_dsp)
|
||||
#define GEN_SOC_OFFSET_SYMS() \
|
||||
GEN_OFFSET_SYM(soc_esf_t, mxstatus); \
|
||||
GEN_OFFSET_SYM(soc_esf_t, ucode)
|
||||
|
||||
#elif defined(CONFIG_TELINK_B91_PFT_ARCH)
|
||||
#define GEN_SOC_OFFSET_SYMS() \
|
||||
GEN_OFFSET_SYM(soc_esf_t, mxstatus)
|
||||
|
||||
#elif defined(__riscv_dsp)
|
||||
#define GEN_SOC_OFFSET_SYMS() \
|
||||
GEN_OFFSET_SYM(soc_esf_t, ucode)
|
||||
|
||||
#endif
|
||||
#define GEN_SOC_OFFSET_SYMS() \
|
||||
GEN_CUSTOM_CSR_OFFSET_SYMS()
|
||||
|
||||
#endif /* CONFIG_RISCV_SOC_OFFSETS */
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define NDS_MCACHE_CTL 0x7CA
|
||||
#define NDS_MMISC_CTL 0x7D0
|
||||
|
||||
#include <zephyr/toolchain.h>
|
||||
|
||||
.option push
|
||||
@@ -31,17 +28,6 @@ entry:
|
||||
|
||||
start:
|
||||
|
||||
/* Enable I/D-Cache */
|
||||
csrr t0, NDS_MCACHE_CTL
|
||||
ori t0, t0, 1 #/I-Cache
|
||||
ori t0, t0, 2 #/D-Cache
|
||||
csrw NDS_MCACHE_CTL, t0
|
||||
fence.i
|
||||
|
||||
/* Enable misaligned access and non-blocking load */
|
||||
li t0, (1 << 8) | (1 << 6)
|
||||
csrs NDS_MMISC_CTL, t0
|
||||
|
||||
_ZERO_AES:
|
||||
lui t0, 0
|
||||
la t2, _AES_DATA_VMA_START
|
||||
|
||||
Reference in New Issue
Block a user