/ src / cpu / intel / haswell / romstage.c
romstage.c
 1  /* SPDX-License-Identifier: GPL-2.0-only */
 2  
 3  #include <console/console.h>
 4  #include <cpu/intel/haswell/haswell.h>
 5  #include <cpu/x86/msr.h>
 6  
 7  void set_max_freq(void)
 8  {
 9  	msr_t msr, perf_ctl, platform_info;
10  
11  	/* Check for configurable TDP option */
12  	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  }