aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Paul <seanpaul@chromium.org>2014-12-02 20:39:12 -0500
committerLee Jones <lee.jones@linaro.org>2014-12-09 04:24:45 -0500
commit829b030e58f8349a63909c0fff2fa1913d79314c (patch)
tree7fc2c2e84bd396b8299ab2635ec41472d18e652b
parent47726656dd67a2487bd7fafec1a73472da1db956 (diff)
backlight: lp855x: Add supply regulator to lp855x
This patch adds a supply regulator to the lp855x platform data to facilitate powering on/off the 3V rail attached to the controller. Cc: Stéphane Marchesin <marcheu@chromium.org> Cc: Aaron Durbin <adurbin@chromium.org> Signed-off-by: Sean Paul <seanpaul@chromium.org> Acked-by: Milo Kim <milo.kim@ti.com> Acked-by: Bryan Wu <cooloney@gmail.com> Acked-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r--Documentation/devicetree/bindings/video/backlight/lp855x.txt2
-rw-r--r--drivers/video/backlight/lp855x_bl.c18
-rw-r--r--include/linux/platform_data/lp855x.h2
3 files changed, 22 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/video/backlight/lp855x.txt b/Documentation/devicetree/bindings/video/backlight/lp855x.txt
index 96e83a56048e..0a3ecbc3a1b9 100644
--- a/Documentation/devicetree/bindings/video/backlight/lp855x.txt
+++ b/Documentation/devicetree/bindings/video/backlight/lp855x.txt
@@ -12,6 +12,7 @@ Optional properties:
12 - pwm-period: PWM period value. Set only PWM input mode used (u32) 12 - pwm-period: PWM period value. Set only PWM input mode used (u32)
13 - rom-addr: Register address of ROM area to be updated (u8) 13 - rom-addr: Register address of ROM area to be updated (u8)
14 - rom-val: Register value to be updated (u8) 14 - rom-val: Register value to be updated (u8)
15 - power-supply: Regulator which controls the 3V rail
15 16
16Example: 17Example:
17 18
@@ -56,6 +57,7 @@ Example:
56 backlight@2c { 57 backlight@2c {
57 compatible = "ti,lp8557"; 58 compatible = "ti,lp8557";
58 reg = <0x2c>; 59 reg = <0x2c>;
60 power-supply = <&backlight_vdd>;
59 61
60 dev-ctrl = /bits/ 8 <0x41>; 62 dev-ctrl = /bits/ 8 <0x41>;
61 init-brt = /bits/ 8 <0x0a>; 63 init-brt = /bits/ 8 <0x0a>;
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index 257b3badd8e4..a26d3bb25650 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -17,6 +17,7 @@
17#include <linux/of.h> 17#include <linux/of.h>
18#include <linux/platform_data/lp855x.h> 18#include <linux/platform_data/lp855x.h>
19#include <linux/pwm.h> 19#include <linux/pwm.h>
20#include <linux/regulator/consumer.h>
20 21
21/* LP8550/1/2/3/6 Registers */ 22/* LP8550/1/2/3/6 Registers */
22#define LP855X_BRIGHTNESS_CTRL 0x00 23#define LP855X_BRIGHTNESS_CTRL 0x00
@@ -383,6 +384,13 @@ static int lp855x_parse_dt(struct lp855x *lp)
383 pdata->rom_data = &rom[0]; 384 pdata->rom_data = &rom[0];
384 } 385 }
385 386
387 pdata->supply = devm_regulator_get(dev, "power");
388 if (IS_ERR(pdata->supply)) {
389 if (PTR_ERR(pdata->supply) == -EPROBE_DEFER)
390 return -EPROBE_DEFER;
391 pdata->supply = NULL;
392 }
393
386 lp->pdata = pdata; 394 lp->pdata = pdata;
387 395
388 return 0; 396 return 0;
@@ -423,6 +431,14 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
423 else 431 else
424 lp->mode = REGISTER_BASED; 432 lp->mode = REGISTER_BASED;
425 433
434 if (lp->pdata->supply) {
435 ret = regulator_enable(lp->pdata->supply);
436 if (ret < 0) {
437 dev_err(&cl->dev, "failed to enable supply: %d\n", ret);
438 return ret;
439 }
440 }
441
426 i2c_set_clientdata(cl, lp); 442 i2c_set_clientdata(cl, lp);
427 443
428 ret = lp855x_configure(lp); 444 ret = lp855x_configure(lp);
@@ -454,6 +470,8 @@ static int lp855x_remove(struct i2c_client *cl)
454 470
455 lp->bl->props.brightness = 0; 471 lp->bl->props.brightness = 0;
456 backlight_update_status(lp->bl); 472 backlight_update_status(lp->bl);
473 if (lp->pdata->supply)
474 regulator_disable(lp->pdata->supply);
457 sysfs_remove_group(&lp->dev->kobj, &lp855x_attr_group); 475 sysfs_remove_group(&lp->dev->kobj, &lp855x_attr_group);
458 476
459 return 0; 477 return 0;
diff --git a/include/linux/platform_data/lp855x.h b/include/linux/platform_data/lp855x.h
index 1b2ba24e4e03..9c7fd1efe495 100644
--- a/include/linux/platform_data/lp855x.h
+++ b/include/linux/platform_data/lp855x.h
@@ -136,6 +136,7 @@ struct lp855x_rom_data {
136 Only valid when mode is PWM_BASED. 136 Only valid when mode is PWM_BASED.
137 * @size_program : total size of lp855x_rom_data 137 * @size_program : total size of lp855x_rom_data
138 * @rom_data : list of new eeprom/eprom registers 138 * @rom_data : list of new eeprom/eprom registers
139 * @supply : regulator that supplies 3V input
139 */ 140 */
140struct lp855x_platform_data { 141struct lp855x_platform_data {
141 const char *name; 142 const char *name;
@@ -144,6 +145,7 @@ struct lp855x_platform_data {
144 unsigned int period_ns; 145 unsigned int period_ns;
145 int size_program; 146 int size_program;
146 struct lp855x_rom_data *rom_data; 147 struct lp855x_rom_data *rom_data;
148 struct regulator *supply;
147}; 149};
148 150
149#endif 151#endif