From 8f705b9fad1f59ea370bf55c8b3b901dd89357ed Mon Sep 17 00:00:00 2001 From: Felix Held Date: Mon, 6 Feb 2023 19:56:35 +0100 Subject: soc/amd/phoenix/soc_util: add get_soc_type Implement a get_soc_type function to determine if the silicon the code is running on is Phoenix or Phoenix 2. This will for example be needed to provide the correct DXIO descriptor table for the SoC. Signed-off-by: Felix Held Change-Id: I5f2b668b83432426b04e7f1354b694ddd6c300d6 Reviewed-on: https://review.coreboot.org/c/coreboot/+/72861 Reviewed-by: ritul guru Reviewed-by: Fred Reitberger Reviewed-by: Martin Roth Tested-by: build bot (Jenkins) --- src/soc/amd/phoenix/Makefile.inc | 2 ++ src/soc/amd/phoenix/include/soc/soc_util.h | 14 ++++++++++++++ src/soc/amd/phoenix/soc_util.c | 20 ++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 src/soc/amd/phoenix/include/soc/soc_util.h create mode 100644 src/soc/amd/phoenix/soc_util.c (limited to 'src/soc/amd') diff --git a/src/soc/amd/phoenix/Makefile.inc b/src/soc/amd/phoenix/Makefile.inc index 84825d0aa0..de465a2523 100644 --- a/src/soc/amd/phoenix/Makefile.inc +++ b/src/soc/amd/phoenix/Makefile.inc @@ -26,6 +26,7 @@ romstage-y += fsp_m_params.c romstage-y += gpio.c romstage-y += i2c.c romstage-y += romstage.c +romstage-y += soc_util.c romstage-y += uart.c ramstage-y += acpi.c @@ -38,6 +39,7 @@ ramstage-y += gpio.c ramstage-y += i2c.c ramstage-y += mca.c ramstage-y += root_complex.c +ramstage-y += soc_util.c ramstage-y += uart.c ramstage-y += xhci.c diff --git a/src/soc/amd/phoenix/include/soc/soc_util.h b/src/soc/amd/phoenix/include/soc/soc_util.h new file mode 100644 index 0000000000..860ab02fee --- /dev/null +++ b/src/soc/amd/phoenix/include/soc/soc_util.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef AMD_PHOENIX_SOC_UTIL_H +#define AMD_PHOENIX_SOC_UTIL_H + +enum soc_type { + SOC_PHOENIX, + SOC_PHOENIX2, + SOC_UNKNOWN, +}; + +enum soc_type get_soc_type(void); + +#endif /* AMD_PHOENIX_SOC_UTIL_H */ diff --git a/src/soc/amd/phoenix/soc_util.c b/src/soc/amd/phoenix/soc_util.c new file mode 100644 index 0000000000..e5677fcfd7 --- /dev/null +++ b/src/soc/amd/phoenix/soc_util.c @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include + +enum soc_type get_soc_type(void) +{ + uint32_t cpuid = cpuid_eax(1); + + if (cpuid_match(cpuid, PHOENIX_A0_CPUID, CPUID_ALL_STEPPINGS_MASK)) + return SOC_PHOENIX; + + + if (cpuid_match(cpuid, PHOENIX2_A0_CPUID, CPUID_ALL_STEPPINGS_MASK)) + return SOC_PHOENIX2; + + return SOC_UNKNOWN; +} -- cgit v1.2.3