drivers/fsp2_0/mp_service_ppi: Use struct device to fill in buffer
[coreboot.git] / src / soc / intel / common / block / include / intelblocks / cpulib.h
blobcbc9e449de78384dabaa04ad68c08bf244d2d70e
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef SOC_INTEL_COMMON_BLOCK_CPULIB_H
4 #define SOC_INTEL_COMMON_BLOCK_CPULIB_H
6 #include <types.h>
8 /*
9 * Set PERF_CTL MSR (0x199) P_Req with
10 * Turbo Ratio which is the Maximum Ratio.
12 void cpu_set_max_ratio(void);
14 /* Get CPU bus frequency in MHz */
15 u32 cpu_get_bus_frequency(void);
17 /* Get CPU's max non-turbo ratio */
18 u8 cpu_get_max_non_turbo_ratio(void);
20 /* Check if CPU is hybrid CPU or not */
21 bool cpu_is_hybrid_supported(void);
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.
28 uint8_t cpu_get_cpu_type(void);
30 * Get the TDP Nominal Ratio from MSR 0x648 Bits 7:0.
32 u8 cpu_get_tdp_nominal_ratio(void);
35 * Read PLATFORM_INFO MSR (0xCE).
36 * Return Value of Bit 34:33 (CONFIG_TDP_LEVELS).
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
44 int cpu_config_tdp_levels(void);
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.
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
56 * Set PERF_CTL MSR (0x199) P_Req with that value.
58 void cpu_set_p_state_to_turbo_ratio(void);
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).
65 * Set PERF_CTL MSR (0x199) P_Req with that value.
67 void cpu_set_p_state_to_nominal_tdp_ratio(void);
70 * PLATFORM_INFO MSR (0xCE) Bits 15:8 tells
71 * MAX_NON_TURBO_LIM_RATIO.
73 * Set PERF_CTL MSR (0x199) P_Req with that value.
75 void cpu_set_p_state_to_max_non_turbo_ratio(void);
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().
82 void cpu_set_p_state_to_min_clock_ratio(void);
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.
92 enum {
93 BURST_MODE_UNKNOWN,
94 BURST_MODE_UNAVAILABLE,
95 BURST_MODE_DISABLED,
96 BURST_MODE_ENABLED
98 int cpu_get_burst_mode_state(void);
101 * Program CPU Burst mode
102 * true = Enable Burst mode.
103 * false = Disable Burst mode.
105 void cpu_burst_mode(bool burst_mode_status);
108 * Program Enhanced Intel Speed Step Technology
109 * true = Enable EIST.
110 * false = Disable EIST.
112 void cpu_set_eist(bool eist_status);
115 * SoC specific implementation:
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`.
121 bool cpu_soc_is_in_untrusted_mode(void);
123 /* SoC function to set the BIOS DONE MSR. */
124 void cpu_soc_bios_done(void);
127 * This function fills in the number of Cores(physical) and Threads(virtual)
128 * of the CPU in the function arguments. It also returns if the number of cores
129 * and number of threads are equal.
131 int cpu_read_topology(unsigned int *num_phys, unsigned int *num_virt);
134 * cpu_get_bus_clock returns the bus clock frequency in KHz.
135 * This is the value the clock ratio is multiplied with.
137 uint32_t cpu_get_bus_clock(void);
140 * cpu_get_coord_type returns coordination type (SW_ANY or SW_ALL or HW_ALL)
141 * which is used to populate _PSD object.
143 int cpu_get_coord_type(void);
146 * cpu_get_min_ratio returns the minimum frequency ratio that is supported
147 * by this processor
149 uint32_t cpu_get_min_ratio(void);
152 * cpu_get_max_ratio returns the nominal TDP ratio if available or the
153 * maximum non turbo frequency ratio for this processor
155 uint32_t cpu_get_max_ratio(void);
157 /* Thermal throttle activation offset */
158 void configure_tcc_thermal_target(void);
161 * cpu_get_power_max calculates CPU TDP in mW
163 uint32_t cpu_get_power_max(void);
166 * cpu_get_max_turbo_ratio returns the maximum turbo ratio limit for the
167 * processor
169 uint32_t cpu_get_max_turbo_ratio(void);
171 /* Configure Machine Check Architecture support */
172 void mca_configure(void);
174 /* Lock chipset memory registers to protect SMM */
175 void cpu_lt_lock_memory(void);
177 /* Get a supported PRMRR size in bytes with respect to users choice */
178 int get_valid_prmrr_size(void);
181 * Enable the emulated ACPI timer in case it's not available or to allow
182 * disabling the PM ACPI timer (PM1_TMR) for power saving.
184 void enable_pm_timer_emulation(void);
187 * Initialize core PRMRR
189 * Read the BSP PRMRR snapshot and apply on the rest of the core threads
191 void init_core_prmrr(void);
194 * Check if TME is supported by the CPU
196 * coreboot shall detect the existence of TME feature by running CPUID instruction:
197 * CPUID leaf 7/sub-leaf 0: Return Value in ECX [bit 13] = 1
199 bool is_tme_supported(void);
202 * Set TME core activate MSR
204 * Write zero to TME core activate MSR will translate the TME_ACTIVATE[MK_TME_KEYID_BITS]
205 * value into PMH mask register.
206 * TME_ACTIVATE[MK_TME_KEYID_BITS] = MSR 0x982 Bits[32-35]
208 void set_tme_core_activate(void);
211 * This function checks if the CPU supports SGX feature.
212 * Returns true if SGX feature is supported otherwise false.
214 bool is_sgx_supported(void);
217 * This function checks if the CPU supports Key Locker feature.
218 * Returns true if Key Locker feature is supported otherwise false.
220 bool is_keylocker_supported(void);
223 * This function prevents the Three Strike Counter from incrementing.
224 * It helps to collect more useful CPU traces for debugging.
226 void disable_three_strike_error(void);
228 #endif /* SOC_INTEL_COMMON_BLOCK_CPULIB_H */