linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/6] Touchscreen performance related fixes
@ 2015-01-07  5:49 Vignesh R
  2015-01-07  5:49 ` [PATCH v6 1/6] input: touchscreen: ti_am335x_tsc Interchange touchscreen and ADC steps Vignesh R
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Vignesh R @ 2015-01-07  5:49 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Dmitry Torokhov, Lee Jones,
	Sebastian Andrzej Siewior
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Benoit Cousson, Tony Lindgren, Russell King, Lars-Peter Clausen,
	Peter Meerwald, Samuel Ortiz, Brad Griffis, Paul Gortmaker,
	Sanjeev Sharma, Jan Kardell, Felipe Balbi, Wolfram Sang,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-input-u79uwXL29TY76Z2rM5mHXA, Vignesh R

This series is rebase of v4 onto v3.19-rc1. It also fixes concerns
expressed on v4 wrt simultaneous use of IIO and TSC.

I have tested this patch series on am335x-evm and Beaglebone black
with lcd7-cape.

Note that, these patches do not work as expected on Beaglebone Black
with BB-View 4.3 Cape from Farnell due to a hardware issue in the cape.

Change log:
v6:
 - Reorder patch 4 and 5.

v5:
 - Rebased onto v3.19-rc1
 - minor changes in patch 2,3 and 5.

v3:
 - Replace delta filtering logic in TSC driver with median filtering
   as suggested by Richard.
 - Addressed Lee Jones comments.

v2:
 - Addressed comments by Hartmut Knaack
 - patch 2 was split into two as per Lee Jones comment

Brad Griffis (2):
  input: touchscreen: ti_am335x_tsc Interchange touchscreen and ADC
    steps
  input: touchscreen: ti_am335x_tsc: Remove udelay in interrupt handler

Vignesh R (4):
  mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save
  input: touchscreen: ti_am335x_tsc: Read charge delay from DT
  ARM: dts: AM335x: Make charge delay a DT parameter for TSC
  input: touchscreen: ti_am335x_tsc: Replace delta filtering with median
    filtering

 .../bindings/input/touchscreen/ti-tsc-adc.txt      |  15 ++
 arch/arm/boot/dts/am335x-evm.dts                   |   1 +
 drivers/iio/adc/ti_am335x_adc.c                    |   5 +-
 drivers/input/touchscreen/ti_am335x_tsc.c          | 197 ++++++++++++---------
 drivers/mfd/ti_am335x_tscadc.c                     |  13 +-
 include/linux/mfd/ti_am335x_tscadc.h               |   4 +-
 6 files changed, 137 insertions(+), 98 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v6 1/6] input: touchscreen: ti_am335x_tsc Interchange touchscreen and ADC steps
  2015-01-07  5:49 [PATCH v6 0/6] Touchscreen performance related fixes Vignesh R
@ 2015-01-07  5:49 ` Vignesh R
  2015-01-07  5:49 ` [PATCH v6 2/6] input: touchscreen: ti_am335x_tsc: Remove udelay in interrupt handler Vignesh R
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: Vignesh R @ 2015-01-07  5:49 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Dmitry Torokhov, Lee Jones,
	Sebastian Andrzej Siewior
  Cc: Mark Rutland, Vignesh R, Wolfram Sang, linux-iio, Paul Gortmaker,
	Peter Meerwald, Lars-Peter Clausen, Russell King, Jan Kardell,
	Tony Lindgren, linux-input, Sanjeev Sharma, devicetree,
	Brad Griffis, Pawel Moll, Ian Campbell, Rob Herring, linux-omap,
	linux-arm-kernel, Samuel Ortiz, linux-kernel, Felipe Balbi,
	Benoit Cousson, Kumar Gala

From: Brad Griffis <bgriffis@ti.com>

This patch makes the initial changes required to workaround TSC-false
pen-up interrupts. It is required to implement these changes in order to
remove udelay in the TSC interrupt handler and false pen-up events.
The charge step is to be executed immediately after sampling X+. Hence
TSC is made to use higher numbered steps (steps 5 to 16 for 5 co-ordinate
readouts, 4 wire TSC configuration) and ADC to use lower ones. Further
X co-ordinate readouts must be the last to be sampled, thus co-ordinates
are sampled in the order Y-Z-X.

Signed-off-by: Brad Griffis <bgriffis@ti.com>
[vigneshr@ti.com: Ported the patch from v3.12 to v3.19rc1]

Signed-off-by: Vignesh R <vigneshr@ti.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
---
 drivers/iio/adc/ti_am335x_adc.c           |  5 ++--
 drivers/input/touchscreen/ti_am335x_tsc.c | 42 ++++++++++++++++++-------------
 2 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index b730864731e8..adba23246474 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -86,19 +86,18 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
 {
 	struct tiadc_device *adc_dev = iio_priv(indio_dev);
 	unsigned int stepconfig;
-	int i, steps;
+	int i, steps = 0;
 
 	/*
 	 * There are 16 configurable steps and 8 analog input
 	 * lines available which are shared between Touchscreen and ADC.
 	 *
-	 * Steps backwards i.e. from 16 towards 0 are used by ADC
+	 * Steps forwards i.e. from 0 towards 16 are used by ADC
 	 * depending on number of input lines needed.
 	 * Channel would represent which analog input
 	 * needs to be given to ADC to digitalize data.
 	 */
 
-	steps = TOTAL_STEPS - adc_dev->channels;
 	if (iio_buffer_enabled(indio_dev))
 		stepconfig = STEPCONFIG_AVG_16 | STEPCONFIG_FIFO1
 					| STEPCONFIG_MODE_SWCNT;
diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index 004f1346a957..dfbb9fe6a270 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -121,7 +121,7 @@ static void titsc_step_config(struct titsc *ts_dev)
 {
 	unsigned int	config;
 	int i;
-	int end_step;
+	int end_step, first_step, tsc_steps;
 	u32 stepenable;
 
 	config = STEPCONFIG_MODE_HWSYNC |
@@ -140,9 +140,11 @@ static void titsc_step_config(struct titsc *ts_dev)
 		break;
 	}
 
-	/* 1 … coordinate_readouts is for X */
-	end_step = ts_dev->coordinate_readouts;
-	for (i = 0; i < end_step; i++) {
+	tsc_steps = ts_dev->coordinate_readouts * 2 + 2;
+	first_step = TOTAL_STEPS - tsc_steps;
+	/* Steps 16 to 16-coordinate_readouts is for X */
+	end_step = first_step + tsc_steps;
+	for (i = end_step - ts_dev->coordinate_readouts; i < end_step; i++) {
 		titsc_writel(ts_dev, REG_STEPCONFIG(i), config);
 		titsc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY);
 	}
@@ -164,9 +166,9 @@ static void titsc_step_config(struct titsc *ts_dev)
 		break;
 	}
 
-	/* coordinate_readouts … coordinate_readouts * 2 is for Y */
-	end_step = ts_dev->coordinate_readouts * 2;
-	for (i = ts_dev->coordinate_readouts; i < end_step; i++) {
+	/* 1 ... coordinate_readouts is for Y */
+	end_step = first_step + ts_dev->coordinate_readouts;
+	for (i = first_step; i < end_step; i++) {
 		titsc_writel(ts_dev, REG_STEPCONFIG(i), config);
 		titsc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY);
 	}
@@ -179,7 +181,7 @@ static void titsc_step_config(struct titsc *ts_dev)
 	titsc_writel(ts_dev, REG_CHARGECONFIG, config);
 	titsc_writel(ts_dev, REG_CHARGEDELAY, CHARGEDLY_OPENDLY);
 
-	/* coordinate_readouts * 2 … coordinate_readouts * 2 + 2 is for Z */
+	/* coordinate_readouts + 1 ... coordinate_readouts + 2 is for Z */
 	config = STEPCONFIG_MODE_HWSYNC |
 			STEPCONFIG_AVG_16 | ts_dev->bit_yp |
 			ts_dev->bit_xn | STEPCONFIG_INM_ADCREFM |
@@ -194,8 +196,11 @@ static void titsc_step_config(struct titsc *ts_dev)
 	titsc_writel(ts_dev, REG_STEPDELAY(end_step),
 			STEPCONFIG_OPENDLY);
 
-	/* The steps1 … end and bit 0 for TS_Charge */
-	stepenable = (1 << (end_step + 2)) - 1;
+	/* The steps end ... end - readouts * 2 + 2 and bit 0 for TS_Charge */
+	stepenable = 1;
+	for (i = 0; i < tsc_steps; i++)
+		stepenable |= 1 << (first_step + i + 1);
+
 	ts_dev->step_mask = stepenable;
 	am335x_tsc_se_set_cache(ts_dev->mfd_tscadc, ts_dev->step_mask);
 }
@@ -209,6 +214,7 @@ static void titsc_read_coordinates(struct titsc *ts_dev,
 	unsigned int read, diff;
 	unsigned int i, channel;
 	unsigned int creads = ts_dev->coordinate_readouts;
+	unsigned int first_step = TOTAL_STEPS - (creads * 2 + 2);
 
 	*z1 = *z2 = 0;
 	if (fifocount % (creads * 2 + 2))
@@ -226,7 +232,7 @@ static void titsc_read_coordinates(struct titsc *ts_dev,
 
 		channel = (read & 0xf0000) >> 16;
 		read &= 0xfff;
-		if (channel < creads) {
+		if (channel > first_step + creads + 2) {
 			diff = abs(read - prev_val_x);
 			if (diff < prev_diff_x) {
 				prev_diff_x = diff;
@@ -234,19 +240,19 @@ static void titsc_read_coordinates(struct titsc *ts_dev,
 			}
 			prev_val_x = read;
 
-		} else if (channel < creads * 2) {
+		} else if (channel == first_step + creads + 1) {
+			*z1 = read;
+
+		} else if (channel == first_step + creads + 2) {
+			*z2 = read;
+
+		} else if (channel > first_step) {
 			diff = abs(read - prev_val_y);
 			if (diff < prev_diff_y) {
 				prev_diff_y = diff;
 				*y = read;
 			}
 			prev_val_y = read;
-
-		} else if (channel < creads * 2 + 1) {
-			*z1 = read;
-
-		} else if (channel < creads * 2 + 2) {
-			*z2 = read;
 		}
 	}
 }
-- 
1.9.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 2/6] input: touchscreen: ti_am335x_tsc: Remove udelay in interrupt handler
  2015-01-07  5:49 [PATCH v6 0/6] Touchscreen performance related fixes Vignesh R
  2015-01-07  5:49 ` [PATCH v6 1/6] input: touchscreen: ti_am335x_tsc Interchange touchscreen and ADC steps Vignesh R
