From patchwork Thu Feb 5 06:30:54 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: 436631 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 5A5CC140271 for ; Thu, 5 Feb 2015 17:31:44 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 4B3281A0DEA for ; Thu, 5 Feb 2015 17:31:44 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 854D91A0C0C for ; Thu, 5 Feb 2015 17:31:30 +1100 (AEDT) Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Feb 2015 06:31:26 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 5 Feb 2015 06:31:25 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 9749317D8024 for ; Thu, 5 Feb 2015 06:31:33 +0000 (GMT) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t156VPVq7602510 for ; Thu, 5 Feb 2015 06:31:25 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 t156VOtG022141 for ; Wed, 4 Feb 2015 23:31:25 -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 t156VLD7022052; Wed, 4 Feb 2015 23:31:24 -0700 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: skiboot@lists.ozlabs.org Date: Thu, 5 Feb 2015 07:30:54 +0100 Message-Id: <1423117857-32759-7-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-0017-0000-0000-000002EFF1E3 Subject: [Skiboot] [PATCH 06/11] fsp-sensor: add a status property 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 adds a new status property for the sensors available on a Power system. The status of a FSP sensor can be returned by one or more PRS command modifiers. For power supply and fans, we choose the PRS modifier (and not DATA) to return the AC_FAULTED bit. For the ambient temperature, we have no choice, the DATA modifier needs to be used. We leave the decoding to the responsibility of the OS driver. This is a change from the current implementation which should not add too much complexity in the driver. The status bits being : PRS PARAM/DATA Modifier Modifier 0x0010 ON SUPPORTED 0x0008 ON 0x0004 AC FAULTED EM ALERT 0x0002 FAULTED FAULTED 0x0001 PRESENT PRESENT we will expect Linux to only use bits[1-3] to reflect the status as a *_alarm or *_fault attribute. bits [4-5] can be discarded. For the core temperature sensors, we change the trip bits layout to be the same but, as they are always set, we brutaly assign the value to nil for the moment until we know why. Signed-off-by: Cédric Le Goater --- Changes since RFC : - added DTS status hw/dts.c | 24 +++++++++++++++++++++- hw/fsp/fsp-sensor.c | 55 +++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 68 insertions(+), 11 deletions(-) diff --git a/hw/dts.c b/hw/dts.c index 356080e9e756..b5498d95924b 100644 --- a/hw/dts.c +++ b/hw/dts.c @@ -112,6 +112,12 @@ static int dts_read_core_temp(uint32_t pir, struct dts *dts) prlog(PR_TRACE, "DTS: Chip %x Core %x temp:%dC trip:%x\n", chip_id, core, 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; } @@ -158,7 +164,18 @@ int64_t dts_sensor_read(uint32_t sensor_hndl, uint32_t *sensor_data) if (attr == SENSOR_DTS_ATTR_TEMP_MAX) *sensor_data = dts.temp; else if (attr == SENSOR_DTS_ATTR_TEMP_TRIP) - *sensor_data = dts.trip; + /* + * shift left the trip bits and add a 'present' bit to + * fit the common layout for status. The meaning is + * slighty different but testing against 0x6 should + * raise an alarm + * + * fatal 11 1 + * critical 10 1 + * warning 01 1 + * no trip 00 1 + */ + *sensor_data = (dts.trip << 1) | 0x1; return 0; } @@ -199,6 +216,11 @@ bool dts_sensor_create_nodes(void) dt_add_property_string(node, "compatible", "ibm,opal-sensor"); dt_add_property_cells(node, "sensor-data", handler); + + handler = sensor_make_handler(sensor_class, + c->pir, SENSOR_DTS_ATTR_TEMP_TRIP); + dt_add_property_cells(node, "sensor-status", handler); + } } diff --git a/hw/fsp/fsp-sensor.c b/hw/fsp/fsp-sensor.c index dd178138b005..90bed4e90922 100644 --- a/hw/fsp/fsp-sensor.c +++ b/hw/fsp/fsp-sensor.c @@ -78,6 +78,7 @@ enum sensor_state { enum spcn_attr { /* mod 0x01, 0x02 */ + SENSOR_STATUS, SENSOR_PRESENT, SENSOR_FAULTED, SENSOR_AC_FAULTED, @@ -118,6 +119,7 @@ struct spcn_mod { }; static struct spcn_mod_attr prs_status_attrs[] = { + {"status", SENSOR_STATUS}, {"present", SENSOR_PRESENT}, {"faulted", SENSOR_FAULTED}, {"ac-faulted", SENSOR_AC_FAULTED}, @@ -281,6 +283,9 @@ static void fsp_sensor_process_data(struct opal_sensor_data *attr) sensor_mod_data[1] == attr->rid) { switch (attr->spcn_attr) { /* modifier 0x01, 0x02 */ + case SENSOR_STATUS: + sensor_data = sensor_mod_data[3]; + break; case SENSOR_PRESENT: prlog(PR_TRACE,"Not exported to device tree\n"); break; @@ -498,16 +503,19 @@ static inline bool sensor_frc_is_valid(uint16_t frc) * its data. The routine below provides the mapping between the * attribute and the PRS command modifier to use. * - * resource | data | thrs | - * ----------------+--------+--------+ - * power_supply | POWER | | - * ----------------+--------+--------+ - * amb-temp | DATA | | - * | | PARAM | - * ----------------+--------+--------+ - * fan | DATA | | - * | | PARAM | - * | | | + * resource | data | thrs | status | + * ----------------+--------+--------+-----------+ + * power_supply | POWER | | | + * | | | PRS | + * ----------------+--------+--------+-----------+ + * amb-temp | DATA | | DATA | + * | | PARAM | PARAM (*) | + * ----------------+--------+--------+-----------+ + * fan | DATA | | DATA (*) | + * | | PARAM | PARAM (*) | + * | | | PRS | + * + * (*) don't use the attribute given by this command modifier */ static int64_t parse_sensor_id(uint32_t handler, struct opal_sensor_data *attr) { @@ -533,6 +541,21 @@ static int64_t parse_sensor_id(uint32_t handler, struct opal_sensor_data *attr) case SENSOR_THRS: mod = SPCN_MOD_SENSOR_PARAM_FIRST; break; + + case SENSOR_STATUS: + switch (attr->frc) { + case SENSOR_FRC_AMB_TEMP: + mod = SPCN_MOD_SENSOR_DATA_FIRST; + break; + case SENSOR_FRC_POWER_SUPPLY: + case SENSOR_FRC_COOLING_FAN: + mod = SPCN_MOD_PRS_STATUS_FIRST; + break; + default: + return OPAL_PARAMETER; + } + break; + default: return OPAL_PARAMETER; } @@ -654,6 +677,8 @@ static int add_sensor_prs(struct dt_node *sensors, struct sensor_prs *prs) if (!node) return -1; + dt_add_property_cells(node, "sensor-status", + sensor_handler(prs->header, SENSOR_STATUS)); return 0; } @@ -668,6 +693,8 @@ static int add_sensor_param(struct dt_node *sensors, struct sensor_param *param) dt_add_property_string(node, "ibm,loc-code", param->location); dt_add_property_cells(node, "sensor-threshold", sensor_handler(param->header, SENSOR_THRS)); + /* don't use the status coming from the response of the + * SENSOR_PARAM subcommand */ return 0; } @@ -682,6 +709,14 @@ static int add_sensor_data(struct dt_node *sensors, dt_add_property_cells(node, "sensor-data", sensor_handler(data->header, SENSOR_DATA)); + + /* Let's make sure we are not adding a duplicate device node. + * Some resource, like fans, get their status attribute from + * three different commands ... + */ + if (data->header.frc == SENSOR_FRC_AMB_TEMP) + dt_add_property_cells(node, "sensor-status", + sensor_handler(data->header, SENSOR_STATUS)); return 0; }