summaryrefslogtreecommitdiff
path: root/src/mainboard/google/slippy/romstage.c
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2021-02-11 14:25:44 +0100
committerAngel Pons <th3fanbus@gmail.com>2021-02-12 19:52:50 +0000
commit77ef99be22e69982a88bd77cafdb1a737fc2f185 (patch)
tree917de116be581d23a30001258a408f36c3f55a4a /src/mainboard/google/slippy/romstage.c
parent9a094c4b6345e498ac47dc7c30cde2b144f131f5 (diff)
downloadcoreboot-77ef99be22e69982a88bd77cafdb1a737fc2f185.tar.xz
mb/google/slippy: Factor out SPD indexing
The code to read the SPD file and index it is not variant-specific. Change-Id: Ifaedc39b683901b60abbb1d984f1d38c1ed364e2 Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/50542 Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/mainboard/google/slippy/romstage.c')
-rw-r--r--src/mainboard/google/slippy/romstage.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/mainboard/google/slippy/romstage.c b/src/mainboard/google/slippy/romstage.c
index fb32b48e8e..89eaab986b 100644
--- a/src/mainboard/google/slippy/romstage.c
+++ b/src/mainboard/google/slippy/romstage.c
@@ -1,9 +1,13 @@
/* SPDX-License-Identifier: GPL-2.0-only */
-#include <stdint.h>
+#include <cbfs.h>
+#include <console/console.h>
#include <northbridge/intel/haswell/haswell.h>
#include <northbridge/intel/haswell/raminit.h>
#include <southbridge/intel/lynxpoint/pch.h>
+#include <string.h>
+#include <types.h>
+
#include "variant.h"
void mainboard_config_rcba(void)
@@ -46,3 +50,26 @@ void mb_get_spd_map(uint8_t spd_map[4])
spd_map[0] = 0xff;
spd_map[2] = 0xff;
}
+
+unsigned int fill_spd_for_index(uint8_t spd[], unsigned int spd_index)
+{
+ uint8_t *spd_file;
+ size_t spd_file_len;
+
+ printk(BIOS_DEBUG, "SPD index %d\n", spd_index);
+ spd_file = cbfs_map("spd.bin", &spd_file_len);
+ if (!spd_file)
+ die("SPD data not found.");
+
+ if (spd_file_len < ((spd_index + 1) * SPD_LEN)) {
+ printk(BIOS_ERR, "SPD index override to 0 - old hardware?\n");
+ spd_index = 0;
+ }
+
+ if (spd_file_len < SPD_LEN)
+ die("Missing SPD data.");
+
+ memcpy(spd, spd_file + (spd_index * SPD_LEN), SPD_LEN);
+
+ return spd_index;
+}