@ 2015-01-07  5:49 ` Vignesh R
  2015-01-30  5:26   ` Vignesh R
  2015-01-07  5:49 ` [PATCH v6 3/6] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save Vignesh R
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Vignesh R @ 2015-01-07  5:49 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Dmitry Torokhov, Lee Jones,
	Sebastian Andrzej Siewior
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Benoit Cousson, Tony Lindgren, Russell King, Lars-Peter Clausen,
	Peter Meerwald, Samuel Ortiz, Brad Griffis, Paul Gortmaker,
	Sanjeev Sharma, Jan Kardell, Felipe Balbi, Wolfram Sang,
	devicetree, linux-kernel, linux-omap, linux-arm-kernel, linux-iio,
	linux-input, Vignesh R

From: Brad Griffis <bgriffis@ti.com>

TSC interrupt handler had udelay to avoid reporting of false pen-up
interrupt to user space. This patch implements workaround suggesting in
Advisory 1.0.31 of silicon errata for am335x, thus eliminating udelay
and touchscreen lag. This also improves performance of touchscreen and
eliminates sudden jump of cursor at touch release.

IDLECONFIG and CHARGECONFIG registers are to be configured
with same values in order to eliminate false pen-up events. This
workaround may result in false pen-down to be detected, hence considerable
charge step delay needs to be added. The charge delay is set to 0xB000
(in terms of ADC clock cycles) by default.

TSC steps are disabled at the end of every sampling cycle and EOS bit is
set. Once the EOS bit is set, the TSC steps need to be re-enabled to begin
next sampling cycle.

Signed-off-by: Brad Griffis <bgriffis@ti.com>
[vigneshr@ti.com: Ported the patch from v3.12 to v3.19rc1]

Signed-off-by: Vignesh R <vigneshr@ti.com>
---
v5:
 - enable TSC steps only on EOS interrup

v4:
 - check for PEN_IRQ bit in ADCFSM to avoid false-pen when ADC
   and TSC are used together.
 - Set charge delay to 0x400 as default. Most devices function
   normally at this value.

 drivers/input/touchscreen/ti_am335x_tsc.c | 67 ++++++++++++++-----------------
 include/linux/mfd/ti_am335x_tscadc.h      |  3 +-
 2 files changed, 33 insertions(+), 37 deletions(-)

diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index dfbb9fe6a270..0625c102a1d0 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -173,11 +173,9 @@ static void titsc_step_config(struct titsc *ts_dev)
 		titsc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY);
 	}
 
-	/* Charge step configuration */
-	config = ts_dev->bit_xp | ts_dev->bit_yn |
-			STEPCHARGE_RFP_XPUL | STEPCHARGE_RFM_XNUR |
-			STEPCHARGE_INM_AN1 | STEPCHARGE_INP(ts_dev->inp_yp);
+	/* Make CHARGECONFIG same as IDLECONFIG */
 
+	config = titsc_readl(ts_dev, REG_IDLECONFIG);
 	titsc_writel(ts_dev, REG_CHARGECONFIG, config);
 	titsc_writel(ts_dev, REG_CHARGEDELAY, CHARGEDLY_OPENDLY);
 
@@ -261,12 +259,34 @@ static irqreturn_t titsc_irq(int irq, void *dev)
 {
 	struct titsc *ts_dev = dev;
 	struct input_dev *input_dev = ts_dev->input;
-	unsigned int status, irqclr = 0;
+	unsigned int fsm, status, irqclr = 0;
 	unsigned int x = 0, y = 0;
 	unsigned int z1, z2, z;
-	unsigned int fsm;
 
-	status = titsc_readl(ts_dev, REG_IRQSTATUS);
+	status = titsc_readl(ts_dev, REG_RAWIRQSTATUS);
+	if (status & IRQENB_HW_PEN) {
+		ts_dev->pen_down = true;
+		titsc_writel(ts_dev, REG_IRQWAKEUP, 0x00);
+		titsc_writel(ts_dev, REG_IRQCLR, IRQENB_HW_PEN);
+		irqclr |= IRQENB_HW_PEN;
+	}
+
+	if (status & IRQENB_PENUP) {
+		fsm = titsc_readl(ts_dev, REG_ADCFSM);
+		if (fsm == ADCFSM_STEPID) {
+			ts_dev->pen_down = false;
+			input_report_key(input_dev, BTN_TOUCH, 0);
+			input_report_abs(input_dev, ABS_PRESSURE, 0);
+			input_sync(input_dev);
+		} else {
+			ts_dev->pen_down = true;
+		}
+		irqclr |= IRQENB_PENUP;
+	}
+
+	if (status & IRQENB_EOS)
+		irqclr |= IRQENB_EOS;
+
 	/*
 	 * ADC and touchscreen share the IRQ line.
 	 * FIFO1 interrupts are used by ADC. Handle FIFO0 IRQs here only
@@ -297,37 +317,11 @@ static irqreturn_t titsc_irq(int irq, void *dev)
 		}
 		irqclr |= IRQENB_FIFO0THRES;
 	}
-
-	/*
-	 * Time for sequencer to settle, to read
-	 * correct state of the sequencer.
-	 */
-	udelay(SEQ_SETTLE);
-
-	status = titsc_readl(ts_dev, REG_RAWIRQSTATUS);
-	if (status & IRQENB_PENUP) {
-		/* Pen up event */
-		fsm = titsc_readl(ts_dev, REG_ADCFSM);
-		if (fsm == ADCFSM_STEPID) {
-			ts_dev->pen_down = false;
-			input_report_key(input_dev, BTN_TOUCH, 0);
-			input_report_abs(input_dev, ABS_PRESSURE, 0);
-			input_sync(input_dev);
-		} else {
-			ts_dev->pen_down = true;
-		}
-		irqclr |= IRQENB_PENUP;
-	}
-
-	if (status & IRQENB_HW_PEN) {
-
-		titsc_writel(ts_dev, REG_IRQWAKEUP, 0x00);
-		titsc_writel(ts_dev, REG_IRQCLR, IRQENB_HW_PEN);
-	}
-
 	if (irqclr) {
 		titsc_writel(ts_dev, REG_IRQSTATUS, irqclr);
-		am335x_tsc_se_set_cache(ts_dev->mfd_tscadc, ts_dev->step_mask);
+		if (status & IRQENB_EOS)
+			am335x_tsc_se_set_cache(ts_dev->mfd_tscadc,
+						ts_dev->step_mask);
 		return IRQ_HANDLED;
 	}
 	return IRQ_NONE;
@@ -417,6 +411,7 @@ static int titsc_probe(struct platform_device *pdev)
 	}
 
 	titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_FIFO0THRES);
+	titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_EOS);
 	err = titsc_config_wires(ts_dev);
 	if (err) {
 		dev_err(&pdev->dev, "wrong i/p wire configuration\n");
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
index e2e70053470e..3f4e994ace2b 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -52,6 +52,7 @@
 
 /* IRQ enable */
 #define IRQENB_HW_PEN		BIT(0)
+#define IRQENB_EOS		BIT(1)
 #define IRQENB_FIFO0THRES	BIT(2)
 #define IRQENB_FIFO0OVRRUN	BIT(3)
 #define IRQENB_FIFO0UNDRFLW	BIT(4)
@@ -107,7 +108,7 @@
 /* Charge delay */
 #define CHARGEDLY_OPEN_MASK	(0x3FFFF << 0)
 #define CHARGEDLY_OPEN(val)	((val) << 0)
-#define CHARGEDLY_OPENDLY	CHARGEDLY_OPEN(1)
+#define CHARGEDLY_OPENDLY	CHARGEDLY_OPEN(0x400)
 
 /* Control register */
 #define CNTRLREG_TSCSSENB	BIT(0)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 3/6] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save
  2015-01-07  5:49 [PATCH v6 0/6] Touchscreen performance related fixes Vignesh R
  2015-01-07  5:49 ` [PATCH v6 1/6] input: touchscreen: ti_am335x_tsc Interchange touchscreen and ADC steps Vignesh R
  2015-01-07  5:49 ` [PATCH v6 2/6] input: touchscreen: ti_am335x_tsc: Remove udelay in interrupt handler Vignesh R
@ 2015-01-07  5:49 ` Vignesh R
       [not found]   ` <1420609779-11156-4-git-send-email-vigneshr-l0cyMroinI0@public.gmane.org>
  2015-02-25  7:17   ` Lee Jones
  2015-01-07  5:49 ` [PATCH v6 4/6] input: touchscreen: ti_am335x_tsc: Read charge delay from DT Vignesh R
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 16+ messages in thread
From: Vignesh R @ 2015-01-07  5:49 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Dmitry Torokhov, Lee Jones,
	Sebastian Andrzej Siewior
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Benoit Cousson, Tony Lindgren, Russell King, Lars-Peter Clausen,
	Peter Meerwald, Samuel Ortiz, Brad Griffis, Paul Gortmaker,
	Sanjeev Sharma, Jan Kardell, Felipe Balbi, Wolfram Sang,
	devicetree, linux-kernel, linux-omap, linux-arm-kernel, linux-iio,
	linux-input, Vignesh R

In one shot mode, sequencer automatically disables all enabled steps at
the end of each cycle. (both ADC steps and TSC steps) Hence these steps
need not be saved in reg_se_cache for clearing these steps at a later
stage.
Also, when ADC wakes up Sequencer should not be busy executing any of the
config steps except for the charge step. Previously charge step was 1 ADC
clock cycle and hence it was ignored.
TSC steps are always disabled at the end of each conversion cycle, hence
there is no need to explicitly disable TSC steps by writing 0 to REG_SE.

Signed-off-by: Vignesh R <vigneshr@ti.com>
---

v5:
 - Remove unnecessary clearing of REG_SE

 drivers/mfd/ti_am335x_tscadc.c       | 13 +++++--------
 include/linux/mfd/ti_am335x_tscadc.h |  1 +
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 467c80e1c4ae..e4e4b22eebc9 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -68,12 +68,6 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
 	DEFINE_WAIT(wait);
 	u32 reg;
 
-	/*
-	 * disable TSC steps so it does not run while the ADC is using it. If
-	 * write 0 while it is running (it just started or was already running)
-	 * then it completes all steps that were enabled and stops then.
-	 */
-	tscadc_writel(tsadc, REG_SE, 0);
 	reg = tscadc_readl(tsadc, REG_ADCFSM);
 	if (reg & SEQ_STATUS) {
 		tsadc->adc_waiting = true;
@@ -86,8 +80,12 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
 		spin_lock_irq(&tsadc->reg_lock);
 		finish_wait(&tsadc->reg_se_wait, &wait);
 
+		/*
+		 * Sequencer should either be idle or
+		 * busy applying the charge step.
+		 */
 		reg = tscadc_readl(tsadc, REG_ADCFSM);
-		WARN_ON(reg & SEQ_STATUS);
+		WARN_ON((reg & SEQ_STATUS) && !(reg & CHARGE_STEP));
 		tsadc->adc_waiting = false;
 	}
 	tsadc->adc_in_use = true;
@@ -96,7 +94,6 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
 void am335x_tsc_se_set_once(struct ti_tscadc_dev *tsadc, u32 val)
 {
 	spin_lock_irq(&tsadc->reg_lock);
-	tsadc->reg_se_cache |= val;
 	am335x_tscadc_need_adc(tsadc);
 
 	tscadc_writel(tsadc, REG_SE, val);
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
index 3f4e994ace2b..1fd50dcfe47c 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -128,6 +128,7 @@
 
 /* Sequencer Status */
 #define SEQ_STATUS BIT(5)
+#define CHARGE_STEP		0x11
 
 #define ADC_CLK			3000000
 #define TOTAL_STEPS		16
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 4/6] input: touchscreen: ti_am335x_tsc: Read charge delay from DT
  2015-01-07  5:49 [PATCH v6 0/6] Touchscreen performance related fixes Vignesh R
                   ` (2 preceding siblings ...)
  2015-01-07  5:49 ` [PATCH v6 3/6] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save Vignesh R
@ 2015-01-07  5:49 ` Vignesh R
  2015-01-07  5:49 ` [PATCH v6 5/6] ARM: dts: AM335x: Make charge delay a DT parameter for TSC Vignesh R
  2015-01-07  5:49 ` [PATCH v6 6/6] input: touchscreen: ti_am335x_tsc: Replace delta filtering with median filtering Vignesh R
  5 siblings, 0 replies; 16+ messages in thread
