Skip to content

Commit 7c03e5d

Browse files
najumon1980jhedberg
authored andcommitted
kernel: retrieve system timer clock frequency at runtime or static
update kernel timeout logic based on retrieve system timer clock frequency at runtime or static way based on Kconfig TIMER_READS_ITS_FREQUENCY_AT_RUNTIME Signed-off-by: Najumon B.A <[email protected]>
1 parent d82f4a9 commit 7c03e5d

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

include/zephyr/sys_clock.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ typedef struct {
146146

147147
/** @endcond */
148148

149-
#if defined(CONFIG_SYS_CLOCK_EXISTS) && \
150-
(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC == 0)
151-
#error "SYS_CLOCK_HW_CYCLES_PER_SEC must be non-zero!"
149+
#if defined(CONFIG_SYS_CLOCK_EXISTS) && !defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
150+
BUILD_ASSERT(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC != 0,
151+
"SYS_CLOCK_HW_CYCLES_PER_SEC must be non-zero!");
152152
#endif
153153

154154

@@ -164,7 +164,7 @@ typedef struct {
164164
* @{
165165
*/
166166

167-
#ifdef CONFIG_SYS_CLOCK_EXISTS
167+
#if defined(CONFIG_SYS_CLOCK_EXISTS) && !defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
168168

169169
#if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME) || \
170170
(MSEC_PER_SEC % CONFIG_SYS_CLOCK_TICKS_PER_SEC) || \

kernel/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ config SYS_CLOCK_TICKS_PER_SEC
799799

800800
config SYS_CLOCK_HW_CYCLES_PER_SEC
801801
int "System clock's h/w timer frequency"
802+
depends on !TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
802803
help
803804
This option specifies the frequency of the hardware timer used for the
804805
system clock (in Hz). This option is set by the SOC's or board's Kconfig file

kernel/timeout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static struct k_spinlock timeout_lock;
2525
static int announce_remaining;
2626

2727
#if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
28-
int z_clock_hw_cycles_per_sec = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
28+
int z_clock_hw_cycles_per_sec;
2929

3030
#ifdef CONFIG_USERSPACE
3131
static inline int z_vrfy_sys_clock_hw_cycles_per_sec_runtime_get(void)

0 commit comments

Comments
 (0)