From patchwork Mon Jun 17 20:58:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Guinot X-Patchwork-Id: 252060 X-Patchwork-Delegate: prafulla@marvell.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 A79CD2C023D for ; Tue, 18 Jun 2013 06:58:23 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 16DDF4A176; Mon, 17 Jun 2013 22:57:55 +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 fa-7wwIswOco; Mon, 17 Jun 2013 22:57:54 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C94FB4A16A; Mon, 17 Jun 2013 22:57:35 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 518664A160 for ; Mon, 17 Jun 2013 22:57:18 +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 UN1G73iVbJ6f for ; Mon, 17 Jun 2013 22:57:16 +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 vm1.sequanux.org (vm1.sequanux.org [188.165.36.56]) by theia.denx.de (Postfix) with ESMTP id 292B94A164 for ; Mon, 17 Jun 2013 22:57:03 +0200 (CEST) Received: from localhost (localhost.localdomain [127.0.0.1]) by vm1.sequanux.org (Postfix) with ESMTP id CB8141081DB; Mon, 17 Jun 2013 22:57:02 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at vm1.sequanux.org Received: from vm1.sequanux.org ([127.0.0.1]) by localhost (vm1.sequanux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hopbWTyHBr+I; Mon, 17 Jun 2013 22:57:00 +0200 (CEST) Received: from localhost (stp25-2-82-234-233-9.fbx.proxad.net [82.234.233.9]) by vm1.sequanux.org (Postfix) with ESMTPSA id 7FF03108119; Mon, 17 Jun 2013 22:56:58 +0200 (CEST) From: Simon Guinot To: Prafulla Wadaskar Date: Mon, 17 Jun 2013 22:58:04 +0200 Message-Id: <1371502684-17522-4-git-send-email-simon.guinot@sequanux.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1371502684-17522-1-git-send-email-simon.guinot@sequanux.org> References: <1371502684-17522-1-git-send-email-simon.guinot@sequanux.org> Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 3/3] net2big_v2: initialize LEDs at startup 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 This patch allows to configure the net2big_v2 LEDs at startup (through the GPIO extension bus). The front blue LED is enabled and the SATA rear LEDs are configured to blink in relation with the SATA activity. Signed-off-by: Simon Guinot --- board/LaCie/net2big_v2/Makefile | 3 ++ board/LaCie/net2big_v2/net2big_v2.c | 86 +++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/board/LaCie/net2big_v2/Makefile b/board/LaCie/net2big_v2/Makefile index fbae48e..eca25e7 100644 --- a/board/LaCie/net2big_v2/Makefile +++ b/board/LaCie/net2big_v2/Makefile @@ -28,6 +28,9 @@ endif LIB = $(obj)lib$(BOARD).o COBJS := $(BOARD).o ../common/common.o +ifneq ($(and $(CONFIG_KIRKWOOD_GPIO),$(CONFIG_NET2BIG_V2)),) +COBJS += ../common/gpio-ext.o +endif SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS)) diff --git a/board/LaCie/net2big_v2/net2big_v2.c b/board/LaCie/net2big_v2/net2big_v2.c index 6cca4fb..caa9f64 100644 --- a/board/LaCie/net2big_v2/net2big_v2.c +++ b/board/LaCie/net2big_v2/net2big_v2.c @@ -30,6 +30,7 @@ #include "net2big_v2.h" #include "../common/common.h" +#include "../common/gpio-ext.h" DECLARE_GLOBAL_DATA_PTR; @@ -143,6 +144,89 @@ err: static void init_fan(void) {} #endif /* CONFIG_CMD_I2C && CONFIG_SYS_I2C_G762_ADDR */ +#if defined(CONFIG_NET2BIG_V2) && defined(CONFIG_KIRKWOOD_GPIO) +/* + * GPIO extension bus: + * + * - address register : bit [0-2] -> GPIO [47-49] + * - data register : bit [0-2] -> GPIO [44-46] + * - enable register : GPIO 29 + */ +static unsigned gpio_ext_addr[] = { 47, 48, 49 }; +static unsigned gpio_ext_data[] = { 44, 45, 46 }; + +static struct gpio_ext gpio_ext = { + .addr = gpio_ext_addr, + .num_addr = ARRAY_SIZE(gpio_ext_addr), + .data = gpio_ext_data, + .num_data = ARRAY_SIZE(gpio_ext_data), + .enable = 29, +}; + +/* + * LEDs configuration: + * + * The LEDs are controlled by a CPLD and can be configured through + * the GPIO extension bus. + * + * Address register selection: + * + * addr | register + * ---------------------------- + * 0 | front LED + * 1 | front LED brightness + * 2 | SATA LED brightness + * 3 | SATA0 LED + * 4 | SATA1 LED + * 5 | SATA2 LED + * 6 | SATA3 LED + * 7 | SATA4 LED + * + * Data register configuration: + * + * data | LED brightness + * ------------------------------------------------- + * 0 | min (off) + * - | - + * 7 | max + * + * data | front LED mode + * ------------------------------------------------- + * 0 | fix off + * 1 | fix blue on + * 2 | fix red on + * 3 | blink blue on=1 sec and blue off=1 sec + * 4 | blink red on=1 sec and red off=1 sec + * 5 | blink blue on=2.5 sec and red on=0.5 sec + * 6 | blink blue on=1 sec and red on=1 sec + * 7 | blink blue on=0.5 sec and blue off=2.5 sec + * + * data | SATA LED mode + * ------------------------------------------------- + * 0 | fix off + * 1 | SATA activity blink + * 2 | fix red on + * 3 | blink blue on=1 sec and blue off=1 sec + * 4 | blink red on=1 sec and red off=1 sec + * 5 | blink blue on=2.5 sec and red on=0.5 sec + * 6 | blink blue on=1 sec and red on=1 sec + * 7 | fix blue on + */ +static void init_leds(void) +{ + /* Enable the front blue LED */ + gpio_ext_set_value(&gpio_ext, 0, 1); + gpio_ext_set_value(&gpio_ext, 1, 3); + + /* Configure SATA LEDs to blink in relation with the SATA activity */ + gpio_ext_set_value(&gpio_ext, 3, 1); + gpio_ext_set_value(&gpio_ext, 4, 1); + gpio_ext_set_value(&gpio_ext, 2, 3); +} +#else +static void init_leds(void) {} +#endif /* CONFIG_NET2BIG_V2 && CONFIG_KIRKWOOD_GPIO */ + int misc_init_r(void) { init_fan(); @@ -153,6 +237,8 @@ int misc_init_r(void) eth_setenv_enetaddr("ethaddr", mac); } #endif + init_leds(); + return 0; } #endif /* CONFIG_MISC_INIT_R */