Felix Held | dd73714 | 2021-03-26 00:44:35 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <amdblocks/apob_cache.h> |
| 4 | #include <commonlib/helpers.h> |
| 5 | #include <console/uart.h> |
| 6 | #include <device/device.h> |
| 7 | #include <fsp/api.h> |
| 8 | #include <soc/pci_devs.h> |
| 9 | #include <soc/fsp.h> |
| 10 | #include <types.h> |
| 11 | #include "chip.h" |
| 12 | |
| 13 | void __weak mainboard_updm_update(FSP_M_CONFIG *mupd) {} |
| 14 | |
| 15 | static const struct device_path hda_path[] = { |
| 16 | { |
| 17 | .type = DEVICE_PATH_PCI, |
| 18 | .pci.devfn = PCIE_GPP_A_DEVFN |
| 19 | }, |
| 20 | { |
| 21 | .type = DEVICE_PATH_PCI, |
| 22 | .pci.devfn = HD_AUDIO_DEVFN |
| 23 | }, |
| 24 | }; |
| 25 | |
| 26 | static bool devtree_hda_dev_enabled(void) |
| 27 | { |
| 28 | const struct device *hda_dev; |
| 29 | |
| 30 | hda_dev = find_dev_nested_path(pci_root_bus(), hda_path, ARRAY_SIZE(hda_path)); |
| 31 | |
| 32 | if (!hda_dev) |
| 33 | return false; |
| 34 | |
| 35 | return hda_dev->enabled; |
| 36 | } |
| 37 | |
| 38 | |
| 39 | static const struct device_path sata_path[] = { |
| 40 | { |
| 41 | .type = DEVICE_PATH_PCI, |
| 42 | .pci.devfn = PCIE_GPP_B_DEVFN |
| 43 | }, |
| 44 | { |
| 45 | .type = DEVICE_PATH_PCI, |
| 46 | .pci.devfn = SATA_DEVFN |
| 47 | }, |
| 48 | }; |
| 49 | |
| 50 | static bool devtree_sata_dev_enabled(void) |
| 51 | { |
| 52 | const struct device *ahci_dev; |
| 53 | |
| 54 | ahci_dev = find_dev_nested_path(pci_root_bus(), sata_path, ARRAY_SIZE(sata_path)); |
| 55 | |
| 56 | if (!ahci_dev) |
| 57 | return false; |
| 58 | |
| 59 | return ahci_dev->enabled; |
| 60 | } |
| 61 | |
| 62 | void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version) |
| 63 | { |
| 64 | FSP_M_CONFIG *mcfg = &mupd->FspmConfig; |
| 65 | const struct soc_amd_picasso_config *config = config_of_soc(); |
| 66 | |
| 67 | mupd->FspmArchUpd.NvsBufferPtr = (uintptr_t)soc_fill_apob_cache(); |
| 68 | |
| 69 | mcfg->pci_express_base_addr = CONFIG_MMCONF_BASE_ADDRESS; |
| 70 | mcfg->tseg_size = CONFIG_SMM_TSEG_SIZE; |
| 71 | mcfg->bert_size = CONFIG_ACPI_BERT_SIZE; |
| 72 | mcfg->serial_port_base = uart_platform_base(CONFIG_UART_FOR_CONSOLE); |
| 73 | mcfg->serial_port_use_mmio = CONFIG(DRIVERS_UART_8250MEM); |
| 74 | mcfg->serial_port_stride = CONFIG(DRIVERS_UART_8250MEM_32) ? 4 : 1; |
| 75 | mcfg->serial_port_baudrate = get_uart_baudrate(); |
| 76 | mcfg->serial_port_refclk = uart_platform_refclk(); |
| 77 | |
| 78 | mcfg->system_config = config->system_config; |
| 79 | |
| 80 | if ((config->slow_ppt_limit_mW) && |
| 81 | (config->fast_ppt_limit_mW) && |
| 82 | (config->slow_ppt_time_constant_s) && |
| 83 | (config->stapm_time_constant_s)) { |
| 84 | mcfg->slow_ppt_limit_mW = config->slow_ppt_limit_mW; |
| 85 | mcfg->fast_ppt_limit_mW = config->fast_ppt_limit_mW; |
| 86 | mcfg->slow_ppt_time_constant_s = config->slow_ppt_time_constant_s; |
| 87 | mcfg->stapm_time_constant_s = config->stapm_time_constant_s; |
| 88 | } |
| 89 | |
| 90 | mcfg->ccx_down_core_mode = config->downcore_mode; |
| 91 | mcfg->ccx_disable_smt = config->smt_disable; |
| 92 | |
| 93 | mcfg->sustained_power_limit_mW = config->sustained_power_limit_mW; |
| 94 | mcfg->prochot_l_deassertion_ramp_time_ms = config->prochot_l_deassertion_ramp_time_ms; |
| 95 | mcfg->thermctl_limit_degreeC = config->thermctl_limit_degreeC; |
| 96 | mcfg->psi0_current_limit_mA = config->psi0_current_limit_mA; |
| 97 | mcfg->psi0_soc_current_limit_mA = config->psi0_soc_current_limit_mA; |
| 98 | mcfg->vddcr_soc_voltage_margin_mV = config->vddcr_soc_voltage_margin_mV; |
| 99 | mcfg->vddcr_vdd_voltage_margin_mV = config->vddcr_vdd_voltage_margin_mV; |
| 100 | mcfg->vrm_maximum_current_limit_mA = config->vrm_maximum_current_limit_mA; |
| 101 | mcfg->vrm_soc_maximum_current_limit_mA = config->vrm_soc_maximum_current_limit_mA; |
| 102 | mcfg->vrm_current_limit_mA = config->vrm_current_limit_mA; |
| 103 | mcfg->vrm_soc_current_limit_mA = config->vrm_soc_current_limit_mA; |
| 104 | mcfg->sb_tsi_alert_comparator_mode_en = config->sb_tsi_alert_comparator_mode_en; |
| 105 | mcfg->core_dldo_bypass = config->core_dldo_bypass; |
| 106 | mcfg->min_soc_vid_offset = config->min_soc_vid_offset; |
| 107 | mcfg->aclk_dpm0_freq_400MHz = config->aclk_dpm0_freq_400MHz; |
| 108 | mcfg->telemetry_vddcr_vdd_slope_mA = config->telemetry_vddcr_vdd_slope_mA; |
| 109 | mcfg->telemetry_vddcr_vdd_offset = config->telemetry_vddcr_vdd_offset; |
| 110 | mcfg->telemetry_vddcr_soc_slope_mA = config->telemetry_vddcr_soc_slope_mA; |
| 111 | mcfg->telemetry_vddcr_soc_offset = config->telemetry_vddcr_soc_offset; |
| 112 | mcfg->hd_audio_enable = devtree_hda_dev_enabled(); |
| 113 | mcfg->sata_enable = devtree_sata_dev_enabled(); |
Patrick Huang | ed1592b | 2021-04-20 20:40:09 +0800 | [diff] [blame^] | 114 | mcfg->hdmi2_disable = config->hdmi2_disable; |
Felix Held | dd73714 | 2021-03-26 00:44:35 +0100 | [diff] [blame] | 115 | |
| 116 | mainboard_updm_update(mcfg); |
| 117 | } |