blob: c74549438a3d3e6273427b1834ac9bcd24c62994 [file] [log] [blame]
Angel Ponsf94ac9a2020-04-05 15:46:48 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Duncan Lauriec88c54c2014-04-30 16:36:13 -07002
Duncan Lauriec88c54c2014-04-30 16:36:13 -07003#include <console/console.h>
Angel Pons9d733de2020-11-23 13:15:19 +01004#include <cpu/intel/haswell/haswell.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -07005#include <cpu/x86/msr.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -07006
Duncan Lauriec88c54c2014-04-30 16:36:13 -07007void set_max_freq(void)
8{
9 msr_t msr, perf_ctl, platform_info;
10
Lee Leahy26b7cd02017-03-16 18:47:55 -070011 /* Check for configurable TDP option */
Duncan Lauriec88c54c2014-04-30 16:36:13 -070012 platform_info = rdmsr(MSR_PLATFORM_INFO);
13
14 if ((platform_info.hi >> 1) & 3) {
15 /* Set to nominal TDP ratio */
16 msr = rdmsr(MSR_CONFIG_TDP_NOMINAL);
17 perf_ctl.lo = (msr.lo & 0xff) << 8;
18 } else {
19 /* Platform Info bits 15:8 give max ratio */
20 msr = rdmsr(MSR_PLATFORM_INFO);
21 perf_ctl.lo = msr.lo & 0xff00;
22 }
23
24 perf_ctl.hi = 0;
25 wrmsr(IA32_PERF_CTL, perf_ctl);
26
27 printk(BIOS_DEBUG, "CPU: frequency set to %d MHz\n",
28 ((perf_ctl.lo >> 8) & 0xff) * CPU_BCLK);
29}