All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: devicetree-discuss@lists.ozlabs.org, linux-input@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	davinci-linux-open-source@linux.davincidsp.com
Cc: dmitry.torokhov@gmail.com, rob.herring@calxeda.com,
	rob@landley.net, manishv.b@ti.com
Subject: Re: [PATCH V3 1/2] tps6507x-ts: Add DT support
Date: Wed, 12 Jun 2013 12:24:21 +0100	[thread overview]
Message-ID: <20130612112421.AF2F93E0A56@localhost> (raw)
In-Reply-To: <1369126458-24872-2-git-send-email-manishv.b@ti.com>

On Tue, 21 May 2013 14:24:17 +0530, "Vishwanathrao Badarkhe, Manish" <manishv.b@ti.com> wrote:
> Add device tree based support for TI's tps6507x touchscreen.
> 
> Tested on da850-evm.
> 
> Signed-off-by: Vishwanathrao Badarkhe, Manish <manishv.b@ti.com>
> ---
> Changes since V2:
>  - Removed unnecessary code.
>  - Updated Documentation to provide proper names of
>    devicetree properties.
> 
> Changes since V1:
>  - Updated documentation to specify tps6507x as multifunctional
>    device.
>  - return proper error value in absence of platform and DT
>    data for touchscreen.
>  - Updated commit message.
> 
> :100755 100755 8fffa3c... 65ee2cd... M	Documentation/devicetree/bindings/mfd/tps6507x.txt
> :100644 100644 65e0f9a... 89232ee... M	drivers/input/touchscreen/tps6507x-ts.c
>  Documentation/devicetree/bindings/mfd/tps6507x.txt |   28 ++++++-

Binding looks fine to me.

Acked-by: Grant Likely <grant.likely@secretlab.ca>

g.

