Werner Zeh has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/29771
Change subject: intelblocks/cpu: Add function to enable maximum efficiency ......................................................................
intelblocks/cpu: Add function to enable maximum efficiency
Provide a library function to set the CPU frequency to maximum efficiency value. This will result in the lowest possible CPU clock with the lowest possible power consumption. This can be useful in mobile devices where the power dissipation is limited.
Change-Id: I817095b13ab8cbaab82f25c72947b00ee854d549 Signed-off-by: Werner Zeh werner.zeh@siemens.com --- M src/soc/intel/common/block/cpu/cpulib.c M src/soc/intel/common/block/include/intelblocks/cpulib.h 2 files changed, 26 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/71/29771/1
diff --git a/src/soc/intel/common/block/cpu/cpulib.c b/src/soc/intel/common/block/cpu/cpulib.c index 0c042df..1e50dc9 100644 --- a/src/soc/intel/common/block/cpu/cpulib.c +++ b/src/soc/intel/common/block/cpu/cpulib.c @@ -141,6 +141,25 @@ }
/* + * Set PERF_CTL MSR (0x199) P_Req (14:8 bits) with the value + * for maximum efficiency. This value is reported in PLATFORM_INFO MSR (0xCE) + * in Bits 47:40 and is extracted with cpu_get_min_ratio(). + */ +void cpu_set_p_state_to_max_efficiency_ratio(void) +{ + uint32_t min_ratio; + msr_t perf_ctl; + + /* Read the minimum ratio for the best efficiency. */ + min_ratio = cpu_get_min_ratio(); + perf_ctl.lo = (min_ratio << 8) & 0xff00; + perf_ctl.hi = 0; + wrmsr(IA32_PERF_CTL, perf_ctl); + printk(BIOS_DEBUG, "CPU: frequency set to %d MHz\n", + ((perf_ctl.lo >> 8) & 0xff) * CONFIG_CPU_BCLK_MHZ); +} + +/* * Get the Burst/Turbo Mode State from MSR IA32_MISC_ENABLE 0x1A0 * Bit 38 - TURBO_MODE_DISABLE Bit to get state ENABLED / DISABLED. * Also check for the cpuid 0x6 to check whether Burst mode unsupported. diff --git a/src/soc/intel/common/block/include/intelblocks/cpulib.h b/src/soc/intel/common/block/include/intelblocks/cpulib.h index 88f04b4..8e3313c 100644 --- a/src/soc/intel/common/block/include/intelblocks/cpulib.h +++ b/src/soc/intel/common/block/include/intelblocks/cpulib.h @@ -73,6 +73,13 @@ void cpu_set_p_state_to_max_non_turbo_ratio(void);
/* + * Set PERF_CTL MSR (0x199) P_Req (14:8 bits) with the value + * for maximum efficiency. This value is reported in PLATFORM_INFO MSR (0xCE) + * in Bits 47:40 and is extracted with cpu_get_min_ratio(). + */ +void cpu_set_p_state_to_max_efficiency_ratio(void); + +/* * Get the Burst/Turbo Mode State from MSR IA32_MISC_ENABLE 0x1A0 * Bit 38 - TURBO_MODE_DISABLE Bit to get state ENABLED / DISABLED. * Also check for the cpuid 0x6 to check whether Burst mode unsupported.