From patchwork Thu Apr 24 15:57:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Egli X-Patchwork-Id: 342430 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 4711E1400AD for ; Fri, 25 Apr 2014 02:06:23 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5F38A4BC73; Thu, 24 Apr 2014 18:06:06 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 Sm+cxPNte5qu; Thu, 24 Apr 2014 18:06:06 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2B6804BE2F; Thu, 24 Apr 2014 18:06:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BA42D4BE16 for ; Thu, 24 Apr 2014 18:05:48 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 wmxYF4T5zlyb for ; Thu, 24 Apr 2014 18:05:46 +0200 (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 goliath.siemens.de (goliath.siemens.de [192.35.17.28]) by theia.denx.de (Postfix) with ESMTPS id 304294BE09 for ; Thu, 24 Apr 2014 18:05:44 +0200 (CEST) Received: from mail1.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.14.3/8.14.3) with ESMTP id s3OG0I9T022174; Thu, 24 Apr 2014 18:00:18 +0200 Received: from localhost.localdomain ([139.16.77.89]) by mail1.siemens.de (8.14.3/8.14.3) with ESMTP id s3OG0HKE021236; Thu, 24 Apr 2014 18:00:17 +0200 From: Samuel Egli To: u-boot@lists.denx.de Date: Thu, 24 Apr 2014 17:57:54 +0200 Message-Id: <1398355077-6661-4-git-send-email-samuel.egli@siemens.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1398355077-6661-1-git-send-email-samuel.egli@siemens.com> References: <1398355077-6661-1-git-send-email-samuel.egli@siemens.com> Cc: pascal.bach@siemens.com, samuel.egli@siemens.com, r.meier@siemens.com Subject: [U-Boot] [PATCH 3/5] siemens: add led cmd for flexible LED control X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de * remove setting LED in user button function. We want to decouple reading user button and setting LED. This two things need to be done independently. * led cmd can be used to control LEDs that are defined in board file having a led cmd, one can easily set LEDs in u-boot shell. For example bootcmd can be extended to disable status LED before loading kernel. Signed-off-by: Samuel Egli Cc: Roger Meier Cc: Heiko Schocher Cc: Wolfgang Denk --- board/siemens/common/board.c | 46 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/board/siemens/common/board.c b/board/siemens/common/board.c index 7e8731b..2782bcc 100644 --- a/board/siemens/common/board.c +++ b/board/siemens/common/board.c @@ -128,12 +128,6 @@ do_userbutton(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) button = 0; gpio_free(gpio); - if (!button) { - /* LED0 - RED=1: GPIO2_0 2*32 = 64 */ - gpio_request(BOARD_DFU_BUTTON_LED, ""); - gpio_direction_output(BOARD_DFU_BUTTON_LED, 1); - gpio_set_value(BOARD_DFU_BUTTON_LED, 1); - } return button; } @@ -144,6 +138,46 @@ U_BOOT_CMD( "" ); #endif +/* + * This command sets led + * Input - name of led + * value of led + * Returns - 1 if input does not match + * 0 if led was set + */ +static int +do_setled(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + int gpio = 0; + if (argc != 3) + goto exit; +#if defined(BOARD_STATUS_LED) + if (!strcmp(argv[1], "stat")) + gpio = BOARD_STATUS_LED; +#endif +#if defined(BOARD_DFU_BUTTON_LED) + if (!strcmp(argv[1], "dfu")) + gpio = BOARD_DFU_BUTTON_LED; +#endif + /* If argument does not mach exit */ + if (gpio == 0) + goto exit; + gpio_request(gpio, ""); + gpio_direction_output(gpio, 1); + if (!strcmp(argv[2], "1")) + gpio_set_value(gpio, 1); + else + gpio_set_value(gpio, 0); + return 0; +exit: + return 1; +} + +U_BOOT_CMD( + led, CONFIG_SYS_MAXARGS, 2, do_setled, + "Set led on or off", + "dfu val - set dfu led\nled stat val - set status led" +); static int do_usertestwdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])