Received: by 10.223.176.46 with SMTP id f43csp4481746wra; Tue, 23 Jan 2018 09:59:38 -0800 (PST) X-Google-Smtp-Source: AH8x2252EyF6IL/bhSmPEdQUmPaQPG17775mbHvKjNzKwA0jG8L8aXTV4cXOjyk5sSje8QcEtXTB X-Received: by 10.36.54.203 with SMTP id l194mr4908972itl.144.1516730378176; Tue, 23 Jan 2018 09:59:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516730378; cv=none; d=google.com; s=arc-20160816; b=IT2oFAP2vVrLHG5uC3q0nQPxFoFEAqZhFDLTkyTBJDZ3/0BmpVFFszvpiXuvtNVNUH 7VZejAmivSBAzT8Txqs6ZgQAykQqeZMt+mJyF1B4tPTTZR0tKAynEyleAk/hhwJGYOR9 vgKjqbDxT7Qra/gVebTUXiyDCYRdoz4vxzCcQYWen3ktsgbjT+Pl/AmrY9PZ9G1EDxG1 ExFA/0rVAWzleI01nK2h886CVATakNczHDr5lCrDsAO9RDapo3asGWfoCuZFScF2XRAE YCPZ4wagnCMlPTi8Ww2Bl8H5xsDyEwYOqP3GpHDwqDmLYDk0NOSPc2gv41hri9zxGQw5 T9ZQ== 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=2oMm2NKw6xuplGgr4ykEubSk+NIFn7PHPoZxR7CHomM=; b=BbFUjs1OGct/KnVFjS3jxC8WgcC5lvd6wJZobazfDXrH1jB9GmqzuGScI/5AdCYHBI MTPbM5KHv65W6uAeNxdOTgcqhMUVKx0sKaGPMKbURnwwmRoSVTmSPhu1iGxB6TQOhKAb Wg18ucmTwOWCw5m+4efKRpm2fqbASd77OwY3lmTkOXWjDWkaH3HYf7UebpYJx0bEtShq wim+qh9ehHTjOMLvCsNaU+kVuqIYGJkbZ8BNkrWKNuyilWqCcxNve+xkNQwtADprkKXq 6FR6d4OpIoqguLlmbalS7oiN3DjF+IPxuWoGcUT/wgTEFCbYbMXdstwyEpthMXbKorRJ Yo5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jNXyWaDN; 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=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r197si2962364ior.186.2018.01.23.09.59.24; Tue, 23 Jan 2018 09:59:38 -0800 (PST) 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=jNXyWaDN; 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=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752128AbeAWR6g (ORCPT + 99 others); Tue, 23 Jan 2018 12:58:36 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:41497 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751633AbeAWR6e (ORCPT ); Tue, 23 Jan 2018 12:58:34 -0500 Received: by mail-io0-f193.google.com with SMTP id f4so1841926ioh.8; Tue, 23 Jan 2018 09:58:33 -0800 (PST) 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=2oMm2NKw6xuplGgr4ykEubSk+NIFn7PHPoZxR7CHomM=; b=jNXyWaDNhP49cfkYDR00g5jlmu+7bwvlPAiwBGMaaWekDfTysBchTv0IP20e56BtD/ KsZl+ymbk2Eo6szDrXq/rEmilwwjRK7gLz87Hhf0YePWQ3OgzB50ZQlL+IGsUiup3M8a wmOKE7lpAsY0QlFrw8Mn//HDrgDLkIpvbX2PbbloiRxhbD2hp4hRbx2HSscq/e0BKqTg VVVEHoWHFa3yDQKC2NMTr3cFp2G/2nX6/rzgB/c1KkPCgBGtbfFQT/gzgA4m8Ln7S3sn 9HCW6Sn3slsCXSqdtulUjOm5FRfxL+A0T5aqG4v8QeZxAd9MuBoqCw4jrA147oCOJr7B LYYQ== 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=2oMm2NKw6xuplGgr4ykEubSk+NIFn7PHPoZxR7CHomM=; b=Yz0FAdbnKk8Q+f9nKBsmvNaiqFU93TGUZIV24fh1+NfIVsPxNgU2xoQnYKntuBV7WO CI1NTzYhg67mj3KKepdh7evVPjOJDK+81VVn9ycZ8wtHR40cdW1WHqtilbD/JNxw7j7c vxiB75422Uo3goEchOCnxJSBqV5do+n2J3CRCIV4s/jByWDUnuuko3l07Hs15zBUgBsz f0gr64/krnkn1Z0V362cXTCrBv+ZR+SXiX/VNz5uz674PFf8pr60ORQ6KiEY/LAmitFg 7+Y/HuBx/pNYqzT8hhdxjBCkjtXooIl2jTwVuf/t1XN+vzEx8IclDCt1H8hyS0T6ekZx pP3A== X-Gm-Message-State: AKwxyteZ3wIRQeaP1Lh3EcILKuL1TaY2IMXZOqnvw6OK5CLrPvF7C4tS ov7uHl9zTdpFAaO2X5hA3CE= X-Received: by 10.107.101.24 with SMTP id z24mr4851311iob.55.1516730312679; Tue, 23 Jan 2018 09:58:32 -0800 (PST) Received: from dtor-ws ([2620:0:1000:1611:da80:8749:c06f:9515]) by smtp.gmail.com with ESMTPSA id y128sm5665561itb.43.2018.01.23.09.58.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jan 2018 09:58:32 -0800 (PST) Date: Tue, 23 Jan 2018 09:58:29 -0800 From: Dmitry Torokhov To: Mylene Josserand Cc: Rob Herring , Mark Rutland , Russell King - ARM Linux , Maxime Ripard , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org, "linux-input@vger.kernel.org" , devicetree@vger.kernel.org, lkml , Thomas Petazzoni , Quentin Schulz Subject: Re: [PATCH v2 1/2] Input: edt-ft5x06 - Add support for regulator Message-ID: <20180123175829.2axe3pdntrueqlnw@dtor-ws> References: <20171228163336.28131-1-mylene.josserand@free-electrons.com> <20171228163336.28131-2-mylene.josserand@free-electrons.com> <20180123101055.28c4786a@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: <20180123101055.28c4786a@dell-desktop.home> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 23, 2018 at 10:10:55AM +0100, Mylene Josserand wrote: > Hello Dimitry, > > Thank you for the review! > > Le Mon, 22 Jan 2018 09:42:08 -0800, > Dmitry Torokhov a ?crit : > > > Hi Myl?ne, > > > > On Thu, Dec 28, 2017 at 8:33 AM, 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 | 33 ++++++++++++++++++++++ > > > 2 files changed, 34 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 c53a3d7239e7..5ee14a25a382 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; > > > @@ -993,6 +995,23 @@ 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); > > > + dev_err(&client->dev, "failed to request regulator: %d\n", > > > + error); > > > + return error; > > > + }; > > > > As 0-day pounted out, this semicolon is not needed. > > Yes, thanks, I will fix that in next version. > > > > > > + > > > + if (tsdata->vcc) { > > > > You do not need to check for non-NULL here, devm_regulator_get() wil > > lnever give you a NULL. If regulator is not defined in DT/board > > mappings, then dummy regulator will be provided. You can call > > regulator_enable() and regulator_disable() and other regulator APIs > > with dummy regulator. > > Okay, thanks for the explanation, I will remove that. > > > > > > + 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)) { > > > @@ -1122,20 +1141,34 @@ 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); > > > > > > + if (tsdata->vcc) > > > > Same here. > > yep > > > > > > + regulator_disable(tsdata->vcc); > > > + > > > return 0; > > > } > > > > > > 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); > > > > > > + if (tsdata->vcc) { > > > > And here. > > yep > > > > > > + ret = regulator_enable(tsdata->vcc); > > > + if (ret < 0) { > > > + dev_err(dev, "failed to enable vcc: %d\n", ret); > > > + return ret; > > > + } > > > > Since power to the device may have been cut, I think you need to > > restore the register settings to whatever it was (factory vs work > > mode, threshold, gain and offset registers, etc, etc). > > Okay. Could you tell me how can I do that? If you take a look at edt_ft5x06_work_mode() at the end ther eis code to restore parameters. You want to factor it out and apply to the device when resuming. You probably also want to see what mode (factory/normal) the device was before suspend and restore the previous mode on resume. > > > > > > + } > > > + > > > return 0; > > > } > > > > > > -- > > > 2.11.0 > > > > > > > Thanks. > > > > About your V2's review, you suggested to add support for wake/reset in > suspend/resume (that I forgot in this version). I wanted to add it but > with my board, I can't test suspend/resume. What should I do about > that? See if Simon Budig can help us here. > > If I send a V3 in next few days, do you think you will have time to > merge it for v4.16? It all depends on the patch shape... Thanks. -- Dmitry