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