spd_bin: Replace get_spd_cbfs_rdev() with spd_cbfs_map()

In pursuit of the goal of eliminating the proliferation of raw region
devices to represent CBFS files outside of the CBFS core code, this
patch removes the get_spd_cbfs_rdev() API and instead replaces it with
spd_cbfs_map() which will find and map the SPD file in one go and return
a pointer to the relevant section. (This makes it impossible to unmap
the mapping again, which all but one of the users didn't bother to do
anyway since the API is only used on platforms with memory-mapped
flash. Presumably this will stay that way in the future so this is not
something worth worrying about.)

Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: Iec7571bec809f2f0712e7a97b4c853b8b40702d1
Reviewed-on: https://review.coreboot.org/c/coreboot/+/50350
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Wim Vervoorn <wvervoorn@eltan.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
diff --git a/src/mainboard/google/kahlee/variants/baseboard/memory.c b/src/mainboard/google/kahlee/variants/baseboard/memory.c
index d3d81fd..4b60a9c 100644
--- a/src/mainboard/google/kahlee/variants/baseboard/memory.c
+++ b/src/mainboard/google/kahlee/variants/baseboard/memory.c
@@ -4,6 +4,7 @@
 #include <console/console.h>
 #include <gpio.h>
 #include <spd_bin.h>
+#include <string.h>
 #include <variant/gpio.h>
 #include <amdblocks/dimm_spd.h>
 
@@ -22,25 +23,22 @@
 int __weak variant_mainboard_read_spd(uint8_t spdAddress,
 							char *buf, size_t len)
 {
-	struct region_device spd_rdev;
 	u8 spd_index = variant_memory_sku();
 
 	printk(BIOS_INFO, "%s SPD index %d\n", __func__, spd_index);
 
-	if (get_spd_cbfs_rdev(&spd_rdev, spd_index) < 0) {
+	void *spd = (void *)spd_cbfs_map(spd_index);
+	if (!spd) {
 		printk(BIOS_ERR, "Error: spd.bin not found\n");
 		return -1;
 	}
 
-	if (len != region_device_sz(&spd_rdev)) {
+	if (len != CONFIG_DIMM_SPD_SIZE) {
 		printk(BIOS_ERR, "Error: spd.bin is not the correct size\n");
 		return -1;
 	}
 
-	if (rdev_readat(&spd_rdev, buf, 0, len) != len) {
-		printk(BIOS_ERR, "Error: couldn't read spd.bin\n");
-		return -1;
-	}
+	memcpy(buf, spd, len);
 
 	return 0;
 }