summaryrefslogtreecommitdiff
path: root/src/device/dram
diff options
context:
space:
mode:
Diffstat (limited to 'src/device/dram')
-rw-r--r--src/device/dram/ddr2.c24
-rw-r--r--src/device/dram/ddr3.c6
2 files changed, 27 insertions, 3 deletions
diff --git a/src/device/dram/ddr2.c b/src/device/dram/ddr2.c
index 921679c584..0d395c4315 100644
--- a/src/device/dram/ddr2.c
+++ b/src/device/dram/ddr2.c
@@ -72,6 +72,30 @@ u8 spd_ddr2_calc_checksum(u8 *spd, int len)
}
/**
+ * \brief Calculate the CRC of a DDR2 SPD unique identifier
+ *
+ * @param spd pointer to raw SPD data
+ * @param len length of data in SPD
+ *
+ * @return the CRC of SPD data bytes 64..72 and 93..98, or 0
+ * when spd data is truncated.
+ */
+u16 spd_ddr2_calc_unique_crc(const u8 *spd, int len)
+{
+ u8 id_bytes[15];
+ int i, j = 0;
+ if (len < 98)
+ /* Not enough bytes available to get the CRC */
+ return 0;
+ for (i = 64; i <= 72; i++)
+ id_bytes[j++] = spd[i];
+ for (i = 93; i <= 98; i++)
+ id_bytes[j++] = spd[i];
+
+ return ddr3_crc16(id_bytes, 15);
+}
+
+/**
* \brief Return size of SPD.
*
* Returns size of SPD. Usually 128 Byte.
diff --git a/src/device/dram/ddr3.c b/src/device/dram/ddr3.c
index 87aa3c5362..67f30092ea 100644
--- a/src/device/dram/ddr3.c
+++ b/src/device/dram/ddr3.c
@@ -46,7 +46,7 @@ int spd_dimm_is_registered_ddr3(enum spd_dimm_type type)
return 0;
}
-static u16 crc16(const u8 *ptr, int n_crc)
+u16 ddr3_crc16(const u8 *ptr, int n_crc)
{
int i;
u16 crc = 0;
@@ -87,7 +87,7 @@ u16 spd_ddr3_calc_crc(u8 *spd, int len)
/* Not enough bytes available to get the CRC */
return 0;
- return crc16(spd, n_crc);
+ return ddr3_crc16(spd, n_crc);
}
/**
@@ -104,7 +104,7 @@ u16 spd_ddr3_calc_unique_crc(u8 *spd, int len)
/* Not enough bytes available to get the CRC */
return 0;
- return crc16(&spd[117], 11);
+ return ddr3_crc16(&spd[117], 11);
}
/**