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> |
Felix Held | 1ed5a63 | 2021-05-04 21:51:43 +0200 | [diff] [blame] | 4 | #include <amdblocks/ioapic.h> |
Felix Held | 2421de6 | 2021-03-26 01:13:53 +0100 | [diff] [blame] | 5 | #include <amdblocks/memmap.h> |
Matt Papageorge | ea0f225 | 2021-03-30 11:41:22 -0500 | [diff] [blame] | 6 | #include <assert.h> |
Felix Held | 2421de6 | 2021-03-26 01:13:53 +0100 | [diff] [blame] | 7 | #include <console/uart.h> |
Felix Held | d0b5164 | 2021-04-08 22:25:19 +0200 | [diff] [blame] | 8 | #include <device/device.h> |
Felix Held | 2421de6 | 2021-03-26 01:13:53 +0100 | [diff] [blame] | 9 | #include <fsp/api.h> |
Matt Papageorge | ea0f225 | 2021-03-30 11:41:22 -0500 | [diff] [blame] | 10 | #include <soc/platform_descriptors.h> |
| 11 | #include <string.h> |
| 12 | #include <types.h> |
Felix Held | d0b5164 | 2021-04-08 22:25:19 +0200 | [diff] [blame] | 13 | #include "chip.h" |
Matt Papageorge | ea0f225 | 2021-03-30 11:41:22 -0500 | [diff] [blame] | 14 | |
| 15 | static void fill_dxio_descriptors(FSP_M_CONFIG *mcfg, |
| 16 | const fsp_dxio_descriptor *descs, size_t num) |
| 17 | { |
| 18 | size_t i; |
| 19 | |
| 20 | ASSERT_MSG(num <= FSPM_UPD_DXIO_DESCRIPTOR_COUNT, |
| 21 | "Too many DXIO descriptors provided."); |
| 22 | |
| 23 | for (i = 0; i < num; i++) { |
| 24 | memcpy(mcfg->dxio_descriptor[i], &descs[i], sizeof(mcfg->dxio_descriptor[0])); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | static void fill_ddi_descriptors(FSP_M_CONFIG *mcfg, |
| 29 | const fsp_ddi_descriptor *descs, size_t num) |
| 30 | { |
| 31 | size_t i; |
| 32 | |
| 33 | ASSERT_MSG(num <= FSPM_UPD_DDI_DESCRIPTOR_COUNT, |
| 34 | "Too many DDI descriptors provided."); |
| 35 | |
| 36 | for (i = 0; i < num; i++) { |
| 37 | memcpy(&mcfg->ddi_descriptor[i], &descs[i], sizeof(mcfg->ddi_descriptor[0])); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | static void fsp_fill_pcie_ddi_descriptors(FSP_M_CONFIG *mcfg) |
| 42 | { |
| 43 | const fsp_dxio_descriptor *fsp_dxio; |
| 44 | const fsp_ddi_descriptor *fsp_ddi; |
| 45 | size_t num_dxio; |
| 46 | size_t num_ddi; |
| 47 | |
| 48 | mainboard_get_dxio_ddi_descriptors(&fsp_dxio, &num_dxio, |
| 49 | &fsp_ddi, &num_ddi); |
| 50 | fill_dxio_descriptors(mcfg, fsp_dxio, num_dxio); |
| 51 | fill_ddi_descriptors(mcfg, fsp_ddi, num_ddi); |
| 52 | } |
Felix Held | 2421de6 | 2021-03-26 01:13:53 +0100 | [diff] [blame] | 53 | |
Felix Held | 1ed5a63 | 2021-05-04 21:51:43 +0200 | [diff] [blame] | 54 | static void fsp_assign_ioapic_upds(FSP_M_CONFIG *mcfg) |
| 55 | { |
| 56 | mcfg->gnb_ioapic_base = GNB_IO_APIC_ADDR; |
| 57 | mcfg->gnb_ioapic_id = GNB_IOAPIC_ID; |
| 58 | mcfg->fch_ioapic_id = FCH_IOAPIC_ID; |
| 59 | } |
| 60 | |
Felix Held | 2421de6 | 2021-03-26 01:13:53 +0100 | [diff] [blame] | 61 | void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version) |
| 62 | { |
| 63 | FSP_M_CONFIG *mcfg = &mupd->FspmConfig; |
Felix Held | d0b5164 | 2021-04-08 22:25:19 +0200 | [diff] [blame] | 64 | const struct soc_amd_cezanne_config *config = config_of_soc(); |
Felix Held | 2421de6 | 2021-03-26 01:13:53 +0100 | [diff] [blame] | 65 | |
| 66 | mupd->FspmArchUpd.NvsBufferPtr = (uintptr_t)soc_fill_apob_cache(); |
| 67 | |
| 68 | mcfg->pci_express_base_addr = CONFIG_MMCONF_BASE_ADDRESS; |
| 69 | mcfg->tseg_size = CONFIG_SMM_TSEG_SIZE; |
| 70 | mcfg->bert_size = CONFIG_ACPI_BERT_SIZE; |
| 71 | mcfg->serial_port_base = uart_platform_base(CONFIG_UART_FOR_CONSOLE); |
| 72 | mcfg->serial_port_use_mmio = CONFIG(DRIVERS_UART_8250MEM); |
Felix Held | 2421de6 | 2021-03-26 01:13:53 +0100 | [diff] [blame] | 73 | mcfg->serial_port_baudrate = get_uart_baudrate(); |
| 74 | mcfg->serial_port_refclk = uart_platform_refclk(); |
Matt Papageorge | ea0f225 | 2021-03-30 11:41:22 -0500 | [diff] [blame] | 75 | |
Felix Held | d0b5164 | 2021-04-08 22:25:19 +0200 | [diff] [blame] | 76 | /* 0 is default */ |
| 77 | mcfg->ccx_down_core_mode = config->downcore_mode; |
| 78 | mcfg->ccx_disable_smt = config->disable_smt; |
| 79 | |
Felix Held | d3be9ba | 2021-04-19 21:40:35 +0200 | [diff] [blame] | 80 | /* when stt_control isn't 1, FSP will ignore the other stt values */ |
| 81 | mcfg->stt_control = config->stt_control; |
| 82 | mcfg->stt_pcb_sensor_count = config->stt_pcb_sensor_count; |
| 83 | mcfg->stt_min_limit = config->stt_min_limit; |
| 84 | mcfg->stt_m1 = config->stt_m1; |
| 85 | mcfg->stt_m2 = config->stt_m2; |
| 86 | mcfg->stt_m3 = config->stt_m3; |
| 87 | mcfg->stt_m4 = config->stt_m4; |
| 88 | mcfg->stt_m5 = config->stt_m5; |
| 89 | mcfg->stt_m6 = config->stt_m6; |
| 90 | mcfg->stt_c_apu = config->stt_c_apu; |
| 91 | mcfg->stt_c_gpu = config->stt_c_gpu; |
| 92 | mcfg->stt_c_hs2 = config->stt_c_hs2; |
| 93 | mcfg->stt_alpha_apu = config->stt_alpha_apu; |
| 94 | mcfg->stt_alpha_gpu = config->stt_alpha_gpu; |
| 95 | mcfg->stt_alpha_hs2 = config->stt_alpha_hs2; |
| 96 | mcfg->stt_skin_temp_apu = config->stt_skin_temp_apu; |
| 97 | mcfg->stt_skin_temp_gpu = config->stt_skin_temp_gpu; |
| 98 | mcfg->stt_skin_temp_hs2 = config->stt_skin_temp_hs2; |
| 99 | mcfg->stt_error_coeff = config->stt_error_coeff; |
| 100 | mcfg->stt_error_rate_coefficient = config->stt_error_rate_coefficient; |
| 101 | |
| 102 | /* all following fields being 0 is a valid config */ |
| 103 | mcfg->stapm_boost = config->stapm_boost; |
Martin Roth | 9c17665 | 2021-04-23 12:24:35 -0600 | [diff] [blame] | 104 | mcfg->stapm_time_constant = config->stapm_time_constant_s; |
Felix Held | d3be9ba | 2021-04-19 21:40:35 +0200 | [diff] [blame] | 105 | mcfg->apu_only_sppt_limit = config->apu_only_sppt_limit; |
Martin Roth | 9c17665 | 2021-04-23 12:24:35 -0600 | [diff] [blame] | 106 | mcfg->sustained_power_limit = config->sustained_power_limit_mW; |
| 107 | mcfg->fast_ppt_limit = config->fast_ppt_limit_mW; |
| 108 | mcfg->slow_ppt_limit = config->slow_ppt_limit_mW; |
Martin Roth | 029d997 | 2021-04-23 12:22:59 -0600 | [diff] [blame] | 109 | mcfg->slow_ppt_time_constant = config->slow_ppt_time_constant_s; |
| 110 | mcfg->thermctl_limit = config->thermctl_limit_degreeC; |
Felix Held | d3be9ba | 2021-04-19 21:40:35 +0200 | [diff] [blame] | 111 | |
| 112 | /* 0 is default */ |
| 113 | mcfg->smartshift_enable = config->smartshift_enable; |
| 114 | |
| 115 | /* 0 is default */ |
| 116 | mcfg->system_configuration = config->system_configuration; |
| 117 | |
| 118 | /* when cppc_ctrl is 0 the other values won't be used */ |
| 119 | mcfg->cppc_ctrl = config->cppc_ctrl; |
| 120 | mcfg->cppc_perf_limit_max_range = config->cppc_perf_limit_max_range; |
| 121 | mcfg->cppc_perf_limit_min_range = config->cppc_perf_limit_min_range; |
| 122 | mcfg->cppc_epp_max_range = config->cppc_epp_max_range; |
| 123 | mcfg->cppc_epp_min_range = config->cppc_epp_min_range; |
| 124 | mcfg->cppc_preferred_cores = config->cppc_preferred_cores; |
| 125 | |
Karthikeyan Ramasubramanian | 5ad85d9 | 2021-04-22 16:59:08 -0600 | [diff] [blame] | 126 | /* S0i3 enable */ |
| 127 | mcfg->s0i3_enable = config->s0ix_enable; |
| 128 | |
Chris Wang | 0679392 | 2021-04-29 00:11:01 +0800 | [diff] [blame] | 129 | /* voltage regulator telemetry settings */ |
| 130 | mcfg->telemetry_vddcrvddfull_scale_current = |
| 131 | config->telemetry_vddcrvddfull_scale_current_mA; |
| 132 | mcfg->telemetry_vddcrvddoffset = |
| 133 | config->telemetry_vddcrvddoffset; |
| 134 | mcfg->telemetry_vddcrsocfull_scale_current = |
| 135 | config->telemetry_vddcrsocfull_scale_current_mA; |
| 136 | mcfg->telemetry_vddcrsocOffset = |
| 137 | config->telemetry_vddcrsocoffset; |
| 138 | |
Matt Papageorge | ea0f225 | 2021-03-30 11:41:22 -0500 | [diff] [blame] | 139 | fsp_fill_pcie_ddi_descriptors(mcfg); |
Felix Held | 1ed5a63 | 2021-05-04 21:51:43 +0200 | [diff] [blame] | 140 | fsp_assign_ioapic_upds(mcfg); |
Felix Held | 2421de6 | 2021-03-26 01:13:53 +0100 | [diff] [blame] | 141 | } |