blob: 0f3c8a08e69d57862bec0bd9d43b0acd408dca34 [file] [log] [blame]
Mariusz Szafranskia4041332017-08-02 17:28:17 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2015 - 2017 Intel Corp.
Julien Viard de Galbertf5281952017-11-06 13:19:58 +01005 * Copyright (C) 2017 Online SAS.
Mariusz Szafranskia4041332017-08-02 17:28:17 +02006 *
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; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18#include <arch/acpi.h>
19#include <bootstate.h>
20#include <cbfs.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +020021#include <console/console.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +020022#include <device/device.h>
23#include <device/pci.h>
24#include <fsp/api.h>
25#include <fsp/util.h>
26#include <intelblocks/fast_spi.h>
27#include <soc/iomap.h>
28#include <soc/intel/common/vbt.h>
29#include <soc/pci_devs.h>
30#include <soc/ramstage.h>
31#include <soc/fiamux.h>
32#include <spi-generic.h>
Julien Viard de Galbert2d0aaa72018-02-26 18:32:59 +010033#include <soc/hob_mem.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +020034
Elyes HAOUAS2ec41832018-05-27 17:40:58 +020035static void pci_domain_set_resources(struct device *dev)
Mariusz Szafranskia4041332017-08-02 17:28:17 +020036{
37 assign_resources(dev->link_list);
38}
39
40static struct device_operations pci_domain_ops = {
41 .read_resources = &pci_domain_read_resources,
42 .set_resources = &pci_domain_set_resources,
43 .scan_bus = &pci_domain_scan_bus,
Mariusz Szafranskia4041332017-08-02 17:28:17 +020044};
45
46static struct device_operations cpu_bus_ops = {
47 .read_resources = DEVICE_NOOP,
48 .set_resources = DEVICE_NOOP,
49 .enable_resources = DEVICE_NOOP,
50 .init = denverton_init_cpus,
51 .scan_bus = NULL,
52#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
53 .acpi_fill_ssdt_generator = generate_cpu_entries,
54#endif
55};
56
Elyes HAOUAS2ec41832018-05-27 17:40:58 +020057static void soc_enable_dev(struct device *dev)
Mariusz Szafranskia4041332017-08-02 17:28:17 +020058{
59 /* Set the operations if it is a special bus type */
60 if (dev->path.type == DEVICE_PATH_DOMAIN)
61 dev->ops = &pci_domain_ops;
62 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
63 dev->ops = &cpu_bus_ops;
64}
65
Julien Viard de Galbert2d0aaa72018-02-26 18:32:59 +010066static void soc_init(void *data)
67{
68 fsp_silicon_init(false);
69 soc_save_dimm_info();
70}
Mariusz Szafranskia4041332017-08-02 17:28:17 +020071
72static void soc_final(void *data) {}
73
74static void soc_silicon_init_params(FSPS_UPD *silupd)
75{
76 size_t num;
77 uint16_t supported_hsio_lanes;
Mariusz Szafranskia4041332017-08-02 17:28:17 +020078 BL_HSIO_INFORMATION *hsio_config;
79 BL_FIA_MUX_CONFIG_HOB *fiamux_hob_data = get_fiamux_hob_data();
80
81 /* Configure FIA MUX PCD */
82 supported_hsio_lanes =
83 (uint16_t)fiamux_hob_data->FiaMuxConfig.SkuNumLanesAllowed;
84
Julien Viard de Galbertf5281952017-11-06 13:19:58 +010085 num = mainboard_get_hsio_config(&hsio_config);
Mariusz Szafranskia4041332017-08-02 17:28:17 +020086
87 if (get_fiamux_hsio_info(supported_hsio_lanes, num, &hsio_config))
88 die("HSIO Configuration is invalid, please correct it!");
89
90 /* Check the requested FIA MUX Configuration */
91 if (!(&hsio_config->FiaConfig)) {
92 die("Requested FIA MUX Configuration is invalid,"
93 " please correct it!");
94 }
95
96 /* Initialize PCIE Bifurcation & HSIO configuration */
97 silupd->FspsConfig.PcdBifurcationPcie0 = hsio_config->PcieBifCtr[0];
98 silupd->FspsConfig.PcdBifurcationPcie1 = hsio_config->PcieBifCtr[1];
99
100 silupd->FspsConfig.PcdFiaMuxConfigRequestPtr =
101 (uint32_t)&hsio_config->FiaConfig;
102}
103
104void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd)
105{
106 const struct microcode *microcode_file;
107 size_t microcode_len;
108
109 microcode_file = cbfs_boot_map_with_leak("cpu_microcode_blob.bin",
110 CBFS_TYPE_MICROCODE, &microcode_len);
111
112 if ((microcode_file != NULL) && (microcode_len != 0)) {
113 /* Update CPU Microcode patch base address/size */
114 silupd->FspsConfig.PcdCpuMicrocodePatchBase =
115 (uint32_t)microcode_file;
116 silupd->FspsConfig.PcdCpuMicrocodePatchSize =
117 (uint32_t)microcode_len;
118 }
119
120 soc_silicon_init_params(silupd);
121 mainboard_silicon_init_params(silupd);
122}
123
124struct chip_operations soc_intel_denverton_ns_ops = {
125 CHIP_NAME("Intel Denverton-NS SOC")
Elyes HAOUAS1d191272018-11-27 12:23:48 +0100126 .enable_dev = soc_enable_dev,
127 .init = soc_init,
128 .final = soc_final
Mariusz Szafranskia4041332017-08-02 17:28:17 +0200129};
130
Elyes HAOUAS2ec41832018-05-27 17:40:58 +0200131static void soc_set_subsystem(struct device *dev, uint32_t vendor,
132 uint32_t device)
Mariusz Szafranskia4041332017-08-02 17:28:17 +0200133{
134 if (!vendor || !device) {
135 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
136 pci_read_config32(dev, PCI_VENDOR_ID));
137 } else {
138 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
139 ((device & 0xffff) << 16) |
140 (vendor & 0xffff));
141 }
142}
143
144struct pci_operations soc_pci_ops = {
145 .set_subsystem = soc_set_subsystem,
146};
147
148/*
149 * spi_flash init() needs to run unconditionally on every boot (including
150 * resume) to allow write protect to be disabled for eventlog and nvram
151 * updates. This needs to be done as early as possible in ramstage. Thus, add a
152 * callback for entry into BS_PRE_DEVICE.
153 */
154static void spi_flash_init_cb(void *unused)
155{
156 fast_spi_init();
157}
158
159BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_ENTRY, spi_flash_init_cb, NULL);