Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6990903imm; Tue, 24 Jul 2018 06:42:38 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfFFyFRMQbf2GCNJTJbXnzYseEm6gqbD87o2XWNyHMRkZVEIXBQEICTaXWyG8qPZrLVGhJW X-Received: by 2002:a17:902:48c8:: with SMTP id u8-v6mr17210282plh.152.1532439758824; Tue, 24 Jul 2018 06:42:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532439758; cv=none; d=google.com; s=arc-20160816; b=o/YlgHXJwXwQtMlt76yDT90Jgu1R5F3G+A8gF6Rq0DEXMHwjX7yXv5HuG/BuLO8mG1 +Jn1OgoLJHz6kBZK9YIEgHisoA8pHDo7vFX6gCjTipqmbL3Igs9ZJLQ77rMOHG9gRJxY cGM4xFKp3VW2Z+qe6XVaftysa6MM9xTvgAp3rJofoV9wVtmTKJ5HQ9o7fJawPvndEAKS kXox3fW5JGHS8dn1rodj2T5JkLuJIG9GQEnuJyPMFDjRO8C8CEkoBHTR5Nu5Tu8volCb fPP2mSPUy6DBmT23o7+zjTNo1pfyXKmjQ54+tJ7/bPeEfwwZGcioLyRIxEgDeHgUDQ1h 1Dhg== 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:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=C+IFXMMnqAAvycXPEwu9kBOEKSIZ5ui94zk8sHu5PZU=; b=D/ms6czIDMufpi8pKu1smszmAn83HH3cxmeY2eeYsZPtXIKvzFxCvI/O17xq+9x3Gn RS89OQmf8y+VinJNbkjg7vFJBrx1KJuH4katsTukRPXwDS7CtqeHez2vp5Cj5Uy1VhrG TrCTXxrU/Za2wS/k/1Q2t0C8ZFegl4E9c974vHuI8N1CS8R8PR7QUEhfH10EWktVhIj6 oYbm4xe5ORig7GhXkR5tWA8JaxvoSD2w90VdQ7MkvlujNmzDnTO7ejb5eNB/DbxITC/R Dna8GR5O0aO3OMl6aMI9ODJJWUc1iyW88M3E4O91S880cdMaZgE5IOQY4io14Yxmcq3e aoPA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s16-v6si11560996pgg.538.2018.07.24.06.42.24; Tue, 24 Jul 2018 06:42:38 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388470AbeGXOrW convert rfc822-to-8bit (ORCPT + 99 others); Tue, 24 Jul 2018 10:47:22 -0400 Received: from mail.bootlin.com ([62.4.15.54]:33693 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388338AbeGXOrW (ORCPT ); Tue, 24 Jul 2018 10:47:22 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 4A14A2073D; Tue, 24 Jul 2018 15:40:47 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from dell-desktop.home (AAubervilliers-681-1-78-122.w90-88.abo.wanadoo.fr [90.88.20.122]) by mail.bootlin.com (Postfix) with ESMTPSA id E5388203D9; Tue, 24 Jul 2018 15:40:36 +0200 (CEST) Date: Tue, 24 Jul 2018 15:40:37 +0200 From: =?UTF-8?B?TXlsw6huZQ==?= Josserand To: Dmitry Torokhov Cc: robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 1/3] Input: edt-ft5x06 - Add support for regulator Message-ID: <20180724154037.25174c07@dell-desktop.home> In-Reply-To: <20180723223926.GL100814@dtor-ws> References: <20180718182719.29663-1-mylene.josserand@bootlin.com> <20180718182719.29663-2-mylene.josserand@bootlin.com> <20180718224645.ns7nvqxvqc6huxcz@core> <20180723223926.GL100814@dtor-ws> Organization: Bootlin X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Dmitry, Thank you for your review! On Mon, 23 Jul 2018 15:39:26 -0700 Dmitry Torokhov wrote: > On Thu, Jul 19, 2018 at 12:46:45AM +0200, Ondřej Jirman wrote: > > Hello Mylène, > > > > On Wed, Jul 18, 2018 at 08:27:17PM +0200, Mylène Josserand wrote: > > > Add the support of regulator to use it as VCC source. > > > > > > Signed-off-by: Mylène Josserand > > > --- > > > .../bindings/input/touchscreen/edt-ft5x06.txt | 1 + > > > drivers/input/touchscreen/edt-ft5x06.c | 29 ++++++++++++++++++++++ > > > 2 files changed, 30 insertions(+) > > > > > > diff --git a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt > > > index 025cf8c9324a..48e975b9c1aa 100644 > > > --- a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt > > > +++ b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt > > > @@ -30,6 +30,7 @@ Required properties: > > > Optional properties: > > > - reset-gpios: GPIO specification for the RESET input > > > - wake-gpios: GPIO specification for the WAKE input > > > + - vcc-supply: Regulator that supplies the touchscreen > > > > > > - pinctrl-names: should be "default" > > > - pinctrl-0: a phandle pointing to the pin settings for the > > > diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c > > > index 1e18ca0d1b4e..aa94494b06b5 100644 > > > --- a/drivers/input/touchscreen/edt-ft5x06.c > > > +++ b/drivers/input/touchscreen/edt-ft5x06.c > > > @@ -39,6 +39,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > > > > #define WORK_REGISTER_THRESHOLD 0x00 > > > #define WORK_REGISTER_REPORT_RATE 0x08 > > > @@ -91,6 +92,7 @@ struct edt_ft5x06_ts_data { > > > struct touchscreen_properties prop; > > > u16 num_x; > > > u16 num_y; > > > + struct regulator *vcc; > > > > > > struct gpio_desc *reset_gpio; > > > struct gpio_desc *wake_gpio; > > > @@ -991,6 +993,22 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, > > > > > > tsdata->max_support_points = chip_data->max_support_points; > > > > > > + tsdata->vcc = devm_regulator_get(&client->dev, "vcc"); > > > + if (IS_ERR(tsdata->vcc)) { > > > + error = PTR_ERR(tsdata->vcc); > > > + if (error != -EPROBE_DEFER) > > > + dev_err(&client->dev, "failed to request regulator: %d\n", > > > + error); > > > + return error; > > > + } > > > + > > > + error = regulator_enable(tsdata->vcc); > > > + if (error < 0) { > > > + dev_err(&client->dev, "failed to enable vcc: %d\n", > > > + error); > > > + return error; > > > + } > > > + > > > tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, > > > "reset", GPIOD_OUT_HIGH); > > > if (IS_ERR(tsdata->reset_gpio)) { > > You need to disable regulator here. We do not have > devm_regulator_enable() (and Mark had some concerns about mixing managed > and unmanaged APIs for regulators so we can't simply introduce it), > so I'd recommend using devm_add_action_or_reset() and iunstall custom > action to turn off regulator. Yep, I see. Thank you about "devm_add_action_or_reset", I did not know this function. I will add it in next version. > > > > @@ -1120,20 +1138,31 @@ static int edt_ft5x06_ts_remove(struct i2c_client *client) > > > static int __maybe_unused edt_ft5x06_ts_suspend(struct device *dev) > > > { > > > struct i2c_client *client = to_i2c_client(dev); > > > + struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); > > > > > > if (device_may_wakeup(dev)) > > > enable_irq_wake(client->irq); > > > > > > + regulator_disable(tsdata->vcc); > > > + > > > > How will the touchscreen wakeup the system with interrupt if you power it off > > on suspend? Perhaps guard this with device_may_wakeup() too? > > Exactly, it should be in an "else" branch. > > Thanks. > I see, I will add it in v4. Best regards, -- Mylène Josserand, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com