From a1bedb47197c154069710b8f0f2258a7651cc05c Mon Sep 17 00:00:00 2001
From: Joel A Fernandes <joelagnel@ti.com>
Date: Tue, 29 Nov 2011 09:44:22 -0600
Subject: [PATCH 12/26] tscadc: switch to polling instead of interrupts

Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
---
 drivers/input/touchscreen/ti_tscadc.c |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c
index c82f9bf..3082e5c 100644
--- a/drivers/input/touchscreen/ti_tscadc.c
+++ b/drivers/input/touchscreen/ti_tscadc.c
@@ -483,6 +483,8 @@ size_t do_adc_sample(struct kobject *kobj, struct attribute *attr, char *buf) {
 	struct device *dev;
 	struct tscadc *ts_dev;
 	int channel_num;
+	int fifo0count = 0;
+	int read_sample = 0;
 
 	pdev = (struct platform_device *)container_of(kobj, struct device, kobj);
 	dev = &pdev->dev;
@@ -502,7 +504,17 @@ size_t do_adc_sample(struct kobject *kobj, struct attribute *attr, char *buf) {
 
 	tsc_adc_step_config(ts_dev, channel_num);
 
-	memcpy(buf, attr->name, strlen(attr->name)+1);
+	do {
+		fifo0count = tscadc_readl(ts_dev, TSCADC_REG_FIFO0CNT);
+	}
+	while (!fifo0count);
+
+	while (fifo0count--) {
+			  read_sample = tscadc_readl(ts_dev, TSCADC_REG_FIFO0) & 0xfff;
+			  // printk("polling sample: %d: %x\n", fifo0count, read_sample);
+	}
+	sprintf(buf, "%d", read_sample);
+
 	return strlen(attr->name);
 }
 
@@ -657,7 +669,7 @@ static	int __devinit tscadc_probe(struct platform_device *pdev)
 	}
 	else {
 		tscadc_writel(ts_dev, TSCADC_REG_FIFO0THR, 0);
-		irqenable = TSCADC_IRQENB_FIFO0THRES;
+		irqenable = 0; // TSCADC_IRQENB_FIFO0THRES;
 	}
 	tscadc_writel(ts_dev, TSCADC_REG_IRQENABLE, irqenable);
 
-- 
1.7.9.5

