summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-07-01 10:14:40 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-07-01 10:14:40 +0200
commit55e87e07c1c788726423ac617545590cf36c0402 (patch)
tree28a9f2424abe72b3b04236eb3c7fa8e05057177e /common
parentda05cbd69a559a1750d6dd07d932b3db32ad3daa (diff)
parent5c179dd08da0799a584a2ed9ec19ffefa8165721 (diff)
downloadbarebox-55e87e07c1c788726423ac617545590cf36c0402.tar.gz
barebox-55e87e07c1c788726423ac617545590cf36c0402.tar.xz
Merge branch 'for-next/ppc'
Diffstat (limited to 'common')
-rw-r--r--common/Makefile1
-rw-r--r--common/ddr_spd.c39
2 files changed, 40 insertions, 0 deletions
diff --git a/common/Makefile b/common/Makefile
index 4f430b6ed1..64eacc3047 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_CMD_LOADS) += s_record.o
obj-$(CONFIG_OFTREE) += oftree.o
obj-y += memory.o
+obj-$(CONFIG_DDR_SPD) += ddr_spd.o
obj-y += memory_display.o
obj-$(CONFIG_MALLOC_DLMALLOC) += dlmalloc.o
obj-$(CONFIG_MALLOC_TLSF) += tlsf_malloc.o
diff --git a/common/ddr_spd.c b/common/ddr_spd.c
new file mode 100644
index 0000000000..c8b73ff56c
--- /dev/null
+++ b/common/ddr_spd.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2008 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * Version 2 as published by the Free Software Foundation.
+ */
+
+#include <common.h>
+#include <ddr_spd.h>
+
+uint32_t ddr2_spd_checksum_pass(const struct ddr2_spd_eeprom_s *spd)
+{
+ uint32_t i, cksum = 0;
+ const uint8_t *buf = (const uint8_t *)spd;
+ uint8_t rev, spd_cksum;
+
+ rev = spd->spd_rev;
+ spd_cksum = spd->cksum;
+
+ /* Rev 1.X or less supported by this code */
+ if (rev >= 0x20)
+ goto error;
+
+ /*
+ * The checksum is calculated on the first 64 bytes
+ * of the SPD as per JEDEC specification.
+ */
+ for (i = 0; i < 63; i++)
+ cksum += *buf++;
+ cksum &= 0xFF;
+
+ if (cksum != spd_cksum)
+ goto error;
+
+ return 0;
+error:
+ return 1;
+}