[Skiboot] [RFC PATCH v2 7/9] sensor: add a type property
Cédric Le Goater
clg at fr.ibm.com
Thu Jan 22 18:09:20 AEDT 2015
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 at fr.ibm.com>
---
hw/dts.c | 1 +
hw/fsp/fsp-sensor.c | 13 +++++++++++++
2 files changed, 14 insertions(+)
diff --git a/hw/dts.c b/hw/dts.c
index 4590d0dba7b6..7fc4ce45fa2b 100644
--- a/hw/dts.c
+++ b/hw/dts.c
@@ -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");
}
}
diff --git a/hw/fsp/fsp-sensor.c b/hw/fsp/fsp-sensor.c
index c08e79dae6b3..27fcb2d57a4a 100644
--- a/hw/fsp/fsp-sensor.c
+++ b/hw/fsp/fsp-sensor.c
@@ -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;
}
--
1.7.10.4
More information about the Skiboot
mailing list