Debian Codegraph @

src/soc/intel/meteorlake/chip.h

raw symbols SCIP
1 /* 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>
7 #include <drivers/intel/gma/gma.h>
8 #include <device/pci_ids.h>
9 #include <gpio.h>
10 #include <intelblocks/cfg.h>
11 #include <intelblocks/gspi.h>
12 #include <intelblocks/power_limit.h>
13 #include <intelblocks/pcie_rp.h>
14 #include <intelblocks/tcss.h>
15 #include <soc/gpe.h>
16 #include <soc/pci_devs.h>
17 #include <soc/pmc.h>
18 #include <soc/serialio.h>
19 #include <soc/usb.h>
20 #include <stdbool.h>
21 #include <stdint.h>
22
23 /* Define config parameters for In-Band ECC (IBECC). */
24 #define MAX_IBECC_REGIONS 8
25
26 #define MAX_SAGV_POINTS 4
27 #define MAX_HD_AUDIO_SDI_LINKS 2
28
29 /* In-Band ECC Operation Mode */
30 enum ibecc_mode {
31 IBECC_MODE_PER_REGION,
32 IBECC_MODE_NONE,
33 IBECC_MODE_ALL
34 };
35
36 struct ibecc_config {
37 bool enable;
38 bool parity_en;
39 enum ibecc_mode mode;
40 bool region_enable[MAX_IBECC_REGIONS];
41 uint16_t region_base[MAX_IBECC_REGIONS];
42 uint16_t region_mask[MAX_IBECC_REGIONS];
43 };
44
45 /* Types of different SKUs */
46 enum soc_intel_meteorlake_power_limits {
47 MTL_P_282_242_CORE,
48 MTL_P_682_482_CORE,
49 MTL_POWER_LIMITS_COUNT
50 };
51
52 /* TDP values for different SKUs */
53 enum soc_intel_meteorlake_cpu_tdps {
54 TDP_15W = 15,
55 TDP_28W = 28
56 };
57
58 /* Mapping of different SKUs based on CPU ID and TDP values */
59 static const struct {
60 unsigned int cpu_id;
61 enum soc_intel_meteorlake_power_limits limits;
62 enum soc_intel_meteorlake_cpu_tdps cpu_tdp;
63 } cpuid_to_mtl[] = {
64 { PCI_DID_INTEL_MTL_P_ID_5, MTL_P_282_242_CORE, TDP_15W },
65 { PCI_DID_INTEL_MTL_P_ID_2, MTL_P_282_242_CORE, TDP_15W },
66 { PCI_DID_INTEL_MTL_P_ID_3, MTL_P_682_482_CORE, TDP_28W },
67 { PCI_DID_INTEL_MTL_P_ID_1, MTL_P_682_482_CORE, TDP_28W },
68 { PCI_DID_INTEL_ARL_H_ID_1, MTL_P_682_482_CORE, TDP_28W },
69 { PCI_DID_INTEL_ARL_H_ID_2, MTL_P_682_482_CORE, TDP_28W },
70 };
71
72 /* Types of display ports */
73 enum ddi_ports {
74 DDI_PORT_A,
75 DDI_PORT_B,
76 DDI_PORT_C,
77 DDI_PORT_1,
78 DDI_PORT_2,
79 DDI_PORT_3,
80 DDI_PORT_4,
81 DDI_PORT_COUNT,
82 };
83
84 enum ddi_port_flags {
85 DDI_ENABLE_DDC = 1 << 0, // Display Data Channel
86 DDI_ENABLE_HPD = 1 << 1, // Hot Plug Detect
87 };
88
89 /*
90 * The Max Pkg Cstate
91 * Values 0 - C0/C1, 1 - C2, 2 - C3, 3 - C6, 4 - C7, 5 - C7S, 6 - C8, 7 - C9, 8 - C10,
92 * 254 - CPU Default , 255 - Auto.
93 */
94 enum pkgcstate_limit {
95 LIMIT_C0_C1 = 0,
96 LIMIT_C2 = 1,
97 LIMIT_C3 = 2,
98 LIMIT_C6 = 3,
99 LIMIT_C7 = 4,
100 LIMIT_C7S = 5,
101 LIMIT_C8 = 6,
102 LIMIT_C9 = 7,
103 LIMIT_C10 = 8,
104 LIMIT_CPUDEFAULT = 254,
105 LIMIT_AUTO = 255,
106 };
107
108 /* Bit values for use in LpmStateEnableMask. */
109 enum lpm_state_mask {
110 LPM_S0i2_0 = BIT(0),
111 LPM_S0i2_1 = BIT(1),
112 LPM_S0i2_2 = BIT(2),
113 LPM_S0i3_0 = BIT(3),
114 LPM_S0i3_1 = BIT(4),
115 LPM_S0i3_2 = BIT(5),
116 LPM_S0i3_3 = BIT(6),
117 LPM_S0i3_4 = BIT(7),
118 LPM_S0iX_ALL = LPM_S0i2_0 | LPM_S0i2_1 | LPM_S0i2_2
119 | LPM_S0i3_0 | LPM_S0i3_1 | LPM_S0i3_2 | LPM_S0i3_3 | LPM_S0i3_4,
120 };
121
122 /*
123 * As per definition from FSP header:
124 * - [0] for IA
125 * - [1] for GT
126 * - [2] for SA
127 * - [3] through [5] are reserved
128 */
129 enum vr_domain {
130 VR_DOMAIN_IA,
131 VR_DOMAIN_GT,
132 VR_DOMAIN_SA,
133 NUM_VR_DOMAINS
134 };
135
136 /*
137 * Slew Rate configuration for Deep Package C States for VR domain.
138 * They are fast time divided by 2.
139 * 0 - Fast/2
140 * 1 - Fast/4
141 * 2 - Fast/8
142 * 3 - Fast/16
143 */
144 enum slew_rate {
145 SLEW_FAST_2,
146 SLEW_FAST_4,
147 SLEW_FAST_8,
148 SLEW_FAST_16,
149 SLEW_IGNORE = 0xff,
150 };
151
152 struct soc_intel_meteorlake_config {
153 /* Common struct containing soc config data required by common code */
154 struct soc_intel_common_config common_soc_config;
155
156 /* Common struct containing power limits configuration information */
157 struct soc_power_limits_config power_limits_config[MTL_POWER_LIMITS_COUNT];
158
159 /* Gpio group routed to each dword of the GPE0 block. Values are
160 * of the form PMC_GPP_[A:U] or GPD. */
161 uint8_t pmc_gpe0_dw0; /* GPE0_31_0 STS/EN */
162 uint8_t pmc_gpe0_dw1; /* GPE0_63_32 STS/EN */
163 uint8_t pmc_gpe0_dw2; /* GPE0_95_64 STS/EN */
164
165 /* Generic IO decode ranges */
166 uint32_t gen1_dec;
167 uint32_t gen2_dec;
168 uint32_t gen3_dec;
169 uint32_t gen4_dec;
170
171 /* Enable S0iX support */
172 bool s0ix_enable;
173 /* Support for TCSS xhci, xdci, TBT PCIe root ports and DMA controllers */
174 bool tcss_d3_hot_disable;
175 /* Enable DPTF support */
176 bool dptf_enable;
177
178 /* Deep SX enable for both AC and DC */
179 bool deep_s3_enable_ac;
180 bool deep_s3_enable_dc;
181 bool deep_s5_enable_ac;
182 bool deep_s5_enable_dc;
183
184 /* Deep Sx Configuration
185 * DSX_EN_WAKE_PIN - Enable WAKE# pin
186 * DSX_EN_LAN_WAKE_PIN - Enable LAN_WAKE# pin
187 * DSX_DIS_AC_PRESENT_PD - Disable pull-down on AC_PRESENT pin */
188 uint32_t deep_sx_config;
189
190 /* TCC activation offset */
191 uint32_t tcc_offset;
192
193 /* In-Band ECC (IBECC) configuration */
194 struct ibecc_config ibecc;
195
196 /* System Agent dynamic frequency support. Only effects ULX/ULT CPUs.
197 * When enabled memory will be training at two different frequencies.
198 * 0:Disabled, 1:Enabled
199 */
200 enum {
201 SAGV_DISABLED,
202 SAGV_ENABLED,
203 } sagv;
204
205 /* System Agent dynamic frequency work points that memory will be training
206 * at the enabled frequencies. Possible work points are:
207 * 0x3:Points0_1, 0x7:Points0_1_2, 0xF:AllPoints0_1_2_3
208 */
209 enum {
210 SAGV_POINTS_0_1 = 0x03,
211 SAGV_POINTS_0_1_2 = 0x07,
212 SAGV_POINTS_0_1_2_3 = 0x0f,
213 } sagv_wp_bitmap;
214
215 /* Rank Margin Tool. */
216 bool rmt;
217
218 /* USB related */
219 struct usb2_port_config usb2_ports[CONFIG_SOC_INTEL_USB2_DEV_MAX];
220 struct usb3_port_config usb3_ports[CONFIG_SOC_INTEL_USB3_DEV_MAX];
221 /* Wake Enable Bitmap for USB2 ports */
222 uint16_t usb2_wake_enable_bitmap;
223 /* Wake Enable Bitmap for USB3 ports */
224 uint16_t usb3_wake_enable_bitmap;
225 /* Program OC pins for TCSS */
226 struct tcss_port_config tcss_ports[MAX_TYPE_C_PORTS];
227 /* Validate TBT firmware authenticated and loaded into IMR */
228 bool tbt_authentication;
229
230 /* SATA related */
231 uint8_t sata_mode;
232 bool sata_salp_support;
233 bool sata_ports_enable[8];
234 bool sata_ports_dev_slp[8];
235
236 /*
237 * Enable(false)/Disable(true) SATA Power Optimizer on PCH side.
238 * Default false. Setting this to true disables the SATA Power Optimizer.
239 */
240 bool sata_pwr_optimize_disable;
241
242 /*
243 * SATA Port Enable Dito Config.
244 * Enable DEVSLP Idle Timeout settings (DmVal, DitoVal).
245 */
246 bool sata_ports_enable_dito_config[8];
247
248 /* SataPortsDmVal is the DITO multiplier. Default is 15. */
249 uint8_t sata_ports_dm_val[8];
250 /* SataPortsDitoVal is the DEVSLP Idle Timeout, default is 625ms */
251 uint16_t sata_ports_dito_val[8];
252
253 /* Audio related */
254 bool pch_hda_audio_link_hda_enable;
255 bool pch_hda_dsp_enable;
256
257 bool pch_hda_sdi_enable[MAX_HD_AUDIO_SDI_LINKS];
258
259 /* iDisp-Link T-Mode 0: 2T, 2: 4T, 3: 8T, 4: 16T */
260 enum {
261 HDA_TMODE_2T = 0,
262 HDA_TMODE_4T = 2,
263 HDA_TMODE_8T = 3,
264 HDA_TMODE_16T = 4,
265 } pch_hda_idisp_link_tmode;
266
267 /* iDisp-Link Freq 4: 96MHz, 3: 48MHz. */
268 enum {
269 HDA_LINKFREQ_48MHZ = 3,
270 HDA_LINKFREQ_96MHZ = 4,
271 } pch_hda_idisp_link_frequency;
272
273 bool pch_hda_idisp_codec_enable;
274
275 struct pcie_rp_config pcie_rp[CONFIG_MAX_ROOT_PORTS];
276 uint8_t pcie_clk_config_flag[CONFIG_MAX_PCIE_CLOCK_SRC];
277
278 /* Gfx related */
279 enum {
280 IGD_SM_0MB = 0x00,
281 IGD_SM_32MB = 0x01,
282 IGD_SM_64MB = 0x02,
283 IGD_SM_96MB = 0x03,
284 IGD_SM_128MB = 0x04,
285 IGD_SM_160MB = 0x05,
286 IGD_SM_4MB = 0xF0,
287 IGD_SM_8MB = 0xF1,
288 IGD_SM_12MB = 0xF2,
289 IGD_SM_16MB = 0xF3,
290 IGD_SM_20MB = 0xF4,
291 IGD_SM_24MB = 0xF5,
292 IGD_SM_28MB = 0xF6,
293 IGD_SM_36MB = 0xF8,
294 IGD_SM_40MB = 0xF9,
295 IGD_SM_44MB = 0xFA,
296 IGD_SM_48MB = 0xFB,
297 IGD_SM_52MB = 0xFC,
298 IGD_SM_56MB = 0xFD,
299 IGD_SM_60MB = 0xFE,
300 } igd_dvmt50_pre_alloc;
301
302 bool skip_ext_gfx_scan;
303 bool eist_enable;
304
305 /*
306 * When enabled, this feature makes the SoC throttle when the power
307 * consumption exceeds the I_TRIP threshold.
308 *
309 * FSPs sets a by default I_TRIP threshold adapted to the current SoC
310 * and assuming a Voltage Regulator error accuracy of 6.5%.
311 */
312 bool enable_fast_vmode[NUM_VR_DOMAINS];
313
314 /*
315 * Current Excursion Protection needs to be set for each VR domain
316 * in order to be able to enable fast Vmode.
317 */
318 bool cep_enable[NUM_VR_DOMAINS];
319
320 /*
321 * VR Fast Vmode I_TRIP threshold.
322 * 0-255A in 1/4 A units. Example: 400 = 100A
323 * This setting overrides the default value set by FSPs when Fast VMode
324 * is enabled.
325 */
326 uint16_t fast_vmode_i_trip[NUM_VR_DOMAINS];
327
328 /*
329 * Power state current threshold 1.
330 * Defined in 1/4 A increments. A value of 400 = 100A. Range 0-512,
331 * which translates to 0-128A. 0 = AUTO. [0] for IA, [1] for GT, [2] for
332 * SA, [3] through [5] are Reserved.
333 */
334 uint16_t ps_cur_1_threshold[NUM_VR_DOMAINS];
335
336 /*
337 * Power state current threshold 2.
338 * Defined in 1/4 A increments. A value of 400 = 100A. Range 0-512,
339 * which translates to 0-128A. 0 = AUTO. [0] for IA, [1] for GT, [2] for
340 * SA, [3] through [5] are Reserved.
341 */
342 uint16_t ps_cur_2_threshold[NUM_VR_DOMAINS];
343
344 /*
345 * Power state current threshold 3.
346 * Defined in 1/4 A increments. A value of 400 = 100A. Range 0-512,
347 * which translates to 0-128A. 0 = AUTO. [0] for IA, [1] for GT, [2] for
348 * SA, [3] through [5] are Reserved.
349 */
350 uint16_t ps_cur_3_threshold[NUM_VR_DOMAINS];
351
352 /*
353 * SerialIO device mode selection:
354 * PchSerialIoDisabled,
355 * PchSerialIoPci,
356 * PchSerialIoHidden,
357 * PchSerialIoLegacyUart,
358 * PchSerialIoSkipInit
359 */
360 uint8_t serial_io_i2c_mode[CONFIG_SOC_INTEL_I2C_DEV_MAX];
361 uint8_t serial_io_gspi_mode[CONFIG_SOC_INTEL_COMMON_BLOCK_GSPI_MAX];
362 uint8_t serial_io_uart_mode[CONFIG_SOC_INTEL_UART_DEV_MAX];
363 /*
364 * GSPIn Default Chip Select Mode:
365 * 0:Hardware Mode,
366 * 1:Software Mode
367 */
368 uint8_t serial_io_gspi_cs_mode[CONFIG_SOC_INTEL_COMMON_BLOCK_GSPI_MAX];
369 /*
370 * GSPIn Default Chip Select State:
371 * 0: Low,
372 * 1: High
373 */
374 uint8_t serial_io_gspi_cs_state[CONFIG_SOC_INTEL_COMMON_BLOCK_GSPI_MAX];
375
376 /* CNVi WiFi Core Enable/Disable */
377 bool cnvi_wifi_core;
378
379 /* CNVi BT Core Enable/Disable */
380 bool cnvi_bt_core;
381
382 /* CNVi BT Audio Offload: Enable/Disable BT Audio Offload. */
383 bool cnvi_bt_audio_offload;
384
385 /*
386 * These GPIOs will be programmed by the IOM to handle biasing of the
387 * Type-C aux (SBU) signals when certain alternate modes are used.
388 * `pad_auxn_dc` should be assigned to the GPIO pad providing negative
389 * bias (name usually contains `AUXN_DC` or `AUX_N`); similarly,
390 * `pad_auxp_dc` should be assigned to the GPIO providing positive bias
391 * (name often contains `AUXP_DC` or `_AUX_P`).
392 */
393 struct typec_aux_bias_pads typec_aux_bias_pads[MAX_TYPE_C_PORTS];
394
395 /*
396 * SOC Aux orientation override:
397 * This is a bitfield that corresponds to up to 4 TCSS ports on MTL.
398 * Even numbered bits (0, 2, 4, 6) control the retimer being handled by SOC.
399 * Odd numbered bits (1, 3, 5, 7) control the orientation of the physical aux lines
400 * on the motherboard.
401 */
402 uint16_t tcss_aux_ori;
403
404 /* Connect Topology Command timeout value */
405 uint16_t itbt_connect_topology_timeout_in_ms;
406
407 /*
408 * Override GPIO PM configuration:
409 * 0: Use FSP default GPIO PM program,
410 * 1: coreboot to override GPIO PM program
411 */
412 uint8_t gpio_override_pm;
413
414 /*
415 * GPIO PM configuration: 0 to disable, 1 to enable power gating
416 * Bit 6-7: Reserved
417 * Bit 5: MISCCFG_GPSIDEDPCGEN
418 * Bit 4: MISCCFG_GPRCOMPCDLCGEN
419 * Bit 3: MISCCFG_GPRTCDLCGEN
420 * Bit 2: MISCCFG_GSXLCGEN
421 * Bit 1: MISCCFG_GPDPCGEN
422 * Bit 0: MISCCFG_GPDLCGEN
423 */
424 uint8_t gpio_pm[TOTAL_GPIO_COMM];
425
426 /* DP config */
427 /*
428 * Port config
429 * 0:Disabled, 1:eDP, 2:MIPI DSI
430 */
431 uint8_t ddi_port_A_config;
432 uint8_t ddi_port_B_config;
433
434 /* Enable(1)/Disable(0) HPD/DDC */
435 uint8_t ddi_ports_config[DDI_PORT_COUNT];
436
437 /*
438 * Override CPU flex ratio value:
439 * CPU ratio value controls the maximum processor non-turbo ratio.
440 * Valid Range 0 to 63.
441 *
442 * In general descriptor provides option to set default cpu flex ratio.
443 * Default cpu flex ratio is 0 ensures booting with non-turbo max frequency.
444 * That's the reason FSP skips cpu_ratio override if cpu_ratio is 0.
445 *
446 * Only override CPU flex ratio if don't want to boot with non-turbo max.
447 */
448 uint8_t cpu_ratio_override;
449
450 /*
451 * Enable(true)/Disable(false) DMI Power Optimizer on PCH side.
452 * Default false. Setting this to true disables the DMI Power Optimizer.
453 */
454 bool dmi_pwr_optimize_disable;
455
456 /*
457 * Enable(true)/Disable(false) CPU Replacement check.
458 * Default false. Setting this to true to check CPU replacement.
459 */
460 bool cpu_replacement_check;
461
462 enum {
463 SLP_S3_ASSERTION_DEFAULT,
464 SLP_S3_ASSERTION_60_US,
465 SLP_S3_ASSERTION_1_MS,
466 SLP_S3_ASSERTION_50_MS,
467 SLP_S3_ASSERTION_2_S,
468 } pch_slp_s3_min_assertion_width;
469
470 enum {
471 SLP_S4_ASSERTION_DEFAULT,
472 SLP_S4_ASSERTION_1S,
473 SLP_S4_ASSERTION_2S,
474 SLP_S4_ASSERTION_3S,
475 SLP_S4_ASSERTION_4S,
476 } pch_slp_s4_min_assertion_width;
477
478 enum {
479 SLP_SUS_ASSERTION_DEFAULT,
480 SLP_SUS_ASSERTION_0_MS,
481 SLP_SUS_ASSERTION_500_MS,
482 SLP_SUS_ASSERTION_1_S,
483 SLP_SUS_ASSERTION_4_S,
484 } pch_slp_sus_min_assertion_width;
485
486 enum {
487 SLP_A_ASSERTION_DEFAULT,
488 SLP_A_ASSERTION_0_MS,
489 SLP_A_ASSERTION_4_S,
490 SLP_A_ASSERTION_98_MS,
491 SLP_A_ASSERTION_2_S,
492 } pch_slp_a_min_assertion_width;
493
494 /*
495 * PCH PM Reset Power Cycle Duration
496 * NOTE: Duration programmed in the PchPmPwrCycDur should never be smaller than the
497 * stretch duration programmed in the following registers:
498 * - GEN_PMCON_A.SLP_S3_MIN_ASST_WDTH (PchPmSlpS3MinAssert)
499 * - GEN_PMCON_A.S4MAW (PchPmSlpS4MinAssert)
500 * - PM_CFG.SLP_A_MIN_ASST_WDTH (PchPmSlpAMinAssert)
501 * - PM_CFG.SLP_LAN_MIN_ASST_WDTH
502 */
503 enum {
504 POWER_CYCLE_DURATION_DEFAULT,
505 POWER_CYCLE_DURATION_1S,
506 POWER_CYCLE_DURATION_2S,
507 POWER_CYCLE_DURATION_3S,
508 POWER_CYCLE_DURATION_4S,
509 } pch_reset_power_cycle_duration;
510
511 /* ISA Serial Base selection. */
512 enum {
513 ISA_SERIAL_BASE_ADDR_3F8,
514 ISA_SERIAL_BASE_ADDR_2F8,
515 } isa_serial_uart_base;
516
517 /*
518 * Assign clock source port for GbE. 0: Disable, N-1: port number
519 * Default 0.
520 */
521 uint8_t lan_clk;
522
523 /*
524 * Enable or Disable C1 C-state Auto Demotion & un-demotion
525 * The algorithm looks at the behavior of the wake up tracker, how
526 * often it is waking up, and based on that it demote the c-state.
527 * Default false. Set this to true in order to disable C1-state auto
528 * demotion.
529 * NOTE: Un-Demotion from Demoted C1 needs to be disabled when
530 * C1 C-state Auto Demotion is disabled.
531 */
532 bool disable_c1_state_auto_demotion;
533
534 /*
535 * Enable or Disable Package C-state Demotion.
536 * Default is set to false.
537 * Set this to true in order to disable Package C-state demotion.
538 * NOTE: Un-Demotion from demoted Package C-state needs to be disabled
539 * when auto demotion is disabled.
540 */
541 bool disable_package_c_state_demotion;
542
543 /* Enable PCH to CPU energy report feature. */
544 bool pch_pm_energy_report_enable;
545
546 /* Energy-Performance Preference (HWP feature) */
547 bool enable_energy_perf_pref;
548 uint8_t energy_perf_pref_value;
549
550 bool disable_vmx;
551
552 /*
553 * SAGV Frequency per point in Mhz. 0 is Auto, otherwise holds the
554 * frequency value expressed as an integer. For example: 1867
555 */
556 uint16_t sagv_freq_mhz[MAX_SAGV_POINTS];
557
558 /* Gear Selection for SAGV points. 0: Auto, 1: Gear 1, 2: Gear 2, 4: Gear 4 */
559 uint8_t sagv_gear[MAX_SAGV_POINTS];
560
561 /*
562 * Enable or Disable Reduced BasicMemoryTest size.
563 * Default is set to false.
564 * Set this to true in order to reduce BasicMemoryTest size
565 */
566 bool lower_basic_mem_test_size;
567
568 /* Platform Power Pmax in Watts. Zero means automatic. */
569 uint16_t psys_pmax_watts;
570
571 /* Platform Power Limit 2 in Watts. */
572 uint16_t psys_pl2_watts;
573
574 /* Enable or Disable Acoustic Noise Mitigation feature */
575 bool enable_acoustic_noise_mitigation;
576 /* Disable Fast Slew Rate for Deep Package C States for VR domains */
577 bool disable_fast_pkgc_ramp[NUM_VR_DOMAINS];
578 /*
579 * Slew Rate configuration for Deep Package C States for VR domains
580 * as per `enum slew_rate` data type.
581 */
582 uint8_t slow_slew_rate_config[NUM_VR_DOMAINS];
583
584 /* i915 struct for GMA backlight control */
585 struct i915_gpu_controller_info gfx;
586 };
587
588 typedef struct soc_intel_meteorlake_config config_t;
589
590 #endif