u-boot-mkimage-gta01-native: re-add till uboot-utils actually works
[openembedded.git] / packages / linux / linux-ezx-2.6.21 / pcap_ts.c.patch
1 Index: linux-2.6.21/drivers/input/touchscreen/pcap_ts.c
2 ===================================================================
3 --- linux-2.6.21.orig/drivers/input/touchscreen/pcap_ts.c       2007-05-01 16:28:00.000000000 +0200
4 +++ linux-2.6.21/drivers/input/touchscreen/pcap_ts.c    2007-05-01 16:28:03.000000000 +0200
5 @@ -21,15 +21,14 @@
6  #include <linux/string.h>
7  #include <linux/pm.h>
8  #include <linux/timer.h>
9 -#include <linux/config.h>
10 +//#include <linux/config.h>
11  #include <linux/interrupt.h>
12  #include <linux/platform_device.h>
13  #include <linux/input.h>
14  
15  #include <asm/arch/hardware.h>
16  #include <asm/arch/pxa-regs.h>
17 -
18 -#include "../../misc/ezx/ssp_pcap.h"
19 +#include <asm/arch/ezx-pcap.h>
20  
21  #if 1
22  #define DEBUGP(x, args ...) printk(KERN_DEBUG "%s: " x, __FUNCTION__, ## args)
23 @@ -61,6 +60,9 @@
24  #define PRESSURE_MAX   X_AXIS_MAX
25  #define PRESSURE_MIN   X_AXIS_MIN
26  
27 +#define SAMPLE_INTERVAL                (HZ/100)
28 +
29 +
30  static int pcap_ts_mode(u_int32_t mode)
31  {
32         int ret;
33 @@ -157,8 +159,6 @@
34                 pcap_ts->x, pcap_ts->y, pcap_ts->pressure);
35  
36         if (pcap_ts->read_state == PRESSURE) {
37 -               input_report_abs(pcap_ts->input, ABS_PRESSURE,
38 -                                pcap_ts->pressure);
39                 if ((pcap_ts->pressure >= PRESSURE_MAX ||
40                      pcap_ts->pressure <= PRESSURE_MIN ) &&
41                     pcap_ts->pressure == pcap_ts->pressure_last) {
42 @@ -166,6 +166,8 @@
43                         input_report_key(pcap_ts->input, BTN_TOUCH, 0);
44                         input_sync(pcap_ts->input);
45  
46 +                       input_report_abs(pcap_ts->input, ABS_PRESSURE, 0);
47 +
48                         pcap_ts->x = pcap_ts->y = 0;
49  
50                         /* ask PCAP2 to interrupt us if touch event happens
51 @@ -182,18 +184,24 @@
52                         input_report_key(pcap_ts->input, BTN_TOUCH, 1);
53                         /* don't input_sync(), we don't know position yet */
54  
55 +                       if (pcap_ts->pressure == 0) 
56 +                               pcap_ts->pressure = pcap_ts->pressure_last;
57 +
58 +                       input_report_abs(pcap_ts->input, ABS_PRESSURE,
59 +                               pcap_ts->pressure);
60 +
61                         /* switch state machine into coordinate read mode */
62                         pcap_ts->read_state = COORDINATE;
63                         pcap_ts_mode(PCAP_TS_POSITION_XY_MEASUREMENT);
64                         pcap_ts_start_xy_read(pcap_ts);
65 -
66 -                       mod_timer(&pcap_ts->timer, jiffies + HZ/20);
67                 }
68         } else {
69                 /* we are in coordinate mode */
70                 if (pcap_ts->x <= X_AXIS_MIN || pcap_ts->x >= X_AXIS_MAX ||
71                     pcap_ts->y <= Y_AXIS_MIN || pcap_ts->y >= Y_AXIS_MAX) {
72                         DEBUGP("invalid x/y coordinate position: PEN_UP?\n");
73 +
74 +                       pcap_ts->pressure = 0;
75  #if 0
76                         input_report_key(pcap_ts->input, BTN_TOUCH, 0);
77                         pcap_ts->x = pcap_ts->y = 0;
78 @@ -206,8 +214,8 @@
79  
80                 /* switch back to pressure read mode */
81                 pcap_ts->read_state = PRESSURE;
82 -               pcap_ts_mode(PCAP_TS_STANDBY_MODE);
83 -               ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_MSR_TSM, 0);
84 +               pcap_ts_mode(PCAP_TS_PRESSURE_MEASUREMENT);
85 +               mod_timer(&pcap_ts->timer, jiffies + SAMPLE_INTERVAL);
86         }
87  
88         return IRQ_HANDLED;
89 @@ -234,18 +242,19 @@
90  {
91         struct pcap_ts *pcap_ts = (struct pcap_ts *) data;
92  
93 -       ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_MSR_TSM, 1);
94 -       pcap_ts_mode(PCAP_TS_PRESSURE_MEASUREMENT);
95 -       pcap_ts->read_state = PRESSURE;
96         pcap_ts_start_xy_read(pcap_ts);
97  }
98  
99  static int __init ezxts_probe(struct platform_device *pdev)
100  {
101 +       int ret;
102 +       u_int32_t tmp;
103         struct pcap_ts *pcap_ts;
104         struct input_dev *input_dev;
105         int err = -ENOMEM;
106  
107 +       printk(KERN_DEBUG "Start probing TS!\n");
108 +
109         pcap_ts = kzalloc(sizeof(*pcap_ts), GFP_KERNEL);
110         input_dev = input_allocate_device();
111         if (!pcap_ts || !input_dev)
112 @@ -263,7 +272,46 @@
113                 goto fail;
114         }
115  
116 -       ssp_pcap_open(SSP_PCAP_TS_OPEN);
117 +       // Some initialization before done in ssp_pcap_open()
118 +       //ssp_pcap_open(SSP_PCAP_TS_OPEN);
119 +       ezx_pcap_bit_set( SSP_PCAP_ADJ_BIT_ADC1_TS_REFENB, 0);
120 +       ezx_pcap_bit_set( SSP_PCAP_ADJ_BIT_ISR_ADCDONE2I, 1);
121 +       ezx_pcap_bit_set( SSP_PCAP_ADJ_BIT_ISR_TSI, 1);
122 +       ezx_pcap_bit_set( SSP_PCAP_ADJ_BIT_MSR_TSM, 0);
123 +       ezx_pcap_bit_set( SSP_PCAP_ADJ_BIT_MSR_ADCDONE2M, 0);
124 +       ezx_pcap_bit_set( SSP_PCAP_ADJ_BIT_ADC2_ADINC1, 0);
125 +       ezx_pcap_bit_set( SSP_PCAP_ADJ_BIT_ADC2_ADINC2, 0);
126 +       ezx_pcap_bit_set( SSP_PCAP_ADJ_BIT_ADC1_ATO0, 0);
127 +       ezx_pcap_bit_set( SSP_PCAP_ADJ_BIT_ADC1_ATO1, 0);
128 +       ezx_pcap_bit_set( SSP_PCAP_ADJ_BIT_ADC1_ATO2, 0);
129 +       ezx_pcap_bit_set( SSP_PCAP_ADJ_BIT_ADC1_ATO3, 0);
130 +       ezx_pcap_bit_set( SSP_PCAP_ADJ_BIT_ADC1_ATOX, 0);
131 +       ezx_pcap_bit_set( SSP_PCAP_ADJ_BIT_ADC1_MTR1, 0);
132 +       ezx_pcap_bit_set( SSP_PCAP_ADJ_BIT_ADC1_MTR2, 0);
133 +
134 +       //SSP_PCAP_TSI_mode_set(PCAP_TS_STANDBY_MODE);
135 +       ret = ezx_pcap_read(SSP_PCAP_ADJ_ADC1_REGISTER, &tmp);
136 +       if (ret < 0)
137 +               return ret;
138 +
139 +       tmp &= (~SSP_PCAP_TOUCH_PANEL_POSITION_DETECT_MODE_MASK);
140 +       tmp |= PCAP_TS_STANDBY_MODE;
141 +
142 +       ret = ezx_pcap_write(SSP_PCAP_ADJ_ADC1_REGISTER, tmp);
143 +       if (ret < 0)
144 +               return ret;
145 +
146 +       /* send the usb accessory infomation to PM */
147 +       /*
148 +       if((ACCESSORY_TYPE) sspUsbAccessoryInfo.type == ACCESSORY_DEVICE_USB_PORT)
149 +       {
150 +               if( (ACCESSORY_DEVICE_STATUS )sspUsbAccessoryInfo.status == ACCESSORY_DEVICE_STATUS_ATTACHED )
151 +                       apm_queue_event(KRNL_ACCS_ATTACH);
152 +               else
153 +                       apm_queue_event(KRNL_ACCS_DETACH);
154 +       }
155 +       */
156 +
157  
158         err = request_irq(pcap_ts->irq_xy, pcap_ts_irq_xy, SA_INTERRUPT,
159                           "PCAP Touchscreen XY", pcap_ts);
160 @@ -343,10 +391,11 @@
161         //.resume               = ezxts_resume,
162         .driver         = {
163                 .name   = "pcap-ts",
164 +               .owner  = THIS_MODULE,
165         },
166  };
167  
168 -static int __devinit ezxts_init(void)
169 +static int __init ezxts_init(void)
170  {
171         return platform_driver_register(&ezxts_driver);
172  }
173 Index: linux-2.6.21/drivers/input/touchscreen/Kconfig
174 ===================================================================
175 --- linux-2.6.21.orig/drivers/input/touchscreen/Kconfig 2007-05-01 16:28:00.000000000 +0200
176 +++ linux-2.6.21/drivers/input/touchscreen/Kconfig      2007-05-01 16:28:03.000000000 +0200
177 @@ -166,7 +166,7 @@
178  
179  config TOUCHSCREEN_PCAP
180         tristate "Motorola PCAP touchscreen"
181 -       depends on PXA_EZX_PCAP
182 +       depends on PXA_EZX
183         help
184           Say Y here if you have a Motorola EZX (E680, A780) telephone
185           and want to support the built-in touchscreen.
186 @@ -174,6 +174,6 @@
187           If unsure, say N.
188  
189           To compile this driver as a module, choose M here: the
190 -         module will be called hp680_ts_input.
191 +         module will be called pcap_ts.
192  
193  endif
194 Index: linux-2.6.21/arch/arm/mach-pxa/ezx.c
195 ===================================================================
196 --- linux-2.6.21.orig/arch/arm/mach-pxa/ezx.c   2007-05-01 16:28:00.000000000 +0200
197 +++ linux-2.6.21/arch/arm/mach-pxa/ezx.c        2007-05-01 16:28:03.000000000 +0200
198 @@ -116,6 +116,31 @@
199         .resource       = ezxemu_resources,
200  };
201  
202 +/* PCAP_TS */
203 +struct resource pcap_ts_resources[] = {
204 +       [0] = {
205 +               .start          = EZX_IRQ_ADCDONE2,
206 +               .end            = EZX_IRQ_ADCDONE2,
207 +               .flags          = IORESOURCE_IRQ,
208 +       },
209 +       [1] = {
210 +               .start          = EZX_IRQ_TS,
211 +               .end            = EZX_IRQ_TS,
212 +               .flags          = IORESOURCE_IRQ,
213 +       }
214 +};
215 +
216 +struct platform_device pcap_ts_device = {
217 +       .name           = "pcap-ts",
218 +       .id             = -1,
219 +       .dev            = {
220 +               .parent         = &ezxpcap_device.dev,
221 +       },
222 +       .num_resources  = ARRAY_SIZE(pcap_ts_resources),
223 +       .resource       = pcap_ts_resources,
224 +};
225 +
226 +
227  /* OHCI Controller */
228  
229  static int ezx_ohci_init(struct device *dev)
230 @@ -342,6 +367,7 @@
231         &ezxpcap_device,
232         &ezxbp_device,
233         &ezxemu_device,
234 +       &pcap_ts_device,
235  };
236  
237  static void __init a780_init(void)