* [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support @ 2013-10-07 11:37 Thierry Reding 2013-10-07 11:37 ` [PATCH v2 02/12] pwm-backlight: Refactor backlight power on/off Thierry Reding ` (9 more replies) 0 siblings, 10 replies; 16+ messages in thread From: Thierry Reding @ 2013-10-07 11:37 UTC (permalink / raw) To: Thierry Reding Cc: Tony Lindgren, Eric Miao, Haojian Zhuang, Marek Vasut, Ben Dooks, Kukjin Kim, Guan Xuetao, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-pwm-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA 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(-) -- 1.8.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 02/12] pwm-backlight: Refactor backlight power on/off 2013-10-07 11:37 [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support Thierry Reding @ 2013-10-07 11:37 ` Thierry Reding 2013-10-07 11:37 ` [PATCH v2 03/12] pwm-backlight: Track enable state Thierry Reding ` (8 subsequent siblings) 9 siblings, 0 replies; 16+ messages in thread From: Thierry Reding @ 2013-10-07 11:37 UTC (permalink / raw) To: Thierry Reding Cc: Tony Lindgren, Eric Miao, Haojian Zhuang, Marek Vasut, Ben Dooks, Kukjin Kim, Guan Xuetao, devicetree, linux-pwm, linux-kernel In 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. Signed-off-by: Thierry Reding <treding@nvidia.com> --- 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(-) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 774bce3..ab9d5e6 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -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); -- 1.8.4 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 03/12] pwm-backlight: Track enable state 2013-10-07 11:37 [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support Thierry Reding 2013-10-07 11:37 ` [PATCH v2 02/12] pwm-backlight: Refactor backlight power on/off Thierry Reding @ 2013-10-07 11:37 ` Thierry Reding 2013-10-07 11:37 ` [PATCH v2 04/12] pwm-backlight: Add optional enable GPIO Thierry Reding ` (7 subsequent siblings) 9 siblings, 0 replies; 16+ messages in thread From: Thierry Reding @ 2013-10-07 11:37 UTC (permalink / raw) To: Thierry Reding Cc: Tony Lindgren, Eric Miao, Haojian Zhuang, Marek Vasut, Ben Dooks, Kukjin Kim, Guan Xuetao, devicetree, linux-pwm, linux-kernel Follow 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. Signed-off-by: Thierry Reding <treding@nvidia.com> --- drivers/video/backlight/pwm_bl.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index ab9d5e6..4053efb 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -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)) { -- 1.8.4 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 04/12] pwm-backlight: Add optional enable GPIO 2013-10-07 11:37 [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support Thierry Reding 2013-10-07 11:37 ` [PATCH v2 02/12] pwm-backlight: Refactor backlight power on/off Thierry Reding 2013-10-07 11:37 ` [PATCH v2 03/12] pwm-backlight: Track enable state Thierry Reding @ 2013-10-07 11:37 ` Thierry Reding [not found] ` <1381145866-445-1-git-send-email-treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> ` (6 subsequent siblings) 9 siblings, 0 replies; 16+ messages in thread From: Thierry Reding @ 2013-10-07 11:37 UTC (permalink / raw) To: Thierry Reding Cc: Tony Lindgren, Eric Miao, Haojian Zhuang, Marek Vasut, Ben Dooks, Kukjin Kim, Guan Xuetao, devicetree, linux-pwm, linux-kernel To 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. Signed-off-by: Thierry Reding <treding@nvidia.com> --- include/linux/pwm_backlight.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/pwm_backlight.h b/include/linux/pwm_backlight.h index 56f4a86..2de2e27 100644 --- a/include/linux/pwm_backlight.h +++ b/include/linux/pwm_backlight.h @@ -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); -- 1.8.4 ^ permalink raw reply related [flat|nested] 16+ messages in thread
[parent not found: <1381145866-445-1-git-send-email-treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>]
* [PATCH v2 01/12] pwm-backlight: Improve readability [not found] ` <1381145866-445-1-git-send-email-treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> @ 2013-10-07 11:37 ` Thierry Reding 2013-10-07 11:37 ` [PATCH v2 05/12] ARM: OMAP: Initialize PWM backlight enable_gpio field Thierry Reding ` (3 subsequent siblings) 4 siblings, 0 replies; 16+ messages in thread From: Thierry Reding @ 2013-10-07 11:37 UTC (permalink / raw) To: Thierry Reding Cc: Tony Lindgren, Eric Miao, Haojian Zhuang, Marek Vasut, Ben Dooks, Kukjin Kim, Guan Xuetao, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-pwm-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA Add more blank lines to increase readability. While at it, remove a trailing blank line at the end of the file. Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> --- drivers/video/backlight/pwm_bl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 1fea627..774bce3 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -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"); - -- 1.8.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 05/12] ARM: OMAP: Initialize PWM backlight enable_gpio field [not found] ` <1381145866-445-1-git-send-email-treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> 2013-10-07 11:37 ` [PATCH v2 01/12] pwm-backlight: Improve readability Thierry Reding @ 2013-10-07 11:37 ` Thierry Reding 2013-10-07 11:37 ` [PATCH v2 06/12] ARM: pxa: " Thierry Reding ` (2 subsequent siblings) 4 siblings, 0 replies; 16+ messages in thread From: Thierry Reding @ 2013-10-07 11:37 UTC (permalink / raw) To: Thierry Reding Cc: Tony Lindgren, Eric Miao, Haojian Zhuang, Marek Vasut, Ben Dooks, Kukjin Kim, Guan Xuetao, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-pwm-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA The GPIO API defines 0 as being a valid GPIO number, so this field needs to be initialized explicitly. Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> --- arch/arm/mach-omap2/board-zoom-peripherals.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-omap2/board-zoom-peripherals.c b/arch/arm/mach-omap2/board-zoom-peripherals.c index a90375d..5ed2884 100644 --- a/arch/arm/mach-omap2/board-zoom-peripherals.c +++ b/arch/arm/mach-omap2/board-zoom-peripherals.c @@ -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 = { -- 1.8.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 06/12] ARM: pxa: Initialize PWM backlight enable_gpio field [not found] ` <1381145866-445-1-git-send-email-treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> 2013-10-07 11:37 ` [PATCH v2 01/12] pwm-backlight: Improve readability Thierry Reding 2013-10-07 11:37 ` [PATCH v2 05/12] ARM: OMAP: Initialize PWM backlight enable_gpio field Thierry Reding @ 2013-10-07 11:37 ` Thierry Reding 2013-10-07 11:37 ` [PATCH v2 07/12] ARM: SAMSUNG: " Thierry Reding 2013-11-07 12:44 ` [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support Christian Gmeiner 4 siblings, 0 replies; 16+ messages in thread From: Thierry Reding @ 2013-10-07 11:37 UTC (permalink / raw) To: Thierry Reding Cc: Tony Lindgren, Eric Miao, Haojian Zhuang, Marek Vasut, Ben Dooks, Kukjin Kim, Guan Xuetao, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-pwm-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA The 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. Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> --- 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(-) diff --git a/arch/arm/mach-pxa/cm-x300.c b/arch/arm/mach-pxa/cm-x300.c index f942349..584439b 100644 --- a/arch/arm/mach-pxa/cm-x300.c +++ b/arch/arm/mach-pxa/cm-x300.c @@ -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 = { diff --git a/arch/arm/mach-pxa/colibri-pxa270-income.c b/arch/arm/mach-pxa/colibri-pxa270-income.c index 2d4a7b4..3aa2646 100644 --- a/arch/arm/mach-pxa/colibri-pxa270-income.c +++ b/arch/arm/mach-pxa/colibri-pxa270-income.c @@ -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 = { diff --git a/arch/arm/mach-pxa/ezx.c b/arch/arm/mach-pxa/ezx.c index fe2eb83..ab93441 100644 --- a/arch/arm/mach-pxa/ezx.c +++ b/arch/arm/mach-pxa/ezx.c @@ -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 = { diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c index 133109e..a7c30eb 100644 --- a/arch/arm/mach-pxa/hx4700.c +++ b/arch/arm/mach-pxa/hx4700.c @@ -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 = { diff --git a/arch/arm/mach-pxa/lpd270.c b/arch/arm/mach-pxa/lpd270.c index 1255ee0..9f6ec16 100644 --- a/arch/arm/mach-pxa/lpd270.c +++ b/arch/arm/mach-pxa/lpd270.c @@ -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 = { diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index f44532f..fab30d6 100644 --- a/arch/arm/mach-pxa/magician.c +++ b/arch/arm/mach-pxa/magician.c @@ -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, diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c index dd70343..08ccc07 100644 --- a/arch/arm/mach-pxa/mainstone.c +++ b/arch/arm/mach-pxa/mainstone.c @@ -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 = { diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c index acc9d3c..f70583f 100644 --- a/arch/arm/mach-pxa/mioa701.c +++ b/arch/arm/mach-pxa/mioa701.c @@ -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, }; /* diff --git a/arch/arm/mach-pxa/palm27x.c b/arch/arm/mach-pxa/palm27x.c index 17d4c53..e54a296 100644 --- a/arch/arm/mach-pxa/palm27x.c +++ b/arch/arm/mach-pxa/palm27x.c @@ -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, diff --git a/arch/arm/mach-pxa/palmtc.c b/arch/arm/mach-pxa/palmtc.c index 100b176f..7691c97 100644 --- a/arch/arm/mach-pxa/palmtc.c +++ b/arch/arm/mach-pxa/palmtc.c @@ -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 = { diff --git a/arch/arm/mach-pxa/palmte2.c b/arch/arm/mach-pxa/palmte2.c index 0742721..956fd24 100644 --- a/arch/arm/mach-pxa/palmte2.c +++ b/arch/arm/mach-pxa/palmte2.c @@ -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, diff --git a/arch/arm/mach-pxa/pcm990-baseboard.c b/arch/arm/mach-pxa/pcm990-baseboard.c index 3133ba8..9a4e470 100644 --- a/arch/arm/mach-pxa/pcm990-baseboard.c +++ b/arch/arm/mach-pxa/pcm990-baseboard.c @@ -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 = { diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c index 969b0ba..8386dc3 100644 --- a/arch/arm/mach-pxa/raumfeld.c +++ b/arch/arm/mach-pxa/raumfeld.c @@ -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 = { diff --git a/arch/arm/mach-pxa/tavorevb.c b/arch/arm/mach-pxa/tavorevb.c index 4680efe..a71da84 100644 --- a/arch/arm/mach-pxa/tavorevb.c +++ b/arch/arm/mach-pxa/tavorevb.c @@ -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, }, }; diff --git a/arch/arm/mach-pxa/viper.c b/arch/arm/mach-pxa/viper.c index 9c363c0..29905b1 100644 --- a/arch/arm/mach-pxa/viper.c +++ b/arch/arm/mach-pxa/viper.c @@ -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, diff --git a/arch/arm/mach-pxa/z2.c b/arch/arm/mach-pxa/z2.c index 2513d8f..e1a121b 100644 --- a/arch/arm/mach-pxa/z2.c +++ b/arch/arm/mach-pxa/z2.c @@ -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, }, }; diff --git a/arch/arm/mach-pxa/zylonite.c b/arch/arm/mach-pxa/zylonite.c index 36cf7cf..77daea4 100644 --- a/arch/arm/mach-pxa/zylonite.c +++ b/arch/arm/mach-pxa/zylonite.c @@ -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 = { -- 1.8.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 07/12] ARM: SAMSUNG: Initialize PWM backlight enable_gpio field [not found] ` <1381145866-445-1-git-send-email-treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> ` (2 preceding siblings ...) 2013-10-07 11:37 ` [PATCH v2 06/12] ARM: pxa: " Thierry Reding @ 2013-10-07 11:37 ` Thierry Reding 2013-11-07 12:44 ` [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support Christian Gmeiner 4 siblings, 0 replies; 16+ messages in thread From: Thierry Reding @ 2013-10-07 11:37 UTC (permalink / raw) To: Thierry Reding Cc: Tony Lindgren, Eric Miao, Haojian Zhuang, Marek Vasut, Ben Dooks, Kukjin Kim, Guan Xuetao, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-pwm-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA The GPIO API defines 0 as being a valid GPIO number, so this field needs to be initialized explicitly. Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> --- 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(+) diff --git a/arch/arm/mach-s3c24xx/mach-h1940.c b/arch/arm/mach-s3c24xx/mach-h1940.c index 74dd479..952b6a0 100644 --- a/arch/arm/mach-s3c24xx/mach-h1940.c +++ b/arch/arm/mach-s3c24xx/mach-h1940.c @@ -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, diff --git a/arch/arm/mach-s3c24xx/mach-rx1950.c b/arch/arm/mach-s3c24xx/mach-rx1950.c index 206b1f7..034b7fe 100644 --- a/arch/arm/mach-s3c24xx/mach-rx1950.c +++ b/arch/arm/mach-s3c24xx/mach-rx1950.c @@ -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, diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c b/arch/arm/mach-s3c64xx/mach-crag6410.c index 1a911df..b319bf9 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410.c @@ -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 = { diff --git a/arch/arm/mach-s3c64xx/mach-hmt.c b/arch/arm/mach-s3c64xx/mach-hmt.c index e806404..614a03a 100644 --- a/arch/arm/mach-s3c64xx/mach-hmt.c +++ b/arch/arm/mach-s3c64xx/mach-hmt.c @@ -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, diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c b/arch/arm/mach-s3c64xx/mach-smartq.c index 0f47237..a6b338f 100644 --- a/arch/arm/mach-s3c64xx/mach-smartq.c +++ b/arch/arm/mach-s3c64xx/mach-smartq.c @@ -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, }; diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c b/arch/arm/mach-s3c64xx/mach-smdk6410.c index 2a7b32c..d5ea938 100644 --- a/arch/arm/mach-s3c64xx/mach-smdk6410.c +++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c @@ -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; diff --git a/arch/arm/mach-s5p64x0/mach-smdk6440.c b/arch/arm/mach-s5p64x0/mach-smdk6440.c index 0b00304..9efdcc0 100644 --- a/arch/arm/mach-s5p64x0/mach-smdk6440.c +++ b/arch/arm/mach-s5p64x0/mach-smdk6440.c @@ -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) diff --git a/arch/arm/mach-s5p64x0/mach-smdk6450.c b/arch/arm/mach-s5p64x0/mach-smdk6450.c index 5949296..c3cacc0 100644 --- a/arch/arm/mach-s5p64x0/mach-smdk6450.c +++ b/arch/arm/mach-s5p64x0/mach-smdk6450.c @@ -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) diff --git a/arch/arm/mach-s5pc100/mach-smdkc100.c b/arch/arm/mach-s5pc100/mach-smdkc100.c index 7c57a22..9e256b9 100644 --- a/arch/arm/mach-s5pc100/mach-smdkc100.c +++ b/arch/arm/mach-s5pc100/mach-smdkc100.c @@ -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) diff --git a/arch/arm/mach-s5pv210/mach-smdkv210.c b/arch/arm/mach-s5pv210/mach-smdkv210.c index 6d72bb99..f52cc15 100644 --- a/arch/arm/mach-s5pv210/mach-smdkv210.c +++ b/arch/arm/mach-s5pv210/mach-smdkv210.c @@ -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) diff --git a/arch/arm/plat-samsung/dev-backlight.c b/arch/arm/plat-samsung/dev-backlight.c index d51f956..be4ad0b 100644 --- a/arch/arm/plat-samsung/dev-backlight.c +++ b/arch/arm/plat-samsung/dev-backlight.c @@ -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) -- 1.8.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support [not found] ` <1381145866-445-1-git-send-email-treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> ` (3 preceding siblings ...) 2013-10-07 11:37 ` [PATCH v2 07/12] ARM: SAMSUNG: " Thierry Reding @ 2013-11-07 12:44 ` Christian Gmeiner 4 siblings, 0 replies; 16+ messages in thread From: Christian Gmeiner @ 2013-11-07 12:44 UTC (permalink / raw) To: Thierry Reding Cc: Tony Lindgren, Eric Miao, Haojian Zhuang, Marek Vasut, Ben Dooks, Kukjin Kim, Guan Xuetao, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-pwm-u79uwXL29TY76Z2rM5mHXA, LKML Hi Thierry > 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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 08/12] ARM: shmobile: Initialize PWM backlight enable_gpio field 2013-10-07 11:37 [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support Thierry Reding ` (3 preceding siblings ...) [not found] ` <1381145866-445-1-git-send-email-treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> @ 2013-10-07 11:37 ` Thierry Reding 2013-10-07 11:37 ` [PATCH v2 09/12] unicore32: " Thierry Reding ` (4 subsequent siblings) 9 siblings, 0 replies; 16+ messages in thread From: Thierry Reding @ 2013-10-07 11:37 UTC (permalink / raw) To: Thierry Reding Cc: Tony Lindgren, Eric Miao, Haojian Zhuang, Marek Vasut, Ben Dooks, Kukjin Kim, Guan Xuetao, devicetree, linux-pwm, linux-kernel The GPIO API defines 0 as being a valid GPIO number, so this field needs to be initialized explicitly. Acked-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Thierry Reding <treding@nvidia.com> --- arch/arm/mach-shmobile/board-armadillo800eva.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c index 8bc8e4c..958e3cb 100644 --- a/arch/arm/mach-shmobile/board-armadillo800eva.c +++ b/arch/arm/mach-shmobile/board-armadillo800eva.c @@ -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 = { -- 1.8.4 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 09/12] unicore32: Initialize PWM backlight enable_gpio field 2013-10-07 11:37 [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support Thierry Reding ` (4 preceding siblings ...) 2013-10-07 11:37 ` [PATCH v2 08/12] ARM: shmobile: Initialize PWM backlight enable_gpio field Thierry Reding @ 2013-10-07 11:37 ` Thierry Reding 2013-10-07 11:37 ` [PATCH v2 10/12] pwm-backlight: Use new " Thierry Reding ` (3 subsequent siblings) 9 siblings, 0 replies; 16+ messages in thread From: Thierry Reding @ 2013-10-07 11:37 UTC (permalink / raw) To: Thierry Reding Cc: Tony Lindgren, Eric Miao, Haojian Zhuang, Marek Vasut, Ben Dooks, Kukjin Kim, Guan Xuetao, devicetree, linux-pwm, linux-kernel The GPIO API defines 0 as being a valid GPIO number, so this field needs to be initialized explicitly. Signed-off-by: Thierry Reding <treding@nvidia.com> --- arch/unicore32/kernel/puv3-nb0916.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/unicore32/kernel/puv3-nb0916.c b/arch/unicore32/kernel/puv3-nb0916.c index 181108b..0c6618e 100644 --- a/arch/unicore32/kernel/puv3-nb0916.c +++ b/arch/unicore32/kernel/puv3-nb0916.c @@ -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[] = { -- 1.8.4 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 10/12] pwm-backlight: Use new enable_gpio field 2013-10-07 11:37 [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support Thierry Reding ` (5 preceding siblings ...) 2013-10-07 11:37 ` [PATCH v2 09/12] unicore32: " Thierry Reding @ 2013-10-07 11:37 ` Thierry Reding 2013-10-07 11:37 ` [PATCH v2 11/12] pwm-backlight: Add power supply support Thierry Reding ` (2 subsequent siblings) 9 siblings, 0 replies; 16+ messages in thread From: Thierry Reding @ 2013-10-07 11:37 UTC (permalink / raw) To: Thierry Reding Cc: Tony Lindgren, Eric Miao, Haojian Zhuang, Marek Vasut, Ben Dooks, Kukjin Kim, Guan Xuetao, devicetree, linux-pwm, linux-kernel Make 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. Signed-off-by: Thierry Reding <treding@nvidia.com> --- 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(-) diff --git a/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt b/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt index 1e4fc72..72810cc 100644 --- a/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +++ b/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt @@ -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>; }; diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 4053efb..cdef4a3 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -10,6 +10,8 @@ * published by the Free Software Foundation. */ +#include <linux/gpio.h> +#include <linux/of_gpio.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> @@ -28,6 +30,8 @@ struct pwm_bl_data { unsigned int lth_brightness; unsigned int *levels; bool enabled; + int enable_gpio; + unsigned long enable_gpio_flags; int (*notify)(struct device *, int brightness); void (*notify_after)(struct device *, @@ -55,6 +59,14 @@ static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness, pb->lth_brightness; pwm_config(pb->pwm, duty_cycle, pb->period); + + if (gpio_is_valid(pb->enable_gpio)) { + if (pb->enable_gpio_flags & PWM_BACKLIGHT_GPIO_ACTIVE_LOW) + gpio_set_value(pb->enable_gpio, 0); + else + gpio_set_value(pb->enable_gpio, 1); + } + pwm_enable(pb->pwm); pb->enabled = true; } @@ -67,6 +79,13 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb) pwm_config(pb->pwm, 0, pb->period); pwm_disable(pb->pwm); + if (gpio_is_valid(pb->enable_gpio)) { + if (pb->enable_gpio_flags & PWM_BACKLIGHT_GPIO_ACTIVE_LOW) + gpio_set_value(pb->enable_gpio, 1); + else + gpio_set_value(pb->enable_gpio, 0); + } + pb->enabled = false; } @@ -119,6 +138,7 @@ static int pwm_backlight_parse_dt(struct device *dev, struct platform_pwm_backlight_data *data) { struct device_node *node = dev->of_node; + enum of_gpio_flags flags; struct property *prop; int length; u32 value; @@ -159,11 +179,13 @@ static int pwm_backlight_parse_dt(struct device *dev, data->max_brightness--; } - /* - * TODO: Most users of this driver use a number of GPIOs to control - * backlight power. Support for specifying these needs to be - * added. - */ + data->enable_gpio = of_get_named_gpio_flags(node, "enable-gpios", 0, + &flags); + if (data->enable_gpio == -EPROBE_DEFER) + return -EPROBE_DEFER; + + if (gpio_is_valid(data->enable_gpio) && (flags & OF_GPIO_ACTIVE_LOW)) + data->enable_gpio_flags |= PWM_BACKLIGHT_GPIO_ACTIVE_LOW; return 0; } @@ -221,6 +243,8 @@ static int pwm_backlight_probe(struct platform_device *pdev) } else max = data->max_brightness; + pb->enable_gpio = data->enable_gpio; + pb->enable_gpio_flags = data->enable_gpio_flags; pb->notify = data->notify; pb->notify_after = data->notify_after; pb->check_fb = data->check_fb; @@ -228,6 +252,22 @@ static int pwm_backlight_probe(struct platform_device *pdev) pb->dev = &pdev->dev; pb->enabled = false; + if (gpio_is_valid(pb->enable_gpio)) { + unsigned long flags; + + if (pb->enable_gpio_flags & PWM_BACKLIGHT_GPIO_ACTIVE_LOW) + flags = GPIOF_OUT_INIT_HIGH; + else + flags = GPIOF_OUT_INIT_LOW; + + ret = gpio_request_one(pb->enable_gpio, flags, "enable"); + if (ret < 0) { + dev_err(&pdev->dev, "failed to request GPIO#%d: %d\n", + pb->enable_gpio, ret); + goto err_alloc; + } + } + 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"); @@ -236,7 +276,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) if (IS_ERR(pb->pwm)) { dev_err(&pdev->dev, "unable to request legacy PWM\n"); ret = PTR_ERR(pb->pwm); - goto err_alloc; + goto err_gpio; } } @@ -261,7 +301,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); ret = PTR_ERR(bl); - goto err_alloc; + goto err_gpio; } if (data->dft_brightness > data->max_brightness) { @@ -277,6 +317,9 @@ static int pwm_backlight_probe(struct platform_device *pdev) platform_set_drvdata(pdev, bl); return 0; +err_gpio: + if (gpio_is_valid(pb->enable_gpio)) + gpio_free(pb->enable_gpio); err_alloc: if (data->exit) data->exit(&pdev->dev); -- 1.8.4 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 11/12] pwm-backlight: Add power supply support 2013-10-07 11:37 [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support Thierry Reding ` (6 preceding siblings ...) 2013-10-07 11:37 ` [PATCH v2 10/12] pwm-backlight: Use new " Thierry Reding @ 2013-10-07 11:37 ` Thierry Reding 2013-10-07 11:37 ` [PATCH v2 12/12] pwm-backlight: Allow backlight to remain disabled on boot Thierry Reding [not found] ` <CAH9NwWfDRiQ3FegMyx1YBQ5jUgPvc7h2cxd3KgyeDdnsq6UgMw@mail.gmail.com> 9 siblings, 0 replies; 16+ messages in thread From: Thierry Reding @ 2013-10-07 11:37 UTC (permalink / raw) To: Thierry Reding Cc: Tony Lindgren, Eric Miao, Haojian Zhuang, Marek Vasut, Ben Dooks, Kukjin Kim, Guan Xuetao, devicetree, linux-pwm, linux-kernel Backlights require a power supply to work properly. This commit adds a regulator to power up and power down the backlight. Signed-off-by: Thierry Reding <treding@nvidia.com> --- 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(+) diff --git a/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt b/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt index 72810cc..764db86 100644 --- a/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +++ b/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt @@ -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>; }; diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index cdef4a3..eec6c98 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -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"); -- 1.8.4 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 12/12] pwm-backlight: Allow backlight to remain disabled on boot 2013-10-07 11:37 [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support Thierry Reding ` (7 preceding siblings ...) 2013-10-07 11:37 ` [PATCH v2 11/12] pwm-backlight: Add power supply support Thierry Reding @ 2013-10-07 11:37 ` Thierry Reding [not found] ` <CAH9NwWfDRiQ3FegMyx1YBQ5jUgPvc7h2cxd3KgyeDdnsq6UgMw@mail.gmail.com> 9 siblings, 0 replies; 16+ messages in thread From: Thierry Reding @ 2013-10-07 11:37 UTC (permalink / raw) To: Thierry Reding Cc: Tony Lindgren, Eric Miao, Haojian Zhuang, Marek Vasut, Ben Dooks, Kukjin Kim, Guan Xuetao, devicetree, linux-pwm, linux-kernel The 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". Signed-off-by: Thierry Reding <treding@nvidia.com> --- 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(+) diff --git a/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt b/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt index 764db86..65e001a 100644 --- a/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +++ b/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt @@ -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 diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index eec6c98..cd87ecb 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -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); diff --git a/include/linux/pwm_backlight.h b/include/linux/pwm_backlight.h index 2de2e27..ea4a239 100644 --- a/include/linux/pwm_backlight.h +++ b/include/linux/pwm_backlight.h @@ -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); -- 1.8.4 ^ permalink raw reply related [flat|nested] 16+ messages in thread
[parent not found: <CAH9NwWfDRiQ3FegMyx1YBQ5jUgPvc7h2cxd3KgyeDdnsq6UgMw@mail.gmail.com>]
* Re: [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support [not found] ` <CAH9NwWfDRiQ3FegMyx1YBQ5jUgPvc7h2cxd3KgyeDdnsq6UgMw@mail.gmail.com> @ 2013-11-08 12:36 ` Thierry Reding [not found] ` <20131108123619.GC31551-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org> 0 siblings, 1 reply; 16+ messages in thread From: Thierry Reding @ 2013-11-08 12:36 UTC (permalink / raw) To: Christian Gmeiner Cc: Tony Lindgren, Eric Miao, Haojian Zhuang, Marek Vasut, Ben Dooks, Kukjin Kim, Guan Xuetao, devicetree, linux-pwm, LKML [-- Attachment #1: Type: text/plain, Size: 474 bytes --] On Thu, Nov 07, 2013 at 01:00:04PM +0100, Christian Gmeiner wrote: > Hi Thierry > > > 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. Those patches (except the one that adds the backlight-boot-off property) will be part of my pull request for 3.13. Thierry [-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <20131108123619.GC31551-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>]
* Re: [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support [not found] ` <20131108123619.GC31551-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org> @ 2013-11-08 13:58 ` Christian Gmeiner 0 siblings, 0 replies; 16+ messages in thread From: Christian Gmeiner @ 2013-11-08 13:58 UTC (permalink / raw) To: Thierry Reding Cc: Tony Lindgren, Eric Miao, Haojian Zhuang, Marek Vasut, Ben Dooks, Kukjin Kim, Guan Xuetao, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-pwm-u79uwXL29TY76Z2rM5mHXA, LKML 2013/11/8 Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > On Thu, Nov 07, 2013 at 01:00:04PM +0100, Christian Gmeiner wrote: >> Hi Thierry >> >> >> 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. > > 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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2013-11-08 13:58 UTC | newest] Thread overview: 16+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-10-07 11:37 [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support Thierry Reding 2013-10-07 11:37 ` [PATCH v2 02/12] pwm-backlight: Refactor backlight power on/off Thierry Reding 2013-10-07 11:37 ` [PATCH v2 03/12] pwm-backlight: Track enable state Thierry Reding 2013-10-07 11:37 ` [PATCH v2 04/12] pwm-backlight: Add optional enable GPIO Thierry Reding [not found] ` <1381145866-445-1-git-send-email-treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> 2013-10-07 11:37 ` [PATCH v2 01/12] pwm-backlight: Improve readability Thierry Reding 2013-10-07 11:37 ` [PATCH v2 05/12] ARM: OMAP: Initialize PWM backlight enable_gpio field Thierry Reding 2013-10-07 11:37 ` [PATCH v2 06/12] ARM: pxa: " Thierry Reding 2013-10-07 11:37 ` [PATCH v2 07/12] ARM: SAMSUNG: " Thierry Reding 2013-11-07 12:44 ` [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support Christian Gmeiner 2013-10-07 11:37 ` [PATCH v2 08/12] ARM: shmobile: Initialize PWM backlight enable_gpio field Thierry Reding 2013-10-07 11:37 ` [PATCH v2 09/12] unicore32: " Thierry Reding 2013-10-07 11:37 ` [PATCH v2 10/12] pwm-backlight: Use new " Thierry Reding 2013-10-07 11:37 ` [PATCH v2 11/12] pwm-backlight: Add power supply support Thierry Reding 2013-10-07 11:37 ` [PATCH v2 12/12] pwm-backlight: Allow backlight to remain disabled on boot Thierry Reding [not found] ` <CAH9NwWfDRiQ3FegMyx1YBQ5jUgPvc7h2cxd3KgyeDdnsq6UgMw@mail.gmail.com> 2013-11-08 12:36 ` [PATCH v2 00/12] pwm-backlight: Add GPIO and power supply support Thierry Reding [not found] ` <20131108123619.GC31551-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org> 2013-11-08 13:58 ` Christian Gmeiner
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).