linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Patil, Rachna" <rachna@ti.com>
To: <linux-kernel@vger.kernel.org>, <linux-input@vger.kernel.org>,
	<linux-iio@vger.kernel.org>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Dmitry Torokhov <dtor@mail.ru>,
	Jonathan Cameron <jic23@cam.ac.uk>,
	"Patil, Rachna" <rachna@ti.com>
Subject: [PATCH RESEND 2/8] input: TSC: ti_tscadc: Add Step configuration as platform data
Date: Tue, 16 Oct 2012 12:55:39 +0530	[thread overview]
Message-ID: <1350372345-27108-3-git-send-email-rachna@ti.com> (raw)
In-Reply-To: <1350372345-27108-1-git-send-email-rachna@ti.com>

There are 16 programmable Step Configuration
registers which are used by the sequencer.
Program the Steps in order to configure a channel
input to be sampled. If the same step is applied
several times, the coordinate values read are more
accurate.
Hence we provide the user an option of how many steps
should be configured.

For ex: If this value is assigned as 4, This means that
4 steps are applied to read x co-ordinate and 4 steps to read
y co-ordinate. Furtheron the interrupt handler already
holds code to use delta filter and report the best value
out of these values to the input sub-system.

Signed-off-by: Patil, Rachna <rachna@ti.com>
---
 drivers/input/touchscreen/ti_tscadc.c |   25 +++++++++++++------------
 include/linux/input/ti_tscadc.h       |    6 ++++++
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c
index d198cab..c1bd8e5 100644
--- a/drivers/input/touchscreen/ti_tscadc.c
+++ b/drivers/input/touchscreen/ti_tscadc.c
@@ -41,10 +41,6 @@
 #define REG_CHARGEDELAY		0x060
 #define REG_STEPCONFIG(n)	(0x64 + ((n - 1) * 8))
 #define REG_STEPDELAY(n)	(0x68 + ((n - 1) * 8))
-#define REG_STEPCONFIG13	0x0C4
-#define REG_STEPDELAY13		0x0C8
-#define REG_STEPCONFIG14	0x0CC
-#define REG_STEPDELAY14		0x0D0
 #define REG_FIFO0CNT		0xE4
 #define REG_FIFO1THR		0xF4
 #define REG_FIFO0		0x100
@@ -134,6 +130,7 @@ struct tscadc {
 	unsigned int		wires;
 	unsigned int		x_plate_resistance;
 	bool			pen_down;
+	int			steps_to_configure;
 };
 
 static unsigned int tscadc_readl(struct tscadc *ts, unsigned int reg)
@@ -150,9 +147,10 @@ static void tscadc_writel(struct tscadc *tsc, unsigned int reg,
 static void tscadc_step_config(struct tscadc *ts_dev)
 {
 	unsigned int	config;
-	int i;
+	int i, total_steps;
 
 	/* Configure the Step registers */
+	total_steps = 2 * ts_dev->steps_to_configure;
 
 	config = STEPCONFIG_MODE_HWSYNC |
 			STEPCONFIG_AVG_16 | STEPCONFIG_XPP;
@@ -170,7 +168,7 @@ static void tscadc_step_config(struct tscadc *ts_dev)
 		break;
 	}
 
-	for (i = 1; i < 7; i++) {
+	for (i = 1; i <= ts_dev->steps_to_configure; i++) {
 		tscadc_writel(ts_dev, REG_STEPCONFIG(i), config);
 		tscadc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY);
 	}
@@ -192,7 +190,7 @@ static void tscadc_step_config(struct tscadc *ts_dev)
 		break;
 	}
 
-	for (i = 7; i < 13; i++) {
+	for (i = (ts_dev->steps_to_configure + 1); i <= total_steps; i++) {
 		tscadc_writel(ts_dev, REG_STEPCONFIG(i), config);
 		tscadc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY);
 	}
@@ -211,12 +209,14 @@ static void tscadc_step_config(struct tscadc *ts_dev)
 	config = STEPCONFIG_MODE_HWSYNC |
 			STEPCONFIG_AVG_16 | STEPCONFIG_YPP |
 			STEPCONFIG_XNN | STEPCONFIG_INM_ADCREFM;
-	tscadc_writel(ts_dev, REG_STEPCONFIG13, config);
-	tscadc_writel(ts_dev, REG_STEPDELAY13, STEPCONFIG_OPENDLY);
+	tscadc_writel(ts_dev, REG_STEPCONFIG(total_steps + 1), config);
+	tscadc_writel(ts_dev, REG_STEPDELAY(total_steps + 1),
+			STEPCONFIG_OPENDLY);
 
 	config |= STEPCONFIG_INP_AN3 | STEPCONFIG_FIFO1;
