Blob Blame History Raw
From e296a0e6f5d88029d561ba2eef0d39b5cc96cbd3 Mon Sep 17 00:00:00 2001
From: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Date: Tue, 29 Nov 2016 12:12:37 +0530
Subject: [PATCH 37/43] devtree: Add part and serial number info to memory bank

SPD has both part number and serial number information. Presently
we are displaying part number info under serial numbers. Instead
use Product field for part number and display proper serial number
under serial field.

Signed-off-by: Jack Miller <jack@codezen.org>
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
---
 src/core/device-tree.cc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/core/device-tree.cc b/src/core/device-tree.cc
index e224024..41034e5 100644
--- a/src/core/device-tree.cc
+++ b/src/core/device-tree.cc
@@ -763,6 +763,7 @@ static void add_memory_bank_spd(string path, hwNode & bank)
   unsigned char week_offset;
   unsigned char partno_offset;
   unsigned char ver_offset;
+  unsigned char serial_offset;
   int fd;
   size_t len = 0;
   dimminfo_buf dimminfo;
@@ -798,6 +799,7 @@ static void add_memory_bank_spd(string path, hwNode & bank)
     week_offset = 0x79;
     partno_offset = 0x80;
     ver_offset = 0x01;
+    serial_offset = 0x7a;
 
     switch ((dimminfo[0x8] >> 3) & 0x3) // DDR3 error detection and correction scheme
     {
@@ -850,6 +852,7 @@ static void add_memory_bank_spd(string path, hwNode & bank)
     week_offset = 0x5e;
     partno_offset = 0x49;
     ver_offset = 0x3e;
+    serial_offset = 0x5f;
 
     switch (dimminfo[0xb] & 0x3) // DDR2 error detection and correction scheme
     {
@@ -872,12 +875,16 @@ static void add_memory_bank_spd(string path, hwNode & bank)
     "%02X%02X,%02X %02X,%02X", dimminfo[rev_offset1],
     dimminfo[rev_offset2], dimminfo[year_offset], dimminfo[week_offset],
     dimminfo[mfg_loc_offset]);
-  bank.setSerial(string((char *) &dimminfo[partno_offset], 18));
+  bank.setProduct(string((char *) &dimminfo[partno_offset], 18));
   bank.setVersion(dimmversion);
 
+  unsigned long serial = be_long(&dimminfo[serial_offset]);
   int version = dimminfo[ver_offset];
   char buff[32];
 
+  snprintf(buff, sizeof(buff), "0x%lx", serial);
+  bank.setSerial(buff);
+
   snprintf(buff, sizeof(buff), "spd-%d.%d", (version & 0xF0) >> 4, version & 0x0F);
   bank.addCapability(buff);
 }
-- 
2.10.2