summaryrefslogtreecommitdiffstats
path: root/common/ddr_spd.c
diff options
context:
space:
mode:
authorRenaud Barbier <renaud.barbier@ge.com>2014-03-13 18:09:59 +0000
committerSascha Hauer <s.hauer@pengutronix.de>2014-03-18 17:32:31 +0100
commit64e38721cde4d9bf6cca0b9e92a5900da1dd9577 (patch)
tree1573bb14518a409257b06de64177c2179306549b /common/ddr_spd.c
parentdf188547a95accdc26369edfdcb84cd5785f4a80 (diff)
downloadbarebox-64e38721cde4d9bf6cca0b9e92a5900da1dd9577.tar.gz
common: DDR3 SPD verification support
Add DDR3 SPD verification support for use by the PPC 8xxx DDR driver. This is based on the equivalent files from U-Boot version git-be937b5. Signed-off-by: Renaud Barbier <renaud.barbier@ge.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/ddr_spd.c')
-rw-r--r--common/ddr_spd.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/common/ddr_spd.c b/common/ddr_spd.c
index c8b73ff..ea0b529 100644
--- a/common/ddr_spd.c
+++ b/common/ddr_spd.c
@@ -7,6 +7,7 @@
*/
#include <common.h>
+#include <crc.h>
#include <ddr_spd.h>
uint32_t ddr2_spd_checksum_pass(const struct ddr2_spd_eeprom_s *spd)
@@ -37,3 +38,26 @@ uint32_t ddr2_spd_checksum_pass(const struct ddr2_spd_eeprom_s *spd)
error:
return 1;
}
+
+uint32_t ddr3_spd_checksum_pass(const struct ddr3_spd_eeprom_s *spd)
+{
+ char crc_lsb, crc_msb;
+ int csum16, len;
+
+ /*
+ * SPD byte0[7] - CRC coverage
+ * 0 = CRC covers bytes 0~125
+ * 1 = CRC covers bytes 0~116
+ */
+
+ len = !(spd->info_size_crc & 0x80) ? 126 : 117;
+ csum16 = cyg_crc16((char *)spd, len);
+
+ crc_lsb = (char) (csum16 & 0xff);
+ crc_msb = (char) (csum16 >> 8);
+
+ if (spd->crc[0] != crc_lsb || spd->crc[1] != crc_msb)
+ return 1;
+
+ return 0;
+}