From patchwork Thu Feb 5 06:30:51 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: 436630 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 C4D1B14027C for ; Thu, 5 Feb 2015 17:31:41 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id B3C821A0C99 for ; Thu, 5 Feb 2015 17:31:41 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e06smtp16.uk.ibm.com (e06smtp16.uk.ibm.com [195.75.94.112]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 890391A0C12 for ; Thu, 5 Feb 2015 17:31:30 +1100 (AEDT) Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Feb 2015 06:31:25 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp16.uk.ibm.com (192.168.101.146) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 5 Feb 2015 06:31:24 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 21FAF1B0804B for ; Thu, 5 Feb 2015 06:31:31 +0000 (GMT) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t156VNep6488420 for ; Thu, 5 Feb 2015 06:31:23 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t156VN7i022095 for ; Wed, 4 Feb 2015 23:31:23 -0700 Received: from hermes.kaod.org (sig-9-79-46-126.de.ibm.com [9.79.46.126]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t156VLD4022052; Wed, 4 Feb 2015 23:31:23 -0700 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: skiboot@lists.ozlabs.org Date: Thu, 5 Feb 2015 07:30:51 +0100 Message-Id: <1423117857-32759-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: 15020506-0025-0000-0000-000003BFC71F Subject: [Skiboot] [PATCH 03/11] 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 RFC: - "/ibm,opal/sensors" needs to be created on open power platform core/sensor.c | 3 +++ hw/dts.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/dts.h | 1 + 3 files changed, 46 insertions(+) diff --git a/core/sensor.c b/core/sensor.c index 5db072e0e501..83ef2d98cd94 100644 --- a/core/sensor.c +++ b/core/sensor.c @@ -18,6 +18,7 @@ #include #include #include +#include static int64_t opal_sensor_read(uint32_t sensor_hndl, int token, uint32_t *sensor_data) @@ -32,4 +33,6 @@ void sensor_init(void) { /* Register OPAL interface */ opal_register(OPAL_SENSOR_READ, opal_sensor_read, 3); + + dts_sensor_create_nodes(); } diff --git a/hw/dts.c b/hw/dts.c index 288793a1c68d..356080e9e756 100644 --- a/hw/dts.c +++ b/hw/dts.c @@ -162,3 +162,45 @@ int64_t dts_sensor_read(uint32_t sensor_hndl, uint32_t *sensor_data) return 0; } + +bool dts_sensor_create_nodes(void) +{ + uint8_t sensor_class = SENSOR_DTS_CORE_TEMP|SENSOR_DTS; + + struct proc_chip *chip; + struct dt_node *sensors; + char name[64]; + + sensors = dt_find_by_path(dt_root, "/ibm,opal/sensors"); + if (!sensors) { + prlog(PR_WARNING, "DTS: creating node /ibm,opal/sensors\n"); + sensors = dt_new(opal_node, "sensors"); + } + + /* 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..f506c58efb6f 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(void); #endif /* __DTS_H */