Commit 1efc15812d8ce5d9096bb8af400f51a85b5f5af0
Committed by
Samuel Ortiz
1 parent
7825806474
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
backlight: Modified power control of pm860x backlight
Since several sub modules such as backlight, leds and vibrator depend on the refernce group and internal oscillator in pm8606, so modified the power control of backlight in pm8606 by unified interface. Signed-off-by: Jett.Zhou <jtzhou@marvell.com> Cc: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Showing 1 changed file with 28 additions and 21 deletions Side-by-side Diff
drivers/video/backlight/88pm860x_bl.c
... | ... | @@ -67,6 +67,28 @@ |
67 | 67 | return ret; |
68 | 68 | } |
69 | 69 | |
70 | +static int backlight_power_set(struct pm860x_chip *chip, int port, | |
71 | + int on) | |
72 | +{ | |
73 | + int ret = -EINVAL; | |
74 | + | |
75 | + switch (port) { | |
76 | + case PM8606_BACKLIGHT1: | |
77 | + ret = on ? pm8606_osc_enable(chip, WLED1_DUTY) : | |
78 | + pm8606_osc_disable(chip, WLED1_DUTY); | |
79 | + break; | |
80 | + case PM8606_BACKLIGHT2: | |
81 | + ret = on ? pm8606_osc_enable(chip, WLED2_DUTY) : | |
82 | + pm8606_osc_disable(chip, WLED2_DUTY); | |
83 | + break; | |
84 | + case PM8606_BACKLIGHT3: | |
85 | + ret = on ? pm8606_osc_enable(chip, WLED3_DUTY) : | |
86 | + pm8606_osc_disable(chip, WLED3_DUTY); | |
87 | + break; | |
88 | + } | |
89 | + return ret; | |
90 | +} | |
91 | + | |
70 | 92 | static int pm860x_backlight_set(struct backlight_device *bl, int brightness) |
71 | 93 | { |
72 | 94 | struct pm860x_backlight_data *data = bl_get_data(bl); |
... | ... | @@ -79,6 +101,9 @@ |
79 | 101 | else |
80 | 102 | value = brightness; |
81 | 103 | |
104 | + if (brightness) | |
105 | + backlight_power_set(chip, data->port, 1); | |
106 | + | |
82 | 107 | ret = pm860x_reg_write(data->i2c, wled_a(data->port), value); |
83 | 108 | if (ret < 0) |
84 | 109 | goto out; |
... | ... | @@ -115,6 +140,9 @@ |
115 | 140 | if (ret < 0) |
116 | 141 | goto out; |
117 | 142 | |
143 | + if (brightness == 0) | |
144 | + backlight_power_set(chip, data->port, 0); | |
145 | + | |
118 | 146 | dev_dbg(chip->dev, "set brightness %d\n", value); |
119 | 147 | data->current_brightness = value; |
120 | 148 | return 0; |
... | ... | @@ -170,7 +198,6 @@ |
170 | 198 | struct backlight_device *bl; |
171 | 199 | struct resource *res; |
172 | 200 | struct backlight_properties props; |
173 | - unsigned char value; | |
174 | 201 | char name[MFD_NAME_SIZE]; |
175 | 202 | int ret; |
176 | 203 | |
... | ... | @@ -218,26 +245,6 @@ |
218 | 245 | |
219 | 246 | platform_set_drvdata(pdev, bl); |
220 | 247 | |
221 | - /* Enable reference VSYS */ | |
222 | - ret = pm860x_reg_read(data->i2c, PM8606_VSYS); | |
223 | - if (ret < 0) | |
224 | - goto out; | |
225 | - if ((ret & PM8606_VSYS_EN) == 0) { | |
226 | - value = ret | PM8606_VSYS_EN; | |
227 | - ret = pm860x_reg_write(data->i2c, PM8606_VSYS, value); | |
228 | - if (ret < 0) | |
229 | - goto out; | |
230 | - } | |
231 | - /* Enable reference OSC */ | |
232 | - ret = pm860x_reg_read(data->i2c, PM8606_MISC); | |
233 | - if (ret < 0) | |
234 | - goto out; | |
235 | - if ((ret & PM8606_MISC_OSC_EN) == 0) { | |
236 | - value = ret | PM8606_MISC_OSC_EN; | |
237 | - ret = pm860x_reg_write(data->i2c, PM8606_MISC, value); | |
238 | - if (ret < 0) | |
239 | - goto out; | |
240 | - } | |
241 | 248 | /* read current backlight */ |
242 | 249 | ret = pm860x_backlight_get_brightness(bl); |
243 | 250 | if (ret < 0) |