blob: 9ea77737e2323b0cc06f99949097d845ce18908a [file] [log] [blame]
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -07001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#ifndef _SOC_CHIP_H_
4#define _SOC_CHIP_H_
5
6#include <drivers/i2c/designware/dw_i2c.h>
Sumeet R Pawnikardbf132c2023-04-13 22:02:01 +05307#include <device/pci_ids.h>
Dinesh Gehlot166c75c72023-01-03 05:26:19 +00008#include <gpio.h>
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -07009#include <intelblocks/cfg.h>
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -070010#include <intelblocks/gspi.h>
11#include <intelblocks/power_limit.h>
12#include <intelblocks/pcie_rp.h>
13#include <intelblocks/tcss.h>
14#include <soc/gpe.h>
15#include <soc/pci_devs.h>
16#include <soc/pmc.h>
17#include <soc/serialio.h>
18#include <soc/usb.h>
19#include <stdint.h>
20
Bora Guvendik9f15dee2023-05-15 14:28:44 -070021#define MAX_SAGV_POINTS 4
Ronak Kanabarb807a1d2023-05-31 10:28:51 +053022#define MAX_HD_AUDIO_SDI_LINKS 2
Bora Guvendik9f15dee2023-05-15 14:28:44 -070023
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -070024/* Types of different SKUs */
25enum soc_intel_meteorlake_power_limits {
Sumeet R Pawnikardbf132c2023-04-13 22:02:01 +053026 MTL_P_282_CORE,
Sumeet Pawnikar33c61712023-07-04 14:34:36 +053027 MTL_P_682_CORE,
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -070028 MTL_POWER_LIMITS_COUNT
29};
30
Sumeet R Pawnikardbf132c2023-04-13 22:02:01 +053031/* TDP values for different SKUs */
32enum soc_intel_meteorlake_cpu_tdps {
Sumeet Pawnikar33c61712023-07-04 14:34:36 +053033 TDP_15W = 15,
34 TDP_28W = 28
Sumeet R Pawnikardbf132c2023-04-13 22:02:01 +053035};
36
37/* Mapping of different SKUs based on CPU ID and TDP values */
38static const struct {
39 unsigned int cpu_id;
40 enum soc_intel_meteorlake_power_limits limits;
41 enum soc_intel_meteorlake_cpu_tdps cpu_tdp;
42} cpuid_to_mtl[] = {
43 { PCI_DID_INTEL_MTL_P_ID_2, MTL_P_282_CORE, TDP_15W },
Sumeet Pawnikar33c61712023-07-04 14:34:36 +053044 { PCI_DID_INTEL_MTL_P_ID_1, MTL_P_682_CORE, TDP_28W },
Sumeet R Pawnikardbf132c2023-04-13 22:02:01 +053045};
46
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -070047/* Types of display ports */
48enum ddi_ports {
49 DDI_PORT_A,
50 DDI_PORT_B,
51 DDI_PORT_C,
52 DDI_PORT_1,
53 DDI_PORT_2,
54 DDI_PORT_3,
55 DDI_PORT_4,
56 DDI_PORT_COUNT,
57};
58
59enum ddi_port_flags {
Maximilian Brune27900ea2023-01-04 19:22:35 +010060 DDI_ENABLE_DDC = 1 << 0, // Display Data Channel
61 DDI_ENABLE_HPD = 1 << 1, // Hot Plug Detect
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -070062};
63
Kapil Porwalae5ba372023-01-04 21:49:36 +053064/*
65 * The Max Pkg Cstate
66 * Values 0 - C0/C1, 1 - C2, 2 - C3, 3 - C6, 4 - C7, 5 - C7S, 6 - C8, 7 - C9, 8 - C10,
67 * 254 - CPU Default , 255 - Auto.
68 */
69enum pkgcstate_limit {
70 LIMIT_C0_C1 = 0,
71 LIMIT_C2 = 1,
72 LIMIT_C3 = 2,
73 LIMIT_C6 = 3,
74 LIMIT_C7 = 4,
75 LIMIT_C7S = 5,
76 LIMIT_C8 = 6,
77 LIMIT_C9 = 7,
78 LIMIT_C10 = 8,
79 LIMIT_CPUDEFAULT = 254,
80 LIMIT_AUTO = 255,
81};
82
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -070083/* Bit values for use in LpmStateEnableMask. */
84enum lpm_state_mask {
85 LPM_S0i2_0 = BIT(0),
86 LPM_S0i2_1 = BIT(1),
87 LPM_S0i2_2 = BIT(2),
88 LPM_S0i3_0 = BIT(3),
89 LPM_S0i3_1 = BIT(4),
90 LPM_S0i3_2 = BIT(5),
91 LPM_S0i3_3 = BIT(6),
92 LPM_S0i3_4 = BIT(7),
93 LPM_S0iX_ALL = LPM_S0i2_0 | LPM_S0i2_1 | LPM_S0i2_2
94 | LPM_S0i3_0 | LPM_S0i3_1 | LPM_S0i3_2 | LPM_S0i3_3 | LPM_S0i3_4,
95};
96
97struct soc_intel_meteorlake_config {
98
99 /* Common struct containing soc config data required by common code */
100 struct soc_intel_common_config common_soc_config;
101
102 /* Common struct containing power limits configuration information */
103 struct soc_power_limits_config power_limits_config[MTL_POWER_LIMITS_COUNT];
104
105 /* Gpio group routed to each dword of the GPE0 block. Values are
106 * of the form PMC_GPP_[A:U] or GPD. */
107 uint8_t pmc_gpe0_dw0; /* GPE0_31_0 STS/EN */
108 uint8_t pmc_gpe0_dw1; /* GPE0_63_32 STS/EN */
109 uint8_t pmc_gpe0_dw2; /* GPE0_95_64 STS/EN */
110
111 /* Generic IO decode ranges */
112 uint32_t gen1_dec;
113 uint32_t gen2_dec;
114 uint32_t gen3_dec;
115 uint32_t gen4_dec;
116
117 /* Enable S0iX support */
118 int s0ix_enable;
119 /* Support for TCSS xhci, xdci, TBT PCIe root ports and DMA controllers */
120 uint8_t tcss_d3_hot_disable;
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -0700121 /* Enable DPTF support */
122 int dptf_enable;
123
124 /* Deep SX enable for both AC and DC */
125 int deep_s3_enable_ac;
126 int deep_s3_enable_dc;
127 int deep_s5_enable_ac;
128 int deep_s5_enable_dc;
129
130 /* Deep Sx Configuration
131 * DSX_EN_WAKE_PIN - Enable WAKE# pin
132 * DSX_EN_LAN_WAKE_PIN - Enable LAN_WAKE# pin
133 * DSX_DIS_AC_PRESENT_PD - Disable pull-down on AC_PRESENT pin */
134 uint32_t deep_sx_config;
135
136 /* TCC activation offset */
137 uint32_t tcc_offset;
138
139 /* System Agent dynamic frequency support. Only effects ULX/ULT CPUs.
140 * When enabled memory will be training at two different frequencies.
Subrata Banik289f9a52023-01-20 21:38:05 +0530141 * 0:Disabled, 1:Enabled
142 */
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -0700143 enum {
Subrata Banik289f9a52023-01-20 21:38:05 +0530144 SAGV_DISABLED,
145 SAGV_ENABLED,
146 } sagv;
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -0700147
Subrata Banika1933082023-05-22 14:22:37 +0530148 /* System Agent dynamic frequency work points that memory will be training
149 * at the enabled frequencies. Possible work points are:
150 * 0x3:Points0_1, 0x7:Points0_1_2, 0xF:AllPoints0_1_2_3
151 */
152 enum {
153 SAGV_POINTS_0_1 = 0x03,
154 SAGV_POINTS_0_1_2 = 0x07,
155 SAGV_POINTS_0_1_2_3 = 0x0f,
156 } sagv_wp_bitmap;
157
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -0700158 /* Rank Margin Tool. 1:Enable, 0:Disable */
Subrata Banik289f9a52023-01-20 21:38:05 +0530159 uint8_t rmt;
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -0700160
161 /* USB related */
162 struct usb2_port_config usb2_ports[CONFIG_SOC_INTEL_USB2_DEV_MAX];
163 struct usb3_port_config usb3_ports[CONFIG_SOC_INTEL_USB3_DEV_MAX];
164 /* Wake Enable Bitmap for USB2 ports */
165 uint16_t usb2_wake_enable_bitmap;
166 /* Wake Enable Bitmap for USB3 ports */
167 uint16_t usb3_wake_enable_bitmap;
168 /* Program OC pins for TCSS */
169 struct tcss_port_config tcss_ports[MAX_TYPE_C_PORTS];
John Zhao54a03e42022-08-03 20:07:03 -0700170 /* Validate TBT firmware authenticated and loaded into IMR */
171 bool tbt_authentication;
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -0700172
173 /* SATA related */
174 uint8_t sata_mode;
175 uint8_t sata_salp_support;
176 uint8_t sata_ports_enable[8];
177 uint8_t sata_ports_dev_slp[8];
178
179 /*
180 * Enable(0)/Disable(1) SATA Power Optimizer on PCH side.
181 * Default 0. Setting this to 1 disables the SATA Power Optimizer.
182 */
183 uint8_t sata_pwr_optimize_disable;
184
185 /*
186 * SATA Port Enable Dito Config.
187 * Enable DEVSLP Idle Timeout settings (DmVal, DitoVal).
188 */
189 uint8_t sata_ports_enable_dito_config[8];
190
191 /* SataPortsDmVal is the DITO multiplier. Default is 15. */
192 uint8_t sata_ports_dm_val[8];
193 /* SataPortsDitoVal is the DEVSLP Idle Timeout, default is 625ms */
194 uint16_t sata_ports_dito_val[8];
195
196 /* Audio related */
197 uint8_t pch_hda_dsp_enable;
198
Ronak Kanabarb807a1d2023-05-31 10:28:51 +0530199 bool pch_hda_sdi_enable[MAX_HD_AUDIO_SDI_LINKS];
200
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -0700201 /* iDisp-Link T-Mode 0: 2T, 2: 4T, 3: 8T, 4: 16T */
202 enum {
203 HDA_TMODE_2T = 0,
204 HDA_TMODE_4T = 2,
205 HDA_TMODE_8T = 3,
206 HDA_TMODE_16T = 4,
207 } pch_hda_idisp_link_tmode;
208
209 /* iDisp-Link Freq 4: 96MHz, 3: 48MHz. */
210 enum {
211 HDA_LINKFREQ_48MHZ = 3,
212 HDA_LINKFREQ_96MHZ = 4,
213 } pch_hda_idisp_link_frequency;
214
215 bool pch_hda_idisp_codec_enable;
216
217 struct pcie_rp_config pcie_rp[CONFIG_MAX_ROOT_PORTS];
218 uint8_t pcie_clk_config_flag[CONFIG_MAX_PCIE_CLOCK_SRC];
219
220 /* Gfx related */
221 enum {
222 IGD_SM_0MB = 0x00,
223 IGD_SM_32MB = 0x01,
224 IGD_SM_64MB = 0x02,
225 IGD_SM_96MB = 0x03,
226 IGD_SM_128MB = 0x04,
227 IGD_SM_160MB = 0x05,
228 IGD_SM_4MB = 0xF0,
229 IGD_SM_8MB = 0xF1,
230 IGD_SM_12MB = 0xF2,
231 IGD_SM_16MB = 0xF3,
232 IGD_SM_20MB = 0xF4,
233 IGD_SM_24MB = 0xF5,
234 IGD_SM_28MB = 0xF6,
235 IGD_SM_36MB = 0xF8,
236 IGD_SM_40MB = 0xF9,
237 IGD_SM_44MB = 0xFA,
238 IGD_SM_48MB = 0xFB,
239 IGD_SM_52MB = 0xFC,
240 IGD_SM_56MB = 0xFD,
241 IGD_SM_60MB = 0xFE,
242 } igd_dvmt50_pre_alloc;
243 uint8_t skip_ext_gfx_scan;
244
245 /* Enable/Disable EIST. 1b:Enabled, 0b:Disabled */
246 uint8_t eist_enable;
247
248 uint8_t PmTimerDisabled;
249 /*
250 * SerialIO device mode selection:
251 * PchSerialIoDisabled,
252 * PchSerialIoPci,
253 * PchSerialIoHidden,
254 * PchSerialIoLegacyUart,
255 * PchSerialIoSkipInit
256 */
257 uint8_t serial_io_i2c_mode[CONFIG_SOC_INTEL_I2C_DEV_MAX];
258 uint8_t serial_io_gspi_mode[CONFIG_SOC_INTEL_COMMON_BLOCK_GSPI_MAX];
259 uint8_t serial_io_uart_mode[CONFIG_SOC_INTEL_UART_DEV_MAX];
260 /*
261 * GSPIn Default Chip Select Mode:
262 * 0:Hardware Mode,
263 * 1:Software Mode
264 */
265 uint8_t serial_io_gspi_cs_mode[CONFIG_SOC_INTEL_COMMON_BLOCK_GSPI_MAX];
266 /*
267 * GSPIn Default Chip Select State:
268 * 0: Low,
269 * 1: High
270 */
271 uint8_t serial_io_gspi_cs_state[CONFIG_SOC_INTEL_COMMON_BLOCK_GSPI_MAX];
272
Kapil Porwal78cc76d2023-04-12 10:30:48 +0530273 /* CNVi WiFi Core Enable/Disable */
274 bool cnvi_wifi_core;
275
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -0700276 /* CNVi BT Core Enable/Disable */
277 bool cnvi_bt_core;
278
279 /* CNVi BT Audio Offload: Enable/Disable BT Audio Offload. */
280 bool cnvi_bt_audio_offload;
281
282 /*
283 * These GPIOs will be programmed by the IOM to handle biasing of the
284 * Type-C aux (SBU) signals when certain alternate modes are used.
285 * `pad_auxn_dc` should be assigned to the GPIO pad providing negative
286 * bias (name usually contains `AUXN_DC` or `AUX_N`); similarly,
287 * `pad_auxp_dc` should be assigned to the GPIO providing positive bias
288 * (name often contains `AUXP_DC` or `_AUX_P`).
289 */
290 struct typec_aux_bias_pads typec_aux_bias_pads[MAX_TYPE_C_PORTS];
291
292 /*
293 * SOC Aux orientation override:
294 * This is a bitfield that corresponds to up to 4 TCSS ports on MTL.
295 * Even numbered bits (0, 2, 4, 6) control the retimer being handled by SOC.
296 * Odd numbered bits (1, 3, 5, 7) control the orientation of the physical aux lines
297 * on the motherboard.
298 */
299 uint16_t tcss_aux_ori;
300
301 /* Connect Topology Command timeout value */
302 uint16_t itbt_connect_topology_timeout_in_ms;
303
304 /*
305 * Override GPIO PM configuration:
306 * 0: Use FSP default GPIO PM program,
307 * 1: coreboot to override GPIO PM program
308 */
309 uint8_t gpio_override_pm;
310
311 /*
312 * GPIO PM configuration: 0 to disable, 1 to enable power gating
313 * Bit 6-7: Reserved
314 * Bit 5: MISCCFG_GPSIDEDPCGEN
315 * Bit 4: MISCCFG_GPRCOMPCDLCGEN
316 * Bit 3: MISCCFG_GPRTCDLCGEN
317 * Bit 2: MISCCFG_GSXLCGEN
318 * Bit 1: MISCCFG_GPDPCGEN
319 * Bit 0: MISCCFG_GPDLCGEN
320 */
321 uint8_t gpio_pm[TOTAL_GPIO_COMM];
322
323 /* DP config */
324 /*
325 * Port config
326 * 0:Disabled, 1:eDP, 2:MIPI DSI
327 */
328 uint8_t ddi_port_A_config;
329 uint8_t ddi_port_B_config;
330
331 /* Enable(1)/Disable(0) HPD/DDC */
332 uint8_t ddi_ports_config[DDI_PORT_COUNT];
333
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -0700334 /*
335 * Override CPU flex ratio value:
336 * CPU ratio value controls the maximum processor non-turbo ratio.
337 * Valid Range 0 to 63.
338 *
339 * In general descriptor provides option to set default cpu flex ratio.
340 * Default cpu flex ratio is 0 ensures booting with non-turbo max frequency.
341 * That's the reason FSP skips cpu_ratio override if cpu_ratio is 0.
342 *
343 * Only override CPU flex ratio if don't want to boot with non-turbo max.
344 */
345 uint8_t cpu_ratio_override;
346
347 /*
348 * Enable(0)/Disable(1) DMI Power Optimizer on PCH side.
349 * Default 0. Setting this to 1 disables the DMI Power Optimizer.
350 */
351 uint8_t dmi_pwr_optimize_disable;
352
353 /*
354 * Enable(1)/Disable(0) CPU Replacement check.
355 * Default 0. Setting this to 1 to check CPU replacement.
356 */
357 uint8_t cpu_replacement_check;
358
359 /* ISA Serial Base selection. */
360 enum {
361 ISA_SERIAL_BASE_ADDR_3F8,
362 ISA_SERIAL_BASE_ADDR_2F8,
363 } isa_serial_uart_base;
364
365 /*
366 * Assign clock source port for GbE. 0: Disable, N-1: port number
367 * Default 0.
368 */
369 uint8_t lan_clk;
Wonkyu Kime5f6ff82022-10-13 13:34:27 -0700370
371 /*
Kapil Porwalae5bc432023-01-04 22:03:02 +0530372 * Enable or Disable Package C-state Demotion.
373 * Default is set to 0.
374 * Set this to 1 in order to disable Package C-state demotion.
375 */
376 bool disable_package_c_state_demotion;
Yong Zhi309d5a52023-02-14 17:25:17 -0600377
378 /* Enable PCH to CPU energy report feature. */
379 bool pch_pm_energy_report_enable;
Subrata Banikd0d7f472023-04-01 14:48:15 +0530380
381 /* Energy-Performance Preference (HWP feature) */
382 bool enable_energy_perf_pref;
383 uint8_t energy_perf_pref_value;
Subrata Banikad6073c2023-04-01 20:37:12 +0530384
385 bool disable_vmx;
Bora Guvendik9f15dee2023-05-15 14:28:44 -0700386
387 /*
388 * SAGV Frequency per point in Mhz. 0 is Auto, otherwise holds the
389 * frequency value expressed as an integer. For example: 1867
390 */
391 uint16_t sagv_freq_mhz[MAX_SAGV_POINTS];
392
393 /* Gear Selection for SAGV points. 0: Auto, 1: Gear 1, 2: Gear 2, 4: Gear 4 */
394 uint8_t sagv_gear[MAX_SAGV_POINTS];
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -0700395};
396
397typedef struct soc_intel_meteorlake_config config_t;
398
399#endif