summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/linux-ti33x-psp-3.2/beaglebone/0012-tscadc-switch-to-polling-instead-of-interrupts.patch
blob: 86ef82ef2d995a815db6436ce75ad1c55643e35e (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 04b4ae6caf9912acb99b294ab946ca88146ec6a9 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/56] 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 da48bcd..4fd2e18 100644
--- a/drivers/input/touchscreen/ti_tscadc.c
+++ b/drivers/input/touchscreen/ti_tscadc.c
@@ -484,6 +484,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;
@@ -503,7 +505,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);
 }
 
@@ -658,7 +670,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.6