soc/amd/common/fsp/dmi: Set dimm voltage based on memory type

Voltage set based on standard configuration for each type.

TEST=build/boot google/skyrim, verify output in cbmem console log,
DMI type 17 table.

Change-Id: I9b1e68a9417e43cbb9c55b4c471664f3f9090342
Signed-off-by: Matt DeVillier <matt.devillier@amd.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/66981
Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
Reviewed-by: Marshall Dawson <marshalldawson3rd@gmail.com>
diff --git a/src/soc/amd/common/fsp/dmi.c b/src/soc/amd/common/fsp/dmi.c
index e3b6fad..b443fe2 100644
--- a/src/soc/amd/common/fsp/dmi.c
+++ b/src/soc/amd/common/fsp/dmi.c
@@ -38,6 +38,25 @@
 }
 
 /**
+ * Return DDR voltage (in mV) based on memory type
+ */
+static uint16_t ddr_get_voltage(uint16_t ddr_type)
+{
+	switch (ddr_type) {
+	case MEMORY_TYPE_DDR4:
+		return 1200;
+	case MEMORY_TYPE_LPDDR4:
+	case MEMORY_TYPE_DDR5:
+		return 1100;
+	case MEMORY_TYPE_LPDDR5:
+		return 1050;
+	default:
+		printk(BIOS_ERR, "Unknown memory type %x\n", ddr_type);
+		return 0;
+	}
+}
+
+/**
  * Populate dimm_info using AGESA TYPE17_DMI_INFO.
  */
 static void transfer_memory_info(const TYPE17_DMI_INFO *dmi17,
@@ -67,6 +86,8 @@
 
 	dimm->bank_locator = 0;
 
+	dimm->vdd_voltage = ddr_get_voltage(dmi17->MemoryType);
+
 	strncpy((char *)dimm->module_part_number, dmi17->PartNumber,
 		sizeof(dimm->module_part_number) - 1);
 }
@@ -79,6 +100,7 @@
 	       "  ddr_type: 0x%hx\n"
 	       "  max_speed_mts: %hu\n"
 	       "  config_speed_mts: %hu\n"
+	       "  vdd_voltage: %hu\n"
 	       "  rank_per_dimm: %hhu\n"
 	       "  channel_num: %hhu\n"
 	       "  dimm_num: %hhu\n"
@@ -92,6 +114,7 @@
 	       dimm->ddr_type,
 	       dimm->max_speed_mts,
 	       dimm->configured_speed_mts,
+	       dimm->vdd_voltage,
 	       dimm->rank_per_dimm,
 	       dimm->channel_num,
 	       dimm->dimm_num,