From 05ae6f048cf1e93887dc14d3bde28e5ed76520e7 Mon Sep 17 00:00:00 2001 From: Eero Nurkkala Date: Fri, 29 Nov 2024 12:04:44 +0200 Subject: [PATCH] risc-v/mpfs: introduce CONFIG_MPFS_CLKINIT flag This CONFIG_MPFS_CLKINIT is set with bootloaders by default. However, this gives an option to have it unset. In some cases, the clocks may be already set so it becomes unnecessary to re-initialize them. Signed-off-by: Eero Nurkkala --- arch/risc-v/src/mpfs/Kconfig | 8 ++++++++ arch/risc-v/src/mpfs/Make.defs | 6 +++++- arch/risc-v/src/mpfs/mpfs_start.c | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) 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_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