[Skiboot] [PATCH v2 05/10] opal: Get backplane (io base) part-number and serial-number.
Mahesh Salgaonkar
mahesh at linux.ibm.com
Wed Oct 7 23:09:21 AEDT 2020
Get backplane (io base) part-number and serial-number and store it under
phb structure for quick reference while sending error log that needs
backplane FRU details.
Signed-off-by: Mahesh Salgaonkar <mahesh at linux.ibm.com>
---
hdata/iohub.c | 43 ++++++++++++++++++++++++++++++++++++++++++
hdata/test/p8-840-spira.dts | 2 ++
hdata/test/p81-811.spira.dts | 2 ++
hw/phb4.c | 6 ++++++
include/pci.h | 2 ++
5 files changed, 55 insertions(+)
diff --git a/hdata/iohub.c b/hdata/iohub.c
index fa3afbf7a..c751823a7 100644
--- a/hdata/iohub.c
+++ b/hdata/iohub.c
@@ -54,6 +54,46 @@ static bool io_get_lx_info(const void *kwvpd, unsigned int kwvpd_sz,
return true;
}
+/* Discard trailing spaces and populate device tree */
+static void io_dt_add_string_prop(struct dt_node *node, const char *name,
+ const char *val, int vlen)
+{
+ char *prop = zalloc(vlen + 1);
+ int i;
+
+ if (!prop)
+ return;
+
+ memcpy(prop, val, vlen);
+ for (i = vlen - 1; i >= 0; i--) {
+ if (prop[i] != 0x20) {
+ prop[i + 1] = '\0';
+ break;
+ }
+ }
+
+ if (i >= 0 && !dt_find_property(node, name))
+ dt_add_property_string(node, name, prop);
+}
+
+static void io_get_fru_info(const void *kwvpd, unsigned int kwvpd_sz,
+ struct dt_node *hn)
+{
+ const void *kw;
+ uint8_t sz;
+ char buf[12];
+
+ memset(buf, 0, 12);
+ /* Serial Number */
+ kw = vpd_find(kwvpd, kwvpd_sz, "VINI", "SN", &sz);
+ if (kw)
+ io_dt_add_string_prop(hn, "ibm,io-base-serial-number", kw, sz);
+
+ /* Part Number */
+ kw = vpd_find(kwvpd, kwvpd_sz, "VINI", "PN", &sz);
+ if (kw)
+ io_dt_add_string_prop(hn, "ibm,io-base-part-number", kw, sz);
+}
static void io_get_loc_code(const void *sp_iohubs, struct dt_node *hn, const char *prop_name)
{
@@ -336,6 +376,9 @@ static void io_add_p8_cec_vpd(const struct HDIF_common_hdr *sp_iohubs)
/* Grab LX load info */
io_get_lx_info(kwvpd, kwvpd_sz, 0, dt_root);
+
+ /* Grab part-number and serial-number of io base (backplane) */
+ io_get_fru_info(kwvpd, kwvpd_sz, dt_root);
}
/*
diff --git a/hdata/test/p8-840-spira.dts b/hdata/test/p8-840-spira.dts
index 625935d30..f461df2f5 100644
--- a/hdata/test/p8-840-spira.dts
+++ b/hdata/test/p8-840-spira.dts
@@ -12,6 +12,8 @@
nest-frequency = <0x0 0x77359400>;
vendor = "IBM";
ibm,io-base-loc-code = "U78C9.001.WZS0CWX-P1";
+ ibm,io-base-part-number = "00E4241";
+ ibm,io-base-serial-number = "YL30UF55N006";
ibm,vpd-lx-info = <0x0 0x31000401 0x300043>;
model = "8286-41A";
system-id = "TU00163";
diff --git a/hdata/test/p81-811.spira.dts b/hdata/test/p81-811.spira.dts
index ed7bd5deb..800ad800c 100644
--- a/hdata/test/p81-811.spira.dts
+++ b/hdata/test/p81-811.spira.dts
@@ -13,6 +13,8 @@
nest-frequency = <0x0 0x77359400>;
vendor = "IBM";
ibm,io-base-loc-code = "U78CB.001.WZS00AL-P1";
+ ibm,io-base-part-number = "00E3997";
+ ibm,io-base-serial-number = "YL10UF42L013";
ibm,vpd-lx-info = <0x0 0x31000401 0x300042>;
model = "8247-22L";
system-id = "1010C8A";
diff --git a/hw/phb4.c b/hw/phb4.c
index 17a233f39..79bfdbf9a 100644
--- a/hw/phb4.c
+++ b/hw/phb4.c
@@ -5780,6 +5780,12 @@ static void phb4_create(struct dt_node *np)
if (!p->phb.base_loc_code)
PHBDBG(p, "Base location code not found !\n");
+ /* Find base io backplane part/serial number from root node */
+ p->phb.base_part_no = dt_prop_get_def(dt_root,
+ "ibm,io-base-part-number", NULL);
+ p->phb.base_serial_no = dt_prop_get_def(dt_root,
+ "ibm,io-base-serial-number", NULL);
+
/*
* Grab CEC IO VPD load info from the root of the device-tree,
* on P8 there's a single such VPD for the whole machine
diff --git a/include/pci.h b/include/pci.h
index eb23a6d9b..0b7a1f8a6 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -379,6 +379,8 @@ struct phb {
/* Base location code used to generate the children one */
const char *base_loc_code;
+ const char *base_part_no;
+ const char *base_serial_no;
/* Additional data the platform might need to attach */
void *platform_data;
More information about the Skiboot
mailing list