timer: hpet: extract Counter Clock Period into a macro

This extracts the hard-coded value into a macro which can be
overridden. This is in preparation for SoCs where the period
is not in femptoseconds.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2021-05-19 14:12:36 -07:00 committed by Carles Cufí
commit aadcd10a6e

View file

@ -40,6 +40,11 @@ DEVICE_MMIO_TOPLEVEL_STATIC(hpet_regs, DT_DRV_INST(0));
#define TCONF_MODE32 BIT(8) #define TCONF_MODE32 BIT(8)
#define TCONF_FSB_EN BIT(14) /* FSB interrupt delivery enable */ #define TCONF_FSB_EN BIT(14) /* FSB interrupt delivery enable */
#ifndef HPET_COUNTER_CLK_PERIOD
/* COUNTER_CLK_PERIOD (CLK_PERIOD_REG) is in femtoseconds (1e-15 sec) */
#define HPET_COUNTER_CLK_PERIOD (1000000000000000ULL)
#endif
#define MIN_DELAY 1000 #define MIN_DELAY 1000
static __pinned_bss struct k_spinlock lock; static __pinned_bss struct k_spinlock lock;
@ -125,8 +130,7 @@ int sys_clock_driver_init(const struct device *dev)
set_timer0_irq(DT_INST_IRQN(0)); set_timer0_irq(DT_INST_IRQN(0));
irq_enable(DT_INST_IRQN(0)); irq_enable(DT_INST_IRQN(0));
/* CLK_PERIOD_REG is in femtoseconds (1e-15 sec) */ hz = (uint32_t)(HPET_COUNTER_CLK_PERIOD / CLK_PERIOD_REG);
hz = (uint32_t)(1000000000000000ULL / CLK_PERIOD_REG);
z_clock_hw_cycles_per_sec = hz; z_clock_hw_cycles_per_sec = hz;
cyc_per_tick = hz / CONFIG_SYS_CLOCK_TICKS_PER_SEC; cyc_per_tick = hz / CONFIG_SYS_CLOCK_TICKS_PER_SEC;