All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Rob Herring <robh+dt@kernel.org>,
	linux-input@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	devicetree <devicetree@vger.kernel.org>
Subject: Re: [PATCH v2] input: touchscreen: silead: Add regulator support
Date: Wed, 16 Nov 2016 09:51:59 -0800	[thread overview]
Message-ID: <20161116175159.GB335@dtor-ws> (raw)
In-Reply-To: <20161116115507.24220-1-hdegoede@redhat.com>

On Wed, Nov 16, 2016 at 12:55:07PM +0100, Hans de Goede wrote:
> On some tablets the touchscreen controller is powered by separate
> regulators, add support for this.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Acked-by: Rob Herring <robh@kernel.org>
> ---
> Changes in v2:
> -Use devm_regulator_bulk_get() and friends
> -Use devm_add_action_or_reset() to disable the regulator
> ---
>  .../bindings/input/touchscreen/silead_gsl1680.txt  |  2 ++
>  drivers/input/touchscreen/silead.c                 | 29 ++++++++++++++++++++++
>  2 files changed, 31 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt b/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt
> index e844c3f..b726823 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt
> @@ -22,6 +22,8 @@ Optional properties:
>  - touchscreen-inverted-y  : See touchscreen.txt
>  - touchscreen-swapped-x-y : See touchscreen.txt
>  - silead,max-fingers	  : maximum number of fingers the touchscreen can detect
> +- vddio-supply		  : regulator phandle for controller VDDIO
> +- avdd-supply		  : regulator phandle for controller AVDD
>  
>  Example:
>  
> diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c
> index f502c84..404830a 100644
> --- a/drivers/input/touchscreen/silead.c
> +++ b/drivers/input/touchscreen/silead.c
> @@ -29,6 +29,7 @@
>  #include <linux/input/touchscreen.h>
>  #include <linux/pm.h>
>  #include <linux/irq.h>
> +#include <linux/regulator/consumer.h>
>  
>  #include <asm/unaligned.h>
>  
> @@ -73,6 +74,7 @@ struct silead_ts_data {
>  	struct i2c_client *client;
>  	struct gpio_desc *gpio_power;
>  	struct input_dev *input;
> +	struct regulator_bulk_data regulators[2];
>  	char fw_name[64];
>  	struct touchscreen_properties prop;
>  	u32 max_fingers;
> @@ -433,6 +435,13 @@ static int silead_ts_set_default_fw_name(struct silead_ts_data *data,
>  }
>  #endif
>  
> +static void silead_disable_regulator(void *arg)
> +{
> +	struct silead_ts_data *data = arg;
> +
> +	regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
> +}
> +
>  static int silead_ts_probe(struct i2c_client *client,
>  			   const struct i2c_device_id *id)
>  {
> @@ -465,6 +474,26 @@ static int silead_ts_probe(struct i2c_client *client,
>  	if (client->irq <= 0)
>  		return -ENODEV;
>  
> +	data->regulators[0].supply = "vddio";
> +	data->regulators[1].supply = "avdd";
> +	error = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->regulators),
> +					data->regulators);
> +	if (error)
> +		return error;
> +
> +	/*
> +	 * Enable regulators at probe and disable them at remove, we need
> +	 * to keep the chip powered otherwise it forgets its firmware.
> +	 */

Hmm, this burns power though. Why can't we reload firmware on resume (it
should be already cached)? Does it take too long?

Thanks.

