From patchwork Mon Apr 6 08:32:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 458351 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 8E2C81401DC for ; Mon, 6 Apr 2015 18:42:24 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 72FB31A074A for ; Mon, 6 Apr 2015 18:42:24 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e28smtp07.in.ibm.com (e28smtp07.in.ibm.com [122.248.162.7]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 72BCB1A0272 for ; Mon, 6 Apr 2015 18:42:20 +1000 (AEST) Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 6 Apr 2015 14:12:18 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp07.in.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 6 Apr 2015 14:12:16 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id D3725E0044 for ; Mon, 6 Apr 2015 14:14:40 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay05.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t368gGJ953608506 for ; Mon, 6 Apr 2015 14:12:16 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t368Qtvi021048 for ; Mon, 6 Apr 2015 13:57:03 +0530 Received: from localhost.localdomain ([9.124.35.90]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t368H8f3023944 for ; Mon, 6 Apr 2015 13:47:09 +0530 From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Mon, 06 Apr 2015 14:02:21 +0530 Message-ID: <20150406083215.24643.73948.stgit@localhost.localdomain> In-Reply-To: <20150406082641.24643.57570.stgit@localhost.localdomain> References: <20150406082641.24643.57570.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: 15040608-0025-0000-0000-0000041E765A Subject: [Skiboot] [PATCH v2 09/12] FSP/LED: Get SAI location code from device tree 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" SAI information is available in device tree. This patch parses device tree to get SAI location code information. Signed-off-by: Vasant Hegde --- hw/fsp/fsp-leds.c | 70 ++++++++++++++++++++++++++++++++++++++++++++-------- include/fsp-leds.h | 6 ++++ 2 files changed, 65 insertions(+), 11 deletions(-) diff --git a/hw/fsp/fsp-leds.c b/hw/fsp/fsp-leds.c index 1637000..5aa6f20 100644 --- a/hw/fsp/fsp-leds.c +++ b/hw/fsp/fsp-leds.c @@ -77,6 +77,13 @@ static bool spcn_cmd_complete = true; /* SPCN command complete */ static u32 last_spcn_cmd; static int replay = 0; +/* + * FSP controls System Attention Indicator. But it expects hypervisor + * keep track of the status and serve get LED state request (both from + * Linux and FSP itself)! + */ +static struct sai_data sai_data; + /* Forward declaration */ static void fsp_read_leds_data_complete(struct fsp_msg *msg); static int process_led_state_change(void); @@ -1273,6 +1280,53 @@ success: return rc; } +/* Get LED node from device tree */ +static struct dt_node *dt_get_led_node(void) +{ + struct dt_node *pled; + + if (!opal_node) { + prlog(PR_WARNING, PREFIX + "OPAL parent device node not available\n"); + return NULL; + } + + pled = dt_find_by_path(opal_node, DT_PROPERTY_LED_NODE); + if (!pled) + prlog(PR_WARNING, PREFIX + "Parent device node not available\n"); + + return pled; +} + +/* Get System attention indicator location code from device tree */ +static void dt_get_sai_loc_code(void) +{ + struct dt_node *pled, *child; + const char *led_type = NULL; + + memset(sai_data.loc_code, 0, LOC_CODE_SIZE); + + pled = dt_get_led_node(); + if (!pled) + return; + + list_for_each(&pled->children, child, list) { + led_type = dt_prop_get(child, DT_PROPERTY_LED_TYPES); + if (!led_type) + continue; + + if (strcmp(led_type, LED_TYPE_ATTENTION)) + continue; + + memcpy(sai_data.loc_code, child->name, LOC_CODE_SIZE - 1); + + prlog(PR_TRACE, PREFIX "SAI Location code = %s\n", + sai_data.loc_code); + return; + } +} + /* * create_led_device_node * @@ -1301,19 +1355,10 @@ void create_led_device_nodes(void) return; } - if (!opal_node) { - prlog(PR_WARNING, PREFIX - "OPAL parent device node not available\n"); - return; - } - /* Get LED node */ - pled = dt_find_by_path(opal_node, DT_PROPERTY_LED_NODE); - if (!pled) { - prlog(PR_WARNING, PREFIX - "Parent device node not available\n"); + pled = dt_get_led_node(); + if (!pled) return; - } dt_add_property_strings(pled, "compatible", DT_PROPERTY_LED_COMPATIBLE); @@ -1672,6 +1717,9 @@ void fsp_led_init(void) fsp_leds_query_spcn(); prlog(PR_TRACE, PREFIX "Init completed\n"); + /* Get System attention indicator state */ + dt_get_sai_loc_code(); + /* Handle FSP initiated async LED commands */ fsp_register_client(&fsp_indicator_client, FSP_MCLASS_INDICATOR); prlog(PR_TRACE, PREFIX "FSP async command client registered\n"); diff --git a/include/fsp-leds.h b/include/fsp-leds.h index 2b8ed98..1b99ffc 100644 --- a/include/fsp-leds.h +++ b/include/fsp-leds.h @@ -126,6 +126,12 @@ struct led_set_cmd { struct list_node link; }; +/* System Attention Indicator */ +struct sai_data { + uint8_t state; + char loc_code[LOC_CODE_SIZE]; +}; + /* LED commands and state */ #define LED_COMMAND_FAULT 1 #define LED_COMMAND_IDENTIFY 0