|
|
21ef37 |
From 0ea2e95b3ccdeb3834bec6fe22d0794a65e8c37a Mon Sep 17 00:00:00 2001
|
|
|
21ef37 |
From: Jeremy Kerr <jk@ozlabs.org>
|
|
|
21ef37 |
Date: Tue, 6 Sep 2016 14:57:21 +0800
|
|
|
21ef37 |
Subject: [PATCH 40/43] devtree: Add support for DDR4 SPD
|
|
|
21ef37 |
|
|
|
21ef37 |
This patch adds support for DDR4 SPD.
|
|
|
21ef37 |
|
|
|
21ef37 |
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
21ef37 |
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
|
|
|
21ef37 |
---
|
|
|
21ef37 |
src/core/device-tree.cc | 51 ++++++++++++++++++++++++++++++++++++-------------
|
|
|
21ef37 |
1 file changed, 38 insertions(+), 13 deletions(-)
|
|
|
21ef37 |
|
|
|
21ef37 |
diff --git a/src/core/device-tree.cc b/src/core/device-tree.cc
|
|
|
21ef37 |
index 2672b53..48aac94 100644
|
|
|
21ef37 |
--- a/src/core/device-tree.cc
|
|
|
21ef37 |
+++ b/src/core/device-tree.cc
|
|
|
21ef37 |
@@ -815,6 +815,7 @@ static void add_memory_bank_spd(string path, hwNode & bank)
|
|
|
21ef37 |
uint16_t partno_offset;
|
|
|
21ef37 |
uint16_t ver_offset;
|
|
|
21ef37 |
uint16_t serial_offset;
|
|
|
21ef37 |
+ uint16_t bus_width_offset;
|
|
|
21ef37 |
int fd;
|
|
|
21ef37 |
size_t len = 0;
|
|
|
21ef37 |
dimminfo_buf dimminfo;
|
|
|
21ef37 |
@@ -847,16 +848,47 @@ static void add_memory_bank_spd(string path, hwNode & bank)
|
|
|
21ef37 |
close(fd);
|
|
|
21ef37 |
|
|
|
21ef37 |
if (dimminfo[2] >= 9) {
|
|
|
21ef37 |
- mfg_loc_offset = 0x77;
|
|
|
21ef37 |
+ double ns;
|
|
|
21ef37 |
+ char vendor[5];
|
|
|
21ef37 |
+ const char *type, *mod_type;
|
|
|
21ef37 |
+
|
|
|
21ef37 |
rev_offset1 = 0x92;
|
|
|
21ef37 |
rev_offset2 = 0x93;
|
|
|
21ef37 |
- year_offset = 0x78;
|
|
|
21ef37 |
- week_offset = 0x79;
|
|
|
21ef37 |
- partno_offset = 0x80;
|
|
|
21ef37 |
ver_offset = 0x01;
|
|
|
21ef37 |
- serial_offset = 0x7a;
|
|
|
21ef37 |
|
|
|
21ef37 |
- switch ((dimminfo[0x8] >> 3) & 0x3) // DDR3 error detection and correction scheme
|
|
|
21ef37 |
+ if (dimminfo[0x2] >= 0xc) {
|
|
|
21ef37 |
+ type = "DDR4";
|
|
|
21ef37 |
+ mfg_loc_offset = 0x142;
|
|
|
21ef37 |
+ year_offset = 0x143;
|
|
|
21ef37 |
+ week_offset = 0x144;
|
|
|
21ef37 |
+ partno_offset = 0x149;
|
|
|
21ef37 |
+ bus_width_offset = 0x0d;
|
|
|
21ef37 |
+ serial_offset = 0x145;
|
|
|
21ef37 |
+
|
|
|
21ef37 |
+ /*
|
|
|
21ef37 |
+ * There is no other valid values for the medium- and fine- timebase
|
|
|
21ef37 |
+ * other than (125ps, 1ps), so we hard-code those here. The fine
|
|
|
21ef37 |
+ * t_{ckavg}_{min} value is signed. Divide by 2 to get from raw clock
|
|
|
21ef37 |
+ * to expected data rate
|
|
|
21ef37 |
+ */
|
|
|
21ef37 |
+ ns = (((float)dimminfo[0x12] * 0.125) +
|
|
|
21ef37 |
+ (((signed char) dimminfo[0x7d]) * 0.001)) / 2;
|
|
|
21ef37 |
+ snprintf(vendor, sizeof(vendor), "%x%x", dimminfo[0x141], dimminfo[0x140]);
|
|
|
21ef37 |
+ } else {
|
|
|
21ef37 |
+ type = "DDR3";
|
|
|
21ef37 |
+ mfg_loc_offset = 0x77;
|
|
|
21ef37 |
+ year_offset = 0x78;
|
|
|
21ef37 |
+ week_offset = 0x79;
|
|
|
21ef37 |
+ partno_offset = 0x80;
|
|
|
21ef37 |
+ serial_offset = 0x7a;
|
|
|
21ef37 |
+ bus_width_offset = 0x08;
|
|
|
21ef37 |
+
|
|
|
21ef37 |
+ ns = (dimminfo[0xc] / 2) * (dimminfo[0xa] / (float) dimminfo[0xb]);
|
|
|
21ef37 |
+ snprintf(vendor, sizeof(vendor), "%x%x", dimminfo[0x76], dimminfo[0x75]);
|
|
|
21ef37 |
+ }
|
|
|
21ef37 |
+
|
|
|
21ef37 |
+ /* DDR3 & DDR4 error detection and correction scheme */
|
|
|
21ef37 |
+ switch ((dimminfo[bus_width_offset] >> 3) & 0x3)
|
|
|
21ef37 |
{
|
|
|
21ef37 |
case 0x00:
|
|
|
21ef37 |
bank.setConfig("errordetection", "none");
|
|
|
21ef37 |
@@ -867,17 +899,10 @@ static void add_memory_bank_spd(string path, hwNode & bank)
|
|
|
21ef37 |
break;
|
|
|
21ef37 |
}
|
|
|
21ef37 |
|
|
|
21ef37 |
- double ns = (dimminfo[0xc] / 2) * (dimminfo[0xa] / (float) dimminfo[0xb]);
|
|
|
21ef37 |
bank.setClock(1000000000 / ns);
|
|
|
21ef37 |
-
|
|
|
21ef37 |
- char vendor[3];
|
|
|
21ef37 |
- snprintf(vendor, sizeof(vendor), "%x%x", dimminfo[0x76], dimminfo[0x75]);
|
|
|
21ef37 |
bank.setVendor(jedec_resolve(vendor));
|
|
|
21ef37 |
|
|
|
21ef37 |
char description[100];
|
|
|
21ef37 |
- const char *type, *mod_type;
|
|
|
21ef37 |
-
|
|
|
21ef37 |
- type = "DDR3";
|
|
|
21ef37 |
switch(dimminfo[0x3])
|
|
|
21ef37 |
{
|
|
|
21ef37 |
case 0x1:
|
|
|
21ef37 |
--
|
|
|
21ef37 |
2.10.2
|
|
|
21ef37 |
|