From patchwork Sat Mar 28 16:40:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Nortmann X-Patchwork-Id: 455747 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id A94B114007D for ; Sun, 29 Mar 2015 22:24:56 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 87DDCA7469; Sun, 29 Mar 2015 13:24:52 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I_v39Q5ZXdK4; Sun, 29 Mar 2015 13:24:52 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0E2F1A748B; Sun, 29 Mar 2015 13:24:47 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 45CA9A7438 for ; Sun, 29 Mar 2015 08:08:35 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SertQx-q_-ko for ; Sun, 29 Mar 2015 08:08:35 +0200 (CEST) X-Greylist: delayed 1754 seconds by postgrey-1.34 at theia; Sun, 29 Mar 2015 08:08:34 CEST X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mout.web.de (mout.web.de [212.227.17.12]) by theia.denx.de (Postfix) with ESMTPS id 0ED9AA7428 for ; Sun, 29 Mar 2015 08:08:34 +0200 (CEST) Received: from [172.16.0.1] ([79.244.63.124]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0LuuFh-1Zbb404ABl-0106SN for ; Sat, 28 Mar 2015 17:40:54 +0100 Message-ID: <5516D996.4050001@web.de> Date: Sat, 28 Mar 2015 17:40:54 +0100 From: Bernhard Nortmann User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: u-boot@lists.denx.de X-Provags-ID: V03:K0:xAHLDy9WhsPyG69GUK2BjI8AERzu3JprhPjDcJoH4xKawLS5CIq MH8wKtVyFqvf2jZ7IK3dY0/Cq+rSpM2tpqyRAFs3YOtFg/ZlC/+OzhKr6mEmG4isYKUdgxM 952PTv60Kruxj6003mxdtp3qIpKw0usB+oLJzahjlK60V6Hk6EOjj2l7lVxV25f73hvdIDS XOizqgZB6hjC9If8/Lueg== X-UI-Out-Filterresults: notjunk:1; X-Mailman-Approved-At: Sun, 29 Mar 2015 13:24:43 +0200 Subject: [U-Boot] allow LED initialization without STATUS_LED_BOOT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" For current U-Boot to initialize status LEDs via status_led_init(), it is required to have both CONFIG_STATUS_LED and STATUS_LED_BOOT defined. This may be a particular concern with GPIO LEDs, where __led_init() is required to correctly set up the GPIO (gpio_request and gpio_direction_output). Without STATUS_LED_BOOT the initialization isn't called, which could leave the user with a non-functional "led" command - due to the fact that the LED routines in gpio_led.c use gpio_set_value() just fine, but the GPIO never got set up properly in the first place. I think having CONFIG_STATUS_LED is sufficient to justify a corresponding call to status_led_init(), even with no STATUS_LED_BOOT defined. To do so, common/board_r.c needs some way to call that routine either directly (which probably requires exposing it via status_led.h) or indirectly. For the latter, I've attached a patch that (ab)uses an invalid LED id in status_led_set() to enforce the init. Regards, B. Nortmann --- common/board_r.c | 10 +++++++--- drivers/misc/status_led.c | 7 ++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/common/board_r.c b/common/board_r.c index 0335f6b..c67f459 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -547,11 +547,15 @@ static int initr_kgdb(void) } #endif -#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT) +#ifdef CONFIG_STATUS_LED static int initr_status_led(void) { +#ifdef STATUS_LED_BOOT status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING); - +#else + /* use invalid LED id to enforce status_led_init() */ + status_led_set(-1, 0); +#endif return 0; } #endif @@ -838,7 +842,7 @@ init_fnc_t init_sequence_r[] = { || defined(CONFIG_M68K) timer_init, /* initialize timer */ #endif -#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT) +#ifdef CONFIG_STATUS_LED initr_status_led, #endif /* PPC has a udelay(20) here dating from 2002. Why? */ diff --git a/drivers/misc/status_led.c b/drivers/misc/status_led.c index ed9adb2..4751c8d 100644 --- a/drivers/misc/status_led.c +++ b/drivers/misc/status_led.c @@ -94,12 +94,13 @@ void status_led_set (int led, int state) { led_dev_t *ld; - if (led < 0 || led >= MAX_LED_DEV) - return; - + /* reordered, allows using invalid led ID to enforce init */ if (!status_led_init_done) status_led_init (); + if (led < 0 || led >= MAX_LED_DEV) + return; + ld = &led_dev[led]; ld->state = state;