sarien: Set SPD page to 0 before reading

In some cases FSP might leave the SPD pointer set to page 1,
which will cause mosys to not be able to read the SPD info.
To fix this force a write to address 0x36 on the same I2C bus
which will set the page back to 0.

This change also switches to use a hard coded DIMM count rather
than reading it from SMBIOS.  This is because if there is a
DIMM only installed in slot B it will not be found if SMBIOS
says there is only 1 DIMM in the system.

TEST=test 'memory spd print all' on sarien/arcada with both
DIMMs installed, and with one DIMM installed in slot A or B.

Change-Id: Idcb872a8a54e374c6c344613772a24af7ba3e55e
Signed-off-by: Duncan Laurie <>
Tested-by: Lijian Zhao <>
Tested-by: EricR Lai <>
Reviewed-by: Furquan Shaikh <>
Reviewed-by: Lijian Zhao <>
Reviewed-by: Shelley Chen <>
diff --git a/platform/sarien/memory.c b/platform/sarien/memory.c
index 766c4b0..39ff399 100644
--- a/platform/sarien/memory.c
+++ b/platform/sarien/memory.c
@@ -45,16 +45,28 @@
 #include "sarien.h"
+#define SARIEN_SPD_PAGE_0_ADDR	0x36
+#define SARIEN_SPD_PAGE_1_ADDR	0x37
+static int sarien_dimm_count(struct platform_intf *intf)
 static int sarien_spd_read(struct platform_intf *intf,
 		 int dimm, int reg, int spd_len, uint8_t *spd_buf)
 	int bus;
 	int address;
+	uint8_t page_sel = 0;
 	bus = intf->cb->memory->dimm_map(intf, DIMM_TO_BUS, dimm);
 	address = intf->cb->memory->dimm_map(intf, DIMM_TO_ADDRESS, dimm);
+	/* First ensure SPD is pointing at page 0 */
+	intf->op->i2c->smbus_write_reg(intf, bus, SARIEN_SPD_PAGE_0_ADDR,
+				       0, sizeof(page_sel), &page_sel);
 	return spd_read_i2c(intf, bus, address, reg, spd_len, spd_buf);
@@ -142,7 +154,7 @@
 struct memory_cb sarien_memory_cb = {
-	.dimm_count	= smbios_dimm_count,
+	.dimm_count	= sarien_dimm_count,
 	.dimm_speed	= smbios_dimm_speed,
 	.dimm_map	= dimm_sarien_dimm_map,
 	.spd		= &sarien_spd_cb,