> +	error = regulator_bulk_enable(ARRAY_SIZE(data->regulators),
> +				      data->regulators);
> +	if (error)
> +		return error;
> +
> +	error = devm_add_action_or_reset(dev, silead_disable_regulator, data);
> +	if (error)
> +		return error;
> +
>  	/* Power GPIO pin */
>  	data->gpio_power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW);
>  	if (IS_ERR(data->gpio_power)) {
> -- 
> 2.9.3
> 

-- 
Dmitry

WARNING: multiple messages have this Message-ID (diff)
From: dmitry.torokhov@gmail.com (Dmitry Torokhov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] input: touchscreen: silead: Add regulator support
Date: Wed, 16 Nov 2016 09:51:59 -0800	[thread overview]
Message-ID: <20161116175159.GB335@dtor-ws> (raw)
In-Reply-To: <20161116115507.24220-1-hdegoede@redhat.com>

On Wed, Nov 16, 2016 at 12:55:07PM +0100, Hans de Goede wrote:
> On some tablets the touchscreen controller is powered by separate
> regulators, add support for this.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Acked-by: Rob Herring <robh@kernel.org>
> ---
> Changes in v2:
> -Use devm_regulator_bulk_get() and friends
> -Use devm_add_action_or_reset() to disable the regulator
> ---
>  .../bindings/input/touchscreen/silead_gsl1680.txt  |  2 ++
>  drivers/input/touchscreen/silead.c                 | 29 ++++++++++++++++++++++
>  2 files changed, 31 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt b/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt
> index e844c3f..b726823 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt
> @@ -22,6 +22,8 @@ Optional properties:
>  - touchscreen-inverted-y  : See touchscreen.txt
>  - touchscreen-swapped-x-y : See touchscreen.txt
>  - silead,max-fingers	  : maximum number of fingers the touchscreen can detect
> +- vddio-supply		  : regulator phandle for controller VDDIO
> +- avdd-supply		  : regulator phandle for controller AVDD
>  
>  Example:
>  
> diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c
> index f502c84..404830a 100644
> --- a/drivers/input/touchscreen/silead.c
> +++ b/drivers/input/touchscreen/silead.c
> @@ -29,6 +29,7 @@
>  #include <linux/input/touchscreen.h>
>  #include <linux/pm.h>
>  #include <linux/irq.h>
> +#include <linux/regulator/consumer.h>
>  
>  #include <asm/unaligned.h>
>  
> @@ -73,6 +74,7 @@ struct silead_ts_data {
>  	struct i2c_client *client;
>  	struct gpio_desc *gpio_power;
>  	struct input_dev *input;
> +	struct regulator_bulk_data regulators[2];
>  	char fw_name[64];
>  	struct touchscreen_properties prop;
>  	u32 max_fingers;
> @@ -433,6 +435,13 @@ static int silead_ts_set_default_fw_name(struct silead_ts_data *data,
>  }
>  #endif
>  
> +static void silead_disable_regulator(void *arg)
> +{
> +	struct silead_ts_data *data = arg;
> +
> +	regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
> +}
> +
>  static int silead_ts_probe(struct i2c_client *client,
>  			   const struct i2c_device_id *id)
>  {
> @@ -465,6 +474,26 @@ static int silead_ts_probe(struct i2c_client *client,
>  	if (client->irq <= 0)
>  		return -ENODEV;
>  
> +	data->regulators[0].supply = "vddio";
> +	data->regulators[1].supply = "avdd";
> +	error = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->regulators),
> +					data->regulators);
> +	if (error)
> +		return error;
> +
> +	/*
> +	 * Enable regulators at probe and disable them at remove, we need
> +	 * to keep the chip powered otherwise it forgets its firmware.
> +	 */

Hmm, this burns power though. Why can't we reload firmware on resume (it
should be already cached)? Does it take too long?

Thanks.

> +	error = regulator_bulk_enable(ARRAY_SIZE(data->regulators),
> +				      data->regulators);
> +	if (error)
> +		return error;
> +
> +	error = devm_add_action_or_reset(dev, silead_disable_regulator, data);
> +	if (error)
> +		return error;
> +
>  	/* Power GPIO pin */
>  	data->gpio_power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW);
>  	if (IS_ERR(data->gpio_power)) {
> -- 
> 2.9.3
> 

-- 
Dmitry

  reply	other threads:[~2016-11-16 17:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-16 11:55 [PATCH v2] input: touchscreen: silead: Add regulator support Hans de Goede
2016-11-16 11:55 ` Hans de Goede
2016-11-16 17:51 ` Dmitry Torokhov [this message]
2016-11-16 17:51   ` Dmitry Torokhov
2016-11-16 18:58   ` Hans de Goede
2016-11-16 18:58     ` Hans de Goede
     [not found]     ` <cdc827c1-f5ba-27b8-b7d0-4489fbd6da28-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-11-17  1:01       ` Dmitry Torokhov
2016-11-17  1:01         ` Dmitry Torokhov

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=20161116175159.GB335@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-input@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.