Received: by 10.223.176.46 with SMTP id f43csp3183639wra; Mon, 22 Jan 2018 09:42:56 -0800 (PST) X-Google-Smtp-Source: AH8x227hPnPTeFriUiexPtzSTzJZV8nLW63/CpQsgkb6eBAUiRrRDpvB+EU3b8YS1dnpr8jqMRWp X-Received: by 10.36.212.66 with SMTP id x63mr9208051itg.59.1516642976701; Mon, 22 Jan 2018 09:42:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516642976; cv=none; d=google.com; s=arc-20160816; b=mYZPS3KDgHjjQle0m+HSFTIz1UWV0Ac4PtkMV/nQ+OcrVAqcLI3Y/Ms/5EPUU19NTK 8ZsZpeA+Pr4ZwBc4WiR4WjGscqENt7moV+MSuRpFyqv/K9PC6lqVS2YH8ITlyiUv4mwb ANVbougxt1h+yk9oiNCibNmR9xjpouWQSJVJ5wCzkU+nnrGVsVLapQ61yfbMHEr3PJM1 l/dOkn50ZwvGfiNI4ikmWzNQTZHuzz1d0mWvmjsF+9EyEvGDRlx/H9BJMw+nYYU3Dh30 s1ZSCJaYqgylwrYGa1nysR6hIjMb2iI+btc2ulkA1lPl7WcaHkZbgMs2VrkoZkh6/62Z jnDQ== 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:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=NBi1lm6xj6DbKNVIbt0021YAveMqfMzTvBMs+/mugBM=; b=XFzvMCZwpP45VZyzDBmTZlVOuOKkF4a3YYPAsNvNrBPUD3Kc7gmqPSbASzp6RZhxRM V3KtW7ESPYlMmEVoH3+IgNRttnkoxuGEK9Nxqna1zVzK3AO3KYe92phM6O9hnzxPN0Xg 7+VzVj3bgiOYPnvhl1jXPqUwC/X7XntjyH0T4FnMy4HnVvGAevStQJAHuuWBOUfVE9XD GOCtbUIcbZZBKGUgF40uC5jLSiOi1Wh6ALwk3viSHFjOun3Dc1sqjKEf71+QWo6F94L7 RPB8IEB2XjzdEbUETyMjorjYKq3siMi5ygZwHzjsQWHecX336hV/vDGyc2qP6Ook1YMd +NAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sfsMI/oC; 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 l64si12607666iof.279.2018.01.22.09.42.43; Mon, 22 Jan 2018 09:42:56 -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=sfsMI/oC; 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 S1751195AbeAVRmM (ORCPT + 99 others); Mon, 22 Jan 2018 12:42:12 -0500 Received: from mail-vk0-f67.google.com ([209.85.213.67]:42854 "EHLO mail-vk0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751040AbeAVRmJ (ORCPT ); Mon, 22 Jan 2018 12:42:09 -0500 Received: by mail-vk0-f67.google.com with SMTP id t4so5455551vkb.9; Mon, 22 Jan 2018 09:42:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=NBi1lm6xj6DbKNVIbt0021YAveMqfMzTvBMs+/mugBM=; b=sfsMI/oCYMNX1wDPgwkQeO7sIwTpsbrvE4Imqg/9jmoXvbk+oEMwAycLrSbUGEMV/m hlo3dsTZwkxI2S6Pma0dsCPpphCqLJuU6PEqdo70pD5k22vMYLWuUKTMJrZ02h3WXOxE nCHQSfOD+ne/ULB7ET0FTPf5V4L1K7FyMFUCkvw3f8AyINwNziLLpwh25w6caWRpBsr9 UbCnE0Bgxk3PDl2NbD+ktLGEfWmMScDKpiTWNJ1Q0OAuGVM6G5ypvJIXNVNvar5q07ar M0uXQ4tAgiTZLCI9/STkiUiOV3j4/P6vJJxzPm4cpuCwg0hAienNQMHovlpjoRcCsOKM edeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=NBi1lm6xj6DbKNVIbt0021YAveMqfMzTvBMs+/mugBM=; b=G3xSwnsXGbjliqSz4IQC6yXRLOZhd3H2sFYAOGnxftgAMfrXxC6F8moo8H/d6oFyfV vKIB+Bn/T4EnkfitRx0os4f/4ODZ6clJ2L8Ex8UCF0PAPtR4O+E3Qn+TWYX9QAQgBt0E uGTRX2KVpSBOgWoUNSjzyEoszM06/A2fYVMUlPQn0CbuM5Q/LLFnQmEeBVE0PxlRJt6U 8boFcr5RNZfK7hrB8RS7mZk3MP4l3LZhS+qLBNC02doyH/ZM2BqXneX41n0xzKlJvyND cy2IAq8V+X9ggw3j8M08eJGmtvdg0LllWFDVldQvQAQCd1s9X92hrAmPBNIV8wZzSasx U/1Q== X-Gm-Message-State: AKwxytfC9nty/AfLfIxmx9E+sZjicwJzfTTKdmEgH6iz5ph1Usod/CSN /LLzWO3IAr4TVtaRlWvA46BZDoFciwFQSes9yR4= X-Received: by 10.31.154.194 with SMTP id c185mr5307051vke.60.1516642928571; Mon, 22 Jan 2018 09:42:08 -0800 (PST) MIME-Version: 1.0 Received: by 10.176.26.172 with HTTP; Mon, 22 Jan 2018 09:42:08 -0800 (PST) In-Reply-To: <20171228163336.28131-2-mylene.josserand@free-electrons.com> References: <20171228163336.28131-1-mylene.josserand@free-electrons.com> <20171228163336.28131-2-mylene.josserand@free-electrons.com> From: Dmitry Torokhov Date: Mon, 22 Jan 2018 09:42:08 -0800 Message-ID: Subject: Re: [PATCH v2 1/2] Input: edt-ft5x06 - Add support for regulator To: =?UTF-8?Q?Myl=C3=A8ne_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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Myl=C3=A8ne, On Thu, Dec 28, 2017 at 8:33 AM, Myl=C3=A8ne Josserand wrote: > Add the support of regulator to use it as VCC source. > > Signed-off-by: Myl=C3=A8ne 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-ft5x= 06.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/touch= screen/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 *cl= ient, > > tsdata->max_support_points =3D chip_data->max_support_points; > > + tsdata->vcc =3D devm_regulator_get(&client->dev, "vcc"); > + if (IS_ERR(tsdata->vcc)) { > + error =3D 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. > + > + 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. > + error =3D regulator_enable(tsdata->vcc); > + if (error < 0) { > + dev_err(&client->dev, "failed to enable vcc: %d\n= ", > + error); > + return error; > + } > + } > + > tsdata->reset_gpio =3D devm_gpiod_get_optional(&client->dev, > "reset", GPIOD_OUT_H= IGH); > 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 =3D to_i2c_client(dev); > + struct edt_ft5x06_ts_data *tsdata =3D i2c_get_clientdata(client); > > if (device_may_wakeup(dev)) > enable_irq_wake(client->irq); > > + if (tsdata->vcc) Same here. > + regulator_disable(tsdata->vcc); > + > return 0; > } > > static int __maybe_unused edt_ft5x06_ts_resume(struct device *dev) > { > struct i2c_client *client =3D to_i2c_client(dev); > + struct edt_ft5x06_ts_data *tsdata =3D i2c_get_clientdata(client); > + int ret; > > if (device_may_wakeup(dev)) > disable_irq_wake(client->irq); > > + if (tsdata->vcc) { And here. > + ret =3D 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). > + } > + > return 0; > } > > -- > 2.11.0 > Thanks. --=20 Dmitry