summaryrefslogtreecommitdiff
path: root/src/soc
diff options
context:
space:
mode:
authorEric Lai <ericr_lai@compal.corp-partner.google.com>2020-04-21 15:32:20 +0800
committerTim Wawrzynczak <twawrzynczak@chromium.org>2020-04-28 16:23:15 +0000
commit0ee9b14c09c4dfeb59ad94315051ae423b26384d (patch)
tree6be8c5a251b7e83808e36b138cceffc3cb4fb4c9 /src/soc
parentd2b2be39296d910178173273017800a1b054a1ba (diff)
soc/intel/common/block/smbus: Set SPD array NULL if no DIMM present
Set SPD array NULL if no DIMM present. do_smbus_read_byte returns negative value if SMBus transaction fails. BUG=b:154445630,b:151702387 TEST=Check SPD is NULL if no DIMM in the slot. Signed-off-by: Eric Lai <ericr_lai@compal.corp-partner.google.com> Change-Id: Ie81adbfab5bb1d5c557fe549a158cb68e26b1162 Reviewed-on: https://review.coreboot.org/c/coreboot/+/40558 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src/soc')
-rw-r--r--src/soc/intel/common/block/smbus/smbuslib.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/soc/intel/common/block/smbus/smbuslib.c b/src/soc/intel/common/block/smbus/smbuslib.c
index 4db2c6e7a4..5f60ddcab3 100644
--- a/src/soc/intel/common/block/smbus/smbuslib.c
+++ b/src/soc/intel/common/block/smbus/smbuslib.c
@@ -38,14 +38,14 @@ static void smbus_read_spd(u8 *spd, u8 addr)
}
}
-static void get_spd(u8 *spd, u8 addr)
+/* return -1 if SMBus errors otherwise return 0 */
+static int get_spd(u8 *spd, u8 addr)
{
- if (do_smbus_read_byte(SMBUS_IO_BASE, addr, 0) == 0xff) {
+ /* If address is not 0, it will return CB_ERR(-1) if no dimm */
+ if (do_smbus_read_byte(SMBUS_IO_BASE, addr, 0) < 0) {
printk(BIOS_INFO, "No memory dimm at address %02X\n",
addr << 1);
- /* Make sure spd is zeroed if dimm doesn't exist. */
- memset(spd, 0, CONFIG_DIMM_SPD_SIZE);
- return;
+ return -1;
}
smbus_read_spd(spd, addr);
@@ -58,6 +58,7 @@ static void get_spd(u8 *spd, u8 addr)
/* Restore to page 0 */
do_smbus_write_byte(SMBUS_IO_BASE, SPD_PAGE_0, 0, 0);
}
+ return 0;
}
static u8 spd_data[CONFIG_DIMM_MAX * CONFIG_DIMM_SPD_SIZE];
@@ -66,9 +67,15 @@ void get_spd_smbus(struct spd_block *blk)
{
u8 i;
for (i = 0 ; i < CONFIG_DIMM_MAX; i++) {
- get_spd(&spd_data[i * CONFIG_DIMM_SPD_SIZE],
- blk->addr_map[i]);
- blk->spd_array[i] = &spd_data[i * CONFIG_DIMM_SPD_SIZE];
+ if (blk->addr_map[i] == 0) {
+ blk->spd_array[i] = NULL;
+ continue;
+ }
+
+ if (get_spd(&spd_data[i * CONFIG_DIMM_SPD_SIZE], blk->addr_map[i]) == 0)
+ blk->spd_array[i] = &spd_data[i * CONFIG_DIMM_SPD_SIZE];
+ else
+ blk->spd_array[i] = NULL;
}
update_spd_len(blk);