linux-ti335x-psp: add 3.2 based on 3.2-staging branch
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 0014-tscadc-switch-to-polling-instead-of-interrupts.patch
1 From f36d060e6965cdbf797308fb2d80a77c4bbaeac3 Mon Sep 17 00:00:00 2001
2 From: Joel A Fernandes <joelagnel@ti.com>
3 Date: Tue, 29 Nov 2011 09:44:22 -0600
4 Subject: [PATCH 14/16] tscadc: switch to polling instead of interrupts
6 Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
7 ---
8  drivers/input/touchscreen/ti_tscadc.c |   16 ++++++++++++++--
9  1 files changed, 14 insertions(+), 2 deletions(-)
11 diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c
12 index 1f9cbf5..8e2a994 100644
13 --- a/drivers/input/touchscreen/ti_tscadc.c
14 +++ b/drivers/input/touchscreen/ti_tscadc.c
15 @@ -477,6 +477,8 @@ size_t do_adc_sample(struct kobject *kobj, struct attribute *attr, char *buf) {
16         struct device *dev;
17         struct tscadc *ts_dev;
18         int channel_num;
19 +       int fifo0count = 0;
20 +       int read_sample = 0;
21  
22         pdev = (struct platform_device *)container_of(kobj, struct device, kobj);
23         dev = &pdev->dev;
24 @@ -496,7 +498,17 @@ size_t do_adc_sample(struct kobject *kobj, struct attribute *attr, char *buf) {
25  
26         tsc_adc_step_config(ts_dev, channel_num);
27  
28 -       memcpy(buf, attr->name, strlen(attr->name)+1);
29 +       do {
30 +               fifo0count = tscadc_readl(ts_dev, TSCADC_REG_FIFO0CNT);
31 +       }
32 +       while (!fifo0count);
33 +
34 +       while (fifo0count--) {
35 +                         read_sample = tscadc_readl(ts_dev, TSCADC_REG_FIFO0) & 0xfff;
36 +                         // printk("polling sample: %d: %x\n", fifo0count, read_sample);
37 +       }
38 +       sprintf(buf, "%d", read_sample);
39 +
40         return strlen(attr->name);
41  }
42  
43 @@ -656,7 +668,7 @@ static      int __devinit tscadc_probe(struct platform_device *pdev)
44         }
45         else {
46                 tscadc_writel(ts_dev, TSCADC_REG_FIFO0THR, 0);
47 -               irqenable = TSCADC_IRQENB_FIFO0THRES;
48 +               irqenable = 0; // TSCADC_IRQENB_FIFO0THRES;
49         }
50         tscadc_writel(ts_dev, TSCADC_REG_IRQENABLE, irqenable);
51  
52 -- 
53 1.7.7.5