diff --git a/boards/riscv/hifive1/support/hifive1.resc b/boards/riscv/hifive1/support/hifive1.resc index 113e30ec86f..e9aaa1be62d 100644 --- a/boards/riscv/hifive1/support/hifive1.resc +++ b/boards/riscv/hifive1/support/hifive1.resc @@ -3,9 +3,17 @@ $name?="SiFive-FE310" +set platform +""" +using "platforms/cpus/sifive-fe310.repl" + +clint: + frequency: 16000000 +""" + using sysbus mach create $name -machine LoadPlatformDescription @platforms/cpus/sifive-fe310.repl +machine LoadPlatformDescriptionFromString $platform sysbus Tag <0x10008000 4> "PRCI_HFROSCCFG" 0xFFFFFFFF sysbus Tag <0x10008008 4> "PRCI_PLLCFG" 0xFFFFFFFF diff --git a/drivers/timer/Kconfig.riscv_machine b/drivers/timer/Kconfig.riscv_machine index fa67b2bee39..262126d43c8 100644 --- a/drivers/timer/Kconfig.riscv_machine +++ b/drivers/timer/Kconfig.riscv_machine @@ -28,3 +28,11 @@ config RISCV_MACHINE_TIMER_SYSTEM_CLOCK_DIVIDER The division ratio should define in devicetree, and it is desirable usage that references it with using a function such as dt_node_int_prop_int from Kconfig. (Tune in the conf file is not preferable.) + +config RISCV_MACHINE_TIMER_MIN_DELAY + int + default 100 + help + Specifies the minimum number of machine cycles before the RISC-V machine + time compare register is allowed to be updated by the RISC-V machine timer + driver. diff --git a/drivers/timer/riscv_machine_timer.c b/drivers/timer/riscv_machine_timer.c index f8e55426375..39d20bf3088 100644 --- a/drivers/timer/riscv_machine_timer.c +++ b/drivers/timer/riscv_machine_timer.c @@ -14,7 +14,7 @@ / (uint64_t)CONFIG_SYS_CLOCK_TICKS_PER_SEC)) #define MAX_CYC INT_MAX #define MAX_TICKS ((MAX_CYC - CYC_PER_TICK) / CYC_PER_TICK) -#define MIN_DELAY 1000 +#define MIN_DELAY CONFIG_RISCV_MACHINE_TIMER_MIN_DELAY #define TICKLESS IS_ENABLED(CONFIG_TICKLESS_KERNEL) diff --git a/soc/riscv/riscv-privilege/sifive-freedom/Kconfig.defconfig.series b/soc/riscv/riscv-privilege/sifive-freedom/Kconfig.defconfig.series index 59c47394ad4..0c3cd541773 100644 --- a/soc/riscv/riscv-privilege/sifive-freedom/Kconfig.defconfig.series +++ b/soc/riscv/riscv-privilege/sifive-freedom/Kconfig.defconfig.series @@ -6,7 +6,7 @@ config SOC_SERIES default "sifive-freedom" config SYS_CLOCK_HW_CYCLES_PER_SEC - default 320000 + default 32768 config RISCV_SOC_INTERRUPT_INIT default y