From patchwork Fri Feb 20 14:27:34 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: 441988 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BD054140291 for ; Sat, 21 Feb 2015 01:30:30 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id AD9CF1A0FB0 for ; Sat, 21 Feb 2015 01:30:30 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e06smtp17.uk.ibm.com (e06smtp17.uk.ibm.com [195.75.94.113]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 655081A0ED4 for ; Sat, 21 Feb 2015 01:29:51 +1100 (AEDT) Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Feb 2015 14:29:47 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 20 Feb 2015 14:29:45 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 4CB2517D805A for ; Fri, 20 Feb 2015 14:29:59 +0000 (GMT) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t1KETijU9109996 for ; Fri, 20 Feb 2015 14:29:44 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 t1KEThmO004354 for ; Fri, 20 Feb 2015 07:29:44 -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 t1KETZdu004057; Fri, 20 Feb 2015 07:29:43 -0700 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: skiboot@lists.ozlabs.org Date: Fri, 20 Feb 2015 15:27:34 +0100 Message-Id: <1424442456-11979-12-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-0029-0000-0000-00000372E938 Subject: [Skiboot] [PATCH v2 11/13] dts: add memory buffers temperature sensors 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" The memory buffer chips (Centaur) have DTS very similar to the ones we find on the cores. Only available on open power machines for the moment. Signed-off-by: Cédric Le Goater --- doc/device-tree/ibm,opal/sensors.txt | 25 +++++++++ hw/dts.c | 96 ++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) diff --git a/doc/device-tree/ibm,opal/sensors.txt b/doc/device-tree/ibm,opal/sensors.txt index 06c57351ce9a..7d4091cb8f2d 100644 --- a/doc/device-tree/ibm,opal/sensors.txt +++ b/doc/device-tree/ibm,opal/sensors.txt @@ -74,6 +74,31 @@ ibm,opal/sensors/ { label = "Core"; }; + /* + * Centaur temperatures (DTS) nodes. Open Power only. + * + * We use the PIR of the core as a resource identifier. + */ + mem-temp@1 { + compatible = "ibm,opal-sensor"; + name = "mem-temp"; + sensor-type = "temp"; + + /* Status bits : + * + * 0x0006 CRITICAL+WARNING -> FATAL + * 0x0004 CRITICAL + * 0x0002 WARNING + * 0x0001 PRESENT + */ + sensor-data = <0x00810001>; + + /* + * These are extra properties to help Linux output. + */ + ibm,chip-id = <0x80000001>; + label = "Centaur"; + }; /* * IBM POWER8 system (FSP) sensor nodes diff --git a/hw/dts.c b/hw/dts.c index d06e3891fc88..8b2377e28966 100644 --- a/hw/dts.c +++ b/hw/dts.c @@ -30,6 +30,14 @@ #define EX_THERM_CONTROL_REG 0x10050012 #define EX_THERM_ERR_STATUS_REG 0x10050013 +/* Per memory controller Digital Thermal Sensors */ +#define THERM_MEM_DTS_RESULT0 0x2050000 + +/* Per memory controller Digital Thermal Sensors control registers */ +#define THERM_MEM_MODE_REG 0x205000F +#define THERM_MEM_CONTROL_REG 0x2050012 +#define THERM_MEM_ERR_STATUS_REG 0x2050013 + struct dts { uint8_t valid; uint8_t trip; @@ -123,12 +131,58 @@ static int dts_read_core_temp(uint32_t pir, struct dts *dts) return 0; } + +/* Different sensor locations */ +#define P8_MEM_DTS0 0 +#define P8_MEM_DTS1 1 +#define P8_MEM_ZONES 2 + +static int dts_read_mem_temp(uint32_t chip_id, struct dts *dts) +{ + uint64_t dts0; + struct dts temps[P8_MEM_ZONES]; + int i; + int rc; + + rc = xscom_read(chip_id, THERM_MEM_DTS_RESULT0, &dts0); + if (rc) + return rc; + + dts_decode_one_dts(dts0 >> 48, &temps[P8_MEM_DTS0]); + dts_decode_one_dts(dts0 >> 32, &temps[P8_MEM_DTS1]); + + for (i = 0; i < P8_MEM_ZONES; i++) { + int16_t t = temps[i].temp; + + if (!temps[i].valid) + continue; + + /* keep the max temperature of all 4 sensors */ + if (t > dts->temp) + dts->temp = t; + + dts->valid++; + dts->trip |= temps[i].trip; + } + + prlog(PR_TRACE, "DTS: Chip %x temp:%dC trip:%x\n", + chip_id, dts->temp, dts->trip); + + /* + * FIXME: The trip bits are always set ?! Just discard + * them for the moment until we understand why. + */ + dts->trip = 0; + return 0; +} + /* * DTS sensor class ids. Only one for the moment: the core * temperature. */ enum sensor_dts_class { SENSOR_DTS_CORE_TEMP, + SENSOR_DTS_MEM_TEMP, /* To be continued */ }; @@ -156,6 +210,14 @@ int64_t dts_sensor_read(uint32_t sensor_hndl, uint32_t *sensor_data) case SENSOR_DTS_CORE_TEMP: rc = dts_read_core_temp(rid, &dts); break; + case SENSOR_DTS_MEM_TEMP: + /* + * restore centaur chip id which was truncated to fit + * in the sensor handler + */ + rid |= 0x80000000; + rc = dts_read_mem_temp(rid, &dts); + break; default: rc = OPAL_PARAMETER; break; @@ -187,6 +249,7 @@ bool dts_sensor_create_nodes(struct dt_node *sensors) uint8_t sensor_class = SENSOR_DTS_CORE_TEMP|SENSOR_DTS; struct proc_chip *chip; + struct dt_node *cn; char name[64]; /* build the device tree nodes : @@ -221,5 +284,38 @@ bool dts_sensor_create_nodes(struct dt_node *sensors) } } + sensor_class = SENSOR_DTS_MEM_TEMP|SENSOR_DTS; + + /* + * sensors/mem-temp@chip for Centaurs + */ + dt_for_each_compatible(dt_root, cn, "ibm,centaur") { + uint32_t chip_id; + struct dt_node *node; + uint32_t handler; + + chip_id = dt_prop_get_u32(cn, "ibm,chip-id"); + + snprintf(name, sizeof(name), "mem-temp@%x", chip_id); + + /* + * We only have two bytes for the resource + * identifier. Let's trunctate the centaur chip id + */ + handler = sensor_make_handler(sensor_class, + chip_id & 0xffff, 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); + + handler = sensor_make_handler(sensor_class, + chip_id, SENSOR_DTS_ATTR_TEMP_TRIP); + dt_add_property_cells(node, "sensor-status", handler); + dt_add_property_string(node, "sensor-type", "temp"); + dt_add_property_cells(node, "ibm,chip-id", chip_id); + dt_add_property_string(node, "label", "Centaur"); + } + return true; }