diff options
author | Simon Glass <sjg@chromium.org> | 2020-09-22 12:45:08 -0600 |
---|---|---|
committer | Bin Meng <bmeng.cn@gmail.com> | 2020-09-25 11:27:16 +0800 |
commit | 6c0da2da7ca9f4bf75e384dc679bcb4575a9940e (patch) | |
tree | 2c8baf422a9ff01a41be7ac899f296213f90d5b1 /arch/x86/cpu/intel_common/cpu.c | |
parent | abc585b7451378acd396993dfaf287c39013eae3 (diff) |
x86: Add a few common Intel CPU functions
Add functions to query CPU information, needed for ACPI.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'arch/x86/cpu/intel_common/cpu.c')
-rw-r--r-- | arch/x86/cpu/intel_common/cpu.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/arch/x86/cpu/intel_common/cpu.c b/arch/x86/cpu/intel_common/cpu.c index 509730aea9..cb4ef84013 100644 --- a/arch/x86/cpu/intel_common/cpu.c +++ b/arch/x86/cpu/intel_common/cpu.c @@ -12,6 +12,7 @@ #include <dm.h> #include <errno.h> #include <log.h> +#include <acpi/acpigen.h> #include <asm/cpu.h> #include <asm/cpu_common.h> #include <asm/intel_regs.h> @@ -227,3 +228,66 @@ void cpu_set_eist(bool eist_status) msr.lo &= ~MISC_ENABLE_ENHANCED_SPEEDSTEP; msr_write(MSR_IA32_MISC_ENABLE, msr); } + +int cpu_get_coord_type(void) +{ + return HW_ALL; +} + +int cpu_get_min_ratio(void) +{ + msr_t msr; + + /* Get bus ratio limits and calculate clock speeds */ + msr = msr_read(MSR_PLATFORM_INFO); + + return (msr.hi >> 8) & 0xff; /* Max Efficiency Ratio */ +} + +int cpu_get_max_ratio(void) +{ + u32 ratio_max; + msr_t msr; + + if (cpu_config_tdp_levels()) { + /* Set max ratio to nominal TDP ratio */ + msr = msr_read(MSR_CONFIG_TDP_NOMINAL); + ratio_max = msr.lo & 0xff; + } else { + msr = msr_read(MSR_PLATFORM_INFO); + /* Max Non-Turbo Ratio */ + ratio_max = (msr.lo >> 8) & 0xff; + } + + return ratio_max; +} + +int cpu_get_bus_clock_khz(void) +{ + /* + * CPU bus clock is set by default here to 100MHz. This function returns + * the bus clock in KHz. + */ + return INTEL_BCLK_MHZ * 1000; +} + +int cpu_get_power_max(void) +{ + int power_unit; + msr_t msr; + + msr = msr_read(MSR_PKG_POWER_SKU_UNIT); + power_unit = 2 << ((msr.lo & 0xf) - 1); + msr = msr_read(MSR_PKG_POWER_SKU); + + return (msr.lo & 0x7fff) * 1000 / power_unit; +} + +int cpu_get_max_turbo_ratio(void) +{ + msr_t msr; + + msr = msr_read(MSR_TURBO_RATIO_LIMIT); + + return msr.lo & 0xff; +} |