Debian Codegraph @

src/soc/intel/common/block/include/intelblocks/acpi.h

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 #ifndef SOC_INTEL_COMMON_BLOCK_ACPI_H
4 #define SOC_INTEL_COMMON_BLOCK_ACPI_H
5
6 #include <acpi/acpi.h>
7 #include <device/device.h>
8 #include <intelblocks/cpulib.h>
9 #include <soc/pm.h>
10 #include <stdint.h>
11
12 /* CPU Types */
13 enum core_type {
14 CPUID_RESERVED_1 = 0x10,
15 CPUID_CORE_TYPE_INTEL_ATOM = 0x20,
16 CPUID_RESERVED_2 = 0x30,
17 CPUID_CORE_TYPE_INTEL_CORE = 0x40,
18 CPUID_UNKNOWN = 0xff,
19 };
20
21 /* CPU Performance Type */
22 enum cpu_perf_eff_type {
23 CPU_TYPE_EFF,
24 CPU_TYPE_PERF,
25 };
26
27 unsigned long acpi_create_madt_lapics_with_nmis_hybrid(unsigned long current);
28
29 #if CONFIG(SOC_INTEL_COMMON_BLOCK_ACPI_CPU_HYBRID)
30 /*
31 * Read the performance and efficient core ratios.
32 * This is to be implemented by the SoC specific code if
33 * SOC_INTEL_COMMON_BLOCK_RUNTIME_CORE_SCALING_FACTORS is selected.
34 */
35 #if CONFIG(SOC_INTEL_COMMON_BLOCK_RUNTIME_CORE_SCALING_FACTORS)
36 enum cb_err soc_read_core_scaling_factors(u16 *performance, u16 *efficient);
37 #else
38 static inline enum cb_err soc_read_core_scaling_factors(u16 *performance, u16 *efficient)
39 {
40 _Static_assert(CONFIG_SOC_INTEL_PERFORMANCE_CORE_SCALE_FACTOR != 0,
41 "CONFIG_SOC_INTEL_PERFORMANCE_CORE_SCALE_FACTOR must not be zero");
42
43 _Static_assert(CONFIG_SOC_INTEL_EFFICIENT_CORE_SCALE_FACTOR != 0,
44 "CONFIG_SOC_INTEL_EFFICIENT_CORE_SCALE_FACTOR must not be zero");
45
46 *performance = CONFIG_SOC_INTEL_PERFORMANCE_CORE_SCALE_FACTOR;
47 *efficient = CONFIG_SOC_INTEL_EFFICIENT_CORE_SCALE_FACTOR;
48
49 return CB_SUCCESS;
50 }
51 #endif
52 #endif /* SOC_INTEL_COMMON_BLOCK_ACPI_CPU_HYBRID */
53
54 /* Generates ACPI code to define _CPC control method */
55 void acpigen_write_CPPC_hybrid_method(int core_id);
56
57 /* Forward declare the power state struct here */
58 struct chipset_power_state;
59
60 /* Forward declare the global nvs structure here */
61 struct global_nvs;
62
63 /* Return ACPI name for this device */
64 const char *soc_acpi_name(const struct device *dev);
65
66 /* Read the scis from soc specific register. Returns int scis value */
67 uint32_t soc_read_sci_irq_select(void);
68
69 /* Write the scis from soc specific register. */
70 void soc_write_sci_irq_select(uint32_t scis);
71
72 /* _CST MWAIT resource used by cstate_map. */
73 #define MWAIT_RES(state, sub_state) \
74 { \
75 .addrl = (((state) << 4) | (sub_state)), \
76 .space_id = ACPI_ADDRESS_SPACE_FIXED, \
77 .bit_width = ACPI_FFIXEDHW_VENDOR_INTEL, \
78 .bit_offset = ACPI_FFIXEDHW_CLASS_MWAIT, \
79 .access_size = ACPI_FFIXEDHW_FLAG_HW_COORD, \
80 }
81
82 /*
83 * get_cstate_map returns a table of processor specific acpi_cstate_t entries
84 * and number of entries in the table
85 */
86 const acpi_cstate_t *soc_get_cstate_map(size_t *num_entries);
87
88 /*
89 * get_tstate_map returns a table of processor specific acpi_tstate_t entries
90 * and number of entries in the table
91 */
92 acpi_tstate_t *soc_get_tss_table(int *entries);
93
94 /*
95 * Chipset specific quirks for the wake enable bits.
96 */
97 void acpi_fill_soc_wake(uint32_t *pm1_en, uint32_t *gpe0_en,
98 const struct chipset_power_state *ps);
99
100 /* Chipset specific settings for filling up dmar table */
101 unsigned long sa_write_acpi_tables(const struct device *dev,
102 unsigned long current,
103 struct acpi_rsdp *rsdp);
104
105 /* Return the polarity flag for SCI IRQ */
106 int soc_madt_sci_irq_polarity(int sci);
107
108 /* Generate P-state tables */
109 void generate_p_state_entries(int core, int cores_per_package);
110
111 /* Generate T-state tables */
112 void generate_t_state_entries(int core, int cores_per_package);
113
114 /*
115 * soc specific power states generation. We need this to be defined by soc
116 * as the state generations varies in chipsets e.g. APL generates T and P
117 * states while SKL generates * P state only depending on a devicetree config
118 */
119 void soc_power_states_generation(int core_id, int cores_per_package);
120
121 /*
122 * Common function to calculate the power ratio for power state generation
123 */
124 int common_calculate_power_ratio(int tdp, int p1_ratio, int ratio);
125
126
127 /*
128 * Return the number of table entries and takes a pointer to an array of ioapic bases.
129 */
130 size_t soc_get_ioapic_info(const uintptr_t *ioapic_bases[]);
131
132 struct soc_pmc_lpm {
133 unsigned int num_substates;
134 unsigned int num_req_regs;
135 unsigned int lpm_ipc_offset;
136 unsigned int req_reg_stride;
137 uint8_t lpm_enable_mask;
138 };
139
140 /* Generate an Intel Power Engine ACPI device */
141 void generate_acpi_power_engine(void);
142
143 /* Generate an Intel Power Engine ACPI device that supports exposing LPM
144 substate requirements */
145 void generate_acpi_power_engine_with_lpm(const struct soc_pmc_lpm *lpm);
146
147 /* Fill SSDT for SGX status, EPC base and length */
148 void sgx_fill_ssdt(void);
149
150 /*
151 * This function returns the CPU type (big or small) of the CPU that it is executing
152 * on. It is designed to be called after MP initialization. If the SoC selects
153 * SOC_INTEL_COMMON_BLOCK_ACPI_CPU_HYBRID, then this function must be implemented,
154 * and will be called from set_cpu_type().
155 */
156 enum core_type get_soc_cpu_type(void);
157
158 /* Check if CPU supports Nominal frequency or not */
159 bool soc_is_nominal_freq_supported(void);
160
161 /* Min sleep state per device*/
162 struct min_sleep_state {
163 uint8_t pci_dev;
164 enum acpi_device_sleep_states min_sleep_state;
165 };
166
167 /* Updates core type into 'struct cpu_info' */
168 void set_dev_core_type(void);
169
170 /*
171 * This SOC callback returns an array that maps devices to their min sleep state.
172 * Example:
173 *
174 * static struct min_sleep_state min_pci_sleep_states[] = {
175 * { SA_DEVFN_ROOT, ACPI_DEVICE_SLEEP_D3 },
176 * { SA_DEVFN_CPU_PCIE1_0, ACPI_DEVICE_SLEEP_D3 },
177 * { SA_DEVFN_IGD, ACPI_DEVICE_SLEEP_D3 },
178 * ...
179 * };
180 *
181 * const struct pad_config *variant_early_gpio_table(size_t *num)
182 * {
183 * *num = ARRAY_SIZE(early_gpio_table);
184 * return early_gpio_table;
185 * }
186 *
187 */
188 struct min_sleep_state *soc_get_min_sleep_state_array(size_t *size);
189
190 #endif /* _SOC_INTEL_COMMON_BLOCK_ACPI_H_ */