[coreboot-gerrit] Patch set updated for coreboot: 9846db7 Add a device/dram function to read in a users SPD

Dave Frodin (dave.frodin@se-eng.com) gerrit at coreboot.org
Wed Dec 18 16:08:37 CET 2013


Dave Frodin (dave.frodin at se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4533

-gerrit

commit 9846db72a5c255bc6898b349a9a3aef463e8f1c8
Author: Dave Frodin <dave.frodin at se-eng.com>
Date:   Sat Dec 14 11:21:26 2013 -0700

    Add a device/dram function to read in a users SPD
    
    This allows mainboards with solder-down memory and without
    a solder-down SPD EEPROM to have the SPD values set by
    a mainboard include file.
    
    Change-Id: I3fb351f4b84cf290e3f4374bcee8a038bccf7eed
    Signed-off-by: Dave Frodin <dave.frodin at se-eng.com>
---
 src/device/Makefile.inc        |  1 +
 src/device/dram/ddr3.c         | 36 ++++++++++++++++++++++++++++++++++++
 src/include/device/dram/ddr3.h |  1 +
 3 files changed, 38 insertions(+)

diff --git a/src/device/Makefile.inc b/src/device/Makefile.inc
index 96e2cd9..c83dc9d 100644
--- a/src/device/Makefile.inc
+++ b/src/device/Makefile.inc
@@ -14,6 +14,7 @@ ramstage-$(CONFIG_PCI) += pci_ops.c
 ramstage-y += smbus_ops.c
 
 romstage-y+= device_romstage.c
+romstage-$(CONFIG_USER_DEFINED_SPD) += dram/ddr3.c
 
 subdirs-y += oprom
 
diff --git a/src/device/dram/ddr3.c b/src/device/dram/ddr3.c
index 9b4f490..b8924f9 100644
--- a/src/device/dram/ddr3.c
+++ b/src/device/dram/ddr3.c
@@ -609,3 +609,39 @@ mrs_cmd_t ddr3_mrs_mirror_pins(mrs_cmd_t cmd)
 	cmd |= (downshift >> 1) | (upshift << 1);
 	return cmd;
 }
+
+/**
+ * \brief Fill SPD array with user data and calculate the CRC.
+ *
+ * The spd_num allows the user to specify a position in a
+ * input array that contains multiple SPDs.
+ */
+#if IS_ENABLED(CONFIG_USER_DEFINED_SPD)
+int fill_users_spd(unsigned char *spd_ptr, int spd_num)
+{
+	u16 index, crc;
+
+	#include CONFIG_PATH_TO_USERS_SPD
+	if ( spd_num >= sizeof(user_ddr3_spd)/128) {
+		printk(BIOS_SPEW, "Error: requested SPD isn't in user array\n");
+		return 1;
+	}
+	/* read the bytes from the table */
+	for (index = 0; index < 128; index++)
+		spd_ptr[index] = user_ddr3_spd[index + (spd_num * 128)];
+
+	/* If CRC bytes are zeroes, calculate and store the CRC of the fake table */
+	if ((spd_ptr[126] == 0) && (spd_ptr[127] == 0)) {
+		crc = spd_ddr3_calc_crc(spd_ptr, 128);
+		spd_ptr[126] = (unsigned char)(crc & 0xff);
+		spd_ptr[127] = (unsigned char)(crc >> 8);
+	}
+	printk(BIOS_SPEW, "\nDisplay the SPD");
+	for (index = 0; index < 128; index++) {
+		if((index&0x0F)==0x00) printk(BIOS_SPEW, "\n%02x:  ",index);
+		printk(BIOS_SPEW, "%02x ", spd_ptr[index]);
+	}
+	printk(BIOS_SPEW, "\n");
+	return 0;
+}
+#endif
diff --git a/src/include/device/dram/ddr3.h b/src/include/device/dram/ddr3.h
index b19c51c..770aa36 100644
--- a/src/include/device/dram/ddr3.h
+++ b/src/include/device/dram/ddr3.h
@@ -174,6 +174,7 @@ u16 spd_ddr3_calc_crc(u8 *spd, int len);
 int spd_decode_ddr3(dimm_attr * dimm, spd_raw_data spd_data);
 int dimm_is_registered(enum spd_dimm_type type);
 void dram_print_spd_ddr3(const dimm_attr * dimm);
+int fill_users_spd(unsigned char *spd_ptr, int spd_num);
 
 /**
  * \brief Read double word from specified address



More information about the coreboot-gerrit mailing list