[1/2] HDAT: Add chip-id property to ipmi sensors

Message ID 20170727084518.31710-1-hegdevasant@linux.vnet.ibm.com
State Accepted
Headers show

Commit Message

Vasant Hegde July 27, 2017, 8:45 a.m.
Presently we do not have a way to map sensor to chip id. Hence we are
always passing chip id 0 for occ_reset request (see occ_sensor_id_to_chip()).

This patch adds chip-id property to sensors (whenever its available) so that
we can map occ sensor to chip-id and pass valid chip-id to occ_reset request.

Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
---
 hdata/fsp.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

Comments

Stewart Smith Aug. 15, 2017, 12:53 a.m. | #1
Vasant Hegde <hegdevasant@linux.vnet.ibm.com> writes:
> Presently we do not have a way to map sensor to chip id. Hence we are
> always passing chip id 0 for occ_reset request (see occ_sensor_id_to_chip()).
>
> This patch adds chip-id property to sensors (whenever its available) so that
> we can map occ sensor to chip-id and pass valid chip-id to occ_reset request.
>
> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>

Thanks, series merged to master as of 98e5c27e15e355de01a6c8f362be3e1ee95ff014

Patch

diff --git a/hdata/fsp.c b/hdata/fsp.c
index 4846fcd..2bf691f 100644
--- a/hdata/fsp.c
+++ b/hdata/fsp.c
@@ -281,6 +281,40 @@  static void add_uart(const struct spss_iopath *iopath, struct dt_node *lpc)
 		be32_to_cpu(iopath->lpc.uart_baud));
 }
 
+static void add_chip_id_to_sensors(struct dt_node *sensor_node, __be32 slca_index)
+{
+	unsigned int i;
+	const void *hdif;
+	const struct slca_entry *slca;
+	const struct spira_fru_id *fru_id;
+	const struct sppcrd_chip_info *cinfo;
+
+	slca = slca_get_entry(slca_index);
+	if (slca == NULL) {
+		prlog(PR_WARNING, "SENSORS: Invalid slca index\n");
+		return;
+	}
+
+	for_each_ntuple_idx(&spira.ntuples.proc_chip, hdif, i, SPPCRD_HDIF_SIG) {
+		fru_id = HDIF_get_idata(hdif, SPPCRD_IDATA_FRU_ID, NULL);
+		if (!fru_id)
+			return;
+
+		if (fru_id->rsrc_id != slca->rsrc_id)
+			continue;
+
+		cinfo = HDIF_get_idata(hdif, SPPCRD_IDATA_CHIP_INFO, NULL);
+		if (!CHECK_SPPTR(cinfo)) {
+			prlog(PR_ERR, "SENSORS: Bad ChipID data %d\n", i);
+			return;
+		}
+
+		dt_add_property_cells(sensor_node,
+				      "ibm,chip-id", be32_to_cpu(cinfo->xscom_id));
+		return;
+	}
+}
+
 static void add_ipmi_sensors(struct dt_node *bmc_node)
 {
 	int i;
@@ -325,6 +359,8 @@  static void add_ipmi_sensors(struct dt_node *bmc_node)
 		dt_add_property_cells(sensor_node, "reg", ipmi_sensors->data[i].id);
 		dt_add_property_cells(sensor_node, "ipmi-sensor-type",
 				      ipmi_sensors->data[i].type);
+
+		add_chip_id_to_sensors(sensor_node, ipmi_sensors->data[i].slca_index);
 	}
 }