blob: a66c10b032f86545dea223430a5ad7ea92a4ac52 [file] [log] [blame]
Angel Pons60ec3652020-04-03 01:22:13 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +02002
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +02003#include <cbfs.h>
4#include <console/console.h>
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +02005
6#include "spd.h"
7
8/* Get SPD data for on-board memory */
9uint8_t *mainboard_find_spd_data()
10{
11 uint8_t *spd_data;
12 int spd_index;
13 size_t spd_file_len;
14 char *spd_file;
15
16 spd_index = 0;
17
Julius Werner834b3ec2020-03-04 16:52:08 -080018 spd_file = cbfs_map("spd.bin", &spd_file_len);
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +020019 if (!spd_file)
20 die("SPD data not found.");
21
22 if (spd_file_len < ((spd_index + 1) * SPD_LEN)) {
23 printk(BIOS_ERR,
24 "SPD index override to 0 due to incorrect SPD index.\n");
25 spd_index = 0;
26 }
27
28 if (spd_file_len < SPD_LEN)
29 die("Missing SPD data.");
30
31 /* Assume same memory in both channels */
32 spd_index *= SPD_LEN;
33 spd_data = (uint8_t *)(spd_file + spd_index);
34
35 /* Make sure a valid SPD was found */
36 if (spd_data[0] == 0)
37 die("Invalid SPD data.");
38
39 return spd_data;
40}