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 | |
| 43 | static void pci_domain_set_resources(device_t dev) |
| 44 | { |
| 45 | assign_resources(dev->link_list); |
| 46 | } |
| 47 | |
| 48 | static struct device_operations pci_domain_ops = { |
| 49 | .read_resources = &pci_domain_read_resources, |
| 50 | .set_resources = &pci_domain_set_resources, |
| 51 | .scan_bus = &pci_domain_scan_bus, |
| 52 | .ops_pci_bus = &pci_bus_default_ops, |
| 53 | #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) |
| 54 | .acpi_name = &soc_acpi_name, |
| 55 | #endif |
| 56 | }; |
| 57 | |
| 58 | static struct device_operations cpu_bus_ops = { |
| 59 | .read_resources = DEVICE_NOOP, |
| 60 | .set_resources = DEVICE_NOOP, |
| 61 | .enable_resources = DEVICE_NOOP, |
Subrata Banik | a4b11e5c | 2017-02-03 18:57:49 +0530 | [diff] [blame] | 62 | .init = DEVICE_NOOP, |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 63 | #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) |
| 64 | .acpi_fill_ssdt_generator = generate_cpu_entries, |
| 65 | #endif |
| 66 | }; |
| 67 | |
| 68 | static void soc_enable(device_t dev) |
| 69 | { |
| 70 | /* Set the operations if it is a special bus type */ |
| 71 | if (dev->path.type == DEVICE_PATH_DOMAIN) { |
| 72 | dev->ops = &pci_domain_ops; |
| 73 | } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) { |
| 74 | dev->ops = &cpu_bus_ops; |
| 75 | } else if (dev->path.type == DEVICE_PATH_PCI) { |
| 76 | /* Handle PCH device enable */ |
| 77 | if (PCI_SLOT(dev->path.pci.devfn) > SA_DEV_SLOT_IGD && |
| 78 | (dev->ops == NULL || dev->ops->enable == NULL)) { |
| 79 | pch_enable_dev(dev); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | struct chip_operations soc_intel_skylake_ops = { |
| 85 | CHIP_NAME("Intel 6th Gen") |
| 86 | .enable_dev = &soc_enable, |
| 87 | .init = &soc_init_pre_device, |
| 88 | }; |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 89 | |
Rizwan Qureshi | 1222a73 | 2016-08-23 14:31:23 +0530 | [diff] [blame] | 90 | /* UPD parameters to be initialized before SiliconInit */ |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 91 | void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd) |
Rizwan Qureshi | 1222a73 | 2016-08-23 14:31:23 +0530 | [diff] [blame] | 92 | { |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 93 | FSP_S_CONFIG *params = &supd->FspsConfig; |
| 94 | FSP_S_TEST_CONFIG *tconfig = &supd->FspsTestConfig; |
| 95 | static struct soc_intel_skylake_config *config; |
| 96 | uintptr_t vbt_data = 0; |
| 97 | |
| 98 | int i; |
| 99 | |
| 100 | int is_s3_wakeup = acpi_is_wakeup_s3(); |
| 101 | |
| 102 | struct device *dev = SA_DEV_ROOT; |
| 103 | if (!dev || !dev->chip_info) { |
| 104 | printk(BIOS_ERR, "BUG! Could not find SOC devicetree config\n"); |
| 105 | return; |
| 106 | } |
| 107 | config = dev->chip_info; |
| 108 | |
| 109 | mainboard_silicon_init_params(params); |
| 110 | |
| 111 | /* Load VBT */ |
Duncan Laurie | 7d48410 | 2017-01-09 22:23:39 -0800 | [diff] [blame] | 112 | if (is_s3_wakeup) { |
| 113 | printk(BIOS_DEBUG, "S3 resume do not pass VBT to GOP\n"); |
| 114 | } else if (display_init_required()) { |
| 115 | /* Get VBT data */ |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 116 | vbt_data = fsp_load_vbt(); |
Duncan Laurie | 7d48410 | 2017-01-09 22:23:39 -0800 | [diff] [blame] | 117 | if (vbt_data) |
| 118 | printk(BIOS_DEBUG, "Passing VBT to GOP\n"); |
| 119 | else |
| 120 | printk(BIOS_DEBUG, "VBT not found!\n"); |
| 121 | } else { |
| 122 | printk(BIOS_DEBUG, "Not passing VBT to GOP\n"); |
| 123 | } |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 124 | params->GraphicsConfigPtr = (u32) vbt_data; |
| 125 | |
| 126 | for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) { |
| 127 | params->PortUsb20Enable[i] = |
| 128 | config->usb2_ports[i].enable; |
Subrata Banik | 2c3054c | 2016-11-22 20:21:49 +0530 | [diff] [blame] | 129 | params->Usb2OverCurrentPin[i] = |
| 130 | config->usb2_ports[i].ocpin; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 131 | params->Usb2AfePetxiset[i] = |
| 132 | config->usb2_ports[i].pre_emp_bias; |
| 133 | params->Usb2AfeTxiset[i] = |
| 134 | config->usb2_ports[i].tx_bias; |
| 135 | params->Usb2AfePredeemp[i] = |
| 136 | config->usb2_ports[i].tx_emp_enable; |
| 137 | params->Usb2AfePehalfbit[i] = |
| 138 | config->usb2_ports[i].pre_emp_bit; |
| 139 | } |
| 140 | |
| 141 | for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) { |
| 142 | params->PortUsb30Enable[i] = config->usb3_ports[i].enable; |
Subrata Banik | 2c3054c | 2016-11-22 20:21:49 +0530 | [diff] [blame] | 143 | params->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 144 | if (config->usb3_ports[i].tx_de_emp) { |
| 145 | params->Usb3HsioTxDeEmphEnable[i] = 1; |
| 146 | params->Usb3HsioTxDeEmph[i] = |
| 147 | config->usb3_ports[i].tx_de_emp; |
| 148 | } |
| 149 | if (config->usb3_ports[i].tx_downscale_amp) { |
| 150 | params->Usb3HsioTxDownscaleAmpEnable[i] = 1; |
| 151 | params->Usb3HsioTxDownscaleAmp[i] = |
| 152 | config->usb3_ports[i].tx_downscale_amp; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | memcpy(params->SataPortsEnable, config->SataPortsEnable, |
| 157 | sizeof(params->SataPortsEnable)); |
| 158 | memcpy(params->SataPortsDevSlp, config->SataPortsDevSlp, |
| 159 | sizeof(params->SataPortsDevSlp)); |
| 160 | memcpy(params->PcieRpClkReqSupport, config->PcieRpClkReqSupport, |
| 161 | sizeof(params->PcieRpClkReqSupport)); |
| 162 | memcpy(params->PcieRpClkReqNumber, config->PcieRpClkReqNumber, |
| 163 | sizeof(params->PcieRpClkReqNumber)); |
| 164 | |
Naresh G Solanki | eedf6d8 | 2016-11-16 21:27:38 +0530 | [diff] [blame] | 165 | /* disable Legacy PME */ |
| 166 | memset(params->PcieRpPmSci, 0, sizeof(params->PcieRpPmSci)); |
| 167 | |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 168 | memcpy(params->SerialIoDevMode, config->SerialIoDevMode, |
| 169 | sizeof(params->SerialIoDevMode)); |
| 170 | |
| 171 | params->PchCio2Enable = config->Cio2Enable; |
| 172 | params->Heci3Enabled = config->Heci3Enabled; |
| 173 | |
| 174 | params->LogoPtr = config->LogoPtr; |
| 175 | params->LogoSize = config->LogoSize; |
| 176 | |
| 177 | params->CpuConfig.Bits.VmxEnable = config->VmxEnable; |
| 178 | |
| 179 | params->PchPmWoWlanEnable = config->PchPmWoWlanEnable; |
| 180 | params->PchPmWoWlanDeepSxEnable = config->PchPmWoWlanDeepSxEnable; |
| 181 | params->PchPmLanWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx; |
| 182 | |
| 183 | params->PchLanEnable = config->EnableLan; |
| 184 | params->PchCio2Enable = config->Cio2Enable; |
| 185 | params->SataSalpSupport = config->SataSalpSupport; |
| 186 | params->SsicPortEnable = config->SsicPortEnable; |
| 187 | params->ScsEmmcEnabled = config->ScsEmmcEnabled; |
| 188 | params->ScsEmmcHs400Enabled = config->ScsEmmcHs400Enabled; |
| 189 | params->ScsSdCardEnabled = config->ScsSdCardEnabled; |
| 190 | params->PchIshEnable = config->IshEnable; |
| 191 | params->PchHdaEnable = config->EnableAzalia; |
| 192 | params->PchHdaIoBufferOwnership = config->IoBufferOwnership; |
| 193 | params->PchHdaDspEnable = config->DspEnable; |
| 194 | params->XdciEnable = config->XdciEnable; |
| 195 | params->Device4Enable = config->Device4Enable; |
| 196 | params->SataEnable = config->EnableSata; |
| 197 | params->SataMode = config->SataMode; |
| 198 | tconfig->PchLockDownGlobalSmi = config->LockDownConfigGlobalSmi; |
| 199 | tconfig->PchLockDownBiosInterface = config->LockDownConfigBiosInterface; |
| 200 | tconfig->PchLockDownRtcLock = config->LockDownConfigRtcLock; |
| 201 | params->PchLockDownBiosLock = config->LockDownConfigBiosLock; |
| 202 | params->PchLockDownSpiEiss = config->LockDownConfigSpiEiss; |
| 203 | params->PchSubSystemVendorId = config->PchConfigSubSystemVendorId; |
| 204 | params->PchSubSystemId = config->PchConfigSubSystemId; |
| 205 | params->PchPmWolEnableOverride = config->WakeConfigWolEnableOverride; |
| 206 | params->PchPmPcieWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx; |
| 207 | params->PchPmDeepSxPol = config->PmConfigDeepSxPol; |
| 208 | params->PchPmSlpS3MinAssert = config->PmConfigSlpS3MinAssert; |
| 209 | params->PchPmSlpS4MinAssert = config->PmConfigSlpS4MinAssert; |
| 210 | params->PchPmSlpSusMinAssert = config->PmConfigSlpSusMinAssert; |
| 211 | params->PchPmSlpAMinAssert = config->PmConfigSlpAMinAssert; |
| 212 | params->PchPmLpcClockRun = config->PmConfigPciClockRun; |
| 213 | params->PchPmSlpStrchSusUp = config->PmConfigSlpStrchSusUp; |
| 214 | params->PchPmPwrBtnOverridePeriod = |
| 215 | config->PmConfigPwrBtnOverridePeriod; |
| 216 | params->PchPmPwrCycDur = config->PmConfigPwrCycDur; |
| 217 | params->PchSirqEnable = config->SerialIrqConfigSirqEnable; |
| 218 | params->PchSirqMode = config->SerialIrqConfigSirqMode; |
| 219 | |
| 220 | params->CpuConfig.Bits.SkipMpInit = config->FspSkipMpInit; |
| 221 | |
| 222 | for (i = 0; i < ARRAY_SIZE(config->i2c); i++) |
Aaron Durbin | ed14a4e | 2016-11-09 17:04:15 -0600 | [diff] [blame] | 223 | params->SerialIoI2cVoltage[i] = config->i2c_voltage[i]; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 224 | |
| 225 | for (i = 0; i < ARRAY_SIZE(config->domain_vr_config); i++) |
| 226 | fill_vr_domain_config(params, i, &config->domain_vr_config[i]); |
| 227 | |
| 228 | /* Show SPI controller if enabled in devicetree.cb */ |
| 229 | dev = dev_find_slot(0, PCH_DEVFN_SPI); |
| 230 | params->ShowSpiController = dev->enabled; |
| 231 | |
Rizwan Qureshi | 6467014 | 2016-11-23 15:25:19 +0530 | [diff] [blame] | 232 | /* |
| 233 | * Send VR specific mailbox commands: |
| 234 | * 000b - no VR specific command sent |
| 235 | * 001b - VR mailbox command specifically for the MPS IMPV8 VR |
| 236 | * will be sent |
| 237 | * 010b - VR specific command sent for PS4 exit issue |
| 238 | * 100b - VR specific command sent for MPS VR decay issue |
| 239 | */ |
| 240 | params->SendVrMbxCmd1 = config->SendVrMbxCmd; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 241 | |
| 242 | soc_irq_settings(params); |
Rizwan Qureshi | 1222a73 | 2016-08-23 14:31:23 +0530 | [diff] [blame] | 243 | } |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 244 | |
Rizwan Qureshi | 1222a73 | 2016-08-23 14:31:23 +0530 | [diff] [blame] | 245 | struct pci_operations soc_pci_ops = { |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 246 | .set_subsystem = &pci_dev_set_subsystem |
Rizwan Qureshi | 1222a73 | 2016-08-23 14:31:23 +0530 | [diff] [blame] | 247 | }; |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 248 | |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 249 | /* Mainboard GPIO Configuration */ |
| 250 | __attribute__((weak)) void mainboard_silicon_init_params(FSP_S_CONFIG *params) |
| 251 | { |
| 252 | printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__); |
| 253 | } |