Angel Pons has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/42547 )
Change subject: cpu/intel/model_206ax: Add overclocking support ......................................................................
cpu/intel/model_206ax: Add overclocking support
Add a Kconfig option to force Turbo Ratio values to the maximum possible value, which is the maximum non-turbo ratio plus the number of OC bins.
Tested on Asus P8Z77-V LX2 with an i5-3330, CPU now runs at 3.4 GHz.
Change-Id: I60bef32bfdde3c32a11f07afff64fc83d65fd3f1 Signed-off-by: Angel Pons th3fanbus@gmail.com --- M src/cpu/intel/model_206ax/Kconfig M src/cpu/intel/model_206ax/model_206ax.h M src/cpu/intel/model_206ax/model_206ax_init.c 3 files changed, 55 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/47/42547/1
diff --git a/src/cpu/intel/model_206ax/Kconfig b/src/cpu/intel/model_206ax/Kconfig index c6a5020..df78524 100644 --- a/src/cpu/intel/model_206ax/Kconfig +++ b/src/cpu/intel/model_206ax/Kconfig @@ -38,4 +38,13 @@ int default 8
+config FORCE_MAX_TURBO_RATIO + bool "Force turbo ratios to the maximum possible value" + default n + help + By selecting this, all core turbo ratios will be set to the maximum possible value, + which is the maximum non-turbo ratio of the CPU plus the number of overclocking bins + by which the CPU can be overclocked. This is an overclocking option and therefore is + dangerous to enable, especially on mobile platforms with a limited cooling solution! + endif diff --git a/src/cpu/intel/model_206ax/model_206ax.h b/src/cpu/intel/model_206ax/model_206ax.h index e24993c..7ac3ec9 100644 --- a/src/cpu/intel/model_206ax/model_206ax.h +++ b/src/cpu/intel/model_206ax/model_206ax.h @@ -18,6 +18,7 @@ #define MSR_PIC_MSG_CONTROL 0x2e #define MSR_PLATFORM_INFO 0xce #define PLATFORM_INFO_SET_TDP (1 << 29) +#define PLATFORM_INFO_RATIO_LIMIT (1 << 28)
#define MSR_MISC_PWR_MGMT 0x1aa #define MISC_PWR_MGMT_EIST_HW_DIS (1 << 0) diff --git a/src/cpu/intel/model_206ax/model_206ax_init.c b/src/cpu/intel/model_206ax/model_206ax_init.c index e69d4fa..de4392d 100644 --- a/src/cpu/intel/model_206ax/model_206ax_init.c +++ b/src/cpu/intel/model_206ax/model_206ax_init.c @@ -14,6 +14,7 @@ #include <cpu/intel/turbo.h> #include <cpu/x86/cache.h> #include <cpu/x86/name.h> +#include <stdint.h> #include "model_206ax.h" #include "chip.h" #include <cpu/intel/smm_reloc.h> @@ -439,6 +440,47 @@ printk(BIOS_INFO, "CPU: VT %ssupported\n", mode[vt]); }
+static void xe_init(void) +{ + msr_t msr; + + /* If not enabled, do not touch anything */ + if (!CONFIG(FORCE_MAX_TURBO_RATIO)) { + printk(BIOS_DEBUG, "XE: not overriding Turbo Ratio limits\n"); + return; + } + + /* Get the number of OC bins */ + msr = rdmsr(MSR_FLEX_RATIO); + const uint8_t oc_bins = (msr.lo >> 17) & 0x7; + + /* Ensure that the preconditions for XE are true */ + msr = rdmsr(MSR_PLATFORM_INFO); + if (!(cpuid_eax(1) >= 0x206a3 && (msr.lo & PLATFORM_INFO_RATIO_LIMIT) && oc_bins)) { + + printk(BIOS_WARNING, "XE: Cannot configure XE on a non-XE processor\n"); + return; + } + + /* Obtain maximum non-turbo ratio from MSR_PLATFORM_INFO */ + const uint8_t max_non_turbo = (msr.lo >> 8) & 0xff; + + /* Now do the deed */ + msr = rdmsr(MSR_TURBO_RATIO_LIMIT); + + msr.lo = 0; + msr.lo |= (max_non_turbo + oc_bins) << 0; + msr.lo |= (max_non_turbo + oc_bins) << 8; + msr.lo |= (max_non_turbo + oc_bins) << 16; + msr.lo |= (max_non_turbo + oc_bins) << 24; + + printk(BIOS_NOTICE, "XE: Setting Turbo Ratio to %d... ", max_non_turbo + oc_bins); + + wrmsr(MSR_TURBO_RATIO_LIMIT, msr); + + printk(BIOS_NOTICE, "done.\n"); +} + static void model_206ax_init(struct device *cpu) {
@@ -481,6 +523,9 @@
/* Enable Turbo */ enable_turbo(); + + /* Crank up the turbo ratio, if possible and desired */ + xe_init(); }
/* MP initialization support. */