diff mbox series

[v2,04/10] opal: Get chip part-number and serial-number.

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

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (f901fcafae14d38e29f1cc11440086ee678785d0)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Mahesh J Salgaonkar Oct. 7, 2020, 12:09 p.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>
---
Change in v2:
- Use dt_prop_get_def().
---
 core/chip.c    |    4 ++++
 include/chip.h |   28 ++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)
diff mbox series

Patch

diff --git a/core/chip.c b/core/chip.c
index f1269d3f9..d1ee59d58 100644
--- a/core/chip.c
+++ b/core/chip.c
@@ -113,6 +113,10 @@  static void init_chip(struct dt_node *dn)
 	if (lc)
 		chip->loc_code = strdup(lc);
 
+	/* Update part number and serial number for this chip */
+	chip->part_no = dt_prop_get_def(dn, "part-number", NULL);
+	chip->serial_no = dt_prop_get_def(dn, "serial-number", NULL);
+
 	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 4deb96182..53b4a41b7 100644
--- a/include/chip.h
+++ b/include/chip.h
@@ -220,6 +220,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;
 
@@ -276,5 +280,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 */