-	tscadc_writel(ts_dev, REG_STEPCONFIG14, config);
-	tscadc_writel(ts_dev, REG_STEPDELAY14, STEPCONFIG_OPENDLY);
+	tscadc_writel(ts_dev, REG_STEPCONFIG(total_steps + 2), config);
+	tscadc_writel(ts_dev, REG_STEPDELAY(total_steps + 2),
+			STEPCONFIG_OPENDLY);
 
 	tscadc_writel(ts_dev, REG_SE, STPENB_STEPENB);
 }
@@ -379,6 +379,7 @@ static int __devinit tscadc_probe(struct platform_device *pdev)
 	ts_dev->irq = irq;
 	ts_dev->wires = pdata->wires;
 	ts_dev->x_plate_resistance = pdata->x_plate_resistance;
+	ts_dev->steps_to_configure = pdata->steps_to_configure;
 
 	res = request_mem_region(res->start, resource_size(res), pdev->name);
 	if (!res) {
@@ -447,7 +448,7 @@ static int __devinit tscadc_probe(struct platform_device *pdev)
 	tscadc_idle_config(ts_dev);
 	tscadc_writel(ts_dev, REG_IRQENABLE, IRQENB_FIFO1THRES);
 	tscadc_step_config(ts_dev);
-	tscadc_writel(ts_dev, REG_FIFO1THR, 6);
+	tscadc_writel(ts_dev, REG_FIFO1THR, ts_dev->steps_to_configure);
 
 	ctrl |= CNTRLREG_TSCSSENB;
 	tscadc_writel(ts_dev, REG_CTRL, ctrl);
diff --git a/include/linux/input/ti_tscadc.h b/include/linux/input/ti_tscadc.h
index b10a527..ad442a3 100644
--- a/include/linux/input/ti_tscadc.h
+++ b/include/linux/input/ti_tscadc.h
@@ -7,11 +7,17 @@
  *			i.e. 4/5/8 wire touchscreen support
  *			on the platform.
  * @x_plate_resistance:	X plate resistance.
+ * @steps_to_configure:	The sequencer supports a total of
+ *			16 programmable steps.
+ *			A step configured to read a single
+ *			co-ordinate value, can be applied
+ *			more number of times for better results.
  */
 
 struct tsc_data {
 	int wires;
 	int x_plate_resistance;
+	int steps_to_configure;
 };
 
 #endif
-- 
1.7.0.4


  parent reply	other threads:[~2012-10-16  7:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-16  7:25 [PATCH RESEND 0/8] TI Touchscreen driver updates and Support for TSC/ADC MFD driver Patil, Rachna
2012-10-16  7:25 ` [PATCH RESEND 1/8] input: TSC: ti_tscadc: Correct register usage Patil, Rachna
2012-10-16  7:25 ` Patil, Rachna [this message]
2012-10-16  7:25 ` [PATCH RESEND 3/8] input: TSC: ti_tscadc: set FIFO0 threshold Interrupt Patil, Rachna
2012-10-16  7:25 ` [PATCH RESEND 4/8] input: TSC: ti_tscadc: Remove definition of End Of Interrupt register Patil, Rachna
2012-10-16  7:25 ` [PATCH RESEND 5/8] input: TSC: ti_tscadc: Rename the existing touchscreen driver Patil, Rachna
2012-10-16  7:25 ` [PATCH RESEND 6/8] MFD: ti_tscadc: Add support for TI's TSC/ADC MFDevice Patil, Rachna
2012-10-16  7:25 ` [PATCH RESEND 7/8] input: TSC: ti_tsc: Convert TSC into a MFDevice Patil, Rachna
2012-10-16  7:25 ` [PATCH RESEND 8/8] IIO : ADC: tiadc: Add support of TI's ADC driver Patil, Rachna
2012-10-16 17:42 ` [PATCH RESEND 0/8] TI Touchscreen driver updates and Support for TSC/ADC MFD driver Dmitry Torokhov
2012-10-17  6:11   ` Patil, Rachna
2012-10-29  7:13   ` Patil, Rachna
2012-10-22 10:46 ` Patil, Rachna
2012-11-05 22:55 ` Samuel Ortiz
2012-11-06  4:47   ` Patil, Rachna

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=1350372345-27108-3-git-send-email-rachna@ti.com \
    --to=rachna@ti.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dtor@mail.ru \
    --cc=jic23@cam.ac.uk \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sameo@linux.intel.com \
    /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).