Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4848817ybe; Mon, 9 Sep 2019 15:57:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwEGkvLJY7lxL9UH5c3+THQSzCtwde1H7ZDcAKpUa+B9wBeS5HbKyESDJfV/GnXJgnPZj4b X-Received: by 2002:a50:fe17:: with SMTP id f23mr14780684edt.224.1568069850900; Mon, 09 Sep 2019 15:57:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568069850; cv=none; d=google.com; s=arc-20160816; b=TZRyaOCdv1qXqCRpGGVVdPQ4aT8rssvu0Q3orSU0dGBW4LrLC3ut6+hVySGcd0RbJH Ym9HVetq+dZfK8+NJkogczpfxQKbl4A0p2OoZN0QACw85d2r194UoM2zVwaQTLNLmVvH GEKWM2LeuPV02meYUadEskfYEE1hXh80STqx7xrm5Qkl1cE+9QnXepVeD+F0ftx183Z6 uproK8S2lzVrjYK8Ickaz33l4O77ihHtmh2akzCPrLrpCco396o4eNpwn4Wxw67kG5Fk HXnQAnxON3YS+Vif6X9wkAD5mjLSD50FjpJSuCeQ5MIljg66fGEFhqyfyEFIUQQ/Ig70 UNPw== 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=RlXHN5Ix30FP88bBs/TiJIVQtqEqdtYjO/ksq2NpWCg=; b=Ofs4bPdzpkgsUL+b1qXoeJk+fAU9TM4GUJYDmBX4R3FPjWvjxBf3PHNbiYeqWyrgwr ZezqrJK4XjEP3pbgubn1Bn4SyoQ/TlhkuyntRT2ek+uLICsztKv3cJi8QnKT1yumt5L3 2kbahIMgRocR1TaSceS/2rbwA0/MURGMWX8jW15A7+b/iuX7WjYCZbzioKW3gG70tKJ5 ZiUy2C1GurZDG3a3PAkgEaK7gubtUda0VWhnXxoSmi/fMDK49xyatroPqyUZXLsCU8pF KuYWk8QUKdt4qz99RhoxnLeCXsdu50YDI3HGEsscXg/YP1vY4EarC2VA0PfSETsYvOir W3nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="pgan3/KE"; 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 i56si9166156eda.19.2019.09.09.15.57.06; Mon, 09 Sep 2019 15:57:30 -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="pgan3/KE"; 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 S1732585AbfIIK5e (ORCPT + 99 others); Mon, 9 Sep 2019 06:57:34 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:51464 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbfIIK5e (ORCPT ); Mon, 9 Sep 2019 06:57:34 -0400 Received: by mail-wm1-f65.google.com with SMTP id 7so3619551wme.1 for ; Mon, 09 Sep 2019 03:57:32 -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=RlXHN5Ix30FP88bBs/TiJIVQtqEqdtYjO/ksq2NpWCg=; b=pgan3/KEQnhn7ZcaynKzZHra/KGSzMg74XSUwMiPg68U30ANdU3IbUc2+NTbH5uHuV 2f+BqabSS2vknJtIwazP57ZLuTWgbQg9OU9yur/ody+/dRsLSgpGkBcPuueJaAWrDWL5 p39Vc5SC2gbKjUVK5a+Z3NpB52GGp1LJ9XlZiKyj/E55rVt/qAGE9dteFfT7uV/ZwUpA hOGxj/qvf4pFkh/P++GQ30oH8rEmREpPutfQRAWmuHUBvpZuhfBuxlp1MPsjKhPjNKr7 5la4M5cNiLZ7+wGs6M1BalVnhrEywn9IvP0Wo13j3hmD7LUy0N+lBIZZ0lpMkS7xWHTz 69vQ== 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=RlXHN5Ix30FP88bBs/TiJIVQtqEqdtYjO/ksq2NpWCg=; b=DtCTSlwmw2L5D5y5zyTHQgKDkHinDcxi04xzDAMDsiLcoAfI8qlWRjrQOPFRNOKLt9 45TQIMwA8kDeqbL/TiCKKDPXB89AhKe4qp1j+/o4/phKKEMETyBUYT4wVq4z62z6LOLm Dmar4admuo5TNaq/YFnkgm/mi+ekECvCGdZopGwFyjgYDILtMoIStacCUcmPuI89Z/9L Wohr1/drgIsChT9IEDLpvprrjqAkIxdxkmow25i8kLiO5We7Q1VY7eiRqZW5qYu6IMwA dBXuQGqpMoNn66vKU7oy2BUFHvMtLEas+jtq2qFVJil0aOmkteyMaCODOXSlDhlDhqYt X5+w== X-Gm-Message-State: APjAAAV3w1+lZs0JqF1l0KE56kO3tIznB6GS+iuepbfZ4jyfL3h6qdHR bN7dgh7nyzCcqCGvSVbMY/AaRQ== X-Received: by 2002:a1c:cb83:: with SMTP id b125mr19176609wmg.43.1568026651947; Mon, 09 Sep 2019 03:57:31 -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 s12sm4418832wrn.90.2019.09.09.03.57.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 03:57:30 -0700 (PDT) Date: Mon, 9 Sep 2019 11:57:29 +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: <20190909105729.w5552rtop7rhghy2@holly.lan> References: <20190908203704.30147-1-andreas@kemnade.info> <20190908203704.30147-2-andreas@kemnade.info> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190908203704.30147-2-andreas@kemnade.info> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > + 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(). > + } > /* 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? > if (pchip->irq) { > free_irq(pchip->irq, pchip); > flush_workqueue(pchip->irqthread); > -- > 2.20.1 >