blob: 68bd60c83a9e568649a6f756e4c3c668082a3603 [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>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020024#include <device/pci_ops.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +020025#include <fsp/api.h>
26#include <fsp/util.h>
27#include <intelblocks/fast_spi.h>
28#include <soc/iomap.h>
29#include <soc/intel/common/vbt.h>
30#include <soc/pci_devs.h>
31#include <soc/ramstage.h>
32#include <soc/fiamux.h>
33#include <spi-generic.h>
Julien Viard de Galbert2d0aaa72018-02-26 18:32:59 +010034#include <soc/hob_mem.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +020035
Elyes HAOUAS2ec41832018-05-27 17:40:58 +020036static void pci_domain_set_resources(struct device *dev)
Mariusz Szafranskia4041332017-08-02 17:28:17 +020037{
38 assign_resources(dev->link_list);
39}
40
41static struct device_operations pci_domain_ops = {
42 .read_resources = &pci_domain_read_resources,
43 .set_resources = &pci_domain_set_resources,
44 .scan_bus = &pci_domain_scan_bus,
Mariusz Szafranskia4041332017-08-02 17:28:17 +020045};
46
47static struct device_operations cpu_bus_ops = {
48 .read_resources = DEVICE_NOOP,
49 .set_resources = DEVICE_NOOP,
50 .enable_resources = DEVICE_NOOP,
51 .init = denverton_init_cpus,
52 .scan_bus = NULL,
Julius Wernercd49cce2019-03-05 16:53:33 -080053#if CONFIG(HAVE_ACPI_TABLES)
Mariusz Szafranskia4041332017-08-02 17:28:17 +020054 .acpi_fill_ssdt_generator = generate_cpu_entries,
55#endif
56};
57
Elyes HAOUAS2ec41832018-05-27 17:40:58 +020058static void soc_enable_dev(struct device *dev)
Mariusz Szafranskia4041332017-08-02 17:28:17 +020059{
60 /* Set the operations if it is a special bus type */
61 if (dev->path.type == DEVICE_PATH_DOMAIN)
62 dev->ops = &pci_domain_ops;
63 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
64 dev->ops = &cpu_bus_ops;
65}
66
Julien Viard de Galbert2d0aaa72018-02-26 18:32:59 +010067static void soc_init(void *data)
68{
69 fsp_silicon_init(false);
70 soc_save_dimm_info();
71}
Mariusz Szafranskia4041332017-08-02 17:28:17 +020072
73static void soc_final(void *data) {}
74
75static void soc_silicon_init_params(FSPS_UPD *silupd)
76{
77 size_t num;
78 uint16_t supported_hsio_lanes;
Mariusz Szafranskia4041332017-08-02 17:28:17 +020079 BL_HSIO_INFORMATION *hsio_config;
80 BL_FIA_MUX_CONFIG_HOB *fiamux_hob_data = get_fiamux_hob_data();
81
82 /* Configure FIA MUX PCD */
83 supported_hsio_lanes =
84 (uint16_t)fiamux_hob_data->FiaMuxConfig.SkuNumLanesAllowed;
85
Julien Viard de Galbertf5281952017-11-06 13:19:58 +010086 num = mainboard_get_hsio_config(&hsio_config);
Mariusz Szafranskia4041332017-08-02 17:28:17 +020087
88 if (get_fiamux_hsio_info(supported_hsio_lanes, num, &hsio_config))
89 die("HSIO Configuration is invalid, please correct it!");
90
91 /* Check the requested FIA MUX Configuration */
92 if (!(&hsio_config->FiaConfig)) {
93 die("Requested FIA MUX Configuration is invalid,"
94 " please correct it!");
95 }
96
97 /* Initialize PCIE Bifurcation & HSIO configuration */
98 silupd->FspsConfig.PcdBifurcationPcie0 = hsio_config->PcieBifCtr[0];
99 silupd->FspsConfig.PcdBifurcationPcie1 = hsio_config->PcieBifCtr[1];
100
101 silupd->FspsConfig.PcdFiaMuxConfigRequestPtr =
102 (uint32_t)&hsio_config->FiaConfig;
103}
104
105void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd)
106{
107 const struct microcode *microcode_file;
108 size_t microcode_len;
109
110 microcode_file = cbfs_boot_map_with_leak("cpu_microcode_blob.bin",
111 CBFS_TYPE_MICROCODE, &microcode_len);
112
113 if ((microcode_file != NULL) && (microcode_len != 0)) {
114 /* Update CPU Microcode patch base address/size */
115 silupd->FspsConfig.PcdCpuMicrocodePatchBase =
116 (uint32_t)microcode_file;
117 silupd->FspsConfig.PcdCpuMicrocodePatchSize =
118 (uint32_t)microcode_len;
119 }
120
121 soc_silicon_init_params(silupd);
122 mainboard_silicon_init_params(silupd);
123}
124
125struct chip_operations soc_intel_denverton_ns_ops = {
126 CHIP_NAME("Intel Denverton-NS SOC")
Elyes HAOUAS1d191272018-11-27 12:23:48 +0100127 .enable_dev = soc_enable_dev,
128 .init = soc_init,
129 .final = soc_final
Mariusz Szafranskia4041332017-08-02 17:28:17 +0200130};
131
Elyes HAOUAS2ec41832018-05-27 17:40:58 +0200132static void soc_set_subsystem(struct device *dev, uint32_t vendor,
133 uint32_t device)
Mariusz Szafranskia4041332017-08-02 17:28:17 +0200134{
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);