Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1395896imm; Wed, 25 Jul 2018 17:48:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdbUjfrmfT9D4cqM7bMVwwkEvroMsRfXH3CoZ5MOvyc1G9n0CpB3Sux14PwY/1loNRqtRMw X-Received: by 2002:a62:3a5b:: with SMTP id h88-v6mr24384660pfa.61.1532566129593; Wed, 25 Jul 2018 17:48:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532566129; cv=none; d=google.com; s=arc-20160816; b=jOLOsPtLsE6sCdYkwDFlXzMH7WUoBqDizdYqIGnGhRFYJz0xZcF+k8ZnDUNPrM76oi Pd7km4lmJmc+4khll2PbPfKGy4aFW5d/S3FmEaFtYS8NKDZTmFDOu9ba9F660pndAQrY b/GXCmbOCLxBIBOYnI1sK3hoXbo5wOVzArusKcOufT5ejp/Lsd8yRnFDeYTp0kLt70pp thUCkXbR1jwg9NqibpPkX0cVGZI+ckjgvs79Hb4nDd7DjBLnYi3SebHi7IDHF3w1OleM CLebJzy+H6Q1Hm6gyHueRIsaDgQmy4OpKj12bRLe+nRZZnhDcDzcwdePdSF6Zwtc4o8V MBpw== 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=7+Zh5Op/5HAZULzSjVbvKmGeJRf5fpRCHw7QAKZSvgc=; b=cw90x7DF0Sl/NTD8Qo5Y1qxFylzC+EilYKauf9Huvcgnqss8QQhXdTcyawuEvI1uV8 493W42xjrMQ8a3SC2YhxpgxnCLPKgpm8xOd0em5QSuIl7rkWNvrGiJgXxMFH6VWyl5HQ pVG0jxLshcbn7x7mztwsIMbdCI4+ySFFofq80mYFAsXaPAqBFXee0SAjppkfHEd3Oj65 d4KO/1KPuKp73rRNxR/XPtcEjBALuVDHof+UOtSnOqH+AeGwbHArfgrw044SpY/2DrmY Etclr//JNmAuYxyZm5chwwisbJ9N7IKHSxsgJYvX4Lrvxuz0B6p/J9btUU8JZTMJzqqv xoIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=I+Gv786I; 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 p65-v6si15788754pga.401.2018.07.25.17.48.35; Wed, 25 Jul 2018 17:48:49 -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=I+Gv786I; 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 S1728597AbeGZCBv (ORCPT + 99 others); Wed, 25 Jul 2018 22:01:51 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:38642 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728385AbeGZCBt (ORCPT ); Wed, 25 Jul 2018 22:01:49 -0400 Received: by mail-pg1-f196.google.com with SMTP id k3-v6so6374364pgq.5; Wed, 25 Jul 2018 17:47:36 -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=7+Zh5Op/5HAZULzSjVbvKmGeJRf5fpRCHw7QAKZSvgc=; b=I+Gv786IvV/ol3CfbVTx1WMqdjeZEe1gJRzBPjJSMk63nxit54D4Aebkxq4D7oLlTw PUefnu/MQiKZdkUX8grMWumCp0+2/PGzExWA8uegieppZF+apLI1OSpzqUBzZ72AuMxT un/wfCQ8FeBtuOc/1ju7MKJIM1m+XHLQwFPjuQUyoT/4mgx9G0ZMs3KcXt1laVCJDvKL /1WLpJeKHqP51WAAoomDeOzqi2N46HFoN6BQygKrtuHP7GMwvGvX3qisZi6JrrsWLFv0 hjJNB15kaFG+7l0rokNnGc1+5dLC5P/vWNAmUAzyR5bSVt89gNKD+DSzdKbDc4q/2E7a yHwg== 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=7+Zh5Op/5HAZULzSjVbvKmGeJRf5fpRCHw7QAKZSvgc=; b=h7VGAcC+FQRfJbXvcdCd3Qhh6mRmUEH+JX8d3ff0Lwni3sN5F+qewT2FKM+qpvWSlj EKIxPPcEDNndnVUdG4nlxHzKqZevmxjDI89Tyzk9zi0NiQw/zuzg2fhTIlG5txbEiut7 BpLh2xP2aFcBUjajc29AtuU9vpok5L6yL6ADP9lqF3cJ0q+j3NEuE2raKOOQ4B94uvzR U9/lKKPykkQUJbH/Ix/BCU/3m7HBlHhnXIZNsNnHzmIZwRNdMzJqH5AaFhIlDUYqYleM QMQYkFs4Kj8v2/UTv2qotrArzCLkItA64fnULkzdy80eXfk+jhFG+5+Btyz7CA2xy4/u VKbw== X-Gm-Message-State: AOUpUlGcesh98S4oWN7GB/oyGKWeGTYq6/nP13JZ2Ojqnek7QVRe9WJB ISdnnwgQ26OeoHtFmOxZChE= X-Received: by 2002:a62:2744:: with SMTP id n65-v6mr24407252pfn.125.1532566055419; Wed, 25 Jul 2018 17:47:35 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1511:8de6:27a8:ed13:2ef5]) by smtp.gmail.com with ESMTPSA id s14-v6sm22307945pfj.105.2018.07.25.17.47.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Jul 2018 17:47:34 -0700 (PDT) Date: Wed, 25 Jul 2018 17:47:32 -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 Subject: Re: [PATCH v4 1/3] Input: edt-ft5x06 - Add support for regulator Message-ID: <20180726004732.GD80336@dtor-ws> References: <20180725073410.730-1-mylene.josserand@bootlin.com> <20180725073410.730-2-mylene.josserand@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180725073410.730-2-mylene.josserand@bootlin.com> 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 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. > + > + 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. Thanks. -- Dmitry