blob: 6600ba2574bfbca223f33822ee0677c65b7d0287 [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>
Mariusz Szafranskia4041332017-08-02 17:28:17 +020035
36static void pci_domain_set_resources(device_t dev)
37{
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,
53#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
54 .acpi_fill_ssdt_generator = generate_cpu_entries,
55#endif
56};
57
58static void soc_enable_dev(device_t dev)
59{
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
67static void soc_init(void *data) { fsp_silicon_init(false); }
68
69static void soc_final(void *data) {}
70
71static void soc_silicon_init_params(FSPS_UPD *silupd)
72{
73 size_t num;
74 uint16_t supported_hsio_lanes;
Mariusz Szafranskia4041332017-08-02 17:28:17 +020075 BL_HSIO_INFORMATION *hsio_config;
76 BL_FIA_MUX_CONFIG_HOB *fiamux_hob_data = get_fiamux_hob_data();
77
78 /* Configure FIA MUX PCD */
79 supported_hsio_lanes =
80 (uint16_t)fiamux_hob_data->FiaMuxConfig.SkuNumLanesAllowed;
81
Julien Viard de Galbertf5281952017-11-06 13:19:58 +010082 num = mainboard_get_hsio_config(&hsio_config);
Mariusz Szafranskia4041332017-08-02 17:28:17 +020083
84 if (get_fiamux_hsio_info(supported_hsio_lanes, num, &hsio_config))
85 die("HSIO Configuration is invalid, please correct it!");
86
87 /* Check the requested FIA MUX Configuration */
88 if (!(&hsio_config->FiaConfig)) {
89 die("Requested FIA MUX Configuration is invalid,"
90 " please correct it!");
91 }
92
93 /* Initialize PCIE Bifurcation & HSIO configuration */
94 silupd->FspsConfig.PcdBifurcationPcie0 = hsio_config->PcieBifCtr[0];
95 silupd->FspsConfig.PcdBifurcationPcie1 = hsio_config->PcieBifCtr[1];
96
97 silupd->FspsConfig.PcdFiaMuxConfigRequestPtr =
98 (uint32_t)&hsio_config->FiaConfig;
99}
100
101void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd)
102{
103 const struct microcode *microcode_file;
104 size_t microcode_len;
105
106 microcode_file = cbfs_boot_map_with_leak("cpu_microcode_blob.bin",
107 CBFS_TYPE_MICROCODE, &microcode_len);
108
109 if ((microcode_file != NULL) && (microcode_len != 0)) {
110 /* Update CPU Microcode patch base address/size */
111 silupd->FspsConfig.PcdCpuMicrocodePatchBase =
112 (uint32_t)microcode_file;
113 silupd->FspsConfig.PcdCpuMicrocodePatchSize =
114 (uint32_t)microcode_len;
115 }
116
117 soc_silicon_init_params(silupd);
118 mainboard_silicon_init_params(silupd);
119}
120
121struct chip_operations soc_intel_denverton_ns_ops = {
122 CHIP_NAME("Intel Denverton-NS SOC")
123 .enable_dev = &soc_enable_dev,
124 .init = &soc_init,
125 .final = &soc_final
126};
127
128static void soc_set_subsystem(device_t dev, uint32_t vendor, uint32_t device)
129{
130 if (!vendor || !device) {
131 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
132 pci_read_config32(dev, PCI_VENDOR_ID));
133 } else {
134 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
135 ((device & 0xffff) << 16) |
136 (vendor & 0xffff));
137 }
138}
139
140struct pci_operations soc_pci_ops = {
141 .set_subsystem = soc_set_subsystem,
142};
143
144/*
145 * spi_flash init() needs to run unconditionally on every boot (including
146 * resume) to allow write protect to be disabled for eventlog and nvram
147 * updates. This needs to be done as early as possible in ramstage. Thus, add a
148 * callback for entry into BS_PRE_DEVICE.
149 */
150static void spi_flash_init_cb(void *unused)
151{
152 fast_spi_init();
153}
154
155BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_ENTRY, spi_flash_init_cb, NULL);