]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/meta-ti-glsdk.git/blob - recipes-kernel/linux/linux-ti33x-psp-3.2/beaglebone/0010-tscadc-Trigger-through-sysfs.patch
linux-ti335x-psp 3.2: update to v3.2.11
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / beaglebone / 0010-tscadc-Trigger-through-sysfs.patch
1 From fb718df2afa6f3876c22d830c55de70943d95812 Mon Sep 17 00:00:00 2001
2 From: Joel A Fernandes <joelagnel@ti.com>
3 Date: Mon, 28 Nov 2011 20:55:25 -0600
4 Subject: [PATCH 10/22] tscadc: Trigger through sysfs
6 Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
8 Conflicts:
10         drivers/input/touchscreen/ti_tscadc.c
11 ---
12  drivers/input/touchscreen/ti_tscadc.c |   60 ++++++++++++++++++++++++++++++---
13  include/linux/input/ti_tscadc.h       |    1 +
14  2 files changed, 56 insertions(+), 5 deletions(-)
16 diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c
17 index 0b91bdc..a74d9ba 100644
18 --- a/drivers/input/touchscreen/ti_tscadc.c
19 +++ b/drivers/input/touchscreen/ti_tscadc.c
20 @@ -26,6 +26,17 @@
21  #include <linux/io.h>
22  #include <linux/input/ti_tscadc.h>
23  #include <linux/delay.h>
24 +#include <linux/device.h>
25 +
26 +size_t do_adc_sample(struct kobject *, struct attribute *, char *);
27 +static DEVICE_ATTR(ain1, S_IRUGO, do_adc_sample, NULL);
28 +static DEVICE_ATTR(ain2, S_IRUGO, do_adc_sample, NULL);
29 +static DEVICE_ATTR(ain3, S_IRUGO, do_adc_sample, NULL);
30 +static DEVICE_ATTR(ain4, S_IRUGO, do_adc_sample, NULL);
31 +static DEVICE_ATTR(ain5, S_IRUGO, do_adc_sample, NULL);
32 +static DEVICE_ATTR(ain6, S_IRUGO, do_adc_sample, NULL);
33 +static DEVICE_ATTR(ain7, S_IRUGO, do_adc_sample, NULL);
34 +static DEVICE_ATTR(ain8, S_IRUGO, do_adc_sample, NULL);
35  
36  /* Memory mapped registers here have incorrect offsets!
37   * Correct after referring TRM */
38 @@ -144,12 +155,12 @@ static void tsc_adc_step_config(struct tscadc *ts_dev, int channel)
39         stepconfig = TSCADC_STEPCONFIG_MODE_SWONESHOT |
40                 TSCADC_STEPCONFIG_2SAMPLES_AVG |
41                 ((channel-1) << 19);
42 -
43 +       
44         delay = TSCADC_STEPCONFIG_SAMPLEDLY | TSCADC_STEPCONFIG_OPENDLY;
45  
46         tscadc_writel(ts_dev, TSCADC_REG_STEPCONFIG(10), stepconfig);
47         tscadc_writel(ts_dev, TSCADC_REG_STEPDELAY(10), delay);
48 -
49 +       
50         /* Get the ball rolling, this will trigger the FSM to step through
51          * as soon as TSC_ADC_SS is turned on */
52         tscadc_writel(ts_dev, TSCADC_REG_SE, TSCADC_STPENB_STEPENB_GENERAL);
53 @@ -199,7 +210,7 @@ static irqreturn_t tsc_adc_interrupt(int irq, void *dev)
54                 irqclr |= TSCADC_IRQENB_FIFO1THRES;
55         }
56  
57 -       mdelay(500);
58 +       // mdelay(500);
59  
60         tscadc_writel(ts_dev, TSCADC_REG_IRQSTATUS, irqclr);
61  
62 @@ -207,7 +218,7 @@ static irqreturn_t tsc_adc_interrupt(int irq, void *dev)
63         tscadc_writel(ts_dev, TSCADC_REG_IRQEOI, 0x0);
64  
65         /* Turn on Step 1 again */
66 -       tscadc_writel(ts_dev, TSCADC_REG_SE, TSCADC_STPENB_STEPENB_GENERAL);
67 +       // tscadc_writel(ts_dev, TSCADC_REG_SE, TSCADC_STPENB_STEPENB_GENERAL);
68         return IRQ_HANDLED;
69  }
70  
71 @@ -461,6 +472,34 @@ static irqreturn_t tsc_interrupt(int irq, void *dev)
72  * The functions for inserting/removing driver as a module.
73  */
74  
75 +size_t do_adc_sample(struct kobject *kobj, struct attribute *attr, char *buf) {
76 +       struct platform_device *pdev;
77 +       struct device *dev;
78 +       struct tscadc *ts_dev;
79 +       int channel_num;
80 +
81 +       pdev = (struct platform_device *)container_of(kobj, struct device, kobj);
82 +       dev = &pdev->dev;
83 +
84 +       ts_dev = dev_get_drvdata(dev);
85 +
86 +       if(strncmp(attr->name, "ain", 3)) {
87 +               printk("Invalid ain num\n");
88 +               return -EINVAL;
89 +       }
90 +
91 +       channel_num = attr->name[3] - 0x30;
92 +       if(channel_num > 8 || channel_num < 1) {
93 +               printk("Invalid channel_num=%d\n", channel_num);
94 +               return -EINVAL;
95 +       }
96 +
97 +       tsc_adc_step_config(ts_dev, channel_num);
98 +
99 +       memcpy(buf, attr->name, strlen(attr->name)+1);
100 +       return strlen(attr->name);
101 +}
103  static int __devinit tscadc_probe(struct platform_device *pdev)
104  {
105         struct tscadc                   *ts_dev;
106 @@ -472,6 +511,18 @@ static     int __devinit tscadc_probe(struct platform_device *pdev)
107         struct resource                 *res;
108         struct clk                      *clk;
109  
110 +       printk("dev addr = %p\n", &pdev->dev);
111 +       printk("pdev addr = %p\n", pdev);
113 +       device_create_file(&pdev->dev, &dev_attr_ain1);
114 +       device_create_file(&pdev->dev, &dev_attr_ain2);
115 +       device_create_file(&pdev->dev, &dev_attr_ain3);
116 +       device_create_file(&pdev->dev, &dev_attr_ain4);
117 +       device_create_file(&pdev->dev, &dev_attr_ain5);
118 +       device_create_file(&pdev->dev, &dev_attr_ain6);
119 +       device_create_file(&pdev->dev, &dev_attr_ain7);
120 +       device_create_file(&pdev->dev, &dev_attr_ain8);
122         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
123         if (!res) {
124                 dev_err(&pdev->dev, "no memory resource defined.\n");
125 @@ -604,7 +655,6 @@ static      int __devinit tscadc_probe(struct platform_device *pdev)
126                         goto err_fail;
127         }
128         else {
129 -               tsc_adc_step_config(ts_dev, 8);
130                 tscadc_writel(ts_dev, TSCADC_REG_FIFO0THR, 0);
131                 irqenable = TSCADC_IRQENB_FIFO0THRES;
132         }
133 diff --git a/include/linux/input/ti_tscadc.h b/include/linux/input/ti_tscadc.h
134 index 850cd4b..fc239c6 100644
135 --- a/include/linux/input/ti_tscadc.h
136 +++ b/include/linux/input/ti_tscadc.h
137 @@ -13,6 +13,7 @@
138   *                     0.
139   * @x_plate_resistance:        X plate resistance.
140   */
141 +#include <linux/device.h>
142  
143  #define TI_TSCADC_TSCMODE 0
144  #define TI_TSCADC_GENMODE 1
145 -- 
146 1.7.9.4