Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 2 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 3 | #include <acpi/acpi.h> |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 4 | #include <bootstate.h> |
| 5 | #include <cbfs.h> |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 6 | #include <console/console.h> |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 7 | #include <device/device.h> |
| 8 | #include <device/pci.h> |
| 9 | #include <fsp/api.h> |
| 10 | #include <fsp/util.h> |
| 11 | #include <intelblocks/fast_spi.h> |
Michael Niewöhner | fc862dd | 2020-12-11 22:13:44 +0100 | [diff] [blame^] | 12 | #include <intelblocks/gpio.h> |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 13 | #include <soc/iomap.h> |
| 14 | #include <soc/intel/common/vbt.h> |
| 15 | #include <soc/pci_devs.h> |
| 16 | #include <soc/ramstage.h> |
| 17 | #include <soc/fiamux.h> |
| 18 | #include <spi-generic.h> |
Julien Viard de Galbert | 2d0aaa7 | 2018-02-26 18:32:59 +0100 | [diff] [blame] | 19 | #include <soc/hob_mem.h> |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 20 | |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 21 | static struct device_operations pci_domain_ops = { |
| 22 | .read_resources = &pci_domain_read_resources, |
| 23 | .set_resources = &pci_domain_set_resources, |
| 24 | .scan_bus = &pci_domain_scan_bus, |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 25 | }; |
| 26 | |
| 27 | static struct device_operations cpu_bus_ops = { |
Nico Huber | 2f8ba69 | 2020-04-05 14:05:24 +0200 | [diff] [blame] | 28 | .read_resources = noop_read_resources, |
| 29 | .set_resources = noop_set_resources, |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 30 | .init = denverton_init_cpus, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 31 | #if CONFIG(HAVE_ACPI_TABLES) |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 32 | .acpi_fill_ssdt = generate_cpu_entries, |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 33 | #endif |
| 34 | }; |
| 35 | |
Elyes HAOUAS | 2ec4183 | 2018-05-27 17:40:58 +0200 | [diff] [blame] | 36 | static void soc_enable_dev(struct device *dev) |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 37 | { |
| 38 | /* Set the operations if it is a special bus type */ |
| 39 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 40 | dev->ops = &pci_domain_ops; |
| 41 | else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) |
| 42 | dev->ops = &cpu_bus_ops; |
Michael Niewöhner | fc862dd | 2020-12-11 22:13:44 +0100 | [diff] [blame^] | 43 | else if (dev->path.type == DEVICE_PATH_GPIO) |
| 44 | block_gpio_enable(dev); |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 45 | } |
| 46 | |
Julien Viard de Galbert | 2d0aaa7 | 2018-02-26 18:32:59 +0100 | [diff] [blame] | 47 | static void soc_init(void *data) |
| 48 | { |
Kyösti Mälkki | cc93c6e | 2021-01-09 22:53:52 +0200 | [diff] [blame] | 49 | fsp_silicon_init(); |
Julien Viard de Galbert | 2d0aaa7 | 2018-02-26 18:32:59 +0100 | [diff] [blame] | 50 | soc_save_dimm_info(); |
| 51 | } |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 52 | |
| 53 | static void soc_final(void *data) {} |
| 54 | |
| 55 | static void soc_silicon_init_params(FSPS_UPD *silupd) |
| 56 | { |
| 57 | size_t num; |
| 58 | uint16_t supported_hsio_lanes; |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 59 | BL_HSIO_INFORMATION *hsio_config; |
| 60 | BL_FIA_MUX_CONFIG_HOB *fiamux_hob_data = get_fiamux_hob_data(); |
| 61 | |
| 62 | /* Configure FIA MUX PCD */ |
| 63 | supported_hsio_lanes = |
| 64 | (uint16_t)fiamux_hob_data->FiaMuxConfig.SkuNumLanesAllowed; |
| 65 | |
Julien Viard de Galbert | f528195 | 2017-11-06 13:19:58 +0100 | [diff] [blame] | 66 | num = mainboard_get_hsio_config(&hsio_config); |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 67 | |
| 68 | if (get_fiamux_hsio_info(supported_hsio_lanes, num, &hsio_config)) |
| 69 | die("HSIO Configuration is invalid, please correct it!"); |
| 70 | |
| 71 | /* Check the requested FIA MUX Configuration */ |
| 72 | if (!(&hsio_config->FiaConfig)) { |
| 73 | die("Requested FIA MUX Configuration is invalid," |
| 74 | " please correct it!"); |
| 75 | } |
| 76 | |
| 77 | /* Initialize PCIE Bifurcation & HSIO configuration */ |
| 78 | silupd->FspsConfig.PcdBifurcationPcie0 = hsio_config->PcieBifCtr[0]; |
| 79 | silupd->FspsConfig.PcdBifurcationPcie1 = hsio_config->PcieBifCtr[1]; |
| 80 | |
| 81 | silupd->FspsConfig.PcdFiaMuxConfigRequestPtr = |
| 82 | (uint32_t)&hsio_config->FiaConfig; |
| 83 | } |
| 84 | |
| 85 | void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd) |
| 86 | { |
| 87 | const struct microcode *microcode_file; |
| 88 | size_t microcode_len; |
| 89 | |
Julius Werner | 834b3ec | 2020-03-04 16:52:08 -0800 | [diff] [blame] | 90 | microcode_file = cbfs_map("cpu_microcode_blob.bin", µcode_len); |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 91 | |
| 92 | if ((microcode_file != NULL) && (microcode_len != 0)) { |
| 93 | /* Update CPU Microcode patch base address/size */ |
| 94 | silupd->FspsConfig.PcdCpuMicrocodePatchBase = |
| 95 | (uint32_t)microcode_file; |
| 96 | silupd->FspsConfig.PcdCpuMicrocodePatchSize = |
| 97 | (uint32_t)microcode_len; |
| 98 | } |
| 99 | |
| 100 | soc_silicon_init_params(silupd); |
| 101 | mainboard_silicon_init_params(silupd); |
| 102 | } |
| 103 | |
| 104 | struct chip_operations soc_intel_denverton_ns_ops = { |
| 105 | CHIP_NAME("Intel Denverton-NS SOC") |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 106 | .enable_dev = soc_enable_dev, |
| 107 | .init = soc_init, |
| 108 | .final = soc_final |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 109 | }; |
| 110 | |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 111 | struct pci_operations soc_pci_ops = { |
Subrata Banik | 4a0f071 | 2019-03-20 14:29:47 +0530 | [diff] [blame] | 112 | .set_subsystem = pci_dev_set_subsystem, |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 113 | }; |
| 114 | |
| 115 | /* |
| 116 | * spi_flash init() needs to run unconditionally on every boot (including |
| 117 | * resume) to allow write protect to be disabled for eventlog and nvram |
| 118 | * updates. This needs to be done as early as possible in ramstage. Thus, add a |
| 119 | * callback for entry into BS_PRE_DEVICE. |
| 120 | */ |
| 121 | static void spi_flash_init_cb(void *unused) |
| 122 | { |
| 123 | fast_spi_init(); |
| 124 | } |
| 125 | |
| 126 | BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_ENTRY, spi_flash_init_cb, NULL); |