Browse Source

include: zephyr: sys: time_units: Make z_clock_hw_cycles_per_sec unsigned

Convert z_clock_hw_cycles_per_sec to unsigned int to increase
supported frequency range.

Signed-off-by: Anisetti Avinash Krishna <anisetti.avinash.krishna@intel.com>
pull/87825/head
Anisetti Avinash Krishna 3 months ago committed by Henrik Brix Andersen
parent
commit
139211772c
  1. 2
      drivers/clock_control/clock_control_smartbond.c
  2. 2
      drivers/timer/gecko_burtc_timer.c
  3. 2
      drivers/timer/hpet.c
  4. 2
      drivers/timer/silabs_sleeptimer_timer.c
  5. 6
      include/zephyr/arch/arm64/timer.h
  6. 6
      include/zephyr/sys/time_units.h
  7. 4
      kernel/timeout.c
  8. 2
      soc/neorv32/soc.c

2
drivers/clock_control/clock_control_smartbond.c

@ -39,7 +39,7 @@ struct lpc_clock_state { @@ -39,7 +39,7 @@ struct lpc_clock_state {
#define CALIBRATION_INTERVAL CONFIG_SMARTBOND_LP_OSC_CALIBRATION_INTERVAL
#ifdef CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
extern int z_clock_hw_cycles_per_sec;
extern unsigned int z_clock_hw_cycles_per_sec;
#endif
static void calibration_work_cb(struct k_work *work);

2
drivers/timer/gecko_burtc_timer.c

@ -54,7 +54,7 @@ const int32_t z_sys_timer_irq_for_test = TIMER_IRQ; @@ -54,7 +54,7 @@ const int32_t z_sys_timer_irq_for_test = TIMER_IRQ;
/* With CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME, that's where we
* should write hw_cycles timer clock frequency upon init
*/
extern int z_clock_hw_cycles_per_sec;
extern unsigned int z_clock_hw_cycles_per_sec;
/* Number of hw_cycles clocks per 1 kernel tick */
static uint32_t g_cyc_per_tick;

2
drivers/timer/hpet.c

@ -415,7 +415,7 @@ void sys_clock_idle_exit(void) @@ -415,7 +415,7 @@ void sys_clock_idle_exit(void)
__boot_func
static int sys_clock_driver_init(void)
{
extern int z_clock_hw_cycles_per_sec;
extern unsigned int z_clock_hw_cycles_per_sec;
uint32_t hz, reg;
ARG_UNUSED(hz);

2
drivers/timer/silabs_sleeptimer_timer.c

@ -30,7 +30,7 @@ LOG_MODULE_REGISTER(silabs_sleeptimer_timer); @@ -30,7 +30,7 @@ LOG_MODULE_REGISTER(silabs_sleeptimer_timer);
/* With CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME, this global variable holds the clock frequency,
* and must be written by the driver at init.
*/
extern int z_clock_hw_cycles_per_sec;
extern unsigned int z_clock_hw_cycles_per_sec;
/* Global timer state */
struct sleeptimer_timer_data {

6
include/zephyr/arch/arm64/timer.h

@ -26,11 +26,11 @@ extern "C" { @@ -26,11 +26,11 @@ extern "C" {
static ALWAYS_INLINE void arm_arch_timer_init(void)
{
#ifdef CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
extern int z_clock_hw_cycles_per_sec;
extern unsigned int z_clock_hw_cycles_per_sec;
uint64_t cntfrq_el0 = read_cntfrq_el0();
__ASSERT(cntfrq_el0 < INT_MAX, "cntfrq_el0 cannot fit in system 'int'");
z_clock_hw_cycles_per_sec = (int) cntfrq_el0;
__ASSERT(cntfrq_el0 < UINT_MAX, "cntfrq_el0 cannot fit in system 'unsigned int'");
z_clock_hw_cycles_per_sec = (unsigned int) cntfrq_el0;
#endif
}

6
include/zephyr/sys/time_units.h

@ -52,11 +52,11 @@ extern "C" { @@ -52,11 +52,11 @@ extern "C" {
/* Exhaustively enumerated, highly optimized time unit conversion API */
#if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
__syscall int sys_clock_hw_cycles_per_sec_runtime_get(void);
__syscall unsigned int sys_clock_hw_cycles_per_sec_runtime_get(void);
static inline int z_impl_sys_clock_hw_cycles_per_sec_runtime_get(void)
static inline unsigned int z_impl_sys_clock_hw_cycles_per_sec_runtime_get(void)
{
extern int z_clock_hw_cycles_per_sec;
extern unsigned int z_clock_hw_cycles_per_sec;
return z_clock_hw_cycles_per_sec;
}

4
kernel/timeout.c

@ -29,10 +29,10 @@ static struct k_spinlock timeout_lock; @@ -29,10 +29,10 @@ static struct k_spinlock timeout_lock;
static int announce_remaining;
#if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
int z_clock_hw_cycles_per_sec = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
unsigned int z_clock_hw_cycles_per_sec = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
#ifdef CONFIG_USERSPACE
static inline int z_vrfy_sys_clock_hw_cycles_per_sec_runtime_get(void)
static inline unsigned int z_vrfy_sys_clock_hw_cycles_per_sec_runtime_get(void)
{
return z_impl_sys_clock_hw_cycles_per_sec_runtime_get();
}

2
soc/neorv32/soc.c

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
#include <soc.h>
#ifdef CONFIG_SOC_NEORV32_READ_FREQUENCY_AT_RUNTIME
extern int z_clock_hw_cycles_per_sec;
extern unsigned int z_clock_hw_cycles_per_sec;
void soc_early_init_hook(void)
{

Loading…
Cancel
Save