[RFC,3/4] hdata/vpd: Parse the OpenPOWER OPFR record

Submitted by Ananth N Mavinakayanahalli on Feb. 28, 2017, 5:15 a.m.

Details

Message ID 148825891801.16559.10612736386933097923.stgit@thinktux.in.ibm.com
State Superseded
Headers show

Commit Message

Ananth N Mavinakayanahalli Feb. 28, 2017, 5:15 a.m.
Parse the OpenPOWER FRU VPD (OPFR) record on OpenPOWER instead
of the VINI records.

Signed-off-by: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
---
 hdata/vpd.c |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/hdata/vpd.c b/hdata/vpd.c
index 79f2893..a8e5070 100644
--- a/hdata/vpd.c
+++ b/hdata/vpd.c
@@ -236,6 +236,45 @@  static void vpd_add_property_string(struct dt_node *n, const char *name,
 	free(str);
 }
 
+/*
+ * For OpenPOWER, we only decipher OPFR records. While OP HDAT have VINI
+ * records too, populating the fields in there is optional. Also, there
+ * is an overlap in the fields contained therein.
+ */
+static void vpd_opfr_parse(struct dt_node *node,
+		const void *fruvpd, unsigned int fruvpd_sz)
+{
+	const void *kw;
+	uint8_t sz;
+
+	/* Vendor Name */
+	kw = vpd_find(fruvpd, fruvpd_sz, "OPFR", "VN", &sz);
+	if (kw)
+		vpd_add_property_string(node, "vendor", kw, sz);
+
+	/* FRU Description */
+	kw = vpd_find(fruvpd, fruvpd_sz, "OPFR", "DR", &sz);
+	if (kw)
+		vpd_add_property_string(node, "description", kw, sz);
+
+	/* Part number */
+	kw = vpd_find(fruvpd, fruvpd_sz, "OPFR", "VP", &sz);
+	if (kw)
+		vpd_add_property_string(node, "part-number", kw, sz);
+
+	/* Serial number */
+	kw = vpd_find(fruvpd, fruvpd_sz, "OPFR", "VS", &sz);
+	if (kw)
+		vpd_add_property_string(node, "serial-number", kw, sz);
+
+	/* Build date in BCD */
+	kw = vpd_find(fruvpd, fruvpd_sz, "OPFR", "MB", &sz);
+	if (kw)
+		vpd_add_property_string(node, "build-date", kw, sz);
+
+	return;
+}
+
 static void vpd_vini_parse(struct dt_node *node,
 			   const void *fruvpd, unsigned int fruvpd_sz)
 {
@@ -462,7 +501,11 @@  struct dt_node *dt_add_vpd_node(const struct HDIF_common_hdr *hdr,
 	if (vpd_valid(fruvpd, fruvpd_sz)
 	    && !dt_find_property(node, "ibm,vpd")) {
 		dt_add_property(node, "ibm,vpd", fruvpd, fruvpd_sz);
-		vpd_vini_parse(node, fruvpd, fruvpd_sz);
+
+		if (op_platform)
+			vpd_opfr_parse(node, fruvpd, fruvpd_sz);
+		else
+			vpd_vini_parse(node, fruvpd, fruvpd_sz);
 	}
 
 	return node;