From patchwork Thu Jan 22 07:09:19 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: 431684 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 61303140277 for ; Thu, 22 Jan 2015 18:10:03 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 3C7621A0E81 for ; Thu, 22 Jan 2015 18:10:03 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 208031A0CE0 for ; Thu, 22 Jan 2015 18:09:47 +1100 (AEDT) Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 22 Jan 2015 07:09:44 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 22 Jan 2015 07:09:42 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 17C4B1B08061 for ; Thu, 22 Jan 2015 07:09:44 +0000 (GMT) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t0M79glu59048080 for ; Thu, 22 Jan 2015 07:09:42 GMT Received: from d06av05.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t0M79f5A007455 for ; Thu, 22 Jan 2015 00:09:42 -0700 Received: from hermes.kaod.org (sig-9-84-94-176.evts.de.ibm.com [9.84.94.176]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t0M79b8H007346; Thu, 22 Jan 2015 00:09:41 -0700 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: skiboot@lists.ozlabs.org Date: Thu, 22 Jan 2015 08:09:19 +0100 Message-Id: <1421910562-18973-7-git-send-email-clg@fr.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1421910562-18973-1-git-send-email-clg@fr.ibm.com> References: <1421910562-18973-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: 15012207-0041-0000-0000-000002FC0F02 Subject: [Skiboot] [RFC PATCH v2 6/9] 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" The status of a resource is returned by one or more PRS command modifiers. Depending on the resource class, this patch adds a new status property for the resources available on the Power system. For power supply, we use the PRS modifier. For fans, also because the status returned by the PRS modifier contains a AC_FAULTED bit which seems interesting to report but we could use the DATA modifier. To be discussed. For the ambient temperature, 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. Here are the status bits : PRS PARAM/DATA Modifier Modifier 0x0010 ON SUPPORTED 0x0008 ON 0x0004 AC FAULTED EM ALERT 0x0002 FAULTED FAULTED 0x0001 PRESENT PRESENT We can discard bits 4-5 and use only 1-2-3 in the driver to reflect the status as a *_alarm or *_fault attribute as expected under Linux. Signed-off-by: Cédric Le Goater --- hw/fsp/fsp-sensor.c | 54 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/hw/fsp/fsp-sensor.c b/hw/fsp/fsp-sensor.c index dd178138b005..c08e79dae6b3 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 +676,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 +692,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 +708,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; }