video: backlight: pwm_bl: add pwm_gpio
Matt Wagner [Wed, 16 Jan 2013 23:54:46 +0000 (15:54 -0800)]
Add parameter for pwm_gpio if the pwm pin is on a GPIO

Doing this will allow us to keep the backlight on during boot

Bug 1219004

Change-Id: Ic159933aaf4fdebbd8ea36e2960ff83dfb5fcab5
Signed-off-by: Matt Wagner <mwagner@nvidia.com>
Reviewed-on: http://git-master/r/191821
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Jon Mayo <jmayo@nvidia.com>

drivers/video/backlight/pwm_bl.c
include/linux/pwm_backlight.h

index 342b7d7..6aca33c 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/fb.h>
 #include <linux/backlight.h>
 #include <linux/err.h>
+#include <linux/gpio.h>
 #include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 #include <linux/slab.h>
@@ -26,6 +27,7 @@ struct pwm_bl_data {
        struct device           *dev;
        unsigned int            period;
        unsigned int            lth_brightness;
+       unsigned int            pwm_gpio;
        int                     (*notify)(struct device *,
                                          int brightness);
        void                    (*notify_after)(struct device *,
@@ -116,6 +118,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
        pb->lth_brightness = data->lth_brightness *
                (data->pwm_period_ns / data->max_brightness);
        pb->dev = &pdev->dev;
+       pb->pwm_gpio = data->pwm_gpio;
 
        pb->pwm = pwm_request(data->pwm_id, "backlight");
        if (IS_ERR(pb->pwm)) {
@@ -128,6 +131,13 @@ static int pwm_backlight_probe(struct platform_device *pdev)
        memset(&props, 0, sizeof(struct backlight_properties));
        props.type = BACKLIGHT_RAW;
        props.max_brightness = data->max_brightness;
+
+       if (gpio_is_valid(pb->pwm_gpio)) {
+               ret = gpio_request(pb->pwm_gpio, "disp_bl");
+               if (ret)
+                       dev_err(&pdev->dev, "backlight gpio request failed\n");
+       }
+
        bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb,
                                       &pwm_backlight_ops, &props);
        if (IS_ERR(bl)) {
@@ -139,6 +149,9 @@ static int pwm_backlight_probe(struct platform_device *pdev)
        bl->props.brightness = data->dft_brightness;
        backlight_update_status(bl);
 
+       if (gpio_is_valid(pb->pwm_gpio))
+               gpio_free(pb->pwm_gpio);
+
        platform_set_drvdata(pdev, bl);
        return 0;
 
index 63d2df4..7b4365d 100644 (file)
@@ -12,6 +12,7 @@ struct platform_pwm_backlight_data {
        unsigned int dft_brightness;
        unsigned int lth_brightness;
        unsigned int pwm_period_ns;
+       unsigned int pwm_gpio;
        int (*init)(struct device *dev);
        int (*notify)(struct device *dev, int brightness);
        void (*notify_after)(struct device *dev, int brightness);