From patchwork Mon Dec 1 21:07:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 5415431 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 98BCFBEEA8 for ; Mon, 1 Dec 2014 21:08:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 54F1B2026F for ; Mon, 1 Dec 2014 21:08:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5250B201D3 for ; Mon, 1 Dec 2014 21:08:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932348AbaLAVIJ (ORCPT ); Mon, 1 Dec 2014 16:08:09 -0500 Received: from mail-ie0-f178.google.com ([209.85.223.178]:39641 "EHLO mail-ie0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932112AbaLAVII (ORCPT ); Mon, 1 Dec 2014 16:08:08 -0500 Received: by mail-ie0-f178.google.com with SMTP id tp5so10061443ieb.23 for ; Mon, 01 Dec 2014 13:08:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=IjsBit9JqbXyRzJ3vBzf8MRtlVXGBeXLVFFigds4my8=; b=bc6z/v9P2diSTij5HMHwvPHyxuIfsHOmczjJ99BmjPCPGOSs1I0dRVrIZRfoM+Sm4q pp2HxSPuWhOrWAD3I4JJo95CoTYyL9uqASr1P4v3hFz5ilmVAzvgy1xB5lF8w5C2C1ZH ZgjHLbh6I6LbuwkbHM8pUMoAnvchMBbeaTXgY= 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:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=IjsBit9JqbXyRzJ3vBzf8MRtlVXGBeXLVFFigds4my8=; b=ZXcYO3z5/veMCGG4eO8HSQmF2TEHBFzopEfnsmtm1FDlqkTCR4b6vVF7rbiuiPaM4h 5R/pa94qsYiE2X38Jo2swrkMo9ih6MGJNzSWKm62TOk/KcmJlF86NTSMcwEQDMmE9vsR Rhmkhae56z92l+TVCvs/X2UBZLBT9/+oLEkemBwZZ38vgzsvGLL/dxp3rlZ90SrlMhEM Q7VczZZk+bg7EyWogEDU/JoEcVgc3C5vdyhaJTBMSm368XmoYXOyB9iBOTVDX7ete/gI UmUUNjbUmNqknVDEGX1tgQoYeJKNqh2cyrn+5KMtWpHywaio+vskglkZrRgcxQrE3O3U DsKA== X-Gm-Message-State: ALoCoQlV6lJZShlOTnSt3oXI3zIFCnQX5G/QI6iGi57lQzAV4vyvf2CVWuk1UXyLvqc1LtdwS5A4 X-Received: by 10.50.66.179 with SMTP id g19mr48941449igt.40.1417468087648; Mon, 01 Dec 2014 13:08:07 -0800 (PST) Received: from davidriley-lab.mtv.corp.google.com ([172.22.64.15]) by mx.google.com with ESMTPSA id l14sm10088409ioi.31.2014.12.01.13.08.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Dec 2014 13:08:06 -0800 (PST) From: Sean Paul To: linux-fbdev@vger.kernel.org, devicetree@vger.kernel.org, milo.kim@ti.com Cc: jg1.han@samsung.com, cooloney@gmail.com, lee.jones@linaro.org, Sean Paul , =?UTF-8?q?St=C3=A9phane=20Marchesin?= , Aaron Durbin Subject: [PATCH v2 2/2] backlight/lp855x: Add supply regulator to lp855x Date: Mon, 1 Dec 2014 13:07:59 -0800 Message-Id: <1417468079-4990-1-git-send-email-seanpaul@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <54767F43.2060901@ti.com> References: <54767F43.2060901@ti.com> MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Aaron Durbin Signed-off-by: Sean Paul Acked-by: Milo Kim --- Changes in v2: - Add NULL check in lp855x_remove .../devicetree/bindings/video/backlight/lp855x.txt | 2 ++ drivers/video/backlight/lp855x_bl.c | 18 ++++++++++++++++++ include/linux/platform_data/lp855x.h | 2 ++ 3 files changed, 22 insertions(+) diff --git a/Documentation/devicetree/bindings/video/backlight/lp855x.txt b/Documentation/devicetree/bindings/video/backlight/lp855x.txt index 96e83a5..0a3ecbc 100644 --- a/Documentation/devicetree/bindings/video/backlight/lp855x.txt +++ b/Documentation/devicetree/bindings/video/backlight/lp855x.txt @@ -12,6 +12,7 @@ Optional properties: - pwm-period: PWM period value. Set only PWM input mode used (u32) - 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 Example: @@ -56,6 +57,7 @@ Example: backlight@2c { compatible = "ti,lp8557"; reg = <0x2c>; + power-supply = <&backlight_vdd>; dev-ctrl = /bits/ 8 <0x41>; init-brt = /bits/ 8 <0x0a>; diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index 257b3ba..a26d3bb 100644 --- a/drivers/video/backlight/lp855x_bl.c +++ b/drivers/video/backlight/lp855x_bl.c @@ -17,6 +17,7 @@ #include #include #include +#include /* LP8550/1/2/3/6 Registers */ #define LP855X_BRIGHTNESS_CTRL 0x00 @@ -383,6 +384,13 @@ static int lp855x_parse_dt(struct lp855x *lp) pdata->rom_data = &rom[0]; } + pdata->supply = devm_regulator_get(dev, "power"); + if (IS_ERR(pdata->supply)) { + if (PTR_ERR(pdata->supply) == -EPROBE_DEFER) + return -EPROBE_DEFER; + pdata->supply = NULL; + } + lp->pdata = pdata; return 0; @@ -423,6 +431,14 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) else lp->mode = REGISTER_BASED; + if (lp->pdata->supply) { + ret = regulator_enable(lp->pdata->supply); + if (ret < 0) { + dev_err(&cl->dev, "failed to enable supply: %d\n", ret); + return ret; + } + } + i2c_set_clientdata(cl, lp); ret = lp855x_configure(lp); @@ -454,6 +470,8 @@ static int lp855x_remove(struct i2c_client *cl) lp->bl->props.brightness = 0; backlight_update_status(lp->bl); + if (lp->pdata->supply) + regulator_disable(lp->pdata->supply); sysfs_remove_group(&lp->dev->kobj, &lp855x_attr_group); return 0; diff --git a/include/linux/platform_data/lp855x.h b/include/linux/platform_data/lp855x.h index 1b2ba24..9c7fd1e 100644 --- a/include/linux/platform_data/lp855x.h +++ b/include/linux/platform_data/lp855x.h @@ -136,6 +136,7 @@ struct lp855x_rom_data { Only valid when mode is PWM_BASED. * @size_program : total size of lp855x_rom_data * @rom_data : list of new eeprom/eprom registers + * @supply : regulator that supplies 3V input */ struct lp855x_platform_data { const char *name; @@ -144,6 +145,7 @@ struct lp855x_platform_data { unsigned int period_ns; int size_program; struct lp855x_rom_data *rom_data; + struct regulator *supply; }; #endif