From patchwork Thu Jul 31 11:42:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 4655371 Return-Path: X-Original-To: patchwork-linux-arm@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 3744CC0338 for ; Thu, 31 Jul 2014 11:45:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 46E3E2011B for ; Thu, 31 Jul 2014 11:45:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4B29F200D9 for ; Thu, 31 Jul 2014 11:45:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XColU-0003TQ-KH; Thu, 31 Jul 2014 11:43:20 +0000 Received: from mail-we0-x231.google.com ([2a00:1450:400c:c03::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XColQ-00039z-V9 for linux-arm-kernel@lists.infradead.org; Thu, 31 Jul 2014 11:43:17 +0000 Received: by mail-we0-f177.google.com with SMTP id w62so2617587wes.8 for ; Thu, 31 Jul 2014 04:42:54 -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; bh=smUXJlxEqDsseW5cQjH21AzeydBoEzf36M7MyXL3Bbs=; b=JVMMqY7JJzBjqXdcpdnwqL0r5mr2RJpIiB6rnLpzIprPNgJhQu9H1Uq6O8UQcaEJcJ vtm+IT59umdPzxHTGK7cj71VZAgFAa58fj7WSryl4+D0CjpjZ4vyBE3guKDemLMFF3VZ glmxcYa2T6D+OMNuDvEkiH2bzQ68gAt9fhkzFsGZUviWy+P+V9pYaaBMi9RlA/RH9D6/ 8KdDz9rhQi3idIqTlaTnLRgjIcteP2v6QhDlCNf+MFsKdyIZuBYcxuV5FupB1KBkoKC6 PtLh+LCVy4b6JXJ7lP5JqnQ45NGjYEF+rGpQQtR4NzphFTTPhGAkmLCF6FfsrMJ0m77G s7fQ== X-Received: by 10.194.191.131 with SMTP id gy3mr16371297wjc.108.1406806974162; Thu, 31 Jul 2014 04:42:54 -0700 (PDT) Received: from localhost (port-1968.pppoe.wtnet.de. [84.46.7.183]) by mx.google.com with ESMTPSA id u10sm19754267wix.14.2014.07.31.04.42.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jul 2014 04:42:53 -0700 (PDT) From: Thierry Reding To: Jingoo Han , Bryan Wu , Lee Jones Subject: [RFC] pwm-backlight: Allow backlight to remain disabled on boot Date: Thu, 31 Jul 2014 13:42:50 +0200 Message-Id: <1406806970-12561-1-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 2.0.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140731_044317_304558_06B69B67 X-CRM114-Status: GOOD ( 22.84 ) X-Spam-Score: -0.8 (/) Cc: Mark Rutland , devicetree@vger.kernel.org, linux-fbdev@vger.kernel.org, Russell King , Pawel Moll , Ian Campbell , Tomi Valkeinen , linux-kernel@vger.kernel.org, Rob Herring , Thierry Reding , Kumar Gala , Eric Miao , Jean-Christophe Plagniol-Villard , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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=-2.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 From: Thierry Reding The default for backlight devices is to be enabled immediately when registering with the backlight core. This can be useful for setups that use a simple framebuffer device and where the backlight cannot otherwise be hooked up to the panel. However, when dealing with more complex setups, such as those of recent ARM SoCs, this can be problematic. Since the backlight is usually setup separately from the display controller, the probe order is not usually deterministic. That can lead to situations where the backlight will be powered up and the panel will show an uninitialized framebuffer. Furthermore, subsystems such as DRM have advanced functionality to set the power mode of a panel. In order to allow such setups to power up the panel at exactly the right moment, a way is needed to prevent the backlight core from powering the backlight up automatically when it is registered. This commit introduces a new boot_off field in the platform data (and also implements getting the same information from device tree). When set the initial backlight power mode will be set to "off". Signed-off-by: Thierry Reding --- I've been meaning to send this for a while but was always holding back because of the indoctrination that this type of configuration shouldn't be part of device tree. However this issue was recently raised again in the context of power up sequences for display panels. As described above the issue is that panel datasheets recommend that the backlight attached to a panel be turned on at the very last step to avoid visual glitches during the panel's power up sequence. With the current implementation it is typical for the backlight to be probed before the display panel. That has, in many cases, the side-effect of enabling the backlight, therefore making the screen content visible before it's actually initialized. Some panels come up with random garbage when uninitialized, others show all white. With some luck the panel will be all black and users won't really notice. This patch is an attempt to enable boards to override the default of turning on the backlight for the pwm-backlight driver. I'm not sure if there was a specific reason to turn on the backlight by default when this driver was initially written, but the fact is that since it has pretty much always been like this we can't really go and change the default, otherwise a lot of people may end up with no backlight and no clue as to how to enable it. So the only reasonable thing we can do is to keep the old behaviour and give new boards a way to override it if they know that some other part of the stack will enable it at the right moment. .../devicetree/bindings/video/backlight/pwm-backlight.txt | 1 + drivers/video/backlight/pwm_bl.c | 8 ++++++++ include/linux/pwm_backlight.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt b/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt index 764db86d441a..65e001a1733d 100644 --- a/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +++ b/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt @@ -17,6 +17,7 @@ Optional properties: "pwms" property (see PWM binding[0]) - enable-gpios: contains a single GPIO specifier for the GPIO which enables and disables the backlight (see GPIO binding[1]) + - backlight-boot-off: keep the backlight disabled on boot [0]: Documentation/devicetree/bindings/pwm/pwm.txt [1]: Documentation/devicetree/bindings/gpio/gpio.txt diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index d7a3d13e72ec..62adfc9d37a7 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -173,6 +173,8 @@ static int pwm_backlight_parse_dt(struct device *dev, data->max_brightness--; } + data->boot_off = of_property_read_bool(node, "backlight-boot-off"); + return 0; } @@ -317,6 +319,12 @@ static int pwm_backlight_probe(struct platform_device *pdev) } bl->props.brightness = data->dft_brightness; + + if (data->boot_off) + bl->props.power = FB_BLANK_POWERDOWN; + else + bl->props.power = FB_BLANK_UNBLANK; + backlight_update_status(bl); platform_set_drvdata(pdev, bl); diff --git a/include/linux/pwm_backlight.h b/include/linux/pwm_backlight.h index efdd9227a49c..1fc14989da4a 100644 --- a/include/linux/pwm_backlight.h +++ b/include/linux/pwm_backlight.h @@ -15,6 +15,8 @@ struct platform_pwm_backlight_data { unsigned int *levels; /* TODO remove once all users are switched to gpiod_* API */ int enable_gpio; + bool boot_off; + int (*init)(struct device *dev); int (*notify)(struct device *dev, int brightness); void (*notify_after)(struct device *dev, int brightness);