summaryrefslogtreecommitdiff
path: root/src/soc/amd/common/block
diff options
context:
space:
mode:
authorFelix Held <felix-coreboot@felixheld.de>2023-03-23 23:44:03 +0100
committerFelix Held <felix-coreboot@felixheld.de>2023-03-27 12:02:21 +0000
commit23a398e001b55950f7759aa7ffa2ec966e2ea917 (patch)
tree87e4cf413dd987a8b3b6f1cee6211cdd28bda6bd /src/soc/amd/common/block
parentfd5d26522c021c8f7a3242609f3b54cf209a8767 (diff)
soc/amd: introduce and use get_uvolts_from_vid for SVI2 and SVI3
Instead of implementing the conversion from the raw serial voltage ID value to the voltage in microvolts in every SoC, introduce the SOC_AMD_COMMON_BLOCK_SVI[2,3] Kconfig options for the SoC to select the correct version, implement get_uvolts_from_vid for both cases and only include the selected implementation in the build. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I344641217e6e4654fd281d434b88e346e0482f57 Reviewed-on: https://review.coreboot.org/c/coreboot/+/73995 Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com> Reviewed-by: Matt DeVillier <matt.devillier@amd.corp-partner.google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/soc/amd/common/block')
-rw-r--r--src/soc/amd/common/block/cpu/Kconfig12
-rw-r--r--src/soc/amd/common/block/cpu/Makefile.inc3
-rw-r--r--src/soc/amd/common/block/cpu/svi2.c19
-rw-r--r--src/soc/amd/common/block/cpu/svi3.c19
-rw-r--r--src/soc/amd/common/block/include/amdblocks/cpu.h1
5 files changed, 54 insertions, 0 deletions
diff --git a/src/soc/amd/common/block/cpu/Kconfig b/src/soc/amd/common/block/cpu/Kconfig
index f7583e720a..5dc846bb00 100644
--- a/src/soc/amd/common/block/cpu/Kconfig
+++ b/src/soc/amd/common/block/cpu/Kconfig
@@ -66,6 +66,18 @@ config SOC_AMD_COMMON_BLOCK_SMM
Add common SMM relocation, finalization and handler functionality to
the build.
+config SOC_AMD_COMMON_BLOCK_SVI2
+ bool
+ help
+ Select this option is the SoC uses the serial VID 2 standard for
+ encoding the voltage it requests from the VRM.
+
+config SOC_AMD_COMMON_BLOCK_SVI3
+ bool
+ help
+ Select this option is the SoC uses the serial VID 3 standard for
+ encoding the voltage it requests from the VRM.
+
config SOC_AMD_COMMON_BLOCK_TSC_FAM17H_19H
bool
select COLLECT_TIMESTAMPS_NO_TSC # selected use SoC-specific timestamp function
diff --git a/src/soc/amd/common/block/cpu/Makefile.inc b/src/soc/amd/common/block/cpu/Makefile.inc
index bd9e8ff88f..055341ec4d 100644
--- a/src/soc/amd/common/block/cpu/Makefile.inc
+++ b/src/soc/amd/common/block/cpu/Makefile.inc
@@ -4,6 +4,9 @@ ramstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_UCODE) += update_microcode.c
romstage-y += cpu.c
ramstage-y += cpu.c
+ramstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_SVI2) += svi2.c
+ramstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_SVI3) += svi3.c
+
ifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_UCODE),y)
define add-ucode-as-cbfs
cbfs-files-y += cpu_microcode_$(2).bin
diff --git a/src/soc/amd/common/block/cpu/svi2.c b/src/soc/amd/common/block/cpu/svi2.c
new file mode 100644
index 0000000000..0a41b78b26
--- /dev/null
+++ b/src/soc/amd/common/block/cpu/svi2.c
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <amdblocks/cpu.h>
+#include <types.h>
+
+/* Value defined in Serial VID Interface 2.0 spec (#48022, NDA only) */
+#define SERIAL_VID_2_DECODE_MICROVOLTS 6250
+#define SERIAL_VID_2_MAX_MICROVOLTS 1550000L
+
+uint32_t get_uvolts_from_vid(uint16_t core_vid)
+{
+ if ((core_vid >= 0xF8) && (core_vid <= 0xFF)) {
+ /* Voltage off for VID codes 0xF8 to 0xFF */
+ return 0;
+ } else {
+ return SERIAL_VID_2_MAX_MICROVOLTS -
+ (SERIAL_VID_2_DECODE_MICROVOLTS * core_vid);
+ }
+}
diff --git a/src/soc/amd/common/block/cpu/svi3.c b/src/soc/amd/common/block/cpu/svi3.c
new file mode 100644
index 0000000000..35a4a789de
--- /dev/null
+++ b/src/soc/amd/common/block/cpu/svi3.c
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <amdblocks/cpu.h>
+#include <types.h>
+
+/* Value defined in Serial VID Interface 3.0 spec (#56413, NDA only) */
+#define SERIAL_VID_3_DECODE_MICROVOLTS 5000
+#define SERIAL_VID_3_BASE_MICROVOLTS 245000L
+
+uint32_t get_uvolts_from_vid(uint16_t core_vid)
+{
+ if (core_vid == 0x00) {
+ /* Voltage off for VID code 0x00 */
+ return 0;
+ } else {
+ return SERIAL_VID_3_BASE_MICROVOLTS +
+ (SERIAL_VID_3_DECODE_MICROVOLTS * core_vid);
+ }
+}
diff --git a/src/soc/amd/common/block/include/amdblocks/cpu.h b/src/soc/amd/common/block/include/amdblocks/cpu.h
index 3501b22104..cbce028631 100644
--- a/src/soc/amd/common/block/include/amdblocks/cpu.h
+++ b/src/soc/amd/common/block/include/amdblocks/cpu.h
@@ -16,6 +16,7 @@ void write_resume_eip(void);
union pstate_msr; /* proper definition is in soc/msr.h */
+uint32_t get_uvolts_from_vid(uint16_t core_vid);
uint32_t get_pstate_core_freq(union pstate_msr pstate_reg);
uint32_t get_pstate_core_power(union pstate_msr pstate_reg);
const acpi_cstate_t *get_cstate_config_data(size_t *size);