Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp634985ybi; Fri, 21 Jun 2019 05:43:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLYNDCk8MVjldb1CKnxlA0UQpSh39roZ2qDxcAlGsrQdyNWrCZYn5TkPXaY8axk3xRH5JP X-Received: by 2002:a17:90a:a404:: with SMTP id y4mr6698839pjp.58.1561121016058; Fri, 21 Jun 2019 05:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561121016; cv=none; d=google.com; s=arc-20160816; b=XXv8yP0QVZ53N6U66ksISrRbqrnjCYMJ5qDlYjjyisfoWwUR35Qqi9Uw5+qGmpld+b 3QtbbS2r5OOhh97IdD7LpQ3KBEY0uAAHn4wejuGeBwWJ6Vc5f+JKtWw6C4Pof3K+gWUk 6Jj/mHWS7b8t/qloUxwOxU8Sdc/BpPua8nqGpn5N1nHRENRpf+vdT4NfCsbKdeHEXQNx etDgw4uBa+g2bfaN+JZMjVXlOoLx9rZL86orrU0LZ5e8ntj8EspGefqk4Xq4eDvNjbgf Hg5lHbOBaIo1ILWeyuWIslx1fp6XLWZeqoaalWcwBBqiX8VxJZlLSCWGiui2/Iu9SFKB t0oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=UyII8E/E3mshPHrIMsqTxjJtV2uC2oH9mjOQblUJ9/o=; b=bC/d1wNyk/CtvfZJSlwFmaZZyunvZIIpIuo94a/thJ/yIzRpyLa7XQYbMiagza8ewv id1I4MLa7wIinMmdp8E55Lz2M2AjhkZWAhlCTUCnU+BkWdi6DsWI+4HhathcdRQMwBi0 3X6EdZ8s3LCeVoUjy7BA4wlb8EfVThvuUbcvG5mjHxzxdDNW2YI0PYoKOIuLlNW4jjYN Ilt1DksBhDjX58fbAAo7djbVytEVx/weruTgTJkuf5VVmuTY45BtiG1+rpze90HHvoHi YLdJGfM1ffLBSKHQV53+toX7W4nweFjjRYRjGxA6Gfnc6YK3zjRBN/DsIJMAdTSJJTjZ ZfWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JrgRZGiB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o13si464806pll.69.2019.06.21.05.43.20; Fri, 21 Jun 2019 05:43:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JrgRZGiB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726878AbfFUMlu (ORCPT + 99 others); Fri, 21 Jun 2019 08:41:50 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44500 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726368AbfFUMlt (ORCPT ); Fri, 21 Jun 2019 08:41:49 -0400 Received: by mail-wr1-f68.google.com with SMTP id r16so6415047wrl.11 for ; Fri, 21 Jun 2019 05:41:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=UyII8E/E3mshPHrIMsqTxjJtV2uC2oH9mjOQblUJ9/o=; b=JrgRZGiBTmjujp1DAceFMwZAzGMDtr8E0Ek2p5PEfVsS473YGQb4eZz/hSfRCUa4PT PCL/0VmmsvC3bwMDGBcwLtoEV3CsVenV3I9cy9JAgXOfRedFJHPzAJH14pTHhhmRhJuH zSIgviNgNjnQ3q+QyY+x7yM/+irnqrLXG54A9xvJR793m0llXVeuC9hc/QtscAlcp2uC qjQ2GkqaHziMVeJ3Ci94+48IV1FaLhgc0tWBdIIHeAoHYeSifPU45Fuu/dX1MKphi8Jp jHCcbZrHc4m9hYCz01MRC6bnnKjkjoypabgBcEunqnOnVoFRUlq3mS6ZA+911H28wTVE WBAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=UyII8E/E3mshPHrIMsqTxjJtV2uC2oH9mjOQblUJ9/o=; b=JbwPzqTtiXPMy4jEa05N9C2nlJl/Zxo/D/WTUZ9ZDSzvwUHsoGqTBg9tVlJBihHEJ/ Ci5qnmGh3GAANv36scSgJ3bMhLSwM4T7dU1Z6opV3JCXDOQBnz8FyblBm97e9cWh4wSH lR3QV0ylCNC1qsqIN3ejn0QEZiAxZElITfQr8bBUFgU10ItSzUdXkgKTT2Pt614pm5bb XPFQjrCSO13/a1w+SsNg8L39CQOe5ROwz96bNyEvsNtEBuZPrC9076JmYJk3taqdxGIO CHn+/6U8p854JBJWrsBIKVEm1g7yNqQIt+iDgus1RQWSCPaMyEL+1JjrvHp0fOMfDRu8 X46w== X-Gm-Message-State: APjAAAU0dKF1E0skGpUkQivCkW85blQcwOTVTlv/FSKIEmJwDduOTSyU McTaZhQO2ri0t3npBfgGLfMAadI4rc6hkw== X-Received: by 2002:a5d:4708:: with SMTP id y8mr1982160wrq.85.1561120907035; Fri, 21 Jun 2019 05:41:47 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.googlemail.com with ESMTPSA id o20sm6964907wrh.8.2019.06.21.05.41.45 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Fri, 21 Jun 2019 05:41:46 -0700 (PDT) Subject: Re: [PATCH] backlight: pwm_bl: Set pin to sleep state when powered down To: Paul Cercueil , Thierry Reding , Lee Jones , Jingoo Han , Bartlomiej Zolnierkiewicz Cc: od@zcrc.me, linux-pwm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190522163428.7078-1-paul@crapouillou.net> From: Daniel Thompson Message-ID: <5b0f8bb3-e7b0-52c1-1f2f-9709992b76fc@linaro.org> Date: Fri, 21 Jun 2019 13:41:45 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190522163428.7078-1-paul@crapouillou.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/05/2019 17:34, Paul Cercueil wrote: > When the driver probes, the PWM pin is automatically configured to its > default state, which should be the "pwm" function. At which point in the probe... and by who? > However, at this > point we don't know the actual level of the pin, which may be active or > inactive. As a result, if the driver probes without enabling the > backlight, the PWM pin might be active, and the backlight would be > lit way before being officially enabled. > > To work around this, if the probe function doesn't enable the backlight, > the pin is set to its sleep state instead of the default one, until the > backlight is enabled. Whenk the backlight is disabled, the pin is reset > to its sleep state. Doesn't this workaround result in a backlight flash between whatever enables it and the new code turning it off again? > > Signed-off-by: Paul Cercueil > --- > drivers/video/backlight/pwm_bl.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c > index fb45f866b923..422f7903b382 100644 > --- a/drivers/video/backlight/pwm_bl.c > +++ b/drivers/video/backlight/pwm_bl.c > @@ -16,6 +16,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -50,6 +51,8 @@ static void pwm_backlight_power_on(struct pwm_bl_data *pb) > struct pwm_state state; > int err; > > + pinctrl_pm_select_default_state(pb->dev); > + > pwm_get_state(pb->pwm, &state); > if (pb->enabled) > return; > @@ -90,6 +93,8 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb) > > regulator_disable(pb->power_supply); > pb->enabled = false; > + > + pinctrl_pm_select_sleep_state(pb->dev); > } > > static int compute_duty_cycle(struct pwm_bl_data *pb, int brightness) > @@ -626,6 +631,10 @@ static int pwm_backlight_probe(struct platform_device *pdev) > backlight_update_status(bl); > > platform_set_drvdata(pdev, bl); > + > + if (bl->props.power == FB_BLANK_POWERDOWN) > + pinctrl_pm_select_sleep_state(&pdev->dev); Didn't backlight_update_status(bl) already do this? Daniel. > + > return 0; > > err_alloc: >