devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: Stephan Gerhold <stephan@gerhold.net>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	linux-input@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	devicetree@vger.kernel.org,
	Simon Budig <simon.budig@kernelconcepts.de>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Ondrej Jirman <megous@megous.com>
Subject: Re: [PATCH 2/2] Input: edt-ft5x06 - add support for iovcc-supply
Date: Mon, 11 Jan 2021 09:36:12 +0100	[thread overview]
Message-ID: <20210111083612.swe2bu7mvjzjromg@pengutronix.de> (raw)
In-Reply-To: <20210108192337.563679-2-stephan@gerhold.net>

Hi Stephan,

thanks for the patch :) Please see my inline comments.

On 21-01-08 20:23, Stephan Gerhold wrote:
> At the moment, the edt-ft5x06 driver can control a single regulator
> ("vcc"). However, some FocalTech touch controllers have an additional
> IOVCC pin that should be supplied with the digital I/O voltage.
> 
> The I/O voltage might be provided by another regulator that should also
> be kept on. Otherwise, the touchscreen can randomly stop functioning if
> the regulator is turned off because no other components still require it.
> 
> Implement (optional) support for also enabling an "iovcc-supply".
> IOVCC is needed whenever VCC is needed, so switch to the regulator bulk
> APIs to request/enable/disable both when appropriate.
> 
> Cc: Ondrej Jirman <megous@megous.com>
> Cc: Marco Felsch <m.felsch@pengutronix.de>
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> ---
>  drivers/input/touchscreen/edt-ft5x06.c | 35 ++++++++++++++------------
>  1 file changed, 19 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
> index 2eefbc2485bc..bf2e208112fe 100644
> --- a/drivers/input/touchscreen/edt-ft5x06.c
> +++ b/drivers/input/touchscreen/edt-ft5x06.c
> @@ -103,7 +103,7 @@ struct edt_ft5x06_ts_data {
>  	struct touchscreen_properties prop;
>  	u16 num_x;
>  	u16 num_y;
> -	struct regulator *vcc;
> +	struct regulator_bulk_data regulators[2];

Is there an enabling order we must follow?

>  	struct gpio_desc *reset_gpio;
>  	struct gpio_desc *wake_gpio;
> @@ -1066,7 +1066,7 @@ static void edt_ft5x06_disable_regulator(void *arg)
>  {
>  	struct edt_ft5x06_ts_data *data = arg;
>  
> -	regulator_disable(data->vcc);
> +	regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
>  }
>  
>  static int edt_ft5x06_ts_probe(struct i2c_client *client,
> @@ -1098,18 +1098,19 @@ 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;
> -	}
> +	tsdata->regulators[0].supply = "vcc";
> +	tsdata->regulators[1].supply = "iovcc";
> +	error = devm_regulator_bulk_get(&client->dev,
> +					ARRAY_SIZE(tsdata->regulators),
> +					tsdata->regulators);
> +	if (error)
> +		return dev_err_probe(&client->dev, error,
> +				     "failed to request regulators\n");

It would be nice to have a patch in front of this one which handles the
support for dev_err_probe().

Regards,
  Marco

>  
> -	error = regulator_enable(tsdata->vcc);
> +	error = regulator_bulk_enable(ARRAY_SIZE(tsdata->regulators),
> +				      tsdata->regulators);
>  	if (error < 0) {
> -		dev_err(&client->dev, "failed to enable vcc: %d\n", error);
> +		dev_err(&client->dev, "failed to enable regulators: %d\n", error);
>  		return error;
>  	}
>  
> @@ -1286,9 +1287,10 @@ static int __maybe_unused edt_ft5x06_ts_suspend(struct device *dev)
>  	gpiod_set_value_cansleep(reset_gpio, 1);
>  	usleep_range(1000, 2000);
>  
> -	ret = regulator_disable(tsdata->vcc);
> +	ret = regulator_bulk_disable(ARRAY_SIZE(tsdata->regulators),
> +				     tsdata->regulators);
>  	if (ret)
> -		dev_warn(dev, "Failed to disable vcc\n");
> +		dev_warn(dev, "Failed to disable regulators\n");
>  
>  	return 0;
>  }
> @@ -1319,9 +1321,10 @@ static int __maybe_unused edt_ft5x06_ts_resume(struct device *dev)
>  		gpiod_set_value_cansleep(reset_gpio, 1);
>  		usleep_range(5000, 6000);
>  
> -		ret = regulator_enable(tsdata->vcc);
> +		ret = regulator_bulk_enable(ARRAY_SIZE(tsdata->regulators),
> +					    tsdata->regulators);
>  		if (ret) {
> -			dev_err(dev, "Failed to enable vcc\n");
> +			dev_err(dev, "Failed to enable regulators\n");
>  			return ret;
>  		}
>  
> -- 
> 2.30.0
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2021-01-11  8:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08 19:23 [PATCH 1/2] dt-bindings: input: touchscreen: edt-ft5x06: add iovcc-supply Stephan Gerhold
2021-01-08 19:23 ` [PATCH 2/2] Input: edt-ft5x06 - add support for iovcc-supply Stephan Gerhold
2021-01-11  8:36   ` Marco Felsch [this message]
2021-01-11  9:26     ` Stephan Gerhold
2021-01-11  9:45       ` Marco Felsch
2021-01-11 10:10         ` Stephan Gerhold
2021-01-11 15:46           ` Stephan Gerhold
2021-01-11 10:22       ` Andy Shevchenko
2021-01-11 10:43         ` Stephan Gerhold
2021-01-13 15:25 ` [PATCH 1/2] dt-bindings: input: touchscreen: edt-ft5x06: add iovcc-supply Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210111083612.swe2bu7mvjzjromg@pengutronix.de \
    --to=m.felsch@pengutronix.de \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=megous@megous.com \
    --cc=robh+dt@kernel.org \
    --cc=simon.budig@kernelconcepts.de \
    --cc=stephan@gerhold.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).