From 888913aadadaccf759c4d1fc7c329243764012f1 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 13/21] tscadc: switch to polling instead of interrupts

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

diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c
index 1f9cbf5..8e2a994 100644
--- a/drivers/input/touchscreen/ti_tscadc.c
+++ b/drivers/input/touchscreen/ti_tscadc.c
@@ -477,6 +477,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;
@@ -496,7 +498,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);
 }
 
@@ -656,7 +668,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.7.4