From: Vignesh R @ 2015-01-07  5:49 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Dmitry Torokhov, Lee Jones,
	Sebastian Andrzej Siewior
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Benoit Cousson, Tony Lindgren, Russell King, Lars-Peter Clausen,
	Peter Meerwald, Samuel Ortiz, Brad Griffis, Paul Gortmaker,
	Sanjeev Sharma, Jan Kardell, Felipe Balbi, Wolfram Sang,
	devicetree, linux-kernel, linux-omap, linux-arm-kernel, linux-iio,
	linux-input, Vignesh R

This patch reads charge delay from tsc DT node and writes to
REG_CHARGEDELAY register. If the charge delay is not specified in DT
then default value of 0x400(CHARGEDLY_OPENDLY) is used.

Signed-off-by: Vignesh R <vigneshr@ti.com>
---

v6:
 - Move Documentation from DT patch to 	driver code. 

v5:
 - print out a warning when ti,charge-delay is not specified

v4:
 - Set charge delay to 0x400 as default. Most devices function normally
   at this value

 .../devicetree/bindings/input/touchscreen/ti-tsc-adc.txt  | 15 +++++++++++++++
 drivers/input/touchscreen/ti_am335x_tsc.c                 | 14 +++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt b/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
index 878549ba814d..6c4fb34823d3 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
@@ -28,6 +28,20 @@ Required properties:
 	ti,adc-channels: List of analog inputs available for ADC.
 			 AIN0 = 0, AIN1 = 1 and so on till AIN7 = 7.
 
+Optional properties:
+- child "tsc"
+	ti,charge-delay: Length of touch screen charge delay step in terms of
+			 ADC clock cycles. Charge delay value should be large
+			 in order to avoid false pen-up events. This value
+			 effects the overall sampling speed, hence need to be
+			 kept as low as possible, while avoiding false pen-up
+			 event. Start from a lower value, say 0x400, and
+			 increase value until false pen-up events are avoided.
+			 The pen-up detection happens immediately after the
+			 charge step, so this does in fact function as a
+			 hardware knob for adjusting the amount of "settling
+			 time".
+
 Example:
 	tscadc: tscadc@44e0d000 {
 		compatible = "ti,am3359-tscadc";
@@ -36,6 +50,7 @@ Example:
 			ti,x-plate-resistance = <200>;
 			ti,coordiante-readouts = <5>;
 			ti,wire-config = <0x00 0x11 0x22 0x33>;
+			ti,charge-delay = <0x400>;
 		};
 
 		adc {
diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index 0625c102a1d0..7c0f6b21559d 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -52,6 +52,7 @@ struct titsc {
 	u32			bit_xp, bit_xn, bit_yp, bit_yn;
 	u32			inp_xp, inp_xn, inp_yp, inp_yn;
 	u32			step_mask;
+	u32			charge_delay;
 };
 
 static unsigned int titsc_readl(struct titsc *ts, unsigned int reg)
@@ -177,7 +178,7 @@ static void titsc_step_config(struct titsc *ts_dev)
 
 	config = titsc_readl(ts_dev, REG_IDLECONFIG);
 	titsc_writel(ts_dev, REG_CHARGECONFIG, config);
-	titsc_writel(ts_dev, REG_CHARGEDELAY, CHARGEDLY_OPENDLY);
+	titsc_writel(ts_dev, REG_CHARGEDELAY, ts_dev->charge_delay);
 
 	/* coordinate_readouts + 1 ... coordinate_readouts + 2 is for Z */
 	config = STEPCONFIG_MODE_HWSYNC |
@@ -368,6 +369,17 @@ static int titsc_parse_dt(struct platform_device *pdev,
 	if (err < 0)
 		return err;
 
+	err = of_property_read_u32(node, "ti,charge-delay",
+				   &ts_dev->charge_delay);
+	/*
+	 * If ti,charge-delay value is not specified, then use
+	 * CHARGEDLY_OPENDLY as the default value.
+	 */
+	if (err < 0) {
+		ts_dev->charge_delay = CHARGEDLY_OPENDLY;
+		dev_warn(&pdev->dev, "ti,charge-delay not specified\n");
+	}
+
 	return of_property_read_u32_array(node, "ti,wire-config",
 			ts_dev->config_inp, ARRAY_SIZE(ts_dev->config_inp));
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 5/6] ARM: dts: AM335x: Make charge delay a DT parameter for TSC
  2015-01-07  5:49 [PATCH v6 0/6] Touchscreen performance related fixes Vignesh R
                   ` (3 preceding siblings ...)
  2015-01-07  5:49 ` [PATCH v6 4/6] input: touchscreen: ti_am335x_tsc: Read charge delay from DT Vignesh R
@ 2015-01-07  5:49 ` Vignesh R
  2015-01-07  5:49 ` [PATCH v6 6/6] input: touchscreen: ti_am335x_tsc: Replace delta filtering with median filtering Vignesh R
  5 siblings, 0 replies; 16+ messages in thread
From: Vignesh R @ 2015-01-07  5:49 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Dmitry Torokhov, Lee Jones,
	Sebastian Andrzej Siewior
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Benoit Cousson, Tony Lindgren, Russell King, Lars-Peter Clausen,
	Peter Meerwald, Samuel Ortiz, Brad Griffis, Paul Gortmaker,
	Sanjeev Sharma, Jan Kardell, Felipe Balbi, Wolfram Sang,
	devicetree, linux-kernel, linux-omap, linux-arm-kernel, linux-iio,
	linux-input, Vignesh R

The charge delay value is by default 0x400. But it can be set to lower
values on some boards, as long as false pen-ups are avoided. Lowering the
value increases the sampling rate (though current sampling rate is
sufficient for TSC operation). In some boards, the value has to be
increased to avoid false pen-up events. Hence, charge delay has been
made a DT parameter.

Signed-off-by: Vignesh R <vigneshr@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/boot/dts/am335x-evm.dts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts
index 54f118c08db8..66342515df20 100644
--- a/arch/arm/boot/dts/am335x-evm.dts
+++ b/arch/arm/boot/dts/am335x-evm.dts
@@ -648,6 +648,7 @@
 		ti,x-plate-resistance = <200>;
 		ti,coordinate-readouts = <5>;
 		ti,wire-config = <0x00 0x11 0x22 0x33>;
+		ti,charge-delay = <0x400>;
 	};
 
 	adc {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 6/6] input: touchscreen: ti_am335x_tsc: Replace delta filtering with median filtering
  2015-01-07  5:49 [PATCH v6 0/6] Touchscreen performance related fixes Vignesh R
                   ` (4 preceding siblings ...)
  2015-01-07  5:49 ` [PATCH v6 5/6] ARM: dts: AM335x: Make charge delay a DT parameter for TSC Vignesh R
