spd/lp5: Add Hynix memory part
[coreboot.git] / src / soc / amd / mendocino / fsp_misc_data_hob.c
blobe5eae0207556b3522bac1c4bba4bee4afbdbb07a
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <FspGuids.h>
5 #include <fsp/amd_misc_data.h>
6 #include <fsp/amd_misc_data_hob.h>
7 #include <fsp/util.h>
8 #include <types.h>
10 static enum cb_err get_amd_misc_data_hob(const struct amd_misc_data **fsp_misc_data, int min_revision)
12 static const struct amd_misc_data *fsp_misc_data_cache;
13 size_t hob_size = 0;
14 const struct amd_misc_data *hob;
16 if (fsp_misc_data_cache) {
17 *fsp_misc_data = fsp_misc_data_cache;
18 return CB_SUCCESS;
21 hob = fsp_find_extension_hob_by_guid(AMD_MISC_DATA_HOB_GUID.b, &hob_size);
23 if (hob == NULL || hob_size < sizeof(struct amd_misc_data)) {
24 printk(BIOS_ERR, "Couldn't find fsp misc data HOB.\n");
25 return CB_ERR;
28 if (hob->version < min_revision) {
29 printk(BIOS_ERR, "Unexpected fsp misc data HOB version.\n");
30 return CB_ERR;
33 fsp_misc_data_cache = hob;
34 *fsp_misc_data = fsp_misc_data_cache;
35 return CB_SUCCESS;
38 enum cb_err get_amd_smu_reported_tdp(uint32_t *tdp)
40 const struct amd_misc_data *fsp_misc_data = NULL;
42 if (get_amd_misc_data_hob(&fsp_misc_data, AMD_MISC_DATA_VERSION) != CB_SUCCESS)
43 return CB_ERR;
46 * The FSP will return the TDP in the format 0xX0000, where 'X' is the value
47 * we're interested in. For example: 0xF0000 (15W), 0x60000 (6W). Re-interpret
48 * the value so the caller just sees the TDP.
50 printk(BIOS_DEBUG, "fsp_misc_data->smu_power_and_thm_limit = 0x%08X\n",
51 fsp_misc_data->smu_power_and_thm_limit);
52 *tdp = fsp_misc_data->smu_power_and_thm_limit >> 16;
54 return CB_SUCCESS;