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