提交 642e8487 编写于 作者: S Simon Glass 提交者: Bin Meng

x86: timer: Reduce timer code size in TPL on Intel CPUs

Most of the timer-calibration methods are not needed on recent Intel CPUs
and just increase code size. Add an option to use the known-good way to
get the clock frequency in TPL. Size reduction is about 700 bytes.

Note that version 1 of this commit caused bootstage to crash since the CPU
was not identified. This is corrected by changes previously applied to
make sure that the CPU is identified before spl_init() is called, such as

   39146a2e0b x86: Move CPU init to before spl_init()
Signed-off-by: NSimon Glass <sjg@chromium.org>
Reviewed-by: NBin Meng <bmeng.cn@gmail.com>
上级 77dd7c68
...@@ -188,6 +188,15 @@ config X86_TSC_READ_BASE ...@@ -188,6 +188,15 @@ config X86_TSC_READ_BASE
The only exception is when U-Boot is used as a secondary bootloader, The only exception is when U-Boot is used as a secondary bootloader,
where this option should be enabled. where this option should be enabled.
config TPL_X86_TSC_TIMER_NATIVE
bool "x86 TSC timer uses native calibration"
depends on TPL && X86_TSC_TIMER
help
Selects native timer calibration for TPL and don't include the other
methods in the code. This helps to reduce code size in TPL and works
on fairly modern Intel chips. Code-size reductions is about 700
bytes.
config MTK_TIMER config MTK_TIMER
bool "MediaTek timer support" bool "MediaTek timer support"
depends on TIMER depends on TIMER
......
...@@ -50,8 +50,7 @@ static unsigned long native_calibrate_tsc(void) ...@@ -50,8 +50,7 @@ static unsigned long native_calibrate_tsc(void)
return 0; return 0;
crystal_freq = tsc_info.ecx / 1000; crystal_freq = tsc_info.ecx / 1000;
if (!CONFIG_IS_ENABLED(X86_TSC_TIMER_NATIVE) && !crystal_freq) {
if (!crystal_freq) {
switch (gd->arch.x86_model) { switch (gd->arch.x86_model) {
case INTEL_FAM6_SKYLAKE_MOBILE: case INTEL_FAM6_SKYLAKE_MOBILE:
case INTEL_FAM6_SKYLAKE_DESKTOP: case INTEL_FAM6_SKYLAKE_DESKTOP:
...@@ -407,6 +406,10 @@ static void tsc_timer_ensure_setup(bool early) ...@@ -407,6 +406,10 @@ static void tsc_timer_ensure_setup(bool early)
if (fast_calibrate) if (fast_calibrate)
goto done; goto done;
/* Reduce code size by dropping other methods */
if (CONFIG_IS_ENABLED(X86_TSC_TIMER_NATIVE))
panic("no timer");
fast_calibrate = cpu_mhz_from_cpuid(); fast_calibrate = cpu_mhz_from_cpuid();
if (fast_calibrate) if (fast_calibrate)
goto done; goto done;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册