diff -urN linux-2.4.0-test8-rmk1-np1/drivers/block/flash_mem.c linux-2.4.0-test8-rmk1-np1-ck1/drivers/block/flash_mem.c --- linux-2.4.0-test8-rmk1-np1/drivers/block/flash_mem.c Wed Sep 13 16:24:20 2000 +++ linux-2.4.0-test8-rmk1-np1-ck1/drivers/block/flash_mem.c Wed Sep 13 16:00:49 2000 @@ -73,7 +73,7 @@ /* features*/ #define USE_WRITE_BUFFER #define WRITE_VERIFY -#if 1 +#if 0 #define FLASH_DEBUG_CFI #if 0 #define FLASH_VERBOSE diff -urN linux-2.4.0-test8-rmk1-np1/drivers/char/Config.in linux-2.4.0-test8-rmk1-np1-ck1/drivers/char/Config.in --- linux-2.4.0-test8-rmk1-np1/drivers/char/Config.in Wed Sep 13 16:23:56 2000 +++ linux-2.4.0-test8-rmk1-np1-ck1/drivers/char/Config.in Wed Sep 13 15:33:37 2000 @@ -74,6 +74,8 @@ if [ "$CONFIG_ARCH_SA1100" = "y" ]; then bool ' Console on SA1100 serial port' CONFIG_SERIAL_SA1100_CONSOLE fi + tristate 'UCB1200 touchscreen support' CONFIG_TOUCHSCREEN_UCB1200 + tristate 'Bitsy touchscreen support' CONFIG_TOUCHSCREEN_BITSY fi if [ "$CONFIG_ARCH_INTEGRATOR" = "y" ]; then bool 'ARM AMBA serial port support' CONFIG_SERIAL_AMBA diff -urN linux-2.4.0-test8-rmk1-np1/drivers/char/ucb1200_ts.c linux-2.4.0-test8-rmk1-np1-ck1/drivers/char/ucb1200_ts.c --- linux-2.4.0-test8-rmk1-np1/drivers/char/ucb1200_ts.c Wed Sep 13 16:24:20 2000 +++ linux-2.4.0-test8-rmk1-np1-ck1/drivers/char/ucb1200_ts.c Wed Sep 13 16:14:26 2000 @@ -18,12 +18,18 @@ * iPAQ emulation derived from Driver for the h3600 Touch Screen * Copyright 2000 Compaq Computer Corporation. * Author: Charles Flynn. + * + * Add Some function to let it more flexible + * Allen_cheng@xlinux.com + * chester@linux.org.tw */ /* * INSTRUCTIONS * To use this driver, simply ``mknod /dev/h3600_ts c 11 0'' and * use it as if it were an iPAQ. TODO: iPAQ-compatible IOCTL's. + * + * */ #include @@ -39,634 +45,653 @@ #include #include #include -#include "sa1100_ts.h" +#include "linux/sa1100_ts.h" -/* - * From Compaq's Touch Screen Specification version 0.2 (draft) - */ +/* From Compaq's Touch Screen Specification version 0.2 (draft) */ typedef struct { - short pressure; - int x; - int y; - int millisecs; + short pressure; + short x; + short y; + short millisecs; } TS_EVENT; -/* - * Settings and definitions - */ -#define TS_MAJOR 11 -#define TS_NAME "h3600" -static int raw_max_x, raw_max_y, res_x, res_y, - raw_min_x, raw_min_y, xyswap; -static char *dev_id = "h3600"; -static wait_queue_head_t queue; -static struct timer_list timer; -static int Reg10; -#define PRESSED 0 -#define P_DONE 1 -#define X_DONE 2 -#define Y_DONE 3 -#define RELEASED 4 -#define BUFSIZE 128 -#define XLIMIT 160 -#define YLIMIT 160 -static int state, head, tail, sample; -static TS_EVENT cur_data, samples[3], buf[BUFSIZE]; -static struct fasync_struct *fasync; -static unsigned long in_timehandle = 0; - -static inline void -ts_clear_codec_int(void) -{ - int s; - - /* - * Clear interrupts at codec - */ - if ((s = codec_read(CODEC_REG_INT_STATUS) & (TSPX_INT | ADC_INT))) { - codec_write(CODEC_REG_INT_STATUS, 0); - codec_write(CODEC_REG_INT_STATUS, s); - } -} - -static inline void -set_read_x_pos(void) -{ - /* - * See Philips' AN809 for an explanation of the pressure mode - * switch - */ - codec_write(CODEC_REG_TS_CTL, TSPX_POW | TSMX_GND | - TSC_MODE_PRESSURE | TSC_BIAS_ENA); -#ifdef CONFIG_SA1100_CERF - codec_write(CODEC_REG_ADC_CTL, Reg10 = ADC_INPUT_TSPY | - ADC_ENA); -#else - codec_write(CODEC_REG_ADC_CTL, Reg10 = ADC_INPUT_TSPY | - ADC_ENA | ADC_SYNC_ENA); -#endif - codec_write(CODEC_REG_TS_CTL, TSPX_POW | TSMX_GND | - TSC_MODE_POSITION | TSC_BIAS_ENA); - udelay(50); - codec_write(CODEC_REG_ADC_CTL, Reg10 | ADC_START); -#ifndef CONFIG_SA1100_CERF - codec_write(CODEC_REG_IO_DATA, - codec_read(CODEC_REG_IO_DATA) | 0x200); - codec_write(CODEC_REG_ADC_CTL, Reg10); - codec_write(CODEC_REG_IO_DATA, - codec_read(CODEC_REG_IO_DATA) & ~0x200); -#endif +static int raw_max_x, raw_max_y, res_x, res_y, raw_min_x, raw_min_y, xyswap; + +static int cal_ok, x_rev, y_rev; + +static char *dev_id = "ucb1200"; + +static wait_queue_head_t queue; +static struct timer_list timer; +static int Reg10; +#define PRESSED 0 +#define P_DONE 1 +#define X_DONE 2 +#define Y_DONE 3 +#define RELEASED 4 +#define BUFSIZE 128 +#define XLIMIT 160 +#define YLIMIT 160 +static int state, head, tail, sample; +static TS_EVENT cur_data, samples[3], buf[BUFSIZE]; +static struct fasync_struct *fasync; +static unsigned long in_timehandle = 0; + + +/* Useful operations */ +static inline ushort codec_read(ushort addr) +{ + ulong flags; + ushort data; + + save_flags_cli(flags); + while (!(Ser4MCSR & MCSR_CWC)); + Ser4MCDR2 = ((addr & 0xf) << FShft(MCDR2_ADD)) | MCDR2_Rd; + while (!(Ser4MCSR & MCSR_CRC)); + data = Ser4MCDR2 & 0xffff; + restore_flags(flags); + return data; } -static inline void -set_read_y_pos(void) +static inline void codec_write(ushort addr, ushort data) { - codec_write(CODEC_REG_TS_CTL, TSPY_POW | TSMY_GND | - TSC_MODE_PRESSURE | TSC_BIAS_ENA); -#ifdef CONFIG_SA1100_CERF - codec_write(CODEC_REG_ADC_CTL, Reg10 = ADC_INPUT_TSPX | - ADC_ENA); -#else - codec_write(CODEC_REG_ADC_CTL, Reg10 = ADC_INPUT_TSPX | - ADC_ENA | ADC_SYNC_ENA); -#endif - codec_write(CODEC_REG_TS_CTL, TSPY_POW | TSMY_GND | - TSC_MODE_POSITION | TSC_BIAS_ENA); - udelay(50); - codec_write(CODEC_REG_ADC_CTL, Reg10 | ADC_START); -#ifndef CONFIG_SA1100_CERF - codec_write(CODEC_REG_IO_DATA, - codec_read(CODEC_REG_IO_DATA) | 0x200); - codec_write(CODEC_REG_ADC_CTL, Reg10); - codec_write(CODEC_REG_IO_DATA, - codec_read(CODEC_REG_IO_DATA) & ~0x200); -#endif + ulong flags; + + save_flags_cli(flags); + while (!(Ser4MCSR & MCSR_CWC)); + Ser4MCDR2 = ((addr & 0xf) << FShft(MCDR2_ADD)) | MCDR2_Wr | (data & 0xffff); + restore_flags(flags); } -static inline void -set_read_pressure(void) +static inline void ts_clear_codec_int(void) { - codec_write(CODEC_REG_TS_CTL, TSPX_POW | TSMX_POW | - TSPY_GND | TSMY_GND | TSC_MODE_PRESSURE | - TSC_BIAS_ENA); -#ifdef CONFIG_SA1100_CERF - codec_write(CODEC_REG_ADC_CTL, Reg10 = ADC_INPUT_TSPX | - ADC_ENA); -#else - codec_write(CODEC_REG_ADC_CTL, Reg10 = ADC_INPUT_TSPX | - ADC_ENA | ADC_SYNC_ENA); -#endif - udelay(50); - codec_write(CODEC_REG_ADC_CTL, Reg10 | ADC_START); -#ifndef CONFIG_SA1100_CERF - codec_write(CODEC_REG_IO_DATA, - codec_read(CODEC_REG_IO_DATA) | 0x200); - codec_write(CODEC_REG_ADC_CTL, Reg10); - codec_write(CODEC_REG_IO_DATA, - codec_read(CODEC_REG_IO_DATA) & ~0x200); -#endif + int s; + +/* Clear interrupts at codec */ + if ((s = codec_read(CODEC_REG_INT_STATUS) & (TSPX_INT | ADC_INT))) + { + codec_write(CODEC_REG_INT_STATUS, 0); + codec_write(CODEC_REG_INT_STATUS, s); + } } -static int -read_adc(void) +static inline void set_read_x_pos(void) { - int v; +/* See Philips' AN809 for an explanation of the pressure mode switch */ + codec_write(CODEC_REG_TS_CTL, TSPX_POW | TSMX_GND | TSC_MODE_PRESSURE | TSC_BIAS_ENA); + + codec_write(CODEC_REG_ADC_CTL, Reg10 = ADC_INPUT_TSPY | ADC_ENA | ADC_SYNC_ENA); - while (!((v = codec_read(CODEC_REG_ADC_DATA)) & ADC_DAT_VAL)); - return GET_ADC_DATA(v); + codec_write(CODEC_REG_TS_CTL, TSPX_POW | TSMX_GND | TSC_MODE_POSITION | TSC_BIAS_ENA); + + udelay(50); + + codec_write(CODEC_REG_ADC_CTL, Reg10 | ADC_START); + + codec_write(CODEC_REG_IO_DATA, codec_read(CODEC_REG_IO_DATA) | 0x200); + + codec_write(CODEC_REG_ADC_CTL, Reg10); + + codec_write(CODEC_REG_IO_DATA, codec_read(CODEC_REG_IO_DATA) & ~0x200); } -static int -sa1100_ts_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg) -{ - /* - * Microwindows style (should change to TS_CAL when the - * specification is ready) - */ - switch (cmd) { - case 3: - raw_max_x = arg; - break; - case 4: - raw_max_y = arg; - break; - case 5: - res_x = arg; - break; - case 6: - res_y = arg; - break; - case 10: - raw_min_x = arg; - break; - case 11: - raw_min_y = arg; - break; - case 12: - /* - * New attribute for portrait modes - */ - xyswap = arg; - } - return 0; -} - -static inline int -pen_up(void) -{ - codec_write(CODEC_REG_ADC_CTL, 0); - codec_write(CODEC_REG_TS_CTL, TSPX_POW | TSMX_POW | - TSPY_GND | TSMY_GND); - return codec_read(CODEC_REG_TS_CTL) & TSPX_LOW; -} - -static void -new_data(void) -{ - static TS_EVENT last_data = { 0, 0, 0, 0 }; - int diff0, diff1, diff2, diff3; - - if (cur_data.pressure) { - if (sample < 3) { - samples[sample].x = cur_data.x; - samples[sample++].y = cur_data.y; - return; - } - sample = 0; - - /* - * Check the variance between X samples (discard if not - * similar), then choose the closest pair - */ - diff0 = abs(samples[0].x - samples[1].x); - diff1 = abs(samples[1].x - samples[2].x); - diff2 = abs(samples[2].x - cur_data.x); - diff3 = abs(cur_data.x - samples[1].x); - - if (diff0 > XLIMIT || diff1 > XLIMIT || diff2 > XLIMIT || - diff3 > XLIMIT) - return; - - if (diff1 < diff2) { - if (diff1 < diff3) - cur_data.x = - (samples[1].x + samples[2].x) / 2; - else - cur_data.x = - (cur_data.x + samples[1].x) / 2; - } else { - if (diff2 < diff3) - cur_data.x = - (samples[2].x + cur_data.x) / 2; - else - cur_data.x = - (cur_data.x + samples[1].x) / 2; - } - - /* - * Do the same for Y - */ - diff0 = abs(samples[0].y - samples[1].y); - diff1 = abs(samples[1].y - samples[2].y); - diff2 = abs(samples[2].y - cur_data.y); - diff3 = abs(cur_data.y - samples[1].y); - - if (diff0 > YLIMIT || diff1 > YLIMIT || diff2 > YLIMIT || - diff3 > YLIMIT) - return; - - if (diff1 < diff2) { - if (diff1 < diff3) - cur_data.y = - (samples[1].y + samples[2].y) / 2; - else - cur_data.y = - (cur_data.y + samples[1].y) / 2; - } else { - if (diff2 < diff3) - cur_data.y = - (samples[2].y + cur_data.y) / 2; - else - cur_data.y = - (cur_data.y + samples[1].y) / 2; - } - } else { - /* - * Reset jitter detection on pen release - */ - last_data.x = 0; - last_data.y = 0; - } - - /* - * Jitter elimination - */ - if ((last_data.x || last_data.y) - && abs(last_data.x - cur_data.x) <= 3 - && abs(last_data.y - cur_data.y) <= 3) - return; - cur_data.millisecs = jiffies; - last_data = cur_data; - - if (head != tail) { - int last = head--; - if (last < 0) - last = BUFSIZE - 1; - } - buf[head] = cur_data; - if (++head == BUFSIZE) - head = 0; - if (head == tail && tail++ == BUFSIZE) - tail = 0; - if (fasync) - kill_fasync(&fasync, SIGIO, POLL_IN); - wake_up_interruptible(&queue); -} - -static TS_EVENT -get_data(void) -{ - int last = tail; - - if (++tail == BUFSIZE) - tail = 0; - return buf[last]; -} - -static void -wait_for_action(void) -{ - state = PRESSED; - sample = 0; - codec_write(CODEC_REG_RISE_INT_ENABLE, 0); - codec_write(CODEC_REG_FALL_INT_ENABLE, TSPX_INT); - codec_write(CODEC_REG_ADC_CTL, 0); - codec_write(CODEC_REG_TS_CTL, TSPX_POW | TSMX_POW | - TSPY_GND | TSMY_GND | TSC_MODE_INT); -} - -static void -start_chain(void) -{ - state = P_DONE; - codec_write(CODEC_REG_RISE_INT_ENABLE, ADC_INT); - set_read_pressure(); -} - -static unsigned int -sa1100_ts_poll(struct file *filp, struct poll_table_struct *wait) -{ - poll_wait(filp, &queue, wait); - if (head != tail) - return POLLIN | POLLRDNORM; - return 0; -} - -static ssize_t -sa1100_ts_read(struct file *filp, char *buf, size_t count, loff_t *l) -{ - DECLARE_WAITQUEUE(wait, current); - int i; - TS_EVENT t; - short out_buf[4]; - - if (head == tail) { - if (filp->f_flags & O_NONBLOCK) - return -EAGAIN; - add_wait_queue(&queue, &wait); - current->state = TASK_INTERRUPTIBLE; - while (head == tail && !signal_pending(current)) { - schedule(); - current->state = TASK_INTERRUPTIBLE; - } - current->state = TASK_RUNNING; - remove_wait_queue(&queue, &wait); - } - for (i = count; i >= sizeof out_buf; - i -= sizeof out_buf, buf += sizeof out_buf) { - if (head == tail) - break; - t = get_data(); - out_buf[0] = t.pressure; +static inline void set_read_y_pos(void) +{ + codec_write(CODEC_REG_TS_CTL, TSPY_POW | TSMY_GND | TSC_MODE_PRESSURE | TSC_BIAS_ENA); -#ifdef CONFIG_SA1100_ASSABET - if (xyswap) { - out_buf[1] = - (((raw_max_y - t.y)) * res_y) / - (raw_max_y - raw_min_y); - out_buf[2] = - (((t.x - raw_min_x)) * res_x) / - (raw_max_x - raw_min_x); - } else { - out_buf[1] = - (((raw_max_x - t.x)) * res_x) / - (raw_max_x - raw_min_x); - out_buf[2] = - (((raw_max_y - t.y)) * res_y) / - (raw_max_y - raw_min_y); - } -#elif defined(CONFIG_SA1100_CERF) - if (xyswap) { - out_buf[1] = - (((raw_max_y - t.y)) * res_y) / - (raw_max_y - raw_min_y); - out_buf[2] = - (((t.x - raw_min_x)) * res_x) / - (raw_max_x - raw_min_x); - } else { - out_buf[1] = - (((t.x - raw_min_x)) * res_x) / - (raw_max_x - raw_min_x); - out_buf[2] = - (((raw_max_y - t.y)) * res_y) / - (raw_max_y - raw_min_y); - } -#else - if (xyswap) { - out_buf[1] = - (((t.y - raw_min_y)) * res_y) / - (raw_max_y - raw_min_y); - out_buf[2] = - (((t.x - raw_min_x)) * res_x) / - (raw_max_x - raw_min_x); - } else { - out_buf[1] = - (((t.x - raw_min_x)) * res_x) / - (raw_max_x - raw_min_x); - out_buf[2] = - (((t.y - raw_min_y)) * res_y) / - (raw_max_y - raw_min_y); - } -#endif - out_buf[3] = t.millisecs; - copy_to_user(buf, &out_buf, sizeof out_buf); - } - return count - i; + codec_write(CODEC_REG_ADC_CTL, Reg10 = ADC_INPUT_TSPX | ADC_ENA | ADC_SYNC_ENA); + + codec_write(CODEC_REG_TS_CTL, TSPY_POW | TSMY_GND | TSC_MODE_POSITION | TSC_BIAS_ENA); + + udelay(50); + + codec_write(CODEC_REG_ADC_CTL, Reg10 | ADC_START); + + codec_write(CODEC_REG_IO_DATA, codec_read(CODEC_REG_IO_DATA) | 0x200); + + codec_write(CODEC_REG_ADC_CTL, Reg10); + + codec_write(CODEC_REG_IO_DATA, codec_read(CODEC_REG_IO_DATA) & ~0x200); } -/* - * Forward declaration - */ -static void sa1100_ts_timer(unsigned long); +static inline void set_read_pressure(void) +{ + codec_write(CODEC_REG_TS_CTL, TSPX_POW | TSMX_POW | TSPY_GND | TSMY_GND | TSC_MODE_PRESSURE | TSC_BIAS_ENA); + + codec_write(CODEC_REG_ADC_CTL, Reg10 = ADC_INPUT_TSPX | ADC_ENA | ADC_SYNC_ENA); + + udelay(50); + + codec_write(CODEC_REG_ADC_CTL, Reg10 | ADC_START); + + codec_write(CODEC_REG_IO_DATA, codec_read(CODEC_REG_IO_DATA) | 0x200); -static int -sa1100_ts_starttimer(void) + codec_write(CODEC_REG_ADC_CTL, Reg10); + + codec_write(CODEC_REG_IO_DATA, codec_read(CODEC_REG_IO_DATA) & ~0x200); +} + +static int read_adc(void) { - in_timehandle++; - init_timer(&timer); - timer.function = sa1100_ts_timer; - timer.expires = jiffies + HZ / 100; - add_timer(&timer); - return 0; -} - -static void -sa1100_ts_timer(unsigned long data) -{ - in_timehandle--; - if (pen_up()) { - cur_data.pressure = 0; - new_data(); - wait_for_action(); - } else { - start_chain(); - } -} - -static int -sa1100_ts_fasync(int fd, struct file *filp, int on) -{ - int retval; - - retval = fasync_helper(fd, filp, on, &fasync); - if (retval < 0) - return retval; - else - return 0; -} - -static int -sa1100_ts_open(struct inode *inode, struct file *filp) -{ - MOD_INC_USE_COUNT; - return 0; -} - -static int -sa1100_ts_release(struct inode *inode, struct file *filp) -{ - sa1100_ts_fasync(-1, filp, 0); - MOD_DEC_USE_COUNT; - return 0; -} - -static void -sa1100_ts_interrupt(int irq, void *dev_id, struct pt_regs *regs) -{ - ts_clear_codec_int(); - if (in_timehandle > 0) - return; - switch (state) { - case PRESSED: - start_chain(); - break; - case P_DONE: - cur_data.pressure = read_adc(); - codec_write(CODEC_REG_RISE_INT_ENABLE, ADC_INT); - codec_write(CODEC_REG_FALL_INT_ENABLE, 0); - set_read_x_pos(); - state++; - break; - case X_DONE: - cur_data.x = read_adc(); - codec_write(CODEC_REG_RISE_INT_ENABLE, ADC_INT); - set_read_y_pos(); - state++; - break; - case Y_DONE: - cur_data.y = read_adc(); - codec_write(CODEC_REG_RISE_INT_ENABLE, TSPX_INT); - codec_write(CODEC_REG_ADC_CTL, 0); - codec_write(CODEC_REG_TS_CTL, TSPX_POW | TSMX_POW | - TSPY_GND | TSMY_GND | TSC_MODE_INT); - state++; - new_data(); - sa1100_ts_starttimer(); - break; - case RELEASED: - cur_data.pressure = 0; - new_data(); - wait_for_action(); - } -} - -static struct file_operations sa1100_ts_fops = { - read: sa1100_ts_read, - poll: sa1100_ts_poll, - ioctl: sa1100_ts_ioctl, - fasync: sa1100_ts_fasync, - open: sa1100_ts_open, - release: sa1100_ts_release, -}; + int v; + + while (!((v = codec_read(CODEC_REG_ADC_DATA)) & ADC_DAT_VAL)); + return GET_ADC_DATA(v); +} + +static int sa1100_ts_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) +{ + int ret_data = 0; + +/* Microwindows style (should change to TS_CAL when the specification is ready) */ + switch (cmd) + { + case 3: + raw_max_x = arg; + break; + case 4: + raw_max_y = arg; + break; + case 5: + res_x = arg; + break; + case 6: + res_y = arg; + break; + case 10: + raw_min_x = arg; + break; + case 11: + raw_min_y = arg; + break; + case 12: +/* New attribute for portrait modes */ + xyswap = arg; +/* Allen Add */ + case 13: /* 0 = Enable calibration ; 1 = Calibration OK */ + cal_ok = arg; + case 14: /* Clear all buffer data */ + ts_clear(); + break; + case 15: /* X axis reversed setting */ + x_rev = arg; + break; + case 16: /* X axis reversed setting */ + y_rev = arg; + break; + case 17: /* Clear all buffer data */ + print_par(); + break; +/* Allen */ + } + + return 0; +} + +/* Allen Add */ +static void ts_clear(void); +static void print_par(void); + +static void ts_clear(void) +{ + int i; -int __init -sa1100_ts_init(void) + for (i=0; i < BUFSIZE; i++) + { + buf[i].pressure=(short)NULL; + buf[i].x=(int)NULL; + buf[i].y=(int)NULL; + buf[i].millisecs=(int)NULL; + } + + head = 0; + tail = 0; + + return 0; +} + +static void print_par(void) +{ + printk(" Kernel ==> cal_ok = %d\n",cal_ok); + printk(" Kernel ==> raw_max_x = %d\n",raw_max_x); + printk(" Kernel ==> raw_max_y = %d\n",raw_max_y); + printk(" Kernel ==> res_x = %d\n",res_x); + printk(" Kernel ==> res_y = %d\n",res_y); + printk(" Kernel ==> raw_min_x = %d\n",raw_min_x); + printk(" Kernel ==> raw_min_y = %d\n",raw_min_y); + printk(" Kernel ==> xyswap = %d\n",xyswap); + printk(" Kernel ==> x_rev = %d\n",x_rev); + printk(" Kernel ==> y_rev = %d\n",y_rev); + + return 0; +} + +/* Allen */ + +static inline int pen_up(void) +{ + codec_write(CODEC_REG_ADC_CTL, 0); + codec_write(CODEC_REG_TS_CTL, TSPX_POW | TSMX_POW | TSPY_GND | TSMY_GND); + + return codec_read(CODEC_REG_TS_CTL) & TSPX_LOW; +} + +static void new_data(void) +{ + static TS_EVENT last_data = { 0, 0, 0, 0 }; + int diff0, diff1, diff2, diff3; + + if (cur_data.pressure) + { + if (sample < 3) + { + samples[sample].x = cur_data.x; + samples[sample++].y = cur_data.y; + return; + } + sample = 0; + +/* Check the variance between X samples (discard if not similar), then choose the closest pair */ + diff0 = abs(samples[0].x - samples[1].x); + diff1 = abs(samples[1].x - samples[2].x); + diff2 = abs(samples[2].x - cur_data.x); + diff3 = abs(cur_data.x - samples[1].x); + + if (diff0 > XLIMIT || diff1 > XLIMIT || diff2 > XLIMIT || diff3 > XLIMIT) + return; + + if (diff1 < diff2) + { + if (diff1 < diff3) + cur_data.x = (samples[1].x + samples[2].x) / 2; + else + cur_data.x = (cur_data.x + samples[1].x) / 2; + } + else + { + if (diff2 < diff3) + cur_data.x = (samples[2].x + cur_data.x) / 2; + else + cur_data.x = (cur_data.x + samples[1].x) / 2; + } + +/* Do the same for Y */ + diff0 = abs(samples[0].y - samples[1].y); + diff1 = abs(samples[1].y - samples[2].y); + diff2 = abs(samples[2].y - cur_data.y); + diff3 = abs(cur_data.y - samples[1].y); + + if (diff0 > YLIMIT || diff1 > YLIMIT || diff2 > YLIMIT || diff3 > YLIMIT) + return; + + if (diff1 < diff2) + { + if (diff1 < diff3) + cur_data.y = (samples[1].y + samples[2].y) / 2; + else + cur_data.y = (cur_data.y + samples[1].y) / 2; + } + else + { + if (diff2 < diff3) + cur_data.y = (samples[2].y + cur_data.y) / 2; + else + cur_data.y = (cur_data.y + samples[1].y) / 2; + } + } + else + { +/* Reset jitter detection on pen release */ + last_data.x = 0; + last_data.y = 0; + } + +/* Jitter elimination */ +/* Allen Mask */ +// if ((last_data.x || last_data.y) && abs(last_data.x - cur_data.x) <= 3 && abs(last_data.y - cur_data.y) <= 3) +// return; +/* Allen */ + + cur_data.millisecs = jiffies; + last_data = cur_data; + + if (head != tail) + { + int last = head--; + if (last < 0) + last = BUFSIZE - 1; + } + buf[head] = cur_data; + + if (++head == BUFSIZE) + head = 0; + if (head == tail && tail++ == BUFSIZE) + tail = 0; + + if (fasync) + kill_fasync(&fasync, SIGIO, POLL_IN); + wake_up_interruptible(&queue); +} + +static TS_EVENT get_data(void) { - unsigned int irq; + int last = tail; + + if (++tail == BUFSIZE) + tail = 0; + return buf[last]; +} + +static void wait_for_action(void) +{ + state = PRESSED; + sample = 0; + codec_write(CODEC_REG_RISE_INT_ENABLE, 0); + codec_write(CODEC_REG_FALL_INT_ENABLE, TSPX_INT); + codec_write(CODEC_REG_ADC_CTL, 0); + codec_write(CODEC_REG_TS_CTL, TSPX_POW | TSMX_POW | TSPY_GND | TSMY_GND | TSC_MODE_INT); +} + +static void start_chain(void) +{ + state = P_DONE; + codec_write(CODEC_REG_RISE_INT_ENABLE, ADC_INT); + set_read_pressure(); +} + +static unsigned int sa1100_ts_poll(struct file *filp, struct poll_table_struct *wait) +{ + poll_wait(filp, &queue, wait); + if (head != tail) + return POLLIN | POLLRDNORM; + return 0; +} + +static ssize_t sa1100_ts_read(struct file *filp, char *buf, size_t count, loff_t *l) +{ + DECLARE_WAITQUEUE(wait, current); + int i; + TS_EVENT t; + short out_buf[4]; + + if (head == tail) + { + if (filp->f_flags & O_NONBLOCK) + return -EAGAIN; + add_wait_queue(&queue, &wait); + current->state = TASK_INTERRUPTIBLE; + while ((head == tail) && !signal_pending(current)) + { + schedule(); + current->state = TASK_INTERRUPTIBLE; + } + current->state = TASK_RUNNING; + remove_wait_queue(&queue, &wait); + } + for (i = count; i >= sizeof(out_buf); i -= sizeof(out_buf), buf += sizeof(out_buf)) + { + if (head == tail) + break; + t = get_data(); + + out_buf[0] = t.pressure; + +/* Alen Add */ +#if 0 #ifdef CONFIG_SA1100_ASSABET - raw_max_x = 944; - raw_max_y = 944; - raw_min_x = 70; - raw_min_y = 70; - res_x = 320; - res_y = 240; -#elif defined(CONFIG_SA1100_CERF) - raw_max_x = 944; - raw_max_y = 944; - raw_min_x = 70; - raw_min_y = 70; - res_x = 320; - res_y = 240; + if (xyswap) + { + out_buf[1] = (((raw_max_y - t.y)) * res_y) / (raw_max_y - raw_min_y); + out_buf[2] = (((t.x - raw_min_x)) * res_x) / (raw_max_x - raw_min_x); + } + else + { + out_buf[1] = (((raw_max_x - t.x)) * res_x) / (raw_max_x - raw_min_x); + out_buf[2] = (((raw_max_y - t.y)) * res_y) / (raw_max_y - raw_min_y); + } #else - raw_max_x = 885; - raw_max_y = 885; - raw_min_x = 70; - raw_min_y = 70; - res_x = 640; - res_y = 480; + if (xyswap) + { + out_buf[1] = (((t.y - raw_min_y)) * res_y) / (raw_max_y - raw_min_y); + out_buf[2] = (((t.x - raw_min_x)) * res_x) / (raw_max_x - raw_min_x); + } + else + { + out_buf[1] = (((t.x - raw_min_x)) * res_x) / (raw_max_x - raw_min_x); + out_buf[2] = (((t.y - raw_min_y)) * res_y) / (raw_max_y - raw_min_y); + } #endif - xyswap = 0; - head = 0; - tail = 0; - init_waitqueue_head(&queue); + +#else + if (cal_ok) + { + out_buf[1] = (x_rev) ? ((raw_max_x - t.x) * res_x) / (raw_max_x - raw_min_x) : + ((t.x - raw_min_x) * res_x) / (raw_max_x - raw_min_x); + out_buf[2] = (y_rev) ? ((raw_max_y - t.y) * res_y) / (raw_max_y - raw_min_y) : + ((t.y - raw_min_y) * res_y) / (raw_max_y - raw_min_y); + } + else + { + out_buf[1] = t.x; + out_buf[2] = t.y; + } +#endif +/* Allen */ + + out_buf[3] = t.millisecs; + + copy_to_user(buf, &out_buf, sizeof(out_buf)); + } + + return count - i; +} + +/* Forward declaration */ +static void sa1100_ts_timer(unsigned long); + +static int sa1100_ts_starttimer(void) +{ + in_timehandle++; + init_timer(&timer); + timer.function = sa1100_ts_timer; + timer.expires = jiffies + HZ / 100; + add_timer(&timer); + return 0; +} + +static void sa1100_ts_timer(unsigned long data) +{ + in_timehandle--; + if (pen_up()) + { + cur_data.pressure = 0; + new_data(); + wait_for_action(); + } + else + start_chain(); +} + +static int sa1100_ts_fasync(int fd, struct file *filp, int on) +{ + int retval; + + retval = fasync_helper(fd, filp, on, &fasync); + if (retval < 0) + return retval; + else + return 0; +} + +static int sa1100_ts_open(struct inode *inode, struct file *filp) +{ +/* Allen Add */ + ts_clear(); +/* Allen */ + + MOD_INC_USE_COUNT; + return 0; +} + +static int sa1100_ts_release(struct inode *inode, struct file *filp) +{ +/* Allen Add */ + ts_clear(); +/* Allen */ + + sa1100_ts_fasync(-1, filp, 0); + MOD_DEC_USE_COUNT; + return 0; +} + +static void sa1100_ts_interrupt(int irq, void *dev_id, struct pt_regs *regs) +{ + ts_clear_codec_int(); + if (in_timehandle > 0) + return; + switch (state) + { + case PRESSED: + start_chain(); + break; + case P_DONE: + cur_data.pressure = read_adc(); + codec_write(CODEC_REG_RISE_INT_ENABLE, ADC_INT); + codec_write(CODEC_REG_FALL_INT_ENABLE, 0); + set_read_x_pos(); + state++; + break; + case X_DONE: + cur_data.x = read_adc(); + codec_write(CODEC_REG_RISE_INT_ENABLE, ADC_INT); + set_read_y_pos(); + state++; + break; + case Y_DONE: + cur_data.y = read_adc(); + codec_write(CODEC_REG_RISE_INT_ENABLE, TSPX_INT); + codec_write(CODEC_REG_ADC_CTL, 0); + codec_write(CODEC_REG_TS_CTL, TSPX_POW | TSMX_POW | + TSPY_GND | TSMY_GND | TSC_MODE_INT); + state++; + new_data(); + sa1100_ts_starttimer(); + break; + case RELEASED: + cur_data.pressure = 0; + new_data(); + wait_for_action(); + } +} + +static struct file_operations sa1100_ts_fops = { + read: sa1100_ts_read, + poll: sa1100_ts_poll, + ioctl: sa1100_ts_ioctl, + fasync: sa1100_ts_fasync, + open: sa1100_ts_open, + release: sa1100_ts_release, +}; + +int __init sa1100_ts_init(void) +{ + unsigned int irq; #ifdef CONFIG_SA1100_ASSABET - if (machine_is_assabet()) { - BCR_set(BCR_CODEC_RST); - Ser4MCCR0 = MCCR0_MCE | MCCR0_SmpCnt; - GPDR &= ~GPIO_UCB1300_IRQ; - set_GPIO_IRQ_edge(GPIO_UCB1300_IRQ, GPIO_BOTH_EDGES); - } -#endif -#ifdef CONFIG_SA1100_CERF - if (machine_is_cerf()) { - Ser4MCCR0 = MCCR0_MCE | MCCR0_SmpCnt; - GPDR &= ~GPIO_UCB1200_IRQ; - set_GPIO_IRQ_edge(GPIO_UCB1200_IRQ, GPIO_BOTH_EDGES); - } + raw_max_x = 944; + raw_max_y = 944; + raw_min_x = 70; + raw_min_y = 70; + res_x = 320; + res_y = 240; +#else + raw_max_x = 885; + raw_max_y = 885; + raw_min_x = 70; + raw_min_y = 70; + res_x = 640; + res_y = 480; +#endif + + xyswap = 0; + head = 0; + tail = 0; +/* Allen Add */ + cal_ok = 1; + x_rev = 1; + y_rev = 1; +/* Allen */ + + init_waitqueue_head(&queue); + +#ifdef CONFIG_SA1100_ASSABET + if (machine_is_assabet()) + { + BCR_set(BCR_CODEC_RST); + Ser4MCCR0 = MCCR0_MCE | MCCR0_SmpCnt; + GPDR &= ~GPIO_UCB1300_IRQ; + set_GPIO_IRQ_edge(GPIO_UCB1300_IRQ, GPIO_BOTH_EDGES); + } #endif + #ifdef CONFIG_SA1100_GRAPHICSCLIENT - if (machine_is_graphicsclient()) { - Ser4MCCR0 = MCCR0_MCE; - set_GPIO_IRQ_edge(GPIO_GPIO22, GPIO_BOTH_EDGES); - } + if (machine_is_graphicsclient()) + { + Ser4MCCR0 = MCCR0_MCE; + set_GPIO_IRQ_edge(GPIO_GPIO22, GPIO_BOTH_EDGES); + } #endif - /* - * Initialize the touchscreen controller - */ - codec_write(CODEC_REG_ADC_CTL, 0); - codec_write(CODEC_REG_RISE_INT_ENABLE, 0); - codec_write(CODEC_REG_FALL_INT_ENABLE, 0); - codec_write(CODEC_REG_IO_DIRECTION, 0x200); - ts_clear_codec_int(); - register_chrdev(TS_MAJOR, TS_NAME, &sa1100_ts_fops); +/* Initialize the touchscreen controller */ + codec_write(CODEC_REG_ADC_CTL, 0); + codec_write(CODEC_REG_RISE_INT_ENABLE, 0); + codec_write(CODEC_REG_FALL_INT_ENABLE, 0); + codec_write(CODEC_REG_IO_DIRECTION, 0x200); + ts_clear_codec_int(); + register_chrdev(TS_MAJOR, TS_NAME, &sa1100_ts_fops); #ifdef CONFIG_SA1100_ASSABET - if (machine_is_assabet()) - irq = IRQ_GPIO_UCB1300_IRQ; -#endif - -#ifdef CONFIG_SA1100_CERF - if (machine_is_cerf()) - irq = IRQ_GPIO_UCB1200_IRQ; + if (machine_is_assabet()) + irq = IRQ_GPIO_UCB1300_IRQ; #endif #ifdef CONFIG_SA1100_GRAPHICSCLIENT - if (machine_is_graphicsclient()) - irq = IRQ_GPIO6; + if (machine_is_graphicsclient()) + irq = IRQ_GPIO6; #endif - if (request_irq(irq, sa1100_ts_interrupt, SA_INTERRUPT | - SA_SHIRQ, TS_NAME, dev_id)) - printk("sa1100_ts_init: failed to register IRQ\n"); + if (request_irq(irq, sa1100_ts_interrupt, SA_INTERRUPT | SA_SHIRQ, TS_NAME, dev_id)) + printk("sa1100_ts_init: failed to register IRQ\n"); - wait_for_action(); - printk("sa1100 touch screen driver initialized\n"); - return 0; + wait_for_action(); + printk("sa1100 touch screen driver initialized\n"); + return 0; } -void __exit -sa1100_ts_cleanup(void) +void __exit sa1100_ts_cleanup(void) { - unsigned int irq; + unsigned int irq; #ifdef CONFIG_SA1100_ASSABET - if (machine_is_assabet()) - irq = IRQ_GPIO_UCB1300_IRQ; -#endif - -#ifdef CONFIG_SA1100_CERF - if (machine_is_cerf()) - irq = IRQ_GPIO_UCB1200_IRQ; + if (machine_is_assabet()) + irq = IRQ_GPIO_UCB1300_IRQ; #endif #ifdef CONFIG_SA1100_GRAPHICSCLIENT - if (machine_is_graphicsclient()) - irq = IRQ_GPIO6; + if (machine_is_graphicsclient()) + irq = IRQ_GPIO6; #endif - codec_write(CODEC_REG_ADC_CTL, 0); - codec_write(CODEC_REG_RISE_INT_ENABLE, 0); - codec_write(CODEC_REG_FALL_INT_ENABLE, 0); - free_irq(irq, dev_id); - if (in_timehandle) - del_timer(&timer); - unregister_chrdev(TS_MAJOR, TS_NAME); + codec_write(CODEC_REG_ADC_CTL, 0); + codec_write(CODEC_REG_RISE_INT_ENABLE, 0); + codec_write(CODEC_REG_FALL_INT_ENABLE, 0); + free_irq(irq, dev_id); + if (in_timehandle) + del_timer(&timer); + unregister_chrdev(TS_MAJOR, TS_NAME); - printk("sa1100 touch screen driver removed\n"); + printk("sa1100 touch screen driver removed\n"); } module_init(sa1100_ts_init); diff -urN linux-2.4.0-test8-rmk1-np1/include/asm-arm/arch-sa1100/SA-1111.h linux-2.4.0-test8-rmk1-np1-ck1/include/asm-arm/arch-sa1100/SA-1111.h --- linux-2.4.0-test8-rmk1-np1/include/asm-arm/arch-sa1100/SA-1111.h Thu Aug 17 22:35:15 2000 +++ linux-2.4.0-test8-rmk1-np1-ck1/include/asm-arm/arch-sa1100/SA-1111.h Wed Sep 13 15:30:34 2000 @@ -215,6 +215,154 @@ #endif /* LANGUAGE == C */ /* + * PS/2 Trackpad and Mouse Interfaces + * + * Registers (prefix kbd applies to trackpad interface, mse to mouse) + * KBDCR Control Register + * KBDSTAT Status Register + * KBDDATA Transmit/Receive Data register + * KBDCLKDIV Clock Division Register + * KBDPRECNT Clock Precount Register + * KBDTEST1 Test register 1 + * KBDTEST2 Test register 2 + * KBDTEST3 Test register 3 + * KBDTEST4 Test register 4 + * MSECR + * MSESTAT + * MSEDATA + * MSECLKDIV + * MSEPRECNT + * MSETEST1 + * MSETEST2 + * MSETEST3 + * MSETEST4 + * + */ + +#define _KBD( x ) _SA1111( 0x0A00 ) +#define _MSE( x ) _SA1111( 0x0C00 ) + +#define _KBDCR _SA1111( 0x0A00 ) +#define _KBDSTAT _SA1111( 0x0A04 ) +#define _KBDDATA _SA1111( 0x0A08 ) +#define _KBDCLKDIV _SA1111( 0x0A0C ) +#define _KBDPRECNT _SA1111( 0x0A10 ) +#define _MSECR _SA1111( 0x0C00 ) +#define _MSESTAT _SA1111( 0x0C04 ) +#define _MSEDATA _SA1111( 0x0C08 ) +#define _MSECLKDIV _SA1111( 0x0C10 ) +#define _MSEPRECNT _( 0x0C14 ) + +#if ( LANGUAGE == C ) + +#define KBDCR (*((volatile Word *) SA1111_p2v (_KBDCR))) +#define KBDSTAT (*((volatile Word *) SA1111_p2v (_KBDSTAT))) +#define KBDDATA (*((volatile Word *) SA1111_p2v (_KBDDATA))) +#define KBDCLKDIV (*((volatile Word *) SA1111_p2v (_KBDCLKDIV))) +#define KBDPRECNT (*((volatile Word *) SA1111_p2v (_KBDPRECNT))) +#define KBDTEST1 (*((volatile Word *) SA1111_p2v (_KBDTEST1))) +#define KBDTEST2 (*((volatile Word *) SA1111_p2v (_KBDTEST2))) +#define KBDTEST3 (*((volatile Word *) SA1111_p2v (_KBDTEST3))) +#define KBDTEST4 (*((volatile Word *) SA1111_p2v (_KBDTEST4))) +#define MSECR (*((volatile Word *) SA1111_p2v (_MSECR))) +#define MSESTAT (*((volatile Word *) SA1111_p2v (_MSESTAT))) +#define MSEDATA (*((volatile Word *) SA1111_p2v (_MSEDATA))) +#define MSECLKDIV (*((volatile Word *) SA1111_p2v (_MSECLKDIV))) +#define MSEPRECNT (*((volatile Word *) SA1111_p2v (_MSEPRECNT))) +#define MSETEST1 (*((volatile Word *) SA1111_p2v (_MSETEST1))) +#define MSETEST2 (*((volatile Word *) SA1111_p2v (_MSETEST2))) +#define MSETEST3 (*((volatile Word *) SA1111_p2v (_MSETEST3))) +#define MSETEST4 (*((volatile Word *) SA1111_p2v (_MSETEST4))) + +#define KBDCR_ENA 0x08 +#define KBDCR_FKD 0x02 +#define KBDCR_FKC 0x01 + +#define KBDSTAT_TXE 0x80 +#define KBDSTAT_TXB 0x40 +#define KBDSTAT_RXF 0x20 +#define KBDSTAT_RXB 0x10 +#define KBDSTAT_ENA 0x08 +#define KBDSTAT_RXP 0x04 +#define KBDSTAT_KBD 0x02 +#define KBDSTAT_KBC 0x01 + +#define KBDCLKDIV_DivVal Fld(4,0) + +#define MSECR_ENA 0x08 +#define MSECR_FKD 0x02 +#define MSECR_FKC 0x01 + +#define MSESTAT_TXE 0x80 +#define MSESTAT_TXB 0x40 +#define MSESTAT_RXF 0x20 +#define MSESTAT_RXB 0x10 +#define MSESTAT_ENA 0x08 +#define MSESTAT_RXP 0x04 +#define MSESTAT_MSD 0x02 +#define MSESTAT_MSC 0x01 + +#define MSECLKDIV_DivVal Fld(4,0) + +#define KBDTEST1_CD 0x80 +#define KBDTEST1_RC1 0x40 +#define KBDTEST1_MC 0x20 +#define KBDTEST1_C Fld(2,3) +#define KBDTEST1_T2 0x40 +#define KBDTEST1_T1 0x20 +#define KBDTEST1_T0 0x10 +#define KBDTEST2_TICBnRES 0x08 +#define KBDTEST2_RKC 0x04 +#define KBDTEST2_RKD 0x02 +#define KBDTEST2_SEL 0x01 +#define KBDTEST3_ms_16 0x80 +#define KBDTEST3_us_64 0x40 +#define KBDTEST3_us_16 0x20 +#define KBDTEST3_DIV8 0x10 +#define KBDTEST3_DIn 0x08 +#define KBDTEST3_CIn 0x04 +#define KBDTEST3_KD 0x02 +#define KBDTEST3_KC 0x01 +#define KBDTEST4_BC12 0x80 +#define KBDTEST4_BC11 0x40 +#define KBDTEST4_TRES 0x20 +#define KBDTEST4_CLKOE 0x10 +#define KBDTEST4_CRES 0x08 +#define KBDTEST4_RXB 0x04 +#define KBDTEST4_TXB 0x02 +#define KBDTEST4_SRX 0x01 + +#define MSETEST1_CD 0x80 +#define MSETEST1_RC1 0x40 +#define MSETEST1_MC 0x20 +#define MSETEST1_C Fld(2,3) +#define MSETEST1_T2 0x40 +#define MSETEST1_T1 0x20 +#define MSETEST1_T0 0x10 +#define MSETEST2_TICBnRES 0x08 +#define MSETEST2_RKC 0x04 +#define MSETEST2_RKD 0x02 +#define MSETEST2_SEL 0x01 +#define MSETEST3_ms_16 0x80 +#define MSETEST3_us_64 0x40 +#define MSETEST3_us_16 0x20 +#define MSETEST3_DIV8 0x10 +#define MSETEST3_DIn 0x08 +#define MSETEST3_CIn 0x04 +#define MSETEST3_KD 0x02 +#define MSETEST3_KC 0x01 +#define MSETEST4_BC12 0x80 +#define MSETEST4_BC11 0x40 +#define MSETEST4_TRES 0x20 +#define MSETEST4_CLKOE 0x10 +#define MSETEST4_CRES 0x08 +#define MSETEST4_RXB 0x04 +#define MSETEST4_TXB 0x02 +#define MSETEST4_SRX 0x01 + +#endif /* LANGUAGE == C */ + +/* * PCMCIA Interface * * Registers diff -urN linux-2.4.0-test8-rmk1-np1/include/linux/sa1100_ts.h linux-2.4.0-test8-rmk1-np1-ck1/include/linux/sa1100_ts.h --- linux-2.4.0-test8-rmk1-np1/include/linux/sa1100_ts.h Thu Jan 1 08:00:00 1970 +++ linux-2.4.0-test8-rmk1-np1-ck1/include/linux/sa1100_ts.h Wed Sep 13 16:13:19 2000 @@ -0,0 +1,89 @@ +/* + * Touchscreen Driver (SA1100+UCB1200) Header File + * Copyright (c) Compaq Computer Corporation, 1998, 1999 + * + * Authors: Carl Waldspurger and Larry Brakmo. + * + * Updated to linux-2.4.0-test6-rmk2-np1 by Tak-Shing Chan + */ + +#ifndef _SA1100_TS_H +#define _SA1100_TS_H + +/* + * Codec registers + */ +#define CODEC_REG_IO_DATA (0) +#define CODEC_REG_IO_DIRECTION (1) +#define CODEC_REG_RISE_INT_ENABLE (2) +#define CODEC_REG_FALL_INT_ENABLE (3) +#define CODEC_REG_INT_STATUS (4) +#define CODEC_REG_TELECOM_CTL_A (5) +#define CODEC_REG_TELECOM_CTL_B (6) +#define CODEC_REG_AUDIO_CTL_A (7) +#define CODEC_REG_AUDIO_CTL_B (8) +#define CODEC_REG_TS_CTL (9) +#define CODEC_REG_ADC_CTL (10) +#define CODEC_REG_ADC_DATA (11) +#define CODEC_REG_ID (12) +#define CODEC_REG_MODE (13) + +/* + * Codec registers 2, 3 and 4: interrupt related registers + */ +#define ADC_INT (1 << 11) +#define TSPX_INT (1 << 12) +#define TSMX_INT (1 << 13) + +/* + * Codec register 9: Touchscreen control register + */ +#define TSMX_POW (1 << 0) +#define TSPX_POW (1 << 1) +#define TSMY_POW (1 << 2) +#define TSPY_POW (1 << 3) +#define TSMX_GND (1 << 4) +#define TSPX_GND (1 << 5) +#define TSMY_GND (1 << 6) +#define TSPY_GND (1 << 7) +#define TSC_MODE_MASK (3 << 8) +#define TSC_MODE_INT (0 << 8) +#define TSC_MODE_PRESSURE (1 << 8) +#define TSC_MODE_POSITION (1 << 9) +#define TSC_BIAS_ENA (1 << 11) +#define TSPX_LOW (1 << 12) +#define TSMX_LOW (1 << 13) + +/* + * Codec register 10: ADC control register + */ +#define ADC_SYNC_ENA (1 << 0) +#define ADC_INPUT_MASK (7 << 2) +#define ADC_INPUT_TSPX (0 << 2) +#define ADC_INPUT_TSMX (1 << 2) +#define ADC_INPUT_TSPY (2 << 2) +#define ADC_INPUT_TSMY (3 << 2) +#define ADC_INPUT_AD0 (4 << 2) +#define ADC_INPUT_AD1 (5 << 2) +#define ADC_INPUT_AD2 (6 << 2) +#define ADC_INPUT_AD3 (7 << 2) +#define ADC_START (1 << 7) +#define ADC_ENA (1 << 15) + +/* + * Codec register 11: ADC data register + */ +#define ADC_DATA_SHIFT_VAL (5) +#define GET_ADC_DATA(x) (((x) >> ADC_DATA_SHIFT_VAL) & 0x3ff) +#define ADC_DAT_VAL (1 << 15) +#define ADC_ENA_TYPE (ADC_SYNC_ENA | ADC_ENA) + + +/* Allen Add -- Settings and definitions */ + +#define TS_NAME "ucb1200" +#define TS_MAJOR 11 + +/* Allen */ + +#endif /* _SA1100_TS_H */