From patchwork Fri Jun 10 19:39:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 9170299 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 BA8ED6048C for ; Fri, 10 Jun 2016 19:40:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A85C62824F for ; Fri, 10 Jun 2016 19:40:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C7B628325; Fri, 10 Jun 2016 19:40:28 +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 486E32824F for ; Fri, 10 Jun 2016 19:40:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752879AbcFJTkN (ORCPT ); Fri, 10 Jun 2016 15:40:13 -0400 Received: from mail-pf0-f173.google.com ([209.85.192.173]:35383 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751724AbcFJTkK (ORCPT ); Fri, 10 Jun 2016 15:40:10 -0400 Received: by mail-pf0-f173.google.com with SMTP id c2so26075905pfa.2 for ; Fri, 10 Jun 2016 12:40:09 -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=DQNPrNh5wOhbqrqLWfYOY+PzqxauM00hWgMb/B7lBfM=; b=H69TDGzPq0a5Xd5mc3w9i2qvbZby7rKrlg8dWlNr14eF182efo4wdV/DsLE0pi0v6t aZVfqIB1Gp9Rc5sBvGyUfeXR9DbzYYn3N4+E4V8AunMwqYOkldrQSxE494ueDAuGQnUt /SuO8+fmesEuQtXy7eDpS+g/UOp2bmEf8kbP8= 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=DQNPrNh5wOhbqrqLWfYOY+PzqxauM00hWgMb/B7lBfM=; b=CUUk+jebHrrHQO1bwwA7e2kl8ZDAIo2HcqTGCgRPqPHWcwmYPAnzq7/mx9vLQYLwn0 FcLyQvuD1nv7xmI5XieTyfTgyx8rASPKwBir0vvqUwUjoL5vSb807Wl40YKclicSnPGO mCoNbyD9sPfmTFzwGaBXbPgtgbfvHjEyDd2k9nEPWM+JRn5Qk+JzH+CtGwPYKSuCB9Eq WvhjmuDYuNnxi+3gWRSlKewNdjON836ChK/1GBOgvjqU5OOANvmUjCWA4grf/ELdcS0C cguhNNLDEBbRF2A3sxCMCiEEZrlv55UHhIlKa510IIuv19IFDGqRQ7yRVvHC2HEyMdka H+Tw== X-Gm-Message-State: ALyK8tJNc3Kb3pVVl7KIjHw3fWUgc36o4SmSnaGuEkN1bhcBHvnGvuybnWqIGchtzbjDocNd X-Received: by 10.98.30.133 with SMTP id e127mr3825752pfe.112.1465587608890; Fri, 10 Jun 2016 12:40:08 -0700 (PDT) Received: from ban.mtv.corp.google.com ([172.22.64.120]) by smtp.gmail.com with ESMTPSA id w80sm19524836pfj.53.2016.06.10.12.40.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Jun 2016 12:40:08 -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 v2] backlight: lp855x: Add enable regulator Date: Fri, 10 Jun 2016 12:39:57 -0700 Message-Id: <1465587597-131467-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 Reviewed-by: Stephen Barber Acked-by: Milo Kim Acked-by: Rob Herring --- v2: s/TS8555/LP8555/ in comment (typo) .../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..939f057836e1 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; + } + + /* + * LP8555 datasheet says t_RESPONSE (time between VDDIO and + * I2C) is 1ms. + */ + usleep_range(1000, 2000); + } + i2c_set_clientdata(cl, lp); ret = lp855x_configure(lp);