From patchwork Mon Sep 23 21:41:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 2930591 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2356F9F2B8 for ; Mon, 23 Sep 2013 21:49:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4601B2012D for ; Mon, 23 Sep 2013 21:49:01 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4CC392010A for ; Mon, 23 Sep 2013 21:49:00 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VOE01-0000H3-12; Mon, 23 Sep 2013 21:48:57 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VODzy-0003qe-JE; Mon, 23 Sep 2013 21:48:54 +0000 Received: from mail-bk0-x235.google.com ([2a00:1450:4008:c01::235]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VODzv-0003qH-C0 for linux-arm-kernel@lists.infradead.org; Mon, 23 Sep 2013 21:48:52 +0000 Received: by mail-bk0-f53.google.com with SMTP id d7so1390413bkh.40 for ; Mon, 23 Sep 2013 14:48:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qRyAxVikwZJoIE5hcv9nookc/bWaSpvh95xDh1C9gK4=; b=wng+az1ig158tRaj+YCzWPHyex3C38JR/FpzcUpZ4HTG7/rxu3eJGYlLMpchKJVUuW Fyfc+dF7kKcYqm3cUop8CvJN7+HA3pNIAhOPBzs+MmVSx+A5J5oEaTT24zJ79IHIrdvt rcl48PaIKK4Gn6kfhxwr5EquuqGt9jlVJI1t7tE0VcW6QCj25Wf8CeigaOrYyTAooyLS SjWADFh+ZFBBAsGcaUNCBAlyoyrwBSpYzFTdvp9uXEj7AJCr3Iy/r6Y3dkir7nR8Pm64 YcB6vsiV7fhQMc4xYjk+1Hl24HgPhGra0khyd94RRZCaMcAmQjBnLvFVTJCU/hcpoadY /KqA== X-Received: by 10.205.10.132 with SMTP id pa4mr19403673bkb.15.1379972568996; Mon, 23 Sep 2013 14:42:48 -0700 (PDT) Received: from localhost (port-13639.pppoe.wtnet.de. [84.46.53.124]) by mx.google.com with ESMTPSA id nv4sm9651399bkb.3.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 23 Sep 2013 14:42:48 -0700 (PDT) From: Thierry Reding To: Thierry Reding Subject: [PATCH 09/10] pwm-backlight: Use an optional power supply Date: Mon, 23 Sep 2013 23:41:06 +0200 Message-Id: <1379972467-11243-10-git-send-email-treding@nvidia.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1379972467-11243-1-git-send-email-treding@nvidia.com> References: <1379972467-11243-1-git-send-email-treding@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130923_174851_576166_1B13DC59 X-CRM114-Status: GOOD ( 15.75 ) X-Spam-Score: 1.4 (+) Cc: Mark Rutland , devicetree@vger.kernel.org, Kukjin Kim , Eric Miao , Pawel Moll , Ian Campbell , Tony Lindgren , Stephen Warren , Magnus Damm , linux-kernel@vger.kernel.org, Rob Herring , linux-samsung-soc@vger.kernel.org, linux-omap@vger.kernel.org, Simon Horman , linux-pwm@vger.kernel.org, Haojian Zhuang , Ben Dooks , linux-sh@vger.kernel.org, openezx-devel@lists.openezx.org, Guan Xuetao , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 Many backlights require a power supply to work properly. This commit uses a power-supply regulator, if available, to power up and power down the panel. Signed-off-by: Thierry Reding --- .../bindings/video/backlight/pwm-backlight.txt | 2 ++ drivers/video/backlight/pwm_bl.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt b/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt index 052eb03..3898f26 100644 --- a/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +++ b/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt @@ -15,6 +15,7 @@ Optional properties: - pwm-names: a list of names for the PWM devices specified in the "pwms" property (see PWM binding[0]) - enable-gpios: a list of GPIOs to enable and disable the backlight + - power-supply: regulator for supply voltage [0]: Documentation/devicetree/bindings/pwm/pwm.txt @@ -28,4 +29,5 @@ Example: default-brightness-level = <6>; enable-gpios = <&gpio 58 0>; + power-supply = <&vdd_bl_reg>; }; diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 506810c..a2b3876 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -21,6 +21,7 @@ #include #include #include +#include #include struct pwm_bl_data { @@ -29,6 +30,7 @@ struct pwm_bl_data { unsigned int period; unsigned int lth_brightness; unsigned int *levels; + struct regulator *power_supply; int enable_gpio; unsigned long enable_gpio_flags; int (*notify)(struct device *, @@ -56,6 +58,12 @@ static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness, pwm_config(pb->pwm, duty_cycle, pb->period); + if (pb->power_supply) { + err = regulator_enable(pb->power_supply); + if (err < 0) + dev_err(pb->dev, "failed to enable power supply\n"); + } + if (gpio_is_valid(pb->enable_gpio)) { if (pb->enable_gpio_flags & PWM_BACKLIGHT_GPIO_ACTIVE_LOW) gpio_set_value(pb->enable_gpio, 0); @@ -76,6 +84,9 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb) else gpio_set_value(pb->enable_gpio, 0); } + + if (pb->power_supply) + regulator_disable(pb->power_supply); } static int pwm_backlight_update_status(struct backlight_device *bl) @@ -253,6 +264,16 @@ static int pwm_backlight_probe(struct platform_device *pdev) } } + pb->power_supply = devm_regulator_get_optional(&pdev->dev, "power"); + if (IS_ERR(pb->power_supply)) { + if (PTR_ERR(pb->power_supply) != -ENODEV) { + ret = PTR_ERR(pb->power_supply); + goto err_gpio; + } + + pb->power_supply = NULL; + } + pb->pwm = devm_pwm_get(&pdev->dev, NULL); if (IS_ERR(pb->pwm)) { dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n");