File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -19,4 +19,15 @@ config SOC_NEORV32_VERSION
19
19
identical to that of the NEORV32 Machine implementation ID (mimpid)
20
20
register.
21
21
22
+ config SOC_NEORV32_READ_FREQUENCY_AT_RUNTIME
23
+ bool "Read the NEORV32 clock frequency at runtime"
24
+ default y
25
+ depends on !$(dt_node_has_prop,/cpus/cpu@0,clock-frequency)
26
+ select SOC_EARLY_INIT_HOOK
27
+ select TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
28
+ help
29
+ If enabled, the NEORV32 clock frequency will be read from SYSINFO during boot. This
30
+ results in small overhead, which can be avoided by setting the clock-frequency property of
31
+ the cpu@0 devicetree node if the frequency is known at build-time.
32
+
22
33
endif # SOC_NEORV32
Original file line number Diff line number Diff line change 4
4
if SOC_NEORV32
5
5
6
6
config SYS_CLOCK_HW_CYCLES_PER_SEC
7
- default $(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency) if RISCV_MACHINE_TIMER
7
+ default $(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency) if !SOC_NEORV32_READ_FREQUENCY_AT_RUNTIME
8
8
9
9
config NUM_IRQS
10
10
default 32
Original file line number Diff line number Diff line change 7
7
#include <zephyr/irq.h>
8
8
#include <soc.h>
9
9
10
- #if defined(CONFIG_RISCV_SOC_INTERRUPT_INIT )
10
+ #ifdef CONFIG_SOC_NEORV32_READ_FREQUENCY_AT_RUNTIME
11
+ extern int z_clock_hw_cycles_per_sec ;
12
+
13
+ void soc_early_init_hook (void )
14
+ {
15
+ uint32_t base = DT_REG_ADDR (DT_NODELABEL (sysinfo ));
16
+
17
+ z_clock_hw_cycles_per_sec = sys_read32 (base + NEORV32_SYSINFO_CLK );
18
+ }
19
+ #endif /* CONFIG_SOC_NEORV32_READ_FREQUENCY_AT_RUNTIME */
20
+
21
+ #ifdef CONFIG_RISCV_SOC_INTERRUPT_INIT
11
22
void soc_interrupt_init (void )
12
23
{
13
24
(void )arch_irq_lock ();
14
25
15
26
csr_write (mie , 0 );
16
27
}
17
- #endif
28
+ #endif /* CONFIG_RISCV_SOC_INTERRUPT_INIT */
You can’t perform that action at this time.
0 commit comments