[Skiboot] [RFC PATCH 5/6] opal: Get chip part-number and serial-number.

Mahesh Salgaonkar mahesh at linux.vnet.ibm.com
Wed Apr 24 04:13:11 AEST 2019


Get chip part-number and serial-number and store it under proc_chip for
quick reference during HMI error threshold-ing.

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

diff --git a/core/chip.c b/core/chip.c
index 652632534..9eb993391 100644
--- a/core/chip.c
+++ b/core/chip.c
@@ -77,6 +77,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);
@@ -107,6 +109,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 d6e7e355b..18bb9a2d8 100644
--- a/include/chip.h
+++ b/include/chip.h
@@ -222,6 +222,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;
 };
@@ -262,5 +266,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 */
 



More information about the Skiboot mailing list