Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1041277imm; Wed, 22 Aug 2018 17:58:31 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbZUFepiDOCmJfQS+mK2GES8C+2jOps1Do93oFG6H0Q7XvKwDVwcsSTFczzxwnjYVvaxrvn X-Received: by 2002:a63:990a:: with SMTP id d10-v6mr6053561pge.80.1534985911905; Wed, 22 Aug 2018 17:58:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534985911; cv=none; d=google.com; s=arc-20160816; b=rdUD8rQrOiPdwuhOfkYtY5Au6WMYLgU3DLK0pqGncArVlF8hHxkJkdUA1zWMM2S0D3 tyHuZJLqQMz1l2ORCIjC2/STUnvRs7LsR/9nGEX1s4mET1BOf9mcGEjZBqUKS4aBXPW3 xcnru7tFI0stnesWcGAU+4XB3W5CsCcS3BFxTJFILzpCVuHBtFqKofH+PXRBs0ox31RL 4Nsku5HZwm3PiBrIRUXP3nFtMF1aWB/wjgPdcznqv/BADKUOZe6aiIHHde3z6vdRovm8 MwaBtZnl8USZemfWU0g4FMDeXZWIGS9b8/0il6SBbnsZdXN41DCybJraxb08A8PLcuNg Gbqg== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=0pKP9zggLNjppmnzNPB77dk5Ydk2Nvf2pdWUSPmuYqA=; b=e52NRGe/XAAzwFYOtY6YHLlVHpQAg31MkfAuh2SvdCYzD1m3daoAedJ24fijK7DEPx 06BE+RLwIiFj0VM07nCBA1zfE5IIPsgR1Op463aD1raX2KSETi87VHCLH9Hf/aCCjzp+ wIoCQ/AbnxCQPhSNzdy6+c+hNLAJH7iQbfLCklrWEFSdssVdh7pP/t7vqnnwaKxChEKp SnRDdOWYbVjJ8BBS8BBjGKYheKGE9lzsv/4pHWKLm4/gYfwrABSgbGzpdojJtqT6W7qx AaE85aXnxbYrTnZNxU3wjY5UTQE7V3G0mR2mRrDsrmO6d9hH4hmNf63fnIJDYZr/5gqT uTXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="JdUzr/9k"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j32-v6si2964467pgb.454.2018.08.22.17.58.16; Wed, 22 Aug 2018 17:58:31 -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=@gmail.com header.s=20161025 header.b="JdUzr/9k"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726402AbeHWEP5 (ORCPT + 99 others); Thu, 23 Aug 2018 00:15:57 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34938 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725909AbeHWEP5 (ORCPT ); Thu, 23 Aug 2018 00:15:57 -0400 Received: by mail-pg1-f196.google.com with SMTP id z4-v6so1700702pgv.2; Wed, 22 Aug 2018 17:48:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=0pKP9zggLNjppmnzNPB77dk5Ydk2Nvf2pdWUSPmuYqA=; b=JdUzr/9k/8yM5UOPfXygVqkLNQSLQv5zTFI2tP2iUjL4KbQ5KFL+f2e64krodB6Irm +jTQQNMppO/qANvbddg4oOZcbWCM7oBhWvRW61dr77zCHPllox3NX8cE3XScv47C4edB HGzdmzqlkwAtQYXn1PZuCgqD+mfd6Ez1ynLiG/Mhp/HcI2u62oly/oq6JhpAB89PVR86 Hvo2XpkbiTdb1OSJw1Zoh6goS/aOAP8LHwzq96WbNw1wFnzUSuNiTvtB25N75JVCc80S 54mCiVfVp1erMPbOg0v/H8ljdZa9OewNeUxt7LbkaAv1uLsUOb51OHXZJGZHS1mjCLb8 +zzA== 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:content-transfer-encoding :in-reply-to:user-agent; bh=0pKP9zggLNjppmnzNPB77dk5Ydk2Nvf2pdWUSPmuYqA=; b=H6S4pmwhvE/T8NBjeK2ZmiOI4tHSJO1mZDV7Vkq+kj8z1PB3TcNZ8opAemFt+lvDT+ ArIdQhJJTb3/eC8J3sYGpQ33IGhGtj+0mSiAVxk5/1uYnMrObybLgYMQqu0LamKtwWWG jGw1uk+ew+4h800Dx7GyrUDRmzDyWd6pOgLMfNYDvbOyuyjkdIYQD/moyjn/NsmpgEMw 7A/5yZ0dcdMT8Yy5kYFRy04Xmt63BSrl00Fe7JyasVjaL4fEzTJ0/sNgVbu1L1swCDmJ nHu4qFpsSdOE6wjE/PvbrazhIYMQIf3yaWEuMNE8nOjs+0d0tD00pBBnMaMJtBh7J11X bGtQ== X-Gm-Message-State: APzg51B01kcAqAaRJSYvdHA+eeoCARLqVM0CEwESXE4rWidt+UuWUR5V upwE10ooclYfeksZfAcCCTw= X-Received: by 2002:a63:cf4a:: with SMTP id b10-v6mr3738078pgj.235.1534985332030; Wed, 22 Aug 2018 17:48:52 -0700 (PDT) Received: from dtor-ws ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id k1-v6sm3502958pfi.62.2018.08.22.17.48.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 Aug 2018 17:48:50 -0700 (PDT) Date: Wed, 22 Aug 2018 17:48:48 -0700 From: Dmitry Torokhov To: =?iso-8859-1?Q?Myl=E8ne?= Josserand Cc: robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org, linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, thomas.petazzoni@bootlin.com, Lothar =?iso-8859-1?Q?Wa=DFmann?= , Simon Budig , Franklin S Cooper Jr Subject: Re: [PATCH v4 1/3] Input: edt-ft5x06 - Add support for regulator Message-ID: <20180823004848.GA200828@dtor-ws> References: <20180725073410.730-1-mylene.josserand@bootlin.com> <20180725073410.730-2-mylene.josserand@bootlin.com> <20180726004732.GD80336@dtor-ws> <20180807085944.337bf20b@dell-desktop.home> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180807085944.337bf20b@dell-desktop.home> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 07, 2018 at 08:59:44AM +0200, Myl?ne Josserand wrote: > Hello Dmitry, > > Thank you again for the review. > > On Wed, 25 Jul 2018 17:47:32 -0700 > Dmitry Torokhov wrote: > > > Hi Myl?ne, > > > > On Wed, Jul 25, 2018 at 09:34:08AM +0200, Myl?ne Josserand wrote: > > > Add the support of regulator to use it as VCC source. > > > > > > Signed-off-by: Myl?ne Josserand > > > Reviewed-by: Rob Herring > > > --- > > > .../bindings/input/touchscreen/edt-ft5x06.txt | 1 + > > > drivers/input/touchscreen/edt-ft5x06.c | 43 ++++++++++++++++++++++ > > > 2 files changed, 44 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..dcde719094f7 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; > > > @@ -963,6 +965,13 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata) > > > } > > > } > > > > > > +static void edt_ft5x06_disable_regulator(void *arg) > > > +{ > > > + struct edt_ft5x06_ts_data *data = arg; > > > + > > > + regulator_disable(data->vcc); > > > +} > > > + > > > static int edt_ft5x06_ts_probe(struct i2c_client *client, > > > const struct i2c_device_id *id) > > > { > > > @@ -991,6 +1000,28 @@ 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; > > > + } > > > > It is better to put the chip into reset and then power up the regulatori > > and take it out of the reset, rather than power up and then toggle reset > > on and off. > > okay, thanks, I will update it. > > > > > > + > > > + error = devm_add_action_or_reset(&client->dev, > > > + edt_ft5x06_disable_regulator, > > > + tsdata); > > > + if (error) > > > + return error; > > > + > > > tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, > > > "reset", GPIOD_OUT_HIGH); > > > if (IS_ERR(tsdata->reset_gpio)) { > > > @@ -1120,9 +1151,12 @@ 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); > > > + else > > > + regulator_disable(tsdata->vcc); > > > > > > return 0; > > > } > > > @@ -1130,9 +1164,18 @@ static int __maybe_unused edt_ft5x06_ts_suspend(struct device *dev) > > > static int __maybe_unused edt_ft5x06_ts_resume(struct device *dev) > > > { > > > struct i2c_client *client = to_i2c_client(dev); > > > + struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); > > > + int ret; > > > > > > if (device_may_wakeup(dev)) > > > disable_irq_wake(client->irq); > > > + else { > > > + ret = regulator_enable(tsdata->vcc); > > > + if (ret < 0) { > > > + dev_err(dev, "failed to enable vcc: %d\n", ret); > > > + return ret; > > > + } > > > + } > > > > I believe I mentioned in other review that once you powered up the > > device, you need to restore its settings, include switching to factory > > mode, if it was in factory mode, and restoring threshold/gain/offset > > settings. > > Yes, I will update the driver with that but as I told you in a previous > mail, I can't test the suspend/resume :( I wonder if Simon or Lothar or Franklin could help us with it (CCed). If not, then we'll have to go by review only. Thanks. -- Dmitry