
Add functions to query CPU information, needed for ACPI.
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/x86/cpu/intel_common/cpu.c | 59 +++++++++++++++++++++++++++++++ arch/x86/include/asm/cpu_common.h | 31 ++++++++++++++++ 2 files changed, 90 insertions(+)
diff --git a/arch/x86/cpu/intel_common/cpu.c b/arch/x86/cpu/intel_common/cpu.c index 4d093a5391..106ff41e23 100644 --- a/arch/x86/cpu/intel_common/cpu.c +++ b/arch/x86/cpu/intel_common/cpu.c @@ -8,6 +8,7 @@ */
#include <common.h> +#include <acpigen.h> #include <cpu.h> #include <dm.h> #include <errno.h> @@ -226,3 +227,61 @@ 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; +} + +uint32_t 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 */ +} + +uint32_t 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; +} + +uint32_t cpu_get_bus_clock(void) +{ + /* CPU bus clock is set by default here to 100MHz. + * This function returns the bus clock in KHz. + */ + return INTEL_BCLK_MHZ * 1000; +} + +uint32_t cpu_get_power_max(void) +{ + msr_t msr; + int power_unit; + + 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; +} + +uint32_t cpu_get_max_turbo_ratio(void) +{ + msr_t msr; + + msr = msr_read(MSR_TURBO_RATIO_LIMIT); + return msr.lo & 0xff; +} diff --git a/arch/x86/include/asm/cpu_common.h b/arch/x86/include/asm/cpu_common.h index cdd99a90b7..c3f699ffd3 100644 --- a/arch/x86/include/asm/cpu_common.h +++ b/arch/x86/include/asm/cpu_common.h @@ -128,4 +128,35 @@ void cpu_set_eist(bool eist_status); */ void cpu_set_p_state_to_turbo_ratio(void);
+/* + * cpu_get_bus_clock returns the bus clock frequency in KHz. + * This is the value the clock ratio is multiplied with. + */ +uint32_t cpu_get_bus_clock(void); + +int cpu_get_coord_type(void); + +/* + * cpu_get_min_ratio returns the minimum frequency ratio that is supported + * by this processor + */ +uint32_t cpu_get_min_ratio(void); + +/* + * cpu_get_max_ratio returns the nominal TDP ratio if available or the + * maximum non turbo frequency ratio for this processor + */ +uint32_t cpu_get_max_ratio(void); + +/* + * cpu_get_power_max calculates CPU TDP in mW + */ +uint32_t cpu_get_power_max(void); + +/* + * cpu_get_max_turbo_ratio returns the maximum turbo ratio limit for the + * processor + */ +uint32_t cpu_get_max_turbo_ratio(void); + #endif