linux/ixp4xx: revert r22922
[openwrt.git] / target / linux / ep93xx / patches-2.6.30 / 006-ep93xx-touchscreen.patch
1 Index: linux-2.6.30.9/drivers/input/touchscreen/Kconfig
2 ===================================================================
3 --- linux-2.6.30.9.orig/drivers/input/touchscreen/Kconfig 2009-11-24 21:00:18.000000000 +0100
4 +++ linux-2.6.30.9/drivers/input/touchscreen/Kconfig 2009-11-24 21:00:45.000000000 +0100
5 @@ -161,6 +161,10 @@
6 module will be called wacom_w8001.
7
8
9 +config TOUCHSCREEN_EP93XX
10 + tristate "EP93xx Touchscreen"
11 + depends on ARM && INPUT && ARCH_EP93XX
12 +
13 config TOUCHSCREEN_MTOUCH
14 tristate "MicroTouch serial touchscreens"
15 select SERIO
16 Index: linux-2.6.30.9/drivers/input/touchscreen/Makefile
17 ===================================================================
18 --- linux-2.6.30.9.orig/drivers/input/touchscreen/Makefile 2009-11-24 21:00:18.000000000 +0100
19 +++ linux-2.6.30.9/drivers/input/touchscreen/Makefile 2009-11-24 21:00:45.000000000 +0100
20 @@ -14,6 +14,7 @@
21 obj-$(CONFIG_TOUCHSCREEN_CORGI) += corgi_ts.o
22 obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o
23 obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o
24 +obj-$(CONFIG_TOUCHSCREEN_EP93XX) += ep93xx_ts.o
25 obj-$(CONFIG_TOUCHSCREEN_FUJITSU) += fujitsu_ts.o
26 obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o
27 obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o
28 Index: linux-2.6.30.9/drivers/input/touchscreen/ep93xx_ts.c
29 ===================================================================
30 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
31 +++ linux-2.6.30.9/drivers/input/touchscreen/ep93xx_ts.c 2009-11-24 21:09:48.000000000 +0100
32 @@ -0,0 +1,1117 @@
33 +/*
34 + * linux/drivers/input/touchscreen/ep93xx_ts.c
35 + *
36 + * Copyright (C) 2003-2004 Cirrus Corp.
37 + *
38 + * This program is free software; you can redistribute it and/or modify
39 + * it under the terms of the GNU General Public License version 2 as
40 + * published by the Free Software Foundation.
41 + */
42 +
43 +#include <linux/module.h>
44 +#include <linux/types.h>
45 +#include <linux/delay.h>
46 +#include <linux/wait.h>
47 +#include <linux/fs.h>
48 +#include <linux/sched.h>
49 +#include <linux/poll.h>
50 +#include <linux/miscdevice.h>
51 +#include <linux/init.h>
52 +#include <linux/compiler.h>
53 +#include <linux/timer.h>
54 +#include <linux/interrupt.h>
55 +#include <linux/syscalls.h>
56 +#include <linux/input.h>
57 +#include <asm/irq.h>
58 +#include <mach/hardware.h>
59 +#include <asm/io.h>
60 +
61 +#define TOUCH_OFFSET 0x100000
62 +#define TOUCH_BASE (EP93XX_APB_VIRT_BASE|TOUCH_OFFSET)
63 +#define TSSetup (TOUCH_BASE+0x00) /* R/W touchscreen controller setup control register. */
64 +#define TSXYMaxMin (TOUCH_BASE+0x04) /* R/W touchscreen controller max/min register. */
65 +#define TSXYResult (TOUCH_BASE+0x08) /* R touchscreen controller result register. */
66 +#define TSDischarge (TOUCH_BASE+0x0C) /* LOCKED R/W touchscreen Switch Matrix control register. */
67 +#define TSXSample (TOUCH_BASE+0x10) /* LOCKED R/W touchscreen Switch Matrix control register. */
68 +#define TSYSample (TOUCH_BASE+0x14) /* LOCKED R/W touchscreen Switch Matrix control register. */
69 +#define TSDirect (TOUCH_BASE+0x18) /* LOCKED R/W touchscreen Switch Matrix control register. */
70 +#define TSDetect (TOUCH_BASE+0x1C) /* LOCKED R/W touchscreen Switch Matrix control register. */
71 +#define TSSWLock (TOUCH_BASE+0x20) /* NA R/W touchscreen software lock register. */
72 +#define TSSetup2 (TOUCH_BASE+0x24) /* R/W touchscreen setup control register #2. */
73 +
74 +//
75 +// To customize for a new touchscreen, there are various macros that
76 +// have to be set. If you allow UART_HACK_DEBUG to be defined, you
77 +// will get real time ts data scrolling up your serial terminal
78 +// screen that will help you empirically determine good values for these.
79 +//
80 +
81 +//
82 +// These are used as trigger levels to know when we have pen up/down
83 +//
84 +// The rules:
85 +// 1. TS_HEAVY_INV_PRESSURE < TS_LIGHT_INV_PRESSURE because these
86 +// are Inverse pressure.
87 +// 2. Any touch lighter than TS_LIGHT_INV_PRESSURE is a pen up.
88 +// 3. Any touch heavier than TS_HEAVY_INV_PRESSURE is a pen down.
89 +//
90 +#define TS_HEAVY_INV_PRESSURE 0xFE0 //C00
91 +#define TS_LIGHT_INV_PRESSURE 0xFFF //e00
92 +
93 +//
94 +// If the x, y, or inverse pressure changes more than these values
95 +// between two succeeding points, the point is not reported.
96 +//
97 +#define TS_MAX_VALID_XY_CHANGE 0x300
98 +#define TS_MAX_VALID_PRESSURE_CHANGE 0x100
99 +
100 +//
101 +// This is the minimum Z1 Value that is valid.
102 +//
103 +#define MIN_Z1_VALUE 0x50
104 +
105 +//
106 +// Settling delay for taking each ADC measurement. Increase this
107 +// if ts is jittery.
108 +//
109 +#define EP93XX_TS_ADC_DELAY_USEC 2000
110 +
111 +//
112 +// Delay between TS points.
113 +//
114 +#define EP93XX_TS_PER_POINT_DELAY_USEC 10000
115 +
116 +//-----------------------------------------------------------------------------
117 +// Debug messaging thru the UARTs
118 +//-----------------------------------------------------------------------------
119 +/*
120 + * Hello there! Are you trying to get this driver to work with a new
121 + * touschscreen? Turn this on and you will get useful info coming
122 + * out of your serial port.
123 + */
124 +/* #define PRINT_CALIBRATION_FACTORS */
125 +#ifdef PRINT_CALIBRATION_FACTORS
126 +#define UART_HACK_DEBUG 1
127 +int iMaxX=0, iMaxY=0, iMinX = 0xfff, iMinY = 0xfff;
128 +#endif
129 +
130 +/*
131 + * For debugging, let's spew messages out serial port 1 or 3 at 57,600 baud.
132 + */
133 +/* #define UART_HACK_DEBUG 1 */
134 +#if 0
135 +#ifdef UART_HACK_DEBUG
136 +static char szBuf[256];
137 +void UARTWriteString(char * msg);
138 +#define DPRINTK( x... ) \
139 + sprintf( szBuf, ##x ); \
140 + UARTWriteString( szBuf );
141 +#else
142 +static char szBuf[256];
143 +#define DPRINTK( x... ) \
144 + sprintf( szBuf, ##x ); \
145 + printk( szBuf );
146 +#endif
147 +#endif // 0
148 +#define DPRINTK( x... )
149 +
150 +//-----------------------------------------------------------------------------
151 +// A few more macros...
152 +//-----------------------------------------------------------------------------
153 +#define TSSETUP_DEFAULT ( TSSETUP_NSMP_32 | TSSETUP_DEV_64 | \
154 + ((128<<TSSETUP_SDLY_SHIFT) & TSSETUP_SDLY_MASK) | \
155 + ((128<<TSSETUP_DLY_SHIFT) & TSSETUP_DLY_MASK) )
156 +
157 +#define TSSETUP2_DEFAULT (TSSETUP2_NSIGND)
158 +
159 +//
160 +// For now, we use one of the minor numbers from the local/experimental
161 +// range.
162 +//
163 +#define EP93XX_TS_MINOR 240
164 +
165 +//-----------------------------------------------------------------------------
166 +// Static Declarations
167 +//-----------------------------------------------------------------------------
168 +static unsigned int guiLastX, guiLastY;
169 +static unsigned int guiLastInvPressure;
170 +
171 +struct TouchScreenSample
172 +{
173 + int currentX;
174 + int currentY;
175 + int currentButton;
176 + int currentPressure;
177 + struct timeval currentTime;
178 +};
179 +
180 +//
181 +// This must match the structure in tslib.
182 +//
183 +struct ts_sample {
184 + int x;
185 + int y;
186 + unsigned int pressure;
187 + struct timeval tv;
188 +};
189 +
190 +
191 +static struct TouchScreenSample gSample;
192 +
193 +// static int currentX, currentY, currentButton;
194 +// static int gPressure;
195 +// static struct timeval gtime;
196 +
197 +static int bFreshTouchData;
198 +static int bCurrentPenDown;
199 +
200 +
201 +
202 +static DECLARE_WAIT_QUEUE_HEAD(queue);
203 +static DECLARE_MUTEX(open_sem);
204 +static spinlock_t event_buffer_lock = SPIN_LOCK_UNLOCKED;
205 +static struct fasync_struct *ep93xx_fasync;
206 +
207 +//-----------------------------------------------------------------------------
208 +// Typedef Declarations
209 +//-----------------------------------------------------------------------------
210 +typedef enum {
211 + TS_MODE_UN_INITIALIZED,
212 + TS_MODE_HARDWARE_SCAN,
213 + TS_MODE_SOFT_SCAN
214 +} ts_mode_t;
215 +
216 +static ts_mode_t gScanningMode;
217 +
218 +typedef enum{
219 + TS_STATE_STOPPED = 0,
220 + TS_STATE_Z1,
221 + TS_STATE_Z2,
222 + TS_STATE_Y,
223 + TS_STATE_X,
224 + TS_STATE_DONE
225 +} ts_states_t;
226 +
227 +typedef struct
228 +{
229 + unsigned int uiX;
230 + unsigned int uiY;
231 + unsigned int uiZ1;
232 + unsigned int uiZ2;
233 + ts_states_t state;
234 +} ts_struct_t;
235 +
236 +static ts_struct_t sTouch;
237 +
238 +/*
239 + * From the spec, here's how to set up the touch screen's switch registers.
240 + */
241 +typedef struct
242 +{
243 + unsigned int uiDetect;
244 + unsigned int uiDischarge;
245 + unsigned int uiXSample;
246 + unsigned int uiYSample;
247 + unsigned int uiSwitchZ1;
248 + unsigned int uiSwitchZ2;
249 +}SwitchStructType;
250 +
251 +//
252 +// Here's the switch settings for a 4-wire touchscreen. See the spec
253 +// for how to handle a 4, 7, or 8-wire.
254 +//
255 +const static SwitchStructType sSwitchSettings =
256 +/* s28en=0
257 + * TSDetect TSDischarge TSXSample TSYSample SwitchZ1 SwitchZ2
258 + */
259 + {0x00403604, 0x0007fe04, 0x00081604, 0x00104601, 0x00101601, 0x00101608};
260 +
261 +
262 +//-----------------------------------------------------------------------------
263 +// Function Declarations
264 +//-----------------------------------------------------------------------------
265 +static void ep93xx_ts_set_direct( unsigned int uiADCSwitch );
266 +static irqreturn_t ep93xx_ts_isr(int irq, void *dev_id);
267 +static irqreturn_t ep93xx_timer2_isr(int irq, void *dev_id);
268 +static void ee93xx_ts_evt_add( int button, int dX, int dY, int Pressure );
269 +static ssize_t ep93xx_ts_read(struct file *filp, char *buf,
270 + size_t count, loff_t *l);
271 +static unsigned int ep93xx_ts_poll(struct file *filp, poll_table *wait);
272 +static int ep93xx_ts_open(struct inode *inode, struct file *filp);
273 +static int ep93xx_ts_fasync(int fd, struct file *filp, int on);
274 +static int ep93xx_ts_release(struct inode *inode, struct file *filp);
275 +static ssize_t ep93xx_ts_write(struct file *file, const char *buffer,
276 + size_t count, loff_t *ppos);
277 +static void ep93xx_ts_setup(void);
278 +static void ep93xx_ts_shutdown(void);
279 +int __init ep93xx_ts_init(void);
280 +void __exit ep93xx_ts_exit(void);
281 +static unsigned int CalculateInvPressure( void );
282 +static unsigned int ADCGetData( unsigned int uiSamples, unsigned int uiMaxDiff);
283 +static void TS_Soft_Scan_Mode(void);
284 +static void TS_Hardware_Scan_Mode(void);
285 +static void ProcessPointData(void);
286 +static void Set_Timer2_uSec( unsigned int Delay_mSec );
287 +static void Stop_Timer2(void);
288 +
289 +
290 +
291 +//-----------------------------------------------------------------------------
292 +// Debug stuff...
293 +//-----------------------------------------------------------------------------
294 +
295 +#ifdef UART_HACK_DEBUG
296 +
297 +// This "array" is a cheap-n-easy way of getting access to the UART registers.
298 +static unsigned int * const pDebugUART=(unsigned int *)IO_ADDRESS(UART1_BASE);
299 +//static unsigned int * const pDebugUART=(unsigned int *)IO_ADDRESS(UART3_BASE);
300 +static int bUartInitialized = 0;
301 +
302 +void SendChar(char value)
303 +{
304 + // wait for Tx fifo full flag to clear.
305 + while (pDebugUART[0x18>>2] & 0x20);
306 +
307 + // send a char to the uart
308 + pDebugUART[0] = value;
309 +}
310 +
311 +void UARTWriteString(char * msg)
312 +{
313 + int index = 0;
314 + unsigned int uiTemp;
315 +
316 + //if((pDebugUART[0x14>>2] & 0x1) == 0)
317 + if( bUartInitialized == 0 )
318 + {
319 + uiTemp = inl(EP93XX_SYSCON_DEVICE_CONFIG);
320 + uiTemp |= EP93XX_SYSCON_DEVCFG_U1E;
321 + //uiTemp |= EP93XX_SYSCON_DEVCFG_U3E;
322 + SysconSetLocked(EP93XX_SYSCON_DEVICE_CONFIG, uiTemp);
323 + pDebugUART[0x10>>2] = 0xf;
324 + pDebugUART[0xc>>2] = 0;
325 + pDebugUART[0x8>>2] = 0x70;
326 + pDebugUART[0x14>>2] = 0x1;
327 + bUartInitialized = 1;
328 + }
329 + while (msg[index] != 0)
330 + {
331 + if (msg[index] == '\n')
332 + {
333 + SendChar('\r');
334 + SendChar('\n');
335 + }
336 + else
337 + {
338 + SendChar(msg[index]);
339 + }
340 + index++;
341 + }
342 +}
343 +#endif // UART_HACK_DEBUG
344 +
345 +/*
346 + * ep93xx_ts_isr
347 + */
348 +static irqreturn_t ep93xx_ts_isr(int irq, void *dev_id)
349 +{
350 + DPRINTK("isr\n");
351 +
352 + //
353 + // Note that we don't clear the interrupt here. The interrupt
354 + // gets cleared in TS_Soft_Scan_Mode when the TS ENABLE
355 + // bit is cleared.
356 + //
357 +
358 + //
359 + // Set the ts to manual polling mode and schedule a callback.
360 + // That way we can return from the isr in a reasonable amount of
361 + // time and process the touch in the callback after a brief delay.
362 + //
363 + TS_Soft_Scan_Mode();
364 +
365 + return(IRQ_HANDLED);
366 +}
367 +
368 +/*
369 + * Save the current ts 'event' in an atomic fashion.
370 + */
371 +static void ee93xx_ts_evt_add( int buttons, int iX, int iY, int iPressure )
372 +{
373 +#ifdef PRINT_CALIBRATION_FACTORS
374 + if( iX > iMaxX ) iMaxX = iX;
375 + if( iX < iMinX ) iMinX = iX;
376 + if( iY > iMaxY ) iMaxY = iY;
377 + if( iY < iMinY ) iMinY = iY;
378 +#endif
379 +
380 +
381 + // printk("ee93xx_ts_evt_add\n");
382 + //DPRINTK("cb\n");
383 + /*
384 + * Note the event, but use spinlocks to keep it from getting
385 + * halfway read if we get interrupted.
386 + */
387 +
388 + spin_lock(&event_buffer_lock);
389 + gSample.currentX = iX;
390 + gSample.currentY = iY;
391 + gSample.currentButton = buttons;
392 + gSample.currentPressure = iPressure;
393 + bFreshTouchData = 1;
394 + do_gettimeofday(&gSample.currentTime);
395 +
396 +
397 + spin_unlock(&event_buffer_lock);
398 +
399 + kill_fasync(&ep93xx_fasync, SIGIO, POLL_IN);
400 + wake_up_interruptible(&queue);
401 +
402 +}
403 +
404 +
405 +static ssize_t ep93xx_ts_read(struct file *filp, char *buf, size_t count, loff_t *l)
406 +{
407 +
408 + unsigned short data[3];
409 + struct ts_sample ts_data;
410 + int iReturn = -EFAULT;
411 + // printk("ep93xx_ts_read\n");
412 +
413 +#ifdef PRINT_CALIBRATION_FACTORS
414 + static int lala=0;
415 + if( bFreshTouchData && (lala++ > 9) )
416 + {
417 + DPRINTK("%4d, %4d - range [%4d to %4d],[%4d to %4d]\n",
418 + f, currentY, iMinX, iMaxX, iMinY, iMaxY );
419 + lala = 0;
420 + }
421 +#endif
422 + if( !bFreshTouchData)
423 + {
424 + iReturn = 0;
425 + }
426 + else if( (count == sizeof(data)) )
427 + {
428 + spin_lock_irq(&event_buffer_lock);
429 + bFreshTouchData = 0;
430 + data[0] = gSample.currentX;
431 + data[1] = gSample.currentY;
432 + data[2] = gSample.currentButton;
433 +
434 + spin_unlock_irq(&event_buffer_lock);
435 +
436 + if (copy_to_user(buf, data, sizeof data))
437 + return -EFAULT;
438 +
439 + count -= sizeof(data);
440 +
441 + /* return the # of bytes that got read */
442 + iReturn = sizeof(data) ;
443 + }
444 + else if (count == sizeof(struct ts_sample) )
445 + {
446 + spin_lock_irq(&event_buffer_lock);
447 + bFreshTouchData = 0;
448 + ts_data.x = gSample.currentX;
449 + ts_data.y = gSample.currentY;
450 + ts_data.pressure = gSample.currentPressure;
451 + ts_data.tv = gSample.currentTime;
452 + spin_unlock_irq(&event_buffer_lock);
453 +
454 + if (copy_to_user(buf, &ts_data, sizeof(struct ts_sample)))
455 + {
456 + iReturn = -EFAULT;
457 + }
458 + else
459 + {
460 + count -= sizeof(ts_data);
461 + iReturn = sizeof(ts_data);
462 + }
463 +
464 + }
465 +
466 + return iReturn;
467 +}
468 +
469 +static unsigned int ep93xx_ts_poll(struct file *filp, poll_table *wait)
470 +{
471 + // printk("ep93xx_ts_poll\n");
472 + poll_wait(filp, &queue, wait);
473 +
474 + if( bFreshTouchData )
475 + {
476 + return POLLIN | POLLRDNORM;
477 + }
478 +
479 + return 0;
480 +}
481 +
482 +static int ep93xx_ts_open(struct inode *inode, struct file *filp)
483 +{
484 + printk("ep93xx_ts_open");
485 +
486 + if( down_trylock(&open_sem) )
487 + {
488 + return -EBUSY;
489 + }
490 +
491 + ep93xx_ts_setup();
492 +
493 + return 0;
494 +}
495 +
496 +/*
497 + * Asynchronous I/O support.
498 + */
499 +static int ep93xx_ts_fasync(int fd, struct file *filp, int on)
500 +{
501 + int retval;
502 +
503 + retval = fasync_helper(fd, filp, on, &ep93xx_fasync);
504 + if (retval < 0)
505 + {
506 + return retval;
507 + }
508 +
509 + return 0;
510 +}
511 +
512 +static int ep93xx_ts_release(struct inode *inode, struct file *filp)
513 +{
514 + Stop_Timer2();
515 +
516 + /*
517 + * Call our async I/O support to request that this file
518 + * cease to be used for async I/O.
519 + */
520 + ep93xx_ts_fasync(-1, filp, 0);
521 +
522 + ep93xx_ts_shutdown();
523 +
524 + up(&open_sem);
525 +
526 + return 0;
527 +}
528 +
529 +static ssize_t ep93xx_ts_write(struct file *file, const char *buffer, size_t count,
530 + loff_t *ppos)
531 +{
532 + return -EINVAL;
533 +}
534 +
535 +
536 +static int ep93xx_ts_ioctl(struct inode *inode, struct file *file, uint command, ulong u)
537 +{
538 + static const int version = EV_VERSION;
539 + static const u_int32_t bit =(1 << EV_ABS);
540 + static const u_int32_t absbit = (1 << ABS_X) | (1 << ABS_Y) | (1 << ABS_PRESSURE);
541 + int iReturn ;
542 + int i = 0;
543 +
544 + switch(command)
545 + {
546 + case EVIOCGVERSION:
547 + DPRINTK("ep93xx_ts_ioctl command = EVIOCGVERSION\r\n");
548 + i = copy_to_user((void __user *)u, (void *)version, sizeof(version));
549 + iReturn = i ? -EFAULT : 0;
550 + break;
551 +
552 + case EVIOCGBIT(0,sizeof(u_int32_t) * 8) :
553 + DPRINTK("ep93xx_ts_ioctl command = EVIOCGBIT(0,sizeof(uint32) * 8)\r\n");
554 + i = copy_to_user((void __user *)u, (void *)bit, sizeof(bit));
555 + iReturn = i ? -EFAULT : 0;
556 + break;
557 +
558 + case EVIOCGBIT(EV_ABS, sizeof(absbit) * 8):
559 + DPRINTK("ep93xx_ts_ioctl command = EVIOCGBIT(0,sizeof(uint32) * 8)\r\n");
560 + copy_to_user((void __user *)u, (void *)absbit, sizeof(absbit));
561 + iReturn = i ? -EFAULT : 0;
562 + break;
563 + default:
564 + DPRINTK(" ep93xx_ts_ioctl unknown command = %d\n",u);
565 + iReturn = -1;
566 + break;
567 + }
568 +
569 + return iReturn;
570 +}
571 +
572 +static struct file_operations ep93xx_ts_fops = {
573 + owner: THIS_MODULE,
574 + read: ep93xx_ts_read,
575 + write: ep93xx_ts_write,
576 + poll: ep93xx_ts_poll,
577 + open: ep93xx_ts_open,
578 + ioctl: ep93xx_ts_ioctl,
579 + release: ep93xx_ts_release,
580 + fasync: ep93xx_ts_fasync,
581 +};
582 +
583 +static struct miscdevice ep93xx_ts_miscdev =
584 +{
585 + EP93XX_TS_MINOR,
586 + "ep93xx_ts",
587 + &ep93xx_ts_fops
588 +};
589 +
590 +void ep93xx_ts_setup(void)
591 +{
592 + unsigned int uiKTDIV, uiTSXYMaxMin;
593 + // printk("ep93xx_hw_setup\n");
594 +
595 + /*
596 + * Set the TSEN bit in KTDIV so that we are enabling the clock
597 + * for the touchscreen.
598 + */
599 + uiKTDIV = inl(SYSCON_KTDIV);
600 + uiKTDIV |= SYSCON_KTDIV_TSEN;
601 + SysconSetLocked( SYSCON_KTDIV, uiKTDIV );
602 +
603 + //
604 + // Program the TSSetup and TSSetup2 registers.
605 + //
606 + outl( TSSETUP_DEFAULT, TSSetup );
607 + outl( TSSETUP2_DEFAULT, TSSetup2 );
608 +
609 + //
610 + // Set the the touch settings.
611 + //
612 + outl( 0xaa, TSSWLock );
613 + outl( sSwitchSettings.uiDischarge, TSDirect );
614 +
615 + outl( 0xaa, TSSWLock );
616 + outl( sSwitchSettings.uiDischarge, TSDischarge );
617 +
618 + outl( 0xaa, TSSWLock );
619 + outl( sSwitchSettings.uiSwitchZ1, TSXSample );
620 +
621 + outl( 0xaa, TSSWLock );
622 + outl( sSwitchSettings.uiSwitchZ2, TSYSample );
623 +
624 + outl( 0xaa, TSSWLock );
625 + outl( sSwitchSettings.uiDetect, TSDetect );
626 +
627 + //
628 + // X,YMin set to 0x40 = have to drag that many pixels for a new irq.
629 + // X,YMax set to 0x40 = 1024 pixels is the maximum movement within the
630 + // time scan limit.
631 + //
632 + uiTSXYMaxMin = (50 << TSMAXMIN_XMIN_SHIFT) & TSMAXMIN_XMIN_MASK;
633 + uiTSXYMaxMin |= (50 << TSMAXMIN_YMIN_SHIFT) & TSMAXMIN_YMIN_MASK;
634 + uiTSXYMaxMin |= (0xff << TSMAXMIN_XMAX_SHIFT) & TSMAXMIN_XMAX_MASK;
635 + uiTSXYMaxMin |= (0xff << TSMAXMIN_YMAX_SHIFT) & TSMAXMIN_YMAX_MASK;
636 + outl( uiTSXYMaxMin, TSXYMaxMin );
637 +
638 + bCurrentPenDown = 0;
639 + bFreshTouchData = 0;
640 + guiLastX = 0;
641 + guiLastY = 0;
642 + guiLastInvPressure = 0xffffff;
643 +
644 + //
645 + // Enable the touch screen scanning engine.
646 + //
647 + TS_Hardware_Scan_Mode();
648 +}
649 +
650 +/*
651 + * ep93xx_ts_shutdown
652 + *
653 + */
654 +static void
655 +ep93xx_ts_shutdown(void)
656 +{
657 + unsigned int uiKTDIV;
658 +
659 + DPRINTK("ep93xx_ts_shutdown\n");
660 +
661 + sTouch.state = TS_STATE_STOPPED;
662 + Stop_Timer2();
663 +
664 + /*
665 + * Disable the scanning engine.
666 + */
667 + outl( 0, TSSetup );
668 + outl( 0, TSSetup2 );
669 +
670 + /*
671 + * Clear the TSEN bit in KTDIV so that we are disabling the clock
672 + * for the touchscreen.
673 + */
674 + uiKTDIV = inl(SYSCON_KTDIV);
675 + uiKTDIV &= ~SYSCON_KTDIV_TSEN;
676 + SysconSetLocked( SYSCON_KTDIV, uiKTDIV );
677 +
678 +} /* ep93xx_ts_shutdown */
679 +
680 +static irqreturn_t ep93xx_timer2_isr(int irq, void *dev_id)
681 +{
682 + DPRINTK("%d", (int)sTouch.state );
683 +
684 + switch( sTouch.state )
685 + {
686 + case TS_STATE_STOPPED:
687 + TS_Hardware_Scan_Mode();
688 + break;
689 +
690 + //
691 + // Get the Z1 value for pressure measurement and set up
692 + // the switch register for getting the Z2 measurement.
693 + //
694 + case TS_STATE_Z1:
695 + Set_Timer2_uSec( EP93XX_TS_ADC_DELAY_USEC );
696 + sTouch.uiZ1 = ADCGetData( 2, 200 );
697 + ep93xx_ts_set_direct( sSwitchSettings.uiSwitchZ2 );
698 + sTouch.state = TS_STATE_Z2;
699 + break;
700 +
701 + //
702 + // Get the Z2 value for pressure measurement and set up
703 + // the switch register for getting the Y measurement.
704 + //
705 + case TS_STATE_Z2:
706 + sTouch.uiZ2 = ADCGetData( 2, 200 );
707 + ep93xx_ts_set_direct( sSwitchSettings.uiYSample );
708 + sTouch.state = TS_STATE_Y;
709 + break;
710 +
711 + //
712 + // Get the Y value and set up the switch register for
713 + // getting the X measurement.
714 + //
715 + case TS_STATE_Y:
716 + sTouch.uiY = ADCGetData( 4, 20 );
717 + ep93xx_ts_set_direct( sSwitchSettings.uiXSample );
718 + sTouch.state = TS_STATE_X;
719 + break;
720 +
721 + //
722 + // Read the X value. This is the last of the 4 adc values
723 + // we need so we continue on to process the data.
724 + //
725 + case TS_STATE_X:
726 + Stop_Timer2();
727 +
728 + sTouch.uiX = ADCGetData( 4, 20 );
729 +
730 + outl( 0xaa, TSSWLock );
731 + outl( sSwitchSettings.uiDischarge, TSDirect );
732 +
733 + sTouch.state = TS_STATE_DONE;
734 +
735 + /*
736 + * Process this set of ADC readings.
737 + */
738 + ProcessPointData();
739 +
740 + break;
741 +
742 +
743 + //
744 + // Shouldn't get here. But if we do, we can recover...
745 + //
746 + case TS_STATE_DONE:
747 + TS_Hardware_Scan_Mode();
748 + break;
749 + }
750 +
751 + //
752 + // Clear the timer2 interrupt.
753 + //
754 + outl( 1, TIMER2CLEAR );
755 + return(IRQ_HANDLED);
756 +}
757 +
758 +/*---------------------------------------------------------------------
759 + * ProcessPointData
760 + *
761 + * This routine processes the ADC data into usable point data and then
762 + * puts the driver into hw or sw scanning mode before returning.
763 + *
764 + * We calculate inverse pressure (lower number = more pressure) then
765 + * do a hystheresis with the two pressure values 'light' and 'heavy'.
766 + *
767 + * If we are above the light, we have pen up.
768 + * If we are below the heavy we have pen down.
769 + * As long as the pressure stays below the light, pen stays down.
770 + * When we get above the light again, pen goes back up.
771 + *
772 + */
773 +static void ProcessPointData(void)
774 +{
775 + int bValidPoint = 0;
776 + unsigned int uiXDiff, uiYDiff, uiInvPressureDiff;
777 + unsigned int uiInvPressure;
778 +
779 + //
780 + // Calculate the current pressure.
781 + //
782 + uiInvPressure = CalculateInvPressure();
783 +
784 + DPRINTK(" X=0x%x, Y=0x%x, Z1=0x%x, Z2=0x%x, InvPressure=0x%x",
785 + sTouch.uiX, sTouch.uiY, sTouch.uiZ1, sTouch.uiZ2, uiInvPressure );
786 +
787 + //
788 + // If pen pressure is so light that it is greater than the 'max' setting
789 + // then we consider this to be a pen up.
790 + //
791 + if( uiInvPressure >= TS_LIGHT_INV_PRESSURE )
792 + {
793 + DPRINTK(" -- up \n");
794 + bCurrentPenDown = 0;
795 + ee93xx_ts_evt_add( 0, guiLastX, guiLastY, 0 );
796 + TS_Hardware_Scan_Mode();
797 + return;
798 + }
799 +
800 + //
801 + // Hystheresis:
802 + // If the pen pressure is hard enough to be less than the 'min' OR
803 + // the pen is already down and is still less than the 'max'...
804 + //
805 + if( (uiInvPressure < TS_HEAVY_INV_PRESSURE) ||
806 + ( bCurrentPenDown && (uiInvPressure < TS_LIGHT_INV_PRESSURE) ) )
807 + {
808 + if( bCurrentPenDown )
809 + {
810 + //
811 + // If pen was previously down, check the difference between
812 + // the last sample and this one... if the difference between
813 + // samples is too great, ignore the sample.
814 + //
815 + uiXDiff = abs(guiLastX - sTouch.uiX);
816 + uiYDiff = abs(guiLastY - sTouch.uiY);
817 + uiInvPressureDiff = abs(guiLastInvPressure - uiInvPressure);
818 +
819 + if( (uiXDiff < TS_MAX_VALID_XY_CHANGE) && (uiYDiff < TS_MAX_VALID_XY_CHANGE) &&
820 + (uiInvPressureDiff < TS_MAX_VALID_PRESSURE_CHANGE) )
821 + {
822 + DPRINTK(" -- valid(two) \n");
823 + bValidPoint = 1;
824 + }
825 + else
826 + {
827 + DPRINTK(" -- INvalid(two) \n");
828 + }
829 + }
830 + else
831 + {
832 + DPRINTK(" -- valid \n");
833 + bValidPoint = 1;
834 + }
835 +
836 + /*
837 + * If either the pen was put down or dragged make a note of it.
838 + */
839 + if( bValidPoint )
840 + {
841 + guiLastX = sTouch.uiX;
842 + guiLastY = sTouch.uiY;
843 + guiLastInvPressure = uiInvPressure;
844 + bCurrentPenDown = 1;
845 + ee93xx_ts_evt_add( 1, sTouch.uiX, sTouch.uiY, (0x7000000 /uiInvPressure) );
846 + }
847 +
848 + TS_Soft_Scan_Mode();
849 + return;
850 + }
851 +
852 + DPRINTK(" -- fallout \n");
853 + TS_Hardware_Scan_Mode();
854 +}
855 +
856 +static void ep93xx_ts_set_direct( unsigned int uiADCSwitch )
857 +{
858 + unsigned int uiResult;
859 +
860 + //
861 + // Set the switch settings in the direct register.
862 + //
863 + outl( 0xaa, TSSWLock );
864 + outl( uiADCSwitch, TSDirect );
865 +
866 + //
867 + // Read and throw away the first sample.
868 + //
869 + do {
870 + uiResult = inl(TSXYResult);
871 + } while( !(uiResult & TSXYRESULT_SDR) );
872 +
873 +}
874 +
875 +static unsigned int ADCGetData
876 +(
877 + unsigned int uiSamples,
878 + unsigned int uiMaxDiff
879 +)
880 +{
881 + unsigned int uiResult, uiValue, uiCount, uiLowest, uiHighest, uiSum, uiAve;
882 +
883 + do
884 + {
885 + //
886 + //Initialize our values.
887 + //
888 + uiLowest = 0xfffffff;
889 + uiHighest = 0;
890 + uiSum = 0;
891 +
892 + for( uiCount = 0 ; uiCount < uiSamples ; uiCount++ )
893 + {
894 + //
895 + // Read the touch screen four more times and average.
896 + //
897 + do {
898 + uiResult = inl(TSXYResult);
899 + } while( !(uiResult & TSXYRESULT_SDR) );
900 +
901 + uiValue = (uiResult & TSXYRESULT_AD_MASK) >> TSXYRESULT_AD_SHIFT;
902 + uiValue = ((uiValue >> 4) + ((1 + TSXYRESULT_X_MASK)>>1)) & TSXYRESULT_X_MASK;
903 +
904 + //
905 + // Add up the values.
906 + //
907 + uiSum += uiValue;
908 +
909 + //
910 + // Get the lowest and highest values.
911 + //
912 + if( uiValue < uiLowest )
913 + {
914 + uiLowest = uiValue;
915 + }
916 + if( uiValue > uiHighest )
917 + {
918 + uiHighest = uiValue;
919 + }
920 + }
921 +
922 + } while( (uiHighest - uiLowest) > uiMaxDiff );
923 +
924 + //
925 + // Calculate the Average value.
926 + //
927 + uiAve = uiSum / uiSamples;
928 +
929 + return uiAve;
930 +}
931 +
932 +//****************************************************************************
933 +// CalculateInvPressure
934 +//****************************************************************************
935 +// Is the Touch Valid. Touch is not valid if the X or Y value is not
936 +// in range and the pressure is not enough.
937 +//
938 +// Touch resistance can be measured by the following formula:
939 +//
940 +// Rx * X * Z2
941 +// Rtouch = --------- * (-- - 1)
942 +// 4096 Z1
943 +//
944 +// This is simplified in the ration of Rtouch to Rx. The lower the value, the
945 +// higher the pressure.
946 +//
947 +// Z2
948 +// InvPressure = X * (-- - 1)
949 +// Z1
950 +//
951 +static unsigned int CalculateInvPressure(void)
952 +{
953 + unsigned int uiInvPressure;
954 +
955 + //
956 + // Check to see if the point is valid.
957 + //
958 + if( sTouch.uiZ1 < MIN_Z1_VALUE )
959 + {
960 + uiInvPressure = 0x10000;
961 + }
962 +
963 + //
964 + // Can omit the pressure calculation if you need to get rid of the division.
965 + //
966 + else
967 + {
968 + uiInvPressure = ((sTouch.uiX * sTouch.uiZ2) / sTouch.uiZ1) - sTouch.uiX;
969 + }
970 +
971 + return uiInvPressure;
972 +}
973 +
974 +
975 +
976 +//****************************************************************************
977 +// TS_Hardware_Scan_Mode
978 +//****************************************************************************
979 +// Enables the ep93xx ts scanning engine so that when the pen goes down
980 +// we will get an interrupt.
981 +//
982 +//
983 +static void TS_Hardware_Scan_Mode(void)
984 +{
985 + unsigned int uiDevCfg;
986 +
987 + DPRINTK("S\n");
988 +
989 + //
990 + // Disable the soft scanning engine.
991 + //
992 + sTouch.state = TS_STATE_STOPPED;
993 + Stop_Timer2();
994 +
995 + //
996 + // Clear the TIN (Touchscreen INactive) bit so we can go to
997 + // automatic scanning mode.
998 + //
999 + uiDevCfg = inl( EP93XX_SYSCON_DEVICE_CONFIG );
1000 + SysconSetLocked( EP93XX_SYSCON_DEVICE_CONFIG, (uiDevCfg & ~EP93XX_SYSCON_DEVCFG_TIN) );
1001 +
1002 + //
1003 + // Enable the touch screen scanning state machine by setting
1004 + // the ENABLE bit.
1005 + //
1006 + outl( (TSSETUP_DEFAULT | TSSETUP_ENABLE), TSSetup );
1007 +
1008 + //
1009 + // Set the flag to show that we are in interrupt mode.
1010 + //
1011 + gScanningMode = TS_MODE_HARDWARE_SCAN;
1012 +
1013 + //
1014 + // Initialize TSSetup2 register.
1015 + //
1016 + outl( TSSETUP2_DEFAULT, TSSetup2 );
1017 +
1018 +}
1019 +
1020 +//****************************************************************************
1021 +// TS_Soft_Scan_Mode
1022 +//****************************************************************************
1023 +// Sets the touch screen to manual polling mode.
1024 +//
1025 +//
1026 +static void TS_Soft_Scan_Mode(void)
1027 +{
1028 + unsigned int uiDevCfg;
1029 +
1030 + DPRINTK("M\n");
1031 +
1032 + if( gScanningMode != TS_MODE_SOFT_SCAN )
1033 + {
1034 + //
1035 + // Disable the touch screen scanning state machine by clearing
1036 + // the ENABLE bit.
1037 + //
1038 + outl( TSSETUP_DEFAULT, TSSetup );
1039 +
1040 + //
1041 + // Set the TIN bit so we can do manual touchscreen polling.
1042 + //
1043 + uiDevCfg = inl(EP93XX_SYSCON_DEVICE_CONFIG );
1044 + SysconSetLocked( EP93XX_SYSCON_DEVICE_CONFIG, (uiDevCfg | EP93XX_SYSCON_DEVCFG_TIN) );
1045 + }
1046 +
1047 + //
1048 + // Set the switch register up for the first ADC reading
1049 + //
1050 + ep93xx_ts_set_direct( sSwitchSettings.uiSwitchZ1 );
1051 +
1052 + //
1053 + // Initialize our software state machine to know which ADC
1054 + // reading to take
1055 + //
1056 + sTouch.state = TS_STATE_Z1;
1057 +
1058 + //
1059 + // Set the timer so after a mSec or two settling delay it will
1060 + // take the first ADC reading.
1061 + //
1062 + Set_Timer2_uSec( EP93XX_TS_PER_POINT_DELAY_USEC );
1063 +
1064 + //
1065 + // Note that we are in sw scanning mode not hw scanning mode.
1066 + //
1067 + gScanningMode = TS_MODE_SOFT_SCAN;
1068 +
1069 +}
1070 +
1071 +static void Set_Timer2_uSec( unsigned int uiDelay_uSec )
1072 +{
1073 + unsigned int uiClockTicks;
1074 +
1075 + /*
1076 + * Stop timer 2
1077 + */
1078 + outl( 0, TIMER2CONTROL );
1079 +
1080 + uiClockTicks = ((uiDelay_uSec * 508) + 999) / 1000;
1081 + outl( uiClockTicks, TIMER2LOAD );
1082 + outl( uiClockTicks, TIMER2VALUE );
1083 +
1084 + /*
1085 + * Set up Timer 2 for 508 kHz clock and periodic mode.
1086 + */
1087 + outl( 0xC8, TIMER2CONTROL );
1088 +
1089 +}
1090 +
1091 +static void Stop_Timer2(void)
1092 +{
1093 + outl( 0, TIMER2CONTROL );
1094 +}
1095 +
1096 +/*
1097 + * Initialization and exit routines
1098 + */
1099 +int __init ep93xx_ts_init(void)
1100 +{
1101 + int retval;
1102 +
1103 + //printk("ep93xx_ts_init\n");
1104 +
1105 + // printk("request Touchscreen interrupt.\n");
1106 + retval = request_irq( IRQ_EP93XX_TOUCH, ep93xx_ts_isr, IRQF_DISABLED, "ep93xx_ts", 0);
1107 + if( retval )
1108 + {
1109 + printk(KERN_WARNING "ep93xx_ts: failed to get touchscreen IRQ\n");
1110 + return retval;
1111 + }
1112 +
1113 + // printk("Request Timer interrupt.\n");
1114 + retval = request_irq( IRQ_EP93XX_TIMER2, ep93xx_timer2_isr,
1115 + IRQF_DISABLED, "ep93xx_timer2", 0);
1116 + if( retval )
1117 + {
1118 + printk(KERN_WARNING "ep93xx_ts: failed to get timer2 IRQ\n");
1119 + return retval;
1120 + }
1121 +
1122 + // printk("Register Touchscreen Driver\n");
1123 + misc_register(&ep93xx_ts_miscdev);
1124 +
1125 + sTouch.state = TS_STATE_STOPPED;
1126 + gScanningMode = TS_MODE_UN_INITIALIZED;
1127 +
1128 + printk(KERN_NOTICE "ep93xx touchscreen driver configured for 4-wire operation\n");
1129 +
1130 + return 0;
1131 +}
1132 +void __exit
1133 +ep93xx_ts_exit(void)
1134 +{
1135 + DPRINTK("ep93xx_ts_exit\n");
1136 +
1137 + Stop_Timer2();
1138 +
1139 + free_irq(IRQ_EP93XX_TOUCH, 0);
1140 + free_irq(IRQ_EP93XX_TIMER2, 0);
1141 +
1142 + misc_deregister(&ep93xx_ts_miscdev);
1143 +}
1144 +
1145 +module_init(ep93xx_ts_init);
1146 +module_exit(ep93xx_ts_exit);
1147 +
1148 +MODULE_DESCRIPTION("Cirrus EP93xx touchscreen driver");
1149 +MODULE_SUPPORTED_DEVICE("touchscreen/ep93xx");
1150 Index: linux-2.6.30.9/drivers/input/touchscreen/ep93xx_ts.h
1151 ===================================================================
1152 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1153 +++ linux-2.6.30.9/drivers/input/touchscreen/ep93xx_ts.h 2009-11-24 21:00:45.000000000 +0100
1154 @@ -0,0 +1,53 @@
1155 +/*
1156 + * ep93xx_ts.h
1157 + *
1158 + * The contents of this file are subject to the Mozilla Public License
1159 + * Version 1.1 (the "License"); you may not use this file except in
1160 + * compliance with the License. You may obtain a copy of the License
1161 + * at http://www.mozilla.org/MPL/
1162 + *
1163 + * Software distributed under the License is distributed on an "AS IS"
1164 + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
1165 + * the License for the specific language governing rights and
1166 + * limitations under the License.
1167 + *
1168 + * The initial developer of the original code is David A. Hinds
1169 + * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
1170 + * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
1171 + *
1172 + * Alternatively, the contents of this file may be used under the
1173 + * terms of the GNU General Public License version 2 (the "GPL"), in
1174 + * which case the provisions of the GPL are applicable instead of the
1175 + * above. If you wish to allow the use of your version of this file
1176 + * only under the terms of the GPL and not to allow others to use
1177 + * your version of this file under the MPL, indicate your decision by
1178 + * deleting the provisions above and replace them with the notice and
1179 + * other provisions required by the GPL. If you do not delete the
1180 + * provisions above, a recipient may use your version of this file
1181 + * under either the MPL or the GPL.
1182 + */
1183 +
1184 +#ifndef _LINUX_EP93XX_TS_H
1185 +#define _LINUX_EP93XX_TS_H
1186 +
1187 +/*touchscreen register defines*/
1188 +#define SYSCON_KTDIV EP93XX_SYSCON_KEY_TOUCH_CLOCK_DIV
1189 +#define SYSCON_SWLOCK EP93XX_SYSCON_SWLOCK
1190 +#define TSSetup EP93XX_TOUCHSCREEN_TSSetup
1191 +#define TSXYMaxMin EP93XX_TOUCHSCREEN_TSXYMaxMin
1192 +#define TSXYResult EP93XX_TOUCHSCREEN_TSDischarge
1193 +#define TSDischarge EP93XX_TOUCHSCREEN_TSDischarge
1194 +#define TSXSample EP93XX_TOUCHSCREEN_TSXSample
1195 +#define TSYSample EP93XX_TOUCHSCREEN_TSYSample
1196 +#define TSDirect EP93XX_TOUCHSCREEN_TSDirect
1197 +#define TSDetect EP93XX_TOUCHSCREEN_TSDetect
1198 +#define TSSWLock EP93XX_TOUCHSCREEN_TSSWLock
1199 +#define TSSetup2 EP93XX_TOUCHSCREEN_TSSetup2
1200 +
1201 +
1202 +//#define SYSCON_DEVCFG EP93XX_SYSCON_DEVICE_CONFIG
1203 +#define TIMER2CONTROL EP93XX_TIMER2_CONTROL
1204 +#define TIMER2LOAD EP93XX_TIMER2_LOAD
1205 +#define TIMER2VALUE EP93XX_TIMER2_VALUE
1206 +#define TIMER2CLEAR EP93XX_TIMER2_CLEAR
1207 +#endif
1208 Index: linux-2.6.30.9/arch/arm/mach-ep93xx/include/mach/hardware.h
1209 ===================================================================
1210 --- linux-2.6.30.9.orig/arch/arm/mach-ep93xx/include/mach/hardware.h 2009-11-24 21:00:18.000000000 +0100
1211 +++ linux-2.6.30.9/arch/arm/mach-ep93xx/include/mach/hardware.h 2009-11-24 21:09:21.000000000 +0100
1212 @@ -7,6 +7,7 @@
1213 #include "ep93xx-regs.h"
1214
1215 #define pcibios_assign_all_busses() 0
1216 +#include "regs_touch.h"
1217
1218 #include "platform.h"
1219
1220 Index: linux-2.6.30.9/arch/arm/mach-ep93xx/include/mach/regs_touch.h
1221 ===================================================================
1222 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1223 +++ linux-2.6.30.9/arch/arm/mach-ep93xx/include/mach/regs_touch.h 2009-11-24 21:00:45.000000000 +0100
1224 @@ -0,0 +1,95 @@
1225 +/*=============================================================================
1226 + *
1227 + * FILE: regs_touch.h
1228 + *
1229 + * DESCRIPTION: Analog Touchscreen Register Definition
1230 + *
1231 + * Copyright Cirrus Logic, 2001-2003
1232 + *
1233 + * This program is free software; you can redistribute it and/or modify
1234 + * it under the terms of the GNU General Public License as published by
1235 + * the Free Software Foundation; either version 2 of the License, or
1236 + * (at your option) any later version.
1237 + *
1238 + * This program is distributed in the hope that it will be useful,
1239 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1240 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1241 + * GNU General Public License for more details.
1242 + *
1243 + * You should have received a copy of the GNU General Public License
1244 + * along with this program; if not, write to the Free Software
1245 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1246 + *=============================================================================
1247 + */
1248 +#ifndef _REGS_TOUCH_H_
1249 +#define _REGS_TOUCH_H_
1250 +
1251 +/*
1252 + *-----------------------------------------------------------------------------
1253 + * Individual bit #defines
1254 + *-----------------------------------------------------------------------------
1255 + */
1256 +#define TSSETUP_SDLY_MASK 0x000003FF
1257 +#define TSSETUP_SDLY_SHIFT 0
1258 +#define TSSETUP_NSMP_4 0x00000000
1259 +#define TSSETUP_NSMP_8 0x00000400
1260 +#define TSSETUP_NSMP_16 0x00000800
1261 +#define TSSETUP_NSMP_32 0x00000C00
1262 +#define TSSETUP_NSMP_MASK 0x00000C00
1263 +#define TSSETUP_DEV_4 0x00000000
1264 +#define TSSETUP_DEV_8 0x00001000
1265 +#define TSSETUP_DEV_12 0x00002000
1266 +#define TSSETUP_DEV_16 0x00003000
1267 +#define TSSETUP_DEV_24 0x00004000
1268 +#define TSSETUP_DEV_32 0x00005000
1269 +#define TSSETUP_DEV_64 0x00006000
1270 +#define TSSETUP_DEV_128 0x00007000
1271 +#define TSSETUP_ENABLE 0x00008000
1272 +#define TSSETUP_DLY_MASK 0x03FF0000
1273 +#define TSSETUP_DLY_SHIFT 16
1274 +#define TSSETUP_TDTCT 0x80000000
1275 +
1276 +#define TSMAXMIN_XMIN_MASK 0x000000FF
1277 +#define TSMAXMIN_XMIN_SHIFT 0
1278 +#define TSMAXMIN_YMIN_MASK 0x0000FF00
1279 +#define TSMAXMIN_YMIN_SHIFT 8
1280 +#define TSMAXMIN_XMAX_MASK 0x00FF0000
1281 +#define TSMAXMIN_XMAX_SHIFT 16
1282 +#define TSMAXMIN_YMAX_MASK 0xFF000000
1283 +#define TSMAXMIN_YMAX_SHIFT 24
1284 +
1285 +#define TSXYRESULT_X_MASK 0x00000FFF
1286 +#define TSXYRESULT_X_SHIFT 0
1287 +#define TSXYRESULT_AD_MASK 0x0000FFFF
1288 +#define TSXYRESULT_AD_SHIFT 0
1289 +#define TSXYRESULT_Y_MASK 0x0FFF0000
1290 +#define TSXYRESULT_Y_SHIFT 16
1291 +#define TSXYRESULT_SDR 0x80000000
1292 +
1293 +#define TSX_SAMPLE_MASK 0x00003FFF
1294 +#define TSX_SAMPLE_SHIFT 0x00
1295 +#define TSY_SAMPLE_MASK 0x3FFF0000
1296 +#define TSY_SAMPLE_SHIFT 0x10
1297 +
1298 +#define TSSETUP2_TINT 0x00000001
1299 +#define TSSETUP2_NICOR 0x00000002
1300 +#define TSSETUP2_PINT 0x00000004
1301 +#define TSSETUP2_PENSTS 0x00000008
1302 +#define TSSETUP2_PINTEN 0x00000010
1303 +#define TSSETUP2_DEVINT 0x00000020
1304 +#define TSSETUP2_DINTEN 0x00000040
1305 +#define TSSETUP2_DTMEN 0x00000080
1306 +#define TSSETUP2_DISDEV 0x00000100
1307 +#define TSSETUP2_NSIGND 0x00000200
1308 +#define TSSETUP2_S28EN 0x00000400
1309 +#define TSSETUP2_RINTEN 0x00000800
1310 +
1311 +#define TSXYRESULT_SDR 0x80000000
1312 +
1313 +/*
1314 + *-----------------------------------------------------------------------------
1315 + *-----------------------------------------------------------------------------
1316 + */
1317 +
1318 +
1319 +#endif /* _REGS_TOUCH_H_ */
This page took 0.107905 seconds and 5 git commands to generate.