aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Norris <briannorris@chromium.org>2016-06-10 15:39:57 -0400
committerLee Jones <lee.jones@linaro.org>2016-06-29 05:06:21 -0400
commit602553073892c18f723f8aa090153a23b1312a16 (patch)
treef6b898ed187ef7cf1134e46bf914f49732a783cc
parentaf8c34ce6ae32addda3788d54a7e340cad22516b (diff)
backlight: lp855x: Add enable regulator
The LP8556 datasheet describes an EN/VDDIO input, which serves "both as a chip enable and as a power supply reference for PWM, SDA, and SCL inputs." The LP8556 that I'm testing doesn't respond properly if I try to talk I2C to it too quickly after enabling VDDIO, and the LP8555 datasheet mentions a t_RESPONSE delay of up to 1 millisecond. Support this EN/VDDIO by adding a regulator property to the binding; enabling this regulator at probe time; and sleeping for 1 to 2ms, if the EN/VDDIO regulator was provided. Signed-off-by: Brian Norris <briannorris@chromium.org> Acked-by: Rob Herring <robh@kernel.org> Acked-by: Milo Kim <milo.kim@ti.com> Reviewed-by: Stephen Barber <smbarber@chromium.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r--Documentation/devicetree/bindings/leds/backlight/lp855x.txt2
-rw-r--r--drivers/video/backlight/lp855x_bl.c29
2 files changed, 31 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/leds/backlight/lp855x.txt b/Documentation/devicetree/bindings/leds/backlight/lp855x.txt
index 0a3ecbc3a1b9..88f56641fc28 100644
--- a/Documentation/devicetree/bindings/leds/backlight/lp855x.txt
+++ b/Documentation/devicetree/bindings/leds/backlight/lp855x.txt
@@ -13,6 +13,7 @@ Optional properties:
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 - power-supply: Regulator which controls the 3V rail
16 - enable-supply: Regulator which controls the EN/VDDIO input
16 17
17Example: 18Example:
18 19
@@ -57,6 +58,7 @@ Example:
57 backlight@2c { 58 backlight@2c {
58 compatible = "ti,lp8557"; 59 compatible = "ti,lp8557";
59 reg = <0x2c>; 60 reg = <0x2c>;
61 enable-supply = <&backlight_vddio>;
60 power-supply = <&backlight_vdd>; 62 power-supply = <&backlight_vdd>;
61 63
62 dev-ctrl = /bits/ 8 <0x41>; 64 dev-ctrl = /bits/ 8 <0x41>;
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index e5b14f52628f..939f057836e1 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -13,6 +13,7 @@
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/i2c.h> 14#include <linux/i2c.h>
15#include <linux/backlight.h> 15#include <linux/backlight.h>
16#include <linux/delay.h>
16#include <linux/err.h> 17#include <linux/err.h>
17#include <linux/of.h> 18#include <linux/of.h>
18#include <linux/platform_data/lp855x.h> 19#include <linux/platform_data/lp855x.h>
@@ -74,6 +75,7 @@ struct lp855x {
74 struct lp855x_platform_data *pdata; 75 struct lp855x_platform_data *pdata;
75 struct pwm_device *pwm; 76 struct pwm_device *pwm;
76 struct regulator *supply; /* regulator for VDD input */ 77 struct regulator *supply; /* regulator for VDD input */
78 struct regulator *enable; /* regulator for EN/VDDIO input */
77}; 79};
78 80
79static int lp855x_write_byte(struct lp855x *lp, u8 reg, u8 data) 81static int lp855x_write_byte(struct lp855x *lp, u8 reg, u8 data)
@@ -433,6 +435,19 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
433 lp->supply = NULL; 435 lp->supply = NULL;
434 } 436 }
435 437
438 lp->enable = devm_regulator_get_optional(lp->dev, "enable");
439 if (IS_ERR(lp->enable)) {
440 ret = PTR_ERR(lp->enable);
441 if (ret == -ENODEV) {
442 lp->enable = NULL;
443 } else {
444 if (ret != -EPROBE_DEFER)
445 dev_err(lp->dev, "error getting enable regulator: %d\n",
446 ret);
447 return ret;
448 }
449 }
450
436 if (lp->supply) { 451 if (lp->supply) {
437 ret = regulator_enable(lp->supply); 452 ret = regulator_enable(lp->supply);
438 if (ret < 0) { 453 if (ret < 0) {
@@ -441,6 +456,20 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
441 } 456 }
442 } 457 }
443 458
459 if (lp->enable) {
460 ret = regulator_enable(lp->enable);
461 if (ret < 0) {
462 dev_err(lp->dev, "failed to enable vddio: %d\n", ret);
463 return ret;
464 }
465
466 /*
467 * LP8555 datasheet says t_RESPONSE (time between VDDIO and
468 * I2C) is 1ms.
469 */
470 usleep_range(1000, 2000);
471 }
472
444 i2c_set_clientdata(cl, lp); 473 i2c_set_clientdata(cl, lp);
445 474
446 ret = lp855x_configure(lp); 475 ret = lp855x_configure(lp);