coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
bootblock.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <stdint.h>
4 #include <arch/bootblock.h>
5 #include <arch/cpu.h>
6 #include <cpu/x86/msr.h>
7 #include <arch/io.h>
8 #include <halt.h>
9 
10 #include "model_206ax.h"
11 
12 #if CONFIG(SOUTHBRIDGE_INTEL_BD82X6X) || \
13  CONFIG(SOUTHBRIDGE_INTEL_C216)
14 /* Needed for RCBA access to set Soft Reset Data register */
16 #else
17 #error "CPU must be paired with Intel BD82X6X or C216 southbridge"
18 #endif
19 
21 {
22  msr_t flex_ratio, msr;
24  u8 nominal_ratio;
25 
26  /* Minimum CPU revision for configurable TDP support */
28  return;
29 
30  /* Check for Flex Ratio support */
31  flex_ratio = rdmsr(MSR_FLEX_RATIO);
32  if (!(flex_ratio.lo & FLEX_RATIO_EN))
33  return;
34 
35  /* Check for >0 configurable TDPs */
36  msr = rdmsr(MSR_PLATFORM_INFO);
37  if (((msr.hi >> 1) & 3) == 0)
38  return;
39 
40  /* Use nominal TDP ratio for flex ratio */
42  nominal_ratio = msr.lo & 0xff;
43 
44  /* See if flex ratio is already set to nominal TDP ratio */
45  if (((flex_ratio.lo >> 8) & 0xff) == nominal_ratio)
46  return;
47 
48  /* Set flex ratio to nominal TDP ratio */
49  flex_ratio.lo &= ~0xff00;
50  flex_ratio.lo |= nominal_ratio << 8;
51  flex_ratio.lo |= FLEX_RATIO_LOCK;
52  wrmsr(MSR_FLEX_RATIO, flex_ratio);
53 
54  /* Set flex ratio in soft reset data register bits 11:6.
55  * RCBA region is enabled in southbridge bootblock */
57  soft_reset &= ~(0x3f << 6);
58  soft_reset |= (nominal_ratio & 0x3f) << 6;
60 
61  /* Set soft reset control to use register value */
63 
64  /* Issue warm reset, will be "CPU only" due to soft reset data */
65  outb(0x0, 0xcf9);
66  outb(0x6, 0xcf9);
67  halt();
68 }
69 
71 {
72  /* Set flex ratio and reset if needed */
74 }
static unsigned int cpuid_eax(unsigned int op)
Definition: cpu.h:79
void __weak bootblock_early_cpu_init(void)
Definition: bootblock.c:18
#define FLEX_RATIO_LOCK
Definition: haswell.h:48
#define MSR_FLEX_RATIO
Definition: haswell.h:47
#define MSR_CONFIG_TDP_NOMINAL
Definition: haswell.h:95
#define FLEX_RATIO_EN
Definition: haswell.h:49
static void set_flex_ratio_to_tdp_nominal(void)
Definition: bootblock.c:20
void outb(u8 val, u16 port)
#define MSR_PLATFORM_INFO
Definition: fsb.c:16
void __noreturn halt(void)
halt the system reliably
Definition: halt.c:6
static __always_inline msr_t rdmsr(unsigned int index)
Definition: msr.h:146
static __always_inline void wrmsr(unsigned int index, msr_t msr)
Definition: msr.h:157
#define IVB_CONFIG_TDP_MIN_CPUID
Definition: model_206ax.h:85
#define SOFT_RESET_DATA
Definition: rcba.h:114
#define SOFT_RESET_CTRL
Definition: rcba.h:113
static __noreturn void soft_reset(void)
Definition: reset.h:14
#define RCBA32_OR(x, or)
Definition: rcba.h:22
#define RCBA32(x)
Definition: rcba.h:14
uint32_t u32
Definition: stdint.h:51
uint8_t u8
Definition: stdint.h:45
unsigned int hi
Definition: msr.h:112
unsigned int lo
Definition: msr.h:111