From patchwork Fri Jun 10 16:28:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 9170087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ECF15607D9 for ; Fri, 10 Jun 2016 16:29:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DED7926E1A for ; Fri, 10 Jun 2016 16:29:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D106A27D13; Fri, 10 Jun 2016 16:29:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54C3426E1A for ; Fri, 10 Jun 2016 16:29:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753041AbcFJQ32 (ORCPT ); Fri, 10 Jun 2016 12:29:28 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:36778 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933414AbcFJQ3C (ORCPT ); Fri, 10 Jun 2016 12:29:02 -0400 Received: by mail-pf0-f178.google.com with SMTP id t190so24996832pfb.3 for ; Fri, 10 Jun 2016 09:29:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=aSyXri2JvloNi6OcdlQikbwWNQaln+ksYmx/7ZIBjSk=; b=BLb86xqTg3qqLJhKf625JiNE1Uy9d0gOhhh1wchTd0j9YjbF8WPBCS+eYMKA1Uetn7 rh8Jchczg18UfwUN/xg/xvBtKN5Mny0607pbiVVSUb0/CcO5KoN88fj8C5uZ5tAR5c/V PVo+sfEu12pfq4RLU//cMNvMEaAXOLowZy1Mo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=aSyXri2JvloNi6OcdlQikbwWNQaln+ksYmx/7ZIBjSk=; b=KoSzP7upFhjBKN9cMplMGYQ2GftFY+9ngE/D56ZusAETwl8TkwUsoPAi/VdeqpN8Aj LdRO1RruDE7cG0sRMzo0aq4z/ZG+i7lL3jhptCYu3UwxSuZZi6oL2AAjKT5t31SU4iow JvKPLDD4YYlgNGAHx7olLf6zRXVWl7mbxHS7nscfbzKHU5X4DgPY2R3uwX6NcQisMoJP p4HJeogYDQmagJ3ucjYo0MdT0rIQkimu1/6H3FaWLkgPkBaRocmVtO1pU/u29JwrKRrI p13/3GRmqXWR4cMYuJw4EhXVx7CLmUTHiyCEAuifoZCbjx3T9pcR2hW9E+A5HjqF5FrB T6tQ== X-Gm-Message-State: ALyK8tIkpbvwaBM4wux5k9/+MGOGqFoe6sEZuAHqSxZR+KAk6HyqVKwhyAGqZEW3cdD5dWc5 X-Received: by 10.98.196.18 with SMTP id y18mr1506183pff.163.1465576141800; Fri, 10 Jun 2016 09:29:01 -0700 (PDT) Received: from ban.mtv.corp.google.com ([172.22.64.120]) by smtp.gmail.com with ESMTPSA id a17sm18791016pfa.70.2016.06.10.09.29.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Jun 2016 09:29:01 -0700 (PDT) From: Brian Norris To: Milo Kim , Jingoo Han , Lee Jones Cc: Stephen Barber , Doug Anderson , Jean-Christophe Plagniol-Villard , Tomi Valkeinen , Brian Norris , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org Subject: [PATCH] backlight: lp855x: Add enable regulator Date: Fri, 10 Jun 2016 09:28:45 -0700 Message-Id: <1465576125-118369-1-git-send-email-briannorris@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- .../devicetree/bindings/leds/backlight/lp855x.txt | 2 ++ drivers/video/backlight/lp855x_bl.c | 29 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) 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: - rom-addr: Register address of ROM area to be updated (u8) - rom-val: Register value to be updated (u8) - power-supply: Regulator which controls the 3V rail + - enable-supply: Regulator which controls the EN/VDDIO input Example: @@ -57,6 +58,7 @@ Example: backlight@2c { compatible = "ti,lp8557"; reg = <0x2c>; + enable-supply = <&backlight_vddio>; power-supply = <&backlight_vdd>; dev-ctrl = /bits/ 8 <0x41>; diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index e5b14f52628f..7e1f9a78674e 100644 --- a/drivers/video/backlight/lp855x_bl.c +++ b/drivers/video/backlight/lp855x_bl.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -74,6 +75,7 @@ struct lp855x { struct lp855x_platform_data *pdata; struct pwm_device *pwm; struct regulator *supply; /* regulator for VDD input */ + struct regulator *enable; /* regulator for EN/VDDIO input */ }; static 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) lp->supply = NULL; } + lp->enable = devm_regulator_get_optional(lp->dev, "enable"); + if (IS_ERR(lp->enable)) { + ret = PTR_ERR(lp->enable); + if (ret == -ENODEV) { + lp->enable = NULL; + } else { + if (ret != -EPROBE_DEFER) + dev_err(lp->dev, "error getting enable regulator: %d\n", + ret); + return ret; + } + } + if (lp->supply) { ret = regulator_enable(lp->supply); if (ret < 0) { @@ -441,6 +456,20 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) } } + if (lp->enable) { + ret = regulator_enable(lp->enable); + if (ret < 0) { + dev_err(lp->dev, "failed to enable vddio: %d\n", ret); + return ret; + } + + /* + * TS8555 datasheet says t_RESPONSE (time between VDDIO and + * I2C) is 1ms. + */ + usleep_range(1000, 2000); + } + i2c_set_clientdata(cl, lp); ret = lp855x_configure(lp);