[Skiboot] [PATCH v2 03/13] dts: add device tree nodes for the core temperatures
Cédric Le Goater
clg at fr.ibm.com
Sat Feb 21 01:27:26 AEDT 2015
This patch simply adds sensors nodes for the core temperatures. It
uses the core PIR as a resource identifier to fit in the sensor model.
The device tree nodes use the new layout.
Signed-off-by: Cédric Le Goater <clg at fr.ibm.com>
---
Changes since v1:
- removed creation of "/ibm,opal/sensors" as it is now done in
sensor_init()
Changes since RFC:
- "/ibm,opal/sensors" needs to be created on open power platform
core/sensor.c | 2 ++
hw/dts.c | 36 ++++++++++++++++++++++++++++++++++++
include/dts.h | 1 +
3 files changed, 39 insertions(+)
diff --git a/core/sensor.c b/core/sensor.c
index f2f86c8813ca..e0088fe5bce9 100644
--- a/core/sensor.c
+++ b/core/sensor.c
@@ -40,6 +40,8 @@ void sensor_init(void)
{
sensor_node = dt_new(opal_node, "sensors");
+ dts_sensor_create_nodes(sensor_node);
+
/* Register OPAL interface */
opal_register(OPAL_SENSOR_READ, opal_sensor_read, 3);
}
diff --git a/hw/dts.c b/hw/dts.c
index 8affac34c9c5..a58703cf28de 100644
--- a/hw/dts.c
+++ b/hw/dts.c
@@ -19,6 +19,7 @@
#include <sensor.h>
#include <dts.h>
#include <skiboot.h>
+#include <opal-api.h>
/* Per core Digital Thermal Sensors */
#define EX_THERM_DTS_RESULT0 0x10050000
@@ -163,3 +164,38 @@ int64_t dts_sensor_read(uint32_t sensor_hndl, uint32_t *sensor_data)
return 0;
}
+
+bool dts_sensor_create_nodes(struct dt_node *sensors)
+{
+ uint8_t sensor_class = SENSOR_DTS_CORE_TEMP|SENSOR_DTS;
+
+ struct proc_chip *chip;
+ char name[64];
+
+ /* build the device tree nodes :
+ *
+ * sensors/core-temp at pir
+ *
+ * The core is identified by its PIR, is stored in the resource
+ * number of the sensor handler.
+ */
+ for_each_chip(chip) {
+ struct cpu_thread *c;
+
+ for_each_available_core_in_chip(c, chip->id) {
+ struct dt_node *node;
+ uint32_t handler;
+
+ snprintf(name, sizeof(name), "core-temp@%x", c->pir);
+
+ handler = sensor_make_handler(sensor_class,
+ c->pir, SENSOR_DTS_ATTR_TEMP_MAX);
+ node = dt_new(sensors, name);
+ dt_add_property_string(node, "compatible",
+ "ibm,opal-sensor");
+ dt_add_property_cells(node, "sensor-data", handler);
+ }
+ }
+
+ return true;
+}
diff --git a/include/dts.h b/include/dts.h
index 18933909ee08..8d6a61226917 100644
--- a/include/dts.h
+++ b/include/dts.h
@@ -20,5 +20,6 @@
#include <stdint.h>
extern int64_t dts_sensor_read(uint32_t sensor_hndl, uint32_t *sensor_data);
+extern bool dts_sensor_create_nodes(struct dt_node *sensors);
#endif /* __DTS_H */
--
1.7.10.4
More information about the Skiboot
mailing list