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