1 /* $Id: aurora.c,v 1.1.1.1 2005/04/11 02:50:34 jack Exp $
2 * linux/drivers/sbus/char/aurora.c -- Aurora multiport driver
4 * Copyright (c) 1999 by Oliver Aldulea (oli at bv dot ro)
6 * This code is based on the RISCom/8 multiport serial driver written
7 * by Dmitry Gorodchanin (pgmdsg@ibi.com), based on the Linux serial
8 * driver, written by Linus Torvalds, Theodore T'so and others.
9 * The Aurora multiport programming info was obtained mainly from the
10 * Cirrus Logic CD180 documentation (available on the web), and by
11 * doing heavy tests on the board. Many thanks to Eddie C. Dost for the
12 * help on the sbus interface.
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 * This is the first public release.
32 * Most of the information you need is in the aurora.h file. Please
33 * read that file before reading this one.
35 * Several parts of the code do not have comments yet.
37 * n.b. The board can support 115.2 bit rates, but only on a few
38 * ports. The total badwidth of one chip (ports 0-7 or 8-15) is equal
39 * to OSC_FREQ div 16. In case of my board, each chip can take 6
40 * channels of 115.2 kbaud. This information is not well-tested.
42 * Fixed to use tty_get_baud_rate().
43 * Theodore Ts'o <tytso@mit.edu>, 2001-Oct-12
46 #include <linux/module.h>
48 #include <linux/errno.h>
49 #include <linux/sched.h>
50 #ifdef AURORA_INT_DEBUG
51 #include <linux/timer.h>
53 #include <linux/interrupt.h>
54 #include <linux/tty.h>
55 #include <linux/tty_flip.h>
56 #include <linux/major.h>
57 #include <linux/string.h>
58 #include <linux/fcntl.h>
60 #include <linux/kernel.h>
61 #include <linux/init.h>
62 #include <linux/tqueue.h>
63 #include <linux/delay.h>
67 #include <asm/oplib.h>
68 #include <asm/system.h>
69 #include <asm/segment.h>
70 #include <asm/bitops.h>
71 #include <asm/kdebug.h>
73 #include <asm/uaccess.h>
78 unsigned char irqs[4] = {
82 #ifdef AURORA_INT_DEBUG
87 #define MIN(a,b) ((a) < (b) ? (a) : (b))
90 #define AURORA_TYPE_NORMAL 1
92 static struct tty_driver aurora_driver;
93 static struct Aurora_board aurora_board[AURORA_NBOARD] = {
97 static struct Aurora_port aurora_port[AURORA_TNPORTS] = {
101 /* no longer used. static struct Aurora_board * IRQ_to_board[16] = { NULL, } ;*/
102 static unsigned char * tmp_buf = NULL;
103 static DECLARE_MUTEX(tmp_buf_sem);
104 static int aurora_refcount = 0;
105 static struct tty_struct * aurora_table[AURORA_TNPORTS] = { NULL, };
106 static struct termios * aurora_termios[AURORA_TNPORTS] = { NULL, };
107 static struct termios * aurora_termios_locked[AURORA_TNPORTS] = { NULL, };
109 DECLARE_TASK_QUEUE(tq_aurora);
111 static inline int aurora_paranoia_check(struct Aurora_port const * port,
112 kdev_t device, const char *routine)
114 #ifdef AURORA_PARANOIA_CHECK
115 static const char *badmagic =
116 KERN_DEBUG "aurora: Warning: bad aurora port magic number for device %s in %s\n";
117 static const char *badinfo =
118 KERN_DEBUG "aurora: Warning: null aurora port for device %s in %s\n";
121 printk(badinfo, kdevname(device), routine);
124 if (port->magic != AURORA_MAGIC) {
125 printk(badmagic, kdevname(device), routine);
134 * Service functions for aurora driver.
138 /* Get board number from pointer */
139 static inline int board_No (struct Aurora_board const * bp)
141 return bp - aurora_board;
144 /* Get port number from pointer */
145 static inline int port_No (struct Aurora_port const * port)
147 return AURORA_PORT(port - aurora_port);
150 /* Get pointer to board from pointer to port */
151 static inline struct Aurora_board * port_Board(struct Aurora_port const * port)
153 return &aurora_board[AURORA_BOARD(port - aurora_port)];
156 /* Wait for Channel Command Register ready */
157 static inline void aurora_wait_CCR(struct aurora_reg128 * r)
162 printk("aurora_wait_CCR\n");
164 /* FIXME: need something more descriptive than 100000 :) */
165 for (delay = 100000; delay; delay--)
166 if (!sbus_readb(&r->r[CD180_CCR]))
168 printk(KERN_DEBUG "aurora: Timeout waiting for CCR.\n");
172 * aurora probe functions.
175 /* Must be called with enabled interrupts */
176 static inline void aurora_long_delay(unsigned long delay)
181 printk("aurora_long_delay: start\n");
183 for (i = jiffies + delay; time_before(jiffies, i); ) ;
185 printk("aurora_long_delay: end\n");
189 /* Reset and setup CD180 chip */
190 static int aurora_init_CD180(struct Aurora_board * bp, int chip)
196 printk("aurora_init_CD180: start %d:%d\n",
199 save_flags(flags); cli();
200 sbus_writeb(0, &bp->r[chip]->r[CD180_CAR]);
201 sbus_writeb(0, &bp->r[chip]->r[CD180_GSVR]);
203 /* Wait for CCR ready */
204 aurora_wait_CCR(bp->r[chip]);
206 /* Reset CD180 chip */
207 sbus_writeb(CCR_HARDRESET, &bp->r[chip]->r[CD180_CCR]);
212 (sbus_readb(&bp->r[chip]->r[CD180_GSVR])!=0xff))udelay(100);
214 printk(KERN_ERR "aurora%d: Chip %d failed init.\n",
216 restore_flags(flags);
220 sbus_writeb((board_No(bp)<<5)|((chip+1)<<3),
221 &bp->r[chip]->r[CD180_GSVR]); /* Set ID for this chip */
222 sbus_writeb(0x80|bp->ACK_MINT,
223 &bp->r[chip]->r[CD180_MSMR]); /* Prio for modem intr */
224 sbus_writeb(0x80|bp->ACK_TINT,
225 &bp->r[chip]->r[CD180_TSMR]); /* Prio for transmitter intr */
226 sbus_writeb(0x80|bp->ACK_RINT,
227 &bp->r[chip]->r[CD180_RSMR]); /* Prio for receiver intr */
228 /* Setting up prescaler. We need 4 tick per 1 ms */
229 sbus_writeb((bp->oscfreq/(1000000/AURORA_TPS)) >> 8,
230 &bp->r[chip]->r[CD180_PPRH]);
231 sbus_writeb((bp->oscfreq/(1000000/AURORA_TPS)) & 0xff,
232 &bp->r[chip]->r[CD180_PPRL]);
234 sbus_writeb(SRCR_AUTOPRI|SRCR_GLOBPRI,
235 &bp->r[chip]->r[CD180_SRCR]);
237 id = sbus_readb(&bp->r[chip]->r[CD180_GFRCR]);
238 printk(KERN_INFO "aurora%d: Chip %d id %02x: ",
239 board_No(bp), chip,id);
240 if(sbus_readb(&bp->r[chip]->r[CD180_SRCR]) & 128) {
242 case 0x82:printk("CL-CD1864 rev A\n");break;
243 case 0x83:printk("CL-CD1865 rev A\n");break;
244 case 0x84:printk("CL-CD1865 rev B\n");break;
245 case 0x85:printk("CL-CD1865 rev C\n");break;
246 default:printk("Unknown.\n");
250 case 0x81:printk("CL-CD180 rev B\n");break;
251 case 0x82:printk("CL-CD180 rev C\n");break;
252 default:printk("Unknown.\n");
255 restore_flags(flags);
257 printk("aurora_init_CD180: end\n");
262 static int valid_irq(unsigned char irq)
265 for(i=0;i<TYPE_1_IRQS;i++)
266 if (type_1_irq[i]==irq) return 1;
270 static void aurora_interrupt(int irq, void * dev_id, struct pt_regs * regs);
272 /* Main probing routine, also sets irq. */
273 static int aurora_probe(void)
275 struct sbus_bus *sbus;
276 struct sbus_dev *sdev;
280 struct Aurora_board *bp;
282 for_each_sbus(sbus) {
283 for_each_sbusdev(sdev, sbus) {
284 /* printk("Try: %x %s\n",sdev,sdev->prom_name);*/
285 if (!strcmp(sdev->prom_name, "sio16")) {
287 printk(KERN_INFO "aurora: sio16 at %p\n",sdev);
289 if((sdev->reg_addrs[0].reg_size!=1) &&
290 (sdev->reg_addrs[1].reg_size!=128) &&
291 (sdev->reg_addrs[2].reg_size!=128) &&
292 (sdev->reg_addrs[3].reg_size!=4)) {
293 printk(KERN_ERR "aurora%d: registers' sizes "
294 "do not match.\n", bn);
297 bp = &aurora_board[bn];
298 bp->r0 = (struct aurora_reg1 *)
299 sbus_ioremap(&sdev->resource[0], 0,
300 sdev->reg_addrs[0].reg_size,
302 if (bp->r0 == NULL) {
303 printk(KERN_ERR "aurora%d: can't map "
304 "reg_addrs[0]\n", bn);
308 printk("Map reg 0: %p\n", bp->r0);
310 bp->r[0] = (struct aurora_reg128 *)
311 sbus_ioremap(&sdev->resource[1], 0,
312 sdev->reg_addrs[1].reg_size,
314 if (bp->r[0] == NULL) {
315 printk(KERN_ERR "aurora%d: can't map "
316 "reg_addrs[1]\n", bn);
320 printk("Map reg 1: %p\n", bp->r[0]);
322 bp->r[1] = (struct aurora_reg128 *)
323 sbus_ioremap(&sdev->resource[2], 0,
324 sdev->reg_addrs[2].reg_size,
326 if (bp->r[1] == NULL) {
327 printk(KERN_ERR "aurora%d: can't map "
328 "reg_addrs[2]\n", bn);
332 printk("Map reg 2: %p\n", bp->r[1]);
334 bp->r3 = (struct aurora_reg4 *)
335 sbus_ioremap(&sdev->resource[3], 0,
336 sdev->reg_addrs[3].reg_size,
338 if (bp->r3 == NULL) {
339 printk(KERN_ERR "aurora%d: can't map "
340 "reg_addrs[3]\n", bn);
344 printk("Map reg 3: %p\n", bp->r3);
346 /* Variables setup */
349 grrr=prom_getint(sdev->prom_node,"intr");
350 printk("intr pri %d\n", grrr);
352 if ((bp->irq=irqs[bn]) && valid_irq(bp->irq) &&
353 !request_irq(bp->irq|0x30, aurora_interrupt, SA_SHIRQ, "sio16", bp)) {
354 free_irq(bp->irq|0x30, bp);
356 if ((bp->irq=prom_getint(sdev->prom_node, "bintr")) && valid_irq(bp->irq) &&
357 !request_irq(bp->irq|0x30, aurora_interrupt, SA_SHIRQ, "sio16", bp)) {
358 free_irq(bp->irq|0x30, bp);
360 if ((bp->irq=prom_getint(sdev->prom_node, "intr")) && valid_irq(bp->irq) &&
361 !request_irq(bp->irq|0x30, aurora_interrupt, SA_SHIRQ, "sio16", bp)) {
362 free_irq(bp->irq|0x30, bp);
364 for(grrr=0;grrr<TYPE_1_IRQS;grrr++) {
365 if ((bp->irq=type_1_irq[grrr])&&!request_irq(bp->irq|0x30, aurora_interrupt, SA_SHIRQ, "sio16", bp)) {
366 free_irq(bp->irq|0x30, bp);
369 printk(KERN_ERR "aurora%d: Could not get an irq for this board !!!\n",bn);
373 if(bp->flags==0xff)break;
374 printk(KERN_INFO "aurora%d: irq %d\n",bn,bp->irq&0x0f);
376 grrr=prom_getproperty(sdev->prom_node,"dtr_rts",buf,sizeof(buf));
377 if(!strcmp(buf,"swapped")){
378 printk(KERN_INFO "aurora%d: Swapped DTR and RTS\n",bn);
381 bp->MSVDTR=CD180_MSVRTS;
382 bp->MSVRTS=CD180_MSVDTR;
383 bp->flags|=AURORA_BOARD_DTR_FLOW_OK;
385 #ifdef AURORA_FORCE_DTR_FLOW
386 printk(KERN_INFO "aurora%d: Forcing swapped DTR-RTS\n",bn);
389 bp->MSVDTR=CD180_MSVRTS;
390 bp->MSVRTS=CD180_MSVDTR;
391 bp->flags|=AURORA_BOARD_DTR_FLOW_OK;
393 printk(KERN_INFO "aurora%d: Normal DTR and RTS\n",bn);
396 bp->MSVDTR=CD180_MSVDTR;
397 bp->MSVRTS=CD180_MSVRTS;
400 bp->oscfreq=prom_getint(sdev->prom_node,"clk")*100;
401 printk(KERN_INFO "aurora%d: Oscillator: %d Hz\n",bn,bp->oscfreq);
402 grrr=prom_getproperty(sdev->prom_node,"chip",buf,sizeof(buf));
403 printk(KERN_INFO "aurora%d: Chips: %s\n",bn,buf);
404 grrr=prom_getproperty(sdev->prom_node,"manu",buf,sizeof(buf));
405 printk(KERN_INFO "aurora%d: Manufacturer: %s\n",bn,buf);
406 grrr=prom_getproperty(sdev->prom_node,"model",buf,sizeof(buf));
407 printk(KERN_INFO "aurora%d: Model: %s\n",bn,buf);
408 grrr=prom_getproperty(sdev->prom_node,"rev",buf,sizeof(buf));
409 printk(KERN_INFO "aurora%d: Revision: %s\n",bn,buf);
410 grrr=prom_getproperty(sdev->prom_node,"mode",buf,sizeof(buf));
411 printk(KERN_INFO "aurora%d: Mode: %s\n",bn,buf);
415 bp->flags = AURORA_BOARD_PRESENT;
427 static void aurora_release_io_range(struct Aurora_board *bp)
429 sbus_iounmap((unsigned long)bp->r0, 1);
430 sbus_iounmap((unsigned long)bp->r[0], 128);
431 sbus_iounmap((unsigned long)bp->r[1], 128);
432 sbus_iounmap((unsigned long)bp->r3, 4);
435 static inline void aurora_mark_event(struct Aurora_port * port, int event)
438 printk("aurora_mark_event: start\n");
440 set_bit(event, &port->event);
441 queue_task(&port->tqueue, &tq_aurora);
444 printk("aurora_mark_event: end\n");
448 static __inline__ struct Aurora_port * aurora_get_port(struct Aurora_board const * bp,
450 unsigned char const *what)
452 unsigned char channel;
453 struct Aurora_port * port;
455 channel = ((chip << 3) |
456 ((sbus_readb(&bp->r[chip]->r[CD180_GSCR]) & GSCR_CHAN) >> GSCR_CHAN_OFF));
457 port = &aurora_port[board_No(bp) * AURORA_NPORT * AURORA_NCD180 + channel];
458 if (port->flags & ASYNC_INITIALIZED)
461 printk(KERN_DEBUG "aurora%d: %s interrupt from invalid port %d\n",
462 board_No(bp), what, channel);
466 static void aurora_receive_exc(struct Aurora_board const * bp, int chip)
468 struct Aurora_port *port;
469 struct tty_struct *tty;
470 unsigned char status;
473 if (!(port = aurora_get_port(bp, chip, "Receive_x")))
477 if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
478 #ifdef AURORA_INTNORM
479 printk("aurora%d: port %d: Working around flip buffer overflow.\n",
480 board_No(bp), port_No(port));
485 #ifdef AURORA_REPORT_OVERRUN
486 status = sbus_readb(&bp->r[chip]->r[CD180_RCSR]);
487 if (status & RCSR_OE) {
490 printk("aurora%d: port %d: Overrun. Total %ld overruns.\n",
491 board_No(bp), port_No(port), port->overrun);
494 status &= port->mark_mask;
496 status = sbus_readb(&bp->r[chip]->r[CD180_RCSR]) & port->mark_mask;
498 ch = sbus_readb(&bp->r[chip]->r[CD180_RDR]);
502 if (status & RCSR_TOUT) {
503 /* printk("aurora%d: port %d: Receiver timeout. Hardware problems ?\n",
504 board_No(bp), port_No(port));*/
507 } else if (status & RCSR_BREAK) {
508 printk(KERN_DEBUG "aurora%d: port %d: Handling break...\n",
509 board_No(bp), port_No(port));
510 *tty->flip.flag_buf_ptr++ = TTY_BREAK;
511 if (port->flags & ASYNC_SAK)
514 } else if (status & RCSR_PE)
515 *tty->flip.flag_buf_ptr++ = TTY_PARITY;
517 else if (status & RCSR_FE)
518 *tty->flip.flag_buf_ptr++ = TTY_FRAME;
520 else if (status & RCSR_OE)
521 *tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
524 *tty->flip.flag_buf_ptr++ = 0;
526 *tty->flip.char_buf_ptr++ = ch;
528 queue_task(&tty->flip.tqueue, &tq_timer);
531 static void aurora_receive(struct Aurora_board const * bp, int chip)
533 struct Aurora_port *port;
534 struct tty_struct *tty;
535 unsigned char count,cnt;
537 if (!(port = aurora_get_port(bp, chip, "Receive")))
542 count = sbus_readb(&bp->r[chip]->r[CD180_RDCR]);
544 #ifdef AURORA_REPORT_FIFO
545 port->hits[count > 8 ? 9 : count]++;
549 if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
550 #ifdef AURORA_INTNORM
551 printk("aurora%d: port %d: Working around flip buffer overflow.\n",
552 board_No(bp), port_No(port));
556 cnt = sbus_readb(&bp->r[chip]->r[CD180_RDR]);
557 *tty->flip.char_buf_ptr++ = cnt;
558 *tty->flip.flag_buf_ptr++ = 0;
561 queue_task(&tty->flip.tqueue, &tq_timer);
564 static void aurora_transmit(struct Aurora_board const * bp, int chip)
566 struct Aurora_port *port;
567 struct tty_struct *tty;
570 if (!(port = aurora_get_port(bp, chip, "Transmit")))
575 if (port->SRER & SRER_TXEMPTY) {
577 sbus_writeb(port_No(port) & 7,
578 &bp->r[chip]->r[CD180_CAR]);
580 port->SRER &= ~SRER_TXEMPTY;
581 sbus_writeb(port->SRER, &bp->r[chip]->r[CD180_SRER]);
585 if ((port->xmit_cnt <= 0 && !port->break_length)
586 || tty->stopped || tty->hw_stopped) {
587 sbus_writeb(port_No(port) & 7,
588 &bp->r[chip]->r[CD180_CAR]);
590 port->SRER &= ~SRER_TXRDY;
591 sbus_writeb(port->SRER,
592 &bp->r[chip]->r[CD180_SRER]);
596 if (port->break_length) {
597 if (port->break_length > 0) {
598 if (port->COR2 & COR2_ETC) {
599 sbus_writeb(CD180_C_ESC,
600 &bp->r[chip]->r[CD180_TDR]);
601 sbus_writeb(CD180_C_SBRK,
602 &bp->r[chip]->r[CD180_TDR]);
603 port->COR2 &= ~COR2_ETC;
605 count = MIN(port->break_length, 0xff);
606 sbus_writeb(CD180_C_ESC,
607 &bp->r[chip]->r[CD180_TDR]);
608 sbus_writeb(CD180_C_DELAY,
609 &bp->r[chip]->r[CD180_TDR]);
611 &bp->r[chip]->r[CD180_TDR]);
612 if (!(port->break_length -= count))
613 port->break_length--;
615 sbus_writeb(CD180_C_ESC,
616 &bp->r[chip]->r[CD180_TDR]);
617 sbus_writeb(CD180_C_EBRK,
618 &bp->r[chip]->r[CD180_TDR]);
619 sbus_writeb(port->COR2,
620 &bp->r[chip]->r[CD180_COR2]);
621 aurora_wait_CCR(bp->r[chip]);
622 sbus_writeb(CCR_CORCHG2,
623 &bp->r[chip]->r[CD180_CCR]);
624 port->break_length = 0;
631 u8 byte = port->xmit_buf[port->xmit_tail++];
633 sbus_writeb(byte, &bp->r[chip]->r[CD180_TDR]);
634 port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE-1);
635 if (--port->xmit_cnt <= 0)
637 } while (--count > 0);
639 if (port->xmit_cnt <= 0) {
640 sbus_writeb(port_No(port) & 7,
641 &bp->r[chip]->r[CD180_CAR]);
643 port->SRER &= ~SRER_TXRDY;
644 sbus_writeb(port->SRER,
645 &bp->r[chip]->r[CD180_SRER]);
647 if (port->xmit_cnt <= port->wakeup_chars)
648 aurora_mark_event(port, RS_EVENT_WRITE_WAKEUP);
651 static void aurora_check_modem(struct Aurora_board const * bp, int chip)
653 struct Aurora_port *port;
654 struct tty_struct *tty;
657 if (!(port = aurora_get_port(bp, chip, "Modem")))
662 mcr = sbus_readb(&bp->r[chip]->r[CD180_MCR]);
663 if (mcr & MCR_CDCHG) {
664 if (sbus_readb(&bp->r[chip]->r[CD180_MSVR]) & MSVR_CD)
665 wake_up_interruptible(&port->open_wait);
666 else if (!((port->flags & ASYNC_CALLOUT_ACTIVE) &&
667 (port->flags & ASYNC_CALLOUT_NOHUP))) {
669 if (schedule_task(&port->tqueue_hangup) == 0)
674 /* We don't have such things yet. My aurora board has DTR and RTS swapped, but that doesn't count in this driver. Let's hope
675 * Aurora didn't made any boards with CTS or DSR broken...
677 /* #ifdef AURORA_BRAIN_DAMAGED_CTS
678 if (mcr & MCR_CTSCHG) {
679 if (aurora_in(bp, CD180_MSVR) & MSVR_CTS) {
681 port->SRER |= SRER_TXRDY;
682 if (port->xmit_cnt <= port->wakeup_chars)
683 aurora_mark_event(port, RS_EVENT_WRITE_WAKEUP);
686 port->SRER &= ~SRER_TXRDY;
688 sbus_writeb(port->SRER, &bp->r[chip]->r[CD180_SRER]);
690 if (mcr & MCR_DSRCHG) {
691 if (aurora_in(bp, CD180_MSVR) & MSVR_DSR) {
693 port->SRER |= SRER_TXRDY;
694 if (port->xmit_cnt <= port->wakeup_chars)
695 aurora_mark_event(port, RS_EVENT_WRITE_WAKEUP);
698 port->SRER &= ~SRER_TXRDY;
700 sbus_writeb(port->SRER, &bp->r[chip]->r[CD180_SRER]);
702 #endif AURORA_BRAIN_DAMAGED_CTS */
704 /* Clear change bits */
705 sbus_writeb(0, &bp->r[chip]->r[CD180_MCR]);
708 /* The main interrupt processing routine */
709 static void aurora_interrupt(int irq, void * dev_id, struct pt_regs * regs)
711 unsigned char status;
712 unsigned char ack,chip/*,chip_id*/;
713 struct Aurora_board * bp = (struct Aurora_board *) dev_id;
714 unsigned long loop = 0;
716 #ifdef AURORA_INT_DEBUG
717 printk("IRQ%d %d\n",irq,++irqhit);
718 #ifdef AURORA_FLOODPRO
719 if (irqhit>=AURORA_FLOODPRO)
720 sbus_writeb(8, &bp->r0->r);
724 /* old bp = IRQ_to_board[irq&0x0f];*/
726 if (!bp || !(bp->flags & AURORA_BOARD_ACTIVE))
729 /* The while() below takes care of this.
730 status = sbus_readb(&bp->r[0]->r[CD180_SRSR]);
731 #ifdef AURORA_INT_DEBUG
732 printk("mumu: %02x\n", status);
734 if (!(status&SRSR_ANYINT))
735 return; * Nobody has anything to say, so exit *
737 while ((loop++ < 48) &&
738 (status = sbus_readb(&bp->r[0]->r[CD180_SRSR]) & SRSR_ANYINT)){
739 #ifdef AURORA_INT_DEBUG
740 printk("SRSR: %02x\n", status);
742 if (status & SRSR_REXT) {
743 ack = sbus_readb(&bp->r3->r[bp->ACK_RINT]);
744 #ifdef AURORA_INT_DEBUG
745 printk("R-ACK %02x\n", ack);
747 if ((ack >> 5) == board_No(bp)) {
748 if ((chip=((ack>>3)&3)-1) < AURORA_NCD180) {
749 if ((ack&GSVR_ITMASK)==GSVR_IT_RGD) {
750 aurora_receive(bp,chip);
752 &bp->r[chip]->r[CD180_EOSRR]);
753 } else if ((ack & GSVR_ITMASK) == GSVR_IT_REXC) {
754 aurora_receive_exc(bp,chip);
756 &bp->r[chip]->r[CD180_EOSRR]);
760 } else if (status & SRSR_TEXT) {
761 ack = sbus_readb(&bp->r3->r[bp->ACK_TINT]);
762 #ifdef AURORA_INT_DEBUG
763 printk("T-ACK %02x\n", ack);
765 if ((ack >> 5) == board_No(bp)) {
766 if ((chip=((ack>>3)&3)-1) < AURORA_NCD180) {
767 if ((ack&GSVR_ITMASK)==GSVR_IT_TX) {
768 aurora_transmit(bp,chip);
770 &bp->r[chip]->r[CD180_EOSRR]);
774 } else if (status & SRSR_MEXT) {
775 ack = sbus_readb(&bp->r3->r[bp->ACK_MINT]);
776 #ifdef AURORA_INT_DEBUG
777 printk("M-ACK %02x\n", ack);
779 if ((ack >> 5) == board_No(bp)) {
780 if ((chip = ((ack>>3)&3)-1) < AURORA_NCD180) {
781 if ((ack&GSVR_ITMASK)==GSVR_IT_MDM) {
782 aurora_check_modem(bp,chip);
784 &bp->r[chip]->r[CD180_EOSRR]);
790 /* I guess this faster code can be used with CD1865, using AUROPRI and GLOBPRI. */
792 while ((loop++ < 48)&&(status=bp->r[0]->r[CD180_SRSR]&SRSR_ANYINT)){
793 #ifdef AURORA_INT_DEBUG
794 printk("SRSR: %02x\n",status);
796 ack = sbus_readb(&bp->r3->r[0]);
797 #ifdef AURORA_INT_DEBUG
798 printk("ACK: %02x\n",ack);
800 if ((ack>>5)==board_No(bp)) {
801 if ((chip=((ack>>3)&3)-1) < AURORA_NCD180) {
803 if (ack==GSVR_IT_RGD) {
804 aurora_receive(bp,chip);
806 &bp->r[chip]->r[CD180_EOSRR]);
807 } else if (ack==GSVR_IT_REXC) {
808 aurora_receive_exc(bp,chip);
810 &bp->r[chip]->r[CD180_EOSRR]);
811 } else if (ack==GSVR_IT_TX) {
812 aurora_transmit(bp,chip);
814 &bp->r[chip]->r[CD180_EOSRR]);
815 } else if (ack==GSVR_IT_MDM) {
816 aurora_check_modem(bp,chip);
818 &bp->r[chip]->r[CD180_EOSRR]);
825 /* This is the old handling routine, used in riscom8 for only one CD180. I keep it here for reference. */
827 for(chip=0;chip<AURORA_NCD180;chip++){
828 chip_id=(board_No(bp)<<5)|((chip+1)<<3);
830 while ((loop++ < 1) &&
831 ((status = sbus_readb(&bp->r[chip]->r[CD180_SRSR])) &
832 (SRSR_TEXT | SRSR_MEXT | SRSR_REXT))) {
834 if (status & SRSR_REXT) {
835 ack = sbus_readb(&bp->r3->r[bp->ACK_RINT]);
836 if (ack == (chip_id | GSVR_IT_RGD)) {
840 aurora_receive(bp,chip);
841 } else if (ack == (chip_id | GSVR_IT_REXC)) {
845 aurora_receive_exc(bp,chip);
847 #ifdef AURORA_INTNORM
848 printk("aurora%d-%d: Bad receive ack 0x%02x.\n",
849 board_No(bp), chip, ack);
852 } else if (status & SRSR_TEXT) {
853 ack = sbus_readb(&bp->r3->r[bp->ACK_TINT]);
854 if (ack == (chip_id | GSVR_IT_TX)){
858 aurora_transmit(bp,chip);
860 #ifdef AURORA_INTNORM
861 printk("aurora%d-%d: Bad transmit ack 0x%02x.\n",
862 board_No(bp), chip, ack);
865 } else if (status & SRSR_MEXT) {
866 ack = sbus_readb(&bp->r3->r[bp->ACK_MINT]);
867 if (ack == (chip_id | GSVR_IT_MDM)){
871 aurora_check_modem(bp,chip);
873 #ifdef AURORA_INTNORM
874 printk("aurora%d-%d: Bad modem ack 0x%02x.\n",
875 board_No(bp), chip, ack);
879 sbus_writeb(0, &bp->r[chip]->r[CD180_EOSRR]);
885 #ifdef AURORA_INT_DEBUG
886 static void aurora_timer (unsigned long ignored);
888 static struct timer_list
889 aurora_poll_timer = { NULL, NULL, 0, 0, aurora_timer };
892 aurora_timer (unsigned long ignored)
897 save_flags(flags); cli();
899 printk("SRSR: %02x,%02x - ",
900 sbus_readb(&aurora_board[0].r[0]->r[CD180_SRSR]),
901 sbus_readb(&aurora_board[0].r[1]->r[CD180_SRSR]));
902 for (i = 0; i < 4; i++) {
905 sbus_readb(&aurora_board[0].r3->r[i]));
909 aurora_poll_timer.expires = jiffies + 300;
910 add_timer (&aurora_poll_timer);
912 restore_flags(flags);
917 * Routines for open & close processing.
920 /* Called with disabled interrupts */
921 static int aurora_setup_board(struct Aurora_board * bp)
927 for (i = 0; i < AURORA_ALLIRQ; i++) {
928 error = request_irq(allirq[i]|0x30, aurora_interrupt, SA_SHIRQ,
931 printk(KERN_ERR "IRQ%d request error %d\n",
935 error = request_irq(bp->irq|0x30, aurora_interrupt, SA_SHIRQ,
938 printk(KERN_ERR "IRQ request error %d\n", error);
943 sbus_writeb(0, &bp->r0->r);
945 if (bp->flags & AURORA_BOARD_TYPE_2) {
948 sbus_writeb((AURORA_CFG_ENABLE_IO | AURORA_CFG_ENABLE_IRQ |
949 (((bp->irq)&0x0f)>>2)),
954 if (aurora_init_CD180(bp,0))error=1;error=0;
955 if (aurora_init_CD180(bp,1))error++;
956 if (error == AURORA_NCD180) {
957 printk(KERN_ERR "Both chips failed initialisation.\n");
961 #ifdef AURORA_INT_DEBUG
962 aurora_poll_timer.expires= jiffies + 1;
963 add_timer(&aurora_poll_timer);
966 printk("aurora_setup_board: end\n");
971 /* Called with disabled interrupts */
972 static void aurora_shutdown_board(struct Aurora_board *bp)
977 printk("aurora_shutdown_board: start\n");
980 #ifdef AURORA_INT_DEBUG
981 del_timer(&aurora_poll_timer);
985 for(i=0;i<AURORA_ALLIRQ;i++){
986 free_irq(allirq[i]|0x30, bp);
987 /* IRQ_to_board[allirq[i]&0xf] = NULL;*/
990 free_irq(bp->irq|0x30, bp);
991 /* IRQ_to_board[bp->irq&0xf] = NULL;*/
995 sbus_writeb(i & 7, &bp->r[i>>3]->r[CD180_CAR]);
997 sbus_writeb(0, &bp->r[i>>3]->r[CD180_MSVR]);
1000 /* Board shutdown */
1001 sbus_writeb(0, &bp->r0->r);
1004 printk("aurora_shutdown_board: end\n");
1008 /* Setting up port characteristics.
1009 * Must be called with disabled interrupts
1011 static void aurora_change_speed(struct Aurora_board *bp, struct Aurora_port *port)
1013 struct tty_struct *tty;
1016 unsigned char cor1 = 0, cor3 = 0;
1017 unsigned char mcor1 = 0, mcor2 = 0,chip;
1020 printk("aurora_change_speed: start\n");
1022 if (!(tty = port->tty) || !tty->termios)
1025 chip = AURORA_CD180(port_No(port));
1029 port->MSVR = MSVR_RTS|MSVR_DTR;
1031 baud = tty_get_baud_rate(tty);
1033 /* Select port on the board */
1034 sbus_writeb(port_No(port) & 7,
1035 &bp->r[chip]->r[CD180_CAR]);
1039 /* Drop DTR & exit */
1040 port->MSVR &= ~(bp->DTR|bp->RTS);
1041 sbus_writeb(port->MSVR,
1042 &bp->r[chip]->r[CD180_MSVR]);
1046 port->MSVR |= bp->DTR;
1047 sbus_writeb(port->MSVR,
1048 &bp->r[chip]->r[CD180_MSVR]);
1051 /* Now we must calculate some speed dependant things. */
1053 /* Set baud rate for port. */
1054 tmp = (((bp->oscfreq + baud/2) / baud +
1055 CD180_TPC/2) / CD180_TPC);
1057 /* tmp = (bp->oscfreq/7)/baud;
1058 if((tmp%10)>4)tmp=tmp/10+1;else tmp=tmp/10;*/
1059 /* printk("Prescaler period: %d\n",tmp);*/
1061 sbus_writeb((tmp >> 8) & 0xff,
1062 &bp->r[chip]->r[CD180_RBPRH]);
1063 sbus_writeb((tmp >> 8) & 0xff,
1064 &bp->r[chip]->r[CD180_TBPRH]);
1065 sbus_writeb(tmp & 0xff, &bp->r[chip]->r[CD180_RBPRL]);
1066 sbus_writeb(tmp & 0xff, &bp->r[chip]->r[CD180_TBPRL]);
1068 baud = (baud + 5) / 10; /* Estimated CPS */
1070 /* Two timer ticks seems enough to wakeup something like SLIP driver */
1071 tmp = ((baud + HZ/2) / HZ) * 2 - CD180_NFIFO;
1072 port->wakeup_chars = (tmp < 0) ? 0 : ((tmp >= SERIAL_XMIT_SIZE) ?
1073 SERIAL_XMIT_SIZE - 1 : tmp);
1075 /* Receiver timeout will be transmission time for 1.5 chars */
1076 tmp = (AURORA_TPS + AURORA_TPS/2 + baud/2) / baud;
1077 tmp = (tmp > 0xff) ? 0xff : tmp;
1078 sbus_writeb(tmp, &bp->r[chip]->r[CD180_RTPR]);
1080 switch (C_CSIZE(tty)) {
1098 cor1 |= COR1_IGNORE;
1099 if (C_PARENB(tty)) {
1100 cor1 |= COR1_NORMPAR;
1104 cor1 &= ~COR1_IGNORE;
1106 /* Set marking of some errors */
1107 port->mark_mask = RCSR_OE | RCSR_TOUT;
1109 port->mark_mask |= RCSR_FE | RCSR_PE;
1110 if (I_BRKINT(tty) || I_PARMRK(tty))
1111 port->mark_mask |= RCSR_BREAK;
1113 port->mark_mask &= ~(RCSR_FE | RCSR_PE);
1114 if (I_IGNBRK(tty)) {
1115 port->mark_mask &= ~RCSR_BREAK;
1117 /* Real raw mode. Ignore all */
1118 port->mark_mask &= ~RCSR_OE;
1120 /* Enable Hardware Flow Control */
1121 if (C_CRTSCTS(tty)) {
1122 /*#ifdef AURORA_BRAIN_DAMAGED_CTS
1123 port->SRER |= SRER_DSR | SRER_CTS;
1124 mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD;
1125 mcor2 |= MCOR2_DSROD | MCOR2_CTSOD;
1126 tty->hw_stopped = !(aurora_in(bp, CD180_MSVR) & (MSVR_CTS|MSVR_DSR));
1128 port->COR2 |= COR2_CTSAE;
1130 if (bp->flags&AURORA_BOARD_DTR_FLOW_OK) {
1131 mcor1 |= AURORA_RXTH;
1134 /* Enable Software Flow Control. FIXME: I'm not sure about this */
1135 /* Some people reported that it works, but I still doubt */
1137 port->COR2 |= COR2_TXIBE;
1138 cor3 |= (COR3_FCT | COR3_SCDE);
1140 port->COR2 |= COR2_IXM;
1141 sbus_writeb(START_CHAR(tty),
1142 &bp->r[chip]->r[CD180_SCHR1]);
1143 sbus_writeb(STOP_CHAR(tty),
1144 &bp->r[chip]->r[CD180_SCHR2]);
1145 sbus_writeb(START_CHAR(tty),
1146 &bp->r[chip]->r[CD180_SCHR3]);
1147 sbus_writeb(STOP_CHAR(tty),
1148 &bp->r[chip]->r[CD180_SCHR4]);
1150 if (!C_CLOCAL(tty)) {
1151 /* Enable CD check */
1152 port->SRER |= SRER_CD;
1153 mcor1 |= MCOR1_CDZD;
1154 mcor2 |= MCOR2_CDOD;
1158 /* Enable receiver */
1159 port->SRER |= SRER_RXD;
1161 /* Set input FIFO size (1-8 bytes) */
1162 cor3 |= AURORA_RXFIFO;
1163 /* Setting up CD180 channel registers */
1164 sbus_writeb(cor1, &bp->r[chip]->r[CD180_COR1]);
1165 sbus_writeb(port->COR2, &bp->r[chip]->r[CD180_COR2]);
1166 sbus_writeb(cor3, &bp->r[chip]->r[CD180_COR3]);
1167 /* Make CD180 know about registers change */
1168 aurora_wait_CCR(bp->r[chip]);
1169 sbus_writeb(CCR_CORCHG1 | CCR_CORCHG2 | CCR_CORCHG3,
1170 &bp->r[chip]->r[CD180_CCR]);
1171 /* Setting up modem option registers */
1172 sbus_writeb(mcor1, &bp->r[chip]->r[CD180_MCOR1]);
1173 sbus_writeb(mcor2, &bp->r[chip]->r[CD180_MCOR2]);
1174 /* Enable CD180 transmitter & receiver */
1175 aurora_wait_CCR(bp->r[chip]);
1176 sbus_writeb(CCR_TXEN | CCR_RXEN, &bp->r[chip]->r[CD180_CCR]);
1177 /* Enable interrupts */
1178 sbus_writeb(port->SRER, &bp->r[chip]->r[CD180_SRER]);
1179 /* And finally set RTS on */
1180 sbus_writeb(port->MSVR, &bp->r[chip]->r[CD180_MSVR]);
1182 printk("aurora_change_speed: end\n");
1186 /* Must be called with interrupts enabled */
1187 static int aurora_setup_port(struct Aurora_board *bp, struct Aurora_port *port)
1189 unsigned long flags;
1192 printk("aurora_setup_port: start %d\n",port_No(port));
1194 if (port->flags & ASYNC_INITIALIZED)
1197 if (!port->xmit_buf) {
1198 /* We may sleep in get_free_page() */
1201 if (!(tmp = get_free_page(GFP_KERNEL)))
1204 if (port->xmit_buf) {
1206 return -ERESTARTSYS;
1208 port->xmit_buf = (unsigned char *) tmp;
1211 save_flags(flags); cli();
1214 clear_bit(TTY_IO_ERROR, &port->tty->flags);
1217 if (port->count == 1) {
1219 if((++bp->count) == 1)
1220 bp->flags |= AURORA_BOARD_ACTIVE;
1224 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
1225 aurora_change_speed(bp, port);
1226 port->flags |= ASYNC_INITIALIZED;
1228 restore_flags(flags);
1230 printk("aurora_setup_port: end\n");
1235 /* Must be called with interrupts disabled */
1236 static void aurora_shutdown_port(struct Aurora_board *bp, struct Aurora_port *port)
1238 struct tty_struct *tty;
1242 printk("aurora_shutdown_port: start\n");
1244 if (!(port->flags & ASYNC_INITIALIZED))
1247 chip = AURORA_CD180(port_No(port));
1249 #ifdef AURORA_REPORT_OVERRUN
1250 printk("aurora%d: port %d: Total %ld overruns were detected.\n",
1251 board_No(bp), port_No(port), port->overrun);
1253 #ifdef AURORA_REPORT_FIFO
1257 printk("aurora%d: port %d: FIFO hits [ ",
1258 board_No(bp), port_No(port));
1259 for (i = 0; i < 10; i++) {
1260 printk("%ld ", port->hits[i]);
1265 if (port->xmit_buf) {
1266 free_page((unsigned long) port->xmit_buf);
1267 port->xmit_buf = NULL;
1270 if (!(tty = port->tty) || C_HUPCL(tty)) {
1272 port->MSVR &= ~(bp->DTR|bp->RTS);
1273 sbus_writeb(port->MSVR,
1274 &bp->r[chip]->r[CD180_MSVR]);
1278 sbus_writeb(port_No(port) & 7,
1279 &bp->r[chip]->r[CD180_CAR]);
1283 aurora_wait_CCR(bp->r[chip]);
1284 sbus_writeb(CCR_SOFTRESET, &bp->r[chip]->r[CD180_CCR]);
1286 /* Disable all interrupts from this port */
1288 sbus_writeb(port->SRER, &bp->r[chip]->r[CD180_SRER]);
1291 set_bit(TTY_IO_ERROR, &tty->flags);
1292 port->flags &= ~ASYNC_INITIALIZED;
1295 if (--bp->count < 0) {
1296 printk(KERN_DEBUG "aurora%d: aurora_shutdown_port: "
1297 "bad board count: %d\n",
1298 board_No(bp), bp->count);
1304 bp->flags &= ~AURORA_BOARD_ACTIVE;
1308 printk("aurora_shutdown_port: end\n");
1313 static int block_til_ready(struct tty_struct *tty, struct file * filp,
1314 struct Aurora_port *port)
1316 DECLARE_WAITQUEUE(wait, current);
1317 struct Aurora_board *bp = port_Board(port);
1324 printk("block_til_ready: start\n");
1326 chip = AURORA_CD180(port_No(port));
1328 /* If the device is in the middle of being closed, then block
1329 * until it's done, and then try again.
1331 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) {
1332 interruptible_sleep_on(&port->close_wait);
1333 if (port->flags & ASYNC_HUP_NOTIFY)
1336 return -ERESTARTSYS;
1339 /* If non-blocking mode is set, or the port is not enabled,
1340 * then make the check up front and then exit.
1342 if ((filp->f_flags & O_NONBLOCK) ||
1343 (tty->flags & (1 << TTY_IO_ERROR))) {
1344 if (port->flags & ASYNC_CALLOUT_ACTIVE)
1346 port->flags |= ASYNC_NORMAL_ACTIVE;
1350 if (port->flags & ASYNC_CALLOUT_ACTIVE) {
1351 if (port->normal_termios.c_cflag & CLOCAL)
1358 /* Block waiting for the carrier detect and the line to become
1359 * free (i.e., not in use by the callout). While we are in
1360 * this loop, info->count is dropped by one, so that
1361 * rs_close() knows when to free things. We restore it upon
1362 * exit, either normal or abnormal.
1365 add_wait_queue(&port->open_wait, &wait);
1367 if (!tty_hung_up_p(filp))
1370 port->blocked_open++;
1373 sbus_writeb(port_No(port) & 7,
1374 &bp->r[chip]->r[CD180_CAR]);
1376 CD = sbus_readb(&bp->r[chip]->r[CD180_MSVR]) & MSVR_CD;
1377 if (!(port->flags & ASYNC_CALLOUT_ACTIVE)) {
1380 /* auto drops DTR */
1381 sbus_writeb(port->MSVR,
1382 &bp->r[chip]->r[CD180_MSVR]);
1385 set_current_state(TASK_INTERRUPTIBLE);
1386 if (tty_hung_up_p(filp) ||
1387 !(port->flags & ASYNC_INITIALIZED)) {
1388 if (port->flags & ASYNC_HUP_NOTIFY)
1391 retval = -ERESTARTSYS;
1394 if (/*!(port->flags & ASYNC_CALLOUT_ACTIVE) &&*/
1395 !(port->flags & ASYNC_CLOSING) &&
1398 if (signal_pending(current)) {
1399 retval = -ERESTARTSYS;
1404 current->state = TASK_RUNNING;
1405 remove_wait_queue(&port->open_wait, &wait);
1406 if (!tty_hung_up_p(filp))
1408 port->blocked_open--;
1412 port->flags |= ASYNC_NORMAL_ACTIVE;
1414 printk("block_til_ready: end\n");
1419 static int aurora_open(struct tty_struct * tty, struct file * filp)
1423 struct Aurora_port * port;
1424 struct Aurora_board * bp;
1425 unsigned long flags;
1428 printk("aurora_open: start\n");
1431 board = AURORA_BOARD(MINOR(tty->device));
1432 if (board > AURORA_NBOARD ||
1433 !(aurora_board[board].flags & AURORA_BOARD_PRESENT)) {
1435 printk("aurora_open: error board %d present %d\n",
1436 board, aurora_board[board].flags & AURORA_BOARD_PRESENT);
1441 bp = &aurora_board[board];
1442 port = aurora_port + board * AURORA_NPORT * AURORA_NCD180 + AURORA_PORT(MINOR(tty->device));
1443 if (aurora_paranoia_check(port, tty->device, "aurora_open")) {
1445 printk("aurora_open: error paranoia check\n");
1451 tty->driver_data = port;
1454 if ((error = aurora_setup_port(bp, port))) {
1456 printk("aurora_open: error aurora_setup_port ret %d\n",error);
1461 if ((error = block_til_ready(tty, filp, port))) {
1463 printk("aurora_open: error block_til_ready ret %d\n",error);
1468 if ((port->count == 1) && (port->flags & ASYNC_SPLIT_TERMIOS)) {
1469 *tty->termios = port->normal_termios;
1470 save_flags(flags); cli();
1471 aurora_change_speed(bp, port);
1472 restore_flags(flags);
1475 port->session = current->session;
1476 port->pgrp = current->pgrp;
1478 printk("aurora_open: end\n");
1483 static void aurora_close(struct tty_struct * tty, struct file * filp)
1485 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
1486 struct Aurora_board *bp;
1487 unsigned long flags;
1488 unsigned long timeout;
1492 printk("aurora_close: start\n");
1495 if (!port || aurora_paranoia_check(port, tty->device, "close"))
1498 chip = AURORA_CD180(port_No(port));
1500 save_flags(flags); cli();
1501 if (tty_hung_up_p(filp)) {
1502 restore_flags(flags);
1506 bp = port_Board(port);
1507 if ((tty->count == 1) && (port->count != 1)) {
1508 printk(KERN_DEBUG "aurora%d: aurora_close: bad port count; "
1509 "tty->count is 1, port count is %d\n",
1510 board_No(bp), port->count);
1513 if (--port->count < 0) {
1514 printk(KERN_DEBUG "aurora%d: aurora_close: bad port "
1515 "count for tty%d: %d\n",
1516 board_No(bp), port_No(port), port->count);
1520 restore_flags(flags);
1523 port->flags |= ASYNC_CLOSING;
1525 /* Save the termios structure, since this port may have
1526 * separate termios for callout and dialin.
1528 if (port->flags & ASYNC_NORMAL_ACTIVE)
1529 port->normal_termios = *tty->termios;
1530 /* if (port->flags & ASYNC_CALLOUT_ACTIVE)
1531 port->callout_termios = *tty->termios;*/
1533 /* Now we wait for the transmit buffer to clear; and we notify
1534 * the line discipline to only process XON/XOFF characters.
1537 if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE){
1539 printk("aurora_close: waiting to flush...\n");
1541 tty_wait_until_sent(tty, port->closing_wait);
1544 /* At this point we stop accepting input. To do this, we
1545 * disable the receive line status interrupts, and tell the
1546 * interrupt driver to stop checking the data ready bit in the
1547 * line status register.
1549 port->SRER &= ~SRER_RXD;
1550 if (port->flags & ASYNC_INITIALIZED) {
1551 port->SRER &= ~SRER_TXRDY;
1552 port->SRER |= SRER_TXEMPTY;
1553 sbus_writeb(port_No(port) & 7,
1554 &bp->r[chip]->r[CD180_CAR]);
1556 sbus_writeb(port->SRER, &bp->r[chip]->r[CD180_SRER]);
1558 * Before we drop DTR, make sure the UART transmitter
1559 * has completely drained; this is especially
1560 * important if there is a transmit FIFO!
1562 timeout = jiffies+HZ;
1563 while(port->SRER & SRER_TXEMPTY) {
1564 current->state = TASK_INTERRUPTIBLE;
1565 schedule_timeout(port->timeout);
1566 if (time_after(jiffies, timeout))
1571 printk("aurora_close: shutdown_port\n");
1573 aurora_shutdown_port(bp, port);
1574 if (tty->driver.flush_buffer)
1575 tty->driver.flush_buffer(tty);
1576 if (tty->ldisc.flush_buffer)
1577 tty->ldisc.flush_buffer(tty);
1581 if (port->blocked_open) {
1582 if (port->close_delay) {
1583 current->state = TASK_INTERRUPTIBLE;
1584 schedule_timeout(port->close_delay);
1586 wake_up_interruptible(&port->open_wait);
1588 port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CALLOUT_ACTIVE|
1590 wake_up_interruptible(&port->close_wait);
1591 restore_flags(flags);
1593 printk("aurora_close: end\n");
1597 static int aurora_write(struct tty_struct * tty, int from_user,
1598 const unsigned char *buf, int count)
1600 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
1601 struct Aurora_board *bp;
1603 unsigned long flags;
1607 printk("aurora_write: start %d\n",count);
1609 if (aurora_paranoia_check(port, tty->device, "aurora_write"))
1612 chip = AURORA_CD180(port_No(port));
1614 bp = port_Board(port);
1616 if (!tty || !port->xmit_buf || !tmp_buf)
1623 c = MIN(count, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
1624 SERIAL_XMIT_SIZE - port->xmit_head));
1628 c -= copy_from_user(tmp_buf, buf, c);
1635 c = MIN(c, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
1636 SERIAL_XMIT_SIZE - port->xmit_head));
1637 memcpy(port->xmit_buf + port->xmit_head, tmp_buf, c);
1638 port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
1639 port->xmit_cnt += c;
1640 restore_flags(flags);
1650 c = MIN(count, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
1651 SERIAL_XMIT_SIZE - port->xmit_head));
1653 restore_flags(flags);
1656 memcpy(port->xmit_buf + port->xmit_head, buf, c);
1657 port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
1658 port->xmit_cnt += c;
1659 restore_flags(flags);
1668 if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped &&
1669 !(port->SRER & SRER_TXRDY)) {
1670 port->SRER |= SRER_TXRDY;
1671 sbus_writeb(port_No(port) & 7,
1672 &bp->r[chip]->r[CD180_CAR]);
1674 sbus_writeb(port->SRER, &bp->r[chip]->r[CD180_SRER]);
1676 restore_flags(flags);
1678 printk("aurora_write: end %d\n",total);
1683 static void aurora_put_char(struct tty_struct * tty, unsigned char ch)
1685 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
1686 unsigned long flags;
1689 printk("aurora_put_char: start %c\n",ch);
1691 if (aurora_paranoia_check(port, tty->device, "aurora_put_char"))
1694 if (!tty || !port->xmit_buf)
1697 save_flags(flags); cli();
1699 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) {
1700 restore_flags(flags);
1704 port->xmit_buf[port->xmit_head++] = ch;
1705 port->xmit_head &= SERIAL_XMIT_SIZE - 1;
1707 restore_flags(flags);
1709 printk("aurora_put_char: end\n");
1713 static void aurora_flush_chars(struct tty_struct * tty)
1715 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
1716 unsigned long flags;
1719 /*#ifdef AURORA_DEBUG
1720 printk("aurora_flush_chars: start\n");
1722 if (aurora_paranoia_check(port, tty->device, "aurora_flush_chars"))
1725 chip = AURORA_CD180(port_No(port));
1727 if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
1731 save_flags(flags); cli();
1732 port->SRER |= SRER_TXRDY;
1733 sbus_writeb(port_No(port) & 7,
1734 &port_Board(port)->r[chip]->r[CD180_CAR]);
1736 sbus_writeb(port->SRER,
1737 &port_Board(port)->r[chip]->r[CD180_SRER]);
1738 restore_flags(flags);
1739 /*#ifdef AURORA_DEBUG
1740 printk("aurora_flush_chars: end\n");
1744 static int aurora_write_room(struct tty_struct * tty)
1746 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
1750 printk("aurora_write_room: start\n");
1752 if (aurora_paranoia_check(port, tty->device, "aurora_write_room"))
1755 ret = SERIAL_XMIT_SIZE - port->xmit_cnt - 1;
1759 printk("aurora_write_room: end\n");
1764 static int aurora_chars_in_buffer(struct tty_struct *tty)
1766 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
1768 if (aurora_paranoia_check(port, tty->device, "aurora_chars_in_buffer"))
1771 return port->xmit_cnt;
1774 static void aurora_flush_buffer(struct tty_struct *tty)
1776 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
1777 unsigned long flags;
1780 printk("aurora_flush_buffer: start\n");
1782 if (aurora_paranoia_check(port, tty->device, "aurora_flush_buffer"))
1785 save_flags(flags); cli();
1786 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
1787 restore_flags(flags);
1789 wake_up_interruptible(&tty->write_wait);
1790 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
1791 tty->ldisc.write_wakeup)
1792 (tty->ldisc.write_wakeup)(tty);
1794 printk("aurora_flush_buffer: end\n");
1798 static int aurora_get_modem_info(struct Aurora_port * port, unsigned int *value)
1800 struct Aurora_board * bp;
1801 unsigned char status,chip;
1802 unsigned int result;
1803 unsigned long flags;
1806 printk("aurora_get_modem_info: start\n");
1808 chip = AURORA_CD180(port_No(port));
1810 bp = port_Board(port);
1812 save_flags(flags); cli();
1814 sbus_writeb(port_No(port) & 7, &bp->r[chip]->r[CD180_CAR]);
1817 status = sbus_readb(&bp->r[chip]->r[CD180_MSVR]);
1818 result = 0/*bp->r[chip]->r[AURORA_RI] & (1u << port_No(port)) ? 0 : TIOCM_RNG*/;
1820 restore_flags(flags);
1822 result |= ((status & bp->RTS) ? TIOCM_RTS : 0)
1823 | ((status & bp->DTR) ? TIOCM_DTR : 0)
1824 | ((status & MSVR_CD) ? TIOCM_CAR : 0)
1825 | ((status & MSVR_DSR) ? TIOCM_DSR : 0)
1826 | ((status & MSVR_CTS) ? TIOCM_CTS : 0);
1828 put_user(result,(unsigned long *) value);
1830 printk("aurora_get_modem_info: end\n");
1835 static int aurora_set_modem_info(struct Aurora_port * port, unsigned int cmd,
1836 unsigned int *value)
1839 unsigned long flags;
1840 struct Aurora_board *bp = port_Board(port);
1844 printk("aurora_set_modem_info: start\n");
1846 if (get_user(arg, value))
1848 chip = AURORA_CD180(port_No(port));
1851 if (arg & TIOCM_RTS)
1852 port->MSVR |= bp->RTS;
1853 if (arg & TIOCM_DTR)
1854 port->MSVR |= bp->DTR;
1857 if (arg & TIOCM_RTS)
1858 port->MSVR &= ~bp->RTS;
1859 if (arg & TIOCM_DTR)
1860 port->MSVR &= ~bp->DTR;
1863 port->MSVR = (arg & TIOCM_RTS) ? (port->MSVR | bp->RTS) :
1864 (port->MSVR & ~bp->RTS);
1865 port->MSVR = (arg & TIOCM_DTR) ? (port->MSVR | bp->RTS) :
1866 (port->MSVR & ~bp->RTS);
1872 save_flags(flags); cli();
1874 sbus_writeb(port_No(port) & 7, &bp->r[chip]->r[CD180_CAR]);
1877 sbus_writeb(port->MSVR, &bp->r[chip]->r[CD180_MSVR]);
1879 restore_flags(flags);
1881 printk("aurora_set_modem_info: end\n");
1886 static void aurora_send_break(struct Aurora_port * port, unsigned long length)
1888 struct Aurora_board *bp = port_Board(port);
1889 unsigned long flags;
1893 printk("aurora_send_break: start\n");
1895 chip = AURORA_CD180(port_No(port));
1897 save_flags(flags); cli();
1899 port->break_length = AURORA_TPS / HZ * length;
1900 port->COR2 |= COR2_ETC;
1901 port->SRER |= SRER_TXRDY;
1902 sbus_writeb(port_No(port) & 7, &bp->r[chip]->r[CD180_CAR]);
1905 sbus_writeb(port->COR2, &bp->r[chip]->r[CD180_COR2]);
1906 sbus_writeb(port->SRER, &bp->r[chip]->r[CD180_SRER]);
1907 aurora_wait_CCR(bp->r[chip]);
1909 sbus_writeb(CCR_CORCHG2, &bp->r[chip]->r[CD180_CCR]);
1910 aurora_wait_CCR(bp->r[chip]);
1912 restore_flags(flags);
1914 printk("aurora_send_break: end\n");
1918 static int aurora_set_serial_info(struct Aurora_port * port,
1919 struct serial_struct * newinfo)
1921 struct serial_struct tmp;
1922 struct Aurora_board *bp = port_Board(port);
1924 unsigned long flags;
1927 printk("aurora_set_serial_info: start\n");
1929 if (copy_from_user(&tmp, newinfo, sizeof(tmp)))
1932 if ((tmp.irq != bp->irq) ||
1933 (tmp.port != bp->base) ||
1934 (tmp.type != PORT_CIRRUS) ||
1935 (tmp.baud_base != (bp->oscfreq + CD180_TPC/2) / CD180_TPC) ||
1936 (tmp.custom_divisor != 0) ||
1937 (tmp.xmit_fifo_size != CD180_NFIFO) ||
1938 (tmp.flags & ~AURORA_LEGAL_FLAGS))
1942 change_speed = ((port->flags & ASYNC_SPD_MASK) !=
1943 (tmp.flags & ASYNC_SPD_MASK));
1945 if (!capable(CAP_SYS_ADMIN)) {
1946 if ((tmp.close_delay != port->close_delay) ||
1947 (tmp.closing_wait != port->closing_wait) ||
1948 ((tmp.flags & ~ASYNC_USR_MASK) !=
1949 (port->flags & ~ASYNC_USR_MASK)))
1951 port->flags = ((port->flags & ~ASYNC_USR_MASK) |
1952 (tmp.flags & ASYNC_USR_MASK));
1954 port->flags = ((port->flags & ~ASYNC_FLAGS) |
1955 (tmp.flags & ASYNC_FLAGS));
1956 port->close_delay = tmp.close_delay;
1957 port->closing_wait = tmp.closing_wait;
1960 save_flags(flags); cli();
1961 aurora_change_speed(bp, port);
1962 restore_flags(flags);
1965 printk("aurora_set_serial_info: end\n");
1970 extern int aurora_get_serial_info(struct Aurora_port * port,
1971 struct serial_struct * retinfo)
1973 struct serial_struct tmp;
1974 struct Aurora_board *bp = port_Board(port);
1978 printk("aurora_get_serial_info: start\n");
1980 error = verify_area(VERIFY_WRITE, (void *) retinfo, sizeof(tmp));
1984 memset(&tmp, 0, sizeof(tmp));
1985 tmp.type = PORT_CIRRUS;
1986 tmp.line = port - aurora_port;
1989 tmp.flags = port->flags;
1990 tmp.baud_base = (bp->oscfreq + CD180_TPC/2) / CD180_TPC;
1991 tmp.close_delay = port->close_delay * HZ/100;
1992 tmp.closing_wait = port->closing_wait * HZ/100;
1993 tmp.xmit_fifo_size = CD180_NFIFO;
1994 copy_to_user(retinfo, &tmp, sizeof(tmp));
1996 printk("aurora_get_serial_info: end\n");
2001 static int aurora_ioctl(struct tty_struct * tty, struct file * filp,
2002 unsigned int cmd, unsigned long arg)
2005 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
2009 printk("aurora_ioctl: start\n");
2011 if (aurora_paranoia_check(port, tty->device, "aurora_ioctl"))
2015 case TCSBRK: /* SVID version: non-zero arg --> no break */
2016 retval = tty_check_change(tty);
2019 tty_wait_until_sent(tty, 0);
2021 aurora_send_break(port, HZ/4); /* 1/4 second */
2023 case TCSBRKP: /* support for POSIX tcsendbreak() */
2024 retval = tty_check_change(tty);
2027 tty_wait_until_sent(tty, 0);
2028 aurora_send_break(port, arg ? arg*(HZ/10) : HZ/4);
2031 return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *)arg);
2033 if (get_user(arg,(unsigned long *)arg))
2035 tty->termios->c_cflag =
2036 ((tty->termios->c_cflag & ~CLOCAL) |
2037 (arg ? CLOCAL : 0));
2040 retval = verify_area(VERIFY_WRITE, (void *) arg,
2041 sizeof(unsigned int));
2044 return aurora_get_modem_info(port, (unsigned int *) arg);
2048 return aurora_set_modem_info(port, cmd, (unsigned int *) arg);
2050 return aurora_get_serial_info(port, (struct serial_struct *) arg);
2052 return aurora_set_serial_info(port, (struct serial_struct *) arg);
2054 return -ENOIOCTLCMD;
2057 printk("aurora_ioctl: end\n");
2062 static void aurora_throttle(struct tty_struct * tty)
2064 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
2065 struct Aurora_board *bp;
2066 unsigned long flags;
2070 printk("aurora_throttle: start\n");
2072 if (aurora_paranoia_check(port, tty->device, "aurora_throttle"))
2075 bp = port_Board(port);
2076 chip = AURORA_CD180(port_No(port));
2078 save_flags(flags); cli();
2079 port->MSVR &= ~bp->RTS;
2080 sbus_writeb(port_No(port) & 7, &bp->r[chip]->r[CD180_CAR]);
2083 aurora_wait_CCR(bp->r[chip]);
2084 sbus_writeb(CCR_SSCH2, &bp->r[chip]->r[CD180_CCR]);
2085 aurora_wait_CCR(bp->r[chip]);
2087 sbus_writeb(port->MSVR, &bp->r[chip]->r[CD180_MSVR]);
2088 restore_flags(flags);
2090 printk("aurora_throttle: end\n");
2094 static void aurora_unthrottle(struct tty_struct * tty)
2096 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
2097 struct Aurora_board *bp;
2098 unsigned long flags;
2102 printk("aurora_unthrottle: start\n");
2104 if (aurora_paranoia_check(port, tty->device, "aurora_unthrottle"))
2107 bp = port_Board(port);
2109 chip = AURORA_CD180(port_No(port));
2111 save_flags(flags); cli();
2112 port->MSVR |= bp->RTS;
2113 sbus_writeb(port_No(port) & 7,
2114 &bp->r[chip]->r[CD180_CAR]);
2117 aurora_wait_CCR(bp->r[chip]);
2118 sbus_writeb(CCR_SSCH1,
2119 &bp->r[chip]->r[CD180_CCR]);
2120 aurora_wait_CCR(bp->r[chip]);
2122 sbus_writeb(port->MSVR, &bp->r[chip]->r[CD180_MSVR]);
2123 restore_flags(flags);
2125 printk("aurora_unthrottle: end\n");
2129 static void aurora_stop(struct tty_struct * tty)
2131 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
2132 struct Aurora_board *bp;
2133 unsigned long flags;
2137 printk("aurora_stop: start\n");
2139 if (aurora_paranoia_check(port, tty->device, "aurora_stop"))
2142 bp = port_Board(port);
2144 chip = AURORA_CD180(port_No(port));
2146 save_flags(flags); cli();
2147 port->SRER &= ~SRER_TXRDY;
2148 sbus_writeb(port_No(port) & 7,
2149 &bp->r[chip]->r[CD180_CAR]);
2151 sbus_writeb(port->SRER,
2152 &bp->r[chip]->r[CD180_SRER]);
2153 restore_flags(flags);
2155 printk("aurora_stop: end\n");
2159 static void aurora_start(struct tty_struct * tty)
2161 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
2162 struct Aurora_board *bp;
2163 unsigned long flags;
2167 printk("aurora_start: start\n");
2169 if (aurora_paranoia_check(port, tty->device, "aurora_start"))
2172 bp = port_Board(port);
2174 chip = AURORA_CD180(port_No(port));
2176 save_flags(flags); cli();
2177 if (port->xmit_cnt && port->xmit_buf && !(port->SRER & SRER_TXRDY)) {
2178 port->SRER |= SRER_TXRDY;
2179 sbus_writeb(port_No(port) & 7,
2180 &bp->r[chip]->r[CD180_CAR]);
2182 sbus_writeb(port->SRER,
2183 &bp->r[chip]->r[CD180_SRER]);
2185 restore_flags(flags);
2187 printk("aurora_start: end\n");
2192 * This routine is called from the scheduler tqueue when the interrupt
2193 * routine has signalled that a hangup has occurred. The path of
2194 * hangup processing is:
2196 * serial interrupt routine -> (scheduler tqueue) ->
2197 * do_aurora_hangup() -> tty->hangup() -> aurora_hangup()
2200 static void do_aurora_hangup(void *private_)
2202 struct Aurora_port *port = (struct Aurora_port *) private_;
2203 struct tty_struct *tty;
2206 printk("do_aurora_hangup: start\n");
2210 tty_hangup(tty); /* FIXME: module removal race - AKPM */
2212 printk("do_aurora_hangup: end\n");
2218 static void aurora_hangup(struct tty_struct * tty)
2220 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
2221 struct Aurora_board *bp;
2224 printk("aurora_hangup: start\n");
2226 if (aurora_paranoia_check(port, tty->device, "aurora_hangup"))
2229 bp = port_Board(port);
2231 aurora_shutdown_port(bp, port);
2234 port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CALLOUT_ACTIVE);
2236 wake_up_interruptible(&port->open_wait);
2238 printk("aurora_hangup: end\n");
2242 static void aurora_set_termios(struct tty_struct * tty, struct termios * old_termios)
2244 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
2245 unsigned long flags;
2248 printk("aurora_set_termios: start\n");
2250 if (aurora_paranoia_check(port, tty->device, "aurora_set_termios"))
2253 if (tty->termios->c_cflag == old_termios->c_cflag &&
2254 tty->termios->c_iflag == old_termios->c_iflag)
2257 save_flags(flags); cli();
2258 aurora_change_speed(port_Board(port), port);
2259 restore_flags(flags);
2261 if ((old_termios->c_cflag & CRTSCTS) &&
2262 !(tty->termios->c_cflag & CRTSCTS)) {
2263 tty->hw_stopped = 0;
2267 printk("aurora_set_termios: end\n");
2271 static void do_aurora_bh(void)
2273 run_task_queue(&tq_aurora);
2276 static void do_softint(void *private_)
2278 struct Aurora_port *port = (struct Aurora_port *) private_;
2279 struct tty_struct *tty;
2282 printk("do_softint: start\n");
2288 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event)) {
2289 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
2290 tty->ldisc.write_wakeup)
2291 (tty->ldisc.write_wakeup)(tty);
2292 wake_up_interruptible(&tty->write_wait);
2295 printk("do_softint: end\n");
2299 static int aurora_init_drivers(void)
2305 printk("aurora_init_drivers: start\n");
2307 tmp_buf = (unsigned char *) get_free_page(GFP_KERNEL);
2308 if (tmp_buf == NULL) {
2309 printk(KERN_ERR "aurora: Couldn't get free page.\n");
2312 init_bh(AURORA_BH, do_aurora_bh);
2313 /* memset(IRQ_to_board, 0, sizeof(IRQ_to_board));*/
2314 memset(&aurora_driver, 0, sizeof(aurora_driver));
2315 aurora_driver.magic = TTY_DRIVER_MAGIC;
2316 aurora_driver.name = "ttyA";
2317 aurora_driver.major = AURORA_MAJOR;
2318 aurora_driver.num = AURORA_TNPORTS;
2319 aurora_driver.type = TTY_DRIVER_TYPE_SERIAL;
2320 aurora_driver.subtype = AURORA_TYPE_NORMAL;
2321 aurora_driver.init_termios = tty_std_termios;
2322 aurora_driver.init_termios.c_cflag =
2323 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
2324 aurora_driver.flags = TTY_DRIVER_REAL_RAW;
2325 aurora_driver.refcount = &aurora_refcount;
2326 aurora_driver.table = aurora_table;
2327 aurora_driver.termios = aurora_termios;
2328 aurora_driver.termios_locked = aurora_termios_locked;
2330 aurora_driver.open = aurora_open;
2331 aurora_driver.close = aurora_close;
2332 aurora_driver.write = aurora_write;
2333 aurora_driver.put_char = aurora_put_char;
2334 aurora_driver.flush_chars = aurora_flush_chars;
2335 aurora_driver.write_room = aurora_write_room;
2336 aurora_driver.chars_in_buffer = aurora_chars_in_buffer;
2337 aurora_driver.flush_buffer = aurora_flush_buffer;
2338 aurora_driver.ioctl = aurora_ioctl;
2339 aurora_driver.throttle = aurora_throttle;
2340 aurora_driver.unthrottle = aurora_unthrottle;
2341 aurora_driver.set_termios = aurora_set_termios;
2342 aurora_driver.stop = aurora_stop;
2343 aurora_driver.start = aurora_start;
2344 aurora_driver.hangup = aurora_hangup;
2346 error = tty_register_driver(&aurora_driver);
2348 free_page((unsigned long) tmp_buf);
2349 printk(KERN_ERR "aurora: Couldn't register aurora driver, error = %d\n",
2354 memset(aurora_port, 0, sizeof(aurora_port));
2355 for (i = 0; i < AURORA_TNPORTS; i++) {
2356 aurora_port[i].normal_termios = aurora_driver.init_termios;
2357 aurora_port[i].magic = AURORA_MAGIC;
2358 aurora_port[i].tqueue.routine = do_softint;
2359 aurora_port[i].tqueue.data = &aurora_port[i];
2360 aurora_port[i].tqueue_hangup.routine = do_aurora_hangup;
2361 aurora_port[i].tqueue_hangup.data = &aurora_port[i];
2362 aurora_port[i].close_delay = 50 * HZ/100;
2363 aurora_port[i].closing_wait = 3000 * HZ/100;
2364 init_waitqueue_head(&aurora_port[i].open_wait);
2365 init_waitqueue_head(&aurora_port[i].close_wait);
2368 printk("aurora_init_drivers: end\n");
2373 static void aurora_release_drivers(void)
2376 printk("aurora_release_drivers: start\n");
2378 free_page((unsigned long)tmp_buf);
2379 tty_unregister_driver(&aurora_driver);
2381 printk("aurora_release_drivers: end\n");
2386 * Called at boot time.
2388 * You can specify IO base for up to RC_NBOARD cards,
2389 * using line "riscom8=0xiobase1,0xiobase2,.." at LILO prompt.
2390 * Note that there will be no probing at default
2391 * addresses in this case.
2394 void __init aurora_setup(char *str, int *ints)
2398 for(i=0;(i<ints[0])&&(i<4);i++) {
2399 if (ints[i+1]) irqs[i]=ints[i+1];
2403 static int __init aurora_real_init(void)
2408 printk(KERN_INFO "aurora: Driver starting.\n");
2409 if(aurora_init_drivers())
2411 found = aurora_probe();
2413 aurora_release_drivers();
2414 printk(KERN_INFO "aurora: No Aurora Multiport boards detected.\n");
2417 printk(KERN_INFO "aurora: %d boards found.\n", found);
2419 for (i = 0; i < found; i++) {
2420 int ret = aurora_setup_board(&aurora_board[i]);
2424 printk(KERN_ERR "aurora_init: error aurora_setup_board ret %d\n",
2437 MODULE_PARM(irq , "i");
2438 MODULE_PARM(irq1, "i");
2439 MODULE_PARM(irq2, "i");
2440 MODULE_PARM(irq3, "i");
2442 static int __init aurora_init(void)
2444 if (irq ) irqs[0]=irq ;
2445 if (irq1) irqs[1]=irq1;
2446 if (irq2) irqs[2]=irq2;
2447 if (irq3) irqs[3]=irq3;
2448 return aurora_real_init();
2451 static void __exit aurora_cleanup(void)
2456 printk("cleanup_module: aurora_release_drivers\n");
2459 aurora_release_drivers();
2460 for (i = 0; i < AURORA_NBOARD; i++)
2461 if (aurora_board[i].flags & AURORA_BOARD_PRESENT) {
2462 aurora_shutdown_board(&aurora_board[i]);
2463 aurora_release_io_range(&aurora_board[i]);
2467 module_init(aurora_init);
2468 module_exit(aurora_cleanup);
2469 MODULE_LICENSE("GPL");