From 5c2510d171cb0a0a7e34e659f2b7a2483decf7de Mon Sep 17 00:00:00 2001 From: Shilpasri G Bhat Date: Fri, 28 Jul 2017 00:45:33 +0530 Subject: sensors: occ: Add support to clear sensor groups Adds a generic API to clear sensor groups. OCC inband sensor groups such as CSM, Profiler and Job Scheduler can be cleared using this API. It will clear the min/max of all sensors belonging to OCC sensor groups. Signed-off-by: Shilpasri G Bhat Signed-off-by: Stewart Smith --- hw/occ-sensor.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'hw/occ-sensor.c') diff --git a/hw/occ-sensor.c b/hw/occ-sensor.c index 87886db..a55acac 100644 --- a/hw/occ-sensor.c +++ b/hw/occ-sensor.c @@ -546,6 +546,7 @@ static const char *get_sensor_loc_string(enum occ_sensor_location loc) void occ_sensors_init(void) { struct proc_chip *chip; + struct dt_node *sg; int occ_num = 0, i; /* OCC inband sensors is only supported in P9 */ @@ -561,9 +562,17 @@ void occ_sensors_init(void) occ_sensor_base = chip->occ_common_base + OCC_SENSOR_DATA_BLOCK_OFFSET; + sg = dt_new(opal_node, "sensor-groups"); + if (!sg) { + prerror("OCC: Failed to create sensor groups node\n"); + return; + } + dt_add_property_string(sg, "compatible", "ibm,opal-occ-sensor-group"); + for_each_chip(chip) { struct occ_sensor_data_header *hb; struct occ_sensor_name *md; + u32 *phandles, phcount = 0; hb = get_sensor_header_block(occ_num); md = get_names_block(hb); @@ -572,6 +581,9 @@ void occ_sensors_init(void) if (!occ_sensor_sanity(hb, chip->id)) continue; + phandles = malloc(hb->nr_sensors * sizeof(u32)); + assert(phandles); + for (i = 0; i < hb->nr_sensors; i++) { char name[30]; const char *type, *loc; @@ -615,7 +627,10 @@ void occ_sensors_init(void) if (md[i].location == OCC_SENSOR_LOC_CORE) dt_add_property_cells(node, "ibm,pir", c->pir); + phandles[phcount++] = node->phandle; } occ_num++; + occ_add_sensor_groups(sg, phandles, phcount, chip->id); + free(phandles); } } -- cgit v1.1