blob: 97a37e8afcedda31c1c2937f67af3221181c10b1 [file] [log] [blame]
Lee Leahyb0005132015-05-12 18:19:47 -07001/*
2 * This file is part of the coreboot project.
3 *
Subrata Banika4b11e5c2017-02-03 18:57:49 +05304 * Copyright (C) 2016-2017 Intel Corporation.
Lee Leahyb0005132015-05-12 18:19:47 -07005 *
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 Leahyb0005132015-05-12 18:19:47 -070014 */
15
Lee Leahy1d14b3e2015-05-12 18:23:27 -070016#include <chip.h>
Duncan Laurie7d484102017-01-09 22:23:39 -080017#include <bootmode.h>
Rizwan Qureshi1222a732016-08-23 14:31:23 +053018#include <bootstate.h>
19#include <device/pci.h>
20#include <fsp/api.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053021#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 Breitensteinc6ec8dd2016-11-17 12:23:04 -080029#include <romstage_handoff.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053030#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
37void soc_init_pre_device(void *chip_info)
38{
39 /* Perform silicon specific init. */
Aaron Durbin6c191d82016-11-29 21:22:42 -060040 fsp_silicon_init(romstage_handoff_is_resume());
Naresh G Solankia2d40622016-08-30 20:47:13 +053041}
42
43static void pci_domain_set_resources(device_t dev)
44{
45 assign_resources(dev->link_list);
46}
47
48static 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
58static struct device_operations cpu_bus_ops = {
59 .read_resources = DEVICE_NOOP,
60 .set_resources = DEVICE_NOOP,
61 .enable_resources = DEVICE_NOOP,
Subrata Banika4b11e5c2017-02-03 18:57:49 +053062 .init = DEVICE_NOOP,
Naresh G Solankia2d40622016-08-30 20:47:13 +053063#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
64 .acpi_fill_ssdt_generator = generate_cpu_entries,
65#endif
66};
67
68static 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
84struct 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 Leahyb0005132015-05-12 18:19:47 -070089
Rizwan Qureshi1222a732016-08-23 14:31:23 +053090/* UPD parameters to be initialized before SiliconInit */
Naresh G Solankia2d40622016-08-30 20:47:13 +053091void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
Rizwan Qureshi1222a732016-08-23 14:31:23 +053092{
Naresh G Solankia2d40622016-08-30 20:47:13 +053093 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 Laurie7d484102017-01-09 22:23:39 -0800112 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 Solankia2d40622016-08-30 20:47:13 +0530116 vbt_data = fsp_load_vbt();
Duncan Laurie7d484102017-01-09 22:23:39 -0800117 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 Solankia2d40622016-08-30 20:47:13 +0530124 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 Banik2c3054c2016-11-22 20:21:49 +0530129 params->Usb2OverCurrentPin[i] =
130 config->usb2_ports[i].ocpin;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530131 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 Banik2c3054c2016-11-22 20:21:49 +0530143 params->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530144 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 Solankieedf6d82016-11-16 21:27:38 +0530165 /* disable Legacy PME */
166 memset(params->PcieRpPmSci, 0, sizeof(params->PcieRpPmSci));
167
Naresh G Solankia2d40622016-08-30 20:47:13 +0530168 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;
Duncan Laurie25c7d932017-02-17 17:16:43 -0800208 params->PchPmSlpS0Enable = config->s0ix_enable;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530209 params->PchPmSlpS3MinAssert = config->PmConfigSlpS3MinAssert;
210 params->PchPmSlpS4MinAssert = config->PmConfigSlpS4MinAssert;
211 params->PchPmSlpSusMinAssert = config->PmConfigSlpSusMinAssert;
212 params->PchPmSlpAMinAssert = config->PmConfigSlpAMinAssert;
213 params->PchPmLpcClockRun = config->PmConfigPciClockRun;
214 params->PchPmSlpStrchSusUp = config->PmConfigSlpStrchSusUp;
215 params->PchPmPwrBtnOverridePeriod =
216 config->PmConfigPwrBtnOverridePeriod;
217 params->PchPmPwrCycDur = config->PmConfigPwrCycDur;
218 params->PchSirqEnable = config->SerialIrqConfigSirqEnable;
219 params->PchSirqMode = config->SerialIrqConfigSirqMode;
220
221 params->CpuConfig.Bits.SkipMpInit = config->FspSkipMpInit;
222
223 for (i = 0; i < ARRAY_SIZE(config->i2c); i++)
Aaron Durbined14a4e2016-11-09 17:04:15 -0600224 params->SerialIoI2cVoltage[i] = config->i2c_voltage[i];
Naresh G Solankia2d40622016-08-30 20:47:13 +0530225
226 for (i = 0; i < ARRAY_SIZE(config->domain_vr_config); i++)
227 fill_vr_domain_config(params, i, &config->domain_vr_config[i]);
228
229 /* Show SPI controller if enabled in devicetree.cb */
230 dev = dev_find_slot(0, PCH_DEVFN_SPI);
231 params->ShowSpiController = dev->enabled;
232
Rizwan Qureshi64670142016-11-23 15:25:19 +0530233 /*
234 * Send VR specific mailbox commands:
235 * 000b - no VR specific command sent
236 * 001b - VR mailbox command specifically for the MPS IMPV8 VR
237 * will be sent
238 * 010b - VR specific command sent for PS4 exit issue
239 * 100b - VR specific command sent for MPS VR decay issue
240 */
241 params->SendVrMbxCmd1 = config->SendVrMbxCmd;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530242
243 soc_irq_settings(params);
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530244}
Lee Leahyb0005132015-05-12 18:19:47 -0700245
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530246struct pci_operations soc_pci_ops = {
Naresh G Solankia2d40622016-08-30 20:47:13 +0530247 .set_subsystem = &pci_dev_set_subsystem
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530248};
Lee Leahyb0005132015-05-12 18:19:47 -0700249
Naresh G Solankia2d40622016-08-30 20:47:13 +0530250/* Mainboard GPIO Configuration */
251__attribute__((weak)) void mainboard_silicon_init_params(FSP_S_CONFIG *params)
252{
253 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
254}