coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
cpulib.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef SOC_INTEL_COMMON_BLOCK_CPULIB_H
4 #define SOC_INTEL_COMMON_BLOCK_CPULIB_H
5 
6 #include <types.h>
7 
8 /*
9  * Set PERF_CTL MSR (0x199) P_Req with
10  * Turbo Ratio which is the Maximum Ratio.
11  */
12 void cpu_set_max_ratio(void);
13 
14 /* Get CPU bus frequency in MHz */
16 
17 /* Get CPU's max non-turbo ratio */
19 
20 /* Check if CPU is hybrid CPU or not */
21 bool cpu_is_hybrid_supported(void);
22 
23 /*
24  * Returns type of CPU that executing the function. It returns 0x20
25  * if CPU is atom, otherwise 0x40 if CPU is CORE. The API must be called
26  * if CPU is hybrid.
27  */
29 /*
30  * Get the TDP Nominal Ratio from MSR 0x648 Bits 7:0.
31  */
33 
34 /*
35  * Read PLATFORM_INFO MSR (0xCE).
36  * Return Value of Bit 34:33 (CONFIG_TDP_LEVELS).
37  *
38  * Possible values of Bit 34:33 are -
39  * 00 : Config TDP not supported
40  * 01 : One Additional TDP level supported
41  * 10 : Two Additional TDP level supported
42  * 11 : Reserved
43  */
44 int cpu_config_tdp_levels(void);
45 
46 /*
47  * TURBO_RATIO_LIMIT MSR (0x1AD) Bits 31:0 indicates the
48  * factory configured values for of 1-core, 2-core, 3-core
49  * and 4-core turbo ratio limits for all processors.
50  *
51  * 7:0 - MAX_TURBO_1_CORE
52  * 15:8 - MAX_TURBO_2_CORES
53  * 23:16 - MAX_TURBO_3_CORES
54  * 31:24 - MAX_TURBO_4_CORES
55  *
56  * Set PERF_CTL MSR (0x199) P_Req with that value.
57  */
59 
60 /*
61  * CONFIG_TDP_NOMINAL MSR (0x648) Bits 7:0 tells Nominal
62  * TDP level ratio to be used for specific processor (in units
63  * of 100MHz).
64  *
65  * Set PERF_CTL MSR (0x199) P_Req with that value.
66  */
68 
69 /*
70  * PLATFORM_INFO MSR (0xCE) Bits 15:8 tells
71  * MAX_NON_TURBO_LIM_RATIO.
72  *
73  * Set PERF_CTL MSR (0x199) P_Req with that value.
74  */
76 
77 /*
78  * Set PERF_CTL MSR (0x199) P_Req with the value
79  * for maximum efficiency. This value is reported in PLATFORM_INFO MSR (0xCE)
80  * in Bits 47:40 and is extracted with cpu_get_min_ratio().
81  */
83 
84 /*
85  * Get the Burst/Turbo Mode State from MSR IA32_MISC_ENABLE 0x1A0
86  * Bit 38 - TURBO_MODE_DISABLE Bit to get state ENABLED / DISABLED.
87  * Also check for the cpuid 0x6 to check whether Burst mode unsupported.
88  * Below are the possible cpu_get_burst_mode_state() return values-
89  * These states are exposed to the User since user
90  * need to know which is the current Burst Mode State.
91  */
92 enum {
97 };
98 int cpu_get_burst_mode_state(void);
99 
100 /*
101  * Program CPU Burst mode
102  * true = Enable Burst mode.
103  * false = Disable Burst mode.
104  */
105 void cpu_burst_mode(bool burst_mode_status);
106 
107 /*
108  * Program Enhanced Intel Speed Step Technology
109  * true = Enable EIST.
110  * false = Disable EIST.
111  */
112 void cpu_set_eist(bool eist_status);
113 
114 /*
115  * SoC specific implementation:
116  *
117  * Check CPU security level using ENABLE_IA_UNTRUSTED_MODE of CPU MSR.
118  * If bit is set, meaning CPU has dropped its security level by entering
119  * into `untrusted mode`. Otherwise, it's in `trusted mode`.
120  */
122 
123 /*
124  * This function fills in the number of Cores(physical) and Threads(virtual)
125  * of the CPU in the function arguments. It also returns if the number of cores
126  * and number of threads are equal.
127  */
128 int cpu_read_topology(unsigned int *num_phys, unsigned int *num_virt);
129 
130 /*
131  * cpu_get_bus_clock returns the bus clock frequency in KHz.
132  * This is the value the clock ratio is multiplied with.
133  */
135 
136 /*
137  * cpu_get_coord_type returns coordination type (SW_ANY or SW_ALL or HW_ALL)
138  * which is used to populate _PSD object.
139  */
140 int cpu_get_coord_type(void);
141 
142 /*
143  * cpu_get_min_ratio returns the minimum frequency ratio that is supported
144  * by this processor
145  */
147 
148 /*
149  * cpu_get_max_ratio returns the nominal TDP ratio if available or the
150  * maximum non turbo frequency ratio for this processor
151  */
153 
154 /* Thermal throttle activation offset */
156 
157 /*
158  * cpu_get_power_max calculates CPU TDP in mW
159  */
161 
162 /*
163  * cpu_get_max_turbo_ratio returns the maximum turbo ratio limit for the
164  * processor
165  */
167 
168 /* Configure Machine Check Architecture support */
169 void mca_configure(void);
170 
171 /* Lock chipset memory registers to protect SMM */
172 void cpu_lt_lock_memory(void);
173 
174 /* Get a supported PRMRR size in bytes with respect to users choice */
175 int get_valid_prmrr_size(void);
176 
177 /*
178  * Enable the emulated ACPI timer in case it's not available or to allow
179  * disabling the PM ACPI timer (PM1_TMR) for power saving.
180  */
181 void enable_pm_timer_emulation(void);
182 
183 /* Derive core, package and thread information from lapic ID */
184 void get_cpu_topology_from_apicid(uint32_t apicid, uint8_t *package,
185  uint8_t *core, uint8_t *thread);
186 
187 #endif /* SOC_INTEL_COMMON_BLOCK_CPULIB_H */
void mca_configure(void)
Definition: cpulib.c:376
void cpu_set_eist(bool eist_status)
Definition: cpulib.c:250
void enable_pm_timer_emulation(void)
int cpu_get_burst_mode_state(void)
Definition: cpulib.c:172
uint32_t cpu_get_min_ratio(void)
Definition: cpulib.c:281
uint8_t cpu_get_cpu_type(void)
Definition: cpulib.c:207
void cpu_set_max_ratio(void)
Definition: cpulib.c:45
@ BURST_MODE_DISABLED
Definition: cpulib.h:95
@ BURST_MODE_UNAVAILABLE
Definition: cpulib.h:94
@ BURST_MODE_UNKNOWN
Definition: cpulib.h:93
@ BURST_MODE_ENABLED
Definition: cpulib.h:96
u32 cpu_get_bus_frequency(void)
Definition: cpulib.c:223
int cpu_get_coord_type(void)
Definition: cpulib.c:276
void configure_tcc_thermal_target(void)
Definition: cpulib.c:317
bool cpu_soc_is_in_untrusted_mode(void)
Definition: cpu.c:33
u8 cpu_get_tdp_nominal_ratio(void)
Definition: cpulib.c:55
void cpu_set_p_state_to_max_non_turbo_ratio(void)
Definition: cpulib.c:138
uint32_t cpu_get_max_ratio(void)
Definition: cpulib.c:289
u8 cpu_get_max_non_turbo_ratio(void)
Definition: cpulib.c:305
void cpu_set_p_state_to_turbo_ratio(void)
Definition: cpulib.c:103
void cpu_set_p_state_to_nominal_tdp_ratio(void)
Definition: cpulib.c:121
int cpu_read_topology(unsigned int *num_phys, unsigned int *num_virt)
Definition: cpulib.c:267
uint32_t cpu_get_power_max(void)
Definition: cpulib.c:358
void cpu_set_p_state_to_min_clock_ratio(void)
Definition: cpulib.c:154
bool cpu_is_hybrid_supported(void)
Definition: cpulib.c:194
uint32_t cpu_get_max_turbo_ratio(void)
Definition: cpulib.c:369
void get_cpu_topology_from_apicid(uint32_t apicid, uint8_t *package, uint8_t *core, uint8_t *thread)
Definition: cpulib.c:471
void cpu_lt_lock_memory(void)
Definition: cpulib.c:392
int get_valid_prmrr_size(void)
Definition: cpulib.c:397
int cpu_config_tdp_levels(void)
Definition: haswell_init.c:300
uint32_t cpu_get_bus_clock(void)
Definition: cpulib.c:350
void cpu_burst_mode(bool burst_mode_status)
Definition: cpulib.c:233
unsigned int uint32_t
Definition: stdint.h:14
uint32_t u32
Definition: stdint.h:51
uint8_t u8
Definition: stdint.h:45
unsigned char uint8_t
Definition: stdint.h:8