summaryrefslogtreecommitdiff
path: root/src/mainboard/google/auron/spd.c
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2021-01-20 22:24:22 +0100
committerAngel Pons <th3fanbus@gmail.com>2021-01-23 11:25:59 +0000
commit292a7641418bbd653f8097419578793a9c758623 (patch)
tree3e181602f2f756fcd272b9dea74ba633cd158855 /src/mainboard/google/auron/spd.c
parente23b0abe30f3cf026a931cfd145d568cddf37ffc (diff)
mb/google/auron: Factor out SPD indexing
The code to read the SPD file and index it is not variant-specific. Change-Id: Iaee0a77934a45c65bf32dd0dba23cec654abc0b9 Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/49773 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Matt DeVillier <matt.devillier@gmail.com> Reviewed-by: Michael Niewöhner <foss@mniewoehner.de>
Diffstat (limited to 'src/mainboard/google/auron/spd.c')
-rw-r--r--src/mainboard/google/auron/spd.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/mainboard/google/auron/spd.c b/src/mainboard/google/auron/spd.c
index 751569e843..20d7498a7b 100644
--- a/src/mainboard/google/auron/spd.c
+++ b/src/mainboard/google/auron/spd.c
@@ -19,7 +19,7 @@
#define SPD_PART_OFF 128
#define SPD_PART_LEN 18
-void mainboard_print_spd_info(uint8_t spd[])
+static void mainboard_print_spd_info(uint8_t spd[])
{
const int spd_banks[8] = { 8, 16, 32, 64, -1, -1, -1, -1 };
const int spd_capmb[8] = { 1, 2, 4, 8, 16, 32, 64, 0 };
@@ -68,3 +68,28 @@ void mainboard_print_spd_info(uint8_t spd[])
capmb / 8 * busw / devw * ranks);
}
}
+
+void fill_spd_for_index(uint8_t spd[], unsigned int spd_index)
+{
+ size_t spd_file_len;
+ uint8_t *spd_file = cbfs_map("spd.bin", &spd_file_len);
+
+ if (!spd_file)
+ die("SPD data not found.");
+
+ if (spd_file_len < SPD_LEN)
+ die("Missing SPD data.");
+
+ if (spd_file_len < ((spd_index + 1) * SPD_LEN)) {
+ printk(BIOS_ERR, "SPD index override to 0 - old hardware?\n");
+ spd_index = 0;
+ }
+
+ memcpy(spd, spd_file + (spd_index * SPD_LEN), SPD_LEN);
+
+ /* Make sure a valid SPD was found */
+ if (spd[0] == 0)
+ die("Invalid SPD data.");
+
+ mainboard_print_spd_info(spd);
+}