soc: neorv32: add option for reading clock frequency from sysinfo at boot
Add Kconfig option for reading the NEORV32 clock frequency from SYSINFO at boot time. Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
This commit is contained in:
parent
4b415dfc4c
commit
8a1ed6f02d
3 changed files with 25 additions and 3 deletions
|
@ -19,4 +19,15 @@ config SOC_NEORV32_VERSION
|
||||||
identical to that of the NEORV32 Machine implementation ID (mimpid)
|
identical to that of the NEORV32 Machine implementation ID (mimpid)
|
||||||
register.
|
register.
|
||||||
|
|
||||||
|
config SOC_NEORV32_READ_FREQUENCY_AT_RUNTIME
|
||||||
|
bool "Read the NEORV32 clock frequency at runtime"
|
||||||
|
default y
|
||||||
|
depends on !$(dt_node_has_prop,/cpus/cpu@0,clock-frequency)
|
||||||
|
select SOC_EARLY_INIT_HOOK
|
||||||
|
select TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
|
||||||
|
help
|
||||||
|
If enabled, the NEORV32 clock frequency will be read from SYSINFO during boot. This
|
||||||
|
results in small overhead, which can be avoided by setting the clock-frequency property of
|
||||||
|
the cpu@0 devicetree node if the frequency is known at build-time.
|
||||||
|
|
||||||
endif # SOC_NEORV32
|
endif # SOC_NEORV32
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
if SOC_NEORV32
|
if SOC_NEORV32
|
||||||
|
|
||||||
config SYS_CLOCK_HW_CYCLES_PER_SEC
|
config SYS_CLOCK_HW_CYCLES_PER_SEC
|
||||||
default $(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency) if RISCV_MACHINE_TIMER
|
default $(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency) if !SOC_NEORV32_READ_FREQUENCY_AT_RUNTIME
|
||||||
|
|
||||||
config NUM_IRQS
|
config NUM_IRQS
|
||||||
default 32
|
default 32
|
||||||
|
|
|
@ -7,11 +7,22 @@
|
||||||
#include <zephyr/irq.h>
|
#include <zephyr/irq.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
|
|
||||||
#if defined(CONFIG_RISCV_SOC_INTERRUPT_INIT)
|
#ifdef CONFIG_SOC_NEORV32_READ_FREQUENCY_AT_RUNTIME
|
||||||
|
extern int z_clock_hw_cycles_per_sec;
|
||||||
|
|
||||||
|
void soc_early_init_hook(void)
|
||||||
|
{
|
||||||
|
uint32_t base = DT_REG_ADDR(DT_NODELABEL(sysinfo));
|
||||||
|
|
||||||
|
z_clock_hw_cycles_per_sec = sys_read32(base + NEORV32_SYSINFO_CLK);
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_SOC_NEORV32_READ_FREQUENCY_AT_RUNTIME */
|
||||||
|
|
||||||
|
#ifdef CONFIG_RISCV_SOC_INTERRUPT_INIT
|
||||||
void soc_interrupt_init(void)
|
void soc_interrupt_init(void)
|
||||||
{
|
{
|
||||||
(void)arch_irq_lock();
|
(void)arch_irq_lock();
|
||||||
|
|
||||||
csr_write(mie, 0);
|
csr_write(mie, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_RISCV_SOC_INTERRUPT_INIT */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue