pwm-backlight: Add GPIO and power supply support
Subsystems (10)
v2 cover pwm-backlight: Add GPIO and power supply support
This series adds the ability to specify a GPIO and a power supply to enable a backlight.
Patch 1 adds some blank lines to make the code look less cluttered in various places.
Patch 2 refactors the power on and power off sequences into separate functions in preparation for subsequent patches.
Patch 3 adds functionality to track the on/off state of the backlight. This is required by subsequent patches to make sure that enabling and disabling used resources remains balanced.
Patch 4 adds an optional GPIO to enable a backlight. This patch only includes the field within the platform data so that it can be properly setup before actually being put to use.
Patches 5 to 9 convert all users of the pwm-backlight driver to use the new field. For most of them, this just initializes the field to -1, marking the field as unused.
Patch 10 uses the new field within the pwm-backlight driver and at the same time allows it to be parsed from device tree.
Patch 11 implements support for an optional power supply. This relies on the regulator core to return a dummy regulator when no supply has been otherwise setup so the driver doesn't have to handle that specially nor require all users to be updated.
Patch 12 adds a way to keep a backlight turned off at boot. This is useful when hooking up a backlight with a subsystem such as DRM which has more explicit semantics as to when a backlight should be turned on.
Due to the dependencies within the series, I propose to take all these patches through the PWM tree, so I'll need acks from OMAP, PXA, Samsung, shmobile and Unicore32 maintainers.
Thierry
Thierry Reding (12):
pwm-backlight: Improve readability
pwm-backlight: Refactor backlight power on/off
pwm-backlight: Track enable state
pwm-backlight: Add optional enable GPIO
ARM: OMAP: Initialize PWM backlight enable_gpio field
ARM: pxa: Initialize PWM backlight enable_gpio field
ARM: SAMSUNG: Initialize PWM backlight enable_gpio field
ARM: shmobile: Initialize PWM backlight enable_gpio field
unicore32: Initialize PWM backlight enable_gpio field
pwm-backlight: Use new enable_gpio field
pwm-backlight: Add power supply support
pwm-backlight: Allow backlight to remain disabled on boot
.../bindings/video/backlight/pwm-backlight.txt | 8 ++ arch/arm/mach-omap2/board-zoom-peripherals.c | 1 + arch/arm/mach-pxa/cm-x300.c | 1 + arch/arm/mach-pxa/colibri-pxa270-income.c | 1 + arch/arm/mach-pxa/ezx.c | 1 + arch/arm/mach-pxa/hx4700.c | 1 + arch/arm/mach-pxa/lpd270.c | 1 + arch/arm/mach-pxa/magician.c | 1 + arch/arm/mach-pxa/mainstone.c | 1 + arch/arm/mach-pxa/mioa701.c | 1 + arch/arm/mach-pxa/palm27x.c | 1 + arch/arm/mach-pxa/palmtc.c | 35 +---- arch/arm/mach-pxa/palmte2.c | 1 + arch/arm/mach-pxa/pcm990-baseboard.c | 1 + arch/arm/mach-pxa/raumfeld.c | 1 + arch/arm/mach-pxa/tavorevb.c | 2 + arch/arm/mach-pxa/viper.c | 1 + arch/arm/mach-pxa/z2.c | 2 + arch/arm/mach-pxa/zylonite.c | 1 + arch/arm/mach-s3c24xx/mach-h1940.c | 1 + arch/arm/mach-s3c24xx/mach-rx1950.c | 1 + arch/arm/mach-s3c64xx/mach-crag6410.c | 1 + arch/arm/mach-s3c64xx/mach-hmt.c | 1 + arch/arm/mach-s3c64xx/mach-smartq.c | 1 + arch/arm/mach-s3c64xx/mach-smdk6410.c | 1 + arch/arm/mach-s5p64x0/mach-smdk6440.c | 1 + arch/arm/mach-s5p64x0/mach-smdk6450.c | 1 + arch/arm/mach-s5pc100/mach-smdkc100.c | 1 + arch/arm/mach-s5pv210/mach-smdkv210.c | 1 + arch/arm/mach-shmobile/board-armadillo800eva.c | 1 + arch/arm/plat-samsung/dev-backlight.c | 5 + arch/unicore32/kernel/puv3-nb0916.c | 1 + drivers/video/backlight/pwm_bl.c | 149 ++++++++++++++++----- include/linux/pwm_backlight.h | 7 + 34 files changed, 171 insertions(+), 64 deletions(-)
Signature · 6 lines
1.8.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/12 pwm-backlight: Improve readability
Add more blank lines to increase readability. While at it, remove a trailing blank line at the end of the file.
--- drivers/video/backlight/pwm_bl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/video/backlight/pwm_bl.c +6 -1
@@ -269,8 +269,10 @@ static int pwm_backlight_remove(struct platform_device *pdev)backlight_device_unregister (bl);pwm_config (pb->pwm,0 , pb->period);pwm_disable (pb->pwm); +if (pb->exit) pb->exit (&pdev->dev); +return 0 ; }
@@ -282,10 +284,13 @@ static int pwm_backlight_suspend(struct device *dev)if (pb->notify) pb->notify (pb->dev,0 ); +pwm_config (pb->pwm,0 , pb->period);pwm_disable (pb->pwm); +if (pb->notify_after) pb->notify_after (pb->dev,0 ); +return 0 ; }
@@ -294,6 +299,7 @@ static int pwm_backlight_resume(struct device *dev)struct backlight_device *bl =dev_get_drvdata (dev);backlight_update_status (bl); + return 0; }#endif
@@ -317,4 +323,3 @@ module_platform_driver(pwm_backlight_driver);MODULE_DESCRIPTION ("PWM based Backlight Driver" );MODULE_LICENSE ("GPL" );MODULE_ALIAS ("platform:pwm-backlight" ); -
Signature · 6 lines
1.8.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 2/12 pwm-backlight: Refactor backlight power on/off
In reply to Thierry RedingIn preparation for adding an optional regulator and enable GPIO to the driver, split the power on and power off sequences into separate functions to reduce code duplication at the multiple call sites.
---
Changes in v2:
- add back pwm_config(..., 0, ...) call on power off
- move whitespace cleanups to separate patch
drivers/video/backlight/pwm_bl.c | 53 +++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 22 deletions(-)
drivers/video/backlight/pwm_bl.c +31 -22
@@ -35,6 +35,31 @@ struct pwm_bl_data {void (*exit)(struct device *); }; +static void pwm_backlight_power_on (struct pwm_bl_data *pb,int brightness, +int max) +{ +int duty_cycle, err; + +if (pb->levels) { + duty_cycle = pb->levels[brightness]; + max = pb->levels[max]; + }else { + duty_cycle = brightness; + } + + duty_cycle = (duty_cycle * (pb->period - pb->lth_brightness) / max) + + pb->lth_brightness; + +pwm_config (pb->pwm, duty_cycle, pb->period); +pwm_enable (pb->pwm); +} + +static void pwm_backlight_power_off (struct pwm_bl_data *pb) +{ +pwm_config (pb->pwm,0 , pb->period); +pwm_disable (pb->pwm); +} +static int pwm_backlight_update_status (struct backlight_device *bl) {struct pwm_bl_data *pb =bl_get_data (bl);
@@ -49,24 +74,10 @@ static int pwm_backlight_update_status(struct backlight_device *bl)if (pb->notify) brightness = pb->notify (pb->dev, brightness); -if (brightness ==0 ) { -pwm_config (pb->pwm,0 , pb->period); -pwm_disable (pb->pwm); - }else { -int duty_cycle; - -if (pb->levels) { - duty_cycle = pb->levels[brightness]; - max = pb->levels[max]; - }else { - duty_cycle = brightness; - } - - duty_cycle = pb->lth_brightness + - (duty_cycle * (pb->period - pb->lth_brightness) / max); -pwm_config (pb->pwm, duty_cycle, pb->period); -pwm_enable (pb->pwm); - } +if (brightness >0 ) +pwm_backlight_power_on (pb, brightness, max); +else +pwm_backlight_power_off (pb);if (pb->notify_after) pb->notify_after (pb->dev, brightness);
@@ -267,8 +278,7 @@ static int pwm_backlight_remove(struct platform_device *pdev)struct pwm_bl_data *pb =bl_get_data (bl);backlight_device_unregister (bl); -pwm_config (pb->pwm,0 , pb->period); -pwm_disable (pb->pwm); +pwm_backlight_power_off (pb);if (pb->exit) pb->exit (&pdev->dev);
@@ -285,8 +295,7 @@ static int pwm_backlight_suspend(struct device *dev)if (pb->notify) pb->notify (pb->dev,0 ); -pwm_config (pb->pwm,0 , pb->period); -pwm_disable (pb->pwm); +pwm_backlight_power_off (pb);if (pb->notify_after) pb->notify_after (pb->dev,0 );
Signature · 1 line
1.8.4
PATCH v2 3/12 pwm-backlight: Track enable state
In reply to Thierry RedingFollow up patches will add support for more complex means of powering the backlight on and off such as using a regulator. To prevent calls to the regulator API from becoming unbalanced, keep track of the enabled state internally.
--- drivers/video/backlight/pwm_bl.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/video/backlight/pwm_bl.c +11 -0
@@ -27,6 +27,7 @@ struct pwm_bl_data {unsigned int period;unsigned int lth_brightness;unsigned int *levels; +bool enabled;int (*notify)(struct device *,int brightness); void (*notify_after)(struct device *,
@@ -40,6 +41,9 @@ static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness, {int duty_cycle, err; +if (pb->enabled) +return ; +if (pb->levels) { duty_cycle = pb->levels[brightness]; max = pb->levels[max];
@@ -52,12 +56,18 @@ static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness,pwm_config (pb->pwm, duty_cycle, pb->period);pwm_enable (pb->pwm); + pb->enabled = true; }static void pwm_backlight_power_off (struct pwm_bl_data *pb) { +if (!pb->enabled) +return ; +pwm_config (pb->pwm,0 , pb->period);pwm_disable (pb->pwm); + + pb->enabled = false; }static int pwm_backlight_update_status (struct backlight_device *bl)
@@ -216,6 +226,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) pb->check_fb = data->check_fb; pb->exit = data->exit; pb->dev = &pdev->dev; + pb->enabled = false; pb->pwm =devm_pwm_get (&pdev->dev,NULL );if (IS_ERR (pb->pwm)) {
Signature · 1 line
1.8.4
PATCH v2 4/12 pwm-backlight: Add optional enable GPIO
In reply to Thierry RedingTo support a wider variety of backlight setups, introduce an optional enable GPIO. Legacy users of the platform data already have a means of supporting GPIOs by using the .init(), .exit() and .notify() hooks. DT users however cannot use those, so an alternative method is required.
In order to ease the introduction of the optional enable GPIO, make it available in the platform data first, so that existing users can be converted. Once that has happened a second patch will add code to make use of it in the driver.
--- include/linux/pwm_backlight.h | 5 +++++ 1 file changed, 5 insertions(+)
include/linux/pwm_backlight.h +5 -0
@@ -6,6 +6,9 @@#include <linux/backlight.h> +/* TODO: convert to gpiod_*() API once it has been merged */ +#define PWM_BACKLIGHT_GPIO_ACTIVE_LOW (1 << 0) +struct platform_pwm_backlight_data {int pwm_id;unsigned int max_brightness;
@@ -13,6 +16,8 @@ struct platform_pwm_backlight_data {unsigned int lth_brightness;unsigned int pwm_period_ns;unsigned int *levels; +int enable_gpio; +unsigned long enable_gpio_flags;int (*init)(struct device *dev);int (*notify)(struct device *dev,int brightness);void (*notify_after)(struct device *dev,int brightness);
Signature · 1 line
1.8.4
PATCH v2 5/12 ARM: OMAP: Initialize PWM backlight enable_gpio field
In reply to Thierry RedingThe GPIO API defines 0 as being a valid GPIO number, so this field needs to be initialized explicitly.
--- arch/arm/mach-omap2/board-zoom-peripherals.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-omap2/board-zoom-peripherals.c +1 -0
@@ -227,6 +227,7 @@ static struct platform_pwm_backlight_data zoom_backlight_data = { .max_brightness = 127, .dft_brightness = 127, .pwm_period_ns = 7812500, + .enable_gpio = -1, };static struct platform_device zoom_backlight_pwm = {
Signature · 6 lines
1.8.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 6/12 ARM: pxa: Initialize PWM backlight enable_gpio field
In reply to Thierry RedingThe GPIO API defines 0 as being a valid GPIO number, so this field needs to be initialized explicitly.
A special case is the Palm Tungsten|C board. Since it doesn't use any quirks that would require the existing .init() or .exit() hooks it can simply use the new enable_gpio field.
--- arch/arm/mach-pxa/cm-x300.c | 1 + arch/arm/mach-pxa/colibri-pxa270-income.c | 1 + arch/arm/mach-pxa/ezx.c | 1 + arch/arm/mach-pxa/hx4700.c | 1 + arch/arm/mach-pxa/lpd270.c | 1 + arch/arm/mach-pxa/magician.c | 1 + arch/arm/mach-pxa/mainstone.c | 1 + arch/arm/mach-pxa/mioa701.c | 1 + arch/arm/mach-pxa/palm27x.c | 1 + arch/arm/mach-pxa/palmtc.c | 35 +------------------------------ arch/arm/mach-pxa/palmte2.c | 1 + arch/arm/mach-pxa/pcm990-baseboard.c | 1 + arch/arm/mach-pxa/raumfeld.c | 1 + arch/arm/mach-pxa/tavorevb.c | 2 ++ arch/arm/mach-pxa/viper.c | 1 + arch/arm/mach-pxa/z2.c | 2 ++ arch/arm/mach-pxa/zylonite.c | 1 + 17 files changed, 19 insertions(+), 34 deletions(-)
arch/arm/mach-pxa/cm-x300.c +1 -0
@@ -310,6 +310,7 @@ static struct platform_pwm_backlight_data cm_x300_backlight_data = { .max_brightness = 100, .dft_brightness = 100, .pwm_period_ns = 10000, + .enable_gpio = -1, };static struct platform_device cm_x300_backlight_device = {
arch/arm/mach-pxa/colibri-pxa270-income.c +1 -0
@@ -189,6 +189,7 @@ static struct platform_pwm_backlight_data income_backlight_data = { .max_brightness = 0x3ff, .dft_brightness = 0x1ff, .pwm_period_ns = 1000000, + .enable_gpio = -1, };static struct platform_device income_backlight = {
arch/arm/mach-pxa/ezx.c +1 -0
@@ -54,6 +54,7 @@ static struct platform_pwm_backlight_data ezx_backlight_data = { .max_brightness = 1023, .dft_brightness = 1023, .pwm_period_ns = 78770, + .enable_gpio = -1, };static struct platform_device ezx_backlight_device = {
arch/arm/mach-pxa/hx4700.c +1 -0
@@ -561,6 +561,7 @@ static struct platform_pwm_backlight_data backlight_data = { .max_brightness = 200, .dft_brightness = 100, .pwm_period_ns = 30923, + .enable_gpio = -1, };static struct platform_device backlight = {
arch/arm/mach-pxa/lpd270.c +1 -0
@@ -269,6 +269,7 @@ static struct platform_pwm_backlight_data lpd270_backlight_data = { .max_brightness = 1, .dft_brightness = 1, .pwm_period_ns = 78770, + .enable_gpio = -1, };static struct platform_device lpd270_backlight_device = {
arch/arm/mach-pxa/magician.c +1 -0
@@ -378,6 +378,7 @@ static struct platform_pwm_backlight_data backlight_data = { .max_brightness = 272, .dft_brightness = 100, .pwm_period_ns = 30923, + .enable_gpio = -1, .init = magician_backlight_init, .notify = magician_backlight_notify, .exit = magician_backlight_exit,
arch/arm/mach-pxa/mainstone.c +1 -0
@@ -338,6 +338,7 @@ static struct platform_pwm_backlight_data mainstone_backlight_data = { .max_brightness = 1023, .dft_brightness = 1023, .pwm_period_ns = 78770, + .enable_gpio = -1, };static struct platform_device mainstone_backlight_device = {
arch/arm/mach-pxa/mioa701.c +1 -0
@@ -186,6 +186,7 @@ static struct platform_pwm_backlight_data mioa701_backlight_data = { .max_brightness = 100, .dft_brightness = 50, .pwm_period_ns = 4000 * 1024, /* Fl = 250kHz */ + .enable_gpio = -1, };/*
arch/arm/mach-pxa/palm27x.c +1 -0
@@ -322,6 +322,7 @@ static struct platform_pwm_backlight_data palm27x_backlight_data = { .max_brightness = 0xfe, .dft_brightness = 0x7e, .pwm_period_ns = 3500 * 1024, + .enable_gpio = -1, .init = palm27x_backlight_init, .notify = palm27x_backlight_notify, .exit = palm27x_backlight_exit,
arch/arm/mach-pxa/palmtc.c +1 -34
@@ -166,45 +166,12 @@ static inline void palmtc_keys_init(void) {}* Backlight ******************************************************************************/ #if defined(CONFIG_BACKLIGHT_PWM ) || defined(CONFIG_BACKLIGHT_PWM_MODULE ) -static int palmtc_backlight_init (struct device *dev) -{ -int ret; - - ret =gpio_request (GPIO_NR_PALMTC_BL_POWER ,"BL POWER" ); -if (ret) - goto err; - ret =gpio_direction_output (GPIO_NR_PALMTC_BL_POWER ,1 ); -if (ret) - goto err2; - -return 0 ; - -err2: -gpio_free (GPIO_NR_PALMTC_BL_POWER ); -err: -return ret; -} - -static int palmtc_backlight_notify (struct device *dev,int brightness) -{ -/* backlight is on when GPIO16 AF0 is high */ -gpio_set_value (GPIO_NR_PALMTC_BL_POWER , brightness); -return brightness; -} - -static void palmtc_backlight_exit (struct device *dev) -{ -gpio_free (GPIO_NR_PALMTC_BL_POWER ); -} -static struct platform_pwm_backlight_data palmtc_backlight_data = { .pwm_id =1 , .max_brightness =PALMTC_MAX_INTENSITY , .dft_brightness =PALMTC_MAX_INTENSITY , .pwm_period_ns =PALMTC_PERIOD_NS , - .init = palmtc_backlight_init, - .notify = palmtc_backlight_notify, - .exit = palmtc_backlight_exit, + .enable_gpio =GPIO_NR_PALMTC_BL_POWER , }; static struct platform_device palmtc_backlight = {
arch/arm/mach-pxa/palmte2.c +1 -0
@@ -165,6 +165,7 @@ static struct platform_pwm_backlight_data palmte2_backlight_data = { .max_brightness = PALMTE2_MAX_INTENSITY, .dft_brightness = PALMTE2_MAX_INTENSITY, .pwm_period_ns = PALMTE2_PERIOD_NS, + .enable_gpio = -1, .init = palmte2_backlight_init, .notify = palmte2_backlight_notify, .exit = palmte2_backlight_exit,
arch/arm/mach-pxa/pcm990-baseboard.c +1 -0
@@ -153,6 +153,7 @@ static struct platform_pwm_backlight_data pcm990_backlight_data = { .max_brightness = 1023, .dft_brightness = 1023, .pwm_period_ns = 78770, + .enable_gpio = -1, };static struct platform_device pcm990_backlight_device = {
arch/arm/mach-pxa/raumfeld.c +1 -0
@@ -539,6 +539,7 @@ static struct platform_pwm_backlight_data raumfeld_pwm_backlight_data = { .dft_brightness = 100, /* 10000 ns = 10 ms ^= 100 kHz */ .pwm_period_ns = 10000, + .enable_gpio = -1, };static struct platform_device raumfeld_pwm_backlight_device = {
arch/arm/mach-pxa/tavorevb.c +2 -0
@@ -175,6 +175,7 @@ static struct platform_pwm_backlight_data tavorevb_backlight_data[] = { .max_brightness = 100, .dft_brightness = 100, .pwm_period_ns = 100000, + .enable_gpio = -1, }, [1] = {/* secondary backlight */
@@ -182,6 +183,7 @@ static struct platform_pwm_backlight_data tavorevb_backlight_data[] = { .max_brightness = 100, .dft_brightness = 100, .pwm_period_ns = 100000, + .enable_gpio = -1, }, };
arch/arm/mach-pxa/viper.c +1 -0
@@ -401,6 +401,7 @@ static struct platform_pwm_backlight_data viper_backlight_data = { .max_brightness = 100, .dft_brightness = 100, .pwm_period_ns = 1000000, + .enable_gpio = -1, .init = viper_backlight_init, .notify = viper_backlight_notify, .exit = viper_backlight_exit,
arch/arm/mach-pxa/z2.c +2 -0
@@ -206,6 +206,7 @@ static struct platform_pwm_backlight_data z2_backlight_data[] = { .max_brightness = 1023, .dft_brightness = 0, .pwm_period_ns = 1260320, + .enable_gpio = -1, }, [1] = {/* LCD Backlight */
@@ -213,6 +214,7 @@ static struct platform_pwm_backlight_data z2_backlight_data[] = { .max_brightness = 1023, .dft_brightness = 512, .pwm_period_ns = 1260320, + .enable_gpio = -1, }, };
arch/arm/mach-pxa/zylonite.c +1 -0
@@ -125,6 +125,7 @@ static struct platform_pwm_backlight_data zylonite_backlight_data = { .max_brightness = 100, .dft_brightness = 100, .pwm_period_ns = 10000, + .enable_gpio = -1, };static struct platform_device zylonite_backlight_device = {
Signature · 6 lines
1.8.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 7/12 ARM: SAMSUNG: Initialize PWM backlight enable_gpio field
In reply to Thierry RedingThe GPIO API defines 0 as being a valid GPIO number, so this field needs to be initialized explicitly.
---
Changes in v2:
- 0 is a valid GPIO, so it can be used to override a default
arch/arm/mach-s3c24xx/mach-h1940.c | 1 + arch/arm/mach-s3c24xx/mach-rx1950.c | 1 + arch/arm/mach-s3c64xx/mach-crag6410.c | 1 + arch/arm/mach-s3c64xx/mach-hmt.c | 1 + arch/arm/mach-s3c64xx/mach-smartq.c | 1 + arch/arm/mach-s3c64xx/mach-smdk6410.c | 1 + arch/arm/mach-s5p64x0/mach-smdk6440.c | 1 + arch/arm/mach-s5p64x0/mach-smdk6450.c | 1 + arch/arm/mach-s5pc100/mach-smdkc100.c | 1 + arch/arm/mach-s5pv210/mach-smdkv210.c | 1 + arch/arm/plat-samsung/dev-backlight.c | 5 +++++ 11 files changed, 15 insertions(+)
arch/arm/mach-s3c24xx/mach-h1940.c +1 -0
@@ -504,6 +504,7 @@ static struct platform_pwm_backlight_data backlight_data = { .dft_brightness = 50,/* tcnt = 0x31 */ .pwm_period_ns = 36296, + .enable_gpio = -1, .init = h1940_backlight_init, .notify = h1940_backlight_notify, .exit = h1940_backlight_exit,
arch/arm/mach-s3c24xx/mach-rx1950.c +1 -0
@@ -522,6 +522,7 @@ static struct platform_pwm_backlight_data rx1950_backlight_data = { .max_brightness = 24, .dft_brightness = 4, .pwm_period_ns = 48000, + .enable_gpio = -1, .init = rx1950_backlight_init, .notify = rx1950_backlight_notify, .exit = rx1950_backlight_exit,
arch/arm/mach-s3c64xx/mach-crag6410.c +1 -0
@@ -114,6 +114,7 @@ static struct platform_pwm_backlight_data crag6410_backlight_data = { .max_brightness = 1000, .dft_brightness = 600, .pwm_period_ns = 100000, /* about 1kHz */ + .enable_gpio = -1, };static struct platform_device crag6410_backlight_device = {
arch/arm/mach-s3c64xx/mach-hmt.c +1 -0
@@ -114,6 +114,7 @@ static struct platform_pwm_backlight_data hmt_backlight_data = { .max_brightness = 100 * 256, .dft_brightness = 40 * 256, .pwm_period_ns = 1000000000 / (100 * 256 * 20), + .enable_gpio = -1, .init = hmt_bl_init, .notify = hmt_bl_notify, .exit = hmt_bl_exit,
arch/arm/mach-s3c64xx/mach-smartq.c +1 -0
@@ -151,6 +151,7 @@ static struct platform_pwm_backlight_data smartq_backlight_data = { .max_brightness = 1000, .dft_brightness = 600, .pwm_period_ns = 1000000000 / (1000 * 20), + .enable_gpio = -1, .init = smartq_bl_init, };
arch/arm/mach-s3c64xx/mach-smdk6410.c +1 -0
@@ -625,6 +625,7 @@ static struct samsung_bl_gpio_info smdk6410_bl_gpio_info = {static struct platform_pwm_backlight_data smdk6410_bl_data = { .pwm_id =1 , + .enable_gpio =-1 , };static struct s3c_hsotg_plat smdk6410_hsotg_pdata;
arch/arm/mach-s5p64x0/mach-smdk6440.c +1 -0
@@ -223,6 +223,7 @@ static struct samsung_bl_gpio_info smdk6440_bl_gpio_info = {static struct platform_pwm_backlight_data smdk6440_bl_data = { .pwm_id =1 , + .enable_gpio =-1 , };static void __init smdk6440_map_io (void )
arch/arm/mach-s5p64x0/mach-smdk6450.c +1 -0
@@ -242,6 +242,7 @@ static struct samsung_bl_gpio_info smdk6450_bl_gpio_info = {static struct platform_pwm_backlight_data smdk6450_bl_data = { .pwm_id =1 , + .enable_gpio =-1 , };static void __init smdk6450_map_io (void )
arch/arm/mach-s5pc100/mach-smdkc100.c +1 -0
@@ -216,6 +216,7 @@ static struct samsung_bl_gpio_info smdkc100_bl_gpio_info = {static struct platform_pwm_backlight_data smdkc100_bl_data = { .pwm_id =0 , + .enable_gpio =-1 , };static void __init smdkc100_map_io (void )
arch/arm/mach-s5pv210/mach-smdkv210.c +1 -0
@@ -279,6 +279,7 @@ static struct samsung_bl_gpio_info smdkv210_bl_gpio_info = {static struct platform_pwm_backlight_data smdkv210_bl_data = { .pwm_id =3 , .pwm_period_ns =1000 , + .enable_gpio =-1 , };static void __init smdkv210_map_io (void )
arch/arm/plat-samsung/dev-backlight.c +5 -0
@@ -70,6 +70,7 @@ static struct samsung_bl_drvdata samsung_dfl_bl_data __initdata = { .max_brightness = 255, .dft_brightness = 255, .pwm_period_ns = 78770, + .enable_gpio = -1, .init = samsung_bl_init, .exit = samsung_bl_exit, },
@@ -121,6 +122,10 @@ void __init samsung_bl_set(struct samsung_bl_gpio_info *gpio_info, samsung_bl_data->lth_brightness = bl_data->lth_brightness;if (bl_data->pwm_period_ns) samsung_bl_data->pwm_period_ns = bl_data->pwm_period_ns; +if (bl_data->enable_gpio >=0 ) + samsung_bl_data->enable_gpio = bl_data->enable_gpio; +if (bl_data->enable_gpio_flags) + samsung_bl_data->enable_gpio_flags = bl_data->enable_gpio_flags;if (bl_data->init) samsung_bl_data->init = bl_data->init;if (bl_data->notify)
Signature · 6 lines
1.8.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 8/12 ARM: shmobile: Initialize PWM backlight enable_gpio field
In reply to Thierry RedingThe GPIO API defines 0 as being a valid GPIO number, so this field needs to be initialized explicitly.
--- arch/arm/mach-shmobile/board-armadillo800eva.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-shmobile/board-armadillo800eva.c +1 -0
@@ -423,6 +423,7 @@ static struct platform_pwm_backlight_data pwm_backlight_data = { .max_brightness = 255, .dft_brightness = 255, .pwm_period_ns = 33333, /* 30kHz */ + .enable_gpio = -1, };static struct platform_device pwm_backlight_device = {
Signature · 1 line
1.8.4
PATCH v2 9/12 unicore32: Initialize PWM backlight enable_gpio field
In reply to Thierry RedingThe GPIO API defines 0 as being a valid GPIO number, so this field needs to be initialized explicitly.
--- arch/unicore32/kernel/puv3-nb0916.c | 1 + 1 file changed, 1 insertion(+)
arch/unicore32/kernel/puv3-nb0916.c +1 -0
@@ -54,6 +54,7 @@ static struct platform_pwm_backlight_data nb0916_backlight_data = { .max_brightness = 100, .dft_brightness = 100, .pwm_period_ns = 70 * 1024, + .enable_gpio = -1, };static struct gpio_keys_button nb0916_gpio_keys[] = {
Signature · 1 line
1.8.4
PATCH v2 10/12 pwm-backlight: Use new enable_gpio field
In reply to Thierry RedingMake use of the new enable_gpio field and allow it to be set from DT as well. Now that all legacy users of platform data have been converted to initialize this field to an invalid value, it is safe to use the field from the driver.
---
Changes in v2:
- fix up binding documentation as suggested by Stephen Warren
- properly handle deferred probing
.../bindings/video/backlight/pwm-backlight.txt | 5 ++ drivers/video/backlight/pwm_bl.c | 57 +++++++++++++++++++--- 2 files changed, 55 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +5 -0
@@ -14,8 +14,11 @@ Required properties: Optional properties: - pwm-names: a list of names for the PWM devices specified in the "pwms" property (see PWM binding[0]) + - enable-gpios: contains a single GPIO specifier for the GPIO which enables + and disables the backlight (see GPIO binding[1]) [0]: Documentation/devicetree/bindings/pwm/pwm.txt +[1]: Documentation/devicetree/bindings/gpio/gpio.txt Example:
@@ -25,4 +28,6 @@ Example: brightness-levels = <0 4 8 16 32 64 128 255>; default-brightness-level = <6>; + + enable-gpios = <&gpio 58 0>; };
drivers/video/backlight/pwm_bl.c +50 -7
123 lines not on this page · raw message
Signature · 1 line
1.8.4
PATCH v2 11/12 pwm-backlight: Add power supply support
In reply to Thierry RedingBacklights require a power supply to work properly. This commit adds a regulator to power up and power down the backlight.
---
Changes in v2:
- make regulator mandatory and update commit message accordingly
.../devicetree/bindings/video/backlight/pwm-backlight.txt | 2 ++ drivers/video/backlight/pwm_bl.c | 13 +++++++++++++ 2 files changed, 15 insertions(+)
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +2 -0
@@ -10,6 +10,7 @@ Required properties: last value in the array represents a 100% duty cycle (brightest). - default-brightness-level: the default brightness level (index into the array defined by the "brightness-levels" property) + - power-supply: regulator for supply voltage Optional properties: - pwm-names: a list of names for the PWM devices specified in the
@@ -29,5 +30,6 @@ Example: brightness-levels = <0 4 8 16 32 64 128 255>; default-brightness-level = <6>; + power-supply = <&vdd_bl_reg>; enable-gpios = <&gpio 58 0>; };
drivers/video/backlight/pwm_bl.c +13 -0
@@ -21,6 +21,7 @@#include <linux/err.h> #include <linux/pwm.h> #include <linux/pwm_backlight.h> +#include <linux/regulator/consumer.h> #include <linux/slab.h> struct pwm_bl_data {
@@ -30,6 +31,7 @@ struct pwm_bl_data {unsigned int lth_brightness;unsigned int *levels;bool enabled; +struct regulator *power_supply;int enable_gpio;unsigned long enable_gpio_flags; int (*notify)(struct device *,
@@ -60,6 +62,10 @@ static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness,pwm_config (pb->pwm, duty_cycle, pb->period); + err =regulator_enable (pb->power_supply); +if (err <0 ) +dev_err (pb->dev,"failed to enable power supply\n" ); +if (gpio_is_valid (pb->enable_gpio)) {if (pb->enable_gpio_flags &PWM_BACKLIGHT_GPIO_ACTIVE_LOW )gpio_set_value (pb->enable_gpio,0 );
@@ -86,6 +92,7 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb)gpio_set_value (pb->enable_gpio,0 ); } +regulator_disable (pb->power_supply); pb->enabled = false; }
@@ -268,6 +275,12 @@ static int pwm_backlight_probe(struct platform_device *pdev) } } + pb->power_supply =devm_regulator_get (&pdev->dev,"power" ); +if (IS_ERR (pb->power_supply)) { + ret =PTR_ERR (pb->power_supply); + goto err_gpio; + } + pb->pwm =devm_pwm_get (&pdev->dev,NULL );if (IS_ERR (pb->pwm)) {dev_err (&pdev->dev,"unable to request PWM, trying legacy API\n" );
Signature · 1 line
1.8.4
PATCH v2 12/12 pwm-backlight: Allow backlight to remain disabled on boot
In reply to Thierry RedingThe default for backlight devices is to be enabled immediately when registering with the backlight core. This can be useful for setups that use a simple framebuffer device and where the backlight cannot otherwise be hooked up to the panel.
However, when dealing with more complex setups, such as those of recent ARM SoCs, this can be problematic. Since the backlight is usually setup separately from the display controller, the probe order is not usually deterministic. That can lead to situations where the backlight will be powered up and the panel will show an uninitialized framebuffer.
Furthermore, subsystems such as DRM have advanced functionality to set the power mode of a panel. In order to allow such setups to power up the panel at exactly the right moment, a way is needed to prevent the backlight core from powering the backlight up automatically when it is registered.
This commit introduces a new boot_off field in the platform data (and also implements getting the same information from device tree). When set the initial backlight power mode will be set to "off".
---
Note: Perhaps it would be more useful to make this the default behaviour in the backlight core? Many other subsystems and frameworks assume that a resource is off unless explicitly enabled.
.../devicetree/bindings/video/backlight/pwm-backlight.txt | 1 + drivers/video/backlight/pwm_bl.c | 8 ++++++++ include/linux/pwm_backlight.h | 2 ++ 3 files changed, 11 insertions(+)
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +1 -0
@@ -17,6 +17,7 @@ Optional properties: "pwms" property (see PWM binding[0]) - enable-gpios: contains a single GPIO specifier for the GPIO which enables and disables the backlight (see GPIO binding[1]) + - backlight-boot-off: keep the backlight disabled on boot [0]: Documentation/devicetree/bindings/pwm/pwm.txt [1]: Documentation/devicetree/bindings/gpio/gpio.txt
drivers/video/backlight/pwm_bl.c +8 -0
@@ -194,6 +194,8 @@ static int pwm_backlight_parse_dt(struct device *dev,if (gpio_is_valid (data->enable_gpio) && (flags &OF_GPIO_ACTIVE_LOW )) data->enable_gpio_flags |=PWM_BACKLIGHT_GPIO_ACTIVE_LOW ; + data->boot_off =of_property_read_bool (node,"backlight-boot-off" ); +return 0 ; }
@@ -325,6 +327,12 @@ static int pwm_backlight_probe(struct platform_device *pdev) } bl->props.brightness = data->dft_brightness; + +if (data->boot_off) + bl->props.power =FB_BLANK_POWERDOWN ; +else + bl->props.power =FB_BLANK_UNBLANK ; +backlight_update_status (bl);platform_set_drvdata (pdev, bl);
include/linux/pwm_backlight.h +2 -0
@@ -18,6 +18,8 @@ struct platform_pwm_backlight_data {unsigned int *levels;int enable_gpio;unsigned long enable_gpio_flags; +bool boot_off; +int (*init)(struct device *dev);int (*notify)(struct device *dev,int brightness);void (*notify_after)(struct device *dev,int brightness);
Signature · 1 line
1.8.4
Hi Thierry
This series adds the ability to specify a GPIO and a power supply to
Quoted 2 lines
enable a backlight.
Whats the state of this patch set? I am looking for this kind of functionality for a pwm based
backlight on a devicetree only imx6 device.
greets
--
Christian Gmeiner, MSc
Quoted 10 lines · Christian Gmeiner
Hi Thierry
This series adds the ability to specify a GPIO and a power supply to
Quoted 2 lines
enable a backlight.
Whats the state of this patch set? I am looking for this kind of functionality for a pwm based
backlight on a devicetree only imx6 device.
Those patches (except the one that adds the backlight-boot-off property) will be part of my pull request for 3.13.
Thierry
2013/11/8 Thierry Reding <[email protected]>:
Quoted 8 lines · Christian Gmeiner
Quoted 7 lines
Hi Thierry
This series adds the ability to specify a GPIO and a power supply to
Quoted 2 lines
enable a backlight.
Quoted 7 lines
Quoted 3 lines
Whats the state of this patch set? I am looking for this kind of functionality for a pwm based
backlight on a devicetree only imx6 device.Those patches (except the one that adds the backlight-boot-off property) will be part of my pull request for 3.13.
That are really good news.. will try this patch set on a 3.12 kernel.
--
Christian Gmeiner, MSc
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Thierry
Quoted 2 lines
This series adds the ability to specify a GPIO and a power supply to enable a backlight.
Whats the state of this patch set? I am looking for this kind of functionality for a pwm based
backlight on a devicetree only imx6 device.
greets
--
Christian Gmeiner, MSc
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html