@@ -201,6 +201,7 @@ bool dts_sensor_create_nodes(void)
dt_add_property_string(node, "compatible",
"ibm,opal-sensor");
dt_add_property_cells(node, "sensor-data", handler);
+ dt_add_property_string(node, "sensor-type", "temp");
}
}
@@ -635,6 +635,17 @@ out:
#define MAX_NAME 64
+static const char *convert_frc_to_sensor_type(int frc)
+{
+ switch (frc) {
+ case SENSOR_FRC_POWER_SUPPLY: return "power";
+ case SENSOR_FRC_COOLING_FAN: return "fan";
+ case SENSOR_FRC_AMB_TEMP: return "temp";
+ default:
+ return "";
+ }
+}
+
static struct dt_node *sensor_get_node(struct dt_node *sensors,
struct sensor_header *header)
{
@@ -661,6 +672,8 @@ static struct dt_node *sensor_get_node(struct dt_node *sensors,
node = dt_new(sensors, name);
dt_add_property_string(node, "compatible", "ibm,opal-sensor");
+ dt_add_property_string(node, "sensor-type",
+ convert_frc_to_sensor_type(header->frc));
}
return node;
}
The hwmon framework in Linux needs a type for the sensors it exposes in userspace through the sysfs interface. This patch gives Linux a hand on what is dealing with when parsing the sensor device tree. Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> --- hw/dts.c | 1 + hw/fsp/fsp-sensor.c | 13 +++++++++++++ 2 files changed, 14 insertions(+)