Add support for GPIO LEDs on pandora
Subsystems (3)
PATCH 1/2 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.
--- arch/arm/mach-omap2/board-omap3pandora.c | 60 ++++++++++++++++++++++++++++++ 1 files changed, 60 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/board-omap3pandora.c +60 -0
@@ -28,6 +28,7 @@#include <linux/spi/spi.h> #include <linux/spi/ads7846.h> #include <linux/i2c/twl4030.h> +#include <linux/leds.h> #include <linux/mtd/mtd.h> #include <linux/mtd/nand.h>
@@ -166,6 +167,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 ="backlight" , + .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) {
@@ -174,6 +222,16 @@ static int omap3pandora_twl_gpio_setup(struct device *dev, omap3pandora_mmc[1 ].gpio_cd = gpio +1 ;hsmmc_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 ; }
@@ -181,6 +239,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, };
@@ -285,6 +344,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 )
Signature · 1 line
1.5.4.3
PATCH 2/2 Enable LEDs in pandora defconfig
--- arch/arm/configs/omap3_pandora_defconfig | 51 +++++++++++++++++++++--------- 1 files changed, 36 insertions(+), 15 deletions(-)
arch/arm/configs/omap3_pandora_defconfig +36 -15
@@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit -# Linux kernel version: 2.6.28-rc3-omap1 -# Wed Nov 5 22:02:43 2008 +# Linux kernel version: 2.6.28-rc6-omap1 +# Thu Nov 27 00:25:13 2008 # CONFIG_ARM=y CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@@ -418,7 +418,9 @@ CONFIG_DEFAULT_TCP_CONG="cubic" CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" CONFIG_STANDALONE=y CONFIG_PREVENT_FIRMWARE_BUILD=y -# CONFIG_FW_LOADER is not set +CONFIG_FW_LOADER=y +# CONFIG_FIRMWARE_IN_KERNEL is not set +CONFIG_EXTRA_FIRMWARE="" # CONFIG_DEBUG_DRIVER is not set # CONFIG_DEBUG_DEVRES is not set # CONFIG_SYS_HYPERVISOR is not set
@@ -777,6 +779,10 @@ CONFIG_GPIOLIB=y # CONFIG_GPIO_SYSFS is not set # +# Memory mapped GPIO expanders: +# + +# # I2C GPIO expanders: # # CONFIG_GPIO_MAX732X is not set
@@ -799,11 +805,11 @@ CONFIG_GPIO_TWL4030=y # CONFIG_THERMAL is not set # CONFIG_THERMAL_HWMON is not set # CONFIG_WATCHDOG is not set +CONFIG_SSB_POSSIBLE=y # # Sonics Silicon Backplane # -CONFIG_SSB_POSSIBLE=y # CONFIG_SSB is not set #
@@ -871,6 +877,7 @@ CONFIG_FB_CFB_IMAGEBLIT=y # CONFIG_FB_S1D13XXX is not set # CONFIG_FB_VIRTUAL is not set # CONFIG_FB_METRONOME is not set +# CONFIG_FB_MB862XX is not set CONFIG_FB_OMAP=y # CONFIG_FB_OMAP_LCDC_EXTERNAL is not set # CONFIG_FB_OMAP_BOOTLOADER_INIT is not set
@@ -967,7 +974,6 @@ CONFIG_USB_MON=y # CONFIG_USB_C67X00_HCD is not set # CONFIG_USB_EHCI_HCD is not set # CONFIG_USB_ISP116X_HCD is not set -# CONFIG_USB_ISP1760_HCD is not set # CONFIG_USB_OHCI_HCD is not set # CONFIG_USB_SL811_HCD is not set # CONFIG_USB_R8A66597_HCD is not set
@@ -997,11 +1003,11 @@ CONFIG_USB_INVENTRA_DMA=y # CONFIG_USB_TMC is not set # -# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' +# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed; # # -# may also be needed; see USB_STORAGE Help for more information +# see USB_STORAGE Help for more information # # CONFIG_USB_STORAGE is not set # CONFIG_USB_LIBUSUAL is not set
@@ -1090,7 +1096,27 @@ CONFIG_MMC_OMAP_HS=y # CONFIG_MMC_SPI is not set # CONFIG_MEMSTICK is not set # CONFIG_ACCESSIBILITY is not set -# CONFIG_NEW_LEDS is not set +CONFIG_NEW_LEDS=y +CONFIG_LEDS_CLASS=y + +# +# LED drivers +# +# CONFIG_LEDS_OMAP_DEBUG is not set +# CONFIG_LEDS_OMAP is not set +# CONFIG_LEDS_OMAP_PWM is not set +# CONFIG_LEDS_PCA9532 is not set +CONFIG_LEDS_GPIO=y +# CONFIG_LEDS_PCA955X is not set + +# +# LED Triggers +# +CONFIG_LEDS_TRIGGERS=y +CONFIG_LEDS_TRIGGER_TIMER=y +CONFIG_LEDS_TRIGGER_HEARTBEAT=y +CONFIG_LEDS_TRIGGER_BACKLIGHT=y +CONFIG_LEDS_TRIGGER_DEFAULT_ON=y CONFIG_RTC_LIB=y CONFIG_RTC_CLASS=y CONFIG_RTC_HCTOSYS=y
@@ -1122,12 +1148,14 @@ CONFIG_RTC_INTF_DEV=y CONFIG_RTC_DRV_TWL4030=y # CONFIG_RTC_DRV_S35390A is not set # CONFIG_RTC_DRV_FM3130 is not set +# CONFIG_RTC_DRV_RX8581 is not set # # SPI RTC drivers # # CONFIG_RTC_DRV_M41T94 is not set # CONFIG_RTC_DRV_DS1305 is not set +# CONFIG_RTC_DRV_DS1390 is not set # CONFIG_RTC_DRV_MAX6902 is not set # CONFIG_RTC_DRV_R9701 is not set # CONFIG_RTC_DRV_RS5C348 is not set
@@ -1152,14 +1180,7 @@ CONFIG_RTC_DRV_TWL4030=y # on-CPU RTC drivers # # CONFIG_DMADEVICES is not set - -# -# Voltage and Current regulators -# # CONFIG_REGULATOR is not set -# CONFIG_REGULATOR_FIXED_VOLTAGE is not set -# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set -# CONFIG_REGULATOR_BQ24022 is not set # CONFIG_UIO is not set #
Signature · 1 line
1.5.4.3
Tony Lindgren
maintainerQuoted 4 lines · Grazvydas Ignotas
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.
Pushing to l-o tree and adding to omap3-upstream queue for next merge window. Not adding the defconfig changes to upstream queue right now as the patch does not apply.
Tony
Quoted 111 lines
Signed-off-by Grazvydas Ignotas <[email protected]>--- arch/arm/mach-omap2/board-omap3pandora.c | 60 ++++++++++++++++++++++++++++++ 1 files changed, 60 insertions(+), 0 deletions(-)arch/arm/mach-omap2/board-omap3pandora.c +60
-0@@ -28,6 +28,7 @@#include <linux/spi/spi.h> #include <linux/spi/ads7846.h> #include <linux/i2c/twl4030.h> +#include <linux/leds.h> #include <linux/mtd/mtd.h> #include <linux/mtd/nand.h> @@ -166,6 +167,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 ="backlight" , + .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) {@@ -174,6 +222,16 @@ static int omap3pandora_twl_gpio_setup(struct device *dev, omap3pandora_mmc[1 ].gpio_cd = gpio +1 ;hsmmc_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 ; }@@ -181,6 +239,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, };@@ -285,6 +344,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 )Signature · 6 lines
1.5.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Op 8 jan 2009, om 15:32 heeft Tony Lindgren het volgende geschreven:
Quoted 6 lines · Grazvydas Ignotas
Quoted 4 lines
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.
Quoted 8 lines
Pushing to l-o tree and adding to omap3-upstream queue for next merge window. Not adding the defconfig changes to upstream queue right now as the patch does not apply.
arch/arm/mach-omap2/board-omap3pandora.c static struct omap_uart_config omap3pandora_uart_config __initdata = { · line 183
Quoted 5 lines
arch/arm/mach-omap2/board-omap3pandora.c +3
-0+ .name = "pandora::lcd_bl", + .default_trigger = "backlight", + .gpio = -EINVAL,
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 meant to sync leds with the backlight (e.g. dim keypad leds), not to make leds a backlight.
regards,
Koen
Tony Lindgren
maintainerQuoted 13 lines · Koen Kooi
Op 8 jan 2009, om 15:32 heeft Tony Lindgren het volgende geschreven:
Quoted 10 lines · Grazvydas Ignotas
Quoted 4 lines
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.
Pushing to l-o tree and adding to omap3-upstream queue for next merge window. Not adding the defconfig changes to upstream queue right now as the patch does not apply.
Quoted 1 line
Quoted 9 lines
Quoted 4 lines
arch/arm/mach-omap2/board-omap3pandora.c static struct omap_uart_config omap3pandora_uart_config __initdata = { · line 183
Quoted 4 lines
arch/arm/mach-omap2/board-omap3pandora.c +3
-0+ .name = "pandora::lcd_bl", + .default_trigger = "backlight", + .gpio = -EINVAL,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 meant to sync leds with the backlight (e.g. dim keypad leds), not to make leds a backlight.
OK, thanks, dropping from l-o and omap3-upstream.
Tony
Quoted 2 lines · Koen Kooi
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.
Quoted 2 lines
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.
Quoted 7 lines · Mark Brown
Quoted 2 lines · Koen Kooi
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.
Quoted 7 lines
Quoted 2 lines
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 <[email protected]>
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.
--- arch/arm/mach-omap2/board-omap3pandora.c | 60 ++++++++++++++++++++++++++++++ 1 files changed, 60 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/board-omap3pandora.c +60 -0
@@ -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 )
Signature · 1 line
1.5.4.3
Quoted 2 lines · Grazvydas Ignotas
Well this was only temporary solution until we have proper code to control BL using TWL4030's PWM capability.
I have code to support the PWM0/PWM1 signals that needs testing, so that's not far away. The LEDA/LEDB PWMs can control brightness of those two signals, as part of that same patch.
- Dave
Tony Lindgren
maintainerQuoted 7 lines · David Brownell
Quoted 2 lines · Grazvydas Ignotas
Well this was only temporary solution until we have proper code to control BL using TWL4030's PWM capability.
I have code to support the PWM0/PWM1 signals that needs testing, so that's not far away. The LEDA/LEDB PWMs can control brightness of those two signals, as part of that same patch.
OK, let's wait a bit then so these patches can be done directly against the mainline tree. So not pushing Grazvydas' patch to l-o at this point.
Regards,
Tony