blob: a1e76a9d3916437c859a9d79d9e14b61e01d3358 [file] [log] [blame]
Lee Leahyb0005132015-05-12 18:19:47 -07001/*
2 * This file is part of the coreboot project.
3 *
Rizwan Qureshi1222a732016-08-23 14:31:23 +05304 * Copyright (C) 2016 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>
Rizwan Qureshi1222a732016-08-23 14:31:23 +053017#include <bootstate.h>
18#include <device/pci.h>
19#include <fsp/api.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053020#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 Breitensteinc6ec8dd2016-11-17 12:23:04 -080028#include <romstage_handoff.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053029#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
36void soc_init_pre_device(void *chip_info)
37{
38 /* Perform silicon specific init. */
Aaron Durbin6c191d82016-11-29 21:22:42 -060039 fsp_silicon_init(romstage_handoff_is_resume());
Naresh G Solankia2d40622016-08-30 20:47:13 +053040}
41
42static void pci_domain_set_resources(device_t dev)
43{
44 assign_resources(dev->link_list);
45}
46
47static struct device_operations pci_domain_ops = {
48 .read_resources = &pci_domain_read_resources,
49 .set_resources = &pci_domain_set_resources,
50 .scan_bus = &pci_domain_scan_bus,
51 .ops_pci_bus = &pci_bus_default_ops,
52#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
53 .acpi_name = &soc_acpi_name,
54#endif
55};
56
57static struct device_operations cpu_bus_ops = {
58 .read_resources = DEVICE_NOOP,
59 .set_resources = DEVICE_NOOP,
60 .enable_resources = DEVICE_NOOP,
61 .init = &soc_init_cpus,
62#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
63 .acpi_fill_ssdt_generator = generate_cpu_entries,
64#endif
65};
66
67static void soc_enable(device_t dev)
68{
69 /* Set the operations if it is a special bus type */
70 if (dev->path.type == DEVICE_PATH_DOMAIN) {
71 dev->ops = &pci_domain_ops;
72 } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
73 dev->ops = &cpu_bus_ops;
74 } else if (dev->path.type == DEVICE_PATH_PCI) {
75 /* Handle PCH device enable */
76 if (PCI_SLOT(dev->path.pci.devfn) > SA_DEV_SLOT_IGD &&
77 (dev->ops == NULL || dev->ops->enable == NULL)) {
78 pch_enable_dev(dev);
79 }
80 }
81}
82
83struct chip_operations soc_intel_skylake_ops = {
84 CHIP_NAME("Intel 6th Gen")
85 .enable_dev = &soc_enable,
86 .init = &soc_init_pre_device,
87};
Lee Leahyb0005132015-05-12 18:19:47 -070088
Rizwan Qureshi1222a732016-08-23 14:31:23 +053089/* UPD parameters to be initialized before SiliconInit */
Naresh G Solankia2d40622016-08-30 20:47:13 +053090void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
Rizwan Qureshi1222a732016-08-23 14:31:23 +053091{
Naresh G Solankia2d40622016-08-30 20:47:13 +053092 FSP_S_CONFIG *params = &supd->FspsConfig;
93 FSP_S_TEST_CONFIG *tconfig = &supd->FspsTestConfig;
94 static struct soc_intel_skylake_config *config;
95 uintptr_t vbt_data = 0;
96
97 int i;
98
99 int is_s3_wakeup = acpi_is_wakeup_s3();
100
101 struct device *dev = SA_DEV_ROOT;
102 if (!dev || !dev->chip_info) {
103 printk(BIOS_ERR, "BUG! Could not find SOC devicetree config\n");
104 return;
105 }
106 config = dev->chip_info;
107
108 mainboard_silicon_init_params(params);
109
110 /* Load VBT */
111 if (!is_s3_wakeup)
112 vbt_data = fsp_load_vbt();
113
114 params->GraphicsConfigPtr = (u32) vbt_data;
115
116 for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) {
117 params->PortUsb20Enable[i] =
118 config->usb2_ports[i].enable;
Subrata Banik2c3054c2016-11-22 20:21:49 +0530119 params->Usb2OverCurrentPin[i] =
120 config->usb2_ports[i].ocpin;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530121 params->Usb2AfePetxiset[i] =
122 config->usb2_ports[i].pre_emp_bias;
123 params->Usb2AfeTxiset[i] =
124 config->usb2_ports[i].tx_bias;
125 params->Usb2AfePredeemp[i] =
126 config->usb2_ports[i].tx_emp_enable;
127 params->Usb2AfePehalfbit[i] =
128 config->usb2_ports[i].pre_emp_bit;
129 }
130
131 for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) {
132 params->PortUsb30Enable[i] = config->usb3_ports[i].enable;
Subrata Banik2c3054c2016-11-22 20:21:49 +0530133 params->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530134 if (config->usb3_ports[i].tx_de_emp) {
135 params->Usb3HsioTxDeEmphEnable[i] = 1;
136 params->Usb3HsioTxDeEmph[i] =
137 config->usb3_ports[i].tx_de_emp;
138 }
139 if (config->usb3_ports[i].tx_downscale_amp) {
140 params->Usb3HsioTxDownscaleAmpEnable[i] = 1;
141 params->Usb3HsioTxDownscaleAmp[i] =
142 config->usb3_ports[i].tx_downscale_amp;
143 }
144 }
145
146 memcpy(params->SataPortsEnable, config->SataPortsEnable,
147 sizeof(params->SataPortsEnable));
148 memcpy(params->SataPortsDevSlp, config->SataPortsDevSlp,
149 sizeof(params->SataPortsDevSlp));
150 memcpy(params->PcieRpClkReqSupport, config->PcieRpClkReqSupport,
151 sizeof(params->PcieRpClkReqSupport));
152 memcpy(params->PcieRpClkReqNumber, config->PcieRpClkReqNumber,
153 sizeof(params->PcieRpClkReqNumber));
154
Naresh G Solankieedf6d82016-11-16 21:27:38 +0530155 /* disable Legacy PME */
156 memset(params->PcieRpPmSci, 0, sizeof(params->PcieRpPmSci));
157
Naresh G Solankia2d40622016-08-30 20:47:13 +0530158 memcpy(params->SerialIoDevMode, config->SerialIoDevMode,
159 sizeof(params->SerialIoDevMode));
160
161 params->PchCio2Enable = config->Cio2Enable;
162 params->Heci3Enabled = config->Heci3Enabled;
163
164 params->LogoPtr = config->LogoPtr;
165 params->LogoSize = config->LogoSize;
166
167 params->CpuConfig.Bits.VmxEnable = config->VmxEnable;
168
169 params->PchPmWoWlanEnable = config->PchPmWoWlanEnable;
170 params->PchPmWoWlanDeepSxEnable = config->PchPmWoWlanDeepSxEnable;
171 params->PchPmLanWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx;
172
173 params->PchLanEnable = config->EnableLan;
174 params->PchCio2Enable = config->Cio2Enable;
175 params->SataSalpSupport = config->SataSalpSupport;
176 params->SsicPortEnable = config->SsicPortEnable;
177 params->ScsEmmcEnabled = config->ScsEmmcEnabled;
178 params->ScsEmmcHs400Enabled = config->ScsEmmcHs400Enabled;
179 params->ScsSdCardEnabled = config->ScsSdCardEnabled;
180 params->PchIshEnable = config->IshEnable;
181 params->PchHdaEnable = config->EnableAzalia;
182 params->PchHdaIoBufferOwnership = config->IoBufferOwnership;
183 params->PchHdaDspEnable = config->DspEnable;
184 params->XdciEnable = config->XdciEnable;
185 params->Device4Enable = config->Device4Enable;
186 params->SataEnable = config->EnableSata;
187 params->SataMode = config->SataMode;
188 tconfig->PchLockDownGlobalSmi = config->LockDownConfigGlobalSmi;
189 tconfig->PchLockDownBiosInterface = config->LockDownConfigBiosInterface;
190 tconfig->PchLockDownRtcLock = config->LockDownConfigRtcLock;
191 params->PchLockDownBiosLock = config->LockDownConfigBiosLock;
192 params->PchLockDownSpiEiss = config->LockDownConfigSpiEiss;
193 params->PchSubSystemVendorId = config->PchConfigSubSystemVendorId;
194 params->PchSubSystemId = config->PchConfigSubSystemId;
195 params->PchPmWolEnableOverride = config->WakeConfigWolEnableOverride;
196 params->PchPmPcieWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx;
197 params->PchPmDeepSxPol = config->PmConfigDeepSxPol;
198 params->PchPmSlpS3MinAssert = config->PmConfigSlpS3MinAssert;
199 params->PchPmSlpS4MinAssert = config->PmConfigSlpS4MinAssert;
200 params->PchPmSlpSusMinAssert = config->PmConfigSlpSusMinAssert;
201 params->PchPmSlpAMinAssert = config->PmConfigSlpAMinAssert;
202 params->PchPmLpcClockRun = config->PmConfigPciClockRun;
203 params->PchPmSlpStrchSusUp = config->PmConfigSlpStrchSusUp;
204 params->PchPmPwrBtnOverridePeriod =
205 config->PmConfigPwrBtnOverridePeriod;
206 params->PchPmPwrCycDur = config->PmConfigPwrCycDur;
207 params->PchSirqEnable = config->SerialIrqConfigSirqEnable;
208 params->PchSirqMode = config->SerialIrqConfigSirqMode;
209
210 params->CpuConfig.Bits.SkipMpInit = config->FspSkipMpInit;
211
212 for (i = 0; i < ARRAY_SIZE(config->i2c); i++)
Aaron Durbined14a4e2016-11-09 17:04:15 -0600213 params->SerialIoI2cVoltage[i] = config->i2c_voltage[i];
Naresh G Solankia2d40622016-08-30 20:47:13 +0530214
215 for (i = 0; i < ARRAY_SIZE(config->domain_vr_config); i++)
216 fill_vr_domain_config(params, i, &config->domain_vr_config[i]);
217
218 /* Show SPI controller if enabled in devicetree.cb */
219 dev = dev_find_slot(0, PCH_DEVFN_SPI);
220 params->ShowSpiController = dev->enabled;
221
Rizwan Qureshi64670142016-11-23 15:25:19 +0530222 /*
223 * Send VR specific mailbox commands:
224 * 000b - no VR specific command sent
225 * 001b - VR mailbox command specifically for the MPS IMPV8 VR
226 * will be sent
227 * 010b - VR specific command sent for PS4 exit issue
228 * 100b - VR specific command sent for MPS VR decay issue
229 */
230 params->SendVrMbxCmd1 = config->SendVrMbxCmd;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530231
232 soc_irq_settings(params);
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530233}
Lee Leahyb0005132015-05-12 18:19:47 -0700234
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530235struct pci_operations soc_pci_ops = {
Naresh G Solankia2d40622016-08-30 20:47:13 +0530236 .set_subsystem = &pci_dev_set_subsystem
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530237};
Lee Leahyb0005132015-05-12 18:19:47 -0700238
Naresh G Solankia2d40622016-08-30 20:47:13 +0530239/* Mainboard GPIO Configuration */
240__attribute__((weak)) void mainboard_silicon_init_params(FSP_S_CONFIG *params)
241{
242 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
243}