| 1 |
|
| 2 |
|
| 3 |
#include <bootsplash.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <device/device.h> |
| 6 |
#include <device/pci.h> |
| 7 |
#include <drivers/usb/acpi/chip.h> |
| 8 |
#include <fsp/api.h> |
| 9 |
#include <fsp/util.h> |
| 10 |
#include <option.h> |
| 11 |
#include <intelblocks/irq.h> |
| 12 |
#include <intelblocks/lpss.h> |
| 13 |
#include <intelblocks/power_limit.h> |
| 14 |
#include <intelblocks/pmclib.h> |
| 15 |
#include <intelblocks/xdci.h> |
| 16 |
#include <intelpch/lockdown.h> |
| 17 |
#include <soc/intel/common/vbt.h> |
| 18 |
#include <soc/pci_devs.h> |
| 19 |
#include <soc/ramstage.h> |
| 20 |
#include <static.h> |
| 21 |
#include <string.h> |
| 22 |
#include <types.h> |
| 23 |
|
| 24 |
#include "chip.h" |
| 25 |
|
| 26 |
static const pci_devfn_t serial_io_dev[] = { |
| 27 |
PCH_DEVFN_I2C0, |
| 28 |
PCH_DEVFN_I2C1, |
| 29 |
PCH_DEVFN_I2C2, |
| 30 |
PCH_DEVFN_I2C3, |
| 31 |
PCH_DEVFN_I2C4, |
| 32 |
PCH_DEVFN_I2C5, |
| 33 |
PCH_DEVFN_GSPI0, |
| 34 |
PCH_DEVFN_GSPI1, |
| 35 |
PCH_DEVFN_GSPI2, |
| 36 |
PCH_DEVFN_UART0, |
| 37 |
PCH_DEVFN_UART1, |
| 38 |
PCH_DEVFN_UART2 |
| 39 |
}; |
| 40 |
|
| 41 |
static const struct slot_irq_constraints irq_constraints[] = { |
| 42 |
{ |
| 43 |
.slot = SA_DEV_SLOT_PEG, |
| 44 |
.fns = { |
| 45 |
FIXED_INT_PIRQ(SA_DEVFN_PEG0, PCI_INT_A, PIRQ_A), |
| 46 |
FIXED_INT_PIRQ(SA_DEVFN_PEG1, PCI_INT_B, PIRQ_B), |
| 47 |
FIXED_INT_PIRQ(SA_DEVFN_PEG2, PCI_INT_C, PIRQ_C), |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
FIXED_INT_PIRQ(PCI_DEVFN(SA_DEV_SLOT_PEG, 3), PCI_INT_D, PIRQ_D), |
| 54 |
}, |
| 55 |
}, |
| 56 |
{ |
| 57 |
.slot = SA_DEV_SLOT_IGD, |
| 58 |
.fns = { |
| 59 |
ANY_PIRQ(SA_DEVFN_IGD), |
| 60 |
}, |
| 61 |
}, |
| 62 |
{ |
| 63 |
.slot = SA_DEV_SLOT_TS, |
| 64 |
.fns = { |
| 65 |
ANY_PIRQ(SA_DEVFN_TS), |
| 66 |
}, |
| 67 |
}, |
| 68 |
{ |
| 69 |
.slot = SA_DEV_SLOT_IPU, |
| 70 |
.fns = { |
| 71 |
ANY_PIRQ(SA_DEVFN_IPU), |
| 72 |
}, |
| 73 |
}, |
| 74 |
{ |
| 75 |
.slot = SA_DEV_SLOT_GNA, |
| 76 |
.fns = { |
| 77 |
ANY_PIRQ(SA_DEVFN_GNA), |
| 78 |
}, |
| 79 |
}, |
| 80 |
{ |
| 81 |
.slot = PCH_DEV_SLOT_THERMAL, |
| 82 |
.fns = { |
| 83 |
ANY_PIRQ(PCH_DEVFN_THERMAL), |
| 84 |
#if !CONFIG(SOC_INTEL_CANNONLAKE_PCH_H) |
| 85 |
ANY_PIRQ(PCH_DEVFN_UFS), |
| 86 |
#endif |
| 87 |
DIRECT_IRQ(PCH_DEVFN_GSPI2), |
| 88 |
}, |
| 89 |
}, |
| 90 |
{ |
| 91 |
.slot = PCH_DEV_SLOT_ISH, |
| 92 |
.fns = { |
| 93 |
DIRECT_IRQ(PCH_DEVFN_ISH), |
| 94 |
}, |
| 95 |
}, |
| 96 |
{ |
| 97 |
.slot = PCH_DEV_SLOT_XHCI, |
| 98 |
.fns = { |
| 99 |
ANY_PIRQ(PCH_DEVFN_XHCI), |
| 100 |
ANY_PIRQ(PCH_DEVFN_USBOTG), |
| 101 |
ANY_PIRQ(PCH_DEVFN_CNViWIFI), |
| 102 |
ANY_PIRQ(PCH_DEVFN_SDCARD), |
| 103 |
}, |
| 104 |
}, |
| 105 |
{ |
| 106 |
.slot = PCH_DEV_SLOT_SIO1, |
| 107 |
.fns = { |
| 108 |
DIRECT_IRQ(PCH_DEVFN_I2C0), |
| 109 |
DIRECT_IRQ(PCH_DEVFN_I2C1), |
| 110 |
DIRECT_IRQ(PCH_DEVFN_I2C2), |
| 111 |
DIRECT_IRQ(PCH_DEVFN_I2C3), |
| 112 |
}, |
| 113 |
}, |
| 114 |
{ |
| 115 |
.slot = PCH_DEV_SLOT_CSE, |
| 116 |
.fns = { |
| 117 |
ANY_PIRQ(PCH_DEVFN_CSE), |
| 118 |
ANY_PIRQ(PCH_DEVFN_CSE_2), |
| 119 |
ANY_PIRQ(PCH_DEVFN_CSE_IDER), |
| 120 |
ANY_PIRQ(PCH_DEVFN_CSE_KT), |
| 121 |
ANY_PIRQ(PCH_DEVFN_CSE_3), |
| 122 |
ANY_PIRQ(PCH_DEVFN_CSE_4), |
| 123 |
}, |
| 124 |
}, |
| 125 |
{ |
| 126 |
.slot = PCH_DEV_SLOT_SATA, |
| 127 |
.fns = { |
| 128 |
ANY_PIRQ(PCH_DEVFN_SATA), |
| 129 |
}, |
| 130 |
}, |
| 131 |
{ |
| 132 |
.slot = PCH_DEV_SLOT_SIO2, |
| 133 |
.fns = { |
| 134 |
#if !CONFIG(SOC_INTEL_CANNONLAKE_PCH_H) |
| 135 |
DIRECT_IRQ(PCH_DEVFN_I2C4), |
| 136 |
DIRECT_IRQ(PCH_DEVFN_I2C5), |
| 137 |
#endif |
| 138 |
DIRECT_IRQ(PCH_DEVFN_UART2), |
| 139 |
}, |
| 140 |
}, |
| 141 |
#if !CONFIG(SOC_INTEL_CANNONLAKE_PCH_H) |
| 142 |
{ |
| 143 |
.slot = PCH_DEV_SLOT_STORAGE, |
| 144 |
.fns = { |
| 145 |
ANY_PIRQ(PCH_DEVFN_EMMC), |
| 146 |
}, |
| 147 |
}, |
| 148 |
#endif |
| 149 |
#if CONFIG(SOC_INTEL_CANNONLAKE_PCH_H) |
| 150 |
{ |
| 151 |
.slot = PCH_DEV_SLOT_PCIE_2, |
| 152 |
.fns = { |
| 153 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE17, PCI_INT_A, PIRQ_A), |
| 154 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE18, PCI_INT_B, PIRQ_B), |
| 155 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE19, PCI_INT_C, PIRQ_C), |
| 156 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE20, PCI_INT_D, PIRQ_D), |
| 157 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE21, PCI_INT_A, PIRQ_A), |
| 158 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE22, PCI_INT_B, PIRQ_B), |
| 159 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE23, PCI_INT_C, PIRQ_C), |
| 160 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE24, PCI_INT_D, PIRQ_D), |
| 161 |
}, |
| 162 |
}, |
| 163 |
#endif |
| 164 |
{ |
| 165 |
.slot = PCH_DEV_SLOT_PCIE, |
| 166 |
.fns = { |
| 167 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE1, PCI_INT_A, PIRQ_A), |
| 168 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE2, PCI_INT_B, PIRQ_B), |
| 169 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE3, PCI_INT_C, PIRQ_C), |
| 170 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE4, PCI_INT_D, PIRQ_D), |
| 171 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE5, PCI_INT_A, PIRQ_A), |
| 172 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE6, PCI_INT_B, PIRQ_B), |
| 173 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE7, PCI_INT_C, PIRQ_C), |
| 174 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE8, PCI_INT_D, PIRQ_D), |
| 175 |
}, |
| 176 |
}, |
| 177 |
{ |
| 178 |
.slot = PCH_DEV_SLOT_PCIE_1, |
| 179 |
.fns = { |
| 180 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE9, PCI_INT_A, PIRQ_A), |
| 181 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE10, PCI_INT_B, PIRQ_B), |
| 182 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE11, PCI_INT_C, PIRQ_C), |
| 183 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE12, PCI_INT_D, PIRQ_D), |
| 184 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE13, PCI_INT_A, PIRQ_A), |
| 185 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE14, PCI_INT_B, PIRQ_B), |
| 186 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE15, PCI_INT_C, PIRQ_C), |
| 187 |
FIXED_INT_PIRQ(PCH_DEVFN_PCIE16, PCI_INT_D, PIRQ_D), |
| 188 |
}, |
| 189 |
}, |
| 190 |
{ |
| 191 |
.slot = PCH_DEV_SLOT_SIO3, |
| 192 |
.fns = { |
| 193 |
DIRECT_IRQ(PCH_DEVFN_UART0), |
| 194 |
DIRECT_IRQ(PCH_DEVFN_UART1), |
| 195 |
DIRECT_IRQ(PCH_DEVFN_GSPI0), |
| 196 |
DIRECT_IRQ(PCH_DEVFN_GSPI1), |
| 197 |
}, |
| 198 |
}, |
| 199 |
{ |
| 200 |
.slot = PCH_DEV_SLOT_LPC, |
| 201 |
.fns = { |
| 202 |
ANY_PIRQ(PCH_DEVFN_HDA), |
| 203 |
ANY_PIRQ(PCH_DEVFN_SMBUS), |
| 204 |
ANY_PIRQ(PCH_DEVFN_GBE), |
| 205 |
FIXED_INT_ANY_PIRQ(PCH_DEVFN_TRACEHUB, PCI_INT_A) |
| 206 |
}, |
| 207 |
}, |
| 208 |
}; |
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
#define PCH_SERIAL_IO_INDEX(x) ((x) - 1) |
| 215 |
|
| 216 |
static uint8_t get_param_value(const config_t *config, uint32_t dev_offset) |
| 217 |
{ |
| 218 |
if (!is_devfn_enabled(serial_io_dev[dev_offset])) |
| 219 |
return PCH_SERIAL_IO_INDEX(PchSerialIoDisabled); |
| 220 |
|
| 221 |
if ((config->SerialIoDevMode[dev_offset] >= PchSerialIoMax) || |
| 222 |
(config->SerialIoDevMode[dev_offset] == PchSerialIoNotInitialized)) |
| 223 |
return PCH_SERIAL_IO_INDEX(PchSerialIoPci); |
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
return PCH_SERIAL_IO_INDEX(config->SerialIoDevMode[dev_offset]); |
| 229 |
} |
| 230 |
|
| 231 |
static void parse_devicetree(const config_t *config, FSP_S_CONFIG *s_cfg) |
| 232 |
{ |
| 233 |
#if CONFIG(SOC_INTEL_COMETLAKE) |
| 234 |
uint32_t dev_offset = 0; |
| 235 |
uint32_t i = 0; |
| 236 |
|
| 237 |
for (i = 0; i < CONFIG_SOC_INTEL_I2C_DEV_MAX; i++, dev_offset++) { |
| 238 |
s_cfg->SerialIoI2cMode[i] = |
| 239 |
get_param_value(config, dev_offset); |
| 240 |
} |
| 241 |
|
| 242 |
for (i = 0; i < CONFIG_SOC_INTEL_COMMON_BLOCK_GSPI_MAX; i++, |
| 243 |
dev_offset++) { |
| 244 |
s_cfg->SerialIoSpiMode[i] = |
| 245 |
get_param_value(config, dev_offset); |
| 246 |
} |
| 247 |
|
| 248 |
for (i = 0; i < SOC_INTEL_CML_UART_DEV_MAX; i++, dev_offset++) { |
| 249 |
s_cfg->SerialIoUartMode[i] = |
| 250 |
get_param_value(config, dev_offset); |
| 251 |
} |
| 252 |
#else |
| 253 |
for (int i = 0; i < ARRAY_SIZE(serial_io_dev); i++) |
| 254 |
s_cfg->SerialIoDevMode[i] = get_param_value(config, i); |
| 255 |
#endif |
| 256 |
} |
| 257 |
|
| 258 |
|
| 259 |
static void ignore_gbe_ltr(void) |
| 260 |
{ |
| 261 |
uint8_t reg8; |
| 262 |
uint8_t *pmcbase = pmc_mmio_regs(); |
| 263 |
|
| 264 |
reg8 = read8(pmcbase + LTR_IGN); |
| 265 |
reg8 |= IGN_GBE; |
| 266 |
write8(pmcbase + LTR_IGN, reg8); |
| 267 |
} |
| 268 |
|
| 269 |
static void configure_gspi_cs(int idx, const config_t *config, |
| 270 |
uint8_t *polarity, uint8_t *enable, |
| 271 |
uint8_t *defaultcs) |
| 272 |
{ |
| 273 |
struct spi_cfg cfg; |
| 274 |
|
| 275 |
|
| 276 |
if (config->common_soc_config.gspi[idx].speed_mhz != 0) { |
| 277 |
if (gspi_get_soc_spi_cfg(idx, &cfg) == 0) { |
| 278 |
if (cfg.cs_polarity == SPI_POLARITY_LOW) |
| 279 |
*polarity = 0; |
| 280 |
else |
| 281 |
*polarity = 1; |
| 282 |
|
| 283 |
if (defaultcs != NULL) |
| 284 |
*defaultcs = 0; |
| 285 |
if (enable != NULL) |
| 286 |
*enable = 1; |
| 287 |
} |
| 288 |
} |
| 289 |
} |
| 290 |
|
| 291 |
static const SI_PCH_DEVICE_INTERRUPT_CONFIG *pci_irq_to_fsp(size_t *out_count) |
| 292 |
{ |
| 293 |
const struct pci_irq_entry *entry = get_cached_pci_irqs(); |
| 294 |
SI_PCH_DEVICE_INTERRUPT_CONFIG *config; |
| 295 |
size_t pch_total = 0; |
| 296 |
size_t cfg_count = 0; |
| 297 |
|
| 298 |
if (!entry) |
| 299 |
return NULL; |
| 300 |
|
| 301 |
|
| 302 |
while (entry) { |
| 303 |
if (is_pch_slot(entry->devfn)) |
| 304 |
++pch_total; |
| 305 |
entry = entry->next; |
| 306 |
} |
| 307 |
|
| 308 |
|
| 309 |
config = calloc(pch_total, sizeof(*config)); |
| 310 |
entry = get_cached_pci_irqs(); |
| 311 |
while (entry) { |
| 312 |
if (!is_pch_slot(entry->devfn)) { |
| 313 |
entry = entry->next; |
| 314 |
continue; |
| 315 |
} |
| 316 |
|
| 317 |
config[cfg_count].Device = PCI_SLOT(entry->devfn); |
| 318 |
config[cfg_count].Function = PCI_FUNC(entry->devfn); |
| 319 |
config[cfg_count].IntX = (SI_PCH_INT_PIN)entry->pin; |
| 320 |
config[cfg_count].Irq = entry->irq; |
| 321 |
++cfg_count; |
| 322 |
|
| 323 |
entry = entry->next; |
| 324 |
} |
| 325 |
|
| 326 |
*out_count = cfg_count; |
| 327 |
|
| 328 |
return config; |
| 329 |
} |
| 330 |
|
| 331 |
|
| 332 |
void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd) |
| 333 |
{ |
| 334 |
int i; |
| 335 |
FSP_S_CONFIG *s_cfg = &supd->FspsConfig; |
| 336 |
FSP_S_TEST_CONFIG *tconfig = &supd->FspsTestConfig; |
| 337 |
struct device *dev; |
| 338 |
|
| 339 |
config_t *config = config_of_soc(); |
| 340 |
|
| 341 |
|
| 342 |
parse_devicetree(config, s_cfg); |
| 343 |
|
| 344 |
|
| 345 |
s_cfg->GraphicsConfigPtr = (uintptr_t)vbt_get(); |
| 346 |
|
| 347 |
mainboard_silicon_init_params(supd); |
| 348 |
|
| 349 |
const struct soc_power_limits_config *soc_config; |
| 350 |
soc_config = &config->power_limits_config; |
| 351 |
|
| 352 |
if (soc_config->psys_pmax) { |
| 353 |
printk(BIOS_DEBUG, "psys_pmax = %dW\n", soc_config->psys_pmax); |
| 354 |
|
| 355 |
tconfig->PsysPmax = soc_config->psys_pmax * 8; |
| 356 |
} |
| 357 |
|
| 358 |
|
| 359 |
s_cfg->PchLockDownRtcMemoryLock = 0; |
| 360 |
|
| 361 |
|
| 362 |
s_cfg->SataEnable = is_devfn_enabled(PCH_DEVFN_SATA); |
| 363 |
if (s_cfg->SataEnable) { |
| 364 |
s_cfg->SataMode = config->SataMode; |
| 365 |
s_cfg->SataPwrOptEnable = config->satapwroptimize; |
| 366 |
s_cfg->SataSalpSupport = config->SataSalpSupport; |
| 367 |
memcpy(s_cfg->SataPortsEnable, config->SataPortsEnable, |
| 368 |
sizeof(s_cfg->SataPortsEnable)); |
| 369 |
memcpy(s_cfg->SataPortsDevSlp, config->SataPortsDevSlp, |
| 370 |
sizeof(s_cfg->SataPortsDevSlp)); |
| 371 |
memcpy(s_cfg->SataPortsHotPlug, config->SataPortsHotPlug, |
| 372 |
sizeof(s_cfg->SataPortsHotPlug)); |
| 373 |
#if CONFIG(SOC_INTEL_COMETLAKE) |
| 374 |
memcpy(s_cfg->SataPortsDevSlpResetConfig, |
| 375 |
config->SataPortsDevSlpResetConfig, |
| 376 |
sizeof(s_cfg->SataPortsDevSlpResetConfig)); |
| 377 |
#endif |
| 378 |
} |
| 379 |
s_cfg->SlpS0WithGbeSupport = 0; |
| 380 |
s_cfg->PchPmSlpS0VmRuntimeControl = config->PchPmSlpS0VmRuntimeControl; |
| 381 |
s_cfg->PchPmSlpS0Vm070VSupport = config->PchPmSlpS0Vm070VSupport; |
| 382 |
s_cfg->PchPmSlpS0Vm075VSupport = config->PchPmSlpS0Vm075VSupport; |
| 383 |
|
| 384 |
|
| 385 |
config->s0ix_enable = get_uint_option("s0ix_enable", config->s0ix_enable); |
| 386 |
s_cfg->PchPmSlpS0Enable = config->s0ix_enable; |
| 387 |
|
| 388 |
|
| 389 |
s_cfg->PchLanEnable = is_devfn_enabled(PCH_DEVFN_GBE); |
| 390 |
if (s_cfg->PchLanEnable) { |
| 391 |
if (config->s0ix_enable) { |
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
s_cfg->SlpS0WithGbeSupport = 1; |
| 400 |
s_cfg->PchPmSlpS0VmRuntimeControl = 0; |
| 401 |
s_cfg->PchPmSlpS0Vm070VSupport = 0; |
| 402 |
s_cfg->PchPmSlpS0Vm075VSupport = 0; |
| 403 |
ignore_gbe_ltr(); |
| 404 |
} |
| 405 |
} |
| 406 |
|
| 407 |
|
| 408 |
s_cfg->PchHdaDspEnable = config->PchHdaDspEnable; |
| 409 |
s_cfg->PchHdaIDispCodecDisconnect = config->PchHdaIDispCodecDisconnect; |
| 410 |
s_cfg->PchHdaAudioLinkHda = config->PchHdaAudioLinkHda; |
| 411 |
s_cfg->PchHdaAudioLinkDmic0 = config->PchHdaAudioLinkDmic0; |
| 412 |
s_cfg->PchHdaAudioLinkDmic1 = config->PchHdaAudioLinkDmic1; |
| 413 |
s_cfg->PchHdaAudioLinkSsp0 = config->PchHdaAudioLinkSsp0; |
| 414 |
s_cfg->PchHdaAudioLinkSsp1 = config->PchHdaAudioLinkSsp1; |
| 415 |
s_cfg->PchHdaAudioLinkSsp2 = config->PchHdaAudioLinkSsp2; |
| 416 |
s_cfg->PchHdaAudioLinkSndw1 = config->PchHdaAudioLinkSndw1; |
| 417 |
s_cfg->PchHdaAudioLinkSndw2 = config->PchHdaAudioLinkSndw2; |
| 418 |
s_cfg->PchHdaAudioLinkSndw3 = config->PchHdaAudioLinkSndw3; |
| 419 |
s_cfg->PchHdaAudioLinkSndw4 = config->PchHdaAudioLinkSndw4; |
| 420 |
|
| 421 |
|
| 422 |
s_cfg->DdiPortEdp = config->DdiPortEdp; |
| 423 |
|
| 424 |
|
| 425 |
s_cfg->DdiPortBHpd = config->DdiPortBHpd; |
| 426 |
s_cfg->DdiPortCHpd = config->DdiPortCHpd; |
| 427 |
s_cfg->DdiPortDHpd = config->DdiPortDHpd; |
| 428 |
s_cfg->DdiPortFHpd = config->DdiPortFHpd; |
| 429 |
|
| 430 |
|
| 431 |
s_cfg->DdiPortBDdc = config->DdiPortBDdc; |
| 432 |
s_cfg->DdiPortCDdc = config->DdiPortCDdc; |
| 433 |
s_cfg->DdiPortDDdc = config->DdiPortDDdc; |
| 434 |
s_cfg->DdiPortFDdc = config->DdiPortFDdc; |
| 435 |
|
| 436 |
|
| 437 |
s_cfg->PchPmPcieWakeFromDeepSx = config->LanWakeFromDeepSx; |
| 438 |
s_cfg->PchPmWolEnableOverride = config->WolEnableOverride; |
| 439 |
|
| 440 |
|
| 441 |
memset(s_cfg->PcieRpPmSci, 0, sizeof(s_cfg->PcieRpPmSci)); |
| 442 |
|
| 443 |
|
| 444 |
bool use_8254 = get_uint_option("legacy_8254_timer", CONFIG(USE_LEGACY_8254_TIMER)); |
| 445 |
s_cfg->Enable8254ClockGating = !use_8254; |
| 446 |
s_cfg->Enable8254ClockGatingOnS3 = !use_8254; |
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
s_cfg->EnableTcoTimer = 1; |
| 456 |
|
| 457 |
|
| 458 |
for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) { |
| 459 |
s_cfg->PortUsb20Enable[i] = config->usb2_ports[i].enable; |
| 460 |
s_cfg->Usb2AfePetxiset[i] = config->usb2_ports[i].pre_emp_bias; |
| 461 |
s_cfg->Usb2AfeTxiset[i] = config->usb2_ports[i].tx_bias; |
| 462 |
s_cfg->Usb2AfePredeemp[i] = |
| 463 |
config->usb2_ports[i].tx_emp_enable; |
| 464 |
s_cfg->Usb2AfePehalfbit[i] = config->usb2_ports[i].pre_emp_bit; |
| 465 |
|
| 466 |
if (config->usb2_ports[i].enable) |
| 467 |
s_cfg->Usb2OverCurrentPin[i] = config->usb2_ports[i].ocpin; |
| 468 |
else |
| 469 |
s_cfg->Usb2OverCurrentPin[i] = 0xff; |
| 470 |
} |
| 471 |
|
| 472 |
if (config->PchUsb2PhySusPgDisable) |
| 473 |
s_cfg->PchUsb2PhySusPgEnable = 0; |
| 474 |
|
| 475 |
for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) { |
| 476 |
s_cfg->PortUsb30Enable[i] = config->usb3_ports[i].enable; |
| 477 |
if (config->usb3_ports[i].enable) { |
| 478 |
s_cfg->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin; |
| 479 |
} else { |
| 480 |
s_cfg->Usb3OverCurrentPin[i] = 0xff; |
| 481 |
} |
| 482 |
if (config->usb3_ports[i].tx_de_emp) { |
| 483 |
s_cfg->Usb3HsioTxDeEmphEnable[i] = 1; |
| 484 |
s_cfg->Usb3HsioTxDeEmph[i] = |
| 485 |
config->usb3_ports[i].tx_de_emp; |
| 486 |
} |
| 487 |
if (config->usb3_ports[i].tx_downscale_amp) { |
| 488 |
s_cfg->Usb3HsioTxDownscaleAmpEnable[i] = 1; |
| 489 |
s_cfg->Usb3HsioTxDownscaleAmp[i] = |
| 490 |
config->usb3_ports[i].tx_downscale_amp; |
| 491 |
} |
| 492 |
#if CONFIG(SOC_INTEL_COMETLAKE) |
| 493 |
if (config->usb3_ports[i].gen2_tx_rate0_uniq_tran_enable) { |
| 494 |
s_cfg->Usb3HsioTxRate0UniqTranEnable[i] = 1; |
| 495 |
s_cfg->Usb3HsioTxRate0UniqTran[i] = |
| 496 |
config->usb3_ports[i].gen2_tx_rate0_uniq_tran; |
| 497 |
} |
| 498 |
if (config->usb3_ports[i].gen2_tx_rate1_uniq_tran_enable) { |
| 499 |
s_cfg->Usb3HsioTxRate1UniqTranEnable[i] = 1; |
| 500 |
s_cfg->Usb3HsioTxRate1UniqTran[i] = |
| 501 |
config->usb3_ports[i].gen2_tx_rate1_uniq_tran; |
| 502 |
} |
| 503 |
if (config->usb3_ports[i].gen2_tx_rate2_uniq_tran_enable) { |
| 504 |
s_cfg->Usb3HsioTxRate2UniqTranEnable[i] = 1; |
| 505 |
s_cfg->Usb3HsioTxRate2UniqTran[i] = |
| 506 |
config->usb3_ports[i].gen2_tx_rate2_uniq_tran; |
| 507 |
} |
| 508 |
if (config->usb3_ports[i].gen2_tx_rate3_uniq_tran_enable) { |
| 509 |
s_cfg->Usb3HsioTxRate3UniqTranEnable[i] = 1; |
| 510 |
s_cfg->Usb3HsioTxRate3UniqTran[i] = |
| 511 |
config->usb3_ports[i].gen2_tx_rate3_uniq_tran; |
| 512 |
} |
| 513 |
#endif |
| 514 |
if (config->usb3_ports[i].gen2_rx_tuning_enable) { |
| 515 |
s_cfg->PchUsbHsioRxTuningEnable[i] = |
| 516 |
config->usb3_ports[i].gen2_rx_tuning_enable; |
| 517 |
s_cfg->PchUsbHsioRxTuningParameters[i] = |
| 518 |
config->usb3_ports[i].gen2_rx_tuning_params; |
| 519 |
s_cfg->PchUsbHsioFilterSel[i] = |
| 520 |
config->usb3_ports[i].gen2_rx_filter_sel; |
| 521 |
} |
| 522 |
} |
| 523 |
|
| 524 |
s_cfg->XdciEnable = xdci_can_enable(PCH_DEVFN_USBOTG); |
| 525 |
|
| 526 |
|
| 527 |
s_cfg->SerialIoDebugUartNumber = CONFIG_UART_FOR_CONSOLE; |
| 528 |
#if !CONFIG(SOC_INTEL_COMETLAKE) |
| 529 |
s_cfg->SerialIoEnableDebugUartAfterPost = CONFIG(INTEL_LPSS_UART_FOR_CONSOLE); |
| 530 |
#endif |
| 531 |
|
| 532 |
|
| 533 |
#if CONFIG(SOC_INTEL_COMETLAKE) |
| 534 |
struct device *port = NULL; |
| 535 |
struct drivers_usb_acpi_config *usb_cfg = NULL; |
| 536 |
bool usb_audio_offload = false; |
| 537 |
|
| 538 |
|
| 539 |
while ((port = dev_find_path(port, DEVICE_PATH_USB)) != NULL) { |
| 540 |
|
| 541 |
if (!port->enabled || port->path.type != DEVICE_PATH_USB) |
| 542 |
continue; |
| 543 |
|
| 544 |
usb_cfg = port->chip_info; |
| 545 |
if (usb_cfg && usb_cfg->cnvi_bt_audio_offload) { |
| 546 |
usb_audio_offload = true; |
| 547 |
break; |
| 548 |
} |
| 549 |
} |
| 550 |
|
| 551 |
|
| 552 |
s_cfg->CnviMode = is_devfn_enabled(PCH_DEVFN_CNViWIFI); |
| 553 |
s_cfg->CnviBtCore = config->CnviBtCore; |
| 554 |
s_cfg->CnviBtAudioOffload = config->CnviBtAudioOffload; |
| 555 |
|
| 556 |
if (!s_cfg->CnviBtCore && s_cfg->CnviBtAudioOffload) { |
| 557 |
printk(BIOS_ERR, "BT offload is enabled without CNVi BT being enabled\n"); |
| 558 |
s_cfg->CnviBtAudioOffload = 0; |
| 559 |
} |
| 560 |
if (!s_cfg->CnviMode && s_cfg->CnviBtCore) { |
| 561 |
printk(BIOS_ERR, "CNVi BT is enabled without CNVi being enabled\n"); |
| 562 |
s_cfg->CnviBtCore = 0; |
| 563 |
s_cfg->CnviBtAudioOffload = 0; |
| 564 |
} |
| 565 |
if (s_cfg->CnviBtAudioOffload && !usb_audio_offload) { |
| 566 |
printk(BIOS_WARNING, "CNVi BT Audio offload enabled but not in USB driver.\n"); |
| 567 |
} |
| 568 |
if (!s_cfg->CnviBtAudioOffload && usb_cfg && usb_audio_offload) { |
| 569 |
printk(BIOS_ERR, "USB BT Audio offload enabled but CNVi BT offload disabled\n"); |
| 570 |
usb_cfg->cnvi_bt_audio_offload = 0; |
| 571 |
} |
| 572 |
#else |
| 573 |
s_cfg->PchCnviMode = is_devfn_enabled(PCH_DEVFN_CNViWIFI); |
| 574 |
#endif |
| 575 |
|
| 576 |
for (i = 0; i < ARRAY_SIZE(config->PcieClkSrcUsage); i++) { |
| 577 |
if (config->PcieClkSrcUsage[i] == 0) |
| 578 |
config->PcieClkSrcUsage[i] = PCIE_CLK_NOTUSED; |
| 579 |
else if (config->PcieClkSrcUsage[i] == PCIE_CLK_RP0) |
| 580 |
config->PcieClkSrcUsage[i] = 0; |
| 581 |
} |
| 582 |
memcpy(s_cfg->PcieClkSrcUsage, config->PcieClkSrcUsage, |
| 583 |
sizeof(config->PcieClkSrcUsage)); |
| 584 |
memcpy(s_cfg->PcieClkSrcClkReq, config->PcieClkSrcClkReq, |
| 585 |
sizeof(config->PcieClkSrcClkReq)); |
| 586 |
|
| 587 |
memcpy(s_cfg->PcieRpAdvancedErrorReporting, |
| 588 |
config->PcieRpAdvancedErrorReporting, |
| 589 |
sizeof(config->PcieRpAdvancedErrorReporting)); |
| 590 |
|
| 591 |
memcpy(s_cfg->PcieRpLtrEnable, config->PcieRpLtrEnable, |
| 592 |
sizeof(config->PcieRpLtrEnable)); |
| 593 |
memcpy(s_cfg->PcieRpSlotImplemented, config->PcieRpSlotImplemented, |
| 594 |
sizeof(config->PcieRpSlotImplemented)); |
| 595 |
memcpy(s_cfg->PcieRpHotPlug, config->PcieRpHotPlug, |
| 596 |
sizeof(config->PcieRpHotPlug)); |
| 597 |
|
| 598 |
for (i = 0; i < CONFIG_MAX_ROOT_PORTS; i++) { |
| 599 |
s_cfg->PcieRpMaxPayload[i] = config->PcieRpMaxPayload[i]; |
| 600 |
if (config->PcieRpAspm[i]) |
| 601 |
s_cfg->PcieRpAspm[i] = config->PcieRpAspm[i] - 1; |
| 602 |
}; |
| 603 |
|
| 604 |
|
| 605 |
s_cfg->ScsEmmcEnabled = is_devfn_enabled(PCH_DEVFN_EMMC); |
| 606 |
if (s_cfg->ScsEmmcEnabled) { |
| 607 |
s_cfg->ScsEmmcHs400Enabled = config->ScsEmmcHs400Enabled; |
| 608 |
s_cfg->PchScsEmmcHs400DllDataValid = config->EmmcHs400DllNeed; |
| 609 |
if (config->EmmcHs400DllNeed == 1) { |
| 610 |
s_cfg->PchScsEmmcHs400RxStrobeDll1 = |
| 611 |
config->EmmcHs400RxStrobeDll1; |
| 612 |
s_cfg->PchScsEmmcHs400TxDataDll = |
| 613 |
config->EmmcHs400TxDataDll; |
| 614 |
} |
| 615 |
} |
| 616 |
|
| 617 |
s_cfg->ScsSdCardEnabled = is_devfn_enabled(PCH_DEVFN_SDCARD); |
| 618 |
if (s_cfg->ScsSdCardEnabled) { |
| 619 |
s_cfg->SdCardPowerEnableActiveHigh = CONFIG(MB_HAS_ACTIVE_HIGH_SD_PWR_ENABLE); |
| 620 |
#if CONFIG(SOC_INTEL_COMETLAKE) |
| 621 |
s_cfg->ScsSdCardWpPinEnabled = config->ScsSdCardWpPinEnabled; |
| 622 |
#endif |
| 623 |
} |
| 624 |
|
| 625 |
s_cfg->ScsUfsEnabled = is_devfn_enabled(PCH_DEVFN_UFS); |
| 626 |
|
| 627 |
s_cfg->Heci3Enabled = is_devfn_enabled(PCH_DEVFN_CSE_3); |
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
s_cfg->Heci1Disabled = 0; |
| 634 |
s_cfg->Device4Enable = is_devfn_enabled(SA_DEVFN_TS); |
| 635 |
|
| 636 |
|
| 637 |
s_cfg->TetonGlacierMode = config->TetonGlacierMode; |
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
for (i = 0; i < ARRAY_SIZE(config->domain_vr_config); i++) |
| 643 |
fill_vr_domain_config(s_cfg, i, &config->domain_vr_config[i]); |
| 644 |
|
| 645 |
|
| 646 |
s_cfg->AcousticNoiseMitigation = config->AcousticNoiseMitigation; |
| 647 |
s_cfg->SlowSlewRateForIa = config->SlowSlewRateForIa; |
| 648 |
s_cfg->SlowSlewRateForGt = config->SlowSlewRateForGt; |
| 649 |
s_cfg->SlowSlewRateForSa = config->SlowSlewRateForSa; |
| 650 |
s_cfg->SlowSlewRateForFivr = config->SlowSlewRateForFivr; |
| 651 |
s_cfg->FastPkgCRampDisableIa = config->FastPkgCRampDisableIa; |
| 652 |
s_cfg->FastPkgCRampDisableGt = config->FastPkgCRampDisableGt; |
| 653 |
s_cfg->FastPkgCRampDisableSa = config->FastPkgCRampDisableSa; |
| 654 |
s_cfg->FastPkgCRampDisableFivr = config->FastPkgCRampDisableFivr; |
| 655 |
|
| 656 |
|
| 657 |
if (config->PchPmSlpS3MinAssert) |
| 658 |
s_cfg->PchPmSlpS3MinAssert = config->PchPmSlpS3MinAssert; |
| 659 |
if (config->PchPmSlpS4MinAssert) |
| 660 |
s_cfg->PchPmSlpS4MinAssert = config->PchPmSlpS4MinAssert; |
| 661 |
if (config->PchPmSlpSusMinAssert) |
| 662 |
s_cfg->PchPmSlpSusMinAssert = config->PchPmSlpSusMinAssert; |
| 663 |
if (config->PchPmSlpAMinAssert) |
| 664 |
s_cfg->PchPmSlpAMinAssert = config->PchPmSlpAMinAssert; |
| 665 |
|
| 666 |
#if CONFIG(SOC_INTEL_COMETLAKE) |
| 667 |
if (config->PchPmPwrCycDur) |
| 668 |
s_cfg->PchPmPwrCycDur = get_pm_pwr_cyc_dur(config->PchPmSlpS4MinAssert, |
| 669 |
config->PchPmSlpS3MinAssert, config->PchPmSlpAMinAssert, |
| 670 |
config->PchPmPwrCycDur); |
| 671 |
#endif |
| 672 |
|
| 673 |
|
| 674 |
tconfig->TccActivationOffset = config->tcc_offset; |
| 675 |
tconfig->TccOffsetClamp = config->tcc_offset > 0; |
| 676 |
|
| 677 |
|
| 678 |
tconfig->PchUnlockGpioPads = config->PchUnlockGpioPads; |
| 679 |
|
| 680 |
|
| 681 |
s_cfg->PchSirqEnable = config->serirq_mode != SERIRQ_OFF; |
| 682 |
s_cfg->PchSirqMode = config->serirq_mode == SERIRQ_CONTINUOUS; |
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
#if CONFIG(SOC_INTEL_COMETLAKE) |
| 690 |
configure_gspi_cs(0, config, &s_cfg->SerialIoSpi0CsPolarity[0], |
| 691 |
&s_cfg->SerialIoSpi0CsEnable[0], |
| 692 |
&s_cfg->SerialIoSpiDefaultCsOutput[0]); |
| 693 |
configure_gspi_cs(1, config, &s_cfg->SerialIoSpi1CsPolarity[0], |
| 694 |
&s_cfg->SerialIoSpi1CsEnable[0], |
| 695 |
&s_cfg->SerialIoSpiDefaultCsOutput[1]); |
| 696 |
configure_gspi_cs(2, config, &s_cfg->SerialIoSpi2CsPolarity[0], |
| 697 |
&s_cfg->SerialIoSpi2CsEnable[0], |
| 698 |
&s_cfg->SerialIoSpiDefaultCsOutput[2]); |
| 699 |
#else |
| 700 |
for (i = 0; i < CONFIG_SOC_INTEL_COMMON_BLOCK_GSPI_MAX; i++) |
| 701 |
configure_gspi_cs(i, config, |
| 702 |
&s_cfg->SerialIoSpiCsPolarity[0], NULL, NULL); |
| 703 |
#endif |
| 704 |
|
| 705 |
|
| 706 |
const bool lockdown_by_fsp = get_lockdown_config() == CHIPSET_LOCKDOWN_FSP; |
| 707 |
tconfig->PchLockDownGlobalSmi = lockdown_by_fsp; |
| 708 |
tconfig->PchLockDownBiosInterface = lockdown_by_fsp; |
| 709 |
s_cfg->PchLockDownBiosLock = lockdown_by_fsp; |
| 710 |
s_cfg->PchLockDownRtcMemoryLock = lockdown_by_fsp; |
| 711 |
tconfig->SkipPamLock = !lockdown_by_fsp; |
| 712 |
#if CONFIG(SOC_INTEL_COMETLAKE) |
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
s_cfg->SpiFlashCfgLockDown = lockdown_by_fsp; |
| 720 |
#endif |
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
supd->FspsConfig.DebugInterfaceEnable = 0; |
| 728 |
supd->FspsTestConfig.DebugInterfaceEnable = 0; |
| 729 |
supd->FspsTestConfig.DebugInterfaceLockEnable = 0; |
| 730 |
|
| 731 |
#if !CONFIG(SOC_INTEL_COMETLAKE) |
| 732 |
s_cfg->VrPowerDeliveryDesign = config->VrPowerDeliveryDesign; |
| 733 |
#endif |
| 734 |
|
| 735 |
s_cfg->PeiGraphicsPeimInit = CONFIG(RUN_FSP_GOP) && is_devfn_enabled(SA_DEVFN_IGD); |
| 736 |
|
| 737 |
s_cfg->PavpEnable = CONFIG(PAVP); |
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
|
| 744 |
struct svid_ssid_init_entry { |
| 745 |
union { |
| 746 |
struct { |
| 747 |
uint64_t reg:12; |
| 748 |
uint64_t function:3; |
| 749 |
uint64_t device:5; |
| 750 |
uint64_t bus:8; |
| 751 |
uint64_t :4; |
| 752 |
uint64_t segment:16; |
| 753 |
uint64_t :16; |
| 754 |
}; |
| 755 |
uint64_t segbusdevfuncregister; |
| 756 |
}; |
| 757 |
struct { |
| 758 |
uint16_t svid; |
| 759 |
uint16_t ssid; |
| 760 |
}; |
| 761 |
uint32_t reserved; |
| 762 |
}; |
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
|
| 769 |
const pci_devfn_t devfn_table[] = { PCH_DEVFN_XHCI, PCH_DEVFN_HDA }; |
| 770 |
static struct svid_ssid_init_entry ssid_table[ARRAY_SIZE(devfn_table)]; |
| 771 |
|
| 772 |
for (i = 0; i < ARRAY_SIZE(devfn_table); i++) { |
| 773 |
ssid_table[i].reg = PCI_SUBSYSTEM_VENDOR_ID; |
| 774 |
ssid_table[i].device = PCI_SLOT(devfn_table[i]); |
| 775 |
ssid_table[i].function = PCI_FUNC(devfn_table[i]); |
| 776 |
dev = pcidev_path_on_root(devfn_table[i]); |
| 777 |
if (dev) { |
| 778 |
ssid_table[i].svid = dev->subsystem_vendor; |
| 779 |
ssid_table[i].ssid = dev->subsystem_device; |
| 780 |
} |
| 781 |
} |
| 782 |
|
| 783 |
s_cfg->SiSsidTablePtr = (uintptr_t)ssid_table; |
| 784 |
s_cfg->SiNumberOfSsidTableEntry = ARRAY_SIZE(ssid_table); |
| 785 |
|
| 786 |
|
| 787 |
if (!assign_pci_irqs(irq_constraints, ARRAY_SIZE(irq_constraints))) |
| 788 |
die("ERROR: Unable to assign PCI IRQs, and no ACPI _PRT table is defined\n"); |
| 789 |
|
| 790 |
size_t pch_count = 0; |
| 791 |
const SI_PCH_DEVICE_INTERRUPT_CONFIG *upd_irqs = pci_irq_to_fsp(&pch_count); |
| 792 |
s_cfg->DevIntConfigPtr = (UINT32)((uintptr_t)upd_irqs); |
| 793 |
s_cfg->NumOfDevIntConfig = pch_count; |
| 794 |
printk(BIOS_INFO, "IRQ: Using dynamically assigned PCI IO-APIC IRQs\n"); |
| 795 |
} |
| 796 |
|
| 797 |
|
| 798 |
__weak void mainboard_silicon_init_params(FSPS_UPD *supd) |
| 799 |
{ |
| 800 |
printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__); |
| 801 |
} |
| 802 |
|
| 803 |
|
| 804 |
void soc_load_logo_by_fsp(FSPS_UPD *supd) |
| 805 |
{ |
| 806 |
size_t logo_size; |
| 807 |
supd->FspsConfig.LogoPtr = (uintptr_t)bmp_load_logo(&logo_size); |
| 808 |
supd->FspsConfig.LogoSize = (uint32_t)logo_size; |
| 809 |
} |