From patchwork Fri Mar 20 12:09:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 452619 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 E9F1714016B for ; Fri, 20 Mar 2015 23:10:47 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id D06231A2A98 for ; Fri, 20 Mar 2015 23:10:47 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp01.au.ibm.com (e23smtp01.au.ibm.com [202.81.31.143]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 1723C1A2A8E for ; Fri, 20 Mar 2015 23:10:44 +1100 (AEDT) Received: from /spool/local by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Mar 2015 22:10:43 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 20 Mar 2015 22:10:41 +1000 Received: from d23relay10.au.ibm.com (d23relay10.au.ibm.com [9.190.26.77]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id DA8072CE8054 for ; Fri, 20 Mar 2015 23:10:39 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t2KCAVN242663986 for ; Fri, 20 Mar 2015 23:10:39 +1100 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t2KCA6k2001596 for ; Fri, 20 Mar 2015 23:10:06 +1100 Received: from localhost.localdomain ([9.124.35.34]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t2KCA5Re001247 for ; Fri, 20 Mar 2015 23:10:05 +1100 From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Fri, 20 Mar 2015 17:39:50 +0530 Message-ID: <20150320120938.29915.79151.stgit@localhost.localdomain> In-Reply-To: <20150320114829.29915.11277.stgit@localhost.localdomain> References: <20150320114829.29915.11277.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15032012-1618-0000-0000-000001C68C7C Subject: [Skiboot] [PATCH 11/15] FSP/hdata: Populate System Attention Indicator location code 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" On FSP based machine, FSP controls System Attention Indicator. This indicator detail (location code) is passed to OPAL via HDAT. OPAL OPAL can get/set this indicator via normal MBOX command. This patch takes care of parsing SLCA entry and populating device tree with SAI location code. Device Tree: We create '/ibm,opal/led' node which contains all location code LED information. 'led-types' property under each node tells LED type. For SAI indicator 'led-types' property will be 'attention'. Signed-off-by: Vasant Hegde --- hdata/hdata.h | 1 + hdata/slca.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hdata/spira.c | 3 ++ hdata/spira.h | 1 + 4 files changed, 83 insertions(+) diff --git a/hdata/hdata.h b/hdata/hdata.h index 79cc576..567927c 100644 --- a/hdata/hdata.h +++ b/hdata/hdata.h @@ -43,6 +43,7 @@ extern const struct slca_entry *slca_get_entry(uint16_t slca_index); extern const char *slca_get_vpd_name(uint16_t slca_index); extern const char *slca_get_loc_code_index(uint16_t slca_index); extern void slca_vpd_add_loc_code(struct dt_node *node, uint16_t slca_index); +extern void slca_dt_add_sai_node(void); extern bool hservices_from_hdat(const void *fdt, size_t size); diff --git a/hdata/slca.c b/hdata/slca.c index aaa5fc6..3042fbe 100644 --- a/hdata/slca.c +++ b/hdata/slca.c @@ -16,6 +16,10 @@ #include +#include +#include +#include + #include "spira.h" #include "hdata.h" @@ -89,3 +93,77 @@ void slca_vpd_add_loc_code(struct dt_node *node, uint16_t slca_index) strncpy(loc_code, fru_loc_code, LOC_CODE_SIZE - 1); dt_add_property(node, "ibm,loc-code", loc_code, strlen(loc_code) + 1); } + +/* + * Get System Attention Indicator SLCA entry + */ +static const struct slca_entry *slca_get_sai_entry(void) +{ + int count; + unsigned int i; + struct HDIF_common_hdr *slca_hdr; + + slca_hdr = get_hdif(&spira.ntuples.slca, SLCA_HDIF_SIG); + if (!slca_hdr) { + prerror("SLCA Invalid\n"); + return NULL; + } + + count = HDIF_get_iarray_size(slca_hdr, SLCA_IDATA_ARRAY); + if (count < 0) { + prerror("SLCA: Can't find SLCA array size!\n"); + return NULL; + } + + for (i = 0; i < count; i++) { + const struct slca_entry *s_entry; + unsigned int entry_sz; + + s_entry = HDIF_get_iarray_item(slca_hdr, SLCA_IDATA_ARRAY, + i, &entry_sz); + if (s_entry && + VPD_ID(s_entry->fru_id[0], + s_entry->fru_id[1]) == SLCA_SAI_INDICATOR_ID) { + prlog(PR_TRACE, "SLCA: SAI indicator index: %x\n", + s_entry->my_index); + return s_entry; + } + } + + return NULL; +} + +/* + * SLCA structure contains System Attention Indicator location + * code (FRU ID = SA). Add this information to device tree + * (under '/ibm,opal/led'). + */ +void slca_dt_add_sai_node(void) +{ + const struct slca_entry *s_entry; + struct dt_node *led_node, *sai_node; + + s_entry = slca_get_sai_entry(); + if (!s_entry) + return; + + /* Create /ibm,opal node, if its not created already */ + if (!opal_node) + return; + + /* Crete LED parent node */ + led_node = dt_find_by_path(opal_node, DT_PROPERTY_LED_NODE); + if (!led_node) + return; + + if (s_entry->loc_code_len == 0 || + s_entry->loc_code_len > LOC_CODE_SIZE) + return; + + /* Create SAI node */ + sai_node = dt_new(led_node, s_entry->loc_code); + assert(sai_node); + + dt_add_property_string(sai_node, + DT_PROPERTY_LED_TYPE, LED_TYPE_ATTENTION); +} diff --git a/hdata/spira.c b/hdata/spira.c index 11e8375..faa7e48 100644 --- a/hdata/spira.c +++ b/hdata/spira.c @@ -1027,5 +1027,8 @@ void parse_hdat(bool is_opal, uint32_t master_cpu) /* Host services information. */ hostservices_parse(); + /* Parse System Attention Indicator inforamtion */ + slca_dt_add_sai_node(); + prlog(PR_INFO, "Parsing HDAT...done\n"); } diff --git a/hdata/spira.h b/hdata/spira.h index e98edbd..0916fe3 100644 --- a/hdata/spira.h +++ b/hdata/spira.h @@ -611,6 +611,7 @@ struct slca_entry { uint8_t fru_id[2]; /* ASCII VPD ID */ #define SLCA_ROOT_VPD_ID VPD_ID('V','V') #define SLCA_SYSTEM_VPD_ID VPD_ID('S','V') +#define SLCA_SAI_INDICATOR_ID VPD_ID('S','A') __be16 parent_index; /* Parent entry index */ uint8_t flags; #define SLCA_FLAG_NON_FUNCTIONAL 0x02 /* For redundant entries */