On Thu, Jan 8, 2009 at 5:28 PM, Mark Brown <broonie@xxxxxxxxxxxxx> wrote: > On Thu, Jan 08, 2009 at 03:56:07PM +0100, Koen Kooi wrote: > >> That's a wrong usage of the 'backlight' trigger, which shouldn't get >> into mainline since it sets a bad example. The backlight trigger is > > Too late, it's already there. > >> meant to sync leds with the backlight (e.g. dim keypad leds), not to >> make leds a backlight. > > Indeed, though it does get the job done (modulo setting the brightness > via the backlight interface). I'm not sure if it's better to make the > existing trigger to do what we want or to come up with some other way of > using LEDs as a backlight. Well this was only temporary solution until we have proper code to control BL using TWL4030's PWM capability. Attached is a patch which uses "always on" trigger instead, if that is still of any use.
From ada0defe08eb8f3dcddbcb0b885791edfce82744 Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas <notasas@xxxxxxxxx> Date: Thu, 27 Nov 2008 00:10:35 +0200 Subject: [PATCH] Add support for GPIO LEDs on pandora Pandora has some LEDs and backlights connected to OMAP GPIOs and TWL4030/TPS65950 LED/PWM signals. This patch registers them all with leds-gpio driver. TWL4030/TPS65950 controlled ones will be switched to PWM driver when it's ready. Signed-off-by: Grazvydas Ignotas <notasas@xxxxxxxxx> --- arch/arm/mach-omap2/board-omap3pandora.c | 60 ++++++++++++++++++++++++++++++ 1 files changed, 60 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c index b319610..64477aa 100644 --- a/arch/arm/mach-omap2/board-omap3pandora.c +++ b/arch/arm/mach-omap2/board-omap3pandora.c @@ -24,6 +24,7 @@ #include <linux/spi/spi.h> #include <linux/spi/ads7846.h> #include <linux/i2c/twl4030.h> +#include <linux/leds.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> @@ -61,6 +62,53 @@ static struct omap_uart_config omap3pandora_uart_config __initdata = { .enabled_uarts = (1 << 2), /* UART3 */ }; +static struct gpio_led omap3pandora_gpio_leds[] = { + { + .name = "pandora::keypad_bl", + .gpio = -EINVAL, /* gets replaced */ + .active_low = true, + }, { + .name = "pandora::power", + .default_trigger = "default-on", + .gpio = -EINVAL, + .active_low = true, + }, { + .name = "pandora::lcd_bl", + .default_trigger = "default-on", + .gpio = -EINVAL, + }, { + .name = "pandora::charger", + .gpio = -EINVAL, + }, { + .name = "pandora::sd1", + .default_trigger = "mmc0", + .gpio = 128, + }, { + .name = "pandora::sd2", + .default_trigger = "mmc1", + .gpio = 129, + }, { + .name = "pandora::bluetooth", + .gpio = 158, + }, { + .name = "pandora::wifi", + .gpio = 159, + }, +}; + +static struct gpio_led_platform_data omap3pandora_gpio_led_data = { + .leds = omap3pandora_gpio_leds, + .num_leds = ARRAY_SIZE(omap3pandora_gpio_leds), +}; + +static struct platform_device omap3pandora_leds_gpio = { + .name = "leds-gpio", + .id = -1, + .dev = { + .platform_data = &omap3pandora_gpio_led_data, + }, +}; + static int omap3pandora_twl_gpio_setup(struct device *dev, unsigned gpio, unsigned ngpio) { @@ -69,6 +117,16 @@ static int omap3pandora_twl_gpio_setup(struct device *dev, omap3pandora_mmc[1].gpio_cd = gpio + 1; twl4030_mmc_init(omap3pandora_mmc); + /* TWL4030_GPIO_MAX + 0 == ledA, KEYPAD_BACKLIGHT (out, active low) */ + omap3pandora_gpio_leds[0].gpio = gpio + TWL4030_GPIO_MAX + 0; + + /* TWL4030_GPIO_MAX + 1 == ledB, POWER_LED (out, active low) */ + omap3pandora_gpio_leds[1].gpio = gpio + TWL4030_GPIO_MAX + 1; + + /* gpio + {6,7} is PWM{0,1}, LCD_BACKLIGHT and CHARGER_LED */ + omap3pandora_gpio_leds[2].gpio = gpio + 6; + omap3pandora_gpio_leds[3].gpio = gpio + 7; + return 0; } @@ -76,6 +134,7 @@ static struct twl4030_gpio_platform_data omap3pandora_gpio_data = { .gpio_base = OMAP_MAX_GPIO_LINES, .irq_base = TWL4030_GPIO_IRQ_BASE, .irq_end = TWL4030_GPIO_IRQ_END, + .use_leds = true, .setup = omap3pandora_twl_gpio_setup, }; @@ -180,6 +239,7 @@ static struct omap_board_config_kernel omap3pandora_config[] __initdata = { static struct platform_device *omap3pandora_devices[] __initdata = { &omap3pandora_lcd_device, + &omap3pandora_leds_gpio, }; static void __init omap3pandora_init(void) -- 1.5.4.3