diff options
-rw-r--r-- | Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt | 2 | ||||
-rw-r--r-- | drivers/video/backlight/pwm_bl.c | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt b/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt index 72810cc2dbc1..764db86d441a 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: | |||
10 | last value in the array represents a 100% duty cycle (brightest). | 10 | last value in the array represents a 100% duty cycle (brightest). |
11 | - default-brightness-level: the default brightness level (index into the | 11 | - default-brightness-level: the default brightness level (index into the |
12 | array defined by the "brightness-levels" property) | 12 | array defined by the "brightness-levels" property) |
13 | - power-supply: regulator for supply voltage | ||
13 | 14 | ||
14 | Optional properties: | 15 | Optional properties: |
15 | - pwm-names: a list of names for the PWM devices specified in the | 16 | - pwm-names: a list of names for the PWM devices specified in the |
@@ -29,5 +30,6 @@ Example: | |||
29 | brightness-levels = <0 4 8 16 32 64 128 255>; | 30 | brightness-levels = <0 4 8 16 32 64 128 255>; |
30 | default-brightness-level = <6>; | 31 | default-brightness-level = <6>; |
31 | 32 | ||
33 | power-supply = <&vdd_bl_reg>; | ||
32 | enable-gpios = <&gpio 58 0>; | 34 | enable-gpios = <&gpio 58 0>; |
33 | }; | 35 | }; |
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index cdef4a346555..eec6c98527f9 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
22 | #include <linux/pwm.h> | 22 | #include <linux/pwm.h> |
23 | #include <linux/pwm_backlight.h> | 23 | #include <linux/pwm_backlight.h> |
24 | #include <linux/regulator/consumer.h> | ||
24 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
25 | 26 | ||
26 | struct pwm_bl_data { | 27 | struct pwm_bl_data { |
@@ -30,6 +31,7 @@ struct pwm_bl_data { | |||
30 | unsigned int lth_brightness; | 31 | unsigned int lth_brightness; |
31 | unsigned int *levels; | 32 | unsigned int *levels; |
32 | bool enabled; | 33 | bool enabled; |
34 | struct regulator *power_supply; | ||
33 | int enable_gpio; | 35 | int enable_gpio; |
34 | unsigned long enable_gpio_flags; | 36 | unsigned long enable_gpio_flags; |
35 | int (*notify)(struct device *, | 37 | int (*notify)(struct device *, |
@@ -60,6 +62,10 @@ static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness, | |||
60 | 62 | ||
61 | pwm_config(pb->pwm, duty_cycle, pb->period); | 63 | pwm_config(pb->pwm, duty_cycle, pb->period); |
62 | 64 | ||
65 | err = regulator_enable(pb->power_supply); | ||
66 | if (err < 0) | ||
67 | dev_err(pb->dev, "failed to enable power supply\n"); | ||
68 | |||
63 | if (gpio_is_valid(pb->enable_gpio)) { | 69 | if (gpio_is_valid(pb->enable_gpio)) { |
64 | if (pb->enable_gpio_flags & PWM_BACKLIGHT_GPIO_ACTIVE_LOW) | 70 | if (pb->enable_gpio_flags & PWM_BACKLIGHT_GPIO_ACTIVE_LOW) |
65 | gpio_set_value(pb->enable_gpio, 0); | 71 | gpio_set_value(pb->enable_gpio, 0); |
@@ -86,6 +92,7 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb) | |||
86 | gpio_set_value(pb->enable_gpio, 0); | 92 | gpio_set_value(pb->enable_gpio, 0); |
87 | } | 93 | } |
88 | 94 | ||
95 | regulator_disable(pb->power_supply); | ||
89 | pb->enabled = false; | 96 | pb->enabled = false; |
90 | } | 97 | } |
91 | 98 | ||
@@ -268,6 +275,12 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
268 | } | 275 | } |
269 | } | 276 | } |
270 | 277 | ||
278 | pb->power_supply = devm_regulator_get(&pdev->dev, "power"); | ||
279 | if (IS_ERR(pb->power_supply)) { | ||
280 | ret = PTR_ERR(pb->power_supply); | ||
281 | goto err_gpio; | ||
282 | } | ||
283 | |||
271 | pb->pwm = devm_pwm_get(&pdev->dev, NULL); | 284 | pb->pwm = devm_pwm_get(&pdev->dev, NULL); |
272 | if (IS_ERR(pb->pwm)) { | 285 | if (IS_ERR(pb->pwm)) { |
273 | dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n"); | 286 | dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n"); |