1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
5 #include <fsp/amd_misc_data.h>
6 #include <fsp/amd_misc_data_hob.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
;
14 const struct amd_misc_data
*hob
;
16 if (fsp_misc_data_cache
) {
17 *fsp_misc_data
= fsp_misc_data_cache
;
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");
28 if (hob
->version
< min_revision
) {
29 printk(BIOS_ERR
, "Unexpected fsp misc data HOB version.\n");
33 fsp_misc_data_cache
= hob
;
34 *fsp_misc_data
= fsp_misc_data_cache
;
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
)
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;