Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Subrata Banik | a4b11e5c | 2017-02-03 18:57:49 +0530 | [diff] [blame] | 4 | * Copyright (C) 2016-2017 Intel Corporation. |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 14 | */ |
| 15 | |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 16 | #include <chip.h> |
Duncan Laurie | 7d48410 | 2017-01-09 22:23:39 -0800 | [diff] [blame] | 17 | #include <bootmode.h> |
Rizwan Qureshi | 1222a73 | 2016-08-23 14:31:23 +0530 | [diff] [blame] | 18 | #include <bootstate.h> |
| 19 | #include <device/pci.h> |
| 20 | #include <fsp/api.h> |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 21 | #include <arch/acpi.h> |
| 22 | #include <chip.h> |
| 23 | #include <bootstate.h> |
| 24 | #include <console/console.h> |
| 25 | #include <device/device.h> |
| 26 | #include <device/pci.h> |
| 27 | #include <fsp/api.h> |
| 28 | #include <fsp/util.h> |
Brandon Breitenstein | c6ec8dd | 2016-11-17 12:23:04 -0800 | [diff] [blame] | 29 | #include <romstage_handoff.h> |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 30 | #include <soc/acpi.h> |
| 31 | #include <soc/interrupt.h> |
| 32 | #include <soc/irq.h> |
| 33 | #include <soc/pci_devs.h> |
| 34 | #include <soc/ramstage.h> |
| 35 | #include <string.h> |
| 36 | |
| 37 | void soc_init_pre_device(void *chip_info) |
| 38 | { |
| 39 | /* Perform silicon specific init. */ |
Aaron Durbin | 6c191d8 | 2016-11-29 21:22:42 -0600 | [diff] [blame] | 40 | fsp_silicon_init(romstage_handoff_is_resume()); |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 41 | } |
| 42 | |
Furquan Shaikh | c248044 | 2017-02-20 13:41:56 -0800 | [diff] [blame] | 43 | void soc_fsp_load(void) |
| 44 | { |
| 45 | fsps_load(romstage_handoff_is_resume()); |
| 46 | } |
| 47 | |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 48 | static void pci_domain_set_resources(device_t dev) |
| 49 | { |
| 50 | assign_resources(dev->link_list); |
| 51 | } |
| 52 | |
| 53 | static struct device_operations pci_domain_ops = { |
| 54 | .read_resources = &pci_domain_read_resources, |
| 55 | .set_resources = &pci_domain_set_resources, |
| 56 | .scan_bus = &pci_domain_scan_bus, |
| 57 | .ops_pci_bus = &pci_bus_default_ops, |
| 58 | #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) |
| 59 | .acpi_name = &soc_acpi_name, |
| 60 | #endif |
| 61 | }; |
| 62 | |
| 63 | static struct device_operations cpu_bus_ops = { |
| 64 | .read_resources = DEVICE_NOOP, |
| 65 | .set_resources = DEVICE_NOOP, |
| 66 | .enable_resources = DEVICE_NOOP, |
Subrata Banik | a4b11e5c | 2017-02-03 18:57:49 +0530 | [diff] [blame] | 67 | .init = DEVICE_NOOP, |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 68 | #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) |
| 69 | .acpi_fill_ssdt_generator = generate_cpu_entries, |
| 70 | #endif |
| 71 | }; |
| 72 | |
| 73 | static void soc_enable(device_t dev) |
| 74 | { |
| 75 | /* Set the operations if it is a special bus type */ |
| 76 | if (dev->path.type == DEVICE_PATH_DOMAIN) { |
| 77 | dev->ops = &pci_domain_ops; |
| 78 | } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) { |
| 79 | dev->ops = &cpu_bus_ops; |
| 80 | } else if (dev->path.type == DEVICE_PATH_PCI) { |
| 81 | /* Handle PCH device enable */ |
| 82 | if (PCI_SLOT(dev->path.pci.devfn) > SA_DEV_SLOT_IGD && |
| 83 | (dev->ops == NULL || dev->ops->enable == NULL)) { |
| 84 | pch_enable_dev(dev); |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | struct chip_operations soc_intel_skylake_ops = { |
| 90 | CHIP_NAME("Intel 6th Gen") |
| 91 | .enable_dev = &soc_enable, |
| 92 | .init = &soc_init_pre_device, |
| 93 | }; |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 94 | |
Rizwan Qureshi | 1222a73 | 2016-08-23 14:31:23 +0530 | [diff] [blame] | 95 | /* UPD parameters to be initialized before SiliconInit */ |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 96 | void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd) |
Rizwan Qureshi | 1222a73 | 2016-08-23 14:31:23 +0530 | [diff] [blame] | 97 | { |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 98 | FSP_S_CONFIG *params = &supd->FspsConfig; |
| 99 | FSP_S_TEST_CONFIG *tconfig = &supd->FspsTestConfig; |
| 100 | static struct soc_intel_skylake_config *config; |
| 101 | uintptr_t vbt_data = 0; |
| 102 | |
| 103 | int i; |
| 104 | |
| 105 | int is_s3_wakeup = acpi_is_wakeup_s3(); |
| 106 | |
| 107 | struct device *dev = SA_DEV_ROOT; |
| 108 | if (!dev || !dev->chip_info) { |
| 109 | printk(BIOS_ERR, "BUG! Could not find SOC devicetree config\n"); |
| 110 | return; |
| 111 | } |
| 112 | config = dev->chip_info; |
| 113 | |
| 114 | mainboard_silicon_init_params(params); |
| 115 | |
| 116 | /* Load VBT */ |
Duncan Laurie | 7d48410 | 2017-01-09 22:23:39 -0800 | [diff] [blame] | 117 | if (is_s3_wakeup) { |
| 118 | printk(BIOS_DEBUG, "S3 resume do not pass VBT to GOP\n"); |
| 119 | } else if (display_init_required()) { |
| 120 | /* Get VBT data */ |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 121 | vbt_data = fsp_load_vbt(); |
Duncan Laurie | 7d48410 | 2017-01-09 22:23:39 -0800 | [diff] [blame] | 122 | if (vbt_data) |
| 123 | printk(BIOS_DEBUG, "Passing VBT to GOP\n"); |
| 124 | else |
| 125 | printk(BIOS_DEBUG, "VBT not found!\n"); |
| 126 | } else { |
| 127 | printk(BIOS_DEBUG, "Not passing VBT to GOP\n"); |
| 128 | } |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 129 | params->GraphicsConfigPtr = (u32) vbt_data; |
| 130 | |
| 131 | for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) { |
| 132 | params->PortUsb20Enable[i] = |
| 133 | config->usb2_ports[i].enable; |
Subrata Banik | 2c3054c | 2016-11-22 20:21:49 +0530 | [diff] [blame] | 134 | params->Usb2OverCurrentPin[i] = |
| 135 | config->usb2_ports[i].ocpin; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 136 | params->Usb2AfePetxiset[i] = |
| 137 | config->usb2_ports[i].pre_emp_bias; |
| 138 | params->Usb2AfeTxiset[i] = |
| 139 | config->usb2_ports[i].tx_bias; |
| 140 | params->Usb2AfePredeemp[i] = |
| 141 | config->usb2_ports[i].tx_emp_enable; |
| 142 | params->Usb2AfePehalfbit[i] = |
| 143 | config->usb2_ports[i].pre_emp_bit; |
| 144 | } |
| 145 | |
| 146 | for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) { |
| 147 | params->PortUsb30Enable[i] = config->usb3_ports[i].enable; |
Subrata Banik | 2c3054c | 2016-11-22 20:21:49 +0530 | [diff] [blame] | 148 | params->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 149 | if (config->usb3_ports[i].tx_de_emp) { |
| 150 | params->Usb3HsioTxDeEmphEnable[i] = 1; |
| 151 | params->Usb3HsioTxDeEmph[i] = |
| 152 | config->usb3_ports[i].tx_de_emp; |
| 153 | } |
| 154 | if (config->usb3_ports[i].tx_downscale_amp) { |
| 155 | params->Usb3HsioTxDownscaleAmpEnable[i] = 1; |
| 156 | params->Usb3HsioTxDownscaleAmp[i] = |
| 157 | config->usb3_ports[i].tx_downscale_amp; |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | memcpy(params->SataPortsEnable, config->SataPortsEnable, |
| 162 | sizeof(params->SataPortsEnable)); |
| 163 | memcpy(params->SataPortsDevSlp, config->SataPortsDevSlp, |
| 164 | sizeof(params->SataPortsDevSlp)); |
| 165 | memcpy(params->PcieRpClkReqSupport, config->PcieRpClkReqSupport, |
| 166 | sizeof(params->PcieRpClkReqSupport)); |
| 167 | memcpy(params->PcieRpClkReqNumber, config->PcieRpClkReqNumber, |
| 168 | sizeof(params->PcieRpClkReqNumber)); |
Rizwan Qureshi | 6ab4ed4 | 2017-09-05 14:18:25 +0530 | [diff] [blame] | 169 | memcpy(params->PcieRpAdvancedErrorReporting, |
| 170 | config->PcieRpAdvancedErrorReporting, |
| 171 | sizeof(params->PcieRpAdvancedErrorReporting)); |
Rizwan Qureshi | 0393739 | 2017-09-16 01:54:20 +0530 | [diff] [blame] | 172 | memcpy(params->PcieRpLtrEnable, config->PcieRpLtrEnable, |
| 173 | sizeof(params->PcieRpLtrEnable)); |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 174 | |
Naresh G Solanki | eedf6d8 | 2016-11-16 21:27:38 +0530 | [diff] [blame] | 175 | /* disable Legacy PME */ |
| 176 | memset(params->PcieRpPmSci, 0, sizeof(params->PcieRpPmSci)); |
| 177 | |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 178 | memcpy(params->SerialIoDevMode, config->SerialIoDevMode, |
| 179 | sizeof(params->SerialIoDevMode)); |
| 180 | |
| 181 | params->PchCio2Enable = config->Cio2Enable; |
Rizwan Qureshi | c2c8a74 | 2017-01-13 22:04:11 +0530 | [diff] [blame] | 182 | params->SaImguEnable = config->SaImguEnable; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 183 | params->Heci3Enabled = config->Heci3Enabled; |
| 184 | |
| 185 | params->LogoPtr = config->LogoPtr; |
| 186 | params->LogoSize = config->LogoSize; |
| 187 | |
| 188 | params->CpuConfig.Bits.VmxEnable = config->VmxEnable; |
| 189 | |
| 190 | params->PchPmWoWlanEnable = config->PchPmWoWlanEnable; |
| 191 | params->PchPmWoWlanDeepSxEnable = config->PchPmWoWlanDeepSxEnable; |
| 192 | params->PchPmLanWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx; |
| 193 | |
| 194 | params->PchLanEnable = config->EnableLan; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 195 | params->SataSalpSupport = config->SataSalpSupport; |
| 196 | params->SsicPortEnable = config->SsicPortEnable; |
| 197 | params->ScsEmmcEnabled = config->ScsEmmcEnabled; |
| 198 | params->ScsEmmcHs400Enabled = config->ScsEmmcHs400Enabled; |
| 199 | params->ScsSdCardEnabled = config->ScsSdCardEnabled; |
| 200 | params->PchIshEnable = config->IshEnable; |
| 201 | params->PchHdaEnable = config->EnableAzalia; |
| 202 | params->PchHdaIoBufferOwnership = config->IoBufferOwnership; |
| 203 | params->PchHdaDspEnable = config->DspEnable; |
| 204 | params->XdciEnable = config->XdciEnable; |
| 205 | params->Device4Enable = config->Device4Enable; |
| 206 | params->SataEnable = config->EnableSata; |
| 207 | params->SataMode = config->SataMode; |
| 208 | tconfig->PchLockDownGlobalSmi = config->LockDownConfigGlobalSmi; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 209 | tconfig->PchLockDownRtcLock = config->LockDownConfigRtcLock; |
Barnali Sarkar | fbf1018 | 2017-08-11 18:38:38 +0530 | [diff] [blame] | 210 | /* |
| 211 | * To disable HECI, the Psf needs to be left unlocked |
| 212 | * by FSP till end of post sequence. Based on the devicetree |
| 213 | * setting, we set the appropriate PsfUnlock policy in FSP, |
| 214 | * do the changes and then lock it back in coreboot during finalize. |
| 215 | */ |
| 216 | tconfig->PchSbAccessUnlock = (config->HeciEnabled == 0) ? 1 : 0; |
Subrata Banik | c204aaa | 2017-08-17 15:49:58 +0530 | [diff] [blame] | 217 | if (config->chipset_lockdown == CHIPSET_LOCKDOWN_COREBOOT) { |
| 218 | tconfig->PchLockDownBiosInterface = 0; |
| 219 | params->PchLockDownBiosLock = 0; |
| 220 | params->PchLockDownSpiEiss = 0; |
| 221 | /* |
| 222 | * Skip Spi Flash Lockdown from inside FSP. |
| 223 | * Making this config "0" means FSP won't set the FLOCKDN bit |
| 224 | * of SPIBAR + 0x04 (i.e., Bit 15 of BIOS_HSFSTS_CTL). |
| 225 | * So, it becomes coreboot's responsibility to set this bit |
| 226 | * before end of POST for security concerns. |
| 227 | */ |
| 228 | params->SpiFlashCfgLockDown = 0; |
| 229 | } |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 230 | params->PchSubSystemVendorId = config->PchConfigSubSystemVendorId; |
| 231 | params->PchSubSystemId = config->PchConfigSubSystemId; |
| 232 | params->PchPmWolEnableOverride = config->WakeConfigWolEnableOverride; |
| 233 | params->PchPmPcieWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx; |
| 234 | params->PchPmDeepSxPol = config->PmConfigDeepSxPol; |
Duncan Laurie | 25c7d93 | 2017-02-17 17:16:43 -0800 | [diff] [blame] | 235 | params->PchPmSlpS0Enable = config->s0ix_enable; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 236 | params->PchPmSlpS3MinAssert = config->PmConfigSlpS3MinAssert; |
| 237 | params->PchPmSlpS4MinAssert = config->PmConfigSlpS4MinAssert; |
| 238 | params->PchPmSlpSusMinAssert = config->PmConfigSlpSusMinAssert; |
| 239 | params->PchPmSlpAMinAssert = config->PmConfigSlpAMinAssert; |
| 240 | params->PchPmLpcClockRun = config->PmConfigPciClockRun; |
| 241 | params->PchPmSlpStrchSusUp = config->PmConfigSlpStrchSusUp; |
| 242 | params->PchPmPwrBtnOverridePeriod = |
| 243 | config->PmConfigPwrBtnOverridePeriod; |
| 244 | params->PchPmPwrCycDur = config->PmConfigPwrCycDur; |
Rizwan Qureshi | 0da186c | 2017-02-23 14:43:39 +0530 | [diff] [blame] | 245 | |
| 246 | /* Indicate whether platform supports Voltage Margining */ |
| 247 | params->PchPmSlpS0VmEnable = config->PchPmSlpS0VmEnable; |
| 248 | |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 249 | params->PchSirqEnable = config->SerialIrqConfigSirqEnable; |
| 250 | params->PchSirqMode = config->SerialIrqConfigSirqMode; |
| 251 | |
| 252 | params->CpuConfig.Bits.SkipMpInit = config->FspSkipMpInit; |
| 253 | |
| 254 | for (i = 0; i < ARRAY_SIZE(config->i2c); i++) |
Aaron Durbin | ed14a4e | 2016-11-09 17:04:15 -0600 | [diff] [blame] | 255 | params->SerialIoI2cVoltage[i] = config->i2c_voltage[i]; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 256 | |
| 257 | for (i = 0; i < ARRAY_SIZE(config->domain_vr_config); i++) |
| 258 | fill_vr_domain_config(params, i, &config->domain_vr_config[i]); |
| 259 | |
| 260 | /* Show SPI controller if enabled in devicetree.cb */ |
| 261 | dev = dev_find_slot(0, PCH_DEVFN_SPI); |
| 262 | params->ShowSpiController = dev->enabled; |
| 263 | |
Rizwan Qureshi | 6467014 | 2016-11-23 15:25:19 +0530 | [diff] [blame] | 264 | /* |
| 265 | * Send VR specific mailbox commands: |
| 266 | * 000b - no VR specific command sent |
| 267 | * 001b - VR mailbox command specifically for the MPS IMPV8 VR |
Lee Leahy | f4c4ab9 | 2017-03-16 17:08:03 -0700 | [diff] [blame] | 268 | * will be sent |
Rizwan Qureshi | 6467014 | 2016-11-23 15:25:19 +0530 | [diff] [blame] | 269 | * 010b - VR specific command sent for PS4 exit issue |
| 270 | * 100b - VR specific command sent for MPS VR decay issue |
| 271 | */ |
| 272 | params->SendVrMbxCmd1 = config->SendVrMbxCmd; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 273 | |
Duncan Laurie | b2aac85 | 2017-03-07 19:12:02 -0800 | [diff] [blame] | 274 | /* Acoustic Noise Mitigation */ |
| 275 | params->AcousticNoiseMitigation = config->AcousticNoiseMitigation; |
| 276 | params->SlowSlewRateForIa = config->SlowSlewRateForIa; |
| 277 | params->SlowSlewRateForGt = config->SlowSlewRateForGt; |
| 278 | params->SlowSlewRateForSa = config->SlowSlewRateForSa; |
| 279 | params->FastPkgCRampDisableIa = config->FastPkgCRampDisableIa; |
| 280 | params->FastPkgCRampDisableGt = config->FastPkgCRampDisableGt; |
| 281 | params->FastPkgCRampDisableSa = config->FastPkgCRampDisableSa; |
| 282 | |
Rizwan Qureshi | ffe5810 | 2017-02-10 15:58:24 +0530 | [diff] [blame] | 283 | /* Enable PMC XRAM read */ |
| 284 | tconfig->PchPmPmcReadDisable = config->PchPmPmcReadDisable; |
| 285 | |
Subrata Banik | 6b45ee4 | 2017-05-12 11:43:57 +0530 | [diff] [blame] | 286 | /* Enable/Disable EIST */ |
| 287 | tconfig->Eist = config->eist_enable; |
| 288 | |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 289 | soc_irq_settings(params); |
Rizwan Qureshi | 1222a73 | 2016-08-23 14:31:23 +0530 | [diff] [blame] | 290 | } |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 291 | |
Rizwan Qureshi | 1222a73 | 2016-08-23 14:31:23 +0530 | [diff] [blame] | 292 | struct pci_operations soc_pci_ops = { |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 293 | .set_subsystem = &pci_dev_set_subsystem |
Rizwan Qureshi | 1222a73 | 2016-08-23 14:31:23 +0530 | [diff] [blame] | 294 | }; |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 295 | |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 296 | /* Mainboard GPIO Configuration */ |
| 297 | __attribute__((weak)) void mainboard_silicon_init_params(FSP_S_CONFIG *params) |
| 298 | { |
| 299 | printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__); |
| 300 | } |