blob: 6f227407de284354e32d0771286a1f1be252a73c [file] [log] [blame]
Lee Leahy77ff0b12015-05-05 15:07:29 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Google Inc.
Lee Leahy32471722015-04-20 15:20:28 -07005 * Copyright (C) 2015 Intel Corp.
Lee Leahy77ff0b12015-05-05 15:07:29 -07006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
Patrick Georgi25509ee2015-03-26 15:17:45 +010018 * Foundation, Inc.
Lee Leahy77ff0b12015-05-05 15:07:29 -070019 */
20
Lee Leahy32471722015-04-20 15:20:28 -070021#include <chip.h>
Lee Leahy77ff0b12015-05-05 15:07:29 -070022#include <console/console.h>
23#include <device/device.h>
24#include <device/pci.h>
Aaron Durbin789f2b62015-09-09 17:05:06 -050025#include <fsp/util.h>
Lee Leahy77ff0b12015-05-05 15:07:29 -070026#include <soc/pci_devs.h>
27#include <soc/ramstage.h>
Lee Leahy77ff0b12015-05-05 15:07:29 -070028
29static void pci_domain_set_resources(device_t dev)
30{
Lee Leahy32471722015-04-20 15:20:28 -070031 printk(BIOS_SPEW, "%s/%s ( %s )\n",
32 __FILE__, __func__, dev_name(dev));
Lee Leahy77ff0b12015-05-05 15:07:29 -070033 assign_resources(dev->link_list);
34}
35
36static struct device_operations pci_domain_ops = {
37 .read_resources = pci_domain_read_resources,
38 .set_resources = pci_domain_set_resources,
39 .enable_resources = NULL,
40 .init = NULL,
41 .scan_bus = pci_domain_scan_bus,
42 .ops_pci_bus = pci_bus_default_ops,
43};
44
Lee Leahy32471722015-04-20 15:20:28 -070045static void cpu_bus_noop(device_t dev) { }
46
Lee Leahy77ff0b12015-05-05 15:07:29 -070047static struct device_operations cpu_bus_ops = {
Lee Leahy32471722015-04-20 15:20:28 -070048 .read_resources = cpu_bus_noop,
49 .set_resources = cpu_bus_noop,
50 .enable_resources = cpu_bus_noop,
51 .init = soc_init_cpus
Lee Leahy77ff0b12015-05-05 15:07:29 -070052};
53
54
55static void enable_dev(device_t dev)
56{
Lee Leahy32471722015-04-20 15:20:28 -070057 printk(BIOS_SPEW, "----------\n%s/%s ( %s ), type: %d\n",
58 __FILE__, __func__,
59 dev_name(dev), dev->path.type);
60 printk(BIOS_SPEW, "vendor: 0x%04x. device: 0x%04x\n",
61 pci_read_config16(dev, PCI_VENDOR_ID),
62 pci_read_config16(dev, PCI_DEVICE_ID));
63 printk(BIOS_SPEW, "class: 0x%02x %s\n"
64 "subclass: 0x%02x %s\n"
65 "prog: 0x%02x\n"
66 "revision: 0x%02x\n",
67 pci_read_config16(dev, PCI_CLASS_DEVICE) >> 8,
68 get_pci_class_name(dev),
69 pci_read_config16(dev, PCI_CLASS_DEVICE) & 0xff,
70 get_pci_subclass_name(dev),
71 pci_read_config8(dev, PCI_CLASS_PROG),
72 pci_read_config8(dev, PCI_REVISION_ID));
73
Lee Leahy77ff0b12015-05-05 15:07:29 -070074 /* 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 south cluster enablement. */
81 if (PCI_SLOT(dev->path.pci.devfn) > GFX_DEV &&
82 (dev->ops == NULL || dev->ops->enable == NULL)) {
83 southcluster_enable_dev(dev);
84 }
85 }
86}
87
Lee Leahy32471722015-04-20 15:20:28 -070088void soc_silicon_init_params(SILICON_INIT_UPD *params)
89{
90 device_t dev = dev_find_slot(0, PCI_DEVFN(LPC_DEV, LPC_FUNC));
91 struct soc_intel_braswell_config *config = dev->chip_info;
92
93 /* Set the parameters for SiliconInit */
94 printk(BIOS_DEBUG, "Updating UPD values for SiliconInit\n");
95 params->PcdSdcardMode = config->PcdSdcardMode;
96 params->PcdEnableHsuart0 = config->PcdEnableHsuart0;
97 params->PcdEnableHsuart1 = config->PcdEnableHsuart1;
98 params->PcdEnableAzalia = config->PcdEnableAzalia;
99 params->AzaliaConfigPtr = config->AzaliaConfigPtr;
100 params->PcdEnableSata = config->PcdEnableSata;
101 params->PcdEnableXhci = config->PcdEnableXhci;
102 params->PcdEnableLpe = config->PcdEnableLpe;
103 params->PcdEnableDma0 = config->PcdEnableDma0;
104 params->PcdEnableDma1 = config->PcdEnableDma1;
105 params->PcdEnableI2C0 = config->PcdEnableI2C0;
106 params->PcdEnableI2C1 = config->PcdEnableI2C1;
107 params->PcdEnableI2C2 = config->PcdEnableI2C2;
108 params->PcdEnableI2C3 = config->PcdEnableI2C3;
109 params->PcdEnableI2C4 = config->PcdEnableI2C4;
110 params->PcdEnableI2C5 = config->PcdEnableI2C5;
111 params->PcdEnableI2C6 = config->PcdEnableI2C6;
112 params->PcdGraphicsConfigPtr = config->PcdGraphicsConfigPtr;
113 params->PunitPwrConfigDisable = config->PunitPwrConfigDisable;
114 params->ChvSvidConfig = config->ChvSvidConfig;
115 params->DptfDisable = config->DptfDisable;
116 params->PcdEmmcMode = config->PcdEmmcMode;
117 params->PcdUsb3ClkSsc = config->PcdUsb3ClkSsc;
118 params->PcdDispClkSsc = config->PcdDispClkSsc;
119 params->PcdSataClkSsc = config->PcdSataClkSsc;
120 params->Usb2Port0PerPortPeTxiSet = config->Usb2Port0PerPortPeTxiSet;
121 params->Usb2Port0PerPortTxiSet = config->Usb2Port0PerPortTxiSet;
122 params->Usb2Port0IUsbTxEmphasisEn = config->Usb2Port0IUsbTxEmphasisEn;
123 params->Usb2Port0PerPortTxPeHalf = config->Usb2Port0PerPortTxPeHalf;
124 params->Usb2Port1PerPortPeTxiSet = config->Usb2Port1PerPortPeTxiSet;
125 params->Usb2Port1PerPortTxiSet = config->Usb2Port1PerPortTxiSet;
126 params->Usb2Port1IUsbTxEmphasisEn = config->Usb2Port1IUsbTxEmphasisEn;
127 params->Usb2Port1PerPortTxPeHalf = config->Usb2Port1PerPortTxPeHalf;
128 params->Usb2Port2PerPortPeTxiSet = config->Usb2Port2PerPortPeTxiSet;
129 params->Usb2Port2PerPortTxiSet = config->Usb2Port2PerPortTxiSet;
130 params->Usb2Port2IUsbTxEmphasisEn = config->Usb2Port2IUsbTxEmphasisEn;
131 params->Usb2Port2PerPortTxPeHalf = config->Usb2Port2PerPortTxPeHalf;
132 params->Usb2Port3PerPortPeTxiSet = config->Usb2Port3PerPortPeTxiSet;
133 params->Usb2Port3PerPortTxiSet = config->Usb2Port3PerPortTxiSet;
134 params->Usb2Port3IUsbTxEmphasisEn = config->Usb2Port3IUsbTxEmphasisEn;
135 params->Usb2Port3PerPortTxPeHalf = config->Usb2Port3PerPortTxPeHalf;
136 params->Usb2Port4PerPortPeTxiSet = config->Usb2Port4PerPortPeTxiSet;
137 params->Usb2Port4PerPortTxiSet = config->Usb2Port4PerPortTxiSet;
138 params->Usb2Port4IUsbTxEmphasisEn = config->Usb2Port4IUsbTxEmphasisEn;
139 params->Usb2Port4PerPortTxPeHalf = config->Usb2Port4PerPortTxPeHalf;
140 params->Usb3Lane0Ow2tapgen2deemph3p5 =
141 config->Usb3Lane0Ow2tapgen2deemph3p5;
142 params->Usb3Lane1Ow2tapgen2deemph3p5 =
143 config->Usb3Lane1Ow2tapgen2deemph3p5;
144 params->Usb3Lane2Ow2tapgen2deemph3p5 =
145 config->Usb3Lane2Ow2tapgen2deemph3p5;
146 params->Usb3Lane3Ow2tapgen2deemph3p5 =
147 config->Usb3Lane3Ow2tapgen2deemph3p5;
148 params->PcdSataInterfaceSpeed = config->PcdSataInterfaceSpeed;
149 params->PcdPchUsbSsicPort = config->PcdPchUsbSsicPort;
150 params->PcdPchUsbHsicPort = config->PcdPchUsbHsicPort;
151 params->PcdPcieRootPortSpeed = config->PcdPcieRootPortSpeed;
152 params->PcdPchSsicEnable = config->PcdPchSsicEnable;
153 params->PcdLogoPtr = config->PcdLogoPtr;
154 params->PcdLogoSize = config->PcdLogoSize;
155 params->PcdRtcLock = config->PcdRtcLock;
156 params->PMIC_I2CBus = config->PMIC_I2CBus;
157 params->ISPEnable = config->ISPEnable;
158 params->ISPPciDevConfig = config->ISPPciDevConfig;
159}
160
161void soc_display_silicon_init_params(const SILICON_INIT_UPD *old,
162 SILICON_INIT_UPD *new)
163{
164 /* Display the parameters for SiliconInit */
165 printk(BIOS_SPEW, "UPD values for SiliconInit:\n");
166 soc_display_upd_value("PcdSdcardMode", 1, old->PcdSdcardMode,
167 new->PcdSdcardMode);
168 soc_display_upd_value("PcdEnableHsuart0", 1, old->PcdEnableHsuart0,
169 new->PcdEnableHsuart0);
170 soc_display_upd_value("PcdEnableHsuart1", 1, old->PcdEnableHsuart1,
171 new->PcdEnableHsuart1);
172 soc_display_upd_value("PcdEnableAzalia", 1, old->PcdEnableAzalia,
173 new->PcdEnableAzalia);
174 soc_display_upd_value("AzaliaVerbTablePtr", 4,
175 (uint32_t)old->AzaliaVerbTablePtr,
176 (uint32_t)new->AzaliaVerbTablePtr);
177 soc_display_upd_value("AzaliaConfigPtr", 4, old->AzaliaConfigPtr,
178 new->AzaliaConfigPtr);
179 soc_display_upd_value("PcdEnableSata", 1, old->PcdEnableSata,
180 new->PcdEnableSata);
181 soc_display_upd_value("PcdEnableXhci", 1, old->PcdEnableXhci,
182 new->PcdEnableXhci);
183 soc_display_upd_value("PcdEnableLpe", 1, old->PcdEnableLpe,
184 new->PcdEnableLpe);
185 soc_display_upd_value("PcdEnableDma0", 1, old->PcdEnableDma0,
186 new->PcdEnableDma0);
187 soc_display_upd_value("PcdEnableDma1", 1, old->PcdEnableDma1,
188 new->PcdEnableDma1);
189 soc_display_upd_value("PcdEnableI2C0", 1, old->PcdEnableI2C0,
190 new->PcdEnableI2C0);
191 soc_display_upd_value("PcdEnableI2C1", 1, old->PcdEnableI2C1,
192 new->PcdEnableI2C1);
193 soc_display_upd_value("PcdEnableI2C2", 1, old->PcdEnableI2C2,
194 new->PcdEnableI2C2);
195 soc_display_upd_value("PcdEnableI2C3", 1, old->PcdEnableI2C3,
196 new->PcdEnableI2C3);
197 soc_display_upd_value("PcdEnableI2C4", 1, old->PcdEnableI2C4,
198 new->PcdEnableI2C4);
199 soc_display_upd_value("PcdEnableI2C5", 1, old->PcdEnableI2C5,
200 new->PcdEnableI2C5);
201 soc_display_upd_value("PcdEnableI2C6", 1, old->PcdEnableI2C6,
202 new->PcdEnableI2C6);
203 soc_display_upd_value("PcdGraphicsConfigPtr", 4,
204 old->PcdGraphicsConfigPtr, new->PcdGraphicsConfigPtr);
205 soc_display_upd_value("GpioFamilyInitTablePtr", 4,
206 (uint32_t)old->GpioFamilyInitTablePtr,
207 (uint32_t)new->GpioFamilyInitTablePtr);
208 soc_display_upd_value("GpioPadInitTablePtr", 4,
209 (uint32_t)old->GpioPadInitTablePtr,
210 (uint32_t)new->GpioPadInitTablePtr);
211 soc_display_upd_value("PunitPwrConfigDisable", 1,
212 old->PunitPwrConfigDisable,
213 new->PunitPwrConfigDisable);
214 soc_display_upd_value("ChvSvidConfig", 1, old->ChvSvidConfig,
215 new->ChvSvidConfig);
216 soc_display_upd_value("DptfDisable", 1, old->DptfDisable,
217 new->DptfDisable);
218 soc_display_upd_value("PcdEmmcMode", 1, old->PcdEmmcMode,
219 new->PcdEmmcMode);
220 soc_display_upd_value("PcdUsb3ClkSsc", 1, old->PcdUsb3ClkSsc,
221 new->PcdUsb3ClkSsc);
222 soc_display_upd_value("PcdDispClkSsc", 1, old->PcdDispClkSsc,
223 new->PcdDispClkSsc);
224 soc_display_upd_value("PcdSataClkSsc", 1, old->PcdSataClkSsc,
225 new->PcdSataClkSsc);
226 soc_display_upd_value("Usb2Port0PerPortPeTxiSet", 1,
227 old->Usb2Port0PerPortPeTxiSet,
228 new->Usb2Port0PerPortPeTxiSet);
229 soc_display_upd_value("Usb2Port0PerPortTxiSet", 1,
230 old->Usb2Port0PerPortTxiSet,
231 new->Usb2Port0PerPortTxiSet);
232 soc_display_upd_value("Usb2Port0IUsbTxEmphasisEn", 1,
233 old->Usb2Port0IUsbTxEmphasisEn,
234 new->Usb2Port0IUsbTxEmphasisEn);
235 soc_display_upd_value("Usb2Port0PerPortTxPeHalf", 1,
236 old->Usb2Port0PerPortTxPeHalf,
237 new->Usb2Port0PerPortTxPeHalf);
238 soc_display_upd_value("Usb2Port1PerPortPeTxiSet", 1,
239 old->Usb2Port1PerPortPeTxiSet,
240 new->Usb2Port1PerPortPeTxiSet);
241 soc_display_upd_value("Usb2Port1PerPortTxiSet", 1,
242 old->Usb2Port1PerPortTxiSet,
243 new->Usb2Port1PerPortTxiSet);
244 soc_display_upd_value("Usb2Port1IUsbTxEmphasisEn", 1,
245 old->Usb2Port1IUsbTxEmphasisEn,
246 new->Usb2Port1IUsbTxEmphasisEn);
247 soc_display_upd_value("Usb2Port1PerPortTxPeHalf", 1,
248 old->Usb2Port1PerPortTxPeHalf,
249 new->Usb2Port1PerPortTxPeHalf);
250 soc_display_upd_value("Usb2Port2PerPortPeTxiSet", 1,
251 old->Usb2Port2PerPortPeTxiSet,
252 new->Usb2Port2PerPortPeTxiSet);
253 soc_display_upd_value("Usb2Port2PerPortTxiSet", 1,
254 old->Usb2Port2PerPortTxiSet,
255 new->Usb2Port2PerPortTxiSet);
256 soc_display_upd_value("Usb2Port2IUsbTxEmphasisEn", 1,
257 old->Usb2Port2IUsbTxEmphasisEn,
258 new->Usb2Port2IUsbTxEmphasisEn);
259 soc_display_upd_value("Usb2Port2PerPortTxPeHalf", 1,
260 old->Usb2Port2PerPortTxPeHalf,
261 new->Usb2Port2PerPortTxPeHalf);
262 soc_display_upd_value("Usb2Port3PerPortPeTxiSet", 1,
263 old->Usb2Port3PerPortPeTxiSet,
264 new->Usb2Port3PerPortPeTxiSet);
265 soc_display_upd_value("Usb2Port3PerPortTxiSet", 1,
266 old->Usb2Port3PerPortTxiSet,
267 new->Usb2Port3PerPortTxiSet);
268 soc_display_upd_value("Usb2Port3IUsbTxEmphasisEn", 1,
269 old->Usb2Port3IUsbTxEmphasisEn,
270 new->Usb2Port3IUsbTxEmphasisEn);
271 soc_display_upd_value("Usb2Port3PerPortTxPeHalf", 1,
272 old->Usb2Port3PerPortTxPeHalf,
273 new->Usb2Port3PerPortTxPeHalf);
274 soc_display_upd_value("Usb2Port4PerPortPeTxiSet", 1,
275 old->Usb2Port4PerPortPeTxiSet,
276 new->Usb2Port4PerPortPeTxiSet);
277 soc_display_upd_value("Usb2Port4PerPortTxiSet", 1,
278 old->Usb2Port4PerPortTxiSet,
279 new->Usb2Port4PerPortTxiSet);
280 soc_display_upd_value("Usb2Port4IUsbTxEmphasisEn", 1,
281 old->Usb2Port4IUsbTxEmphasisEn,
282 new->Usb2Port4IUsbTxEmphasisEn);
283 soc_display_upd_value("Usb2Port4PerPortTxPeHalf", 1,
284 old->Usb2Port4PerPortTxPeHalf,
285 new->Usb2Port4PerPortTxPeHalf);
286 soc_display_upd_value("Usb3Lane0Ow2tapgen2deemph3p5", 1,
287 old->Usb3Lane0Ow2tapgen2deemph3p5,
288 new->Usb3Lane0Ow2tapgen2deemph3p5);
289 soc_display_upd_value("Usb3Lane1Ow2tapgen2deemph3p5", 1,
290 old->Usb3Lane1Ow2tapgen2deemph3p5,
291 new->Usb3Lane1Ow2tapgen2deemph3p5);
292 soc_display_upd_value("Usb3Lane2Ow2tapgen2deemph3p5", 1,
293 old->Usb3Lane2Ow2tapgen2deemph3p5,
294 new->Usb3Lane2Ow2tapgen2deemph3p5);
295 soc_display_upd_value("Usb3Lane3Ow2tapgen2deemph3p5", 1,
296 old->Usb3Lane3Ow2tapgen2deemph3p5,
297 new->Usb3Lane3Ow2tapgen2deemph3p5);
298 soc_display_upd_value("PcdSataInterfaceSpeed", 1,
299 old->PcdSataInterfaceSpeed,
300 new->PcdSataInterfaceSpeed);
301 soc_display_upd_value("PcdPchUsbSsicPort", 1,
302 old->PcdPchUsbSsicPort, new->PcdPchUsbSsicPort);
303 soc_display_upd_value("PcdPchUsbHsicPort", 1,
304 old->PcdPchUsbHsicPort, new->PcdPchUsbHsicPort);
305 soc_display_upd_value("PcdPcieRootPortSpeed", 1,
306 old->PcdPcieRootPortSpeed, new->PcdPcieRootPortSpeed);
307 soc_display_upd_value("PcdPchSsicEnable", 1, old->PcdPchSsicEnable,
308 new->PcdPchSsicEnable);
309 soc_display_upd_value("PcdLogoPtr", 4, old->PcdLogoPtr,
310 new->PcdLogoPtr);
311 soc_display_upd_value("PcdLogoSize", 4, old->PcdLogoSize,
312 new->PcdLogoSize);
313 soc_display_upd_value("PcdRtcLock", 1, old->PcdRtcLock,
314 new->PcdRtcLock);
315 soc_display_upd_value("PMIC_I2CBus", 1,
316 old->PMIC_I2CBus, new->PMIC_I2CBus);
317 soc_display_upd_value("ISPEnable", 1,
318 old->ISPEnable, new->ISPEnable);
319 soc_display_upd_value("ISPPciDevConfig", 1,
320 old->ISPPciDevConfig, new->ISPPciDevConfig);
321}
322
Lee Leahy77ff0b12015-05-05 15:07:29 -0700323/* Called at BS_DEV_INIT_CHIPS time -- very early. Just after BS_PRE_DEVICE. */
324static void soc_init(void *chip_info)
325{
Lee Leahy32471722015-04-20 15:20:28 -0700326 printk(BIOS_SPEW, "%s/%s\n", __FILE__, __func__);
327 soc_init_pre_device(chip_info);
Lee Leahy77ff0b12015-05-05 15:07:29 -0700328}
329
Lee Leahy32471722015-04-20 15:20:28 -0700330struct chip_operations soc_intel_braswell_ops = {
331 CHIP_NAME("Intel Braswell SoC")
Lee Leahy77ff0b12015-05-05 15:07:29 -0700332 .enable_dev = enable_dev,
333 .init = soc_init,
334};
335
336static void pci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
337{
Lee Leahy32471722015-04-20 15:20:28 -0700338 printk(BIOS_SPEW, "%s/%s ( %s, 0x%04x, 0x%04x )\n",
339 __FILE__, __func__, dev_name(dev), vendor, device);
Lee Leahy77ff0b12015-05-05 15:07:29 -0700340 if (!vendor || !device) {
341 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
342 pci_read_config32(dev, PCI_VENDOR_ID));
343 } else {
344 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
345 ((device & 0xffff) << 16) | (vendor & 0xffff));
346 }
347}
348
349struct pci_operations soc_pci_ops = {
350 .set_subsystem = &pci_set_subsystem,
351};