>  drivers/input/touchscreen/tps6507x-ts.c            |   98 ++++++++++++++------
>  2 files changed, 95 insertions(+), 31 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/tps6507x.txt b/Documentation/devicetree/bindings/mfd/tps6507x.txt
> index 8fffa3c..65ee2cd 100755
> --- a/Documentation/devicetree/bindings/mfd/tps6507x.txt
> +++ b/Documentation/devicetree/bindings/mfd/tps6507x.txt
> @@ -1,4 +1,8 @@
> -TPS6507x Power Management Integrated Circuit
> +TPS6507x Multifunctional Device.
> +
> +Features provided by TPS6507x:
> +        1.Power Management Integrated Circuit.
> +        2.Touch-Screen.
>  
>  Required properties:
>  - compatible: "ti,tps6507x"
> @@ -23,6 +27,12 @@ Required properties:
>         vindcdc1_2-supply: VDCDC1 and VDCDC2 input.
>         vindcdc3-supply  : VDCDC3 input.
>         vldo1_2-supply   : VLDO1 and VLDO2 input.
> +- tsc: This node specifies touch screen data.
> +	ti,poll-period : Time at which touch input is getting sampled in ms.
> +	ti,min-pressure: Minimum pressure value to trigger touch.
> +	ti,vref	       : voltage reference for ADC.
> +		      0: Reference voltage for ADC is disabled.
> +		      1: Reference voltage for ADC is enabled.
>  
>  Regulator Optional properties:
>  - defdcdc_default: It's property of DCDC2 and DCDC3 regulators.
> @@ -30,6 +40,14 @@ Regulator Optional properties:
>  			1: If defdcdc pin of DCDC2/DCDC3 is driven HIGH.
>    If this property is not defined, it defaults to 0 (not enabled).
>  
> +Touchscreen Optional properties:
> +- ti,vendor : Touchscreen vendor id to populate
> +	      in sysclass interface.
> +- ti,product: Touchscreen product id to populate
> +	      in sysclass interface.
> +- ti,version: Touchscreen version id to populate
> +	      in sysclass interface.
> +
>  Example:
>  
>  	pmu: tps6507x@48 {
> @@ -88,4 +106,12 @@ Example:
>  			};
>  		};
>  
> +		tsc {
> +			ti,poll-period = <30>;
> +			ti,min-pressure = <0x30>;
> +			ti,vref = <0>;
> +			ti,vendor = <0>;
> +			ti,product = <65070>;
> +			ti,version = <0x100>;
> +		};
>  	};
> diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c
> index 65e0f9a..89232ee 100644
> --- a/drivers/input/touchscreen/tps6507x-ts.c
> +++ b/drivers/input/touchscreen/tps6507x-ts.c
> @@ -21,6 +21,8 @@
>  #include <linux/mfd/tps6507x.h>
>  #include <linux/input/tps6507x-ts.h>
>  #include <linux/delay.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
>  
>  #define TSC_DEFAULT_POLL_PERIOD 30 /* ms */
>  #define TPS_DEFAULT_MIN_PRESSURE 0x30
> @@ -231,36 +233,76 @@ done:
>  	ret = tps6507x_adc_standby(tsc);
>  }
>  
> +static int tsc_init_data(struct tps6507x_dev *tps6507x_dev,
> +		struct input_dev *input_dev)
> +{
> +	struct device_node *node = tps6507x_dev->dev->of_node;
> +	struct tps6507x_board *tps_board =
> +		(struct tps6507x_board *)tps6507x_dev->dev->platform_data;
> +	struct touchscreen_init_data *init_data = NULL;
> +	int err;
> +
> +	if (node)
> +		node = of_find_node_by_name(node, "tsc");
> +	if (tps_board)
> +		init_data = tps_board->tps6507x_ts_init_data;
> +
> +	if (node == NULL || init_data == NULL) {
> +		err = -EINVAL;
> +		goto error_ret;
> +	} else if (init_data) {
> +		tps6507x_dev->ts->poll_period = init_data->poll_period;
> +		tps6507x_dev->ts->min_pressure = init_data->min_pressure;
> +		tps6507x_dev->ts->vref = init_data->vref;
> +		input_dev->id.vendor = init_data->vendor;
> +		input_dev->id.product = init_data->product;
> +		input_dev->id.version = init_data->version;
> +	} else if (node) {
> +		err = of_property_read_u32(node, "ti,poll-period",
> +					(u32 *)&tps6507x_dev->ts->poll_period);
> +		if (err < 0)
> +			goto error_ret;
> +
> +		err = of_property_read_u16(node, "ti,min-pressure",
> +					&tps6507x_dev->ts->min_pressure);
> +		if (err < 0)
> +			goto error_ret;
> +
> +		err = of_property_read_u32(node, "ti,vref",
> +					&tps6507x_dev->ts->vref);
> +		if (err < 0)
> +			goto error_ret;
> +
> +		err = of_property_read_u16(node, "ti,vendor",
> +					&input_dev->id.vendor);
> +		if (err < 0)
> +			goto error_ret;
> +
> +		err = of_property_read_u16(node, "ti,product",
> +					&input_dev->id.product);
> +		if (err < 0)
> +			goto error_ret;
> +
> +		err = of_property_read_u16(node, "ti,version",
> +					&input_dev->id.version);
> +		if (err < 0)
> +			goto error_ret;
> +	}
> +
> +	return 0;
> +
> +error_ret:
> +	return err;
> +}
> +
>  static int tps6507x_ts_probe(struct platform_device *pdev)
>  {
>  	int error;
>  	struct tps6507x_ts *tsc;
>  	struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent);
> -	struct touchscreen_init_data *init_data;
>  	struct input_dev *input_dev;
> -	struct tps6507x_board *tps_board;
>  	int schd;
>  
> -	/**
> -	 * tps_board points to pmic related constants
> -	 * coming from the board-evm file.
> -	 */
> -
> -	tps_board = (struct tps6507x_board *)tps6507x_dev->dev->platform_data;
> -
> -	if (!tps_board) {
> -		dev_err(tps6507x_dev->dev,
> -			"Could not find tps6507x platform data\n");
> -		return -EIO;
> -	}
> -
> -	/**
> -	 * init_data points to array of regulator_init structures
> -	 * coming from the board-evm file.
> -	 */
> -
> -	init_data = tps_board->tps6507x_ts_init_data;
> -
>  	tsc = devm_kzalloc(&pdev->dev, sizeof(struct tps6507x_ts), GFP_KERNEL);
>  	if (!tsc) {
>  		dev_err(tps6507x_dev->dev, "failed to allocate driver data\n");
> @@ -301,14 +343,10 @@ static int tps6507x_ts_probe(struct platform_device *pdev)
>  
>  	INIT_DELAYED_WORK(&tsc->work, tps6507x_ts_handler);
>  
> -	if (init_data) {
> -		tsc->poll_period = init_data->poll_period;
> -		tsc->vref = init_data->vref;
> -		tsc->min_pressure = init_data->min_pressure;
> -		input_dev->id.vendor = init_data->vendor;
> -		input_dev->id.product = init_data->product;
> -		input_dev->id.version = init_data->version;
> -	} else {
> +	error = tsc_init_data(tps6507x_dev, input_dev);
> +
> +	if (error) {
> +		dev_warn(&pdev->dev, "Use default platform data\n");
>  		tsc->poll_period = TSC_DEFAULT_POLL_PERIOD;
>  		tsc->min_pressure = TPS_DEFAULT_MIN_PRESSURE;
>  	}
> -- 
> 1.7.4.1
> 

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.

WARNING: multiple messages have this Message-ID (diff)
From: Grant Likely <grant.likely@secretlab.ca>
To: "Vishwanathrao Badarkhe, Manish" <manishv.b@ti.com>,
	devicetree-discuss@lists.ozlabs.org, linux-input@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	davinci-linux-open-source@linux.davincidsp.com
Cc: dmitry.torokhov@gmail.com, rob.herring@calxeda.com,
	rob@landley.net, manishv.b@ti.com
Subject: Re: [PATCH V3 1/2] tps6507x-ts: Add DT support
Date: Wed, 12 Jun 2013 12:24:21 +0100	[thread overview]
Message-ID: <20130612112421.AF2F93E0A56@localhost> (raw)
In-Reply-To: <1369126458-24872-2-git-send-email-manishv.b@ti.com>

On Tue, 21 May 2013 14:24:17 +0530, "Vishwanathrao Badarkhe, Manish" <manishv.b@ti.com> wrote:
> Add device tree based support for TI's tps6507x touchscreen.
> 
> Tested on da850-evm.
> 
> Signed-off-by: Vishwanathrao Badarkhe, Manish <manishv.b@ti.com>
> ---
> Changes since V2:
>  - Removed unnecessary code.
>  - Updated Documentation to provide proper names of
>    devicetree properties.
> 
> Changes since V1:
>  - Updated documentation to specify tps6507x as multifunctional
>    device.
>  - return proper error value in absence of platform and DT
>    data for touchscreen.
>  - Updated commit message.
> 
> :100755 100755 8fffa3c... 65ee2cd... M	Documentation/devicetree/bindings/mfd/tps6507x.txt
> :100644 100644 65e0f9a... 89232ee... M	drivers/input/touchscreen/tps6507x-ts.c
>  Documentation/devicetree/bindings/mfd/tps6507x.txt |   28 ++++++-

Binding looks fine to me.

Acked-by: Grant Likely <grant.likely@secretlab.ca>

g.

>  drivers/input/touchscreen/tps6507x-ts.c            |   98 ++++++++++++++------
>  2 files changed, 95 insertions(+), 31 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/tps6507x.txt b/Documentation/devicetree/bindings/mfd/tps6507x.txt
> index 8fffa3c..65ee2cd 100755
> --- a/Documentation/devicetree/bindings/mfd/tps6507x.txt
> +++ b/Documentation/devicetree/bindings/mfd/tps6507x.txt
> @@ -1,4 +1,8 @@
> -TPS6507x Power Management Integrated Circuit
> +TPS6507x Multifunctional Device.
> +
> +Features provided by TPS6507x:
> +        1.Power Management Integrated Circuit.
> +        2.Touch-Screen.
>  
>  Required properties:
>  - compatible: "ti,tps6507x"
> @@ -23,6 +27,12 @@ Required properties:
>         vindcdc1_2-supply: VDCDC1 and VDCDC2 input.
>         vindcdc3-supply  : VDCDC3 input.
>         vldo1_2-supply   : VLDO1 and VLDO2 input.
> +- tsc: This node specifies touch screen data.
> +	ti,poll-period : Time at which touch input is getting sampled in ms.
> +	ti,min-pressure: Minimum pressure value to trigger touch.
> +	ti,vref	       : voltage reference for ADC.
> +		      0: Reference voltage for ADC is disabled.
> +		      1: Reference voltage for ADC is enabled.
>  
>  Regulator Optional properties:
>  - defdcdc_default: It's property of DCDC2 and DCDC3 regulators.
> @@ -30,6 +40,14 @@ Regulator Optional properties:
>  			1: If defdcdc pin of DCDC2/DCDC3 is driven HIGH.
>    If this property is not defined, it defaults to 0 (not enabled).
>  
> +Touchscreen Optional properties:
> +- ti,vendor : Touchscreen vendor id to populate
> +	      in sysclass interface.
> +- ti,product: Touchscreen product id to populate
> +	      in sysclass interface.
> +- ti,version: Touchscreen version id to populate
> +	      in sysclass interface.
> +
>  Example:
>  
>  	pmu: tps6507x@48 {
> @@ -88,4 +106,12 @@ Example:
>  			};
>  		};
>  
> +		tsc {
> +			ti,poll-period = <30>;
> +			ti,min-pressure = <0x30>;
> +			ti,vref = <0>;
> +			ti,vendor = <0>;
> +			ti,product = <65070>;
> +			ti,version = <0x100>;
> +		};
>  	};
> diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c
> index 65e0f9a..89232ee 100644
> --- a/drivers/input/touchscreen/tps6507x-ts.c
> +++ b/drivers/input/touchscreen/tps6507x-ts.c
> @@ -21,6 +21,8 @@
>  #include <linux/mfd/tps6507x.h>
>  #include <linux/input/tps6507x-ts.h>
>  #include <linux/delay.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
>  
>  #define TSC_DEFAULT_POLL_PERIOD 30 /* ms */
>  #define TPS_DEFAULT_MIN_PRESSURE 0x30
> @@ -231,36 +233,76 @@ done:
>  	ret = tps6507x_adc_standby(tsc);
>  }
>  
> +static int tsc_init_data(struct tps6507x_dev *tps6507x_dev,
> +		struct input_dev *input_dev)
> +{
> +	struct device_node *node = tps6507x_dev->dev->of_node;
> +	struct tps6507x_board *tps_board =
> +		(struct tps6507x_board *)tps6507x_dev->dev->platform_data;
> +	struct touchscreen_init_data *init_data = NULL;
> +	int err;
> +
> +	if (node)
> +		node = of_find_node_by_name(node, "tsc");
> +	if (tps_board)
> +		init_data = tps_board->tps6507x_ts_init_data;
> +
> +	if (node == NULL || init_data == NULL) {
> +		err = -EINVAL;
> +		goto error_ret;
> +	} else if (init_data) {
> +		tps6507x_dev->ts->poll_period = init_data->poll_period;
> +		tps6507x_dev->ts->min_pressure = init_data->min_pressure;
> +		tps6507x_dev->ts->vref = init_data->vref;
> +		input_dev->id.vendor = init_data->vendor;
> +		input_dev->id.product = init_data->product;
> +		input_dev->id.version = init_data->version;
> +	} else if (node) {
> +		err = of_property_read_u32(node, "ti,poll-period",
> +					(u32 *)&tps6507x_dev->ts->poll_period);
> +		if (err < 0)
> +			goto error_ret;
> +
> +		err = of_property_read_u16(node, "ti,min-pressure",
> +					&tps6507x_dev->ts->min_pressure);
> +		if (err < 0)
> +			goto error_ret;
> +
> +		err = of_property_read_u32(node, "ti,vref",
> +					&tps6507x_dev->ts->vref);
> +		if (err < 0)
> +			goto error_ret;
> +
> +		err = of_property_read_u16(node, "ti,vendor",
> +					&input_dev->id.vendor);
> +		if (err < 0)
> +			goto error_ret;
> +
> +		err = of_property_read_u16(node, "ti,product",
> +					&input_dev->id.product);
> +		if (err < 0)
> +			goto error_ret;
> +
> +		err = of_property_read_u16(node, "ti,version",
> +					&input_dev->id.version);
> +		if (err < 0)
> +			goto error_ret;
> +	}
> +
> +	return 0;
> +
> +error_ret:
> +	return err;
> +}
> +
>  static int tps6507x_ts_probe(struct platform_device *pdev)
>  {
>  	int error;
>  	struct tps6507x_ts *tsc;
>  	struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent);
> -	struct touchscreen_init_data *init_data;
>  	struct input_dev *input_dev;
> -	struct tps6507x_board *tps_board;
>  	int schd;
>  
> -	/**
> -	 * tps_board points to pmic related constants
> -	 * coming from the board-evm file.
> -	 */
> -
> -	tps_board = (struct tps6507x_board *)tps6507x_dev->dev->platform_data;
> -
> -	if (!tps_board) {
> -		dev_err(tps6507x_dev->dev,
> -			"Could not find tps6507x platform data\n");
> -		return -EIO;
> -	}
> -
> -	/**
> -	 * init_data points to array of regulator_init structures
> -	 * coming from the board-evm file.
> -	 */
> -
> -	init_data = tps_board->tps6507x_ts_init_data;
> -
>  	tsc = devm_kzalloc(&pdev->dev, sizeof(struct tps6507x_ts), GFP_KERNEL);
>  	if (!tsc) {
>  		dev_err(tps6507x_dev->dev, "failed to allocate driver data\n");
> @@ -301,14 +343,10 @@ static int tps6507x_ts_probe(struct platform_device *pdev)
>  
>  	INIT_DELAYED_WORK(&tsc->work, tps6507x_ts_handler);
>  
> -	if (init_data) {
> -		tsc->poll_period = init_data->poll_period;
> -		tsc->vref = init_data->vref;
> -		tsc->min_pressure = init_data->min_pressure;
> -		input_dev->id.vendor = init_data->vendor;
> -		input_dev->id.product = init_data->product;
> -		input_dev->id.version = init_data->version;
> -	} else {
> +	error = tsc_init_data(tps6507x_dev, input_dev);
> +
> +	if (error) {
> +		dev_warn(&pdev->dev, "Use default platform data\n");
>  		tsc->poll_period = TSC_DEFAULT_POLL_PERIOD;
>  		tsc->min_pressure = TPS_DEFAULT_MIN_PRESSURE;
>  	}
> -- 
> 1.7.4.1
> 

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.

  parent reply	other threads:[~2013-06-12 11:24 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-21  8:54 [PATCH V3 0/2] Add DT support for tps6507x touchscreen Vishwanathrao Badarkhe, Manish
2013-05-21  8:54 ` Vishwanathrao Badarkhe, Manish
2013-05-21  8:54 ` [PATCH V3 1/2] tps6507x-ts: Add DT support Vishwanathrao Badarkhe, Manish
2013-05-21  8:54   ` Vishwanathrao Badarkhe, Manish
     [not found]   ` <1369126458-24872-2-git-send-email-manishv.b-l0cyMroinI0@public.gmane.org>
2013-06-10  6:04     ` Dmitry Torokhov
2013-06-10  6:04       ` Dmitry Torokhov
2013-06-10 10:23       ` Vishwanathrao Badarkhe, Manish
2013-06-10 18:03         ` Dmitry Torokhov
2013-06-12  6:53           ` Vishwanathrao Badarkhe, Manish
     [not found]             ` <A4887BF146CD57468F700B415D2F47015A1315-yXqyApvAXouIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2013-07-01 11:10               ` Manish Badarkhe
2013-07-29  6:17                 ` Manish Badarkhe
     [not found]                   ` <CAKDJKT500ewMEv-f-vZBkMELkFkNBXLrv0oS_qUivbq0T-Y6yA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-20  5:56                     ` Manish Badarkhe
2013-06-12 11:24   ` Grant Likely [this message]
2013-06-12 11:24     ` Grant Likely
2013-08-20  6:14   ` Prabhakar Lad
2013-08-20  6:55     ` Manish Badarkhe
2013-08-21 16:20       ` Dmitry Torokhov
2013-05-21  8:54 ` [PATCH V3 2/2] ARM: davinci: da850: add tps6507x touchscreen DT data Vishwanathrao Badarkhe, Manish
2013-05-21  8:54   ` Vishwanathrao Badarkhe, Manish
2013-05-31  6:04 ` [PATCH V3 0/2] Add DT support for tps6507x touchscreen Vishwanathrao Badarkhe, Manish

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=20130612112421.AF2F93E0A56@localhost \
    --to=grant.likely@secretlab.ca \
    --cc=davinci-linux-open-source@linux.davincidsp.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manishv.b@ti.com \
    --cc=rob.herring@calxeda.com \
    --cc=rob@landley.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 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.