summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/linux-ti33x-psp-3.2/0014-tscadc-switch-to-polling-instead-of-interrupts.patch
blob: 0df53466cab31253d5539c40d0484d7c1879e481 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From f36d060e6965cdbf797308fb2d80a77c4bbaeac3 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 14/16] 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.5