diff options
Diffstat (limited to 'drivers/video/backlight')
-rw-r--r-- | drivers/video/backlight/88pm860x_bl.c | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c index a1376dc73d71..b6ea65f83eb7 100644 --- a/drivers/video/backlight/88pm860x_bl.c +++ b/drivers/video/backlight/88pm860x_bl.c | |||
@@ -67,6 +67,28 @@ static inline int wled_idc(int port) | |||
67 | return ret; | 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 | static int pm860x_backlight_set(struct backlight_device *bl, int brightness) | 92 | static int pm860x_backlight_set(struct backlight_device *bl, int brightness) |
71 | { | 93 | { |
72 | struct pm860x_backlight_data *data = bl_get_data(bl); | 94 | struct pm860x_backlight_data *data = bl_get_data(bl); |
@@ -79,6 +101,9 @@ static int pm860x_backlight_set(struct backlight_device *bl, int brightness) | |||
79 | else | 101 | else |
80 | value = brightness; | 102 | value = brightness; |
81 | 103 | ||
104 | if (brightness) | ||
105 | backlight_power_set(chip, data->port, 1); | ||
106 | |||
82 | ret = pm860x_reg_write(data->i2c, wled_a(data->port), value); | 107 | ret = pm860x_reg_write(data->i2c, wled_a(data->port), value); |
83 | if (ret < 0) | 108 | if (ret < 0) |
84 | goto out; | 109 | goto out; |
@@ -115,6 +140,9 @@ static int pm860x_backlight_set(struct backlight_device *bl, int brightness) | |||
115 | if (ret < 0) | 140 | if (ret < 0) |
116 | goto out; | 141 | goto out; |
117 | 142 | ||
143 | if (brightness == 0) | ||
144 | backlight_power_set(chip, data->port, 0); | ||
145 | |||
118 | dev_dbg(chip->dev, "set brightness %d\n", value); | 146 | dev_dbg(chip->dev, "set brightness %d\n", value); |
119 | data->current_brightness = value; | 147 | data->current_brightness = value; |
120 | return 0; | 148 | return 0; |
@@ -170,7 +198,6 @@ static int pm860x_backlight_probe(struct platform_device *pdev) | |||
170 | struct backlight_device *bl; | 198 | struct backlight_device *bl; |
171 | struct resource *res; | 199 | struct resource *res; |
172 | struct backlight_properties props; | 200 | struct backlight_properties props; |
173 | unsigned char value; | ||
174 | char name[MFD_NAME_SIZE]; | 201 | char name[MFD_NAME_SIZE]; |
175 | int ret; | 202 | int ret; |
176 | 203 | ||
@@ -218,26 +245,6 @@ static int pm860x_backlight_probe(struct platform_device *pdev) | |||
218 | 245 | ||
219 | platform_set_drvdata(pdev, bl); | 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 | /* read current backlight */ | 248 | /* read current backlight */ |
242 | ret = pm860x_backlight_get_brightness(bl); | 249 | ret = pm860x_backlight_get_brightness(bl); |
243 | if (ret < 0) | 250 | if (ret < 0) |