Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Brian Norris and committed by
Lee Jones
60255307 af8c34ce

+31
+2
Documentation/devicetree/bindings/leds/backlight/lp855x.txt
··· 13 13 - rom-addr: Register address of ROM area to be updated (u8) 14 14 - rom-val: Register value to be updated (u8) 15 15 - power-supply: Regulator which controls the 3V rail 16 + - enable-supply: Regulator which controls the EN/VDDIO input 16 17 17 18 Example: 18 19 ··· 58 57 backlight@2c { 59 58 compatible = "ti,lp8557"; 60 59 reg = <0x2c>; 60 + enable-supply = <&backlight_vddio>; 61 61 power-supply = <&backlight_vdd>; 62 62 63 63 dev-ctrl = /bits/ 8 <0x41>;
+29
drivers/video/backlight/lp855x_bl.c
··· 13 13 #include <linux/slab.h> 14 14 #include <linux/i2c.h> 15 15 #include <linux/backlight.h> 16 + #include <linux/delay.h> 16 17 #include <linux/err.h> 17 18 #include <linux/of.h> 18 19 #include <linux/platform_data/lp855x.h> ··· 75 74 struct lp855x_platform_data *pdata; 76 75 struct pwm_device *pwm; 77 76 struct regulator *supply; /* regulator for VDD input */ 77 + struct regulator *enable; /* regulator for EN/VDDIO input */ 78 78 }; 79 79 80 80 static int lp855x_write_byte(struct lp855x *lp, u8 reg, u8 data) ··· 435 433 lp->supply = NULL; 436 434 } 437 435 436 + lp->enable = devm_regulator_get_optional(lp->dev, "enable"); 437 + if (IS_ERR(lp->enable)) { 438 + ret = PTR_ERR(lp->enable); 439 + if (ret == -ENODEV) { 440 + lp->enable = NULL; 441 + } else { 442 + if (ret != -EPROBE_DEFER) 443 + dev_err(lp->dev, "error getting enable regulator: %d\n", 444 + ret); 445 + return ret; 446 + } 447 + } 448 + 438 449 if (lp->supply) { 439 450 ret = regulator_enable(lp->supply); 440 451 if (ret < 0) { 441 452 dev_err(&cl->dev, "failed to enable supply: %d\n", ret); 442 453 return ret; 443 454 } 455 + } 456 + 457 + if (lp->enable) { 458 + ret = regulator_enable(lp->enable); 459 + if (ret < 0) { 460 + dev_err(lp->dev, "failed to enable vddio: %d\n", ret); 461 + return ret; 462 + } 463 + 464 + /* 465 + * LP8555 datasheet says t_RESPONSE (time between VDDIO and 466 + * I2C) is 1ms. 467 + */ 468 + usleep_range(1000, 2000); 444 469 } 445 470 446 471 i2c_set_clientdata(cl, lp);