blob: a19f32a83457a7becedf7ef880b79c7b92dc05d1 [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>
21#include <cbmem.h>
22#include <console/console.h>
23#include <cpu/cpu.h>
24#include <device/device.h>
25#include <device/pci.h>
26#include <fsp/api.h>
27#include <fsp/util.h>
28#include <intelblocks/fast_spi.h>
29#include <soc/iomap.h>
30#include <soc/intel/common/vbt.h>
31#include <soc/pci_devs.h>
32#include <soc/ramstage.h>
33#include <soc/fiamux.h>
34#include <spi-generic.h>
Julien Viard de Galbert2d0aaa72018-02-26 18:32:59 +010035#include <soc/hob_mem.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +020036
37static void pci_domain_set_resources(device_t dev)
38{
39 assign_resources(dev->link_list);
40}
41
42static struct device_operations pci_domain_ops = {
43 .read_resources = &pci_domain_read_resources,
44 .set_resources = &pci_domain_set_resources,
45 .scan_bus = &pci_domain_scan_bus,
Mariusz Szafranskia4041332017-08-02 17:28:17 +020046};
47
48static struct device_operations cpu_bus_ops = {
49 .read_resources = DEVICE_NOOP,
50 .set_resources = DEVICE_NOOP,
51 .enable_resources = DEVICE_NOOP,
52 .init = denverton_init_cpus,
53 .scan_bus = NULL,
54#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
55 .acpi_fill_ssdt_generator = generate_cpu_entries,
56#endif
57};
58
59static void soc_enable_dev(device_t dev)
60{
61 /* Set the operations if it is a special bus type */
62 if (dev->path.type == DEVICE_PATH_DOMAIN)
63 dev->ops = &pci_domain_ops;
64 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
65 dev->ops = &cpu_bus_ops;
66}
67
Julien Viard de Galbert2d0aaa72018-02-26 18:32:59 +010068static void soc_init(void *data)
69{
70 fsp_silicon_init(false);
71 soc_save_dimm_info();
72}
Mariusz Szafranskia4041332017-08-02 17:28:17 +020073
74static void soc_final(void *data) {}
75
76static void soc_silicon_init_params(FSPS_UPD *silupd)
77{
78 size_t num;
79 uint16_t supported_hsio_lanes;
Mariusz Szafranskia4041332017-08-02 17:28:17 +020080 BL_HSIO_INFORMATION *hsio_config;
81 BL_FIA_MUX_CONFIG_HOB *fiamux_hob_data = get_fiamux_hob_data();
82
83 /* Configure FIA MUX PCD */
84 supported_hsio_lanes =
85 (uint16_t)fiamux_hob_data->FiaMuxConfig.SkuNumLanesAllowed;
86
Julien Viard de Galbertf5281952017-11-06 13:19:58 +010087 num = mainboard_get_hsio_config(&hsio_config);
Mariusz Szafranskia4041332017-08-02 17:28:17 +020088
89 if (get_fiamux_hsio_info(supported_hsio_lanes, num, &hsio_config))
90 die("HSIO Configuration is invalid, please correct it!");
91
92 /* Check the requested FIA MUX Configuration */
93 if (!(&hsio_config->FiaConfig)) {
94 die("Requested FIA MUX Configuration is invalid,"
95 " please correct it!");
96 }
97
98 /* Initialize PCIE Bifurcation & HSIO configuration */
99 silupd->FspsConfig.PcdBifurcationPcie0 = hsio_config->PcieBifCtr[0];
100 silupd->FspsConfig.PcdBifurcationPcie1 = hsio_config->PcieBifCtr[1];
101
102 silupd->FspsConfig.PcdFiaMuxConfigRequestPtr =
103 (uint32_t)&hsio_config->FiaConfig;
104}
105
106void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd)
107{
108 const struct microcode *microcode_file;
109 size_t microcode_len;
110
111 microcode_file = cbfs_boot_map_with_leak("cpu_microcode_blob.bin",
112 CBFS_TYPE_MICROCODE, &microcode_len);
113
114 if ((microcode_file != NULL) && (microcode_len != 0)) {
115 /* Update CPU Microcode patch base address/size */
116 silupd->FspsConfig.PcdCpuMicrocodePatchBase =
117 (uint32_t)microcode_file;
118 silupd->FspsConfig.PcdCpuMicrocodePatchSize =
119 (uint32_t)microcode_len;
120 }
121
122 soc_silicon_init_params(silupd);
123 mainboard_silicon_init_params(silupd);
124}
125
126struct chip_operations soc_intel_denverton_ns_ops = {
127 CHIP_NAME("Intel Denverton-NS SOC")
128 .enable_dev = &soc_enable_dev,
129 .init = &soc_init,
130 .final = &soc_final
131};
132
133static void soc_set_subsystem(device_t dev, uint32_t vendor, uint32_t device)
134{
135 if (!vendor || !device) {
136 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
137 pci_read_config32(dev, PCI_VENDOR_ID));
138 } else {
139 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
140 ((device & 0xffff) << 16) |
141 (vendor & 0xffff));
142 }
143}
144
145struct pci_operations soc_pci_ops = {
146 .set_subsystem = soc_set_subsystem,
147};
148
149/*
150 * spi_flash init() needs to run unconditionally on every boot (including
151 * resume) to allow write protect to be disabled for eventlog and nvram
152 * updates. This needs to be done as early as possible in ramstage. Thus, add a
153 * callback for entry into BS_PRE_DEVICE.
154 */
155static void spi_flash_init_cb(void *unused)
156{
157 fast_spi_init();
158}
159
160BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_ENTRY, spi_flash_init_cb, NULL);