Skip to content

Commit 8e80955

Browse files
dcpleunggalak
authored andcommitted
timer: hpet: allow overriding MIN_DELAY
This renames MIN_DELAY to HPET_CMP_MIN_DELAY, and also allows it to be overridden. The default delay is for HPET with relative high frequency, and may not suitable for all HPET implementations. Signed-off-by: Daniel Leung <[email protected]>
1 parent 99dc33f commit 8e80955

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/timer/hpet.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ DEVICE_MMIO_TOPLEVEL_STATIC(hpet_regs, DT_DRV_INST(0));
4545
#define HPET_COUNTER_CLK_PERIOD (1000000000000000ULL)
4646
#endif
4747

48-
#define MIN_DELAY 1000
48+
#ifndef HPET_CMP_MIN_DELAY
49+
/* Minimal delay for comparator before the next timer event */
50+
#define HPET_CMP_MIN_DELAY (1000)
51+
#endif
4952

5053
static __pinned_bss struct k_spinlock lock;
5154
static __pinned_bss unsigned int max_ticks;
@@ -90,7 +93,7 @@ static void hpet_isr(const void *arg)
9093
if (!IS_ENABLED(CONFIG_TICKLESS_KERNEL)) {
9194
uint32_t next = last_count + cyc_per_tick;
9295

93-
if ((int32_t)(next - now) < MIN_DELAY) {
96+
if ((int32_t)(next - now) < HPET_CMP_MIN_DELAY) {
9497
next += cyc_per_tick;
9598
}
9699
TIMER0_COMPARATOR_REG = next;
@@ -192,7 +195,7 @@ void sys_clock_set_timeout(int32_t ticks, bool idle)
192195
cyc = (cyc / cyc_per_tick) * cyc_per_tick;
193196
cyc += last_count;
194197

195-
if ((cyc - now) < MIN_DELAY) {
198+
if ((cyc - now) < HPET_CMP_MIN_DELAY) {
196199
cyc += cyc_per_tick;
197200
}
198201

0 commit comments

Comments
 (0)