@ 2015-01-07  5:49 ` Vignesh R
  5 siblings, 0 replies; 16+ messages in thread
From: Vignesh R @ 2015-01-07  5:49 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Dmitry Torokhov, Lee Jones,
	Sebastian Andrzej Siewior
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Benoit Cousson, Tony Lindgren, Russell King, Lars-Peter Clausen,
	Peter Meerwald, Samuel Ortiz, Brad Griffis, Paul Gortmaker,
	Sanjeev Sharma, Jan Kardell, Felipe Balbi, Wolfram Sang,
	devicetree, linux-kernel, linux-omap, linux-arm-kernel, linux-iio,
	linux-input, Vignesh R

Previously, delta filtering was applied TSC co-ordinate readouts before
reporting a single value to user space. This patch replaces delta filtering
with median filtering. Median filtering sorts co-ordinate readouts, drops min
and max values, and reports the average of remaining values. This method is
more sensible than delta filering. Median filtering is applied only if number
of readouts is greater than 3 else just average of co-ordinate readouts is
reported.

Signed-off-by: Vignesh R <vigneshr@ti.com>
---
 drivers/input/touchscreen/ti_am335x_tsc.c | 92 +++++++++++++++++--------------
 1 file changed, 52 insertions(+), 40 deletions(-)

diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index 7c0f6b21559d..191a1b87895f 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -26,6 +26,7 @@
 #include <linux/delay.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/sort.h>
 
 #include <linux/mfd/ti_am335x_tscadc.h>
 
@@ -204,56 +205,61 @@ static void titsc_step_config(struct titsc *ts_dev)
 	am335x_tsc_se_set_cache(ts_dev->mfd_tscadc, ts_dev->step_mask);
 }
 
+static int titsc_cmp_coord(const void *a, const void *b)
+{
+	return *(int *)a - *(int *)b;
+}
+
 static void titsc_read_coordinates(struct titsc *ts_dev,
 		u32 *x, u32 *y, u32 *z1, u32 *z2)
 {
-	unsigned int fifocount = titsc_readl(ts_dev, REG_FIFO0CNT);
-	unsigned int prev_val_x = ~0, prev_val_y = ~0;
-	unsigned int prev_diff_x = ~0, prev_diff_y = ~0;
-	unsigned int read, diff;
-	unsigned int i, channel;
+	unsigned int yvals[7], xvals[7];
+	unsigned int i, xsum = 0, ysum = 0;
 	unsigned int creads = ts_dev->coordinate_readouts;
-	unsigned int first_step = TOTAL_STEPS - (creads * 2 + 2);
 
-	*z1 = *z2 = 0;
-	if (fifocount % (creads * 2 + 2))
-		fifocount -= fifocount % (creads * 2 + 2);
-	/*
-	 * Delta filter is used to remove large variations in sampled
-	 * values from ADC. The filter tries to predict where the next
-	 * coordinate could be. This is done by taking a previous
-	 * coordinate and subtracting it form current one. Further the
-	 * algorithm compares the difference with that of a present value,
-	 * if true the value is reported to the sub system.
-	 */
-	for (i = 0; i < fifocount; i++) {
-		read = titsc_readl(ts_dev, REG_FIFO0);
-
-		channel = (read & 0xf0000) >> 16;
-		read &= 0xfff;
-		if (channel > first_step + creads + 2) {
-			diff = abs(read - prev_val_x);
-			if (diff < prev_diff_x) {
-				prev_diff_x = diff;
-				*x = read;
-			}
-			prev_val_x = read;
+	for (i = 0; i < creads; i++) {
+		yvals[i] = titsc_readl(ts_dev, REG_FIFO0);
+		yvals[i] &= 0xfff;
+	}
 
-		} else if (channel == first_step + creads + 1) {
-			*z1 = read;
+	*z1 = titsc_readl(ts_dev, REG_FIFO0);
+	*z1 &= 0xfff;
+	*z2 = titsc_readl(ts_dev, REG_FIFO0);
+	*z2 &= 0xfff;
 
-		} else if (channel == first_step + creads + 2) {
-			*z2 = read;
+	for (i = 0; i < creads; i++) {
+		xvals[i] = titsc_readl(ts_dev, REG_FIFO0);
+		xvals[i] &= 0xfff;
+	}
 
-		} else if (channel > first_step) {
-			diff = abs(read - prev_val_y);
-			if (diff < prev_diff_y) {
-				prev_diff_y = diff;
-				*y = read;
-			}
-			prev_val_y = read;
+	/*
+	 * If co-ordinates readouts is less than 4 then
+	 * report the average. In case of 4 or more
+	 * readouts, sort the co-ordinate samples, drop
+	 * min and max values and report the average of
+	 * remaining values.
+	 */
+	if (creads <=  3) {
+		for (i = 0; i < creads; i++) {
+			ysum += yvals[i];
+			xsum += xvals[i];
 		}
+		ysum /= creads;
+		xsum /= creads;
+	} else {
+		sort(yvals, creads, sizeof(unsigned int),
+		     titsc_cmp_coord, NULL);
+		sort(xvals, creads, sizeof(unsigned int),
+		     titsc_cmp_coord, NULL);
+		for (i = 1; i < creads - 1; i++) {
+			ysum += yvals[i];
+			xsum += xvals[i];
+		}
+		ysum /= creads - 2;
+		xsum /= creads - 2;
 	}
+	*y = ysum;
+	*x = xsum;
 }
 
 static irqreturn_t titsc_irq(int irq, void *dev)
@@ -369,6 +375,12 @@ static int titsc_parse_dt(struct platform_device *pdev,
 	if (err < 0)
 		return err;
 
+	if (ts_dev->coordinate_readouts <= 0) {
+		dev_warn(&pdev->dev,
+			 "invalid co-ordinate readouts, resetting it to 5\n");
+		ts_dev->coordinate_readouts = 5;
+	}
+
 	err = of_property_read_u32(node, "ti,charge-delay",
 				   &ts_dev->charge_delay);
 	/*
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 3/6] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save
       [not found]   ` <1420609779-11156-4-git-send-email-vigneshr-l0cyMroinI0@public.gmane.org>
@ 2015-01-20 11:53     ` Lee Jones
  2015-01-20 12:40       ` R, Vignesh
  0 siblings, 1 reply; 16+ messages in thread
From: Lee Jones @ 2015-01-20 11:53 UTC (permalink / raw)
  To: Vignesh R
  Cc: Jonathan Cameron, Hartmut Knaack, Dmitry Torokhov,
	Sebastian Andrzej Siewior, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Benoit Cousson, Tony Lindgren,
	Russell King, Lars-Peter Clausen, Peter Meerwald, Samuel Ortiz,
	Brad Griffis, Paul Gortmaker, Sanjeev Sharma, Jan Kardell,
	Felipe Balbi, Wolfram Sang, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-omap

On Wed, 07 Jan 2015, Vignesh R wrote:

> In one shot mode, sequencer automatically disables all enabled steps at
> the end of each cycle. (both ADC steps and TSC steps) Hence these steps
> need not be saved in reg_se_cache for clearing these steps at a later
> stage.
> Also, when ADC wakes up Sequencer should not be busy executing any of the
> config steps except for the charge step. Previously charge step was 1 ADC
> clock cycle and hence it was ignored.
> TSC steps are always disabled at the end of each conversion cycle, hence
> there is no need to explicitly disable TSC steps by writing 0 to REG_SE.
> 
> Signed-off-by: Vignesh R <vigneshr-l0cyMroinI0@public.gmane.org>
> ---
> 
> v5:
>  - Remove unnecessary clearing of REG_SE
> 
>  drivers/mfd/ti_am335x_tscadc.c       | 13 +++++--------
>  include/linux/mfd/ti_am335x_tscadc.h |  1 +
>  2 files changed, 6 insertions(+), 8 deletions(-)

Looks fine.

For my own reference:
  Acked-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Can this patch be applied on its own?

> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 467c80e1c4ae..e4e4b22eebc9 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -68,12 +68,6 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
>  	DEFINE_WAIT(wait);
>  	u32 reg;
>  
> -	/*
> -	 * disable TSC steps so it does not run while the ADC is using it. If
> -	 * write 0 while it is running (it just started or was already running)
> -	 * then it completes all steps that were enabled and stops then.
> -	 */
> -	tscadc_writel(tsadc, REG_SE, 0);
>  	reg = tscadc_readl(tsadc, REG_ADCFSM);
>  	if (reg & SEQ_STATUS) {
>  		tsadc->adc_waiting = true;
> @@ -86,8 +80,12 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
>  		spin_lock_irq(&tsadc->reg_lock);
>  		finish_wait(&tsadc->reg_se_wait, &wait);
>  
> +		/*
> +		 * Sequencer should either be idle or
> +		 * busy applying the charge step.
> +		 */
>  		reg = tscadc_readl(tsadc, REG_ADCFSM);
> -		WARN_ON(reg & SEQ_STATUS);
> +		WARN_ON((reg & SEQ_STATUS) && !(reg & CHARGE_STEP));
>  		tsadc->adc_waiting = false;
>  	}
>  	tsadc->adc_in_use = true;
> @@ -96,7 +94,6 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
>  void am335x_tsc_se_set_once(struct ti_tscadc_dev *tsadc, u32 val)
>  {
>  	spin_lock_irq(&tsadc->reg_lock);
> -	tsadc->reg_se_cache |= val;
>  	am335x_tscadc_need_adc(tsadc);
>  
>  	tscadc_writel(tsadc, REG_SE, val);
> diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
> index 3f4e994ace2b..1fd50dcfe47c 100644
> --- a/include/linux/mfd/ti_am335x_tscadc.h
> +++ b/include/linux/mfd/ti_am335x_tscadc.h
> @@ -128,6 +128,7 @@
>  
>  /* Sequencer Status */
>  #define SEQ_STATUS BIT(5)
> +#define CHARGE_STEP		0x11
>  
>  #define ADC_CLK			3000000
>  #define TOTAL_STEPS		16

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 3/6] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save
  2015-01-20 11:53     ` Lee Jones
@ 2015-01-20 12:40       ` R, Vignesh
  2015-01-20 16:04         ` Lee Jones
  0 siblings, 1 reply; 16+ messages in thread
From: R, Vignesh @ 2015-01-20 12:40 UTC (permalink / raw)
  To: Lee Jones
  Cc: Jonathan Cameron, Hartmut Knaack, Dmitry Torokhov,
	Sebastian Andrzej Siewior, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Benoit Cousson, Tony Lindgren,
	Russell King, Lars-Peter Clausen, Peter Meerwald, Samuel Ortiz,
	Brad Griffis, Paul Gortmaker, Sanjeev Sharma, Jan Kardell,
	Felipe Balbi, Wolfram Sang, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-omap@



On 1/20/2015 5:23 PM, Lee Jones wrote:
> On Wed, 07 Jan 2015, Vignesh R wrote:
> 
>> In one shot mode, sequencer automatically disables all enabled steps at
>> the end of each cycle. (both ADC steps and TSC steps) Hence these steps
>> need not be saved in reg_se_cache for clearing these steps at a later
>> stage.
>> Also, when ADC wakes up Sequencer should not be busy executing any of the
>> config steps except for the charge step. Previously charge step was 1 ADC
>> clock cycle and hence it was ignored.
>> TSC steps are always disabled at the end of each conversion cycle, hence
>> there is no need to explicitly disable TSC steps by writing 0 to REG_SE.
>>
>> Signed-off-by: Vignesh R <vigneshr-l0cyMroinI0@public.gmane.org>
>> ---
>>
>> v5:
>>  - Remove unnecessary clearing of REG_SE
>>
>>  drivers/mfd/ti_am335x_tscadc.c       | 13 +++++--------
>>  include/linux/mfd/ti_am335x_tscadc.h |  1 +
>>  2 files changed, 6 insertions(+), 8 deletions(-)
> 
> Looks fine.
> 
> For my own reference:
>   Acked-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> 
> Can this patch be applied on its own?
> 

I prefer to wait until input patches are picked up.

>> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
>> index 467c80e1c4ae..e4e4b22eebc9 100644
>> --- a/drivers/mfd/ti_am335x_tscadc.c
>> +++ b/drivers/mfd/ti_am335x_tscadc.c
>> @@ -68,12 +68,6 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
>>  	DEFINE_WAIT(wait);
>>  	u32 reg;
>>  
>> -	/*
>> -	 * disable TSC steps so it does not run while the ADC is using it. If
>> -	 * write 0 while it is running (it just started or was already running)
>> -	 * then it completes all steps that were enabled and stops then.
>> -	 */
>> -	tscadc_writel(tsadc, REG_SE, 0);
>>  	reg = tscadc_readl(tsadc, REG_ADCFSM);
>>  	if (reg & SEQ_STATUS) {
>>  		tsadc->adc_waiting = true;
>> @@ -86,8 +80,12 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
>>  		spin_lock_irq(&tsadc->reg_lock);
>>  		finish_wait(&tsadc->reg_se_wait, &wait);
>>  
>> +		/*
>> +		 * Sequencer should either be idle or
>> +		 * busy applying the charge step.
>> +		 */
>>  		reg = tscadc_readl(tsadc, REG_ADCFSM);
>> -		WARN_ON(reg & SEQ_STATUS);
>> +		WARN_ON((reg & SEQ_STATUS) && !(reg & CHARGE_STEP));
>>  		tsadc->adc_waiting = false;
>>  	}
>>  	tsadc->adc_in_use = true;
>> @@ -96,7 +94,6 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
>>  void am335x_tsc_se_set_once(struct ti_tscadc_dev *tsadc, u32 val)
>>  {
>>  	spin_lock_irq(&tsadc->reg_lock);
>> -	tsadc->reg_se_cache |= val;
>>  	am335x_tscadc_need_adc(tsadc);
>>  
>>  	tscadc_writel(tsadc, REG_SE, val);
>> diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
>> index 3f4e994ace2b..1fd50dcfe47c 100644
>> --- a/include/linux/mfd/ti_am335x_tscadc.h
>> +++ b/include/linux/mfd/ti_am335x_tscadc.h
>> @@ -128,6 +128,7 @@
>>  
>>  /* Sequencer Status */
>>  #define SEQ_STATUS BIT(5)
>> +#define CHARGE_STEP		0x11
>>  
>>  #define ADC_CLK			3000000
>>  #define TOTAL_STEPS		16
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 3/6] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save
  2015-01-20 12:40       ` R, Vignesh
@ 2015-01-20 16:04         ` Lee Jones
  2015-01-21 10:14           ` Vignesh R
  0 siblings, 1 reply; 16+ messages in thread
From: Lee Jones @ 2015-01-20 16:04 UTC (permalink / raw)
  To: R, Vignesh
  Cc: Jonathan Cameron, Hartmut Knaack, Dmitry Torokhov,
	Sebastian Andrzej Siewior, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Benoit Cousson, Tony Lindgren,
	Russell King, Lars-Peter Clausen, Peter Meerwald, Samuel Ortiz,
	Brad Griffis, Paul Gortmaker, Sanjeev Sharma, Jan Kardell,
	Felipe Balbi, Wolfram Sang, devicetree, linux-kernel, linux-omap

On Tue, 20 Jan 2015, R, Vignesh wrote:
> On 1/20/2015 5:23 PM, Lee Jones wrote:
> > On Wed, 07 Jan 2015, Vignesh R wrote:
> > 
> >> In one shot mode, sequencer automatically disables all enabled steps at
> >> the end of each cycle. (both ADC steps and TSC steps) Hence these steps
> >> need not be saved in reg_se_cache for clearing these steps at a later
> >> stage.
> >> Also, when ADC wakes up Sequencer should not be busy executing any of the
> >> config steps except for the charge step. Previously charge step was 1 ADC
> >> clock cycle and hence it was ignored.
> >> TSC steps are always disabled at the end of each conversion cycle, hence
> >> there is no need to explicitly disable TSC steps by writing 0 to REG_SE.
> >>
> >> Signed-off-by: Vignesh R <vigneshr@ti.com>
> >> ---
> >>
> >> v5:
> >>  - Remove unnecessary clearing of REG_SE
> >>
> >>  drivers/mfd/ti_am335x_tscadc.c       | 13 +++++--------
> >>  include/linux/mfd/ti_am335x_tscadc.h |  1 +
> >>  2 files changed, 6 insertions(+), 8 deletions(-)
> > 
> > Looks fine.
> > 
> > For my own reference:
> >   Acked-by: Lee Jones <lee.jones@linaro.org>
> > 
> > Can this patch be applied on its own?
> > 
> 
> I prefer to wait until input patches are picked up.

I have no problem with that, but is there a technical reason why?

