[coreboot-gerrit] Change in ...coreboot[master]: intelblocks/cpu: Add function to enable maximum efficiency

Werner Zeh (Code Review) gerrit at coreboot.org
Wed Nov 21 12:46:55 CET 2018


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 at 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.

-- 
To view, visit https://review.coreboot.org/c/coreboot/+/29771
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I817095b13ab8cbaab82f25c72947b00ee854d549
Gerrit-Change-Number: 29771
Gerrit-PatchSet: 1
Gerrit-Owner: Werner Zeh <werner.zeh at siemens.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20181121/65f030b3/attachment.html>


More information about the coreboot-gerrit mailing list