diff mbox series

[3/5] opal: Get chip part-number and serial-number.

Message ID 159599141769.66951.13565453115820608084.stgit@jupiter
State Superseded
Headers show
Series Add support to report EEH errors to BMC/FSP (eSEL) | expand

Commit Message

Mahesh J Salgaonkar July 29, 2020, 2:56 a.m. UTC
From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>

Get chip part-number and serial-number and store it under proc_chip for
quick reference while sending error log that needs proc chip FRU details.

Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
---
 core/chip.c    |   13 +++++++++++++
 include/chip.h |   28 ++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
diff mbox series

Patch

diff --git a/core/chip.c b/core/chip.c
index 191432d29..8e97a7bcd 100644
--- a/core/chip.c
+++ b/core/chip.c
@@ -63,6 +63,8 @@  static void init_chip(struct dt_node *dn)
 	struct proc_chip *chip;
 	uint32_t id;
 	const char *lc = NULL;
+	const char *part_no = NULL;
+	const char *serial_no = NULL;
 
 	id = dt_get_chip_id(dn);
 	assert(id < MAX_CHIPS);
@@ -93,6 +95,17 @@  static void init_chip(struct dt_node *dn)
 	if (lc)
 		chip->loc_code = strdup(lc);
 
+	/* Update part number and serial number for this chip */
+	if (dt_has_node_property(dn, "part-number", NULL))
+		part_no = dt_prop_get(dn, "part-number");
+	if (part_no)
+		chip->part_no = strdup(part_no);
+
+	if (dt_has_node_property(dn, "serial-number", NULL))
+		serial_no = dt_prop_get(dn, "serial-number");
+	if (serial_no)
+		chip->serial_no = strdup(serial_no);
+
 	prlog(PR_INFO, "CHIP: Initialised chip %d from %s\n", id, dn->name);
 	chips[id] = chip;
 }
diff --git a/include/chip.h b/include/chip.h
index b79b63ecf..e63f17a18 100644
--- a/include/chip.h
+++ b/include/chip.h
@@ -187,6 +187,10 @@  struct proc_chip {
 	/* location code of this chip */
 	const uint8_t		*loc_code;
 
+	/* part-number and serial number for this chip */
+	const uint8_t		*part_no;
+	const uint8_t		*serial_no;
+
 	/* Used by hw/sbe-p9.c */
 	struct p9_sbe		*sbe;
 
@@ -233,5 +237,29 @@  static inline const char *chip_loc_code(uint32_t chip_id)
 	return chip->loc_code;
 }
 
+/* helper to get part number of a chip */
+static inline const char *chip_part_number(uint32_t chip_id)
+{
+	struct proc_chip *chip;
+
+	chip = get_chip(chip_id);
+	if (!chip)
+		return NULL;
+
+	return chip->part_no;
+}
+
+/* helper to get serial number of a chip */
+static inline const char *chip_serial_number(uint32_t chip_id)
+{
+	struct proc_chip *chip;
+
+	chip = get_chip(chip_id);
+	if (!chip)
+		return NULL;
+
+	return chip->serial_no;
+}
+
 #endif /* __CHIP_H */