> >> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> >> index 467c80e1c4ae..e4e4b22eebc9 100644
> >> --- a/drivers/mfd/ti_am335x_tscadc.c
> >> +++ b/drivers/mfd/ti_am335x_tscadc.c
> >> @@ -68,12 +68,6 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
> >>  	DEFINE_WAIT(wait);
> >>  	u32 reg;
> >>  
> >> -	/*
> >> -	 * disable TSC steps so it does not run while the ADC is using it. If
> >> -	 * write 0 while it is running (it just started or was already running)
> >> -	 * then it completes all steps that were enabled and stops then.
> >> -	 */
> >> -	tscadc_writel(tsadc, REG_SE, 0);
> >>  	reg = tscadc_readl(tsadc, REG_ADCFSM);
> >>  	if (reg & SEQ_STATUS) {
> >>  		tsadc->adc_waiting = true;
> >> @@ -86,8 +80,12 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
> >>  		spin_lock_irq(&tsadc->reg_lock);
> >>  		finish_wait(&tsadc->reg_se_wait, &wait);
> >>  
> >> +		/*
> >> +		 * Sequencer should either be idle or
> >> +		 * busy applying the charge step.
> >> +		 */
> >>  		reg = tscadc_readl(tsadc, REG_ADCFSM);
> >> -		WARN_ON(reg & SEQ_STATUS);
> >> +		WARN_ON((reg & SEQ_STATUS) && !(reg & CHARGE_STEP));
> >>  		tsadc->adc_waiting = false;
> >>  	}
> >>  	tsadc->adc_in_use = true;
> >> @@ -96,7 +94,6 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
> >>  void am335x_tsc_se_set_once(struct ti_tscadc_dev *tsadc, u32 val)
> >>  {
> >>  	spin_lock_irq(&tsadc->reg_lock);
> >> -	tsadc->reg_se_cache |= val;
> >>  	am335x_tscadc_need_adc(tsadc);
> >>  
> >>  	tscadc_writel(tsadc, REG_SE, val);
> >> diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
> >> index 3f4e994ace2b..1fd50dcfe47c 100644
> >> --- a/include/linux/mfd/ti_am335x_tscadc.h
> >> +++ b/include/linux/mfd/ti_am335x_tscadc.h
> >> @@ -128,6 +128,7 @@
> >>  
> >>  /* Sequencer Status */
> >>  #define SEQ_STATUS BIT(5)
> >> +#define CHARGE_STEP		0x11
> >>  
> >>  #define ADC_CLK			3000000
> >>  #define TOTAL_STEPS		16
> > 

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 3/6] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save
  2015-01-20 16:04         ` Lee Jones
@ 2015-01-21 10:14           ` Vignesh R
  2015-02-05  6:21             ` Vignesh R
  0 siblings, 1 reply; 16+ messages in thread
From: Vignesh R @ 2015-01-21 10:14 UTC (permalink / raw)
  To: Lee Jones
  Cc: Jonathan Cameron, Hartmut Knaack, Dmitry Torokhov,
	Sebastian Andrzej Siewior, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Benoit Cousson, Tony Lindgren,
	Russell King, Lars-Peter Clausen, Peter Meerwald, Samuel Ortiz,
	Brad Griffis, Paul Gortmaker, Sanjeev Sharma, Jan Kardell,
	Felipe Balbi, Wolfram Sang, devicetree, linux-kernel, linux-omap@



On Tuesday 20 January 2015 09:34 PM, Lee Jones wrote:
> On Tue, 20 Jan 2015, R, Vignesh wrote:
>> On 1/20/2015 5:23 PM, Lee Jones wrote:
>>> On Wed, 07 Jan 2015, Vignesh R wrote:
>>>
>>>> In one shot mode, sequencer automatically disables all enabled steps at
>>>> the end of each cycle. (both ADC steps and TSC steps) Hence these steps
>>>> need not be saved in reg_se_cache for clearing these steps at a later
>>>> stage.
>>>> Also, when ADC wakes up Sequencer should not be busy executing any of the
>>>> config steps except for the charge step. Previously charge step was 1 ADC
>>>> clock cycle and hence it was ignored.
>>>> TSC steps are always disabled at the end of each conversion cycle, hence
>>>> there is no need to explicitly disable TSC steps by writing 0 to REG_SE.
>>>>
>>>> Signed-off-by: Vignesh R <vigneshr@ti.com>
>>>> ---
>>>>
>>>> v5:
>>>>  - Remove unnecessary clearing of REG_SE
>>>>
>>>>  drivers/mfd/ti_am335x_tscadc.c       | 13 +++++--------
>>>>  include/linux/mfd/ti_am335x_tscadc.h |  1 +
>>>>  2 files changed, 6 insertions(+), 8 deletions(-)
>>>
>>> Looks fine.
>>>
>>> For my own reference:
>>>   Acked-by: Lee Jones <lee.jones@linaro.org>
>>>
>>> Can this patch be applied on its own?
>>>
>>
>> I prefer to wait until input patches are picked up.
> 
> I have no problem with that, but is there a technical reason why?
> 

Nothing, in particular. This patch alone has no impact on the
performance of TSC/ADC unit. Patch 2/6 is necessary to observe the
changes caused by this series. Hence, please wait until those patches
are picked up.

>>>> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
>>>> index 467c80e1c4ae..e4e4b22eebc9 100644
>>>> --- a/drivers/mfd/ti_am335x_tscadc.c
>>>> +++ b/drivers/mfd/ti_am335x_tscadc.c
>>>> @@ -68,12 +68,6 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
>>>>  	DEFINE_WAIT(wait);
>>>>  	u32 reg;
>>>>  
>>>> -	/*
>>>> -	 * disable TSC steps so it does not run while the ADC is using it. If
>>>> -	 * write 0 while it is running (it just started or was already running)
>>>> -	 * then it completes all steps that were enabled and stops then.
>>>> -	 */
>>>> -	tscadc_writel(tsadc, REG_SE, 0);
>>>>  	reg = tscadc_readl(tsadc, REG_ADCFSM);
>>>>  	if (reg & SEQ_STATUS) {
>>>>  		tsadc->adc_waiting = true;
>>>> @@ -86,8 +80,12 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
>>>>  		spin_lock_irq(&tsadc->reg_lock);
>>>>  		finish_wait(&tsadc->reg_se_wait, &wait);
>>>>  
>>>> +		/*
>>>> +		 * Sequencer should either be idle or
>>>> +		 * busy applying the charge step.
>>>> +		 */
>>>>  		reg = tscadc_readl(tsadc, REG_ADCFSM);
>>>> -		WARN_ON(reg & SEQ_STATUS);
>>>> +		WARN_ON((reg & SEQ_STATUS) && !(reg & CHARGE_STEP));
>>>>  		tsadc->adc_waiting = false;
>>>>  	}
>>>>  	tsadc->adc_in_use = true;
>>>> @@ -96,7 +94,6 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
>>>>  void am335x_tsc_se_set_once(struct ti_tscadc_dev *tsadc, u32 val)
>>>>  {
>>>>  	spin_lock_irq(&tsadc->reg_lock);
>>>> -	tsadc->reg_se_cache |= val;
>>>>  	am335x_tscadc_need_adc(tsadc);
>>>>  
>>>>  	tscadc_writel(tsadc, REG_SE, val);
>>>> diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
>>>> index 3f4e994ace2b..1fd50dcfe47c 100644
>>>> --- a/include/linux/mfd/ti_am335x_tscadc.h
>>>> +++ b/include/linux/mfd/ti_am335x_tscadc.h
>>>> @@ -128,6 +128,7 @@
>>>>  
>>>>  /* Sequencer Status */
>>>>  #define SEQ_STATUS BIT(5)
>>>> +#define CHARGE_STEP		0x11
>>>>  
>>>>  #define ADC_CLK			3000000
>>>>  #define TOTAL_STEPS		16
>>>
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 2/6] input: touchscreen: ti_am335x_tsc: Remove udelay in interrupt handler
  2015-01-07  5:49 ` [PATCH v6 2/6] input: touchscreen: ti_am335x_tsc: Remove udelay in interrupt handler Vignesh R
@ 2015-01-30  5:26   ` Vignesh R
       [not found]     ` <54CB1604.9030709-l0cyMroinI0@public.gmane.org>
  0 siblings, 1 reply; 16+ messages in thread
From: Vignesh R @ 2015-01-30  5:26 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Dmitry Torokhov, Lee Jones,
	Sebastian Andrzej Siewior
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Benoit Cousson, Tony Lindgren, Russell King, Lars-Peter Clausen,
	Peter Meerwald, Samuel Ortiz, Brad Griffis, Paul Gortmaker,
	Sanjeev Sharma, Jan Kardell, Felipe Balbi, Wolfram Sang,
	devicetree, linux-kernel, linux-omap, linux-arm-kernel, linux-iio,
	linux-input



On Wednesday 07 January 2015 11:19 AM, Vignesh R wrote:
> From: Brad Griffis <bgriffis@ti.com>
> 
> TSC interrupt handler had udelay to avoid reporting of false pen-up
> interrupt to user space. This patch implements workaround suggesting in
> Advisory 1.0.31 of silicon errata for am335x, thus eliminating udelay
> and touchscreen lag. This also improves performance of touchscreen and
> eliminates sudden jump of cursor at touch release.
> 
> IDLECONFIG and CHARGECONFIG registers are to be configured
> with same values in order to eliminate false pen-up events. This
> workaround may result in false pen-down to be detected, hence considerable
> charge step delay needs to be added. The charge delay is set to 0xB000
> (in terms of ADC clock cycles) by default.
> 
> TSC steps are disabled at the end of every sampling cycle and EOS bit is
> set. Once the EOS bit is set, the TSC steps need to be re-enabled to begin
> next sampling cycle.
> 
> Signed-off-by: Brad Griffis <bgriffis@ti.com>
> [vigneshr@ti.com: Ported the patch from v3.12 to v3.19rc1]
> 
> Signed-off-by: Vignesh R <vigneshr@ti.com>
> ---

Ping... Can somebody pick this patch series if there are no more comments??

