Blame SOURCES/0036-devtree-Add-description-vendor-and-clock-info-to-mem.patch

99c779
From 9f448f011d58c5c2e5279dccb077bfd83a02da68 Mon Sep 17 00:00:00 2001
99c779
From: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
99c779
Date: Tue, 29 Nov 2016 12:02:03 +0530
99c779
Subject: [PATCH 36/43] devtree: Add description, vendor and clock info to
99c779
 memory bank
99c779
99c779
This patch parses SPD info to get vendor id and then uses
99c779
jedec_resolve() to get vendor name. Also adds clock and description
99c779
info based on SPD values.
99c779
99c779
Sample output;
99c779
        *-bank:1
99c779
             description: RDIMM DDR3 1600 MHz (0.6ns)
99c779
             product: HMT42GR7BFR4A-PB
99c779
             vendor: Hynix Semiconductor (Hyundai Electronics)
99c779
             physical id: 1
99c779
             version: 5438,15 33,01
99c779
             serial: 0x10c0af2c
99c779
             slot: Physical:/Sys0/Node0/DIMM11
99c779
             size: 16GiB
99c779
             clock: 1333MHz (0.8ns)
99c779
             capabilities: ecc spd-1.3
99c779
             configuration: errordetection=ecc
99c779
99c779
Signed-off-by: Jack Miller <jack@codezen.org>
99c779
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
99c779
---
99c779
 src/core/device-tree.cc | 34 ++++++++++++++++++++++++++++++++++
99c779
 1 file changed, 34 insertions(+)
99c779
99c779
diff --git a/src/core/device-tree.cc b/src/core/device-tree.cc
99c779
index e286ab4..e224024 100644
99c779
--- a/src/core/device-tree.cc
99c779
+++ b/src/core/device-tree.cc
99c779
@@ -14,6 +14,7 @@
99c779
 #include "version.h"
99c779
 #include "device-tree.h"
99c779
 #include "osutils.h"
99c779
+#include "jedec.h"
99c779
 #include <sys/types.h>
99c779
 #include <sys/stat.h>
99c779
 #include <arpa/inet.h>
99c779
@@ -808,6 +809,39 @@ static void add_memory_bank_spd(string path, hwNode & bank)
99c779
         bank.setConfig("errordetection", "ecc");
99c779
         break;
99c779
     }
99c779
+
99c779
+    double ns = (dimminfo[0xc] / 2) * (dimminfo[0xa] / (float) dimminfo[0xb]);
99c779
+    bank.setClock(1000000000 / ns);
99c779
+
99c779
+    char vendor[3];
99c779
+    snprintf(vendor, sizeof(vendor), "%x%x", dimminfo[0x76], dimminfo[0x75]);
99c779
+    bank.setVendor(jedec_resolve(vendor));
99c779
+
99c779
+    char description[100];
99c779
+    const char *type, *mod_type;
99c779
+
99c779
+    type = "DDR3";
99c779
+    switch(dimminfo[0x3])
99c779
+    {
99c779
+      case 0x1:
99c779
+        mod_type = "RDIMM";
99c779
+        break;
99c779
+      case 0x2:
99c779
+        mod_type = "UDIMM";
99c779
+        break;
99c779
+      case 0x3:
99c779
+        mod_type = "SODIMM";
99c779
+        break;
99c779
+      case 0x4:
99c779
+        mod_type = "LRDIMM";
99c779
+        break;
99c779
+      default:
99c779
+        mod_type = "DIMM";
99c779
+    }
99c779
+
99c779
+    snprintf(description, sizeof(description), "%s %s %d MHz (%0.1fns)",
99c779
+	     mod_type, type, (int) (1000 / ns), ns);
99c779
+    bank.setDescription(description);
99c779
   } else {
99c779
     mfg_loc_offset = 0x48;
99c779
     rev_offset1 = 0x5b;
99c779
-- 
99c779
2.10.2
99c779