From 0108c8b742bd7a3a7c2db8357677211e7eb14fac Mon Sep 17 00:00:00 2001 From: Andrey Petrov Date: Wed, 23 Oct 2019 17:12:10 -0700 Subject: soc/intel/broadwell_de: Implement smbios_cpu_get_maximum_freq_mhz() Determine maximum speed by looking at either turbo flex limit or uncore ratio limit. Signed-off-by: Andrey Petrov Change-Id: I0f3a64a40cb1d28d8eb9380c2071ec748e345b88 Reviewed-on: https://review.coreboot.org/c/coreboot/+/36284 Tested-by: build bot (Jenkins) Reviewed-by: David Hendricks --- src/soc/intel/fsp_broadwell_de/cpu.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/soc/intel/fsp_broadwell_de/cpu.c') diff --git a/src/soc/intel/fsp_broadwell_de/cpu.c b/src/soc/intel/fsp_broadwell_de/cpu.c index ac4dcc92dd..b94ee78d7a 100644 --- a/src/soc/intel/fsp_broadwell_de/cpu.c +++ b/src/soc/intel/fsp_broadwell_de/cpu.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -27,6 +28,8 @@ #include #include #include +#include +#include #include #include #include @@ -98,6 +101,25 @@ static void set_max_ratio(void) wrmsr(IA32_PERF_CTL, perf_ctl); } +unsigned int smbios_cpu_get_max_speed_mhz(void) +{ + msr_t msr; + uint32_t uncore_max_ratio, turbo_max_ratio = 0; + + /* + * Use turbo's max ratio if it is enabled, otherwise use + * uncore's max ratio. + */ + msr = rdmsr(MSR_UNCORE_RATIO_LIMIT); + uncore_max_ratio = msr.lo & 0x7f; + if (get_turbo_state() == TURBO_ENABLED) { + msr = rdmsr(MSR_TURBO_RATIO_LIMIT); + turbo_max_ratio = msr.lo & 0xff; /* 1 core */ + } + + return MAX(uncore_max_ratio, turbo_max_ratio) * CPU_BCLK; +} + static void alt_smm_lock(void) { struct device *dev = pcidev_on_root(LPC_DEV, LPC_FUNC); -- cgit v1.2.3