Felix Held | 2421de6 | 2021-03-26 01:13:53 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <amdblocks/apob_cache.h> |
| 4 | #include <amdblocks/memmap.h> |
Matt Papageorge | ea0f225 | 2021-03-30 11:41:22 -0500 | [diff] [blame] | 5 | #include <assert.h> |
Felix Held | 2421de6 | 2021-03-26 01:13:53 +0100 | [diff] [blame] | 6 | #include <console/uart.h> |
| 7 | #include <fsp/api.h> |
Matt Papageorge | ea0f225 | 2021-03-30 11:41:22 -0500 | [diff] [blame] | 8 | #include <soc/platform_descriptors.h> |
| 9 | #include <string.h> |
| 10 | #include <types.h> |
| 11 | |
| 12 | static void fill_dxio_descriptors(FSP_M_CONFIG *mcfg, |
| 13 | const fsp_dxio_descriptor *descs, size_t num) |
| 14 | { |
| 15 | size_t i; |
| 16 | |
| 17 | ASSERT_MSG(num <= FSPM_UPD_DXIO_DESCRIPTOR_COUNT, |
| 18 | "Too many DXIO descriptors provided."); |
| 19 | |
| 20 | for (i = 0; i < num; i++) { |
| 21 | memcpy(mcfg->dxio_descriptor[i], &descs[i], sizeof(mcfg->dxio_descriptor[0])); |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | static void fill_ddi_descriptors(FSP_M_CONFIG *mcfg, |
| 26 | const fsp_ddi_descriptor *descs, size_t num) |
| 27 | { |
| 28 | size_t i; |
| 29 | |
| 30 | ASSERT_MSG(num <= FSPM_UPD_DDI_DESCRIPTOR_COUNT, |
| 31 | "Too many DDI descriptors provided."); |
| 32 | |
| 33 | for (i = 0; i < num; i++) { |
| 34 | memcpy(&mcfg->ddi_descriptor[i], &descs[i], sizeof(mcfg->ddi_descriptor[0])); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | static void fsp_fill_pcie_ddi_descriptors(FSP_M_CONFIG *mcfg) |
| 39 | { |
| 40 | const fsp_dxio_descriptor *fsp_dxio; |
| 41 | const fsp_ddi_descriptor *fsp_ddi; |
| 42 | size_t num_dxio; |
| 43 | size_t num_ddi; |
| 44 | |
| 45 | mainboard_get_dxio_ddi_descriptors(&fsp_dxio, &num_dxio, |
| 46 | &fsp_ddi, &num_ddi); |
| 47 | fill_dxio_descriptors(mcfg, fsp_dxio, num_dxio); |
| 48 | fill_ddi_descriptors(mcfg, fsp_ddi, num_ddi); |
| 49 | } |
Felix Held | 2421de6 | 2021-03-26 01:13:53 +0100 | [diff] [blame] | 50 | |
| 51 | void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version) |
| 52 | { |
| 53 | FSP_M_CONFIG *mcfg = &mupd->FspmConfig; |
| 54 | |
| 55 | mupd->FspmArchUpd.NvsBufferPtr = (uintptr_t)soc_fill_apob_cache(); |
| 56 | |
| 57 | mcfg->pci_express_base_addr = CONFIG_MMCONF_BASE_ADDRESS; |
| 58 | mcfg->tseg_size = CONFIG_SMM_TSEG_SIZE; |
| 59 | mcfg->bert_size = CONFIG_ACPI_BERT_SIZE; |
| 60 | mcfg->serial_port_base = uart_platform_base(CONFIG_UART_FOR_CONSOLE); |
| 61 | mcfg->serial_port_use_mmio = CONFIG(DRIVERS_UART_8250MEM); |
Felix Held | 2421de6 | 2021-03-26 01:13:53 +0100 | [diff] [blame] | 62 | mcfg->serial_port_baudrate = get_uart_baudrate(); |
| 63 | mcfg->serial_port_refclk = uart_platform_refclk(); |
Matt Papageorge | ea0f225 | 2021-03-30 11:41:22 -0500 | [diff] [blame] | 64 | |
| 65 | fsp_fill_pcie_ddi_descriptors(mcfg); |
Felix Held | 2421de6 | 2021-03-26 01:13:53 +0100 | [diff] [blame] | 66 | } |