ARM: OMAP3/4: Correct support for PWM LEDs/backlight
Subsystems (3)
cover ARM: OMAP3/4: Correct support for PWM LEDs/backlight
Hi,
The pwm-leds driver update is going for 3.9:
https://lkml.org/lkml/2012/12/21/99
This series will make sure that in 3.9 we are going to have working LEDs and backlight on these boards.
As a note: 4430SDP never had working backlight and the charger led did not worked for couple of releases already due to wrong pwm_id.
On BeagleBoard we will be able to adjust the brighness of pmu_stat LED instead of full on/off.
Zoom2 will have working keypad light and the backlight will be moved to be handled by the generic pwm-backlight driver.
This series will also fix a compile error in board-zoom-display.c caused by the changes in twl-core - which I missed :(
The DT support for these are going to be sent later.
Tony: can you apply this - if it looks OK - so it will hit linux-next before the second batch of twl-core update?
Regards,
Peter
---
Peter Ujfalusi (3):
ARM: OMAP: board-4430sdp: Proper support for TWL6030 PWM LED/Backlight
ARM: OMAP: omap3beagle: Use the pwm_leds driver to control the PMU_STAT led
ARM: OMAP: zoom: Use pwm stack for lcd and keyboard backlight
arch/arm/mach-omap2/board-4430sdp.c | 31 ++++++++++++++- arch/arm/mach-omap2/board-omap3beagle.c | 39 +++++++++++++++---- arch/arm/mach-omap2/board-zoom-display.c | 56 ---------------------------- arch/arm/mach-omap2/board-zoom-peripherals.c | 53 +++++++++++++++++++++++++- 4 files changed, 113 insertions(+), 66 deletions(-)
Signature · 1 line
1.8.0.2
PATCH 1/3 ARM: OMAP: board-4430sdp: Proper support for TWL6030 PWM LED/Backlight
New PWM drivers are being prepared for twl series which will enable the use of all PWMs (PWMs and LEDs).
They are implemented as generic PWM drivers to be able to use them for different purposes.
The current platform code was broken: the leds_pwm driver was not able to pick up the PWM since the pwm_id was incorrect.
With the other patches we will be able to control the followings:
LCD backlight via pwm-backlight driver
Keypad leds via leds_pwm driver as normal LED
Charging indicator via leds_pwm driver as normal LED
--- arch/arm/mach-omap2/board-4430sdp.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)
arch/arm/mach-omap2/board-4430sdp.c +30 -1
@@ -24,8 +24,10 @@#include <linux/gpio_keys.h> #include <linux/regulator/machine.h> #include <linux/regulator/fixed.h> +#include <linux/pwm.h> #include <linux/leds.h> #include <linux/leds_pwm.h> +#include <linux/pwm_backlight.h> #include <linux/platform_data/omap4-keypad.h> #include <linux/usb/musb.h>
@@ -256,10 +258,20 @@ static struct gpio_led_platform_data sdp4430_led_data = { .num_leds = ARRAY_SIZE(sdp4430_gpio_leds), }; +static struct pwm_lookup sdp4430_pwm_lookup[] = { +PWM_LOOKUP ("twl-pwm" ,0 ,"leds_pwm" ,"omap4::keypad" ), +PWM_LOOKUP ("twl-pwm" ,1 ,"pwm-backlight" ,"backlight" ), +PWM_LOOKUP ("twl-pwmled" ,0 ,"leds_pwm" ,"omap4:green:chrg" ), +}; +static struct led_pwm sdp4430_pwm_leds[] = { { + .name ="omap4::keypad" , + .max_brightness =127 , + .pwm_period_ns =7812500 , + }, + { .name ="omap4:green:chrg" , - .pwm_id =1 , .max_brightness =255 , .pwm_period_ns =7812500 , },
@@ -278,6 +290,21 @@ static struct platform_device sdp4430_leds_pwm = { }, }; +static struct platform_pwm_backlight_data sdp4430_backlight_data = { + .pwm_id =1 , + .max_brightness =127 , + .dft_brightness =127 , + .pwm_period_ns =7812500 , +}; + +static struct platform_device sdp4430_backlight_pwm = { + .name ="pwm-backlight" , + .id =-1 , + .dev = { + .platform_data = &sdp4430_backlight_data, + }, +}; +static int omap_prox_activate (struct device *dev) {gpio_set_value (OMAP4_SFH7741_ENABLE_GPIO ,1 );
@@ -412,6 +439,7 @@ static struct platform_device *sdp4430_devices[] __initdata = { &sdp4430_gpio_keys_device, &sdp4430_leds_gpio, &sdp4430_leds_pwm, + &sdp4430_backlight_pwm, &sdp4430_vbat, &sdp4430_dmic_codec, &sdp4430_abe_audio,
@@ -707,6 +735,7 @@ static void __init omap_4430sdp_init(void) ARRAY_SIZE(sdp4430_spi_board_info)); } +pwm_add_table (sdp4430_pwm_lookup,ARRAY_SIZE (sdp4430_pwm_lookup)); status =omap4_keyboard_init (&sdp4430_keypad_data, &keypad_data);if (status)pr_err ("Keypad initialization failed: %d\n" , status);
Signature · 1 line
1.8.0.2
PATCH 2/3 ARM: OMAP: omap3beagle: Use the pwm_leds driver to control the PMU_STAT led
In reply to Peter UjfalusiWith the PWM backed driver the PMU_STAT led's brighness can be controlled. This needs the new drivers for the TWL PWM/LED to work.
--- arch/arm/mach-omap2/board-omap3beagle.c | 39 ++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-)
arch/arm/mach-omap2/board-omap3beagle.c +31 -8
@@ -20,6 +20,8 @@#include <linux/clk.h> #include <linux/io.h> #include <linux/leds.h> +#include <linux/pwm.h> +#include <linux/leds_pwm.h> #include <linux/gpio.h> #include <linux/input.h> #include <linux/gpio_keys.h>
@@ -55,6 +57,32 @@#define NAND_CS 0 +static struct pwm_lookup pwm_lookup[] = { +/* LEDB -> PMU_STAT */ +PWM_LOOKUP ("twl-pwmled" ,1 ,"leds_pwm" ,"beagleboard::pmu_stat" ), +}; + +static struct led_pwm pwm_leds[] = { + { + .name ="beagleboard::pmu_stat" , + .max_brightness =127 , + .pwm_period_ns =333 , + }, +}; + +static struct led_pwm_platform_data pwm_data = { + .num_leds =ARRAY_SIZE (pwm_leds), + .leds = pwm_leds, +}; + +static struct platform_device leds_pwm = { + .name ="leds_pwm" , + .id =-1 , + .dev = { + .platform_data = &pwm_data, + }, +}; +/* * OMAP3 Beagle revision * Run time detection of Beagle revision is done by reading GPIO.
@@ -292,9 +320,6 @@ static int beagle_twl_gpio_setup(struct device *dev,gpio_request_one (gpio +TWL4030_GPIO_MAX , beagle_config.usb_pwr_level,"nEN_USB_PWR" ); -/* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */ - gpio_leds[2 ].gpio = gpio +TWL4030_GPIO_MAX +1 ; -return 0 ; }
@@ -376,11 +401,6 @@ static struct gpio_led gpio_leds[] = { .default_trigger = "mmc0", .gpio = 149, }, - { - .name = "beagleboard::pmu_stat", - .gpio = -EINVAL, /* gets replaced */ - .active_low = true, - }, }; static struct gpio_led_platform_data gpio_led_info = {
@@ -428,6 +448,7 @@ static struct platform_device *omap3_beagle_devices[] __initdata = { &leds_gpio, &keys_gpio, &madc_hwmon, + &leds_pwm, }; static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
@@ -532,6 +553,8 @@ static void __init omap3_beagle_init(void)/* Ensure SDRC pins are mux'd for self-refresh */ omap_mux_init_signal ("sdrc_cke0" ,OMAP_PIN_OUTPUT );omap_mux_init_signal ("sdrc_cke1" ,OMAP_PIN_OUTPUT ); + +pwm_add_table (pwm_lookup,ARRAY_SIZE (pwm_lookup)); }MACHINE_START (OMAP3_BEAGLE ,"OMAP3 Beagle Board" )
Signature · 1 line
1.8.0.2
PATCH 3/3 ARM: OMAP: zoom: Use pwm stack for lcd and keyboard backlight
In reply to Peter UjfalusiUse pwm_leds driver for the keyboard light and pwm-backlight for the lcd backlight control (instead of implementing the PWM driver part in the board file).
--- arch/arm/mach-omap2/board-zoom-display.c | 56 ---------------------------- arch/arm/mach-omap2/board-zoom-peripherals.c | 53 +++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 57 deletions(-)
arch/arm/mach-omap2/board-zoom-display.c +0 -56
@@ -12,7 +12,6 @@#include <linux/init.h> #include <linux/platform_device.h> #include <linux/gpio.h> -#include <linux/i2c/twl.h> #include <linux/spi/spi.h> #include <linux/platform_data/spi-omap2-mcspi.h> #include <video/omapdss.h>
@@ -49,59 +48,6 @@ static void zoom_panel_disable_lcd(struct omap_dss_device *dssdev) { } -/* -* PWMA/B register offsets (TWL4030_MODULE_PWMA) -*/ -#define TWL_INTBR_PMBR1 0xD -#define TWL_INTBR_GPBR1 0xC -#define TWL_LED_PWMON 0x0 -#define TWL_LED_PWMOFF 0x1 - -static int zoom_set_bl_intensity (struct omap_dss_device *dssdev,int level) -{ -#ifdef CONFIG_TWL4030_CORE -unsigned char c; -u8 mux_pwm, enb_pwm; - -if (level >100 ) -return -1 ; - -twl_i2c_read_u8 (TWL4030_MODULE_INTBR , &mux_pwm,TWL_INTBR_PMBR1 ); -twl_i2c_read_u8 (TWL4030_MODULE_INTBR , &enb_pwm,TWL_INTBR_GPBR1 ); - -if (level ==0 ) { -/* disable pwm1 output and clock */ - enb_pwm = enb_pwm &0xF5 ; -/* change pwm1 pin to gpio pin */ - mux_pwm = mux_pwm &0xCF ; -twl_i2c_write_u8 (TWL4030_MODULE_INTBR , - enb_pwm,TWL_INTBR_GPBR1 ); -twl_i2c_write_u8 (TWL4030_MODULE_INTBR , - mux_pwm,TWL_INTBR_PMBR1 ); -return 0 ; - } - -if (!((enb_pwm &0xA ) && (mux_pwm &0x30 ))) { -/* change gpio pin to pwm1 pin */ - mux_pwm = mux_pwm |0x30 ; -/* enable pwm1 output and clock*/ - enb_pwm = enb_pwm |0x0A ; -twl_i2c_write_u8 (TWL4030_MODULE_INTBR , - mux_pwm,TWL_INTBR_PMBR1 ); -twl_i2c_write_u8 (TWL4030_MODULE_INTBR , - enb_pwm,TWL_INTBR_GPBR1 ); - } - - c = ((50 * (100 - level)) /100 ) +1 ; -twl_i2c_write_u8 (TWL4030_MODULE_PWM1 ,0x7F ,TWL_LED_PWMOFF ); -twl_i2c_write_u8 (TWL4030_MODULE_PWM1 , c,TWL_LED_PWMON ); -#else -pr_warn ("Backlight not enabled\n" ); -#endif - -return 0 ; -} -static struct omap_dss_device zoom_lcd_device = { .name ="lcd" , .driver_name ="NEC_8048_panel" ,
@@ -109,8 +55,6 @@ static struct omap_dss_device zoom_lcd_device = { .phy.dpi.data_lines = 24, .platform_enable = zoom_panel_enable_lcd, .platform_disable = zoom_panel_disable_lcd, - .max_backlight_level = 100, - .set_backlight = zoom_set_bl_intensity, };static struct omap_dss_device *zoom_dss_devices[] = {
arch/arm/mach-omap2/board-zoom-peripherals.c +52 -1
71 lines not on this page · raw message
Signature · 1 line
1.8.0.2
cover ARM: OMAP3/4: Correct support for PWM LEDs/backlight
In reply to Peter UjfalusiHi Tony,
Quoted 17 lines · Peter Ujfalusi
Hi,
The pwm-leds driver update is going for 3.9:
https://lkml.org/lkml/2012/12/21/99This series will make sure that in 3.9 we are going to have working LEDs and backlight on these boards.
As a note: 4430SDP never had working backlight and the charger led did not worked for couple of releases already due to wrong
pwm_id.On BeagleBoard we will be able to adjust the brighness of
pmu_statLED instead of full on/off.Zoom2 will have working keypad light and the backlight will be moved to be handled by the generic pwm-backlight driver.
Quoted 7 lines
This series will also fix a compile error in
board-zoom-display.ccaused by the changes in twl-core - which I missed :(The DT support for these are going to be sent later.
Tony: can you apply this - if it looks OK - so it will hit linux-next before the second batch of twl-core update?
The series has been generated on top of my previous series for audio support update of omap-twl4030:
http://www.mail-archive.com/linux-omap at vger.kernel.org/msg82615.html
I can regenerate this without the depending series if you prefer that way.
Quoted 15 lines
Regards,
Peter
---
Peter Ujfalusi (3):
ARM: OMAP: board-4430sdp: Proper support for TWL6030 PWM LED/Backlight
ARM: OMAP: omap3beagle: Use thepwm_ledsdriver to control thePMU_STATled
ARM: OMAP: zoom: Use pwm stack for lcd and keyboard backlightarch/arm/mach-omap2/board-4430sdp.c | 31 ++++++++++++++- arch/arm/mach-omap2/board-omap3beagle.c | 39 +++++++++++++++---- arch/arm/mach-omap2/board-zoom-display.c | 56 ---------------------------- arch/arm/mach-omap2/board-zoom-peripherals.c | 53 +++++++++++++++++++++++++- 4 files changed, 113 insertions(+), 66 deletions(-)
Signature · 1 line
P?ter