diff --git a/arch/risc-v/src/mpfs/Kconfig b/arch/risc-v/src/mpfs/Kconfig index 532e9f7f720a2..63b36aa6e8844 100644 --- a/arch/risc-v/src/mpfs/Kconfig +++ b/arch/risc-v/src/mpfs/Kconfig @@ -46,6 +46,14 @@ config MPFS_BOOTLOADER ---help--- This NuttX image is used as a bootloader, which will boot only on one hart, putting the others in WFI +config MPFS_CLKINIT + bool "Initialize system clocks" + depends on MPFS_BOOTLOADER + default y + ---help--- + This initilizes the system clocks at mpfs_start.c file. The option may be also turned off + if some other entity has already set them up. + config MPFS_BOARD_PMP bool "Enable board specific PMP configuration" depends on ARCH_USE_MPU && MPFS_BOOTLOADER diff --git a/arch/risc-v/src/mpfs/Make.defs b/arch/risc-v/src/mpfs/Make.defs index b9907d7b78662..11aebc86dd08e 100644 --- a/arch/risc-v/src/mpfs/Make.defs +++ b/arch/risc-v/src/mpfs/Make.defs @@ -27,13 +27,17 @@ CMN_ASRCS += mpfs_head.S endif # Specify our C code within this directory to be included -CHIP_CSRCS = mpfs_allocateheap.c mpfs_clockconfig.c +CHIP_CSRCS = mpfs_allocateheap.c CHIP_CSRCS += mpfs_irq.c mpfs_irq_dispatch.c CHIP_CSRCS += mpfs_lowputc.c mpfs_serial.c CHIP_CSRCS += mpfs_start.c mpfs_timerisr.c CHIP_CSRCS += mpfs_gpio.c mpfs_systemreset.c CHIP_CSRCS += mpfs_plic.c mpfs_dsn.c +ifeq ($(CONFIG_MPFS_CLKINIT),y) +CHIP_CSRCS += mpfs_clockconfig.c +endif + ifeq ($(CONFIG_MPFS_DMA),y) CHIP_CSRCS += mpfs_dma.c endif diff --git a/arch/risc-v/src/mpfs/mpfs_head.S b/arch/risc-v/src/mpfs/mpfs_head.S index e691be33f56d9..77fc982d3aa42 100644 --- a/arch/risc-v/src/mpfs/mpfs_head.S +++ b/arch/risc-v/src/mpfs/mpfs_head.S @@ -49,6 +49,14 @@ __start: csrw CSR_MIE, zero csrw CSR_MIP, zero + /* Clear all IPIs (above doesn't clear them) */ + + csrr a0, CSR_MHARTID + slli t1, a0, 2 + li t0, MPFS_CLINT_BASE + add t1, t1, t0 + sw zero, 0(t1) + /* Initialize the Machine Trap Vector */ la t0, __trap_vec diff --git a/arch/risc-v/src/mpfs/mpfs_start.c b/arch/risc-v/src/mpfs/mpfs_start.c index fb82c2af016c8..c02b568715c4e 100644 --- a/arch/risc-v/src/mpfs/mpfs_start.c +++ b/arch/risc-v/src/mpfs/mpfs_start.c @@ -121,7 +121,7 @@ void __mpfs_start(uint64_t mhartid) /* Setup PLL if not already provided */ -#ifdef CONFIG_MPFS_BOOTLOADER +#ifdef CONFIG_MPFS_CLKINIT mpfs_clockconfig(); #endif diff --git a/arch/risc-v/src/mpfs/mpfs_timerisr.c b/arch/risc-v/src/mpfs/mpfs_timerisr.c index 4608d4637de61..40fc13d6b36c1 100644 --- a/arch/risc-v/src/mpfs/mpfs_timerisr.c +++ b/arch/risc-v/src/mpfs/mpfs_timerisr.c @@ -33,6 +33,7 @@ #include #include "riscv_internal.h" +#include "riscv_sbi.h" #include "mpfs.h" #include "mpfs_clockconfig.h" diff --git a/boards/risc-v/mpfs/icicle/configs/standalone/defconfig b/boards/risc-v/mpfs/icicle/configs/standalone/defconfig deleted file mode 100644 index 532550067b6ce..0000000000000 --- a/boards/risc-v/mpfs/icicle/configs/standalone/defconfig +++ /dev/null @@ -1,61 +0,0 @@ -# -# This file is autogenerated: PLEASE DO NOT EDIT IT. -# -# You can use "make menuconfig" to make any modifications to the installed .config file. -# You can then do "make savedefconfig" to generate a new defconfig file that includes your -# modifications. -# -CONFIG_ARCH="risc-v" -CONFIG_ARCH_BOARD="icicle" -CONFIG_ARCH_BOARD_COMMON=y -CONFIG_ARCH_BOARD_ICICLE_MPFS=y -CONFIG_ARCH_CHIP="mpfs" -CONFIG_ARCH_CHIP_MPFS250T_FCVG484=y -CONFIG_ARCH_CHIP_MPFS=y -CONFIG_ARCH_INTERRUPTSTACK=2048 -CONFIG_ARCH_RISCV=y -CONFIG_ARCH_STACKDUMP=y -CONFIG_BOARD_LOOPSPERMSEC=54000 -CONFIG_DEBUG_ASSERTIONS=y -CONFIG_DEBUG_FEATURES=y -CONFIG_DEBUG_FS=y -CONFIG_DEBUG_FS_ERROR=y -CONFIG_FS_PROCFS=y -CONFIG_FS_ROMFS=y -CONFIG_IDLETHREAD_STACKSIZE=2048 -CONFIG_INIT_ENTRYPOINT="nsh_main" -CONFIG_INIT_STACKSIZE=3072 -CONFIG_INTELHEX_BINARY=y -CONFIG_LIBC_HOSTNAME="icicle" -CONFIG_LIBC_PERROR_STDOUT=y -CONFIG_LIBC_STRERROR=y -CONFIG_MEMSET_64BIT=y -CONFIG_MEMSET_OPTSPEED=y -CONFIG_MPFS_BOOTLOADER=y -CONFIG_MPFS_BOOT_HART=1 -CONFIG_MPFS_DDR_INIT=y -CONFIG_MPFS_ENABLE_DPFPU=y -CONFIG_MPFS_UART0=y -CONFIG_MPFS_UART1=y -CONFIG_NSH_ARCHINIT=y -CONFIG_NSH_DISABLE_IFUPDOWN=y -CONFIG_NSH_DISABLE_MKDIR=y -CONFIG_NSH_DISABLE_RM=y -CONFIG_NSH_DISABLE_RMDIR=y -CONFIG_NSH_DISABLE_UMOUNT=y -CONFIG_NSH_LINELEN=160 -CONFIG_NSH_STRERROR=y -CONFIG_PREALLOC_TIMERS=4 -CONFIG_RAM_SIZE=1048576 -CONFIG_RAM_START=0x08000000 -CONFIG_RAW_BINARY=y -CONFIG_READLINE_CMD_HISTORY=y -CONFIG_SCHED_HPWORK=y -CONFIG_START_MONTH=4 -CONFIG_START_YEAR=2021 -CONFIG_SYSTEM_NSH=y -CONFIG_SYSTEM_TIME64=y -CONFIG_TASK_NAME_SIZE=20 -CONFIG_UART0_SERIAL_CONSOLE=y -CONFIG_UART1_BAUD=2000000 -CONFIG_USEC_PER_TICK=1000