Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
| 16 | #include <arch/acpi.h> |
| 17 | #include <bootstate.h> |
| 18 | #include <cbfs.h> |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 19 | #include <console/console.h> |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 20 | #include <device/device.h> |
| 21 | #include <device/pci.h> |
| 22 | #include <fsp/api.h> |
| 23 | #include <fsp/util.h> |
| 24 | #include <intelblocks/fast_spi.h> |
| 25 | #include <soc/iomap.h> |
| 26 | #include <soc/intel/common/vbt.h> |
| 27 | #include <soc/pci_devs.h> |
| 28 | #include <soc/ramstage.h> |
| 29 | #include <soc/fiamux.h> |
| 30 | #include <spi-generic.h> |
Julien Viard de Galbert | 2d0aaa7 | 2018-02-26 18:32:59 +0100 | [diff] [blame] | 31 | #include <soc/hob_mem.h> |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 32 | |
Elyes HAOUAS | 2ec4183 | 2018-05-27 17:40:58 +0200 | [diff] [blame] | 33 | static void pci_domain_set_resources(struct device *dev) |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 34 | { |
| 35 | assign_resources(dev->link_list); |
| 36 | } |
| 37 | |
| 38 | static struct device_operations pci_domain_ops = { |
| 39 | .read_resources = &pci_domain_read_resources, |
| 40 | .set_resources = &pci_domain_set_resources, |
| 41 | .scan_bus = &pci_domain_scan_bus, |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | static struct device_operations cpu_bus_ops = { |
Nico Huber | 2f8ba69 | 2020-04-05 14:05:24 +0200 | [diff] [blame] | 45 | .read_resources = noop_read_resources, |
| 46 | .set_resources = noop_set_resources, |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 47 | .init = denverton_init_cpus, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 48 | #if CONFIG(HAVE_ACPI_TABLES) |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 49 | .acpi_fill_ssdt = generate_cpu_entries, |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 50 | #endif |
| 51 | }; |
| 52 | |
Elyes HAOUAS | 2ec4183 | 2018-05-27 17:40:58 +0200 | [diff] [blame] | 53 | static void soc_enable_dev(struct device *dev) |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 54 | { |
| 55 | /* Set the operations if it is a special bus type */ |
| 56 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 57 | dev->ops = &pci_domain_ops; |
| 58 | else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) |
| 59 | dev->ops = &cpu_bus_ops; |
| 60 | } |
| 61 | |
Julien Viard de Galbert | 2d0aaa7 | 2018-02-26 18:32:59 +0100 | [diff] [blame] | 62 | static void soc_init(void *data) |
| 63 | { |
| 64 | fsp_silicon_init(false); |
| 65 | soc_save_dimm_info(); |
| 66 | } |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 67 | |
| 68 | static void soc_final(void *data) {} |
| 69 | |
| 70 | static void soc_silicon_init_params(FSPS_UPD *silupd) |
| 71 | { |
| 72 | size_t num; |
| 73 | uint16_t supported_hsio_lanes; |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 74 | BL_HSIO_INFORMATION *hsio_config; |
| 75 | BL_FIA_MUX_CONFIG_HOB *fiamux_hob_data = get_fiamux_hob_data(); |
| 76 | |
| 77 | /* Configure FIA MUX PCD */ |
| 78 | supported_hsio_lanes = |
| 79 | (uint16_t)fiamux_hob_data->FiaMuxConfig.SkuNumLanesAllowed; |
| 80 | |
Julien Viard de Galbert | f528195 | 2017-11-06 13:19:58 +0100 | [diff] [blame] | 81 | num = mainboard_get_hsio_config(&hsio_config); |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 82 | |
| 83 | if (get_fiamux_hsio_info(supported_hsio_lanes, num, &hsio_config)) |
| 84 | die("HSIO Configuration is invalid, please correct it!"); |
| 85 | |
| 86 | /* Check the requested FIA MUX Configuration */ |
| 87 | if (!(&hsio_config->FiaConfig)) { |
| 88 | die("Requested FIA MUX Configuration is invalid," |
| 89 | " please correct it!"); |
| 90 | } |
| 91 | |
| 92 | /* Initialize PCIE Bifurcation & HSIO configuration */ |
| 93 | silupd->FspsConfig.PcdBifurcationPcie0 = hsio_config->PcieBifCtr[0]; |
| 94 | silupd->FspsConfig.PcdBifurcationPcie1 = hsio_config->PcieBifCtr[1]; |
| 95 | |
| 96 | silupd->FspsConfig.PcdFiaMuxConfigRequestPtr = |
| 97 | (uint32_t)&hsio_config->FiaConfig; |
| 98 | } |
| 99 | |
| 100 | void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd) |
| 101 | { |
| 102 | const struct microcode *microcode_file; |
| 103 | size_t microcode_len; |
| 104 | |
| 105 | microcode_file = cbfs_boot_map_with_leak("cpu_microcode_blob.bin", |
| 106 | CBFS_TYPE_MICROCODE, µcode_len); |
| 107 | |
| 108 | if ((microcode_file != NULL) && (microcode_len != 0)) { |
| 109 | /* Update CPU Microcode patch base address/size */ |
| 110 | silupd->FspsConfig.PcdCpuMicrocodePatchBase = |
| 111 | (uint32_t)microcode_file; |
| 112 | silupd->FspsConfig.PcdCpuMicrocodePatchSize = |
| 113 | (uint32_t)microcode_len; |
| 114 | } |
| 115 | |
| 116 | soc_silicon_init_params(silupd); |
| 117 | mainboard_silicon_init_params(silupd); |
| 118 | } |
| 119 | |
| 120 | struct chip_operations soc_intel_denverton_ns_ops = { |
| 121 | CHIP_NAME("Intel Denverton-NS SOC") |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 122 | .enable_dev = soc_enable_dev, |
| 123 | .init = soc_init, |
| 124 | .final = soc_final |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 125 | }; |
| 126 | |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 127 | struct pci_operations soc_pci_ops = { |
Subrata Banik | 4a0f071 | 2019-03-20 14:29:47 +0530 | [diff] [blame] | 128 | .set_subsystem = pci_dev_set_subsystem, |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 129 | }; |
| 130 | |
| 131 | /* |
| 132 | * spi_flash init() needs to run unconditionally on every boot (including |
| 133 | * resume) to allow write protect to be disabled for eventlog and nvram |
| 134 | * updates. This needs to be done as early as possible in ramstage. Thus, add a |
| 135 | * callback for entry into BS_PRE_DEVICE. |
| 136 | */ |
| 137 | static void spi_flash_init_cb(void *unused) |
| 138 | { |
| 139 | fast_spi_init(); |
| 140 | } |
| 141 | |
| 142 | BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_ENTRY, spi_flash_init_cb, NULL); |