ARM: tegra: roth: LED driver platform structure
Jun Yan [Wed, 3 Apr 2013 08:37:04 +0000 (01:37 -0700)]
Moved LED related code from board-roth.c to a new file
board-roth-leds.c

Initialize LED by registering platform data and setting
the GPIO of tri-state buffer

Bug 1198937

Change-Id: I352f79ba2da70b4536b4a6683d0010df44deda8f
Signed-off-by: Jun Yan <juyan@nvidia.com>
Reviewed-on: http://git-master/r/216037
(cherry picked from commit 0e420c1b18c6ade278ef493408366d1445b60b5c)
Reviewed-on: http://git-master/r/246355
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

arch/arm/mach-tegra/Makefile
arch/arm/mach-tegra/board-roth-leds.c [new file with mode: 0644]
arch/arm/mach-tegra/board-roth.c
arch/arm/mach-tegra/board-roth.h

index 934767b..0a2a136 100644 (file)
@@ -304,3 +304,4 @@ obj-${CONFIG_MACH_ROTH}                 += board-roth-panel.o
 obj-${CONFIG_MACH_ROTH}                 += board-roth-kbc.o
 obj-${CONFIG_MACH_ROTH}                 += board-roth-sensors.o
 obj-${CONFIG_MACH_ROTH}                 += board-roth-fan.o
+obj-${CONFIG_MACH_ROTH}                 += board-roth-leds.o
diff --git a/arch/arm/mach-tegra/board-roth-leds.c b/arch/arm/mach-tegra/board-roth-leds.c
new file mode 100644 (file)
index 0000000..0737973
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * arch/arm/mach-tegra/board-roth-leds.c
+ *
+ * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#include <linux/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/leds.h>
+#include <linux/leds_pwm.h>
+#include <linux/pwm.h>
+#include <mach/gpio-tegra.h>
+#include <mach/pinmux.h>
+#include <mach/pinmux-t11.h>
+
+#include "gpio-names.h"
+#include "devices.h"
+#include "board.h"
+#include "board-common.h"
+#include "board-roth.h"
+#include "tegra-board-id.h"
+
+#define LED_ENABLE_GPIO TEGRA_GPIO_PU1
+
+#ifdef CONFIG_LEDS_PWM
+
+static struct led_pwm roth_led_info[] = {
+       {
+               .name                   = "roth-led",
+               .default_trigger        = "none",
+               .pwm_id                 = 2,
+               .active_low             = 0,
+               .max_brightness         = 255,
+               .pwm_period_ns          = 10000000,
+       },
+};
+
+static struct led_pwm_platform_data roth_leds_pdata = {
+       .leds           = roth_led_info,
+       .num_leds       = ARRAY_SIZE(roth_led_info),
+};
+
+static struct platform_device roth_leds_pwm_device = {
+       .name   = "leds_pwm",
+       .id     = -1,
+       .dev    = {
+               .platform_data = &roth_leds_pdata,
+       },
+};
+
+
+#else
+static struct gpio_led roth_led_info[] = {
+       {
+               .name                   = "roth-led",
+               .default_trigger        = "none",
+               .gpio                   = TEGRA_GPIO_PQ3,
+               .active_low             = 0,
+               .retain_state_suspended = 0,
+               .default_state          = LEDS_GPIO_DEFSTATE_OFF,
+       },
+};
+
+static struct gpio_led_platform_data roth_leds_pdata = {
+       .leds           = roth_led_info,
+       .num_leds       = ARRAY_SIZE(roth_led_info),
+};
+
+static struct platform_device roth_leds_gpio_device = {
+       .name   = "leds-gpio",
+       .id     = -1,
+       .dev    = {
+               .platform_data = &roth_leds_pdata,
+       },
+};
+#endif
+
+/*static struct platform_device *roth_led_device[] = {
+       &tegra_pwfm2_device,
+};*/
+
+int __init roth_led_init(void)
+{
+       int err;
+#ifdef CONFIG_LEDS_PWM
+       platform_device_register(&roth_leds_pwm_device);
+#else
+       platform_device_register(&roth_leds_gpio_device);
+#endif
+       gpio_request(LED_ENABLE_GPIO, "LED Trisate Buffer OE");
+       gpio_direction_output(LED_ENABLE_GPIO, 1);
+       gpio_export(LED_ENABLE_GPIO, false);
+       return 0;
+}
index f4dda63..93294bc 100644 (file)
@@ -386,30 +386,6 @@ static struct platform_device tegra_camera = {
        .id = -1,
 };
 
-static struct led_pwm roth_led_info[] = {
-       {
-               .name                   = "roth-led",
-               .default_trigger        = "none",
-               .pwm_id                 = 2,
-               .active_low             = 0,
-               .max_brightness         = 255,
-               .pwm_period_ns          = 10000000,
-       },
-};
-
-static struct led_pwm_platform_data roth_leds_pdata = {
-       .leds           = roth_led_info,
-       .num_leds       = ARRAY_SIZE(roth_led_info),
-};
-
-static struct platform_device roth_leds_pwm_device = {
-       .name   = "leds_pwm",
-       .id     = -1,
-       .dev    = {
-               .platform_data = &roth_leds_pdata,
-       },
-};
-
 
 static struct issp_platform_data roth_issp_pdata = {
        .reset_gpio     = TEGRA_GPIO_PH4,
@@ -456,8 +432,6 @@ static struct platform_device *roth_devices[] __initdata = {
 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
        &tegra_aes_device,
 #endif
-
-       &roth_leds_pwm_device,
        &roth_issp_device,
 };
 
@@ -690,6 +664,7 @@ static void __init tegra_roth_init(void)
        roth_spi_init();
        roth_usb_init();
        roth_uart_init();
+       roth_led_init();
        roth_audio_init();
        platform_add_devices(roth_devices, ARRAY_SIZE(roth_devices));
        //tegra_ram_console_debug_init();
index c479b77..d28c6df 100644 (file)
@@ -119,5 +119,6 @@ int roth_kbc_init(void);
 int roth_pmon_init(void);
 int roth_soctherm_init(void);
 int roth_fan_init(void);
+int roth_led_init(void);
 
 #endif