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