> v5:
>  - enable TSC steps only on EOS interrup
> 
> v4:
>  - check for PEN_IRQ bit in ADCFSM to avoid false-pen when ADC
>    and TSC are used together.
>  - Set charge delay to 0x400 as default. Most devices function
>    normally at this value.
> 
>  drivers/input/touchscreen/ti_am335x_tsc.c | 67 ++++++++++++++-----------------
>  include/linux/mfd/ti_am335x_tscadc.h      |  3 +-
>  2 files changed, 33 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
> index dfbb9fe6a270..0625c102a1d0 100644
> --- a/drivers/input/touchscreen/ti_am335x_tsc.c
> +++ b/drivers/input/touchscreen/ti_am335x_tsc.c
> @@ -173,11 +173,9 @@ static void titsc_step_config(struct titsc *ts_dev)
>  		titsc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY);
>  	}
>  
> -	/* Charge step configuration */
> -	config = ts_dev->bit_xp | ts_dev->bit_yn |
> -			STEPCHARGE_RFP_XPUL | STEPCHARGE_RFM_XNUR |
> -			STEPCHARGE_INM_AN1 | STEPCHARGE_INP(ts_dev->inp_yp);
> +	/* Make CHARGECONFIG same as IDLECONFIG */
>  
> +	config = titsc_readl(ts_dev, REG_IDLECONFIG);
>  	titsc_writel(ts_dev, REG_CHARGECONFIG, config);
>  	titsc_writel(ts_dev, REG_CHARGEDELAY, CHARGEDLY_OPENDLY);
>  
> @@ -261,12 +259,34 @@ static irqreturn_t titsc_irq(int irq, void *dev)
>  {
>  	struct titsc *ts_dev = dev;
>  	struct input_dev *input_dev = ts_dev->input;
> -	unsigned int status, irqclr = 0;
> +	unsigned int fsm, status, irqclr = 0;
>  	unsigned int x = 0, y = 0;
>  	unsigned int z1, z2, z;
> -	unsigned int fsm;
>  
> -	status = titsc_readl(ts_dev, REG_IRQSTATUS);
> +	status = titsc_readl(ts_dev, REG_RAWIRQSTATUS);
> +	if (status & IRQENB_HW_PEN) {
> +		ts_dev->pen_down = true;
> +		titsc_writel(ts_dev, REG_IRQWAKEUP, 0x00);
> +		titsc_writel(ts_dev, REG_IRQCLR, IRQENB_HW_PEN);
> +		irqclr |= IRQENB_HW_PEN;
> +	}
> +
> +	if (status & IRQENB_PENUP) {
> +		fsm = titsc_readl(ts_dev, REG_ADCFSM);
> +		if (fsm == ADCFSM_STEPID) {
> +			ts_dev->pen_down = false;
> +			input_report_key(input_dev, BTN_TOUCH, 0);
> +			input_report_abs(input_dev, ABS_PRESSURE, 0);
> +			input_sync(input_dev);
> +		} else {
> +			ts_dev->pen_down = true;
> +		}
> +		irqclr |= IRQENB_PENUP;
> +	}
> +
> +	if (status & IRQENB_EOS)
> +		irqclr |= IRQENB_EOS;
> +
>  	/*
>  	 * ADC and touchscreen share the IRQ line.
>  	 * FIFO1 interrupts are used by ADC. Handle FIFO0 IRQs here only
> @@ -297,37 +317,11 @@ static irqreturn_t titsc_irq(int irq, void *dev)
>  		}
>  		irqclr |= IRQENB_FIFO0THRES;
>  	}
> -
> -	/*
> -	 * Time for sequencer to settle, to read
> -	 * correct state of the sequencer.
> -	 */
> -	udelay(SEQ_SETTLE);
> -
> -	status = titsc_readl(ts_dev, REG_RAWIRQSTATUS);
> -	if (status & IRQENB_PENUP) {
> -		/* Pen up event */
> -		fsm = titsc_readl(ts_dev, REG_ADCFSM);
> -		if (fsm == ADCFSM_STEPID) {
> -			ts_dev->pen_down = false;
> -			input_report_key(input_dev, BTN_TOUCH, 0);
> -			input_report_abs(input_dev, ABS_PRESSURE, 0);
> -			input_sync(input_dev);
> -		} else {
> -			ts_dev->pen_down = true;
> -		}
> -		irqclr |= IRQENB_PENUP;
> -	}
> -
> -	if (status & IRQENB_HW_PEN) {
> -
> -		titsc_writel(ts_dev, REG_IRQWAKEUP, 0x00);
> -		titsc_writel(ts_dev, REG_IRQCLR, IRQENB_HW_PEN);
> -	}
> -
>  	if (irqclr) {
>  		titsc_writel(ts_dev, REG_IRQSTATUS, irqclr);
> -		am335x_tsc_se_set_cache(ts_dev->mfd_tscadc, ts_dev->step_mask);
> +		if (status & IRQENB_EOS)
> +			am335x_tsc_se_set_cache(ts_dev->mfd_tscadc,
> +						ts_dev->step_mask);
>  		return IRQ_HANDLED;
>  	}
>  	return IRQ_NONE;
> @@ -417,6 +411,7 @@ static int titsc_probe(struct platform_device *pdev)
>  	}
>  
>  	titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_FIFO0THRES);
> +	titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_EOS);
>  	err = titsc_config_wires(ts_dev);
>  	if (err) {
>  		dev_err(&pdev->dev, "wrong i/p wire configuration\n");
> diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
> index e2e70053470e..3f4e994ace2b 100644
> --- a/include/linux/mfd/ti_am335x_tscadc.h
> +++ b/include/linux/mfd/ti_am335x_tscadc.h
> @@ -52,6 +52,7 @@
>  
>  /* IRQ enable */
>  #define IRQENB_HW_PEN		BIT(0)
> +#define IRQENB_EOS		BIT(1)
>  #define IRQENB_FIFO0THRES	BIT(2)
>  #define IRQENB_FIFO0OVRRUN	BIT(3)
>  #define IRQENB_FIFO0UNDRFLW	BIT(4)
> @@ -107,7 +108,7 @@
>  /* Charge delay */
>  #define CHARGEDLY_OPEN_MASK	(0x3FFFF << 0)
>  #define CHARGEDLY_OPEN(val)	((val) << 0)
> -#define CHARGEDLY_OPENDLY	CHARGEDLY_OPEN(1)
> +#define CHARGEDLY_OPENDLY	CHARGEDLY_OPEN(0x400)
>  
>  /* Control register */
>  #define CNTRLREG_TSCSSENB	BIT(0)
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 2/6] input: touchscreen: ti_am335x_tsc: Remove udelay in interrupt handler
       [not found]     ` <54CB1604.9030709-l0cyMroinI0@public.gmane.org>
@ 2015-02-03 19:49       ` Dmitry Torokhov
  0 siblings, 0 replies; 16+ messages in thread
From: Dmitry Torokhov @ 2015-02-03 19:49 UTC (permalink / raw)
  To: Vignesh R
  Cc: Jonathan Cameron, Hartmut Knaack, Lee Jones,
	Sebastian Andrzej Siewior, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Benoit Cousson, Tony Lindgren,
	Russell King, Lars-Peter Clausen, Peter Meerwald, Samuel Ortiz,
	Brad Griffis, Paul Gortmaker, Sanjeev Sharma, Jan Kardell,
	Felipe Balbi, Wolfram Sang, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA

On Fri, Jan 30, 2015 at 10:56:28AM +0530, Vignesh R wrote:
> 
> 
> On Wednesday 07 January 2015 11:19 AM, Vignesh R wrote:
> > From: Brad Griffis <bgriffis-l0cyMroinI0@public.gmane.org>
> > 
> > TSC interrupt handler had udelay to avoid reporting of false pen-up
> > interrupt to user space. This patch implements workaround suggesting in
> > Advisory 1.0.31 of silicon errata for am335x, thus eliminating udelay
> > and touchscreen lag. This also improves performance of touchscreen and
> > eliminates sudden jump of cursor at touch release.
> > 
> > IDLECONFIG and CHARGECONFIG registers are to be configured
> > with same values in order to eliminate false pen-up events. This
> > workaround may result in false pen-down to be detected, hence considerable
> > charge step delay needs to be added. The charge delay is set to 0xB000
> > (in terms of ADC clock cycles) by default.
> > 
> > TSC steps are disabled at the end of every sampling cycle and EOS bit is
> > set. Once the EOS bit is set, the TSC steps need to be re-enabled to begin
> > next sampling cycle.
> > 
> > Signed-off-by: Brad Griffis <bgriffis-l0cyMroinI0@public.gmane.org>
> > [vigneshr-l0cyMroinI0@public.gmane.org: Ported the patch from v3.12 to v3.19rc1]
> > 
> > Signed-off-by: Vignesh R <vigneshr-l0cyMroinI0@public.gmane.org>
> > ---
> 
> Ping... Can somebody pick this patch series if there are no more comments??

Yes, I picked up everything but patch #3 as I assume Lee will merge it
through MFD tree.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 3/6] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save
  2015-01-21 10:14           ` Vignesh R
@ 2015-02-05  6:21             ` Vignesh R
       [not found]               ` <54D30BE5.4070906-l0cyMroinI0@public.gmane.org>
  0 siblings, 1 reply; 16+ messages in thread
From: Vignesh R @ 2015-02-05  6:21 UTC (permalink / raw)
  To: Lee Jones
  Cc: Jonathan Cameron, Hartmut Knaack, Dmitry Torokhov,
	Sebastian Andrzej Siewior, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Benoit Cousson, Tony Lindgren,
	Russell King, Lars-Peter Clausen, Peter Meerwald, Samuel Ortiz,
	Brad Griffis, Paul Gortmaker, Sanjeev Sharma, Jan Kardell,
	Felipe Balbi, Wolfram Sang, devicetree, linux-kernel, linux-omap@



On Wednesday 21 January 2015 03:44 PM, Vignesh R wrote:
> On Tuesday 20 January 2015 09:34 PM, Lee Jones wrote:
>> On Tue, 20 Jan 2015, R, Vignesh wrote:
>>> On 1/20/2015 5:23 PM, Lee Jones wrote:
>>>> On Wed, 07 Jan 2015, Vignesh R wrote:
>>>>
>>>>> In one shot mode, sequencer automatically disables all enabled steps at
>>>>> the end of each cycle. (both ADC steps and TSC steps) Hence these steps
>>>>> need not be saved in reg_se_cache for clearing these steps at a later
>>>>> stage.
>>>>> Also, when ADC wakes up Sequencer should not be busy executing any of the
>>>>> config steps except for the charge step. Previously charge step was 1 ADC
>>>>> clock cycle and hence it was ignored.
>>>>> TSC steps are always disabled at the end of each conversion cycle, hence
>>>>> there is no need to explicitly disable TSC steps by writing 0 to REG_SE.
>>>>>
>>>>> Signed-off-by: Vignesh R <vigneshr@ti.com>
>>>>> ---
>>>>>
>>>>> v5:
>>>>>  - Remove unnecessary clearing of REG_SE
>>>>>
>>>>>  drivers/mfd/ti_am335x_tscadc.c       | 13 +++++--------
>>>>>  include/linux/mfd/ti_am335x_tscadc.h |  1 +
>>>>>  2 files changed, 6 insertions(+), 8 deletions(-)
>>>>
>>>> Looks fine.
>>>>
>>>> For my own reference:
>>>>   Acked-by: Lee Jones <lee.jones@linaro.org>
>>>>
>>>> Can this patch be applied on its own?
>>>>
>>>
>>> I prefer to wait until input patches are picked up.
>>
>> I have no problem with that, but is there a technical reason why?
>>
> 
> Nothing, in particular. This patch alone has no impact on the
> performance of TSC/ADC unit. Patch 2/6 is necessary to observe the
> changes caused by this series. Hence, please wait until those patches
> are picked up.

Input maintainer has applied other patches. You can pick this one.

Regards
Vignesh R

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 3/6] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save
       [not found]               ` <54D30BE5.4070906-l0cyMroinI0@public.gmane.org>
