Skip to content

Commit 99dc33f

Browse files
dcpleunggalak
authored andcommitted
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 <[email protected]>
1 parent 02fbe65 commit 99dc33f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/timer/hpet.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ DEVICE_MMIO_TOPLEVEL_STATIC(hpet_regs, DT_DRV_INST(0));
4040
#define TCONF_MODE32 BIT(8)
4141
#define TCONF_FSB_EN BIT(14) /* FSB interrupt delivery enable */
4242

43+
#ifndef HPET_COUNTER_CLK_PERIOD
44+
/* COUNTER_CLK_PERIOD (CLK_PERIOD_REG) is in femtoseconds (1e-15 sec) */
45+
#define HPET_COUNTER_CLK_PERIOD (1000000000000000ULL)
46+
#endif
47+
4348
#define MIN_DELAY 1000
4449

4550
static __pinned_bss struct k_spinlock lock;
@@ -125,8 +130,7 @@ int sys_clock_driver_init(const struct device *dev)
125130
set_timer0_irq(DT_INST_IRQN(0));
126131
irq_enable(DT_INST_IRQN(0));
127132

128-
/* CLK_PERIOD_REG is in femtoseconds (1e-15 sec) */
129-
hz = (uint32_t)(1000000000000000ULL / CLK_PERIOD_REG);
133+
hz = (uint32_t)(HPET_COUNTER_CLK_PERIOD / CLK_PERIOD_REG);
130134
z_clock_hw_cycles_per_sec = hz;
131135
cyc_per_tick = hz / CONFIG_SYS_CLOCK_TICKS_PER_SEC;
132136

0 commit comments

Comments
 (0)