[PATCH] ppc32: Added support for the Book-E style Watchdog Timer
[linux-2.6/linux-mips.git] / drivers / char / serial167.c
blobc2deac968bdd7c607864a99b72651911d4746e78
1 /*
2 * linux/drivers/char/serial167.c
4 * Driver for MVME166/7 board serial ports, which are via a CD2401.
5 * Based very much on cyclades.c.
7 * MVME166/7 work by Richard Hirst [richard@sleepie.demon.co.uk]
9 * ==============================================================
11 * static char rcsid[] =
12 * "$Revision: 1.36.1.4 $$Date: 1995/03/29 06:14:14 $";
14 * linux/kernel/cyclades.c
16 * Maintained by Marcio Saito (cyclades@netcom.com) and
17 * Randolph Bentson (bentson@grieg.seaslug.org)
19 * Much of the design and some of the code came from serial.c
20 * which was copyright (C) 1991, 1992 Linus Torvalds. It was
21 * extensively rewritten by Theodore Ts'o, 8/16/92 -- 9/14/92,
22 * and then fixed as suggested by Michael K. Johnson 12/12/92.
24 * This version does not support shared irq's.
26 * $Log: cyclades.c,v $
27 * Revision 1.36.1.4 1995/03/29 06:14:14 bentson
28 * disambiguate between Cyclom-16Y and Cyclom-32Ye;
30 * Changes:
32 * 200 lines of changes record removed - RGH 11-10-95, starting work on
33 * converting this to drive serial ports on mvme166 (cd2401).
35 * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 2000/08/25
36 * - get rid of verify_area
37 * - use get_user to access memory from userspace in set_threshold,
38 * set_default_threshold and set_timeout
39 * - don't use the panic function in serial167_init
40 * - do resource release on failure on serial167_init
41 * - include missing restore_flags in mvme167_serial_console_setup
43 * Kars de Jong <jongk@linux-m68k.org> - 2004/09/06
44 * - replace bottom half handler with task queue handler
47 #include <linux/config.h>
48 #include <linux/errno.h>
49 #include <linux/signal.h>
50 #include <linux/sched.h>
51 #include <linux/timer.h>
52 #include <linux/tty.h>
53 #include <linux/interrupt.h>
54 #include <linux/serial.h>
55 #include <linux/serialP.h>
56 #include <linux/string.h>
57 #include <linux/fcntl.h>
58 #include <linux/ptrace.h>
59 #include <linux/serial167.h>
60 #include <linux/delay.h>
61 #include <linux/major.h>
62 #include <linux/mm.h>
63 #include <linux/console.h>
64 #include <linux/module.h>
65 #include <linux/bitops.h>
67 #include <asm/system.h>
68 #include <asm/io.h>
69 #include <asm/mvme16xhw.h>
70 #include <asm/bootinfo.h>
71 #include <asm/setup.h>
73 #include <linux/types.h>
74 #include <linux/kernel.h>
76 #include <asm/uaccess.h>
77 #include <linux/init.h>
79 #define SERIAL_PARANOIA_CHECK
80 #undef SERIAL_DEBUG_OPEN
81 #undef SERIAL_DEBUG_THROTTLE
82 #undef SERIAL_DEBUG_OTHER
83 #undef SERIAL_DEBUG_IO
84 #undef SERIAL_DEBUG_COUNT
85 #undef SERIAL_DEBUG_DTR
86 #undef CYCLOM_16Y_HACK
87 #define CYCLOM_ENABLE_MONITORING
89 #define WAKEUP_CHARS 256
91 #define STD_COM_FLAGS (0)
93 #define SERIAL_TYPE_NORMAL 1
95 static struct tty_driver *cy_serial_driver;
96 extern int serial_console;
97 static struct cyclades_port *serial_console_info = NULL;
98 static unsigned int serial_console_cflag = 0;
99 u_char initial_console_speed;
101 /* Base address of cd2401 chip on mvme166/7 */
103 #define BASE_ADDR (0xfff45000)
104 #define pcc2chip ((volatile u_char *)0xfff42000)
105 #define PccSCCMICR 0x1d
106 #define PccSCCTICR 0x1e
107 #define PccSCCRICR 0x1f
108 #define PccTPIACKR 0x25
109 #define PccRPIACKR 0x27
110 #define PccIMLR 0x3f
112 /* This is the per-port data structure */
113 struct cyclades_port cy_port[] = {
114 /* CARD# */
115 {-1 }, /* ttyS0 */
116 {-1 }, /* ttyS1 */
117 {-1 }, /* ttyS2 */
118 {-1 }, /* ttyS3 */
120 #define NR_PORTS (sizeof(cy_port)/sizeof(struct cyclades_port))
123 * tmp_buf is used as a temporary buffer by serial_write. We need to
124 * lock it in case the copy_from_user blocks while swapping in a page,
125 * and some other program tries to do a serial write at the same time.
126 * Since the lock will only come under contention when the system is
127 * swapping and available memory is low, it makes sense to share one
128 * buffer across all the serial ports, since it significantly saves
129 * memory if large numbers of serial ports are open.
131 static unsigned char *tmp_buf = 0;
132 DECLARE_MUTEX(tmp_buf_sem);
135 * This is used to look up the divisor speeds and the timeouts
136 * We're normally limited to 15 distinct baud rates. The extra
137 * are accessed via settings in info->flags.
138 * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
139 * 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
140 * HI VHI
142 static int baud_table[] = {
143 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
144 1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800,115200,150000,
147 #if 0
148 static char baud_co[] = { /* 25 MHz clock option table */
149 /* value => 00 01 02 03 04 */
150 /* divide by 8 32 128 512 2048 */
151 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02,
152 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
154 static char baud_bpr[] = { /* 25 MHz baud rate period table */
155 0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3,
156 0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15};
157 #endif
159 /* I think 166 brd clocks 2401 at 20MHz.... */
161 /* These values are written directly to tcor, and >> 5 for writing to rcor */
162 static u_char baud_co[] = { /* 20 MHz clock option table */
163 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x60, 0x60, 0x40,
164 0x40, 0x40, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
166 /* These values written directly to tbpr/rbpr */
167 static u_char baud_bpr[] = { /* 20 MHz baud rate period table */
168 0x00, 0xc0, 0x80, 0x58, 0x6c, 0x40, 0xc0, 0x81, 0x40, 0x81,
169 0x57, 0x40, 0x81, 0x40, 0x81, 0x40, 0x2b, 0x20, 0x15, 0x10};
171 static u_char baud_cor4[] = { /* receive threshold */
172 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
173 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07};
177 static void shutdown(struct cyclades_port *);
178 static int startup (struct cyclades_port *);
179 static void cy_throttle(struct tty_struct *);
180 static void cy_unthrottle(struct tty_struct *);
181 static void config_setup(struct cyclades_port *);
182 extern void console_print(const char *);
183 #ifdef CYCLOM_SHOW_STATUS
184 static void show_status(int);
185 #endif
187 #ifdef CONFIG_REMOTE_DEBUG
188 static void debug_setup(void);
189 void queueDebugChar (int c);
190 int getDebugChar(void);
192 #define DEBUG_PORT 1
193 #define DEBUG_LEN 256
195 typedef struct {
196 int in;
197 int out;
198 unsigned char buf[DEBUG_LEN];
199 } debugq;
201 debugq debugiq;
202 #endif
205 * I have my own version of udelay(), as it is needed when initialising
206 * the chip, before the delay loop has been calibrated. Should probably
207 * reference one of the vmechip2 or pccchip2 counter for an accurate
208 * delay, but this wild guess will do for now.
211 void my_udelay (long us)
213 u_char x;
214 volatile u_char *p = &x;
215 int i;
217 while (us--)
218 for (i = 100; i; i--)
219 x |= *p;
222 static inline int
223 serial_paranoia_check(struct cyclades_port *info, char *name,
224 const char *routine)
226 #ifdef SERIAL_PARANOIA_CHECK
227 static const char *badmagic =
228 "Warning: bad magic number for serial struct (%s) in %s\n";
229 static const char *badinfo =
230 "Warning: null cyclades_port for (%s) in %s\n";
231 static const char *badrange =
232 "Warning: cyclades_port out of range for (%s) in %s\n";
234 if (!info) {
235 printk(badinfo, name, routine);
236 return 1;
239 if( (long)info < (long)(&cy_port[0])
240 || (long)(&cy_port[NR_PORTS]) < (long)info ){
241 printk(badrange, name, routine);
242 return 1;
245 if (info->magic != CYCLADES_MAGIC) {
246 printk(badmagic, name, routine);
247 return 1;
249 #endif
250 return 0;
251 } /* serial_paranoia_check */
253 #if 0
254 /* The following diagnostic routines allow the driver to spew
255 information on the screen, even (especially!) during interrupts.
257 void
258 SP(char *data){
259 unsigned long flags;
260 local_irq_save(flags);
261 console_print(data);
262 local_irq_restore(flags);
264 char scrn[2];
265 void
266 CP(char data){
267 unsigned long flags;
268 local_irq_save(flags);
269 scrn[0] = data;
270 console_print(scrn);
271 local_irq_restore(flags);
272 }/* CP */
274 void CP1(int data) { (data<10)? CP(data+'0'): CP(data+'A'-10); }/* CP1 */
275 void CP2(int data) { CP1((data>>4) & 0x0f); CP1( data & 0x0f); }/* CP2 */
276 void CP4(int data) { CP2((data>>8) & 0xff); CP2(data & 0xff); }/* CP4 */
277 void CP8(long data) { CP4((data>>16) & 0xffff); CP4(data & 0xffff); }/* CP8 */
278 #endif
280 /* This routine waits up to 1000 micro-seconds for the previous
281 command to the Cirrus chip to complete and then issues the
282 new command. An error is returned if the previous command
283 didn't finish within the time limit.
285 u_short
286 write_cy_cmd(volatile u_char *base_addr, u_char cmd)
288 unsigned long flags;
289 volatile int i;
291 local_irq_save(flags);
292 /* Check to see that the previous command has completed */
293 for(i = 0 ; i < 100 ; i++){
294 if (base_addr[CyCCR] == 0){
295 break;
297 my_udelay(10L);
299 /* if the CCR never cleared, the previous command
300 didn't finish within the "reasonable time" */
301 if ( i == 10 ) {
302 local_irq_restore(flags);
303 return (-1);
306 /* Issue the new command */
307 base_addr[CyCCR] = cmd;
308 local_irq_restore(flags);
309 return(0);
310 } /* write_cy_cmd */
313 /* cy_start and cy_stop provide software output flow control as a
314 function of XON/XOFF, software CTS, and other such stuff. */
316 static void
317 cy_stop(struct tty_struct *tty)
319 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
320 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
321 int channel;
322 unsigned long flags;
324 #ifdef SERIAL_DEBUG_OTHER
325 printk("cy_stop %s\n", tty->name); /* */
326 #endif
328 if (serial_paranoia_check(info, tty->name, "cy_stop"))
329 return;
331 channel = info->line;
333 local_irq_save(flags);
334 base_addr[CyCAR] = (u_char)(channel); /* index channel */
335 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
336 local_irq_restore(flags);
338 return;
339 } /* cy_stop */
341 static void
342 cy_start(struct tty_struct *tty)
344 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
345 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
346 int channel;
347 unsigned long flags;
349 #ifdef SERIAL_DEBUG_OTHER
350 printk("cy_start %s\n", tty->name); /* */
351 #endif
353 if (serial_paranoia_check(info, tty->name, "cy_start"))
354 return;
356 channel = info->line;
358 local_irq_save(flags);
359 base_addr[CyCAR] = (u_char)(channel);
360 base_addr[CyIER] |= CyTxMpty;
361 local_irq_restore(flags);
363 return;
364 } /* cy_start */
368 * This routine is used by the interrupt handler to schedule
369 * processing in the software interrupt portion of the driver
370 * (also known as the "bottom half"). This can be called any
371 * number of times for any channel without harm.
373 static inline void
374 cy_sched_event(struct cyclades_port *info, int event)
376 info->event |= 1 << event; /* remember what kind of event and who */
377 schedule_work(&info->tqueue);
378 } /* cy_sched_event */
381 /* The real interrupt service routines are called
382 whenever the card wants its hand held--chars
383 received, out buffer empty, modem change, etc.
385 static irqreturn_t
386 cd2401_rxerr_interrupt(int irq, void *dev_id, struct pt_regs *fp)
388 struct tty_struct *tty;
389 struct cyclades_port *info;
390 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
391 unsigned char err, rfoc;
392 int channel;
393 char data;
395 /* determine the channel and change to that context */
396 channel = (u_short ) (base_addr[CyLICR] >> 2);
397 info = &cy_port[channel];
398 info->last_active = jiffies;
400 if ((err = base_addr[CyRISR]) & CyTIMEOUT) {
401 /* This is a receive timeout interrupt, ignore it */
402 base_addr[CyREOIR] = CyNOTRANS;
403 return IRQ_HANDLED;
406 /* Read a byte of data if there is any - assume the error
407 * is associated with this character */
409 if ((rfoc = base_addr[CyRFOC]) != 0)
410 data = base_addr[CyRDR];
411 else
412 data = 0;
414 /* if there is nowhere to put the data, discard it */
415 if(info->tty == 0) {
416 base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
417 return IRQ_HANDLED;
419 else { /* there is an open port for this data */
420 tty = info->tty;
421 if(err & info->ignore_status_mask){
422 base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
423 return IRQ_HANDLED;
425 if (tty->flip.count < TTY_FLIPBUF_SIZE){
426 tty->flip.count++;
427 if (err & info->read_status_mask){
428 if(err & CyBREAK){
429 *tty->flip.flag_buf_ptr++ = TTY_BREAK;
430 *tty->flip.char_buf_ptr++ = data;
431 if (info->flags & ASYNC_SAK){
432 do_SAK(tty);
434 }else if(err & CyFRAME){
435 *tty->flip.flag_buf_ptr++ = TTY_FRAME;
436 *tty->flip.char_buf_ptr++ = data;
437 }else if(err & CyPARITY){
438 *tty->flip.flag_buf_ptr++ = TTY_PARITY;
439 *tty->flip.char_buf_ptr++ = data;
440 }else if(err & CyOVERRUN){
441 *tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
442 *tty->flip.char_buf_ptr++ = 0;
444 If the flip buffer itself is
445 overflowing, we still loose
446 the next incoming character.
448 if(tty->flip.count < TTY_FLIPBUF_SIZE){
449 tty->flip.count++;
450 *tty->flip.flag_buf_ptr++ = TTY_NORMAL;
451 *tty->flip.char_buf_ptr++ = data;
453 /* These two conditions may imply */
454 /* a normal read should be done. */
455 /* else if(data & CyTIMEOUT) */
456 /* else if(data & CySPECHAR) */
457 }else{
458 *tty->flip.flag_buf_ptr++ = 0;
459 *tty->flip.char_buf_ptr++ = 0;
461 }else{
462 *tty->flip.flag_buf_ptr++ = 0;
463 *tty->flip.char_buf_ptr++ = 0;
465 }else{
466 /* there was a software buffer overrun
467 and nothing could be done about it!!! */
470 schedule_delayed_work(&tty->flip.work, 1);
471 /* end of service */
472 base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
473 return IRQ_HANDLED;
474 } /* cy_rxerr_interrupt */
476 static irqreturn_t
477 cd2401_modem_interrupt(int irq, void *dev_id, struct pt_regs *fp)
479 struct cyclades_port *info;
480 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
481 int channel;
482 int mdm_change;
483 int mdm_status;
486 /* determine the channel and change to that context */
487 channel = (u_short ) (base_addr[CyLICR] >> 2);
488 info = &cy_port[channel];
489 info->last_active = jiffies;
491 mdm_change = base_addr[CyMISR];
492 mdm_status = base_addr[CyMSVR1];
494 if(info->tty == 0){ /* nowhere to put the data, ignore it */
496 }else{
497 if((mdm_change & CyDCD)
498 && (info->flags & ASYNC_CHECK_CD)){
499 if(mdm_status & CyDCD){
500 /* CP('!'); */
501 cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP);
502 } else {
503 /* CP('@'); */
504 cy_sched_event(info, Cy_EVENT_HANGUP);
507 if((mdm_change & CyCTS)
508 && (info->flags & ASYNC_CTS_FLOW)){
509 if(info->tty->stopped){
510 if(mdm_status & CyCTS){
511 /* !!! cy_start isn't used because... */
512 info->tty->stopped = 0;
513 base_addr[CyIER] |= CyTxMpty;
514 cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
516 }else{
517 if(!(mdm_status & CyCTS)){
518 /* !!! cy_stop isn't used because... */
519 info->tty->stopped = 1;
520 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
524 if(mdm_status & CyDSR){
527 base_addr[CyMEOIR] = 0;
528 return IRQ_HANDLED;
529 } /* cy_modem_interrupt */
531 static irqreturn_t
532 cd2401_tx_interrupt(int irq, void *dev_id, struct pt_regs *fp)
534 struct cyclades_port *info;
535 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
536 int channel;
537 int char_count, saved_cnt;
538 int outch;
540 /* determine the channel and change to that context */
541 channel = (u_short ) (base_addr[CyLICR] >> 2);
543 #ifdef CONFIG_REMOTE_DEBUG
544 if (channel == DEBUG_PORT) {
545 panic ("TxInt on debug port!!!");
547 #endif
549 info = &cy_port[channel];
551 /* validate the port number (as configured and open) */
552 if( (channel < 0) || (NR_PORTS <= channel) ){
553 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
554 base_addr[CyTEOIR] = CyNOTRANS;
555 return IRQ_HANDLED;
557 info->last_active = jiffies;
558 if(info->tty == 0){
559 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
560 if (info->xmit_cnt < WAKEUP_CHARS) {
561 cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
563 base_addr[CyTEOIR] = CyNOTRANS;
564 return IRQ_HANDLED;
567 /* load the on-chip space available for outbound data */
568 saved_cnt = char_count = base_addr[CyTFTC];
570 if(info->x_char) { /* send special char */
571 outch = info->x_char;
572 base_addr[CyTDR] = outch;
573 char_count--;
574 info->x_char = 0;
577 if (info->x_break){
578 /* The Cirrus chip requires the "Embedded Transmit
579 Commands" of start break, delay, and end break
580 sequences to be sent. The duration of the
581 break is given in TICs, which runs at HZ
582 (typically 100) and the PPR runs at 200 Hz,
583 so the delay is duration * 200/HZ, and thus a
584 break can run from 1/100 sec to about 5/4 sec.
585 Need to check these values - RGH 141095.
587 base_addr[CyTDR] = 0; /* start break */
588 base_addr[CyTDR] = 0x81;
589 base_addr[CyTDR] = 0; /* delay a bit */
590 base_addr[CyTDR] = 0x82;
591 base_addr[CyTDR] = info->x_break*200/HZ;
592 base_addr[CyTDR] = 0; /* terminate break */
593 base_addr[CyTDR] = 0x83;
594 char_count -= 7;
595 info->x_break = 0;
598 while (char_count > 0){
599 if (!info->xmit_cnt){
600 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
601 break;
603 if (info->xmit_buf == 0){
604 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
605 break;
607 if (info->tty->stopped || info->tty->hw_stopped){
608 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
609 break;
611 /* Because the Embedded Transmit Commands have been
612 enabled, we must check to see if the escape
613 character, NULL, is being sent. If it is, we
614 must ensure that there is room for it to be
615 doubled in the output stream. Therefore we
616 no longer advance the pointer when the character
617 is fetched, but rather wait until after the check
618 for a NULL output character. (This is necessary
619 because there may not be room for the two chars
620 needed to send a NULL.
622 outch = info->xmit_buf[info->xmit_tail];
623 if( outch ){
624 info->xmit_cnt--;
625 info->xmit_tail = (info->xmit_tail + 1)
626 & (PAGE_SIZE - 1);
627 base_addr[CyTDR] = outch;
628 char_count--;
629 }else{
630 if(char_count > 1){
631 info->xmit_cnt--;
632 info->xmit_tail = (info->xmit_tail + 1)
633 & (PAGE_SIZE - 1);
634 base_addr[CyTDR] = outch;
635 base_addr[CyTDR] = 0;
636 char_count--;
637 char_count--;
638 }else{
639 break;
644 if (info->xmit_cnt < WAKEUP_CHARS) {
645 cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
647 base_addr[CyTEOIR] = (char_count != saved_cnt) ? 0 : CyNOTRANS;
648 return IRQ_HANDLED;
649 } /* cy_tx_interrupt */
651 static irqreturn_t
652 cd2401_rx_interrupt(int irq, void *dev_id, struct pt_regs *fp)
654 struct tty_struct *tty;
655 struct cyclades_port *info;
656 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
657 int channel;
658 char data;
659 int char_count;
660 int save_cnt;
662 /* determine the channel and change to that context */
663 channel = (u_short ) (base_addr[CyLICR] >> 2);
664 info = &cy_port[channel];
665 info->last_active = jiffies;
666 save_cnt = char_count = base_addr[CyRFOC];
668 #ifdef CONFIG_REMOTE_DEBUG
669 if (channel == DEBUG_PORT) {
670 while (char_count--) {
671 data = base_addr[CyRDR];
672 queueDebugChar(data);
675 else
676 #endif
677 /* if there is nowhere to put the data, discard it */
678 if(info->tty == 0){
679 while(char_count--){
680 data = base_addr[CyRDR];
682 }else{ /* there is an open port for this data */
683 tty = info->tty;
684 /* load # characters available from the chip */
686 #ifdef CYCLOM_ENABLE_MONITORING
687 ++info->mon.int_count;
688 info->mon.char_count += char_count;
689 if (char_count > info->mon.char_max)
690 info->mon.char_max = char_count;
691 info->mon.char_last = char_count;
692 #endif
693 while(char_count--){
694 data = base_addr[CyRDR];
695 if (tty->flip.count >= TTY_FLIPBUF_SIZE){
696 continue;
698 tty->flip.count++;
699 *tty->flip.flag_buf_ptr++ = TTY_NORMAL;
700 *tty->flip.char_buf_ptr++ = data;
701 #ifdef CYCLOM_16Y_HACK
702 udelay(10L);
703 #endif
705 schedule_delayed_work(&tty->flip.work, 1);
707 /* end of service */
708 base_addr[CyREOIR] = save_cnt ? 0 : CyNOTRANS;
709 return IRQ_HANDLED;
710 } /* cy_rx_interrupt */
713 * This routine is used to handle the "bottom half" processing for the
714 * serial driver, known also the "software interrupt" processing.
715 * This processing is done at the kernel interrupt level, after the
716 * cy#/_interrupt() has returned, BUT WITH INTERRUPTS TURNED ON. This
717 * is where time-consuming activities which can not be done in the
718 * interrupt driver proper are done; the interrupt driver schedules
719 * them using cy_sched_event(), and they get done here.
721 * This is done through one level of indirection--the task queue.
722 * When a hardware interrupt service routine wants service by the
723 * driver's bottom half, it enqueues the appropriate tq_struct (one
724 * per port) to the keventd work queue and sets a request flag
725 * that the work queue be processed.
727 * Although this may seem unwieldy, it gives the system a way to
728 * pass an argument (in this case the pointer to the cyclades_port
729 * structure) to the bottom half of the driver. Previous kernels
730 * had to poll every port to see if that port needed servicing.
732 static void
733 do_softint(void *private_)
735 struct cyclades_port *info = (struct cyclades_port *) private_;
736 struct tty_struct *tty;
738 tty = info->tty;
739 if (!tty)
740 return;
742 if (test_and_clear_bit(Cy_EVENT_HANGUP, &info->event)) {
743 tty_hangup(info->tty);
744 wake_up_interruptible(&info->open_wait);
745 info->flags &= ~ASYNC_NORMAL_ACTIVE;
747 if (test_and_clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event)) {
748 wake_up_interruptible(&info->open_wait);
750 if (test_and_clear_bit(Cy_EVENT_WRITE_WAKEUP, &info->event)) {
751 tty_wakeup(tty);
753 } /* do_softint */
756 /* This is called whenever a port becomes active;
757 interrupts are enabled and DTR & RTS are turned on.
759 static int
760 startup(struct cyclades_port * info)
762 unsigned long flags;
763 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
764 int channel;
766 if (info->flags & ASYNC_INITIALIZED){
767 return 0;
770 if (!info->type){
771 if (info->tty){
772 set_bit(TTY_IO_ERROR, &info->tty->flags);
774 return 0;
776 if (!info->xmit_buf){
777 info->xmit_buf = (unsigned char *) get_zeroed_page (GFP_KERNEL);
778 if (!info->xmit_buf){
779 return -ENOMEM;
783 config_setup(info);
785 channel = info->line;
787 #ifdef SERIAL_DEBUG_OPEN
788 printk("startup channel %d\n", channel);
789 #endif
791 local_irq_save(flags);
792 base_addr[CyCAR] = (u_char)channel;
793 write_cy_cmd(base_addr,CyENB_RCVR|CyENB_XMTR);
795 base_addr[CyCAR] = (u_char)channel; /* !!! Is this needed? */
796 base_addr[CyMSVR1] = CyRTS;
797 /* CP('S');CP('1'); */
798 base_addr[CyMSVR2] = CyDTR;
800 #ifdef SERIAL_DEBUG_DTR
801 printk("cyc: %d: raising DTR\n", __LINE__);
802 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
803 #endif
805 base_addr[CyIER] |= CyRxData;
806 info->flags |= ASYNC_INITIALIZED;
808 if (info->tty){
809 clear_bit(TTY_IO_ERROR, &info->tty->flags);
811 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
813 local_irq_restore(flags);
815 #ifdef SERIAL_DEBUG_OPEN
816 printk(" done\n");
817 #endif
818 return 0;
819 } /* startup */
821 void
822 start_xmit( struct cyclades_port *info )
824 unsigned long flags;
825 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
826 int channel;
828 channel = info->line;
829 local_irq_save(flags);
830 base_addr[CyCAR] = channel;
831 base_addr[CyIER] |= CyTxMpty;
832 local_irq_restore(flags);
833 } /* start_xmit */
836 * This routine shuts down a serial port; interrupts are disabled,
837 * and DTR is dropped if the hangup on close termio flag is on.
839 static void
840 shutdown(struct cyclades_port * info)
842 unsigned long flags;
843 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
844 int channel;
846 if (!(info->flags & ASYNC_INITIALIZED)){
847 /* CP('$'); */
848 return;
851 channel = info->line;
853 #ifdef SERIAL_DEBUG_OPEN
854 printk("shutdown channel %d\n", channel);
855 #endif
857 /* !!! REALLY MUST WAIT FOR LAST CHARACTER TO BE
858 SENT BEFORE DROPPING THE LINE !!! (Perhaps
859 set some flag that is read when XMTY happens.)
860 Other choices are to delay some fixed interval
861 or schedule some later processing.
863 local_irq_save(flags);
864 if (info->xmit_buf){
865 free_page((unsigned long) info->xmit_buf);
866 info->xmit_buf = 0;
869 base_addr[CyCAR] = (u_char)channel;
870 if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
871 base_addr[CyMSVR1] = 0;
872 /* CP('C');CP('1'); */
873 base_addr[CyMSVR2] = 0;
874 #ifdef SERIAL_DEBUG_DTR
875 printk("cyc: %d: dropping DTR\n", __LINE__);
876 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
877 #endif
879 write_cy_cmd(base_addr,CyDIS_RCVR);
880 /* it may be appropriate to clear _XMIT at
881 some later date (after testing)!!! */
883 if (info->tty){
884 set_bit(TTY_IO_ERROR, &info->tty->flags);
886 info->flags &= ~ASYNC_INITIALIZED;
887 local_irq_restore(flags);
889 #ifdef SERIAL_DEBUG_OPEN
890 printk(" done\n");
891 #endif
892 return;
893 } /* shutdown */
896 * This routine finds or computes the various line characteristics.
898 static void
899 config_setup(struct cyclades_port * info)
901 unsigned long flags;
902 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
903 int channel;
904 unsigned cflag;
905 int i;
906 unsigned char ti, need_init_chan = 0;
908 if (!info->tty || !info->tty->termios){
909 return;
911 if (info->line == -1){
912 return;
914 cflag = info->tty->termios->c_cflag;
916 /* baud rate */
917 i = cflag & CBAUD;
918 #ifdef CBAUDEX
919 /* Starting with kernel 1.1.65, there is direct support for
920 higher baud rates. The following code supports those
921 changes. The conditional aspect allows this driver to be
922 used for earlier as well as later kernel versions. (The
923 mapping is slightly different from serial.c because there
924 is still the possibility of supporting 75 kbit/sec with
925 the Cyclades board.)
927 if (i & CBAUDEX) {
928 if (i == B57600)
929 i = 16;
930 else if(i == B115200)
931 i = 18;
932 #ifdef B78600
933 else if(i == B78600)
934 i = 17;
935 #endif
936 else
937 info->tty->termios->c_cflag &= ~CBAUDEX;
939 #endif
940 if (i == 15) {
941 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
942 i += 1;
943 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
944 i += 3;
946 /* Don't ever change the speed of the console port. It will
947 * run at the speed specified in bootinfo, or at 19.2K */
948 /* Actually, it should run at whatever speed 166Bug was using */
949 /* Note info->timeout isn't used at present */
950 if (info != serial_console_info) {
951 info->tbpr = baud_bpr[i]; /* Tx BPR */
952 info->tco = baud_co[i]; /* Tx CO */
953 info->rbpr = baud_bpr[i]; /* Rx BPR */
954 info->rco = baud_co[i] >> 5; /* Rx CO */
955 if (baud_table[i] == 134) {
956 info->timeout = (info->xmit_fifo_size*HZ*30/269) + 2;
957 /* get it right for 134.5 baud */
958 } else if (baud_table[i]) {
959 info->timeout = (info->xmit_fifo_size*HZ*15/baud_table[i]) + 2;
960 /* this needs to be propagated into the card info */
961 } else {
962 info->timeout = 0;
965 /* By tradition (is it a standard?) a baud rate of zero
966 implies the line should be/has been closed. A bit
967 later in this routine such a test is performed. */
969 /* byte size and parity */
970 info->cor7 = 0;
971 info->cor6 = 0;
972 info->cor5 = 0;
973 info->cor4 = (info->default_threshold
974 ? info->default_threshold
975 : baud_cor4[i]); /* receive threshold */
976 /* Following two lines added 101295, RGH. */
977 /* It is obviously wrong to access CyCORx, and not info->corx here,
978 * try and remember to fix it later! */
979 channel = info->line;
980 base_addr[CyCAR] = (u_char)channel;
981 if (C_CLOCAL(info->tty)) {
982 if (base_addr[CyIER] & CyMdmCh)
983 base_addr[CyIER] &= ~CyMdmCh; /* without modem intr */
984 /* ignore 1->0 modem transitions */
985 if (base_addr[CyCOR4] & (CyDSR|CyCTS|CyDCD))
986 base_addr[CyCOR4] &= ~(CyDSR|CyCTS|CyDCD);
987 /* ignore 0->1 modem transitions */
988 if (base_addr[CyCOR5] & (CyDSR|CyCTS|CyDCD))
989 base_addr[CyCOR5] &= ~(CyDSR|CyCTS|CyDCD);
990 } else {
991 if ((base_addr[CyIER] & CyMdmCh) != CyMdmCh)
992 base_addr[CyIER] |= CyMdmCh; /* with modem intr */
993 /* act on 1->0 modem transitions */
994 if ((base_addr[CyCOR4] & (CyDSR|CyCTS|CyDCD)) != (CyDSR|CyCTS|CyDCD))
995 base_addr[CyCOR4] |= CyDSR|CyCTS|CyDCD;
996 /* act on 0->1 modem transitions */
997 if ((base_addr[CyCOR5] & (CyDSR|CyCTS|CyDCD)) != (CyDSR|CyCTS|CyDCD))
998 base_addr[CyCOR5] |= CyDSR|CyCTS|CyDCD;
1000 info->cor3 = (cflag & CSTOPB) ? Cy_2_STOP : Cy_1_STOP;
1001 info->cor2 = CyETC;
1002 switch(cflag & CSIZE){
1003 case CS5:
1004 info->cor1 = Cy_5_BITS;
1005 break;
1006 case CS6:
1007 info->cor1 = Cy_6_BITS;
1008 break;
1009 case CS7:
1010 info->cor1 = Cy_7_BITS;
1011 break;
1012 case CS8:
1013 info->cor1 = Cy_8_BITS;
1014 break;
1016 if (cflag & PARENB){
1017 if (cflag & PARODD){
1018 info->cor1 |= CyPARITY_O;
1019 }else{
1020 info->cor1 |= CyPARITY_E;
1022 }else{
1023 info->cor1 |= CyPARITY_NONE;
1026 /* CTS flow control flag */
1027 #if 0
1028 /* Don't complcate matters for now! RGH 141095 */
1029 if (cflag & CRTSCTS){
1030 info->flags |= ASYNC_CTS_FLOW;
1031 info->cor2 |= CyCtsAE;
1032 }else{
1033 info->flags &= ~ASYNC_CTS_FLOW;
1034 info->cor2 &= ~CyCtsAE;
1036 #endif
1037 if (cflag & CLOCAL)
1038 info->flags &= ~ASYNC_CHECK_CD;
1039 else
1040 info->flags |= ASYNC_CHECK_CD;
1042 /***********************************************
1043 The hardware option, CyRtsAO, presents RTS when
1044 the chip has characters to send. Since most modems
1045 use RTS as reverse (inbound) flow control, this
1046 option is not used. If inbound flow control is
1047 necessary, DTR can be programmed to provide the
1048 appropriate signals for use with a non-standard
1049 cable. Contact Marcio Saito for details.
1050 ***********************************************/
1052 channel = info->line;
1054 local_irq_save(flags);
1055 base_addr[CyCAR] = (u_char)channel;
1057 /* CyCMR set once only in mvme167_init_serial() */
1058 if (base_addr[CyLICR] != channel << 2)
1059 base_addr[CyLICR] = channel << 2;
1060 if (base_addr[CyLIVR] != 0x5c)
1061 base_addr[CyLIVR] = 0x5c;
1063 /* tx and rx baud rate */
1065 if (base_addr[CyCOR1] != info->cor1)
1066 need_init_chan = 1;
1067 if (base_addr[CyTCOR] != info->tco)
1068 base_addr[CyTCOR] = info->tco;
1069 if (base_addr[CyTBPR] != info->tbpr)
1070 base_addr[CyTBPR] = info->tbpr;
1071 if (base_addr[CyRCOR] != info->rco)
1072 base_addr[CyRCOR] = info->rco;
1073 if (base_addr[CyRBPR] != info->rbpr)
1074 base_addr[CyRBPR] = info->rbpr;
1076 /* set line characteristics according configuration */
1078 if (base_addr[CySCHR1] != START_CHAR(info->tty))
1079 base_addr[CySCHR1] = START_CHAR(info->tty);
1080 if (base_addr[CySCHR2] != STOP_CHAR(info->tty))
1081 base_addr[CySCHR2] = STOP_CHAR(info->tty);
1082 if (base_addr[CySCRL] != START_CHAR(info->tty))
1083 base_addr[CySCRL] = START_CHAR(info->tty);
1084 if (base_addr[CySCRH] != START_CHAR(info->tty))
1085 base_addr[CySCRH] = START_CHAR(info->tty);
1086 if (base_addr[CyCOR1] != info->cor1)
1087 base_addr[CyCOR1] = info->cor1;
1088 if (base_addr[CyCOR2] != info->cor2)
1089 base_addr[CyCOR2] = info->cor2;
1090 if (base_addr[CyCOR3] != info->cor3)
1091 base_addr[CyCOR3] = info->cor3;
1092 if (base_addr[CyCOR4] != info->cor4)
1093 base_addr[CyCOR4] = info->cor4;
1094 if (base_addr[CyCOR5] != info->cor5)
1095 base_addr[CyCOR5] = info->cor5;
1096 if (base_addr[CyCOR6] != info->cor6)
1097 base_addr[CyCOR6] = info->cor6;
1098 if (base_addr[CyCOR7] != info->cor7)
1099 base_addr[CyCOR7] = info->cor7;
1101 if (need_init_chan)
1102 write_cy_cmd(base_addr,CyINIT_CHAN);
1104 base_addr[CyCAR] = (u_char)channel; /* !!! Is this needed? */
1106 /* 2ms default rx timeout */
1107 ti = info->default_timeout ? info->default_timeout : 0x02;
1108 if (base_addr[CyRTPRL] != ti)
1109 base_addr[CyRTPRL] = ti;
1110 if (base_addr[CyRTPRH] != 0)
1111 base_addr[CyRTPRH] = 0;
1113 /* Set up RTS here also ????? RGH 141095 */
1114 if(i == 0){ /* baud rate is zero, turn off line */
1115 if ((base_addr[CyMSVR2] & CyDTR) == CyDTR)
1116 base_addr[CyMSVR2] = 0;
1117 #ifdef SERIAL_DEBUG_DTR
1118 printk("cyc: %d: dropping DTR\n", __LINE__);
1119 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
1120 #endif
1121 }else{
1122 if ((base_addr[CyMSVR2] & CyDTR) != CyDTR)
1123 base_addr[CyMSVR2] = CyDTR;
1124 #ifdef SERIAL_DEBUG_DTR
1125 printk("cyc: %d: raising DTR\n", __LINE__);
1126 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
1127 #endif
1130 if (info->tty){
1131 clear_bit(TTY_IO_ERROR, &info->tty->flags);
1134 local_irq_restore(flags);
1136 } /* config_setup */
1139 static void
1140 cy_put_char(struct tty_struct *tty, unsigned char ch)
1142 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1143 unsigned long flags;
1145 #ifdef SERIAL_DEBUG_IO
1146 printk("cy_put_char %s(0x%02x)\n", tty->name, ch);
1147 #endif
1149 if (serial_paranoia_check(info, tty->name, "cy_put_char"))
1150 return;
1152 if (!tty || !info->xmit_buf)
1153 return;
1155 local_irq_save(flags);
1156 if (info->xmit_cnt >= PAGE_SIZE - 1) {
1157 local_irq_restore(flags);
1158 return;
1161 info->xmit_buf[info->xmit_head++] = ch;
1162 info->xmit_head &= PAGE_SIZE - 1;
1163 info->xmit_cnt++;
1164 local_irq_restore(flags);
1165 } /* cy_put_char */
1168 static void
1169 cy_flush_chars(struct tty_struct *tty)
1171 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1172 unsigned long flags;
1173 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1174 int channel;
1176 #ifdef SERIAL_DEBUG_IO
1177 printk("cy_flush_chars %s\n", tty->name); /* */
1178 #endif
1180 if (serial_paranoia_check(info, tty->name, "cy_flush_chars"))
1181 return;
1183 if (info->xmit_cnt <= 0 || tty->stopped
1184 || tty->hw_stopped || !info->xmit_buf)
1185 return;
1187 channel = info->line;
1189 local_irq_save(flags);
1190 base_addr[CyCAR] = channel;
1191 base_addr[CyIER] |= CyTxMpty;
1192 local_irq_restore(flags);
1193 } /* cy_flush_chars */
1196 /* This routine gets called when tty_write has put something into
1197 the write_queue. If the port is not already transmitting stuff,
1198 start it off by enabling interrupts. The interrupt service
1199 routine will then ensure that the characters are sent. If the
1200 port is already active, there is no need to kick it.
1202 static int
1203 cy_write(struct tty_struct * tty,
1204 const unsigned char *buf, int count)
1206 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1207 unsigned long flags;
1208 int c, total = 0;
1210 #ifdef SERIAL_DEBUG_IO
1211 printk("cy_write %s\n", tty->name); /* */
1212 #endif
1214 if (serial_paranoia_check(info, tty->name, "cy_write")){
1215 return 0;
1218 if (!tty || !info->xmit_buf || !tmp_buf){
1219 return 0;
1222 while (1) {
1223 local_irq_save(flags);
1224 c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
1225 SERIAL_XMIT_SIZE - info->xmit_head));
1226 if (c <= 0) {
1227 local_irq_restore(flags);
1228 break;
1231 memcpy(info->xmit_buf + info->xmit_head, buf, c);
1232 info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
1233 info->xmit_cnt += c;
1234 local_irq_restore(flags);
1236 buf += c;
1237 count -= c;
1238 total += c;
1241 if (info->xmit_cnt
1242 && !tty->stopped
1243 && !tty->hw_stopped ) {
1244 start_xmit(info);
1246 return total;
1247 } /* cy_write */
1250 static int
1251 cy_write_room(struct tty_struct *tty)
1253 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1254 int ret;
1256 #ifdef SERIAL_DEBUG_IO
1257 printk("cy_write_room %s\n", tty->name); /* */
1258 #endif
1260 if (serial_paranoia_check(info, tty->name, "cy_write_room"))
1261 return 0;
1262 ret = PAGE_SIZE - info->xmit_cnt - 1;
1263 if (ret < 0)
1264 ret = 0;
1265 return ret;
1266 } /* cy_write_room */
1269 static int
1270 cy_chars_in_buffer(struct tty_struct *tty)
1272 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1274 #ifdef SERIAL_DEBUG_IO
1275 printk("cy_chars_in_buffer %s %d\n", tty->name, info->xmit_cnt); /* */
1276 #endif
1278 if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer"))
1279 return 0;
1281 return info->xmit_cnt;
1282 } /* cy_chars_in_buffer */
1285 static void
1286 cy_flush_buffer(struct tty_struct *tty)
1288 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1289 unsigned long flags;
1291 #ifdef SERIAL_DEBUG_IO
1292 printk("cy_flush_buffer %s\n", tty->name); /* */
1293 #endif
1295 if (serial_paranoia_check(info, tty->name, "cy_flush_buffer"))
1296 return;
1297 local_irq_save(flags);
1298 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
1299 local_irq_restore(flags);
1300 tty_wakeup(tty);
1301 } /* cy_flush_buffer */
1304 /* This routine is called by the upper-layer tty layer to signal
1305 that incoming characters should be throttled or that the
1306 throttle should be released.
1308 static void
1309 cy_throttle(struct tty_struct * tty)
1311 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1312 unsigned long flags;
1313 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1314 int channel;
1316 #ifdef SERIAL_DEBUG_THROTTLE
1317 char buf[64];
1319 printk("throttle %s: %d....\n", tty_name(tty, buf),
1320 tty->ldisc.chars_in_buffer(tty));
1321 printk("cy_throttle %s\n", tty->name);
1322 #endif
1324 if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){
1325 return;
1328 if (I_IXOFF(tty)) {
1329 info->x_char = STOP_CHAR(tty);
1330 /* Should use the "Send Special Character" feature!!! */
1333 channel = info->line;
1335 local_irq_save(flags);
1336 base_addr[CyCAR] = (u_char)channel;
1337 base_addr[CyMSVR1] = 0;
1338 local_irq_restore(flags);
1340 return;
1341 } /* cy_throttle */
1344 static void
1345 cy_unthrottle(struct tty_struct * tty)
1347 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1348 unsigned long flags;
1349 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1350 int channel;
1352 #ifdef SERIAL_DEBUG_THROTTLE
1353 char buf[64];
1355 printk("throttle %s: %d....\n", tty_name(tty, buf),
1356 tty->ldisc.chars_in_buffer(tty));
1357 printk("cy_unthrottle %s\n", tty->name);
1358 #endif
1360 if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){
1361 return;
1364 if (I_IXOFF(tty)) {
1365 info->x_char = START_CHAR(tty);
1366 /* Should use the "Send Special Character" feature!!! */
1369 channel = info->line;
1371 local_irq_save(flags);
1372 base_addr[CyCAR] = (u_char)channel;
1373 base_addr[CyMSVR1] = CyRTS;
1374 local_irq_restore(flags);
1376 return;
1377 } /* cy_unthrottle */
1379 static int
1380 get_serial_info(struct cyclades_port * info,
1381 struct serial_struct * retinfo)
1383 struct serial_struct tmp;
1385 /* CP('g'); */
1386 if (!retinfo)
1387 return -EFAULT;
1388 memset(&tmp, 0, sizeof(tmp));
1389 tmp.type = info->type;
1390 tmp.line = info->line;
1391 tmp.port = info->line;
1392 tmp.irq = 0;
1393 tmp.flags = info->flags;
1394 tmp.baud_base = 0; /*!!!*/
1395 tmp.close_delay = info->close_delay;
1396 tmp.custom_divisor = 0; /*!!!*/
1397 tmp.hub6 = 0; /*!!!*/
1398 return copy_to_user(retinfo,&tmp,sizeof(*retinfo)) ? -EFAULT : 0;
1399 } /* get_serial_info */
1401 static int
1402 set_serial_info(struct cyclades_port * info,
1403 struct serial_struct * new_info)
1405 struct serial_struct new_serial;
1406 struct cyclades_port old_info;
1408 /* CP('s'); */
1409 if (!new_info)
1410 return -EFAULT;
1411 if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
1412 return -EFAULT;
1413 old_info = *info;
1415 if (!capable(CAP_SYS_ADMIN)) {
1416 if ((new_serial.close_delay != info->close_delay) ||
1417 ((new_serial.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK) !=
1418 (info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)))
1419 return -EPERM;
1420 info->flags = ((info->flags & ~ASYNC_USR_MASK) |
1421 (new_serial.flags & ASYNC_USR_MASK));
1422 goto check_and_exit;
1427 * OK, past this point, all the error checking has been done.
1428 * At this point, we start making changes.....
1431 info->flags = ((info->flags & ~ASYNC_FLAGS) |
1432 (new_serial.flags & ASYNC_FLAGS));
1433 info->close_delay = new_serial.close_delay;
1436 check_and_exit:
1437 if (info->flags & ASYNC_INITIALIZED){
1438 config_setup(info);
1439 return 0;
1440 }else{
1441 return startup(info);
1443 } /* set_serial_info */
1445 static int
1446 cy_tiocmget(struct tty_struct *tty, struct file *file)
1448 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
1449 int channel;
1450 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1451 unsigned long flags;
1452 unsigned char status;
1453 unsigned int result;
1455 channel = info->line;
1457 local_irq_save(flags);
1458 base_addr[CyCAR] = (u_char)channel;
1459 status = base_addr[CyMSVR1] | base_addr[CyMSVR2];
1460 local_irq_restore(flags);
1462 return ((status & CyRTS) ? TIOCM_RTS : 0)
1463 | ((status & CyDTR) ? TIOCM_DTR : 0)
1464 | ((status & CyDCD) ? TIOCM_CAR : 0)
1465 | ((status & CyDSR) ? TIOCM_DSR : 0)
1466 | ((status & CyCTS) ? TIOCM_CTS : 0);
1467 } /* cy_tiocmget */
1469 static int
1470 cy_tiocmset(struct tty_struct *tty, struct file *file,
1471 unsigned int set, unsigned int clear)
1473 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
1474 int channel;
1475 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1476 unsigned long flags;
1477 unsigned int arg;
1479 channel = info->line;
1481 if (set & TIOCM_RTS){
1482 local_irq_save(flags);
1483 base_addr[CyCAR] = (u_char)channel;
1484 base_addr[CyMSVR1] = CyRTS;
1485 local_irq_restore(flags);
1487 if (set & TIOCM_DTR){
1488 local_irq_save(flags);
1489 base_addr[CyCAR] = (u_char)channel;
1490 /* CP('S');CP('2'); */
1491 base_addr[CyMSVR2] = CyDTR;
1492 #ifdef SERIAL_DEBUG_DTR
1493 printk("cyc: %d: raising DTR\n", __LINE__);
1494 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
1495 #endif
1496 local_irq_restore(flags);
1499 if (clear & TIOCM_RTS){
1500 local_irq_save(flags);
1501 base_addr[CyCAR] = (u_char)channel;
1502 base_addr[CyMSVR1] = 0;
1503 local_irq_restore(flags);
1505 if (clear & TIOCM_DTR){
1506 local_irq_save(flags);
1507 base_addr[CyCAR] = (u_char)channel;
1508 /* CP('C');CP('2'); */
1509 base_addr[CyMSVR2] = 0;
1510 #ifdef SERIAL_DEBUG_DTR
1511 printk("cyc: %d: dropping DTR\n", __LINE__);
1512 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
1513 #endif
1514 local_irq_restore(flags);
1517 return 0;
1518 } /* set_modem_info */
1520 static void
1521 send_break( struct cyclades_port * info, int duration)
1522 { /* Let the transmit ISR take care of this (since it
1523 requires stuffing characters into the output stream).
1525 info->x_break = duration;
1526 if (!info->xmit_cnt ) {
1527 start_xmit(info);
1529 } /* send_break */
1531 static int
1532 get_mon_info(struct cyclades_port * info, struct cyclades_monitor * mon)
1535 if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor)))
1536 return -EFAULT;
1537 info->mon.int_count = 0;
1538 info->mon.char_count = 0;
1539 info->mon.char_max = 0;
1540 info->mon.char_last = 0;
1541 return 0;
1544 static int
1545 set_threshold(struct cyclades_port * info, unsigned long *arg)
1547 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1548 unsigned long value;
1549 int channel;
1551 if (get_user(value, arg))
1552 return -EFAULT;
1554 channel = info->line;
1555 info->cor4 &= ~CyREC_FIFO;
1556 info->cor4 |= value & CyREC_FIFO;
1557 base_addr[CyCOR4] = info->cor4;
1558 return 0;
1561 static int
1562 get_threshold(struct cyclades_port * info, unsigned long *value)
1564 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1565 int channel;
1566 unsigned long tmp;
1568 channel = info->line;
1570 tmp = base_addr[CyCOR4] & CyREC_FIFO;
1571 return put_user(tmp,value);
1574 static int
1575 set_default_threshold(struct cyclades_port * info, unsigned long *arg)
1577 unsigned long value;
1579 if (get_user(value, arg))
1580 return -EFAULT;
1582 info->default_threshold = value & 0x0f;
1583 return 0;
1586 static int
1587 get_default_threshold(struct cyclades_port * info, unsigned long *value)
1589 return put_user(info->default_threshold,value);
1592 static int
1593 set_timeout(struct cyclades_port * info, unsigned long *arg)
1595 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1596 int channel;
1597 unsigned long value;
1599 if (get_user(value, arg))
1600 return -EFAULT;
1602 channel = info->line;
1604 base_addr[CyRTPRL] = value & 0xff;
1605 base_addr[CyRTPRH] = (value >> 8) & 0xff;
1606 return 0;
1609 static int
1610 get_timeout(struct cyclades_port * info, unsigned long *value)
1612 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1613 int channel;
1614 unsigned long tmp;
1616 channel = info->line;
1618 tmp = base_addr[CyRTPRL];
1619 return put_user(tmp,value);
1622 static int
1623 set_default_timeout(struct cyclades_port * info, unsigned long value)
1625 info->default_timeout = value & 0xff;
1626 return 0;
1629 static int
1630 get_default_timeout(struct cyclades_port * info, unsigned long *value)
1632 return put_user(info->default_timeout,value);
1635 static int
1636 cy_ioctl(struct tty_struct *tty, struct file * file,
1637 unsigned int cmd, unsigned long arg)
1639 unsigned long val;
1640 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
1641 int ret_val = 0;
1643 #ifdef SERIAL_DEBUG_OTHER
1644 printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg); /* */
1645 #endif
1647 switch (cmd) {
1648 case CYGETMON:
1649 ret_val = get_mon_info(info, (struct cyclades_monitor *)arg);
1650 break;
1651 case CYGETTHRESH:
1652 ret_val = get_threshold(info, (unsigned long *)arg);
1653 break;
1654 case CYSETTHRESH:
1655 ret_val = set_threshold(info, (unsigned long *)arg);
1656 break;
1657 case CYGETDEFTHRESH:
1658 ret_val = get_default_threshold(info, (unsigned long *)arg);
1659 break;
1660 case CYSETDEFTHRESH:
1661 ret_val = set_default_threshold(info, (unsigned long *)arg);
1662 break;
1663 case CYGETTIMEOUT:
1664 ret_val = get_timeout(info, (unsigned long *)arg);
1665 break;
1666 case CYSETTIMEOUT:
1667 ret_val = set_timeout(info, (unsigned long *)arg);
1668 break;
1669 case CYGETDEFTIMEOUT:
1670 ret_val = get_default_timeout(info, (unsigned long *)arg);
1671 break;
1672 case CYSETDEFTIMEOUT:
1673 ret_val = set_default_timeout(info, (unsigned long)arg);
1674 break;
1675 case TCSBRK: /* SVID version: non-zero arg --> no break */
1676 ret_val = tty_check_change(tty);
1677 if (ret_val)
1678 break;
1679 tty_wait_until_sent(tty,0);
1680 if (!arg)
1681 send_break(info, HZ/4); /* 1/4 second */
1682 break;
1683 case TCSBRKP: /* support for POSIX tcsendbreak() */
1684 ret_val = tty_check_change(tty);
1685 if (ret_val)
1686 break;
1687 tty_wait_until_sent(tty,0);
1688 send_break(info, arg ? arg*(HZ/10) : HZ/4);
1689 break;
1691 /* The following commands are incompletely implemented!!! */
1692 case TIOCGSOFTCAR:
1693 ret_val = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *) arg);
1694 break;
1695 case TIOCSSOFTCAR:
1696 ret_val = get_user(val, (unsigned long *) arg);
1697 if (ret_val)
1698 break;
1699 tty->termios->c_cflag =
1700 ((tty->termios->c_cflag & ~CLOCAL) | (val ? CLOCAL : 0));
1701 break;
1702 case TIOCGSERIAL:
1703 ret_val = get_serial_info(info, (struct serial_struct *) arg);
1704 break;
1705 case TIOCSSERIAL:
1706 ret_val = set_serial_info(info,
1707 (struct serial_struct *) arg);
1708 break;
1709 default:
1710 ret_val = -ENOIOCTLCMD;
1713 #ifdef SERIAL_DEBUG_OTHER
1714 printk("cy_ioctl done\n");
1715 #endif
1717 return ret_val;
1718 } /* cy_ioctl */
1723 static void
1724 cy_set_termios(struct tty_struct *tty, struct termios * old_termios)
1726 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1728 #ifdef SERIAL_DEBUG_OTHER
1729 printk("cy_set_termios %s\n", tty->name);
1730 #endif
1732 if (tty->termios->c_cflag == old_termios->c_cflag)
1733 return;
1734 config_setup(info);
1736 if ((old_termios->c_cflag & CRTSCTS) &&
1737 !(tty->termios->c_cflag & CRTSCTS)) {
1738 tty->stopped = 0;
1739 cy_start(tty);
1741 #ifdef tytso_patch_94Nov25_1726
1742 if (!(old_termios->c_cflag & CLOCAL) &&
1743 (tty->termios->c_cflag & CLOCAL))
1744 wake_up_interruptible(&info->open_wait);
1745 #endif
1747 return;
1748 } /* cy_set_termios */
1751 static void
1752 cy_close(struct tty_struct * tty, struct file * filp)
1754 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
1756 /* CP('C'); */
1757 #ifdef SERIAL_DEBUG_OTHER
1758 printk("cy_close %s\n", tty->name);
1759 #endif
1761 if (!info
1762 || serial_paranoia_check(info, tty->name, "cy_close")){
1763 return;
1765 #ifdef SERIAL_DEBUG_OPEN
1766 printk("cy_close %s, count = %d\n", tty->name, info->count);
1767 #endif
1769 if ((tty->count == 1) && (info->count != 1)) {
1771 * Uh, oh. tty->count is 1, which means that the tty
1772 * structure will be freed. Info->count should always
1773 * be one in these conditions. If it's greater than
1774 * one, we've got real problems, since it means the
1775 * serial port won't be shutdown.
1777 printk("cy_close: bad serial port count; tty->count is 1, "
1778 "info->count is %d\n", info->count);
1779 info->count = 1;
1781 #ifdef SERIAL_DEBUG_COUNT
1782 printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count - 1);
1783 #endif
1784 if (--info->count < 0) {
1785 printk("cy_close: bad serial port count for ttys%d: %d\n",
1786 info->line, info->count);
1787 #ifdef SERIAL_DEBUG_COUNT
1788 printk("cyc: %d: setting count to 0\n", __LINE__);
1789 #endif
1790 info->count = 0;
1792 if (info->count)
1793 return;
1794 info->flags |= ASYNC_CLOSING;
1795 if (info->flags & ASYNC_INITIALIZED)
1796 tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
1797 shutdown(info);
1798 if (tty->driver->flush_buffer)
1799 tty->driver->flush_buffer(tty);
1800 tty_ldisc_flush(tty);
1801 info->event = 0;
1802 info->tty = 0;
1803 if (info->blocked_open) {
1804 if (info->close_delay) {
1805 msleep_interruptible(jiffies_to_msecs(info->close_delay));
1807 wake_up_interruptible(&info->open_wait);
1809 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
1810 wake_up_interruptible(&info->close_wait);
1812 #ifdef SERIAL_DEBUG_OTHER
1813 printk("cy_close done\n");
1814 #endif
1816 return;
1817 } /* cy_close */
1820 * cy_hangup() --- called by tty_hangup() when a hangup is signaled.
1822 void
1823 cy_hangup(struct tty_struct *tty)
1825 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
1827 #ifdef SERIAL_DEBUG_OTHER
1828 printk("cy_hangup %s\n", tty->name); /* */
1829 #endif
1831 if (serial_paranoia_check(info, tty->name, "cy_hangup"))
1832 return;
1834 shutdown(info);
1835 #if 0
1836 info->event = 0;
1837 info->count = 0;
1838 #ifdef SERIAL_DEBUG_COUNT
1839 printk("cyc: %d: setting count to 0\n", __LINE__);
1840 #endif
1841 info->tty = 0;
1842 #endif
1843 info->flags &= ~ASYNC_NORMAL_ACTIVE;
1844 wake_up_interruptible(&info->open_wait);
1845 } /* cy_hangup */
1850 * ------------------------------------------------------------
1851 * cy_open() and friends
1852 * ------------------------------------------------------------
1855 static int
1856 block_til_ready(struct tty_struct *tty, struct file * filp,
1857 struct cyclades_port *info)
1859 DECLARE_WAITQUEUE(wait, current);
1860 unsigned long flags;
1861 int channel;
1862 int retval;
1863 volatile u_char *base_addr = (u_char *)BASE_ADDR;
1866 * If the device is in the middle of being closed, then block
1867 * until it's done, and then try again.
1869 if (info->flags & ASYNC_CLOSING) {
1870 interruptible_sleep_on(&info->close_wait);
1871 if (info->flags & ASYNC_HUP_NOTIFY){
1872 return -EAGAIN;
1873 }else{
1874 return -ERESTARTSYS;
1879 * If non-blocking mode is set, then make the check up front
1880 * and then exit.
1882 if (filp->f_flags & O_NONBLOCK) {
1883 info->flags |= ASYNC_NORMAL_ACTIVE;
1884 return 0;
1888 * Block waiting for the carrier detect and the line to become
1889 * free (i.e., not in use by the callout). While we are in
1890 * this loop, info->count is dropped by one, so that
1891 * cy_close() knows when to free things. We restore it upon
1892 * exit, either normal or abnormal.
1894 retval = 0;
1895 add_wait_queue(&info->open_wait, &wait);
1896 #ifdef SERIAL_DEBUG_OPEN
1897 printk("block_til_ready before block: %s, count = %d\n",
1898 tty->name, info->count);/**/
1899 #endif
1900 info->count--;
1901 #ifdef SERIAL_DEBUG_COUNT
1902 printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count);
1903 #endif
1904 info->blocked_open++;
1906 channel = info->line;
1908 while (1) {
1909 local_irq_save(flags);
1910 base_addr[CyCAR] = (u_char)channel;
1911 base_addr[CyMSVR1] = CyRTS;
1912 /* CP('S');CP('4'); */
1913 base_addr[CyMSVR2] = CyDTR;
1914 #ifdef SERIAL_DEBUG_DTR
1915 printk("cyc: %d: raising DTR\n", __LINE__);
1916 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
1917 #endif
1918 local_irq_restore(flags);
1919 set_current_state(TASK_INTERRUPTIBLE);
1920 if (tty_hung_up_p(filp)
1921 || !(info->flags & ASYNC_INITIALIZED) ){
1922 if (info->flags & ASYNC_HUP_NOTIFY) {
1923 retval = -EAGAIN;
1924 }else{
1925 retval = -ERESTARTSYS;
1927 break;
1929 local_irq_save(flags);
1930 base_addr[CyCAR] = (u_char)channel;
1931 /* CP('L');CP1(1 && C_CLOCAL(tty)); CP1(1 && (base_addr[CyMSVR1] & CyDCD) ); */
1932 if (!(info->flags & ASYNC_CLOSING)
1933 && (C_CLOCAL(tty)
1934 || (base_addr[CyMSVR1] & CyDCD))) {
1935 local_irq_restore(flags);
1936 break;
1938 local_irq_restore(flags);
1939 if (signal_pending(current)) {
1940 retval = -ERESTARTSYS;
1941 break;
1943 #ifdef SERIAL_DEBUG_OPEN
1944 printk("block_til_ready blocking: %s, count = %d\n",
1945 tty->name, info->count);/**/
1946 #endif
1947 schedule();
1949 current->state = TASK_RUNNING;
1950 remove_wait_queue(&info->open_wait, &wait);
1951 if (!tty_hung_up_p(filp)){
1952 info->count++;
1953 #ifdef SERIAL_DEBUG_COUNT
1954 printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count);
1955 #endif
1957 info->blocked_open--;
1958 #ifdef SERIAL_DEBUG_OPEN
1959 printk("block_til_ready after blocking: %s, count = %d\n",
1960 tty->name, info->count);/**/
1961 #endif
1962 if (retval)
1963 return retval;
1964 info->flags |= ASYNC_NORMAL_ACTIVE;
1965 return 0;
1966 } /* block_til_ready */
1969 * This routine is called whenever a serial port is opened. It
1970 * performs the serial-specific initialization for the tty structure.
1973 cy_open(struct tty_struct *tty, struct file * filp)
1975 struct cyclades_port *info;
1976 int retval, line;
1978 /* CP('O'); */
1979 line = tty->index;
1980 if ((line < 0) || (NR_PORTS <= line)){
1981 return -ENODEV;
1983 info = &cy_port[line];
1984 if (info->line < 0){
1985 return -ENODEV;
1987 #ifdef SERIAL_DEBUG_OTHER
1988 printk("cy_open %s\n", tty->name); /* */
1989 #endif
1990 if (serial_paranoia_check(info, tty->name, "cy_open")){
1991 return -ENODEV;
1993 #ifdef SERIAL_DEBUG_OPEN
1994 printk("cy_open %s, count = %d\n", tty->name, info->count);/**/
1995 #endif
1996 info->count++;
1997 #ifdef SERIAL_DEBUG_COUNT
1998 printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count);
1999 #endif
2000 tty->driver_data = info;
2001 info->tty = tty;
2003 if (!tmp_buf) {
2004 tmp_buf = (unsigned char *) get_zeroed_page(GFP_KERNEL);
2005 if (!tmp_buf){
2006 return -ENOMEM;
2011 * Start up serial port
2013 retval = startup(info);
2014 if (retval){
2015 return retval;
2018 retval = block_til_ready(tty, filp, info);
2019 if (retval) {
2020 #ifdef SERIAL_DEBUG_OPEN
2021 printk("cy_open returning after block_til_ready with %d\n",
2022 retval);
2023 #endif
2024 return retval;
2027 #ifdef SERIAL_DEBUG_OPEN
2028 printk("cy_open done\n");/**/
2029 #endif
2030 return 0;
2031 } /* cy_open */
2036 * ---------------------------------------------------------------------
2037 * serial167_init() and friends
2039 * serial167_init() is called at boot-time to initialize the serial driver.
2040 * ---------------------------------------------------------------------
2044 * This routine prints out the appropriate serial driver version
2045 * number, and identifies which options were configured into this
2046 * driver.
2048 static void
2049 show_version(void)
2051 printk("MVME166/167 cd2401 driver\n");
2052 } /* show_version */
2054 /* initialize chips on card -- return number of valid
2055 chips (which is number of ports/4) */
2058 * This initialises the hardware to a reasonable state. It should
2059 * probe the chip first so as to copy 166-Bug setup as a default for
2060 * port 0. It initialises CMR to CyASYNC; that is never done again, so
2061 * as to limit the number of CyINIT_CHAN commands in normal running.
2063 * ... I wonder what I should do if this fails ...
2066 void
2067 mvme167_serial_console_setup(int cflag)
2069 volatile unsigned char* base_addr = (u_char *)BASE_ADDR;
2070 int ch;
2071 u_char spd;
2072 u_char rcor, rbpr, badspeed = 0;
2073 unsigned long flags;
2075 local_irq_save(flags);
2078 * First probe channel zero of the chip, to see what speed has
2079 * been selected.
2082 base_addr[CyCAR] = 0;
2084 rcor = base_addr[CyRCOR] << 5;
2085 rbpr = base_addr[CyRBPR];
2087 for (spd = 0; spd < sizeof(baud_bpr); spd++)
2088 if (rbpr == baud_bpr[spd] && rcor == baud_co[spd])
2089 break;
2090 if (spd >= sizeof(baud_bpr)) {
2091 spd = 14; /* 19200 */
2092 badspeed = 1; /* Failed to identify speed */
2094 initial_console_speed = spd;
2096 /* OK, we have chosen a speed, now reset and reinitialise */
2098 my_udelay(20000L); /* Allow time for any active o/p to complete */
2099 if(base_addr[CyCCR] != 0x00){
2100 local_irq_restore(flags);
2101 /* printk(" chip is never idle (CCR != 0)\n"); */
2102 return;
2105 base_addr[CyCCR] = CyCHIP_RESET; /* Reset the chip */
2106 my_udelay(1000L);
2108 if(base_addr[CyGFRCR] == 0x00){
2109 local_irq_restore(flags);
2110 /* printk(" chip is not responding (GFRCR stayed 0)\n"); */
2111 return;
2115 * System clock is 20Mhz, divided by 2048, so divide by 10 for a 1.0ms
2116 * tick
2119 base_addr[CyTPR] = 10;
2121 base_addr[CyPILR1] = 0x01; /* Interrupt level for modem change */
2122 base_addr[CyPILR2] = 0x02; /* Interrupt level for tx ints */
2123 base_addr[CyPILR3] = 0x03; /* Interrupt level for rx ints */
2126 * Attempt to set up all channels to something reasonable, and
2127 * bang out a INIT_CHAN command. We should then be able to limit
2128 * the ammount of fiddling we have to do in normal running.
2131 for (ch = 3; ch >= 0 ; ch--) {
2132 base_addr[CyCAR] = (u_char)ch;
2133 base_addr[CyIER] = 0;
2134 base_addr[CyCMR] = CyASYNC;
2135 base_addr[CyLICR] = (u_char)ch << 2;
2136 base_addr[CyLIVR] = 0x5c;
2137 base_addr[CyTCOR] = baud_co[spd];
2138 base_addr[CyTBPR] = baud_bpr[spd];
2139 base_addr[CyRCOR] = baud_co[spd] >> 5;
2140 base_addr[CyRBPR] = baud_bpr[spd];
2141 base_addr[CySCHR1] = 'Q' & 0x1f;
2142 base_addr[CySCHR2] = 'X' & 0x1f;
2143 base_addr[CySCRL] = 0;
2144 base_addr[CySCRH] = 0;
2145 base_addr[CyCOR1] = Cy_8_BITS | CyPARITY_NONE;
2146 base_addr[CyCOR2] = 0;
2147 base_addr[CyCOR3] = Cy_1_STOP;
2148 base_addr[CyCOR4] = baud_cor4[spd];
2149 base_addr[CyCOR5] = 0;
2150 base_addr[CyCOR6] = 0;
2151 base_addr[CyCOR7] = 0;
2152 base_addr[CyRTPRL] = 2;
2153 base_addr[CyRTPRH] = 0;
2154 base_addr[CyMSVR1] = 0;
2155 base_addr[CyMSVR2] = 0;
2156 write_cy_cmd(base_addr,CyINIT_CHAN|CyDIS_RCVR|CyDIS_XMTR);
2160 * Now do specials for channel zero....
2163 base_addr[CyMSVR1] = CyRTS;
2164 base_addr[CyMSVR2] = CyDTR;
2165 base_addr[CyIER] = CyRxData;
2166 write_cy_cmd(base_addr,CyENB_RCVR|CyENB_XMTR);
2168 local_irq_restore(flags);
2170 my_udelay(20000L); /* Let it all settle down */
2172 printk("CD2401 initialised, chip is rev 0x%02x\n", base_addr[CyGFRCR]);
2173 if (badspeed)
2174 printk(" WARNING: Failed to identify line speed, rcor=%02x,rbpr=%02x\n",
2175 rcor >> 5, rbpr);
2176 } /* serial_console_init */
2178 static struct tty_operations cy_ops = {
2179 .open = cy_open,
2180 .close = cy_close,
2181 .write = cy_write,
2182 .put_char = cy_put_char,
2183 .flush_chars = cy_flush_chars,
2184 .write_room = cy_write_room,
2185 .chars_in_buffer = cy_chars_in_buffer,
2186 .flush_buffer = cy_flush_buffer,
2187 .ioctl = cy_ioctl,
2188 .throttle = cy_throttle,
2189 .unthrottle = cy_unthrottle,
2190 .set_termios = cy_set_termios,
2191 .stop = cy_stop,
2192 .start = cy_start,
2193 .hangup = cy_hangup,
2194 .tiocmget = cy_tiocmget,
2195 .tiocmset = cy_tiocmset,
2197 /* The serial driver boot-time initialization code!
2198 Hardware I/O ports are mapped to character special devices on a
2199 first found, first allocated manner. That is, this code searches
2200 for Cyclom cards in the system. As each is found, it is probed
2201 to discover how many chips (and thus how many ports) are present.
2202 These ports are mapped to the tty ports 64 and upward in monotonic
2203 fashion. If an 8-port card is replaced with a 16-port card, the
2204 port mapping on a following card will shift.
2206 This approach is different from what is used in the other serial
2207 device driver because the Cyclom is more properly a multiplexer,
2208 not just an aggregation of serial ports on one card.
2210 If there are more cards with more ports than have been statically
2211 allocated above, a warning is printed and the extra ports are ignored.
2213 static int __init
2214 serial167_init(void)
2216 struct cyclades_port *info;
2217 int ret = 0;
2218 int good_ports = 0;
2219 int port_num = 0;
2220 int index;
2221 int DefSpeed;
2222 #ifdef notyet
2223 struct sigaction sa;
2224 #endif
2226 if (!(mvme16x_config &MVME16x_CONFIG_GOT_CD2401))
2227 return 0;
2229 cy_serial_driver = alloc_tty_driver(NR_PORTS);
2230 if (!cy_serial_driver)
2231 return -ENOMEM;
2233 #if 0
2234 scrn[1] = '\0';
2235 #endif
2237 show_version();
2239 /* Has "console=0,9600n8" been used in bootinfo to change speed? */
2240 if (serial_console_cflag)
2241 DefSpeed = serial_console_cflag & 0017;
2242 else {
2243 DefSpeed = initial_console_speed;
2244 serial_console_info = &cy_port[0];
2245 serial_console_cflag = DefSpeed | CS8;
2246 #if 0
2247 serial_console = 64; /*callout_driver.minor_start*/
2248 #endif
2251 /* Initialize the tty_driver structure */
2253 cy_serial_driver->owner = THIS_MODULE;
2254 cy_serial_driver->devfs_name = "tts/";
2255 cy_serial_driver->name = "ttyS";
2256 cy_serial_driver->major = TTY_MAJOR;
2257 cy_serial_driver->minor_start = 64;
2258 cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
2259 cy_serial_driver->subtype = SERIAL_TYPE_NORMAL;
2260 cy_serial_driver->init_termios = tty_std_termios;
2261 cy_serial_driver->init_termios.c_cflag =
2262 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
2263 cy_serial_driver->flags = TTY_DRIVER_REAL_RAW;
2264 tty_set_operations(cy_serial_driver, &cy_ops);
2266 ret = tty_register_driver(cy_serial_driver);
2267 if (ret) {
2268 printk(KERN_ERR "Couldn't register MVME166/7 serial driver\n");
2269 put_tty_driver(cy_serial_driver);
2270 return ret;
2273 port_num = 0;
2274 info = cy_port;
2275 for (index = 0; index < 1; index++) {
2277 good_ports = 4;
2279 if(port_num < NR_PORTS){
2280 while( good_ports-- && port_num < NR_PORTS){
2281 /*** initialize port ***/
2282 info->magic = CYCLADES_MAGIC;
2283 info->type = PORT_CIRRUS;
2284 info->card = index;
2285 info->line = port_num;
2286 info->flags = STD_COM_FLAGS;
2287 info->tty = 0;
2288 info->xmit_fifo_size = 12;
2289 info->cor1 = CyPARITY_NONE|Cy_8_BITS;
2290 info->cor2 = CyETC;
2291 info->cor3 = Cy_1_STOP;
2292 info->cor4 = 0x08; /* _very_ small receive threshold */
2293 info->cor5 = 0;
2294 info->cor6 = 0;
2295 info->cor7 = 0;
2296 info->tbpr = baud_bpr[DefSpeed]; /* Tx BPR */
2297 info->tco = baud_co[DefSpeed]; /* Tx CO */
2298 info->rbpr = baud_bpr[DefSpeed]; /* Rx BPR */
2299 info->rco = baud_co[DefSpeed] >> 5; /* Rx CO */
2300 info->close_delay = 0;
2301 info->x_char = 0;
2302 info->event = 0;
2303 info->count = 0;
2304 #ifdef SERIAL_DEBUG_COUNT
2305 printk("cyc: %d: setting count to 0\n", __LINE__);
2306 #endif
2307 info->blocked_open = 0;
2308 info->default_threshold = 0;
2309 info->default_timeout = 0;
2310 INIT_WORK(&info->tqueue, do_softint, info);
2311 init_waitqueue_head(&info->open_wait);
2312 init_waitqueue_head(&info->close_wait);
2313 /* info->session */
2314 /* info->pgrp */
2315 /*** !!!!!!!! this may expose new bugs !!!!!!!!! *********/
2316 info->read_status_mask = CyTIMEOUT| CySPECHAR| CyBREAK
2317 | CyPARITY| CyFRAME| CyOVERRUN;
2318 /* info->timeout */
2320 printk("ttyS%d ", info->line);
2321 port_num++;info++;
2322 if(!(port_num & 7)){
2323 printk("\n ");
2327 printk("\n");
2329 while( port_num < NR_PORTS){
2330 info->line = -1;
2331 port_num++;info++;
2333 #ifdef CONFIG_REMOTE_DEBUG
2334 debug_setup();
2335 #endif
2336 ret = request_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt, 0,
2337 "cd2401_errors", cd2401_rxerr_interrupt);
2338 if (ret) {
2339 printk(KERN_ERR "Could't get cd2401_errors IRQ");
2340 goto cleanup_serial_driver;
2343 ret = request_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt, 0,
2344 "cd2401_modem", cd2401_modem_interrupt);
2345 if (ret) {
2346 printk(KERN_ERR "Could't get cd2401_modem IRQ");
2347 goto cleanup_irq_cd2401_errors;
2350 ret = request_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt, 0,
2351 "cd2401_txints", cd2401_tx_interrupt);
2352 if (ret) {
2353 printk(KERN_ERR "Could't get cd2401_txints IRQ");
2354 goto cleanup_irq_cd2401_modem;
2357 ret = request_irq(MVME167_IRQ_SER_RX, cd2401_rx_interrupt, 0,
2358 "cd2401_rxints", cd2401_rx_interrupt);
2359 if (ret) {
2360 printk(KERN_ERR "Could't get cd2401_rxints IRQ");
2361 goto cleanup_irq_cd2401_txints;
2364 /* Now we have registered the interrupt handlers, allow the interrupts */
2366 pcc2chip[PccSCCMICR] = 0x15; /* Serial ints are level 5 */
2367 pcc2chip[PccSCCTICR] = 0x15;
2368 pcc2chip[PccSCCRICR] = 0x15;
2370 pcc2chip[PccIMLR] = 3; /* Allow PCC2 ints above 3!? */
2372 return 0;
2373 cleanup_irq_cd2401_txints:
2374 free_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt);
2375 cleanup_irq_cd2401_modem:
2376 free_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt);
2377 cleanup_irq_cd2401_errors:
2378 free_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt);
2379 cleanup_serial_driver:
2380 if (tty_unregister_driver(cy_serial_driver))
2381 printk(KERN_ERR "Couldn't unregister MVME166/7 serial driver\n");
2382 put_tty_driver(cy_serial_driver);
2383 return ret;
2384 } /* serial167_init */
2386 module_init(serial167_init);
2389 #ifdef CYCLOM_SHOW_STATUS
2390 static void
2391 show_status(int line_num)
2393 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
2394 int channel;
2395 struct cyclades_port * info;
2396 unsigned long flags;
2398 info = &cy_port[line_num];
2399 channel = info->line;
2400 printk(" channel %d\n", channel);/**/
2402 printk(" cy_port\n");
2403 printk(" card line flags = %d %d %x\n",
2404 info->card, info->line, info->flags);
2405 printk(" *tty read_status_mask timeout xmit_fifo_size = %lx %x %x %x\n",
2406 (long)info->tty, info->read_status_mask,
2407 info->timeout, info->xmit_fifo_size);
2408 printk(" cor1,cor2,cor3,cor4,cor5,cor6,cor7 = %x %x %x %x %x %x %x\n",
2409 info->cor1, info->cor2, info->cor3, info->cor4, info->cor5,
2410 info->cor6, info->cor7);
2411 printk(" tbpr,tco,rbpr,rco = %d %d %d %d\n",
2412 info->tbpr, info->tco, info->rbpr, info->rco);
2413 printk(" close_delay event count = %d %d %d\n",
2414 info->close_delay, info->event, info->count);
2415 printk(" x_char blocked_open = %x %x\n",
2416 info->x_char, info->blocked_open);
2417 printk(" open_wait = %lx %lx %lx\n",
2418 (long)info->open_wait);
2421 local_irq_save(flags);
2423 /* Global Registers */
2425 printk(" CyGFRCR %x\n", base_addr[CyGFRCR]);
2426 printk(" CyCAR %x\n", base_addr[CyCAR]);
2427 printk(" CyRISR %x\n", base_addr[CyRISR]);
2428 printk(" CyTISR %x\n", base_addr[CyTISR]);
2429 printk(" CyMISR %x\n", base_addr[CyMISR]);
2430 printk(" CyRIR %x\n", base_addr[CyRIR]);
2431 printk(" CyTIR %x\n", base_addr[CyTIR]);
2432 printk(" CyMIR %x\n", base_addr[CyMIR]);
2433 printk(" CyTPR %x\n", base_addr[CyTPR]);
2435 base_addr[CyCAR] = (u_char)channel;
2437 /* Virtual Registers */
2439 #if 0
2440 printk(" CyRIVR %x\n", base_addr[CyRIVR]);
2441 printk(" CyTIVR %x\n", base_addr[CyTIVR]);
2442 printk(" CyMIVR %x\n", base_addr[CyMIVR]);
2443 printk(" CyMISR %x\n", base_addr[CyMISR]);
2444 #endif
2446 /* Channel Registers */
2448 printk(" CyCCR %x\n", base_addr[CyCCR]);
2449 printk(" CyIER %x\n", base_addr[CyIER]);
2450 printk(" CyCOR1 %x\n", base_addr[CyCOR1]);
2451 printk(" CyCOR2 %x\n", base_addr[CyCOR2]);
2452 printk(" CyCOR3 %x\n", base_addr[CyCOR3]);
2453 printk(" CyCOR4 %x\n", base_addr[CyCOR4]);
2454 printk(" CyCOR5 %x\n", base_addr[CyCOR5]);
2455 #if 0
2456 printk(" CyCCSR %x\n", base_addr[CyCCSR]);
2457 printk(" CyRDCR %x\n", base_addr[CyRDCR]);
2458 #endif
2459 printk(" CySCHR1 %x\n", base_addr[CySCHR1]);
2460 printk(" CySCHR2 %x\n", base_addr[CySCHR2]);
2461 #if 0
2462 printk(" CySCHR3 %x\n", base_addr[CySCHR3]);
2463 printk(" CySCHR4 %x\n", base_addr[CySCHR4]);
2464 printk(" CySCRL %x\n", base_addr[CySCRL]);
2465 printk(" CySCRH %x\n", base_addr[CySCRH]);
2466 printk(" CyLNC %x\n", base_addr[CyLNC]);
2467 printk(" CyMCOR1 %x\n", base_addr[CyMCOR1]);
2468 printk(" CyMCOR2 %x\n", base_addr[CyMCOR2]);
2469 #endif
2470 printk(" CyRTPRL %x\n", base_addr[CyRTPRL]);
2471 printk(" CyRTPRH %x\n", base_addr[CyRTPRH]);
2472 printk(" CyMSVR1 %x\n", base_addr[CyMSVR1]);
2473 printk(" CyMSVR2 %x\n", base_addr[CyMSVR2]);
2474 printk(" CyRBPR %x\n", base_addr[CyRBPR]);
2475 printk(" CyRCOR %x\n", base_addr[CyRCOR]);
2476 printk(" CyTBPR %x\n", base_addr[CyTBPR]);
2477 printk(" CyTCOR %x\n", base_addr[CyTCOR]);
2479 local_irq_restore(flags);
2480 } /* show_status */
2481 #endif
2484 #if 0
2485 /* Dummy routine in mvme16x/config.c for now */
2487 /* Serial console setup. Called from linux/init/main.c */
2489 void console_setup(char *str, int *ints)
2491 char *s;
2492 int baud, bits, parity;
2493 int cflag = 0;
2495 /* Sanity check. */
2496 if (ints[0] > 3 || ints[1] > 3) return;
2498 /* Get baud, bits and parity */
2499 baud = 2400;
2500 bits = 8;
2501 parity = 'n';
2502 if (ints[2]) baud = ints[2];
2503 if ((s = strchr(str, ','))) {
2504 do {
2505 s++;
2506 } while(*s >= '0' && *s <= '9');
2507 if (*s) parity = *s++;
2508 if (*s) bits = *s - '0';
2511 /* Now construct a cflag setting. */
2512 switch(baud) {
2513 case 1200:
2514 cflag |= B1200;
2515 break;
2516 case 9600:
2517 cflag |= B9600;
2518 break;
2519 case 19200:
2520 cflag |= B19200;
2521 break;
2522 case 38400:
2523 cflag |= B38400;
2524 break;
2525 case 2400:
2526 default:
2527 cflag |= B2400;
2528 break;
2530 switch(bits) {
2531 case 7:
2532 cflag |= CS7;
2533 break;
2534 default:
2535 case 8:
2536 cflag |= CS8;
2537 break;
2539 switch(parity) {
2540 case 'o': case 'O':
2541 cflag |= PARODD;
2542 break;
2543 case 'e': case 'E':
2544 cflag |= PARENB;
2545 break;
2548 serial_console_info = &cy_port[ints[1]];
2549 serial_console_cflag = cflag;
2550 serial_console = ints[1] + 64; /*callout_driver.minor_start*/
2552 #endif
2555 * The following is probably out of date for 2.1.x serial console stuff.
2557 * The console is registered early on from arch/m68k/kernel/setup.c, and
2558 * it therefore relies on the chip being setup correctly by 166-Bug. This
2559 * seems reasonable, as the serial port has been used to invoke the system
2560 * boot. It also means that this function must not rely on any data
2561 * initialisation performed by serial167_init() etc.
2563 * Of course, once the console has been registered, we had better ensure
2564 * that serial167_init() doesn't leave the chip non-functional.
2566 * The console must be locked when we get here.
2569 void serial167_console_write(struct console *co, const char *str, unsigned count)
2571 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
2572 unsigned long flags;
2573 volatile u_char sink;
2574 u_char ier;
2575 int port;
2576 u_char do_lf = 0;
2577 int i = 0;
2579 local_irq_save(flags);
2581 /* Ensure transmitter is enabled! */
2583 port = 0;
2584 base_addr[CyCAR] = (u_char)port;
2585 while (base_addr[CyCCR])
2587 base_addr[CyCCR] = CyENB_XMTR;
2589 ier = base_addr[CyIER];
2590 base_addr[CyIER] = CyTxMpty;
2592 while (1) {
2593 if (pcc2chip[PccSCCTICR] & 0x20)
2595 /* We have a Tx int. Acknowledge it */
2596 sink = pcc2chip[PccTPIACKR];
2597 if ((base_addr[CyLICR] >> 2) == port) {
2598 if (i == count) {
2599 /* Last char of string is now output */
2600 base_addr[CyTEOIR] = CyNOTRANS;
2601 break;
2603 if (do_lf) {
2604 base_addr[CyTDR] = '\n';
2605 str++;
2606 i++;
2607 do_lf = 0;
2609 else if (*str == '\n') {
2610 base_addr[CyTDR] = '\r';
2611 do_lf = 1;
2613 else {
2614 base_addr[CyTDR] = *str++;
2615 i++;
2617 base_addr[CyTEOIR] = 0;
2619 else
2620 base_addr[CyTEOIR] = CyNOTRANS;
2624 base_addr[CyIER] = ier;
2626 local_irq_restore(flags);
2629 static struct tty_driver *serial167_console_device(struct console *c, int *index)
2631 *index = c->index;
2632 return cy_serial_driver;
2636 static int __init serial167_console_setup(struct console *co, char *options)
2638 return 0;
2642 static struct console sercons = {
2643 .name = "ttyS",
2644 .write = serial167_console_write,
2645 .device = serial167_console_device,
2646 .setup = serial167_console_setup,
2647 .flags = CON_PRINTBUFFER,
2648 .index = -1,
2652 static int __init serial167_console_init(void)
2654 if (vme_brdtype == VME_TYPE_MVME166 ||
2655 vme_brdtype == VME_TYPE_MVME167 ||
2656 vme_brdtype == VME_TYPE_MVME177) {
2657 mvme167_serial_console_setup(0);
2658 register_console(&sercons);
2660 return 0;
2662 console_initcall(serial167_console_init);
2664 #ifdef CONFIG_REMOTE_DEBUG
2665 void putDebugChar (int c)
2667 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
2668 unsigned long flags;
2669 volatile u_char sink;
2670 u_char ier;
2671 int port;
2673 local_irq_save(flags);
2675 /* Ensure transmitter is enabled! */
2677 port = DEBUG_PORT;
2678 base_addr[CyCAR] = (u_char)port;
2679 while (base_addr[CyCCR])
2681 base_addr[CyCCR] = CyENB_XMTR;
2683 ier = base_addr[CyIER];
2684 base_addr[CyIER] = CyTxMpty;
2686 while (1) {
2687 if (pcc2chip[PccSCCTICR] & 0x20)
2689 /* We have a Tx int. Acknowledge it */
2690 sink = pcc2chip[PccTPIACKR];
2691 if ((base_addr[CyLICR] >> 2) == port) {
2692 base_addr[CyTDR] = c;
2693 base_addr[CyTEOIR] = 0;
2694 break;
2696 else
2697 base_addr[CyTEOIR] = CyNOTRANS;
2701 base_addr[CyIER] = ier;
2703 local_irq_restore(flags);
2706 int getDebugChar()
2708 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
2709 unsigned long flags;
2710 volatile u_char sink;
2711 u_char ier;
2712 int port;
2713 int i, c;
2715 i = debugiq.out;
2716 if (i != debugiq.in) {
2717 c = debugiq.buf[i];
2718 if (++i == DEBUG_LEN)
2719 i = 0;
2720 debugiq.out = i;
2721 return c;
2723 /* OK, nothing in queue, wait in poll loop */
2725 local_irq_save(flags);
2727 /* Ensure receiver is enabled! */
2729 port = DEBUG_PORT;
2730 base_addr[CyCAR] = (u_char)port;
2731 #if 0
2732 while (base_addr[CyCCR])
2734 base_addr[CyCCR] = CyENB_RCVR;
2735 #endif
2736 ier = base_addr[CyIER];
2737 base_addr[CyIER] = CyRxData;
2739 while (1) {
2740 if (pcc2chip[PccSCCRICR] & 0x20)
2742 /* We have a Rx int. Acknowledge it */
2743 sink = pcc2chip[PccRPIACKR];
2744 if ((base_addr[CyLICR] >> 2) == port) {
2745 int cnt = base_addr[CyRFOC];
2746 while (cnt-- > 0)
2748 c = base_addr[CyRDR];
2749 if (c == 0)
2750 printk ("!! debug char is null (cnt=%d) !!", cnt);
2751 else
2752 queueDebugChar (c);
2754 base_addr[CyREOIR] = 0;
2755 i = debugiq.out;
2756 if (i == debugiq.in)
2757 panic ("Debug input queue empty!");
2758 c = debugiq.buf[i];
2759 if (++i == DEBUG_LEN)
2760 i = 0;
2761 debugiq.out = i;
2762 break;
2764 else
2765 base_addr[CyREOIR] = CyNOTRANS;
2769 base_addr[CyIER] = ier;
2771 local_irq_restore(flags);
2773 return (c);
2776 void queueDebugChar (int c)
2778 int i;
2780 i = debugiq.in;
2781 debugiq.buf[i] = c;
2782 if (++i == DEBUG_LEN)
2783 i = 0;
2784 if (i != debugiq.out)
2785 debugiq.in = i;
2788 static void
2789 debug_setup()
2791 unsigned long flags;
2792 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
2793 int i, cflag;
2795 cflag = B19200;
2797 local_irq_save(flags);
2799 for (i = 0; i < 4; i++)
2801 base_addr[CyCAR] = i;
2802 base_addr[CyLICR] = i << 2;
2805 debugiq.in = debugiq.out = 0;
2807 base_addr[CyCAR] = DEBUG_PORT;
2809 /* baud rate */
2810 i = cflag & CBAUD;
2812 base_addr[CyIER] = 0;
2814 base_addr[CyCMR] = CyASYNC;
2815 base_addr[CyLICR] = DEBUG_PORT << 2;
2816 base_addr[CyLIVR] = 0x5c;
2818 /* tx and rx baud rate */
2820 base_addr[CyTCOR] = baud_co[i];
2821 base_addr[CyTBPR] = baud_bpr[i];
2822 base_addr[CyRCOR] = baud_co[i] >> 5;
2823 base_addr[CyRBPR] = baud_bpr[i];
2825 /* set line characteristics according configuration */
2827 base_addr[CySCHR1] = 0;
2828 base_addr[CySCHR2] = 0;
2829 base_addr[CySCRL] = 0;
2830 base_addr[CySCRH] = 0;
2831 base_addr[CyCOR1] = Cy_8_BITS | CyPARITY_NONE;
2832 base_addr[CyCOR2] = 0;
2833 base_addr[CyCOR3] = Cy_1_STOP;
2834 base_addr[CyCOR4] = baud_cor4[i];
2835 base_addr[CyCOR5] = 0;
2836 base_addr[CyCOR6] = 0;
2837 base_addr[CyCOR7] = 0;
2839 write_cy_cmd(base_addr,CyINIT_CHAN);
2840 write_cy_cmd(base_addr,CyENB_RCVR);
2842 base_addr[CyCAR] = DEBUG_PORT; /* !!! Is this needed? */
2844 base_addr[CyRTPRL] = 2;
2845 base_addr[CyRTPRH] = 0;
2847 base_addr[CyMSVR1] = CyRTS;
2848 base_addr[CyMSVR2] = CyDTR;
2850 base_addr[CyIER] = CyRxData;
2852 local_irq_restore(flags);
2854 } /* debug_setup */
2856 #endif
2858 MODULE_LICENSE("GPL");