@ 2015-02-25  4:07                 ` Vignesh R
  0 siblings, 0 replies; 16+ messages in thread
From: Vignesh R @ 2015-02-25  4:07 UTC (permalink / raw)
  To: Lee Jones
  Cc: Jonathan Cameron, Hartmut Knaack, Dmitry Torokhov,
	Sebastian Andrzej Siewior, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Benoit Cousson, Tony Lindgren,
	Russell King, Lars-Peter Clausen, Peter Meerwald, Samuel Ortiz,
	Brad Griffis, Paul Gortmaker, Sanjeev Sharma, Jan Kardell,
	Felipe Balbi, Wolfram Sang, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-omap@

Hi,

On Thursday 05 February 2015 11:51 AM, Vignesh R wrote:
> 
> 
> On Wednesday 21 January 2015 03:44 PM, Vignesh R wrote:
>> On Tuesday 20 January 2015 09:34 PM, Lee Jones wrote:
>>> On Tue, 20 Jan 2015, R, Vignesh wrote:
>>>> On 1/20/2015 5:23 PM, Lee Jones wrote:
>>>>> On Wed, 07 Jan 2015, Vignesh R wrote:
>>>>>
>>>>>> In one shot mode, sequencer automatically disables all enabled steps at
>>>>>> the end of each cycle. (both ADC steps and TSC steps) Hence these steps
>>>>>> need not be saved in reg_se_cache for clearing these steps at a later
>>>>>> stage.
>>>>>> Also, when ADC wakes up Sequencer should not be busy executing any of the
>>>>>> config steps except for the charge step. Previously charge step was 1 ADC
>>>>>> clock cycle and hence it was ignored.
>>>>>> TSC steps are always disabled at the end of each conversion cycle, hence
>>>>>> there is no need to explicitly disable TSC steps by writing 0 to REG_SE.
>>>>>>
>>>>>> Signed-off-by: Vignesh R <vigneshr-l0cyMroinI0@public.gmane.org>
>>>>>> ---
>>>>>>
>>>>>> v5:
>>>>>>  - Remove unnecessary clearing of REG_SE
>>>>>>
>>>>>>  drivers/mfd/ti_am335x_tscadc.c       | 13 +++++--------
>>>>>>  include/linux/mfd/ti_am335x_tscadc.h |  1 +
>>>>>>  2 files changed, 6 insertions(+), 8 deletions(-)
>>>>>
>>>>> Looks fine.
>>>>>
>>>>> For my own reference:
>>>>>   Acked-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>>>>>
>>>>> Can this patch be applied on its own?
>>>>>
>>>>
>>>> I prefer to wait until input patches are picked up.
>>>
>>> I have no problem with that, but is there a technical reason why?
>>>
>>
>> Nothing, in particular. This patch alone has no impact on the
>> performance of TSC/ADC unit. Patch 2/6 is necessary to observe the
>> changes caused by this series. Hence, please wait until those patches
>> are picked up.
> 
> Input maintainer has applied other patches. You can pick this one.

Gentle ping... Can you pull this patch into 4.0-rc? Other patches of
this series are already in mainline.

Regards
Vignesh

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 3/6] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save
  2015-01-07  5:49 ` [PATCH v6 3/6] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save Vignesh R
       [not found]   ` <1420609779-11156-4-git-send-email-vigneshr-l0cyMroinI0@public.gmane.org>
@ 2015-02-25  7:17   ` Lee Jones
  1 sibling, 0 replies; 16+ messages in thread
From: Lee Jones @ 2015-02-25  7:17 UTC (permalink / raw)
  To: Vignesh R
  Cc: Jonathan Cameron, Hartmut Knaack, Dmitry Torokhov,
	Sebastian Andrzej Siewior, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Benoit Cousson, Tony Lindgren,
	Russell King, Lars-Peter Clausen, Peter Meerwald, Samuel Ortiz,
	Brad Griffis, Paul Gortmaker, Sanjeev Sharma, Jan Kardell,
	Felipe Balbi, Wolfram Sang, devicetree, linux-kernel, linux-omap

On Wed, 07 Jan 2015, Vignesh R wrote:

> In one shot mode, sequencer automatically disables all enabled steps at
> the end of each cycle. (both ADC steps and TSC steps) Hence these steps
> need not be saved in reg_se_cache for clearing these steps at a later
> stage.
> Also, when ADC wakes up Sequencer should not be busy executing any of the
> config steps except for the charge step. Previously charge step was 1 ADC
> clock cycle and hence it was ignored.
> TSC steps are always disabled at the end of each conversion cycle, hence
> there is no need to explicitly disable TSC steps by writing 0 to REG_SE.
> 
> Signed-off-by: Vignesh R <vigneshr@ti.com>
> ---
> 
> v5:
>  - Remove unnecessary clearing of REG_SE
> 
>  drivers/mfd/ti_am335x_tscadc.c       | 13 +++++--------
>  include/linux/mfd/ti_am335x_tscadc.h |  1 +
>  2 files changed, 6 insertions(+), 8 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 467c80e1c4ae..e4e4b22eebc9 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -68,12 +68,6 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
>  	DEFINE_WAIT(wait);
>  	u32 reg;
>  
> -	/*
> -	 * disable TSC steps so it does not run while the ADC is using it. If
> -	 * write 0 while it is running (it just started or was already running)
> -	 * then it completes all steps that were enabled and stops then.
> -	 */
> -	tscadc_writel(tsadc, REG_SE, 0);
>  	reg = tscadc_readl(tsadc, REG_ADCFSM);
>  	if (reg & SEQ_STATUS) {
>  		tsadc->adc_waiting = true;
> @@ -86,8 +80,12 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
>  		spin_lock_irq(&tsadc->reg_lock);
>  		finish_wait(&tsadc->reg_se_wait, &wait);
>  
> +		/*
> +		 * Sequencer should either be idle or
> +		 * busy applying the charge step.
> +		 */
>  		reg = tscadc_readl(tsadc, REG_ADCFSM);
> -		WARN_ON(reg & SEQ_STATUS);
> +		WARN_ON((reg & SEQ_STATUS) && !(reg & CHARGE_STEP));
>  		tsadc->adc_waiting = false;
>  	}
>  	tsadc->adc_in_use = true;
> @@ -96,7 +94,6 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
>  void am335x_tsc_se_set_once(struct ti_tscadc_dev *tsadc, u32 val)
>  {
>  	spin_lock_irq(&tsadc->reg_lock);
> -	tsadc->reg_se_cache |= val;
>  	am335x_tscadc_need_adc(tsadc);
>  
>  	tscadc_writel(tsadc, REG_SE, val);
> diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
> index 3f4e994ace2b..1fd50dcfe47c 100644
> --- a/include/linux/mfd/ti_am335x_tscadc.h
> +++ b/include/linux/mfd/ti_am335x_tscadc.h
> @@ -128,6 +128,7 @@
>  
>  /* Sequencer Status */
>  #define SEQ_STATUS BIT(5)
> +#define CHARGE_STEP		0x11
>  
>  #define ADC_CLK			3000000
>  #define TOTAL_STEPS		16

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-02-25  7:17 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-07  5:49 [PATCH v6 0/6] Touchscreen performance related fixes Vignesh R
2015-01-07  5:49 ` [PATCH v6 1/6] input: touchscreen: ti_am335x_tsc Interchange touchscreen and ADC steps Vignesh R
2015-01-07  5:49 ` [PATCH v6 2/6] input: touchscreen: ti_am335x_tsc: Remove udelay in interrupt handler Vignesh R
2015-01-30  5:26   ` Vignesh R
     [not found]     ` <54CB1604.9030709-l0cyMroinI0@public.gmane.org>
2015-02-03 19:49       ` Dmitry Torokhov
2015-01-07  5:49 ` [PATCH v6 3/6] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save Vignesh R
     [not found]   ` <1420609779-11156-4-git-send-email-vigneshr-l0cyMroinI0@public.gmane.org>
2015-01-20 11:53     ` Lee Jones
2015-01-20 12:40       ` R, Vignesh
2015-01-20 16:04         ` Lee Jones
2015-01-21 10:14           ` Vignesh R
2015-02-05  6:21             ` Vignesh R
     [not found]               ` <54D30BE5.4070906-l0cyMroinI0@public.gmane.org>
2015-02-25  4:07                 ` Vignesh R
2015-02-25  7:17   ` Lee Jones
2015-01-07  5:49 ` [PATCH v6 4/6] input: touchscreen: ti_am335x_tsc: Read charge delay from DT Vignesh R
2015-01-07  5:49 ` [PATCH v6 5/6] ARM: dts: AM335x: Make charge delay a DT parameter for TSC Vignesh R
2015-01-07  5:49 ` [PATCH v6 6/6] input: touchscreen: ti_am335x_tsc: Replace delta filtering with median filtering Vignesh R

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).