From patchwork Thu Jan 22 07:09:17 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: 431681 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 7F758140277 for ; Thu, 22 Jan 2015 18:09:56 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 68E7B1A0E59 for ; Thu, 22 Jan 2015 18:09:56 +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 CABCE1A0CE0 for ; Thu, 22 Jan 2015 18:09:46 +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 ; Thu, 22 Jan 2015 07:09:42 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 22 Jan 2015 07:09:41 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 45B4A2190046 for ; Thu, 22 Jan 2015 07:09:39 +0000 (GMT) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t0M79fRt62390406 for ; Thu, 22 Jan 2015 07:09:41 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 t0M79eIh007423 for ; Thu, 22 Jan 2015 00:09:40 -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 t0M79b8F007346; Thu, 22 Jan 2015 00:09:40 -0700 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: skiboot@lists.ozlabs.org Date: Thu, 22 Jan 2015 08:09:17 +0100 Message-Id: <1421910562-18973-5-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-0029-0000-0000-000002EB7D01 Subject: [Skiboot] [RFC PATCH v2 4/9] spcn: add definitions for the PRS command and modifiers 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 structures and values are from the SPCN specification document and from : https://w3-01.ibm.com/stg/linux/ltc/mailinglists/pipermail/sapphire/2014-January/001280.html for the new PRS modifier 0x1C which retrieves the power supplies watts. Signed-off-by: Cédric Le Goater --- include/spcn.h | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/include/spcn.h b/include/spcn.h index 1945e8d49232..2f3172812151 100644 --- a/include/spcn.h +++ b/include/spcn.h @@ -90,4 +90,98 @@ enum { SENSOR_FRC_IO_BP, }; +/* + * Common to all PRS modifiers (subcommands) + */ +struct sensor_header { + uint16_t frc; /* Frame resource class */ + uint16_t rid; /* Resource ID */ +} __packed; + +/* + * Data layout for PRS modifier PRS_STATUS 0x01, 0x02 + */ +struct sensor_prs { + struct sensor_header header; + uint16_t src; /* unused */ + uint16_t status; +} __packed; + +#define PRS_STATUS_ON_SUPPORTED 0x0010 +#define PRS_STATUS_ON 0x0008 +#define PRS_STATUS_AC_FAULTED 0x0004 +#define PRS_STATUS_FAULTED 0x0002 +#define PRS_STATUS_PRESENT 0x0001 + +/* + * Data layout for PRS modifier SENSOR_PARAM 0x10, 0x11 + */ +struct sensor_param { + struct sensor_header header; + char location[4]; + char __reserved[4]; + uint16_t threshold; + uint16_t status; +} __packed; + +/* + * Data layout for PRS modifier SENSOR_DATA 0x12, 0x13 + */ +struct sensor_data { + struct sensor_header header; + uint16_t data; + uint16_t status; +} __packed; + +#define SENSOR_STATUS_EM_ALERT 0x0004 +#define SENSOR_STATUS_FAULTED 0x0002 +#define SENSOR_STATUS_PRESENT 0x0001 + +/* Power sensor is retrieved thru a new PRS modifier 0x1C, data + * response is as follows: + * + * Byte 0: + * + * Bit 7: Data valid + * Bit 4-6: reserved + * Bit 0-3: Number of power supply or data records + * + * Each data record is 5 Bytes following above byte 0: + * + * Data Record: Byte 0: Power supply ID {00, 01, 02, 03, ...} + * Byte 1-4: Power sensor value in milli-watts + * + * Example Power Sensor data: (Tuleta) + * 84 00 00 00 00 00 + * 01 00 00 00 00 + * 02 00 02 5d 78 + * 03 00 02 0f 58 + * 00 00 00 00 00 + * + * 0x84: Bit 7 is valid bit and there are 4 power supplies + * 0x00 00 00 00 00 + * | ^^^^^^^^^^^ Power in milli-watts + * \-- Power supply ID + * + * Ox03 00 02 0f 58 + * | ^^^^^^^^^^^ Power in milli-watts (135000 mW) + * \-- Power supply ID + */ + +#define POWER_SUPPLY_MAX 8 + +struct sensor_power_supply { + uint8_t rid; /* Power supply ID */ + uint32_t milliwatts; +} __packed; + +struct sensor_power { + uint8_t status; + struct sensor_power_supply supplies[POWER_SUPPLY_MAX]; +} __packed; + +#define sensor_power_is_valid(s) ((s)->status & 0x80) +#define sensor_power_count(s) ((s)->status & 0x0f) + + #endif /* __SPCN_H */