From patchwork Fri Feb 20 14:27:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 441979 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3540B1401AB for ; Sat, 21 Feb 2015 01:30:01 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 1CEA21A0EED for ; Sat, 21 Feb 2015 01:30:01 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 196F41A0AAA for ; Sat, 21 Feb 2015 01:29:45 +1100 (AEDT) Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Feb 2015 14:29:42 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 20 Feb 2015 14:29:40 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 80E76219004D for ; Fri, 20 Feb 2015 14:29:33 +0000 (GMT) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t1KETdFd2359624 for ; Fri, 20 Feb 2015 14:29:39 GMT Received: from d06av01.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t1KETcAT004195 for ; Fri, 20 Feb 2015 07:29:39 -0700 Received: from hermes.ibm.com (sig-9-78-75-46.uk.ibm.com [9.78.75.46]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t1KETZdm004057; Fri, 20 Feb 2015 07:29:38 -0700 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: skiboot@lists.ozlabs.org Date: Fri, 20 Feb 2015 15:27:26 +0100 Message-Id: <1424442456-11979-4-git-send-email-clg@fr.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1423117857-32759-1-git-send-email-clg@fr.ibm.com> References: <1423117857-32759-1-git-send-email-clg@fr.ibm.com> MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15022014-0041-0000-0000-000003519390 Subject: [Skiboot] [PATCH v2 03/13] dts: add device tree nodes for the core temperatures X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" 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 --- 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 #include #include +#include /* 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@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 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 */