From 60875b47185696c292150058f095b195d7d6901c Mon Sep 17 00:00:00 2001 From: Jason Glenesk Date: Thu, 16 Mar 2023 15:28:10 -0700 Subject: [PATCH] soc/amd/mendocino: Consume fsp misc_data hob Provide support function to query fsp misc_data hob and return smu reported power and thermal limit. BUG=b:253301653 TEST=Use get_amd_smu_reported_tdp(&tdp) values match what FSP placed in the hob. Change-Id: I9f0d8cdd616726c5a714e99504b83b0126dd273b Signed-off-by: Jason Glenesk Reviewed-on: https://review.coreboot.org/c/coreboot/+/73747 Reviewed-by: Martin Roth Tested-by: build bot (Jenkins) --- src/soc/amd/mendocino/Makefile.inc | 1 + src/soc/amd/mendocino/fsp_misc_data_hob.c | 49 +++++++++++++++++++ .../amd/mendocino/include/fsp/amd_misc_data.h | 10 ++++ .../mendocino/include/fsp/amd_misc_data_hob.h | 14 ++++++ src/vendorcode/amd/fsp/mendocino/FspGuids.h | 4 ++ 5 files changed, 78 insertions(+) create mode 100644 src/soc/amd/mendocino/fsp_misc_data_hob.c create mode 100644 src/soc/amd/mendocino/include/fsp/amd_misc_data.h create mode 100644 src/soc/amd/mendocino/include/fsp/amd_misc_data_hob.h diff --git a/src/soc/amd/mendocino/Makefile.inc b/src/soc/amd/mendocino/Makefile.inc index 65a49b0603..9700381092 100644 --- a/src/soc/amd/mendocino/Makefile.inc +++ b/src/soc/amd/mendocino/Makefile.inc @@ -30,6 +30,7 @@ ramstage-y += agesa_acpi.c ramstage-y += chip.c ramstage-y += cpu.c ramstage-y += fch.c +ramstage-y += fsp_misc_data_hob.c ramstage-y += fsp_s_params.c ramstage-y += gpio.c ramstage-y += i2c.c diff --git a/src/soc/amd/mendocino/fsp_misc_data_hob.c b/src/soc/amd/mendocino/fsp_misc_data_hob.c new file mode 100644 index 0000000000..103f821355 --- /dev/null +++ b/src/soc/amd/mendocino/fsp_misc_data_hob.c @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include +#include +#include +#include + +static enum cb_err get_amd_misc_data_hob(const struct amd_misc_data **fsp_misc_data, int min_revision) +{ + static const struct amd_misc_data *fsp_misc_data_cache; + size_t hob_size = 0; + const struct amd_misc_data *hob; + + if (fsp_misc_data_cache) { + *fsp_misc_data = fsp_misc_data_cache; + return CB_SUCCESS; + } + + hob = fsp_find_extension_hob_by_guid(AMD_MISC_DATA_HOB_GUID.b, &hob_size); + + if (hob == NULL || hob_size < sizeof(struct amd_misc_data)) { + printk(BIOS_ERR, "Couldn't find fsp misc data HOB.\n"); + return CB_ERR; + } + + if (hob->version < min_revision) { + printk(BIOS_ERR, "Unexpected fsp misc data HOB version.\n"); + return CB_ERR; + } + + fsp_misc_data_cache = hob; + *fsp_misc_data = fsp_misc_data_cache; + return CB_SUCCESS; +} + +enum cb_err get_amd_smu_reported_tdp(uint32_t *tdp) +{ + const struct amd_misc_data *fsp_misc_data = NULL; + + if (get_amd_misc_data_hob(&fsp_misc_data, AMD_MISC_DATA_VERSION) != CB_SUCCESS) + return CB_ERR; + + *tdp = fsp_misc_data->smu_power_and_thm_limit; + + return CB_SUCCESS; +} diff --git a/src/soc/amd/mendocino/include/fsp/amd_misc_data.h b/src/soc/amd/mendocino/include/fsp/amd_misc_data.h new file mode 100644 index 0000000000..df42d536a6 --- /dev/null +++ b/src/soc/amd/mendocino/include/fsp/amd_misc_data.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef AMD_MISC_DATA_H +#define AMD_MISC_DATA_H + +#include + +enum cb_err get_amd_smu_reported_tdp(uint32_t *tdp); + +#endif /* AMD_MISC_DATA_H */ diff --git a/src/soc/amd/mendocino/include/fsp/amd_misc_data_hob.h b/src/soc/amd/mendocino/include/fsp/amd_misc_data_hob.h new file mode 100644 index 0000000000..66b8bea4eb --- /dev/null +++ b/src/soc/amd/mendocino/include/fsp/amd_misc_data_hob.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __AMD_MISC_DATA_HOB_H__ +#define __AMD_MISC_DATA_HOB_H__ + +#define AMD_MISC_DATA_VERSION 2 + +struct amd_misc_data { + uint8_t version; + uint8_t unused[3]; + uint32_t smu_power_and_thm_limit; +} __packed; + +#endif /* __AMD_MISC_DATA_HOB_H__ */ diff --git a/src/vendorcode/amd/fsp/mendocino/FspGuids.h b/src/vendorcode/amd/fsp/mendocino/FspGuids.h index 1bef794418..cb99d2126b 100644 --- a/src/vendorcode/amd/fsp/mendocino/FspGuids.h +++ b/src/vendorcode/amd/fsp/mendocino/FspGuids.h @@ -21,4 +21,8 @@ GUID_INIT(0x3060C5EC, 0x7399, 0x432D, \ 0xBC, 0x97, 0xBF, 0x95, 0xE4, 0x3D, 0x53, 0x0C ) +#define AMD_MISC_DATA_HOB_GUID \ + GUID_INIT(0x27f7d972, 0x318f, 0x4665, \ + 0x8a, 0x99, 0xf4, 0x4c, 0x04, 0x4b, 0x49, 0x08) + #endif /* __FSP_GUIDS__ */