From patchwork Thu Feb 5 08:40:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 436687 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 662C0140216 for ; Thu, 5 Feb 2015 19:41:36 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 5417A1A0EB9 for ; Thu, 5 Feb 2015 19:41:36 +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 CEAD11A0E61 for ; Thu, 5 Feb 2015 19:41:32 +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 ; Thu, 5 Feb 2015 18:41:31 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 5 Feb 2015 18:41:30 +1000 Received: from d23relay07.au.ibm.com (d23relay07.au.ibm.com [9.190.26.37]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 412F63578053 for ; Thu, 5 Feb 2015 19:41:30 +1100 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t158fMvt38862864 for ; Thu, 5 Feb 2015 19:41:30 +1100 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t158eurV022828 for ; Thu, 5 Feb 2015 19:40:56 +1100 Received: from localhost.localdomain ([9.124.35.64]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t158euLN022408 for ; Thu, 5 Feb 2015 19:40:56 +1100 From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Thu, 05 Feb 2015 14:10:40 +0530 Message-ID: <20150205084040.12859.72532.stgit@localhost.localdomain> In-Reply-To: <20150205083611.12859.41225.stgit@localhost.localdomain> References: <20150205083611.12859.41225.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: 15020508-1618-0000-0000-0000018FC35D Subject: [Skiboot] [PATCH 14/22] FSP/LEDS: Add device tree nodes 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 creates a parent LED device node called 'led' under the root 'opal' device node. This also creates child device nodes under 'led' corresponding to all individual LEDs on the system whether it is an enclosure type or a descendant type with their location code as name. The location code information will be used by the host to enlist and access all the individual LEDs present on the system. The child LED device nodes also have the properties 'led-types' and 'led-loc' representing what kind of LEDs present on the same loation code and whether it is an enclosure type LED or a descendant type LED. Sample device tree output: ibm,opal { .. .. led { compatible = "ibm,opal-v3-led"; phandle = <0x1000006b>; linux,phandle = <0x1000006b>; U78C9.001.RST0027-P1-C1 { led-types = "identify", "fault"; compatible = "ibm,opal-v3-led"; led-loc = "descendent"; phandle = <0x1000006f>; linux,phandle = <0x1000006f>; }; }; }; Signed-off-by: Vasant Hegde Signed-off-by: Anshuman Khandual --- core/init.c | 6 +++++ hw/fsp/fsp-leds.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/fsp.h | 1 + 3 files changed, 68 insertions(+) diff --git a/core/init.c b/core/init.c index 2c7e30c..76eeafc 100644 --- a/core/init.c +++ b/core/init.c @@ -370,6 +370,12 @@ void __noreturn load_and_boot_kernel(bool is_reboot) */ occ_pstates_init(); + /* + * LED related SPCN commands might take a while to + * complete. Call this as late as possible. + */ + create_led_device_nodes(); + /* Set kernel command line argument if specified */ #ifdef KERNEL_COMMAND_LINE dt_add_property_string(dt_chosen, "bootargs", KERNEL_COMMAND_LINE); diff --git a/hw/fsp/fsp-leds.c b/hw/fsp/fsp-leds.c index 2ac9723..cf3328b 100644 --- a/hw/fsp/fsp-leds.c +++ b/hw/fsp/fsp-leds.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "fsp-leds.h" @@ -964,6 +965,66 @@ static struct fsp_client fsp_indicator_client = { }; /* + * create_led_device_node + * + * Creates the system parent LED device node and all individual + * child LED device nodes under it. This is called right before + * starting the payload (Linux) to ensure that the SPCN command + * sequence to fetch the LED location code list has been finished + * and to have a better chance of creating the deviced nodes. + */ +void create_led_device_nodes(void) +{ + struct fsp_led_data *led, *next; + struct dt_node *pled, *cled; + + if (!fsp_present()) + return; + + /* Make sure LED list read is completed */ + while (led_support == LED_STATE_READING) + opal_run_pollers(); + + if (led_support == LED_STATE_ABSENT) { + prlog(PR_WARNING, PREFIX "LED support not available, \ + hence device tree nodes will not be created\n"); + return; + } + + if (!opal_node) { + prlog(PR_WARNING, PREFIX + "OPAL parent device node not available\n"); + return; + } + + /* LED parent node */ + pled = dt_new(opal_node, "led"); + if (!pled) { + prlog(PR_WARNING, PREFIX + "LED parent device node creation failed\n"); + return; + } + dt_add_property_strings(pled, "compatible", "ibm,opal-v3-led"); + + /* LED child nodes */ + list_for_each_safe(&cec_ledq, led, next, link) { + cled = dt_new(pled, led->loc_code); + if (!cled) { + prlog(PR_WARNING, PREFIX + "LED child device node creation failed\n"); + continue; + } + + dt_add_property_strings(cled, "compatible", "ibm,opal-v3-led"); + dt_add_property_strings(cled, "led-types", "identify", "fault"); + if (is_enclosure_led(led->loc_code)) + dt_add_property_strings(cled, "led-loc", "enclosure"); + else + dt_add_property_strings(cled, "led-loc", "descendent"); + } +} + +/* * Process the received LED data from SPCN * * Every LED state data is added into the CEC list. If the location diff --git a/include/fsp.h b/include/fsp.h index 9ef7d9f..c2c586d 100644 --- a/include/fsp.h +++ b/include/fsp.h @@ -773,6 +773,7 @@ extern void fsp_init_diag(void); /* LED */ extern void fsp_led_init(void); +extern void create_led_device_nodes(void); /* EPOW */ extern void fsp_epow_init(void);