Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/34091 )
Change subject: cpu/x86/lapic: Refactor timer_fsb() ......................................................................
cpu/x86/lapic: Refactor timer_fsb()
Common apic_timer code in cpu/x86 should not depend on intel header files.
Change-Id: Ib099921d4b8e561daea47219385762bb00fc4548 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/cpu/intel/common/fsb.c M src/cpu/x86/lapic/apic_timer.c M src/include/delay.h 3 files changed, 40 insertions(+), 36 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/91/34091/1
diff --git a/src/cpu/intel/common/fsb.c b/src/cpu/intel/common/fsb.c index d66e87a..151ad9e 100644 --- a/src/cpu/intel/common/fsb.c +++ b/src/cpu/intel/common/fsb.c @@ -11,12 +11,14 @@ * GNU General Public License for more details. */
+#include <arch/early_variables.h> #include <cpu/cpu.h> #include <cpu/x86/msr.h> #include <cpu/intel/speedstep.h> #include <cpu/intel/fsb.h> #include <console/console.h> #include <commonlib/helpers.h> +#include <delay.h>
static int get_fsb(void) { @@ -95,3 +97,23 @@ printk(BIOS_ERR, "FSB not supported or not found\n"); return -1; } + + + +static u32 g_timer_fsb CAR_GLOBAL; + +int set_timer_fsb(void) +{ + int ia32_fsb = get_ia32_fsb(); + + if (ia32_fsb > 0) { + car_set_var(g_timer_fsb, ia32_fsb); + return 0; + } + return -1; +} + +u32 get_timer_fsb(void) +{ + return car_get_var(g_timer_fsb); +} diff --git a/src/cpu/x86/lapic/apic_timer.c b/src/cpu/x86/lapic/apic_timer.c index 6521a8a..2e0583b 100644 --- a/src/cpu/x86/lapic/apic_timer.c +++ b/src/cpu/x86/lapic/apic_timer.c @@ -20,44 +20,8 @@ #include <thread.h> #include <arch/cpu.h> #include <arch/early_variables.h> -#include <cpu/intel/fsb.h> #include <cpu/x86/msr.h> #include <cpu/x86/lapic.h> -#include <cpu/intel/speedstep.h> - -/* NOTE: This code uses global variables, so it can not be used during - * memory init. - */ - -#if CONFIG_UDELAY_LAPIC_FIXED_FSB != 0 -static inline u32 get_timer_fsb(void) -{ - return CONFIG_UDELAY_LAPIC_FIXED_FSB; -} - -static int set_timer_fsb(void) -{ - return 0; -} -#else -static u32 g_timer_fsb CAR_GLOBAL; - -static int set_timer_fsb(void) -{ - int ia32_fsb = get_ia32_fsb(); - - if (ia32_fsb > 0) { - car_set_var(g_timer_fsb, ia32_fsb); - return 0; - } - return -1; -} - -static inline u32 get_timer_fsb(void) -{ - return car_get_var(g_timer_fsb); -} -#endif
void init_timer(void) { diff --git a/src/include/delay.h b/src/include/delay.h index 8f894d2..acdd374 100644 --- a/src/include/delay.h +++ b/src/include/delay.h @@ -1,6 +1,24 @@ #ifndef DELAY_H #define DELAY_H
+#include <stdint.h> + +#if CONFIG_UDELAY_LAPIC_FIXED_FSB != 0 +static inline u32 get_timer_fsb(void) +{ + return CONFIG_UDELAY_LAPIC_FIXED_FSB; +} + +static int set_timer_fsb(void) +{ + return 0; +} +#else +int set_timer_fsb(void); +u32 get_timer_fsb(void); +#endif + + void init_timer(void);
void udelay(unsigned int usecs);