RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / drivers / char / au1000_ts.c
bloba6a5b77a516738904a14b7f3c10c1f3b6ccc3161
1 /*
2 * au1000_ts.c -- Touch screen driver for the Alchemy Au1000's
3 * SSI Port 0 talking to the ADS7846 touch screen
4 * controller.
6 * Copyright 2001 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc.
8 * stevel@mvista.com or source@mvista.com
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
18 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
21 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 675 Mass Ave, Cambridge, MA 02139, USA.
30 * Notes:
32 * Revision history
33 * 06.27.2001 Initial version
36 #include <linux/module.h>
37 #include <linux/version.h>
39 #include <linux/init.h>
40 #include <linux/fs.h>
41 #include <linux/delay.h>
42 #include <linux/poll.h>
43 #include <linux/string.h>
44 #include <linux/ioport.h> /* request_region */
45 #include <linux/interrupt.h> /* mark_bh */
46 #include <asm/uaccess.h> /* get_user,copy_to_user */
47 #include <asm/io.h>
48 #include <asm/au1000.h>
50 #define TS_NAME "au1000-ts"
51 #define TS_MAJOR 11
53 #define PFX TS_NAME
54 #define AU1000_TS_DEBUG 1
56 #ifdef AU1000_TS_DEBUG
57 #define dbg(format, arg...) printk(KERN_DEBUG PFX ": " format "\n" , ## arg)
58 #else
59 #define dbg(format, arg...) do {} while (0)
60 #endif
61 #define err(format, arg...) printk(KERN_ERR PFX ": " format "\n" , ## arg)
62 #define info(format, arg...) printk(KERN_INFO PFX ": " format "\n" , ## arg)
63 #define warn(format, arg...) printk(KERN_WARNING PFX ": " format "\n" , ## arg)
66 // SSI Status register bit defines
67 #define SSISTAT_BF (1<<4)
68 #define SSISTAT_OF (1<<3)
69 #define SSISTAT_UF (1<<2)
70 #define SSISTAT_DONE (1<<1)
71 #define SSISTAT_BUSY (1<<0)
73 // SSI Interrupt Pending and Enable register bit defines
74 #define SSIINT_OI (1<<3)
75 #define SSIINT_UI (1<<2)
76 #define SSIINT_DI (1<<1)
78 // SSI Address/Data register bit defines
79 #define SSIADAT_D (1<<24)
80 #define SSIADAT_ADDR_BIT 16
81 #define SSIADAT_ADDR_MASK (0xff<<SSIADAT_ADDR_BIT)
82 #define SSIADAT_DATA_BIT 0
83 #define SSIADAT_DATA_MASK (0xfff<<SSIADAT_DATA_BIT)
85 // SSI Enable register bit defines
86 #define SSIEN_CD (1<<1)
87 #define SSIEN_E (1<<0)
89 // SSI Config register bit defines
90 #define SSICFG_AO (1<<24)
91 #define SSICFG_DO (1<<23)
92 #define SSICFG_ALEN_BIT 20
93 #define SSICFG_ALEN_MASK (0x7<<SSICFG_ALEN_BIT)
94 #define SSICFG_DLEN_BIT 16
95 #define SSICFG_DLEN_MASK (0xf<<SSICFG_DLEN_BIT)
96 #define SSICFG_DD (1<<11)
97 #define SSICFG_AD (1<<10)
98 #define SSICFG_BM_BIT 8
99 #define SSICFG_BM_MASK (0x3<<SSICFG_BM_BIT)
100 #define SSICFG_CE (1<<7)
101 #define SSICFG_DP (1<<6)
102 #define SSICFG_DL (1<<5)
103 #define SSICFG_EP (1<<4)
105 // Bus Turnaround Selection
106 #define SCLK_HOLD_HIGH 0
107 #define SCLK_HOLD_LOW 1
108 #define SCLK_CYCLE 2
111 * Default config for SSI0:
113 * - transmit MSBit first
114 * - expect MSBit first on data receive
115 * - address length 7 bits
116 * - expect data length 12 bits
117 * - do not disable Direction bit
118 * - do not disable Address bits
119 * - SCLK held low during bus turnaround
120 * - Address and Data bits clocked out on falling edge of SCLK
121 * - Direction bit high is a read, low is a write
122 * - Direction bit precedes Address bits
123 * - Active low enable signal
126 #define DEFAULT_SSI_CONFIG \
127 (SSICFG_AO | SSICFG_DO | (6<<SSICFG_ALEN_BIT) | (11<<SSICFG_DLEN_BIT) |\
128 (SCLK_HOLD_LOW<<SSICFG_BM_BIT) | SSICFG_DP | SSICFG_EP)
131 // ADS7846 Control Byte bit defines
132 #define ADS7846_ADDR_BIT 4
133 #define ADS7846_ADDR_MASK (0x7<<ADS7846_ADDR_BIT)
134 #define ADS7846_MEASURE_X (0x5<<ADS7846_ADDR_BIT)
135 #define ADS7846_MEASURE_Y (0x1<<ADS7846_ADDR_BIT)
136 #define ADS7846_MEASURE_Z1 (0x3<<ADS7846_ADDR_BIT)
137 #define ADS7846_MEASURE_Z2 (0x4<<ADS7846_ADDR_BIT)
138 #define ADS7846_8BITS (1<<3)
139 #define ADS7846_12BITS 0
140 #define ADS7846_SER (1<<2)
141 #define ADS7846_DFR 0
142 #define ADS7846_PWR_BIT 0
143 #define ADS7846_PD 0
144 #define ADS7846_ADC_ON (0x1<<ADS7846_PWR_BIT)
145 #define ADS7846_REF_ON (0x2<<ADS7846_PWR_BIT)
146 #define ADS7846_REF_ADC_ON (0x3<<ADS7846_PWR_BIT)
148 #define MEASURE_12BIT_X \
149 (ADS7846_MEASURE_X | ADS7846_12BITS | ADS7846_DFR | ADS7846_PD)
150 #define MEASURE_12BIT_Y \
151 (ADS7846_MEASURE_Y | ADS7846_12BITS | ADS7846_DFR | ADS7846_PD)
152 #define MEASURE_12BIT_Z1 \
153 (ADS7846_MEASURE_Z1 | ADS7846_12BITS | ADS7846_DFR | ADS7846_PD)
154 #define MEASURE_12BIT_Z2 \
155 (ADS7846_MEASURE_Z2 | ADS7846_12BITS | ADS7846_DFR | ADS7846_PD)
157 typedef enum {
158 IDLE = 0,
159 ACQ_X,
160 ACQ_Y,
161 ACQ_Z1,
162 ACQ_Z2
163 } acq_state_t;
165 /* +++++++++++++ Lifted from include/linux/h3600_ts.h ++++++++++++++*/
166 typedef struct {
167 unsigned short pressure; // touch pressure
168 unsigned short x; // calibrated X
169 unsigned short y; // calibrated Y
170 unsigned short millisecs; // timestamp of this event
171 } TS_EVENT;
173 typedef struct {
174 int xscale;
175 int xtrans;
176 int yscale;
177 int ytrans;
178 int xyswap;
179 } TS_CAL;
181 /* Use 'f' as magic number */
182 #define IOC_MAGIC 'f'
184 #define TS_GET_RATE _IO(IOC_MAGIC, 8)
185 #define TS_SET_RATE _IO(IOC_MAGIC, 9)
186 #define TS_GET_CAL _IOR(IOC_MAGIC, 10, TS_CAL)
187 #define TS_SET_CAL _IOW(IOC_MAGIC, 11, TS_CAL)
189 /* +++++++++++++ Done lifted from include/linux/h3600_ts.h +++++++++*/
192 #define EVENT_BUFSIZE 128
195 * Which pressure equation to use from ADS7846 datasheet.
196 * The first equation requires knowing only the X plate
197 * resistance, but needs 4 measurements (X, Y, Z1, Z2).
198 * The second equation requires knowing both X and Y plate
199 * resistance, but only needs 3 measurements (X, Y, Z1).
200 * The second equation is preferred because of the shorter
201 * acquisition time required.
203 enum {
204 PRESSURE_EQN_1 = 0,
205 PRESSURE_EQN_2
210 * The touch screen's X and Y plate resistances, used by
211 * pressure equations.
213 #define DEFAULT_X_PLATE_OHMS 580
214 #define DEFAULT_Y_PLATE_OHMS 580
217 * Pen up/down pressure resistance thresholds.
219 * FIXME: these are bogus and will have to be found empirically.
221 * These are hysteresis points. If pen state is up and pressure
222 * is greater than pen-down threshold, pen transitions to down.
223 * If pen state is down and pressure is less than pen-up threshold,
224 * pen transitions to up. If pressure is in-between, pen status
225 * doesn't change.
227 * This wouldn't be needed if PENIRQ* from the ADS7846 were
228 * routed to an interrupt line on the Au1000. This would issue
229 * an interrupt when the panel is touched.
231 #define DEFAULT_PENDOWN_THRESH_OHMS 100
232 #define DEFAULT_PENUP_THRESH_OHMS 80
234 typedef struct {
235 int baudrate;
236 u32 clkdiv;
237 acq_state_t acq_state; // State of acquisition state machine
238 int x_raw, y_raw, z1_raw, z2_raw; // The current raw acquisition values
239 TS_CAL cal; // Calibration values
240 // The X and Y plate resistance, needed to calculate pressure
241 int x_plate_ohms, y_plate_ohms;
242 // pressure resistance at which pen is considered down/up
243 int pendown_thresh_ohms;
244 int penup_thresh_ohms;
245 int pressure_eqn; // eqn to use for pressure calc
246 int pendown; // 1 = pen is down, 0 = pen is up
247 TS_EVENT event_buf[EVENT_BUFSIZE];// The event queue
248 int nextIn, nextOut;
249 int event_count;
250 struct fasync_struct *fasync; // asynch notification
251 struct timer_list acq_timer; // Timer for triggering acquisitions
252 wait_queue_head_t wait; // read wait queue
253 spinlock_t lock;
254 struct tq_struct chug_tq;
255 } au1000_ts_t;
257 static au1000_ts_t au1000_ts;
260 static inline u32
261 calc_clkdiv(int baud)
263 u32 sys_busclk =
264 (get_au1000_speed() / (int)(inl(PM_POWERUP_CONTROL)&0x03) + 2);
265 return (sys_busclk / (2 * baud)) - 1;
268 static inline int
269 calc_baudrate(u32 clkdiv)
271 u32 sys_busclk =
272 (get_au1000_speed() / (int)(inl(PM_POWERUP_CONTROL)&0x03) + 2);
273 return sys_busclk / (2 * (clkdiv + 1));
278 * This is a bottom-half handler that is scheduled after
279 * raw X,Y,Z1,Z2 coordinates have been acquired, and does
280 * the following:
282 * - computes touch screen pressure resistance
283 * - if pressure is above a threshold considered to be pen-down:
284 * - compute calibrated X and Y coordinates
285 * - queue a new TS_EVENT
286 * - signal asynchronously and wake up any read
288 static void
289 chug_raw_data(void* private)
291 au1000_ts_t* ts = (au1000_ts_t*)private;
292 TS_EVENT event;
293 int Rt, Xcal, Ycal;
294 unsigned long flags;
296 // timestamp this new event.
297 event.millisecs = jiffies;
299 // Calculate touch pressure resistance
300 if (ts->pressure_eqn == PRESSURE_EQN_2) {
301 Rt = (ts->x_plate_ohms * ts->x_raw *
302 (4096 - ts->z1_raw)) / ts->z1_raw;
303 Rt -= (ts->y_plate_ohms * ts->y_raw);
304 Rt = (Rt + 2048) >> 12; // round up to nearest ohm
305 } else {
306 Rt = (ts->x_plate_ohms * ts->x_raw *
307 (ts->z2_raw - ts->z1_raw)) / ts->z1_raw;
308 Rt = (Rt + 2048) >> 12; // round up to nearest ohm
311 // hysteresis
312 if (!ts->pendown && Rt > ts->pendown_thresh_ohms)
313 ts->pendown = 1;
314 else if (ts->pendown && Rt < ts->penup_thresh_ohms)
315 ts->pendown = 0;
317 if (ts->pendown) {
318 // Pen is down
319 // Calculate calibrated X,Y
320 Xcal = ((ts->cal.xscale * ts->x_raw) >> 8) + ts->cal.xtrans;
321 Ycal = ((ts->cal.yscale * ts->y_raw) >> 8) + ts->cal.ytrans;
323 event.x = (unsigned short)Xcal;
324 event.y = (unsigned short)Ycal;
325 event.pressure = (unsigned short)Rt;
327 // add this event to the event queue
328 spin_lock_irqsave(&ts->lock, flags);
329 ts->event_buf[ts->nextIn++] = event;
330 if (ts->nextIn == EVENT_BUFSIZE)
331 ts->nextIn = 0;
332 if (ts->event_count < EVENT_BUFSIZE) {
333 ts->event_count++;
334 } else {
335 // throw out the oldest event
336 if (++ts->nextOut == EVENT_BUFSIZE)
337 ts->nextOut = 0;
339 spin_unlock_irqrestore(&ts->lock, flags);
341 // async notify
342 if (ts->fasync)
343 kill_fasync(&ts->fasync, SIGIO, POLL_IN);
344 // wake up any read call
345 if (waitqueue_active(&ts->wait))
346 wake_up_interruptible(&ts->wait);
352 * Raw X,Y,pressure acquisition timer function. This triggers
353 * the start of a new acquisition. Its duration between calls
354 * is the touch screen polling rate.
356 static void
357 au1000_acq_timer(unsigned long data)
359 au1000_ts_t* ts = (au1000_ts_t*)data;
360 unsigned long flags;
362 spin_lock_irqsave(&ts->lock, flags);
364 // start acquisition with X coordinate
365 ts->acq_state = ACQ_X;
366 // start me up
367 outl(SSIADAT_D | (MEASURE_12BIT_X << SSIADAT_ADDR_BIT), SSI0_ADATA);
369 // schedule next acquire
370 ts->acq_timer.expires = jiffies + HZ / 100;
371 add_timer(&ts->acq_timer);
373 spin_unlock_irqrestore(&ts->lock, flags);
376 static void
377 ssi0_interrupt(int irq, void *dev_id)
379 au1000_ts_t *ts = (au1000_ts_t*)dev_id;
380 u32 stat, int_stat, data;
382 spin_lock(&ts->lock);
384 stat = inl(SSI0_STATUS);
385 // clear sticky status bits
386 outl(stat & (SSISTAT_OF|SSISTAT_UF|SSISTAT_DONE), SSI0_STATUS);
388 int_stat = inl(SSI0_INT);
389 // clear sticky intr status bits
390 outl(int_stat & (SSIINT_OI|SSIINT_UI|SSIINT_DI), SSI0_INT);
392 if ((int_stat & (SSIINT_OI|SSIINT_UI|SSIINT_DI)) != SSIINT_DI) {
393 if (int_stat & SSIINT_OI)
394 err("overflow");
395 if (int_stat & SSIINT_UI)
396 err("underflow");
397 spin_unlock(&ts->lock);
398 return;
401 data = inl(SSI0_ADATA) & SSIADAT_DATA_MASK;
403 switch (ts->acq_state) {
404 case IDLE:
405 break;
406 case ACQ_X:
407 ts->x_raw = data;
408 ts->acq_state = ACQ_Y;
409 // trigger Y acq
410 outl(SSIADAT_D | (MEASURE_12BIT_Y << SSIADAT_ADDR_BIT),
411 SSI0_ADATA);
412 break;
413 case ACQ_Y:
414 ts->y_raw = data;
415 ts->acq_state = ACQ_Z1;
416 // trigger Z1 acq
417 outl(SSIADAT_D | (MEASURE_12BIT_Z1 << SSIADAT_ADDR_BIT),
418 SSI0_ADATA);
419 break;
420 case ACQ_Z1:
421 ts->z1_raw = data;
422 if (ts->pressure_eqn == PRESSURE_EQN_2) {
423 // don't acq Z2, using 2nd eqn for touch pressure
424 ts->acq_state = IDLE;
425 // got the raw stuff, now mark BH
426 queue_task(&ts->chug_tq, &tq_immediate);
427 mark_bh(IMMEDIATE_BH);
428 } else {
429 ts->acq_state = ACQ_Z2;
430 // trigger Z2 acq
431 outl(SSIADAT_D | (MEASURE_12BIT_Z2<<SSIADAT_ADDR_BIT),
432 SSI0_ADATA);
434 break;
435 case ACQ_Z2:
436 ts->z2_raw = data;
437 ts->acq_state = IDLE;
438 // got the raw stuff, now mark BH
439 queue_task(&ts->chug_tq, &tq_immediate);
440 mark_bh(IMMEDIATE_BH);
441 break;
444 spin_unlock(&ts->lock);
448 /* +++++++++++++ File operations ++++++++++++++*/
450 static int
451 au1000_fasync(int fd, struct file *filp, int mode)
453 au1000_ts_t* ts = (au1000_ts_t*)filp->private_data;
454 return fasync_helper(fd, filp, mode, &ts->fasync);
457 static int
458 au1000_ioctl(struct inode * inode, struct file *filp,
459 unsigned int cmd, unsigned long arg)
461 au1000_ts_t* ts = (au1000_ts_t*)filp->private_data;
463 switch(cmd) {
464 case TS_GET_RATE: /* TODO: what is this? */
465 break;
466 case TS_SET_RATE: /* TODO: what is this? */
467 break;
468 case TS_GET_CAL:
469 copy_to_user((char *)arg, (char *)&ts->cal, sizeof(TS_CAL));
470 break;
471 case TS_SET_CAL:
472 copy_from_user((char *)&ts->cal, (char *)arg, sizeof(TS_CAL));
473 break;
474 default:
475 err("unknown cmd %04x", cmd);
476 return -EINVAL;
479 return 0;
482 static unsigned int
483 au1000_poll(struct file * filp, poll_table * wait)
485 au1000_ts_t* ts = (au1000_ts_t*)filp->private_data;
486 poll_wait(filp, &ts->wait, wait);
487 if (ts->event_count)
488 return POLLIN | POLLRDNORM;
489 return 0;
492 static ssize_t
493 au1000_read(struct file * filp, char * buf, size_t count, loff_t * l)
495 au1000_ts_t* ts = (au1000_ts_t*)filp->private_data;
496 unsigned long flags;
497 TS_EVENT event;
498 int i;
500 if (ts->event_count == 0) {
501 if (filp->f_flags & O_NONBLOCK)
502 return -EAGAIN;
503 interruptible_sleep_on(&ts->wait);
504 if (signal_pending(current))
505 return -ERESTARTSYS;
508 for (i = count;
509 i >= sizeof(TS_EVENT);
510 i -= sizeof(TS_EVENT), buf += sizeof(TS_EVENT)) {
511 if (ts->event_count == 0)
512 break;
513 spin_lock_irqsave(&ts->lock, flags);
514 event = ts->event_buf[ts->nextOut++];
515 if (ts->nextOut == EVENT_BUFSIZE)
516 ts->nextOut = 0;
517 if (ts->event_count)
518 ts->event_count--;
519 spin_unlock_irqrestore(&ts->lock, flags);
520 copy_to_user(buf, &event, sizeof(TS_EVENT));
523 return count - i;
527 static int
528 au1000_open(struct inode * inode, struct file * filp)
530 au1000_ts_t* ts;
531 unsigned long flags;
533 filp->private_data = ts = &au1000_ts;
535 spin_lock_irqsave(&ts->lock, flags);
537 // setup SSI0 config
538 outl(DEFAULT_SSI_CONFIG, SSI0_CONFIG);
540 // clear out SSI0 status bits
541 outl(SSISTAT_OF|SSISTAT_UF|SSISTAT_DONE, SSI0_STATUS);
542 // clear out SSI0 interrupt pending bits
543 outl(SSIINT_OI|SSIINT_UI|SSIINT_DI, SSI0_INT);
545 // enable SSI0 interrupts
546 outl(SSIINT_OI|SSIINT_UI|SSIINT_DI, SSI0_INT_ENABLE);
549 * init bh handler that chugs the raw data (calibrates and
550 * calculates touch pressure).
552 ts->chug_tq.routine = chug_raw_data;
553 ts->chug_tq.data = ts;
554 ts->pendown = 0; // pen up
556 // flush event queue
557 ts->nextIn = ts->nextOut = ts->event_count = 0;
559 // Start acquisition timer function
560 init_timer(&ts->acq_timer);
561 ts->acq_timer.function = au1000_acq_timer;
562 ts->acq_timer.data = (unsigned long)ts;
563 ts->acq_timer.expires = jiffies + HZ / 100;
564 add_timer(&ts->acq_timer);
566 spin_unlock_irqrestore(&ts->lock, flags);
568 return 0;
571 static int
572 au1000_release(struct inode * inode, struct file * filp)
574 au1000_ts_t* ts = (au1000_ts_t*)filp->private_data;
575 unsigned long flags;
577 au1000_fasync(-1, filp, 0);
578 del_timer_sync(&ts->acq_timer);
580 spin_lock_irqsave(&ts->lock, flags);
581 // disable SSI0 interrupts
582 outl(0, SSI0_INT_ENABLE);
583 spin_unlock_irqrestore(&ts->lock, flags);
585 return 0;
589 static struct file_operations ts_fops = {
590 .read = au1000_read,
591 .poll = au1000_poll,
592 .ioctl = au1000_ioctl,
593 .fasync = au1000_fasync,
594 .open = au1000_open,
595 .release = au1000_release,
598 /* +++++++++++++ End File operations ++++++++++++++*/
601 int __init
602 au1000ts_init_module(void)
604 au1000_ts_t* ts = &au1000_ts;
605 int ret;
607 /* register our character device */
608 if ((ret = register_chrdev(TS_MAJOR, TS_NAME, &ts_fops)) < 0) {
609 err("can't get major number");
610 return ret;
612 info("registered");
614 memset(ts, 0, sizeof(au1000_ts_t));
615 init_waitqueue_head(&ts->wait);
616 spin_lock_init(&ts->lock);
618 if (!request_region(virt_to_phys((void*)SSI0_STATUS), 0x100, TS_NAME)) {
619 err("SSI0 ports in use");
620 return -ENXIO;
623 if ((ret = request_irq(AU1000_SSI0_INT, ssi0_interrupt,
624 SA_SHIRQ | SA_INTERRUPT, TS_NAME, ts))) {
625 err("could not get IRQ");
626 return ret;
629 // initial calibration values
630 ts->cal.xscale = -93;
631 ts->cal.xtrans = 346;
632 ts->cal.yscale = -64;
633 ts->cal.ytrans = 251;
635 // init pen up/down hysteresis points
636 ts->pendown_thresh_ohms = DEFAULT_PENDOWN_THRESH_OHMS;
637 ts->penup_thresh_ohms = DEFAULT_PENUP_THRESH_OHMS;
638 ts->pressure_eqn = PRESSURE_EQN_2;
639 // init X and Y plate resistances
640 ts->x_plate_ohms = DEFAULT_X_PLATE_OHMS;
641 ts->y_plate_ohms = DEFAULT_Y_PLATE_OHMS;
643 // set GPIO to SSI0 function
644 outl(inl(PIN_FUNCTION) & ~1, PIN_FUNCTION);
646 // enable SSI0 clock and bring SSI0 out of reset
647 outl(0, SSI0_CONTROL);
648 udelay(1000);
649 outl(SSIEN_E, SSI0_CONTROL);
650 udelay(100);
652 // FIXME: is this a working baudrate?
653 ts->clkdiv = 0;
654 ts->baudrate = calc_baudrate(ts->clkdiv);
655 outl(ts->clkdiv, SSI0_CLKDIV);
657 info("baudrate = %d Hz", ts->baudrate);
659 return 0;
662 void
663 au1000ts_cleanup_module(void)
665 // disable clocks and hold in reset
666 outl(SSIEN_CD, SSI0_CONTROL);
667 free_irq(AU1000_SSI0_INT, &au1000_ts);
668 release_region(virt_to_phys((void*)SSI0_STATUS), 0x100);
669 unregister_chrdev(TS_MAJOR, TS_NAME);
672 /* Module information */
673 MODULE_AUTHOR("Steve Longerbeam, stevel@mvista.com, www.mvista.com");
674 MODULE_DESCRIPTION("Au1000/ADS7846 Touch Screen Driver");
676 module_init(au1000ts_init_module);
677 module_exit(au1000ts_cleanup_module);