1 /* $Id: aurora.c,v 1.18.2.1 2002/02/04 22:37:43 davem 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 tty_ldisc_flush(tty);
1580 if (port->blocked_open) {
1581 if (port->close_delay) {
1582 current->state = TASK_INTERRUPTIBLE;
1583 schedule_timeout(port->close_delay);
1585 wake_up_interruptible(&port->open_wait);
1587 port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CALLOUT_ACTIVE|
1589 wake_up_interruptible(&port->close_wait);
1590 restore_flags(flags);
1592 printk("aurora_close: end\n");
1596 static int aurora_write(struct tty_struct * tty, int from_user,
1597 const unsigned char *buf, int count)
1599 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
1600 struct Aurora_board *bp;
1602 unsigned long flags;
1606 printk("aurora_write: start %d\n",count);
1608 if (aurora_paranoia_check(port, tty->device, "aurora_write"))
1611 chip = AURORA_CD180(port_No(port));
1613 bp = port_Board(port);
1615 if (!tty || !port->xmit_buf || !tmp_buf)
1622 c = MIN(count, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
1623 SERIAL_XMIT_SIZE - port->xmit_head));
1627 c -= copy_from_user(tmp_buf, buf, c);
1634 c = MIN(c, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
1635 SERIAL_XMIT_SIZE - port->xmit_head));
1636 memcpy(port->xmit_buf + port->xmit_head, tmp_buf, c);
1637 port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
1638 port->xmit_cnt += c;
1639 restore_flags(flags);
1649 c = MIN(count, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
1650 SERIAL_XMIT_SIZE - port->xmit_head));
1652 restore_flags(flags);
1655 memcpy(port->xmit_buf + port->xmit_head, buf, c);
1656 port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
1657 port->xmit_cnt += c;
1658 restore_flags(flags);
1667 if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped &&
1668 !(port->SRER & SRER_TXRDY)) {
1669 port->SRER |= SRER_TXRDY;
1670 sbus_writeb(port_No(port) & 7,
1671 &bp->r[chip]->r[CD180_CAR]);
1673 sbus_writeb(port->SRER, &bp->r[chip]->r[CD180_SRER]);
1675 restore_flags(flags);
1677 printk("aurora_write: end %d\n",total);
1682 static void aurora_put_char(struct tty_struct * tty, unsigned char ch)
1684 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
1685 unsigned long flags;
1688 printk("aurora_put_char: start %c\n",ch);
1690 if (aurora_paranoia_check(port, tty->device, "aurora_put_char"))
1693 if (!tty || !port->xmit_buf)
1696 save_flags(flags); cli();
1698 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) {
1699 restore_flags(flags);
1703 port->xmit_buf[port->xmit_head++] = ch;
1704 port->xmit_head &= SERIAL_XMIT_SIZE - 1;
1706 restore_flags(flags);
1708 printk("aurora_put_char: end\n");
1712 static void aurora_flush_chars(struct tty_struct * tty)
1714 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
1715 unsigned long flags;
1718 /*#ifdef AURORA_DEBUG
1719 printk("aurora_flush_chars: start\n");
1721 if (aurora_paranoia_check(port, tty->device, "aurora_flush_chars"))
1724 chip = AURORA_CD180(port_No(port));
1726 if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
1730 save_flags(flags); cli();
1731 port->SRER |= SRER_TXRDY;
1732 sbus_writeb(port_No(port) & 7,
1733 &port_Board(port)->r[chip]->r[CD180_CAR]);
1735 sbus_writeb(port->SRER,
1736 &port_Board(port)->r[chip]->r[CD180_SRER]);
1737 restore_flags(flags);
1738 /*#ifdef AURORA_DEBUG
1739 printk("aurora_flush_chars: end\n");
1743 static int aurora_write_room(struct tty_struct * tty)
1745 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
1749 printk("aurora_write_room: start\n");
1751 if (aurora_paranoia_check(port, tty->device, "aurora_write_room"))
1754 ret = SERIAL_XMIT_SIZE - port->xmit_cnt - 1;
1758 printk("aurora_write_room: end\n");
1763 static int aurora_chars_in_buffer(struct tty_struct *tty)
1765 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
1767 if (aurora_paranoia_check(port, tty->device, "aurora_chars_in_buffer"))
1770 return port->xmit_cnt;
1773 static void aurora_flush_buffer(struct tty_struct *tty)
1775 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
1776 unsigned long flags;
1779 printk("aurora_flush_buffer: start\n");
1781 if (aurora_paranoia_check(port, tty->device, "aurora_flush_buffer"))
1784 save_flags(flags); cli();
1785 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
1786 restore_flags(flags);
1790 printk("aurora_flush_buffer: end\n");
1794 static int aurora_get_modem_info(struct Aurora_port * port, unsigned int *value)
1796 struct Aurora_board * bp;
1797 unsigned char status,chip;
1798 unsigned int result;
1799 unsigned long flags;
1802 printk("aurora_get_modem_info: start\n");
1804 chip = AURORA_CD180(port_No(port));
1806 bp = port_Board(port);
1808 save_flags(flags); cli();
1810 sbus_writeb(port_No(port) & 7, &bp->r[chip]->r[CD180_CAR]);
1813 status = sbus_readb(&bp->r[chip]->r[CD180_MSVR]);
1814 result = 0/*bp->r[chip]->r[AURORA_RI] & (1u << port_No(port)) ? 0 : TIOCM_RNG*/;
1816 restore_flags(flags);
1818 result |= ((status & bp->RTS) ? TIOCM_RTS : 0)
1819 | ((status & bp->DTR) ? TIOCM_DTR : 0)
1820 | ((status & MSVR_CD) ? TIOCM_CAR : 0)
1821 | ((status & MSVR_DSR) ? TIOCM_DSR : 0)
1822 | ((status & MSVR_CTS) ? TIOCM_CTS : 0);
1824 put_user(result,(unsigned long *) value);
1826 printk("aurora_get_modem_info: end\n");
1831 static int aurora_set_modem_info(struct Aurora_port * port, unsigned int cmd,
1832 unsigned int *value)
1835 unsigned long flags;
1836 struct Aurora_board *bp = port_Board(port);
1840 printk("aurora_set_modem_info: start\n");
1842 if (get_user(arg, value))
1844 chip = AURORA_CD180(port_No(port));
1847 if (arg & TIOCM_RTS)
1848 port->MSVR |= bp->RTS;
1849 if (arg & TIOCM_DTR)
1850 port->MSVR |= bp->DTR;
1853 if (arg & TIOCM_RTS)
1854 port->MSVR &= ~bp->RTS;
1855 if (arg & TIOCM_DTR)
1856 port->MSVR &= ~bp->DTR;
1859 port->MSVR = (arg & TIOCM_RTS) ? (port->MSVR | bp->RTS) :
1860 (port->MSVR & ~bp->RTS);
1861 port->MSVR = (arg & TIOCM_DTR) ? (port->MSVR | bp->RTS) :
1862 (port->MSVR & ~bp->RTS);
1868 save_flags(flags); cli();
1870 sbus_writeb(port_No(port) & 7, &bp->r[chip]->r[CD180_CAR]);
1873 sbus_writeb(port->MSVR, &bp->r[chip]->r[CD180_MSVR]);
1875 restore_flags(flags);
1877 printk("aurora_set_modem_info: end\n");
1882 static void aurora_send_break(struct Aurora_port * port, unsigned long length)
1884 struct Aurora_board *bp = port_Board(port);
1885 unsigned long flags;
1889 printk("aurora_send_break: start\n");
1891 chip = AURORA_CD180(port_No(port));
1893 save_flags(flags); cli();
1895 port->break_length = AURORA_TPS / HZ * length;
1896 port->COR2 |= COR2_ETC;
1897 port->SRER |= SRER_TXRDY;
1898 sbus_writeb(port_No(port) & 7, &bp->r[chip]->r[CD180_CAR]);
1901 sbus_writeb(port->COR2, &bp->r[chip]->r[CD180_COR2]);
1902 sbus_writeb(port->SRER, &bp->r[chip]->r[CD180_SRER]);
1903 aurora_wait_CCR(bp->r[chip]);
1905 sbus_writeb(CCR_CORCHG2, &bp->r[chip]->r[CD180_CCR]);
1906 aurora_wait_CCR(bp->r[chip]);
1908 restore_flags(flags);
1910 printk("aurora_send_break: end\n");
1914 static int aurora_set_serial_info(struct Aurora_port * port,
1915 struct serial_struct * newinfo)
1917 struct serial_struct tmp;
1918 struct Aurora_board *bp = port_Board(port);
1920 unsigned long flags;
1923 printk("aurora_set_serial_info: start\n");
1925 if (copy_from_user(&tmp, newinfo, sizeof(tmp)))
1928 if ((tmp.irq != bp->irq) ||
1929 (tmp.port != bp->base) ||
1930 (tmp.type != PORT_CIRRUS) ||
1931 (tmp.baud_base != (bp->oscfreq + CD180_TPC/2) / CD180_TPC) ||
1932 (tmp.custom_divisor != 0) ||
1933 (tmp.xmit_fifo_size != CD180_NFIFO) ||
1934 (tmp.flags & ~AURORA_LEGAL_FLAGS))
1938 change_speed = ((port->flags & ASYNC_SPD_MASK) !=
1939 (tmp.flags & ASYNC_SPD_MASK));
1941 if (!capable(CAP_SYS_ADMIN)) {
1942 if ((tmp.close_delay != port->close_delay) ||
1943 (tmp.closing_wait != port->closing_wait) ||
1944 ((tmp.flags & ~ASYNC_USR_MASK) !=
1945 (port->flags & ~ASYNC_USR_MASK)))
1947 port->flags = ((port->flags & ~ASYNC_USR_MASK) |
1948 (tmp.flags & ASYNC_USR_MASK));
1950 port->flags = ((port->flags & ~ASYNC_FLAGS) |
1951 (tmp.flags & ASYNC_FLAGS));
1952 port->close_delay = tmp.close_delay;
1953 port->closing_wait = tmp.closing_wait;
1956 save_flags(flags); cli();
1957 aurora_change_speed(bp, port);
1958 restore_flags(flags);
1961 printk("aurora_set_serial_info: end\n");
1966 extern int aurora_get_serial_info(struct Aurora_port * port,
1967 struct serial_struct * retinfo)
1969 struct serial_struct tmp;
1970 struct Aurora_board *bp = port_Board(port);
1974 printk("aurora_get_serial_info: start\n");
1976 error = verify_area(VERIFY_WRITE, (void *) retinfo, sizeof(tmp));
1980 memset(&tmp, 0, sizeof(tmp));
1981 tmp.type = PORT_CIRRUS;
1982 tmp.line = port - aurora_port;
1985 tmp.flags = port->flags;
1986 tmp.baud_base = (bp->oscfreq + CD180_TPC/2) / CD180_TPC;
1987 tmp.close_delay = port->close_delay * HZ/100;
1988 tmp.closing_wait = port->closing_wait * HZ/100;
1989 tmp.xmit_fifo_size = CD180_NFIFO;
1990 copy_to_user(retinfo, &tmp, sizeof(tmp));
1992 printk("aurora_get_serial_info: end\n");
1997 static int aurora_ioctl(struct tty_struct * tty, struct file * filp,
1998 unsigned int cmd, unsigned long arg)
2001 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
2005 printk("aurora_ioctl: start\n");
2007 if (aurora_paranoia_check(port, tty->device, "aurora_ioctl"))
2011 case TCSBRK: /* SVID version: non-zero arg --> no break */
2012 retval = tty_check_change(tty);
2015 tty_wait_until_sent(tty, 0);
2017 aurora_send_break(port, HZ/4); /* 1/4 second */
2019 case TCSBRKP: /* support for POSIX tcsendbreak() */
2020 retval = tty_check_change(tty);
2023 tty_wait_until_sent(tty, 0);
2024 aurora_send_break(port, arg ? arg*(HZ/10) : HZ/4);
2027 return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *)arg);
2029 if (get_user(arg,(unsigned long *)arg))
2031 tty->termios->c_cflag =
2032 ((tty->termios->c_cflag & ~CLOCAL) |
2033 (arg ? CLOCAL : 0));
2036 retval = verify_area(VERIFY_WRITE, (void *) arg,
2037 sizeof(unsigned int));
2040 return aurora_get_modem_info(port, (unsigned int *) arg);
2044 return aurora_set_modem_info(port, cmd, (unsigned int *) arg);
2046 return aurora_get_serial_info(port, (struct serial_struct *) arg);
2048 return aurora_set_serial_info(port, (struct serial_struct *) arg);
2050 return -ENOIOCTLCMD;
2053 printk("aurora_ioctl: end\n");
2058 static void aurora_throttle(struct tty_struct * tty)
2060 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
2061 struct Aurora_board *bp;
2062 unsigned long flags;
2066 printk("aurora_throttle: start\n");
2068 if (aurora_paranoia_check(port, tty->device, "aurora_throttle"))
2071 bp = port_Board(port);
2072 chip = AURORA_CD180(port_No(port));
2074 save_flags(flags); cli();
2075 port->MSVR &= ~bp->RTS;
2076 sbus_writeb(port_No(port) & 7, &bp->r[chip]->r[CD180_CAR]);
2079 aurora_wait_CCR(bp->r[chip]);
2080 sbus_writeb(CCR_SSCH2, &bp->r[chip]->r[CD180_CCR]);
2081 aurora_wait_CCR(bp->r[chip]);
2083 sbus_writeb(port->MSVR, &bp->r[chip]->r[CD180_MSVR]);
2084 restore_flags(flags);
2086 printk("aurora_throttle: end\n");
2090 static void aurora_unthrottle(struct tty_struct * tty)
2092 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
2093 struct Aurora_board *bp;
2094 unsigned long flags;
2098 printk("aurora_unthrottle: start\n");
2100 if (aurora_paranoia_check(port, tty->device, "aurora_unthrottle"))
2103 bp = port_Board(port);
2105 chip = AURORA_CD180(port_No(port));
2107 save_flags(flags); cli();
2108 port->MSVR |= bp->RTS;
2109 sbus_writeb(port_No(port) & 7,
2110 &bp->r[chip]->r[CD180_CAR]);
2113 aurora_wait_CCR(bp->r[chip]);
2114 sbus_writeb(CCR_SSCH1,
2115 &bp->r[chip]->r[CD180_CCR]);
2116 aurora_wait_CCR(bp->r[chip]);
2118 sbus_writeb(port->MSVR, &bp->r[chip]->r[CD180_MSVR]);
2119 restore_flags(flags);
2121 printk("aurora_unthrottle: end\n");
2125 static void aurora_stop(struct tty_struct * tty)
2127 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
2128 struct Aurora_board *bp;
2129 unsigned long flags;
2133 printk("aurora_stop: start\n");
2135 if (aurora_paranoia_check(port, tty->device, "aurora_stop"))
2138 bp = port_Board(port);
2140 chip = AURORA_CD180(port_No(port));
2142 save_flags(flags); cli();
2143 port->SRER &= ~SRER_TXRDY;
2144 sbus_writeb(port_No(port) & 7,
2145 &bp->r[chip]->r[CD180_CAR]);
2147 sbus_writeb(port->SRER,
2148 &bp->r[chip]->r[CD180_SRER]);
2149 restore_flags(flags);
2151 printk("aurora_stop: end\n");
2155 static void aurora_start(struct tty_struct * tty)
2157 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
2158 struct Aurora_board *bp;
2159 unsigned long flags;
2163 printk("aurora_start: start\n");
2165 if (aurora_paranoia_check(port, tty->device, "aurora_start"))
2168 bp = port_Board(port);
2170 chip = AURORA_CD180(port_No(port));
2172 save_flags(flags); cli();
2173 if (port->xmit_cnt && port->xmit_buf && !(port->SRER & SRER_TXRDY)) {
2174 port->SRER |= SRER_TXRDY;
2175 sbus_writeb(port_No(port) & 7,
2176 &bp->r[chip]->r[CD180_CAR]);
2178 sbus_writeb(port->SRER,
2179 &bp->r[chip]->r[CD180_SRER]);
2181 restore_flags(flags);
2183 printk("aurora_start: end\n");
2188 * This routine is called from the scheduler tqueue when the interrupt
2189 * routine has signalled that a hangup has occurred. The path of
2190 * hangup processing is:
2192 * serial interrupt routine -> (scheduler tqueue) ->
2193 * do_aurora_hangup() -> tty->hangup() -> aurora_hangup()
2196 static void do_aurora_hangup(void *private_)
2198 struct Aurora_port *port = (struct Aurora_port *) private_;
2199 struct tty_struct *tty;
2202 printk("do_aurora_hangup: start\n");
2206 tty_hangup(tty); /* FIXME: module removal race - AKPM */
2208 printk("do_aurora_hangup: end\n");
2214 static void aurora_hangup(struct tty_struct * tty)
2216 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
2217 struct Aurora_board *bp;
2220 printk("aurora_hangup: start\n");
2222 if (aurora_paranoia_check(port, tty->device, "aurora_hangup"))
2225 bp = port_Board(port);
2227 aurora_shutdown_port(bp, port);
2230 port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CALLOUT_ACTIVE);
2232 wake_up_interruptible(&port->open_wait);
2234 printk("aurora_hangup: end\n");
2238 static void aurora_set_termios(struct tty_struct * tty, struct termios * old_termios)
2240 struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
2241 unsigned long flags;
2244 printk("aurora_set_termios: start\n");
2246 if (aurora_paranoia_check(port, tty->device, "aurora_set_termios"))
2249 if (tty->termios->c_cflag == old_termios->c_cflag &&
2250 tty->termios->c_iflag == old_termios->c_iflag)
2253 save_flags(flags); cli();
2254 aurora_change_speed(port_Board(port), port);
2255 restore_flags(flags);
2257 if ((old_termios->c_cflag & CRTSCTS) &&
2258 !(tty->termios->c_cflag & CRTSCTS)) {
2259 tty->hw_stopped = 0;
2263 printk("aurora_set_termios: end\n");
2267 static void do_aurora_bh(void)
2269 run_task_queue(&tq_aurora);
2272 static void do_softint(void *private_)
2274 struct Aurora_port *port = (struct Aurora_port *) private_;
2275 struct tty_struct *tty;
2278 printk("do_softint: start\n");
2284 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event)) {
2288 printk("do_softint: end\n");
2292 static int aurora_init_drivers(void)
2298 printk("aurora_init_drivers: start\n");
2300 tmp_buf = (unsigned char *) get_free_page(GFP_KERNEL);
2301 if (tmp_buf == NULL) {
2302 printk(KERN_ERR "aurora: Couldn't get free page.\n");
2305 init_bh(AURORA_BH, do_aurora_bh);
2306 /* memset(IRQ_to_board, 0, sizeof(IRQ_to_board));*/
2307 memset(&aurora_driver, 0, sizeof(aurora_driver));
2308 aurora_driver.magic = TTY_DRIVER_MAGIC;
2309 aurora_driver.name = "ttyA";
2310 aurora_driver.major = AURORA_MAJOR;
2311 aurora_driver.num = AURORA_TNPORTS;
2312 aurora_driver.type = TTY_DRIVER_TYPE_SERIAL;
2313 aurora_driver.subtype = AURORA_TYPE_NORMAL;
2314 aurora_driver.init_termios = tty_std_termios;
2315 aurora_driver.init_termios.c_cflag =
2316 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
2317 aurora_driver.flags = TTY_DRIVER_REAL_RAW;
2318 aurora_driver.refcount = &aurora_refcount;
2319 aurora_driver.table = aurora_table;
2320 aurora_driver.termios = aurora_termios;
2321 aurora_driver.termios_locked = aurora_termios_locked;
2323 aurora_driver.open = aurora_open;
2324 aurora_driver.close = aurora_close;
2325 aurora_driver.write = aurora_write;
2326 aurora_driver.put_char = aurora_put_char;
2327 aurora_driver.flush_chars = aurora_flush_chars;
2328 aurora_driver.write_room = aurora_write_room;
2329 aurora_driver.chars_in_buffer = aurora_chars_in_buffer;
2330 aurora_driver.flush_buffer = aurora_flush_buffer;
2331 aurora_driver.ioctl = aurora_ioctl;
2332 aurora_driver.throttle = aurora_throttle;
2333 aurora_driver.unthrottle = aurora_unthrottle;
2334 aurora_driver.set_termios = aurora_set_termios;
2335 aurora_driver.stop = aurora_stop;
2336 aurora_driver.start = aurora_start;
2337 aurora_driver.hangup = aurora_hangup;
2339 error = tty_register_driver(&aurora_driver);
2341 free_page((unsigned long) tmp_buf);
2342 printk(KERN_ERR "aurora: Couldn't register aurora driver, error = %d\n",
2347 memset(aurora_port, 0, sizeof(aurora_port));
2348 for (i = 0; i < AURORA_TNPORTS; i++) {
2349 aurora_port[i].normal_termios = aurora_driver.init_termios;
2350 aurora_port[i].magic = AURORA_MAGIC;
2351 aurora_port[i].tqueue.routine = do_softint;
2352 aurora_port[i].tqueue.data = &aurora_port[i];
2353 aurora_port[i].tqueue_hangup.routine = do_aurora_hangup;
2354 aurora_port[i].tqueue_hangup.data = &aurora_port[i];
2355 aurora_port[i].close_delay = 50 * HZ/100;
2356 aurora_port[i].closing_wait = 3000 * HZ/100;
2357 init_waitqueue_head(&aurora_port[i].open_wait);
2358 init_waitqueue_head(&aurora_port[i].close_wait);
2361 printk("aurora_init_drivers: end\n");
2366 static void aurora_release_drivers(void)
2369 printk("aurora_release_drivers: start\n");
2371 free_page((unsigned long)tmp_buf);
2372 tty_unregister_driver(&aurora_driver);
2374 printk("aurora_release_drivers: end\n");
2379 * Called at boot time.
2381 * You can specify IO base for up to RC_NBOARD cards,
2382 * using line "riscom8=0xiobase1,0xiobase2,.." at LILO prompt.
2383 * Note that there will be no probing at default
2384 * addresses in this case.
2387 void __init aurora_setup(char *str, int *ints)
2391 for(i=0;(i<ints[0])&&(i<4);i++) {
2392 if (ints[i+1]) irqs[i]=ints[i+1];
2396 static int __init aurora_real_init(void)
2401 printk(KERN_INFO "aurora: Driver starting.\n");
2402 if(aurora_init_drivers())
2404 found = aurora_probe();
2406 aurora_release_drivers();
2407 printk(KERN_INFO "aurora: No Aurora Multiport boards detected.\n");
2410 printk(KERN_INFO "aurora: %d boards found.\n", found);
2412 for (i = 0; i < found; i++) {
2413 int ret = aurora_setup_board(&aurora_board[i]);
2417 printk(KERN_ERR "aurora_init: error aurora_setup_board ret %d\n",
2430 MODULE_PARM(irq , "i");
2431 MODULE_PARM(irq1, "i");
2432 MODULE_PARM(irq2, "i");
2433 MODULE_PARM(irq3, "i");
2435 static int __init aurora_init(void)
2437 if (irq ) irqs[0]=irq ;
2438 if (irq1) irqs[1]=irq1;
2439 if (irq2) irqs[2]=irq2;
2440 if (irq3) irqs[3]=irq3;
2441 return aurora_real_init();
2444 static void __exit aurora_cleanup(void)
2449 printk("cleanup_module: aurora_release_drivers\n");
2452 aurora_release_drivers();
2453 for (i = 0; i < AURORA_NBOARD; i++)
2454 if (aurora_board[i].flags & AURORA_BOARD_PRESENT) {
2455 aurora_shutdown_board(&aurora_board[i]);
2456 aurora_release_io_range(&aurora_board[i]);
2460 module_init(aurora_init);
2461 module_exit(aurora_cleanup);
2462 MODULE_LICENSE("GPL");