From bbb57b5f8035cfedf4a15a9a3aa8d77c24b4efda Mon Sep 17 00:00:00 2001 From: Peter Mitsis Date: Thu, 6 Aug 2015 12:37:11 -0400 Subject: [PATCH] ia32: Add HPET timer initialization abstraction Initializes the HPET timer if it is configured into the system. Change-Id: Ia9474e868101abe88e031266b956c6a559745d75 Signed-off-by: Peter Mitsis --- arch/x86/platforms/ia32/board.h | 1 + arch/x86/platforms/ia32/system.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/arch/x86/platforms/ia32/board.h b/arch/x86/platforms/ia32/board.h index 672450e9281..3e525c9b3ee 100644 --- a/arch/x86/platforms/ia32/board.h +++ b/arch/x86/platforms/ia32/board.h @@ -110,6 +110,7 @@ the 'ia32' platform. #define HPET_TIMER0_VEC (HPET_TIMER0_IRQ + INT_VEC_IRQ0) #define HPET_TIMER0_INT_PRI (4) #define HPET_TIMER0_IRQ (2) +#define HPET_IOAPIC_FLAGS (IOAPIC_EDGE | IOAPIC_LOW) /* serial port (aka COM port) information */ diff --git a/arch/x86/platforms/ia32/system.c b/arch/x86/platforms/ia32/system.c index 6d6612378fc..fef7e91d546 100644 --- a/arch/x86/platforms/ia32/system.c +++ b/arch/x86/platforms/ia32/system.c @@ -81,6 +81,17 @@ static inline void ioapic_init(void) } while ((0)) #endif /* CONFIG_IOAPIC */ +#ifdef CONFIG_HPET_TIMER +static inline void hpet_irq_set(void) +{ + _ioapic_irq_set(HPET_TIMER0_IRQ, HPET_TIMER0_VEC, HPET_IOAPIC_FLAGS); +} +#else +#define hpet_irq_set() \ + do { /* nothing */ \ + } while ((0)) +#endif + #if defined(CONFIG_PRINTK) || defined(CONFIG_STDOUT_CONSOLE) /** @@ -160,6 +171,7 @@ static int ia32_init(struct device *arg) loapic_init(); /* NOP if not needed */ ioapic_init(); /* NOP if not needed */ + hpet_irq_set(); /* NOP if not needed */ console_init(); /* NOP if not needed */ bluetooth_init(); /* NOP if not needed */ return 0;