[Skiboot] [PATCH 2/6] opal: Get chip location code

Mahesh J Salgaonkar mahesh at linux.vnet.ibm.com
Mon Dec 11 16:31:09 AEDT 2017


From: Mahesh Salgaonkar <mahesh at linux.vnet.ibm.com>

and store it under proc_chip for quick reference during HMI handling
code.

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

diff --git a/core/chip.c b/core/chip.c
index d2ff3f4..6526325 100644
--- a/core/chip.c
+++ b/core/chip.c
@@ -76,6 +76,7 @@ static void init_chip(struct dt_node *dn)
 {
 	struct proc_chip *chip;
 	uint32_t id;
+	const char *lc = NULL;
 
 	id = dt_get_chip_id(dn);
 	assert(id < MAX_CHIPS);
@@ -97,6 +98,15 @@ static void init_chip(struct dt_node *dn)
 
 	list_head_init(&chip->i2cms);
 
+	/* Update the location code for this chip. */
+	if (dt_has_node_property(dn, "ibm,loc-code", NULL))
+		lc = dt_prop_get(dn, "ibm,loc-code");
+	else if (dt_has_node_property(dn, "ibm,slot-location-code", NULL))
+		lc = dt_prop_get(dn, "ibm,slot-location-code");
+
+	if (lc)
+		chip->loc_code = strdup(lc);
+
 	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 566edc5..43b5ea5 100644
--- a/include/chip.h
+++ b/include/chip.h
@@ -215,6 +215,9 @@ struct proc_chip {
 	struct xive		*xive;
 
 	struct vas		*vas;
+
+	/* location code of this chip */
+	const uint8_t		*loc_code;
 };
 
 extern uint32_t pir_to_chip_id(uint32_t pir);
@@ -241,5 +244,17 @@ static inline int nr_chips(void)
 	return nr_chips;
 }
 
+/* helper to get location code of a chip */
+static inline const char *chip_loc_code(uint32_t chip_id)
+{
+	struct proc_chip *chip;
+
+	chip = get_chip(chip_id);
+	if (!chip)
+		return NULL;
+
+	return chip->loc_code;
+}
+
 #endif /* __CHIP_H */
 



More information about the Skiboot mailing list