From patchwork Tue Aug 3 11:56:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enric Balletbo Serra X-Patchwork-Id: 116735 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o73BuTTt009958 for ; Tue, 3 Aug 2010 11:56:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756108Ab0HCL4b (ORCPT ); Tue, 3 Aug 2010 07:56:31 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:45985 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756006Ab0HCL40 (ORCPT ); Tue, 3 Aug 2010 07:56:26 -0400 Received: by mail-ww0-f44.google.com with SMTP id 40so5028712wwj.1 for ; Tue, 03 Aug 2010 04:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=xa+5Ku5HWXkfvQnuit4VZsF/en3z3c1QbTK9OkmQPjA=; b=VxBxWO6ZHW/HlCSZlKXrOJln/0Xm/bIrl0tRay0WODggzEbN9yE0u8W5byg6AzJR0T 4mSu3Ham1WDAleKR52NVRKjN4k8D4z/jIWK+b7tpaL0HojCiwm2p3DRRUA1K8QYR0NnA aHqqpwKxlvMqXaeu7UQNQfEPJDOwlpRj8YFVk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=n7j47Ehat9FJZtrGwPDxaegJWWc0/1axVLMmx+CjDZPEUbmAF6ibIY9+pMe8bp6EAs NySs9qjs1RS1KEnD61cIaRuxtyVAND0m9US3R+k017ahAJ1EJLtU1Yja4BqSIyUrAl6p XQY2Is4LQjF9i38Y6Hj/NtvIODlO9C3XMuIBI= Received: by 10.227.72.149 with SMTP id m21mr6108730wbj.217.1280836584885; Tue, 03 Aug 2010 04:56:24 -0700 (PDT) Received: from localhost.localdomain ([81.35.234.198]) by mx.google.com with ESMTPS id e8sm3485720wej.46.2010.08.03.04.56.23 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 03 Aug 2010 04:56:24 -0700 (PDT) From: Enric Balletbo i Serra To: linux-omap@vger.kernel.org Cc: Enric Balletbo i Serra , Enric Balletbo i Serra Subject: [PATCH 3/4] omap3: fix and improve the LED handling on IGEP v2 board. Date: Tue, 3 Aug 2010 13:56:13 +0200 Message-Id: <1280836574-32467-4-git-send-email-eballetbo@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1280836574-32467-1-git-send-email-eballetbo@gmail.com> References: <1280836574-32467-1-git-send-email-eballetbo@gmail.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 03 Aug 2010 11:56:32 +0000 (UTC) diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c index d88fc08..6868dda 100644 --- a/arch/arm/mach-omap2/board-igep0020.c +++ b/arch/arm/mach-omap2/board-igep0020.c @@ -272,6 +272,54 @@ static struct omap2_hsmmc_info mmc[] = { {} /* Terminator */ }; +#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) +#include + +static struct gpio_led igep2_gpio_leds[] = { + [0] = { + .name = "led0:red", + .gpio = IGEP2_GPIO_LED0_RED, + .default_trigger = "default-off", + }, + [1] = { + .name = "led0:green", + .gpio = IGEP2_GPIO_LED0_GREEN, + .default_trigger = "default-off", + }, + [2] = { + .name = "led1:red", + .gpio = IGEP2_GPIO_LED1_RED, + .default_trigger = "default-off", + }, + [3] = { + .name = "led1:green", + .default_trigger = "heartbeat", + .gpio = -EINVAL, /* gets replaced */ + }, +}; + +static struct gpio_led_platform_data igep2_led_pdata = { + .leds = igep2_gpio_leds, + .num_leds = ARRAY_SIZE(igep2_gpio_leds), +}; + +static struct platform_device igep2_led_device = { + .name = "leds-gpio", + .id = -1, + .dev = { + .platform_data = &igep2_led_pdata, + }, +}; + +static void __init igep2_init_led(void) +{ + platform_device_register(&igep2_led_device); +} + +#else +static inline void igep2_init_led(void) {} +#endif + static int igep2_twl_gpio_setup(struct device *dev, unsigned gpio, unsigned ngpio) { @@ -295,6 +343,18 @@ static int igep2_twl_gpio_setup(struct device *dev, gpio_request(gpio + TWL4030_GPIO_MAX, "GPIO_USB_CPEN"); gpio_direction_output(gpio + TWL4030_GPIO_MAX, 0); + /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */ +#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE) + if ((gpio_request(gpio + TWL4030_GPIO_MAX + 1, "led1:green") == 0) && + (gpio_direction_output(gpio + TWL4030_GPIO_MAX + 1, 1) == 0)) { + gpio_export(gpio + TWL4030_GPIO_MAX + 1, 0); + gpio_set_value(gpio + TWL4030_GPIO_MAX + 1, 0); + } else + pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_GREEN\n"); +#else + igep2_gpio_leds[3].gpio = gpio + TWL4030_GPIO_MAX + 1; +#endif + return 0; }; @@ -302,7 +362,7 @@ static struct twl4030_gpio_platform_data igep2_gpio_data = { .gpio_base = OMAP_MAX_GPIO_LINES, .irq_base = TWL4030_GPIO_IRQ_BASE, .irq_end = TWL4030_GPIO_IRQ_END, - .use_leds = false, + .use_leds = true, .setup = igep2_twl_gpio_setup, }; @@ -376,47 +436,6 @@ static void __init igep2_display_init(void) pr_err("IGEP v2: Could not obtain gpio GPIO_DVI_PUP\n"); } -#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) -#include - -static struct gpio_led igep2_gpio_leds[] = { - { - .name = "led0:red", - .gpio = IGEP2_GPIO_LED0_RED, - }, - { - .name = "led0:green", - .default_trigger = "heartbeat", - .gpio = IGEP2_GPIO_LED0_GREEN, - }, - { - .name = "led1:red", - .gpio = IGEP2_GPIO_LED1_RED, - }, -}; - -static struct gpio_led_platform_data igep2_led_pdata = { - .leds = igep2_gpio_leds, - .num_leds = ARRAY_SIZE(igep2_gpio_leds), -}; - -static struct platform_device igep2_led_device = { - .name = "leds-gpio", - .id = -1, - .dev = { - .platform_data = &igep2_led_pdata, - }, -}; - -static void __init igep2_init_led(void) -{ - platform_device_register(&igep2_led_device); -} - -#else -static inline void igep2_init_led(void) {} -#endif - static struct platform_device *igep2_devices[] __initdata = { &igep2_dss_device, };