Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5543692ybe; Tue, 10 Sep 2019 05:31:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfe9cMZvybWFmP0nrz6MicWl0tsWfTs4Qob/iHUrM/3z7KAj/e4ElSzK6PiAPPeEfh9j87 X-Received: by 2002:a17:906:52d7:: with SMTP id w23mr24277452ejn.228.1568118680585; Tue, 10 Sep 2019 05:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568118680; cv=none; d=google.com; s=arc-20160816; b=Y0pIaW407PhkbxJKwTOST8YzaZgzSxfI3QScXzAR/UiV6kCZeRQd2jG0NxkB9x3GK4 1xrEONKQt32euBFy5vv5Y6jnqtDbWtLh+nzm8cYQWJExyJ5BkvGgIGceQxbA4Yrv1Ohw 0quReW7DYZDx6OilOwwebMr54cOnit8fQY8ATlUZBBFjutZYlTeSTK+0Q1O4HlZ/mb0h ef+KHFHSuk+K6AcHtTGhBNu9xk7RWOafZLRK/9IsOPJYpoIxQUfEQihBhYneCeLIkzH4 NT4ptJXuVKyUDPg6A5ToZZdFrGNjLbWI8LFbSJJzPX7saPmrKfRyxJvFCiSFX25ZypZM cgoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Wpr2coDySs9Rh34jajBcihEANouoWM4tiMrDCeWl8sg=; b=f/kZSJEvILDebJ0QnI9zUR8Z1Kib6FVdcfWZ4yEf4V/LzKJr4pEmuj6ooYVAabCx4S vZSqM3cPYdgzLRfaG8FMU2+RZDzbvvvB9KfpX3MuxUVlz8vj4+bRAiN+cc2lrMNzVVCJ rXASxxtsds54bJfirg9MceJILU4xoAcqAN01jOiHg7r+UmXQRTo0IKZhtmMSZU86oERF yQbWUgf1lOf4Zryh6euSbyKK5kHGAO1JkemiWsmuR1Gw3PoQwxyM48h3RNutG8atqL0D ozoBK9D3YBBLhX3LzZ0KCWd2Tz9rfyAKPB5fKh0Wyimu+j0Fc/fnK6t6+U0FcdWTQy/9 W5JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OWD1IplS; 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 y8si5679804edu.344.2019.09.10.05.30.55; Tue, 10 Sep 2019 05:31:20 -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=OWD1IplS; 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 S2388927AbfIJKWC (ORCPT + 99 others); Tue, 10 Sep 2019 06:22:02 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:37687 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729206AbfIJKWC (ORCPT ); Tue, 10 Sep 2019 06:22:02 -0400 Received: by mail-wr1-f67.google.com with SMTP id i1so18435012wro.4 for ; Tue, 10 Sep 2019 03:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Wpr2coDySs9Rh34jajBcihEANouoWM4tiMrDCeWl8sg=; b=OWD1IplSbH+Uj6fRnvAWQMTtgsLhiEt+qYbKjXaLSulXC/QfZK1S8iBbPUxjl80LQs Sxa/NOEYbyoMdACAwtywuw45EkqtZ4cwdzmxnQTw9JieI26ywI5teAX/795GB6Jtqmp9 SK1E4X5R8xry3MoVaEDSWL3tNsjqoxoGYqC+m1t6M9u5PG5TtnU76MQiPPj/ch8FZCVh VNAkXR11i4Q+SFgNCBjUbiUoEY9M8+hM44rio0gVfl4Q1Eof5sap2IoUobfy8txXXqGa SdF6Z2HV1FVkF11y1n4OqbppwEtKiDW3lebmGQ+6jAoCKHsYYEQQTXBbwSvCj25uPmQ+ BMfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Wpr2coDySs9Rh34jajBcihEANouoWM4tiMrDCeWl8sg=; b=LeabYc9QAR/+k0qhFXj+QE+05FQ9YdhGCBxBoS1o9eUmlq7c0kxHZGZAdxnxzj7wFd +xyO4XBXpEO9l2LUtAYxlscGrGuziiz3q51gUH+POzBXl5FAf0R2g1saVHRO5Ev6y83m CsidWecTDfQBGsOzkeV67H+CpkPZfNTkxiMlgKjF1CiKCE5H72FhqbIkvRG+FkaiJllx vNA0E2HOVhgJjSdtGn9brgZQLBlFKf0LFe62PvhfxUV6DjJEX7yGz4biGNzZ74h/e71g tN2Oic5Wb3FmXLmMi9Q38PxbGLYlzpwIeiOm/ZKkS1TJ2JToKRYRFdI5przdJ3gbW6vr umNg== X-Gm-Message-State: APjAAAUGo7l/I+nw7xyxvG+zXbwWdTHeMubm1CWkSmZz48CKvrOOGyOv AC4oQxKhwUEWtIfxHtDp4a8KWw== X-Received: by 2002:adf:f04f:: with SMTP id t15mr13262934wro.250.1568110919018; Tue, 10 Sep 2019 03:21:59 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id o19sm23744301wro.50.2019.09.10.03.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2019 03:21:58 -0700 (PDT) Date: Tue, 10 Sep 2019 11:21:56 +0100 From: Daniel Thompson To: Andreas Kemnade Cc: lee.jones@linaro.org, jingoohan1@gmail.com, jacek.anaszewski@gmail.com, pavel@ucw.cz, dmurphy@ti.com, robh+dt@kernel.org, mark.rutland@arm.com, b.zolnierkie@samsung.com, dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, "H. Nikolaus Schaller" Subject: Re: [PATCH 1/2] backlight: lm3630a: add an enable gpio for the HWEN pin Message-ID: <20190910102156.vmprsjebmlphkv34@holly.lan> References: <20190908203704.30147-1-andreas@kemnade.info> <20190908203704.30147-2-andreas@kemnade.info> <20190909105729.w5552rtop7rhghy2@holly.lan> <20190909221349.46ca5a1f@aktux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190909221349.46ca5a1f@aktux> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 09, 2019 at 10:13:49PM +0200, Andreas Kemnade wrote: > On Mon, 9 Sep 2019 11:57:29 +0100 > Daniel Thompson wrote: > > > On Sun, Sep 08, 2019 at 10:37:03PM +0200, Andreas Kemnade wrote: > > > For now just enable it in the probe function to allow i2c > > > access and disable it on remove. Disabling also means resetting > > > the register values to default. > > > > > > Tested on Kobo Clara HD. > > > > > > Signed-off-by: Andreas Kemnade > > > --- > > > drivers/video/backlight/lm3630a_bl.c | 18 ++++++++++++++++++ > > > 1 file changed, 18 insertions(+) > > > > > > diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c > > > index b04b35d007a2..3b45a1733198 100644 > > > --- a/drivers/video/backlight/lm3630a_bl.c > > > +++ b/drivers/video/backlight/lm3630a_bl.c > > > @@ -12,6 +12,8 @@ > > > #include > > > #include > > > #include > > > +#include > > > +#include > > > #include > > > #include > > > > > > @@ -48,6 +50,7 @@ struct lm3630a_chip { > > > struct lm3630a_platform_data *pdata; > > > struct backlight_device *bleda; > > > struct backlight_device *bledb; > > > + struct gpio_desc *enable_gpio; > > > struct regmap *regmap; > > > struct pwm_device *pwmd; > > > }; > > > @@ -506,6 +509,14 @@ static int lm3630a_probe(struct i2c_client *client, > > > return -ENOMEM; > > > pchip->dev = &client->dev; > > > > > > + pchip->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable", > > > + GPIOD_ASIS); > > > > Initializing GPIOD_ASIS doesn't look right to me. > > > > If you initialize ASIS then the driver must configure the pin as an > > output... far easier just to set GPIOD_OUT_HIGH during the get. > > > > Note also that the call to this function should also be moved *below* > > the calls parse the DT. > > > oops, must have forgotten that, and had good luck here. > > > > > + if (IS_ERR(pchip->enable_gpio)) { > > > + rval = PTR_ERR(pchip->enable_gpio); > > > + return rval; > > > + } > > > + > > > + > > > pchip->regmap = devm_regmap_init_i2c(client, &lm3630a_regmap); > > > if (IS_ERR(pchip->regmap)) { > > > rval = PTR_ERR(pchip->regmap); > > > @@ -535,6 +546,10 @@ static int lm3630a_probe(struct i2c_client *client, > > > } > > > pchip->pdata = pdata; > > > > > > + if (pchip->enable_gpio) { > > > + gpiod_set_value_cansleep(pchip->enable_gpio, 1); > > > > Not needed, use GPIOD_OUT_HIGH instead. > > > > > > > + usleep_range(1000, 2000); > > > > Not needed, this sleep is already part of lm3630a_chip_init(). > > > you are right. > > > > > + } > > > /* chip initialize */ > > > rval = lm3630a_chip_init(pchip); > > > if (rval < 0) { > > > @@ -586,6 +601,9 @@ static int lm3630a_remove(struct i2c_client *client) > > > if (rval < 0) > > > dev_err(pchip->dev, "i2c failed to access register\n"); > > > > > > + if (pchip->enable_gpio) > > > + gpiod_set_value_cansleep(pchip->enable_gpio, 0); > > > + > > > > Is this needed? > > > > This is a remove path, not a power management path, and we have no idea > > what the original status of the pin was anyway? > > > > Looking at Ishdn on page 5 of the datasheet, switching it off everytime > possible seems not needed. We would need to call chip_init() everytime > we enable the gpio or live with default values. > Therefore I did decide to not put it into any power management path. > But switching it on and not switching it off feels so unbalanced. Either the power consumed by the controller when strings aren't lit up matters, in which case the driver should implement proper power management or it doesn't matter and changing the pin state isn't needed. I'm happy with either of the above but this looks like a third way, where eager users could hack in a bit of extra power management by forcing drivers to unbind. Daniel.