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