1 /* $Id: aurora.c,v 1.19 2002/01/08 16:00:16 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/delay.h>
63 #include <linux/bitops.h>
67 #include <asm/oplib.h>
68 #include <asm/system.h>
69 #include <asm/kdebug.h>
71 #include <asm/uaccess.h>
76 unsigned char irqs
[4] = {
80 #ifdef AURORA_INT_DEBUG
85 #define MIN(a,b) ((a) < (b) ? (a) : (b))
88 static struct tty_driver
*aurora_driver
;
89 static struct Aurora_board aurora_board
[AURORA_NBOARD
] = {
93 static struct Aurora_port aurora_port
[AURORA_TNPORTS
] = {
97 /* no longer used. static struct Aurora_board * IRQ_to_board[16] = { NULL, } ;*/
98 static unsigned char * tmp_buf
= NULL
;
99 static DECLARE_MUTEX(tmp_buf_sem
);
101 DECLARE_TASK_QUEUE(tq_aurora
);
103 static inline int aurora_paranoia_check(struct Aurora_port
const * port
,
104 char *name
, const char *routine
)
106 #ifdef AURORA_PARANOIA_CHECK
107 static const char *badmagic
=
108 KERN_DEBUG
"aurora: Warning: bad aurora port magic number for device %s in %s\n";
109 static const char *badinfo
=
110 KERN_DEBUG
"aurora: Warning: null aurora port for device %s in %s\n";
113 printk(badinfo
, name
, routine
);
116 if (port
->magic
!= AURORA_MAGIC
) {
117 printk(badmagic
, name
, routine
);
126 * Service functions for aurora driver.
130 /* Get board number from pointer */
131 extern inline int board_No (struct Aurora_board
const * bp
)
133 return bp
- aurora_board
;
136 /* Get port number from pointer */
137 extern inline int port_No (struct Aurora_port
const * port
)
139 return AURORA_PORT(port
- aurora_port
);
142 /* Get pointer to board from pointer to port */
143 extern inline struct Aurora_board
* port_Board(struct Aurora_port
const * port
)
145 return &aurora_board
[AURORA_BOARD(port
- aurora_port
)];
148 /* Wait for Channel Command Register ready */
149 extern inline void aurora_wait_CCR(struct aurora_reg128
* r
)
154 printk("aurora_wait_CCR\n");
156 /* FIXME: need something more descriptive than 100000 :) */
157 for (delay
= 100000; delay
; delay
--)
158 if (!sbus_readb(&r
->r
[CD180_CCR
]))
160 printk(KERN_DEBUG
"aurora: Timeout waiting for CCR.\n");
164 * aurora probe functions.
167 /* Must be called with enabled interrupts */
168 extern inline void aurora_long_delay(unsigned long delay
)
173 printk("aurora_long_delay: start\n");
175 for (i
= jiffies
+ delay
; time_before(jiffies
, i
); ) ;
177 printk("aurora_long_delay: end\n");
181 /* Reset and setup CD180 chip */
182 static int aurora_init_CD180(struct Aurora_board
* bp
, int chip
)
188 printk("aurora_init_CD180: start %d:%d\n",
191 save_flags(flags
); cli();
192 sbus_writeb(0, &bp
->r
[chip
]->r
[CD180_CAR
]);
193 sbus_writeb(0, &bp
->r
[chip
]->r
[CD180_GSVR
]);
195 /* Wait for CCR ready */
196 aurora_wait_CCR(bp
->r
[chip
]);
198 /* Reset CD180 chip */
199 sbus_writeb(CCR_HARDRESET
, &bp
->r
[chip
]->r
[CD180_CCR
]);
204 (sbus_readb(&bp
->r
[chip
]->r
[CD180_GSVR
])!=0xff))udelay(100);
206 printk(KERN_ERR
"aurora%d: Chip %d failed init.\n",
208 restore_flags(flags
);
212 sbus_writeb((board_No(bp
)<<5)|((chip
+1)<<3),
213 &bp
->r
[chip
]->r
[CD180_GSVR
]); /* Set ID for this chip */
214 sbus_writeb(0x80|bp
->ACK_MINT
,
215 &bp
->r
[chip
]->r
[CD180_MSMR
]); /* Prio for modem intr */
216 sbus_writeb(0x80|bp
->ACK_TINT
,
217 &bp
->r
[chip
]->r
[CD180_TSMR
]); /* Prio for transmitter intr */
218 sbus_writeb(0x80|bp
->ACK_RINT
,
219 &bp
->r
[chip
]->r
[CD180_RSMR
]); /* Prio for receiver intr */
220 /* Setting up prescaler. We need 4 tick per 1 ms */
221 sbus_writeb((bp
->oscfreq
/(1000000/AURORA_TPS
)) >> 8,
222 &bp
->r
[chip
]->r
[CD180_PPRH
]);
223 sbus_writeb((bp
->oscfreq
/(1000000/AURORA_TPS
)) & 0xff,
224 &bp
->r
[chip
]->r
[CD180_PPRL
]);
226 sbus_writeb(SRCR_AUTOPRI
|SRCR_GLOBPRI
,
227 &bp
->r
[chip
]->r
[CD180_SRCR
]);
229 id
= sbus_readb(&bp
->r
[chip
]->r
[CD180_GFRCR
]);
230 printk(KERN_INFO
"aurora%d: Chip %d id %02x: ",
231 board_No(bp
), chip
,id
);
232 if(sbus_readb(&bp
->r
[chip
]->r
[CD180_SRCR
]) & 128) {
234 case 0x82:printk("CL-CD1864 rev A\n");break;
235 case 0x83:printk("CL-CD1865 rev A\n");break;
236 case 0x84:printk("CL-CD1865 rev B\n");break;
237 case 0x85:printk("CL-CD1865 rev C\n");break;
238 default:printk("Unknown.\n");
242 case 0x81:printk("CL-CD180 rev B\n");break;
243 case 0x82:printk("CL-CD180 rev C\n");break;
244 default:printk("Unknown.\n");
247 restore_flags(flags
);
249 printk("aurora_init_CD180: end\n");
254 static int valid_irq(unsigned char irq
)
257 for(i
=0;i
<TYPE_1_IRQS
;i
++)
258 if (type_1_irq
[i
]==irq
) return 1;
262 static irqreturn_t
aurora_interrupt(int irq
, void * dev_id
, struct pt_regs
* regs
);
264 /* Main probing routine, also sets irq. */
265 static int aurora_probe(void)
267 struct sbus_bus
*sbus
;
268 struct sbus_dev
*sdev
;
272 struct Aurora_board
*bp
;
274 for_each_sbus(sbus
) {
275 for_each_sbusdev(sdev
, sbus
) {
276 /* printk("Try: %x %s\n",sdev,sdev->prom_name);*/
277 if (!strcmp(sdev
->prom_name
, "sio16")) {
279 printk(KERN_INFO
"aurora: sio16 at %p\n",sdev
);
281 if((sdev
->reg_addrs
[0].reg_size
!=1) &&
282 (sdev
->reg_addrs
[1].reg_size
!=128) &&
283 (sdev
->reg_addrs
[2].reg_size
!=128) &&
284 (sdev
->reg_addrs
[3].reg_size
!=4)) {
285 printk(KERN_ERR
"aurora%d: registers' sizes "
286 "do not match.\n", bn
);
289 bp
= &aurora_board
[bn
];
290 bp
->r0
= (struct aurora_reg1
*)
291 sbus_ioremap(&sdev
->resource
[0], 0,
292 sdev
->reg_addrs
[0].reg_size
,
294 if (bp
->r0
== NULL
) {
295 printk(KERN_ERR
"aurora%d: can't map "
296 "reg_addrs[0]\n", bn
);
300 printk("Map reg 0: %p\n", bp
->r0
);
302 bp
->r
[0] = (struct aurora_reg128
*)
303 sbus_ioremap(&sdev
->resource
[1], 0,
304 sdev
->reg_addrs
[1].reg_size
,
306 if (bp
->r
[0] == NULL
) {
307 printk(KERN_ERR
"aurora%d: can't map "
308 "reg_addrs[1]\n", bn
);
312 printk("Map reg 1: %p\n", bp
->r
[0]);
314 bp
->r
[1] = (struct aurora_reg128
*)
315 sbus_ioremap(&sdev
->resource
[2], 0,
316 sdev
->reg_addrs
[2].reg_size
,
318 if (bp
->r
[1] == NULL
) {
319 printk(KERN_ERR
"aurora%d: can't map "
320 "reg_addrs[2]\n", bn
);
324 printk("Map reg 2: %p\n", bp
->r
[1]);
326 bp
->r3
= (struct aurora_reg4
*)
327 sbus_ioremap(&sdev
->resource
[3], 0,
328 sdev
->reg_addrs
[3].reg_size
,
330 if (bp
->r3
== NULL
) {
331 printk(KERN_ERR
"aurora%d: can't map "
332 "reg_addrs[3]\n", bn
);
336 printk("Map reg 3: %p\n", bp
->r3
);
338 /* Variables setup */
341 grrr
=prom_getint(sdev
->prom_node
,"intr");
342 printk("intr pri %d\n", grrr
);
344 if ((bp
->irq
=irqs
[bn
]) && valid_irq(bp
->irq
) &&
345 !request_irq(bp
->irq
|0x30, aurora_interrupt
, SA_SHIRQ
, "sio16", bp
)) {
346 free_irq(bp
->irq
|0x30, bp
);
348 if ((bp
->irq
=prom_getint(sdev
->prom_node
, "bintr")) && valid_irq(bp
->irq
) &&
349 !request_irq(bp
->irq
|0x30, aurora_interrupt
, SA_SHIRQ
, "sio16", bp
)) {
350 free_irq(bp
->irq
|0x30, bp
);
352 if ((bp
->irq
=prom_getint(sdev
->prom_node
, "intr")) && valid_irq(bp
->irq
) &&
353 !request_irq(bp
->irq
|0x30, aurora_interrupt
, SA_SHIRQ
, "sio16", bp
)) {
354 free_irq(bp
->irq
|0x30, bp
);
356 for(grrr
=0;grrr
<TYPE_1_IRQS
;grrr
++) {
357 if ((bp
->irq
=type_1_irq
[grrr
])&&!request_irq(bp
->irq
|0x30, aurora_interrupt
, SA_SHIRQ
, "sio16", bp
)) {
358 free_irq(bp
->irq
|0x30, bp
);
361 printk(KERN_ERR
"aurora%d: Could not get an irq for this board !!!\n",bn
);
365 if(bp
->flags
==0xff)break;
366 printk(KERN_INFO
"aurora%d: irq %d\n",bn
,bp
->irq
&0x0f);
368 grrr
=prom_getproperty(sdev
->prom_node
,"dtr_rts",buf
,sizeof(buf
));
369 if(!strcmp(buf
,"swapped")){
370 printk(KERN_INFO
"aurora%d: Swapped DTR and RTS\n",bn
);
373 bp
->MSVDTR
=CD180_MSVRTS
;
374 bp
->MSVRTS
=CD180_MSVDTR
;
375 bp
->flags
|=AURORA_BOARD_DTR_FLOW_OK
;
377 #ifdef AURORA_FORCE_DTR_FLOW
378 printk(KERN_INFO
"aurora%d: Forcing swapped DTR-RTS\n",bn
);
381 bp
->MSVDTR
=CD180_MSVRTS
;
382 bp
->MSVRTS
=CD180_MSVDTR
;
383 bp
->flags
|=AURORA_BOARD_DTR_FLOW_OK
;
385 printk(KERN_INFO
"aurora%d: Normal DTR and RTS\n",bn
);
388 bp
->MSVDTR
=CD180_MSVDTR
;
389 bp
->MSVRTS
=CD180_MSVRTS
;
392 bp
->oscfreq
=prom_getint(sdev
->prom_node
,"clk")*100;
393 printk(KERN_INFO
"aurora%d: Oscillator: %d Hz\n",bn
,bp
->oscfreq
);
394 grrr
=prom_getproperty(sdev
->prom_node
,"chip",buf
,sizeof(buf
));
395 printk(KERN_INFO
"aurora%d: Chips: %s\n",bn
,buf
);
396 grrr
=prom_getproperty(sdev
->prom_node
,"manu",buf
,sizeof(buf
));
397 printk(KERN_INFO
"aurora%d: Manufacturer: %s\n",bn
,buf
);
398 grrr
=prom_getproperty(sdev
->prom_node
,"model",buf
,sizeof(buf
));
399 printk(KERN_INFO
"aurora%d: Model: %s\n",bn
,buf
);
400 grrr
=prom_getproperty(sdev
->prom_node
,"rev",buf
,sizeof(buf
));
401 printk(KERN_INFO
"aurora%d: Revision: %s\n",bn
,buf
);
402 grrr
=prom_getproperty(sdev
->prom_node
,"mode",buf
,sizeof(buf
));
403 printk(KERN_INFO
"aurora%d: Mode: %s\n",bn
,buf
);
407 bp
->flags
= AURORA_BOARD_PRESENT
;
419 static void aurora_release_io_range(struct Aurora_board
*bp
)
421 sbus_iounmap((unsigned long)bp
->r0
, 1);
422 sbus_iounmap((unsigned long)bp
->r
[0], 128);
423 sbus_iounmap((unsigned long)bp
->r
[1], 128);
424 sbus_iounmap((unsigned long)bp
->r3
, 4);
427 extern inline void aurora_mark_event(struct Aurora_port
* port
, int event
)
430 printk("aurora_mark_event: start\n");
432 set_bit(event
, &port
->event
);
433 queue_task(&port
->tqueue
, &tq_aurora
);
436 printk("aurora_mark_event: end\n");
440 static __inline__
struct Aurora_port
* aurora_get_port(struct Aurora_board
const * bp
,
442 unsigned char const *what
)
444 unsigned char channel
;
445 struct Aurora_port
* port
;
447 channel
= ((chip
<< 3) |
448 ((sbus_readb(&bp
->r
[chip
]->r
[CD180_GSCR
]) & GSCR_CHAN
) >> GSCR_CHAN_OFF
));
449 port
= &aurora_port
[board_No(bp
) * AURORA_NPORT
* AURORA_NCD180
+ channel
];
450 if (port
->flags
& ASYNC_INITIALIZED
)
453 printk(KERN_DEBUG
"aurora%d: %s interrupt from invalid port %d\n",
454 board_No(bp
), what
, channel
);
458 static void aurora_receive_exc(struct Aurora_board
const * bp
, int chip
)
460 struct Aurora_port
*port
;
461 struct tty_struct
*tty
;
462 unsigned char status
;
465 if (!(port
= aurora_get_port(bp
, chip
, "Receive_x")))
469 if (tty
->flip
.count
>= TTY_FLIPBUF_SIZE
) {
470 #ifdef AURORA_INTNORM
471 printk("aurora%d: port %d: Working around flip buffer overflow.\n",
472 board_No(bp
), port_No(port
));
477 #ifdef AURORA_REPORT_OVERRUN
478 status
= sbus_readb(&bp
->r
[chip
]->r
[CD180_RCSR
]);
479 if (status
& RCSR_OE
) {
482 printk("aurora%d: port %d: Overrun. Total %ld overruns.\n",
483 board_No(bp
), port_No(port
), port
->overrun
);
486 status
&= port
->mark_mask
;
488 status
= sbus_readb(&bp
->r
[chip
]->r
[CD180_RCSR
]) & port
->mark_mask
;
490 ch
= sbus_readb(&bp
->r
[chip
]->r
[CD180_RDR
]);
494 if (status
& RCSR_TOUT
) {
495 /* printk("aurora%d: port %d: Receiver timeout. Hardware problems ?\n",
496 board_No(bp), port_No(port));*/
499 } else if (status
& RCSR_BREAK
) {
500 printk(KERN_DEBUG
"aurora%d: port %d: Handling break...\n",
501 board_No(bp
), port_No(port
));
502 *tty
->flip
.flag_buf_ptr
++ = TTY_BREAK
;
503 if (port
->flags
& ASYNC_SAK
)
506 } else if (status
& RCSR_PE
)
507 *tty
->flip
.flag_buf_ptr
++ = TTY_PARITY
;
509 else if (status
& RCSR_FE
)
510 *tty
->flip
.flag_buf_ptr
++ = TTY_FRAME
;
512 else if (status
& RCSR_OE
)
513 *tty
->flip
.flag_buf_ptr
++ = TTY_OVERRUN
;
516 *tty
->flip
.flag_buf_ptr
++ = 0;
518 *tty
->flip
.char_buf_ptr
++ = ch
;
520 queue_task(&tty
->flip
.tqueue
, &tq_timer
);
523 static void aurora_receive(struct Aurora_board
const * bp
, int chip
)
525 struct Aurora_port
*port
;
526 struct tty_struct
*tty
;
527 unsigned char count
,cnt
;
529 if (!(port
= aurora_get_port(bp
, chip
, "Receive")))
534 count
= sbus_readb(&bp
->r
[chip
]->r
[CD180_RDCR
]);
536 #ifdef AURORA_REPORT_FIFO
537 port
->hits
[count
> 8 ? 9 : count
]++;
541 if (tty
->flip
.count
>= TTY_FLIPBUF_SIZE
) {
542 #ifdef AURORA_INTNORM
543 printk("aurora%d: port %d: Working around flip buffer overflow.\n",
544 board_No(bp
), port_No(port
));
548 cnt
= sbus_readb(&bp
->r
[chip
]->r
[CD180_RDR
]);
549 *tty
->flip
.char_buf_ptr
++ = cnt
;
550 *tty
->flip
.flag_buf_ptr
++ = 0;
553 queue_task(&tty
->flip
.tqueue
, &tq_timer
);
556 static void aurora_transmit(struct Aurora_board
const * bp
, int chip
)
558 struct Aurora_port
*port
;
559 struct tty_struct
*tty
;
562 if (!(port
= aurora_get_port(bp
, chip
, "Transmit")))
567 if (port
->SRER
& SRER_TXEMPTY
) {
569 sbus_writeb(port_No(port
) & 7,
570 &bp
->r
[chip
]->r
[CD180_CAR
]);
572 port
->SRER
&= ~SRER_TXEMPTY
;
573 sbus_writeb(port
->SRER
, &bp
->r
[chip
]->r
[CD180_SRER
]);
577 if ((port
->xmit_cnt
<= 0 && !port
->break_length
)
578 || tty
->stopped
|| tty
->hw_stopped
) {
579 sbus_writeb(port_No(port
) & 7,
580 &bp
->r
[chip
]->r
[CD180_CAR
]);
582 port
->SRER
&= ~SRER_TXRDY
;
583 sbus_writeb(port
->SRER
,
584 &bp
->r
[chip
]->r
[CD180_SRER
]);
588 if (port
->break_length
) {
589 if (port
->break_length
> 0) {
590 if (port
->COR2
& COR2_ETC
) {
591 sbus_writeb(CD180_C_ESC
,
592 &bp
->r
[chip
]->r
[CD180_TDR
]);
593 sbus_writeb(CD180_C_SBRK
,
594 &bp
->r
[chip
]->r
[CD180_TDR
]);
595 port
->COR2
&= ~COR2_ETC
;
597 count
= MIN(port
->break_length
, 0xff);
598 sbus_writeb(CD180_C_ESC
,
599 &bp
->r
[chip
]->r
[CD180_TDR
]);
600 sbus_writeb(CD180_C_DELAY
,
601 &bp
->r
[chip
]->r
[CD180_TDR
]);
603 &bp
->r
[chip
]->r
[CD180_TDR
]);
604 if (!(port
->break_length
-= count
))
605 port
->break_length
--;
607 sbus_writeb(CD180_C_ESC
,
608 &bp
->r
[chip
]->r
[CD180_TDR
]);
609 sbus_writeb(CD180_C_EBRK
,
610 &bp
->r
[chip
]->r
[CD180_TDR
]);
611 sbus_writeb(port
->COR2
,
612 &bp
->r
[chip
]->r
[CD180_COR2
]);
613 aurora_wait_CCR(bp
->r
[chip
]);
614 sbus_writeb(CCR_CORCHG2
,
615 &bp
->r
[chip
]->r
[CD180_CCR
]);
616 port
->break_length
= 0;
623 u8 byte
= port
->xmit_buf
[port
->xmit_tail
++];
625 sbus_writeb(byte
, &bp
->r
[chip
]->r
[CD180_TDR
]);
626 port
->xmit_tail
= port
->xmit_tail
& (SERIAL_XMIT_SIZE
-1);
627 if (--port
->xmit_cnt
<= 0)
629 } while (--count
> 0);
631 if (port
->xmit_cnt
<= 0) {
632 sbus_writeb(port_No(port
) & 7,
633 &bp
->r
[chip
]->r
[CD180_CAR
]);
635 port
->SRER
&= ~SRER_TXRDY
;
636 sbus_writeb(port
->SRER
,
637 &bp
->r
[chip
]->r
[CD180_SRER
]);
639 if (port
->xmit_cnt
<= port
->wakeup_chars
)
640 aurora_mark_event(port
, RS_EVENT_WRITE_WAKEUP
);
643 static void aurora_check_modem(struct Aurora_board
const * bp
, int chip
)
645 struct Aurora_port
*port
;
646 struct tty_struct
*tty
;
649 if (!(port
= aurora_get_port(bp
, chip
, "Modem")))
654 mcr
= sbus_readb(&bp
->r
[chip
]->r
[CD180_MCR
]);
655 if (mcr
& MCR_CDCHG
) {
656 if (sbus_readb(&bp
->r
[chip
]->r
[CD180_MSVR
]) & MSVR_CD
)
657 wake_up_interruptible(&port
->open_wait
);
659 schedule_task(&port
->tqueue_hangup
);
662 /* 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
663 * Aurora didn't made any boards with CTS or DSR broken...
665 /* #ifdef AURORA_BRAIN_DAMAGED_CTS
666 if (mcr & MCR_CTSCHG) {
667 if (aurora_in(bp, CD180_MSVR) & MSVR_CTS) {
669 port->SRER |= SRER_TXRDY;
670 if (port->xmit_cnt <= port->wakeup_chars)
671 aurora_mark_event(port, RS_EVENT_WRITE_WAKEUP);
674 port->SRER &= ~SRER_TXRDY;
676 sbus_writeb(port->SRER, &bp->r[chip]->r[CD180_SRER]);
678 if (mcr & MCR_DSRCHG) {
679 if (aurora_in(bp, CD180_MSVR) & MSVR_DSR) {
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 #endif AURORA_BRAIN_DAMAGED_CTS */
692 /* Clear change bits */
693 sbus_writeb(0, &bp
->r
[chip
]->r
[CD180_MCR
]);
696 /* The main interrupt processing routine */
697 static irqreturn_t
aurora_interrupt(int irq
, void * dev_id
, struct pt_regs
* regs
)
699 unsigned char status
;
700 unsigned char ack
,chip
/*,chip_id*/;
701 struct Aurora_board
* bp
= (struct Aurora_board
*) dev_id
;
702 unsigned long loop
= 0;
704 #ifdef AURORA_INT_DEBUG
705 printk("IRQ%d %d\n",irq
,++irqhit
);
706 #ifdef AURORA_FLOODPRO
707 if (irqhit
>=AURORA_FLOODPRO
)
708 sbus_writeb(8, &bp
->r0
->r
);
712 /* old bp = IRQ_to_board[irq&0x0f];*/
714 if (!bp
|| !(bp
->flags
& AURORA_BOARD_ACTIVE
))
717 /* The while() below takes care of this.
718 status = sbus_readb(&bp->r[0]->r[CD180_SRSR]);
719 #ifdef AURORA_INT_DEBUG
720 printk("mumu: %02x\n", status);
722 if (!(status&SRSR_ANYINT))
723 return IRQ_NONE; * Nobody has anything to say, so exit *
725 while ((loop
++ < 48) &&
726 (status
= sbus_readb(&bp
->r
[0]->r
[CD180_SRSR
]) & SRSR_ANYINT
)){
727 #ifdef AURORA_INT_DEBUG
728 printk("SRSR: %02x\n", status
);
730 if (status
& SRSR_REXT
) {
731 ack
= sbus_readb(&bp
->r3
->r
[bp
->ACK_RINT
]);
732 #ifdef AURORA_INT_DEBUG
733 printk("R-ACK %02x\n", ack
);
735 if ((ack
>> 5) == board_No(bp
)) {
736 if ((chip
=((ack
>>3)&3)-1) < AURORA_NCD180
) {
737 if ((ack
&GSVR_ITMASK
)==GSVR_IT_RGD
) {
738 aurora_receive(bp
,chip
);
740 &bp
->r
[chip
]->r
[CD180_EOSRR
]);
741 } else if ((ack
& GSVR_ITMASK
) == GSVR_IT_REXC
) {
742 aurora_receive_exc(bp
,chip
);
744 &bp
->r
[chip
]->r
[CD180_EOSRR
]);
748 } else if (status
& SRSR_TEXT
) {
749 ack
= sbus_readb(&bp
->r3
->r
[bp
->ACK_TINT
]);
750 #ifdef AURORA_INT_DEBUG
751 printk("T-ACK %02x\n", ack
);
753 if ((ack
>> 5) == board_No(bp
)) {
754 if ((chip
=((ack
>>3)&3)-1) < AURORA_NCD180
) {
755 if ((ack
&GSVR_ITMASK
)==GSVR_IT_TX
) {
756 aurora_transmit(bp
,chip
);
758 &bp
->r
[chip
]->r
[CD180_EOSRR
]);
762 } else if (status
& SRSR_MEXT
) {
763 ack
= sbus_readb(&bp
->r3
->r
[bp
->ACK_MINT
]);
764 #ifdef AURORA_INT_DEBUG
765 printk("M-ACK %02x\n", ack
);
767 if ((ack
>> 5) == board_No(bp
)) {
768 if ((chip
= ((ack
>>3)&3)-1) < AURORA_NCD180
) {
769 if ((ack
&GSVR_ITMASK
)==GSVR_IT_MDM
) {
770 aurora_check_modem(bp
,chip
);
772 &bp
->r
[chip
]->r
[CD180_EOSRR
]);
778 /* I guess this faster code can be used with CD1865, using AUROPRI and GLOBPRI. */
780 while ((loop
++ < 48)&&(status
=bp
->r
[0]->r
[CD180_SRSR
]&SRSR_ANYINT
)){
781 #ifdef AURORA_INT_DEBUG
782 printk("SRSR: %02x\n",status
);
784 ack
= sbus_readb(&bp
->r3
->r
[0]);
785 #ifdef AURORA_INT_DEBUG
786 printk("ACK: %02x\n",ack
);
788 if ((ack
>>5)==board_No(bp
)) {
789 if ((chip
=((ack
>>3)&3)-1) < AURORA_NCD180
) {
791 if (ack
==GSVR_IT_RGD
) {
792 aurora_receive(bp
,chip
);
794 &bp
->r
[chip
]->r
[CD180_EOSRR
]);
795 } else if (ack
==GSVR_IT_REXC
) {
796 aurora_receive_exc(bp
,chip
);
798 &bp
->r
[chip
]->r
[CD180_EOSRR
]);
799 } else if (ack
==GSVR_IT_TX
) {
800 aurora_transmit(bp
,chip
);
802 &bp
->r
[chip
]->r
[CD180_EOSRR
]);
803 } else if (ack
==GSVR_IT_MDM
) {
804 aurora_check_modem(bp
,chip
);
806 &bp
->r
[chip
]->r
[CD180_EOSRR
]);
813 /* This is the old handling routine, used in riscom8 for only one CD180. I keep it here for reference. */
815 for(chip
=0;chip
<AURORA_NCD180
;chip
++){
816 chip_id
=(board_No(bp
)<<5)|((chip
+1)<<3);
818 while ((loop
++ < 1) &&
819 ((status
= sbus_readb(&bp
->r
[chip
]->r
[CD180_SRSR
])) &
820 (SRSR_TEXT
| SRSR_MEXT
| SRSR_REXT
))) {
822 if (status
& SRSR_REXT
) {
823 ack
= sbus_readb(&bp
->r3
->r
[bp
->ACK_RINT
]);
824 if (ack
== (chip_id
| GSVR_IT_RGD
)) {
828 aurora_receive(bp
,chip
);
829 } else if (ack
== (chip_id
| GSVR_IT_REXC
)) {
833 aurora_receive_exc(bp
,chip
);
835 #ifdef AURORA_INTNORM
836 printk("aurora%d-%d: Bad receive ack 0x%02x.\n",
837 board_No(bp
), chip
, ack
);
840 } else if (status
& SRSR_TEXT
) {
841 ack
= sbus_readb(&bp
->r3
->r
[bp
->ACK_TINT
]);
842 if (ack
== (chip_id
| GSVR_IT_TX
)){
846 aurora_transmit(bp
,chip
);
848 #ifdef AURORA_INTNORM
849 printk("aurora%d-%d: Bad transmit ack 0x%02x.\n",
850 board_No(bp
), chip
, ack
);
853 } else if (status
& SRSR_MEXT
) {
854 ack
= sbus_readb(&bp
->r3
->r
[bp
->ACK_MINT
]);
855 if (ack
== (chip_id
| GSVR_IT_MDM
)){
859 aurora_check_modem(bp
,chip
);
861 #ifdef AURORA_INTNORM
862 printk("aurora%d-%d: Bad modem ack 0x%02x.\n",
863 board_No(bp
), chip
, ack
);
867 sbus_writeb(0, &bp
->r
[chip
]->r
[CD180_EOSRR
]);
875 #ifdef AURORA_INT_DEBUG
876 static void aurora_timer (unsigned long ignored
);
878 static struct timer_list aurora_poll_timer
=
879 TIMER_INITIALIZER(aurora_timer
, 0, 0);
882 aurora_timer (unsigned long ignored
)
887 save_flags(flags
); cli();
889 printk("SRSR: %02x,%02x - ",
890 sbus_readb(&aurora_board
[0].r
[0]->r
[CD180_SRSR
]),
891 sbus_readb(&aurora_board
[0].r
[1]->r
[CD180_SRSR
]));
892 for (i
= 0; i
< 4; i
++) {
895 sbus_readb(&aurora_board
[0].r3
->r
[i
]));
899 aurora_poll_timer
.expires
= jiffies
+ 300;
900 add_timer (&aurora_poll_timer
);
902 restore_flags(flags
);
907 * Routines for open & close processing.
910 /* Called with disabled interrupts */
911 static int aurora_setup_board(struct Aurora_board
* bp
)
917 for (i
= 0; i
< AURORA_ALLIRQ
; i
++) {
918 error
= request_irq(allirq
[i
]|0x30, aurora_interrupt
, SA_SHIRQ
,
921 printk(KERN_ERR
"IRQ%d request error %d\n",
925 error
= request_irq(bp
->irq
|0x30, aurora_interrupt
, SA_SHIRQ
,
928 printk(KERN_ERR
"IRQ request error %d\n", error
);
933 sbus_writeb(0, &bp
->r0
->r
);
935 if (bp
->flags
& AURORA_BOARD_TYPE_2
) {
938 sbus_writeb((AURORA_CFG_ENABLE_IO
| AURORA_CFG_ENABLE_IRQ
|
939 (((bp
->irq
)&0x0f)>>2)),
944 if (aurora_init_CD180(bp
,0))error
=1;error
=0;
945 if (aurora_init_CD180(bp
,1))error
++;
946 if (error
== AURORA_NCD180
) {
947 printk(KERN_ERR
"Both chips failed initialisation.\n");
951 #ifdef AURORA_INT_DEBUG
952 aurora_poll_timer
.expires
= jiffies
+ 1;
953 add_timer(&aurora_poll_timer
);
956 printk("aurora_setup_board: end\n");
961 /* Called with disabled interrupts */
962 static void aurora_shutdown_board(struct Aurora_board
*bp
)
967 printk("aurora_shutdown_board: start\n");
970 #ifdef AURORA_INT_DEBUG
971 del_timer(&aurora_poll_timer
);
975 for(i
=0;i
<AURORA_ALLIRQ
;i
++){
976 free_irq(allirq
[i
]|0x30, bp
);
977 /* IRQ_to_board[allirq[i]&0xf] = NULL;*/
980 free_irq(bp
->irq
|0x30, bp
);
981 /* IRQ_to_board[bp->irq&0xf] = NULL;*/
985 sbus_writeb(i
& 7, &bp
->r
[i
>>3]->r
[CD180_CAR
]);
987 sbus_writeb(0, &bp
->r
[i
>>3]->r
[CD180_MSVR
]);
991 sbus_writeb(0, &bp
->r0
->r
);
994 printk("aurora_shutdown_board: end\n");
998 /* Setting up port characteristics.
999 * Must be called with disabled interrupts
1001 static void aurora_change_speed(struct Aurora_board
*bp
, struct Aurora_port
*port
)
1003 struct tty_struct
*tty
;
1006 unsigned char cor1
= 0, cor3
= 0;
1007 unsigned char mcor1
= 0, mcor2
= 0,chip
;
1010 printk("aurora_change_speed: start\n");
1012 if (!(tty
= port
->tty
) || !tty
->termios
)
1015 chip
= AURORA_CD180(port_No(port
));
1019 port
->MSVR
= MSVR_RTS
|MSVR_DTR
;
1021 baud
= tty_get_baud_rate(tty
);
1023 /* Select port on the board */
1024 sbus_writeb(port_No(port
) & 7,
1025 &bp
->r
[chip
]->r
[CD180_CAR
]);
1029 /* Drop DTR & exit */
1030 port
->MSVR
&= ~(bp
->DTR
|bp
->RTS
);
1031 sbus_writeb(port
->MSVR
,
1032 &bp
->r
[chip
]->r
[CD180_MSVR
]);
1036 port
->MSVR
|= bp
->DTR
;
1037 sbus_writeb(port
->MSVR
,
1038 &bp
->r
[chip
]->r
[CD180_MSVR
]);
1041 /* Now we must calculate some speed dependent things. */
1043 /* Set baud rate for port. */
1044 tmp
= (((bp
->oscfreq
+ baud
/2) / baud
+
1045 CD180_TPC
/2) / CD180_TPC
);
1047 /* tmp = (bp->oscfreq/7)/baud;
1048 if((tmp%10)>4)tmp=tmp/10+1;else tmp=tmp/10;*/
1049 /* printk("Prescaler period: %d\n",tmp);*/
1051 sbus_writeb((tmp
>> 8) & 0xff,
1052 &bp
->r
[chip
]->r
[CD180_RBPRH
]);
1053 sbus_writeb((tmp
>> 8) & 0xff,
1054 &bp
->r
[chip
]->r
[CD180_TBPRH
]);
1055 sbus_writeb(tmp
& 0xff, &bp
->r
[chip
]->r
[CD180_RBPRL
]);
1056 sbus_writeb(tmp
& 0xff, &bp
->r
[chip
]->r
[CD180_TBPRL
]);
1058 baud
= (baud
+ 5) / 10; /* Estimated CPS */
1060 /* Two timer ticks seems enough to wakeup something like SLIP driver */
1061 tmp
= ((baud
+ HZ
/2) / HZ
) * 2 - CD180_NFIFO
;
1062 port
->wakeup_chars
= (tmp
< 0) ? 0 : ((tmp
>= SERIAL_XMIT_SIZE
) ?
1063 SERIAL_XMIT_SIZE
- 1 : tmp
);
1065 /* Receiver timeout will be transmission time for 1.5 chars */
1066 tmp
= (AURORA_TPS
+ AURORA_TPS
/2 + baud
/2) / baud
;
1067 tmp
= (tmp
> 0xff) ? 0xff : tmp
;
1068 sbus_writeb(tmp
, &bp
->r
[chip
]->r
[CD180_RTPR
]);
1070 switch (C_CSIZE(tty
)) {
1088 cor1
|= COR1_IGNORE
;
1089 if (C_PARENB(tty
)) {
1090 cor1
|= COR1_NORMPAR
;
1094 cor1
&= ~COR1_IGNORE
;
1096 /* Set marking of some errors */
1097 port
->mark_mask
= RCSR_OE
| RCSR_TOUT
;
1099 port
->mark_mask
|= RCSR_FE
| RCSR_PE
;
1100 if (I_BRKINT(tty
) || I_PARMRK(tty
))
1101 port
->mark_mask
|= RCSR_BREAK
;
1103 port
->mark_mask
&= ~(RCSR_FE
| RCSR_PE
);
1104 if (I_IGNBRK(tty
)) {
1105 port
->mark_mask
&= ~RCSR_BREAK
;
1107 /* Real raw mode. Ignore all */
1108 port
->mark_mask
&= ~RCSR_OE
;
1110 /* Enable Hardware Flow Control */
1111 if (C_CRTSCTS(tty
)) {
1112 /*#ifdef AURORA_BRAIN_DAMAGED_CTS
1113 port->SRER |= SRER_DSR | SRER_CTS;
1114 mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD;
1115 mcor2 |= MCOR2_DSROD | MCOR2_CTSOD;
1116 tty->hw_stopped = !(aurora_in(bp, CD180_MSVR) & (MSVR_CTS|MSVR_DSR));
1118 port
->COR2
|= COR2_CTSAE
;
1120 if (bp
->flags
&AURORA_BOARD_DTR_FLOW_OK
) {
1121 mcor1
|= AURORA_RXTH
;
1124 /* Enable Software Flow Control. FIXME: I'm not sure about this */
1125 /* Some people reported that it works, but I still doubt */
1127 port
->COR2
|= COR2_TXIBE
;
1128 cor3
|= (COR3_FCT
| COR3_SCDE
);
1130 port
->COR2
|= COR2_IXM
;
1131 sbus_writeb(START_CHAR(tty
),
1132 &bp
->r
[chip
]->r
[CD180_SCHR1
]);
1133 sbus_writeb(STOP_CHAR(tty
),
1134 &bp
->r
[chip
]->r
[CD180_SCHR2
]);
1135 sbus_writeb(START_CHAR(tty
),
1136 &bp
->r
[chip
]->r
[CD180_SCHR3
]);
1137 sbus_writeb(STOP_CHAR(tty
),
1138 &bp
->r
[chip
]->r
[CD180_SCHR4
]);
1140 if (!C_CLOCAL(tty
)) {
1141 /* Enable CD check */
1142 port
->SRER
|= SRER_CD
;
1143 mcor1
|= MCOR1_CDZD
;
1144 mcor2
|= MCOR2_CDOD
;
1148 /* Enable receiver */
1149 port
->SRER
|= SRER_RXD
;
1151 /* Set input FIFO size (1-8 bytes) */
1152 cor3
|= AURORA_RXFIFO
;
1153 /* Setting up CD180 channel registers */
1154 sbus_writeb(cor1
, &bp
->r
[chip
]->r
[CD180_COR1
]);
1155 sbus_writeb(port
->COR2
, &bp
->r
[chip
]->r
[CD180_COR2
]);
1156 sbus_writeb(cor3
, &bp
->r
[chip
]->r
[CD180_COR3
]);
1157 /* Make CD180 know about registers change */
1158 aurora_wait_CCR(bp
->r
[chip
]);
1159 sbus_writeb(CCR_CORCHG1
| CCR_CORCHG2
| CCR_CORCHG3
,
1160 &bp
->r
[chip
]->r
[CD180_CCR
]);
1161 /* Setting up modem option registers */
1162 sbus_writeb(mcor1
, &bp
->r
[chip
]->r
[CD180_MCOR1
]);
1163 sbus_writeb(mcor2
, &bp
->r
[chip
]->r
[CD180_MCOR2
]);
1164 /* Enable CD180 transmitter & receiver */
1165 aurora_wait_CCR(bp
->r
[chip
]);
1166 sbus_writeb(CCR_TXEN
| CCR_RXEN
, &bp
->r
[chip
]->r
[CD180_CCR
]);
1167 /* Enable interrupts */
1168 sbus_writeb(port
->SRER
, &bp
->r
[chip
]->r
[CD180_SRER
]);
1169 /* And finally set RTS on */
1170 sbus_writeb(port
->MSVR
, &bp
->r
[chip
]->r
[CD180_MSVR
]);
1172 printk("aurora_change_speed: end\n");
1176 /* Must be called with interrupts enabled */
1177 static int aurora_setup_port(struct Aurora_board
*bp
, struct Aurora_port
*port
)
1179 unsigned long flags
;
1182 printk("aurora_setup_port: start %d\n",port_No(port
));
1184 if (port
->flags
& ASYNC_INITIALIZED
)
1187 if (!port
->xmit_buf
) {
1188 /* We may sleep in get_zeroed_page() */
1191 if (!(tmp
= get_zeroed_page(GFP_KERNEL
)))
1194 if (port
->xmit_buf
) {
1196 return -ERESTARTSYS
;
1198 port
->xmit_buf
= (unsigned char *) tmp
;
1201 save_flags(flags
); cli();
1204 clear_bit(TTY_IO_ERROR
, &port
->tty
->flags
);
1207 if ((port
->count
== 1) && ((++bp
->count
) == 1))
1208 bp
->flags
|= AURORA_BOARD_ACTIVE
;
1211 port
->xmit_cnt
= port
->xmit_head
= port
->xmit_tail
= 0;
1212 aurora_change_speed(bp
, port
);
1213 port
->flags
|= ASYNC_INITIALIZED
;
1215 restore_flags(flags
);
1217 printk("aurora_setup_port: end\n");
1222 /* Must be called with interrupts disabled */
1223 static void aurora_shutdown_port(struct Aurora_board
*bp
, struct Aurora_port
*port
)
1225 struct tty_struct
*tty
;
1229 printk("aurora_shutdown_port: start\n");
1231 if (!(port
->flags
& ASYNC_INITIALIZED
))
1234 chip
= AURORA_CD180(port_No(port
));
1236 #ifdef AURORA_REPORT_OVERRUN
1237 printk("aurora%d: port %d: Total %ld overruns were detected.\n",
1238 board_No(bp
), port_No(port
), port
->overrun
);
1240 #ifdef AURORA_REPORT_FIFO
1244 printk("aurora%d: port %d: FIFO hits [ ",
1245 board_No(bp
), port_No(port
));
1246 for (i
= 0; i
< 10; i
++) {
1247 printk("%ld ", port
->hits
[i
]);
1252 if (port
->xmit_buf
) {
1253 free_page((unsigned long) port
->xmit_buf
);
1254 port
->xmit_buf
= NULL
;
1257 if (!(tty
= port
->tty
) || C_HUPCL(tty
)) {
1259 port
->MSVR
&= ~(bp
->DTR
|bp
->RTS
);
1260 sbus_writeb(port
->MSVR
,
1261 &bp
->r
[chip
]->r
[CD180_MSVR
]);
1265 sbus_writeb(port_No(port
) & 7,
1266 &bp
->r
[chip
]->r
[CD180_CAR
]);
1270 aurora_wait_CCR(bp
->r
[chip
]);
1271 sbus_writeb(CCR_SOFTRESET
, &bp
->r
[chip
]->r
[CD180_CCR
]);
1273 /* Disable all interrupts from this port */
1275 sbus_writeb(port
->SRER
, &bp
->r
[chip
]->r
[CD180_SRER
]);
1278 set_bit(TTY_IO_ERROR
, &tty
->flags
);
1279 port
->flags
&= ~ASYNC_INITIALIZED
;
1282 if (--bp
->count
< 0) {
1283 printk(KERN_DEBUG
"aurora%d: aurora_shutdown_port: "
1284 "bad board count: %d\n",
1285 board_No(bp
), bp
->count
);
1290 bp
->flags
&= ~AURORA_BOARD_ACTIVE
;
1294 printk("aurora_shutdown_port: end\n");
1299 static int block_til_ready(struct tty_struct
*tty
, struct file
* filp
,
1300 struct Aurora_port
*port
)
1302 DECLARE_WAITQUEUE(wait
, current
);
1303 struct Aurora_board
*bp
= port_Board(port
);
1310 printk("block_til_ready: start\n");
1312 chip
= AURORA_CD180(port_No(port
));
1314 /* If the device is in the middle of being closed, then block
1315 * until it's done, and then try again.
1317 if (tty_hung_up_p(filp
) || port
->flags
& ASYNC_CLOSING
) {
1318 interruptible_sleep_on(&port
->close_wait
);
1319 if (port
->flags
& ASYNC_HUP_NOTIFY
)
1322 return -ERESTARTSYS
;
1325 /* If non-blocking mode is set, or the port is not enabled,
1326 * then make the check up front and then exit.
1328 if ((filp
->f_flags
& O_NONBLOCK
) ||
1329 (tty
->flags
& (1 << TTY_IO_ERROR
))) {
1330 port
->flags
|= ASYNC_NORMAL_ACTIVE
;
1337 /* Block waiting for the carrier detect and the line to become
1338 * free (i.e., not in use by the callout). While we are in
1339 * this loop, info->count is dropped by one, so that
1340 * rs_close() knows when to free things. We restore it upon
1341 * exit, either normal or abnormal.
1344 add_wait_queue(&port
->open_wait
, &wait
);
1346 if (!tty_hung_up_p(filp
))
1349 port
->blocked_open
++;
1352 sbus_writeb(port_No(port
) & 7,
1353 &bp
->r
[chip
]->r
[CD180_CAR
]);
1355 CD
= sbus_readb(&bp
->r
[chip
]->r
[CD180_MSVR
]) & MSVR_CD
;
1358 /* auto drops DTR */
1359 sbus_writeb(port
->MSVR
, &bp
->r
[chip
]->r
[CD180_MSVR
]);
1361 set_current_state(TASK_INTERRUPTIBLE
);
1362 if (tty_hung_up_p(filp
) ||
1363 !(port
->flags
& ASYNC_INITIALIZED
)) {
1364 if (port
->flags
& ASYNC_HUP_NOTIFY
)
1367 retval
= -ERESTARTSYS
;
1370 if (!(port
->flags
& ASYNC_CLOSING
) &&
1373 if (signal_pending(current
)) {
1374 retval
= -ERESTARTSYS
;
1379 current
->state
= TASK_RUNNING
;
1380 remove_wait_queue(&port
->open_wait
, &wait
);
1381 if (!tty_hung_up_p(filp
))
1383 port
->blocked_open
--;
1387 port
->flags
|= ASYNC_NORMAL_ACTIVE
;
1389 printk("block_til_ready: end\n");
1394 static int aurora_open(struct tty_struct
* tty
, struct file
* filp
)
1398 struct Aurora_port
* port
;
1399 struct Aurora_board
* bp
;
1400 unsigned long flags
;
1403 printk("aurora_open: start\n");
1406 board
= AURORA_BOARD(tty
->index
);
1407 if (board
> AURORA_NBOARD
||
1408 !(aurora_board
[board
].flags
& AURORA_BOARD_PRESENT
)) {
1410 printk("aurora_open: error board %d present %d\n",
1411 board
, aurora_board
[board
].flags
& AURORA_BOARD_PRESENT
);
1416 bp
= &aurora_board
[board
];
1417 port
= aurora_port
+ board
* AURORA_NPORT
* AURORA_NCD180
+ AURORA_PORT(tty
->index
);
1418 if ((aurora_paranoia_check(port
, tty
->name
, "aurora_open")) {
1420 printk("aurora_open: error paranoia check\n");
1426 tty
->driver_data
= port
;
1429 if ((error
= aurora_setup_port(bp
, port
))) {
1431 printk("aurora_open: error aurora_setup_port ret %d\n",error
);
1436 if ((error
= block_til_ready(tty
, filp
, port
))) {
1438 printk("aurora_open: error block_til_ready ret %d\n",error
);
1444 printk("aurora_open: end\n");
1449 static void aurora_close(struct tty_struct
* tty
, struct file
* filp
)
1451 struct Aurora_port
*port
= (struct Aurora_port
*) tty
->driver_data
;
1452 struct Aurora_board
*bp
;
1453 unsigned long flags
;
1454 unsigned long timeout
;
1458 printk("aurora_close: start\n");
1461 if (!port
|| (aurora_paranoia_check(port
, tty
->name
, "close"))
1464 chip
= AURORA_CD180(port_No(port
));
1466 save_flags(flags
); cli();
1467 if (tty_hung_up_p(filp
)) {
1468 restore_flags(flags
);
1472 bp
= port_Board(port
);
1473 if ((tty
->count
== 1) && (port
->count
!= 1)) {
1474 printk(KERN_DEBUG
"aurora%d: aurora_close: bad port count; "
1475 "tty->count is 1, port count is %d\n",
1476 board_No(bp
), port
->count
);
1479 if (--port
->count
< 0) {
1480 printk(KERN_DEBUG
"aurora%d: aurora_close: bad port "
1481 "count for tty%d: %d\n",
1482 board_No(bp
), port_No(port
), port
->count
);
1486 restore_flags(flags
);
1489 port
->flags
|= ASYNC_CLOSING
;
1491 /* Now we wait for the transmit buffer to clear; and we notify
1492 * the line discipline to only process XON/XOFF characters.
1495 if (port
->closing_wait
!= ASYNC_CLOSING_WAIT_NONE
){
1497 printk("aurora_close: waiting to flush...\n");
1499 tty_wait_until_sent(tty
, port
->closing_wait
);
1502 /* At this point we stop accepting input. To do this, we
1503 * disable the receive line status interrupts, and tell the
1504 * interrupt driver to stop checking the data ready bit in the
1505 * line status register.
1507 port
->SRER
&= ~SRER_RXD
;
1508 if (port
->flags
& ASYNC_INITIALIZED
) {
1509 port
->SRER
&= ~SRER_TXRDY
;
1510 port
->SRER
|= SRER_TXEMPTY
;
1511 sbus_writeb(port_No(port
) & 7,
1512 &bp
->r
[chip
]->r
[CD180_CAR
]);
1514 sbus_writeb(port
->SRER
, &bp
->r
[chip
]->r
[CD180_SRER
]);
1516 * Before we drop DTR, make sure the UART transmitter
1517 * has completely drained; this is especially
1518 * important if there is a transmit FIFO!
1520 timeout
= jiffies
+HZ
;
1521 while(port
->SRER
& SRER_TXEMPTY
) {
1522 current
->state
= TASK_INTERRUPTIBLE
;
1523 schedule_timeout(port
->timeout
);
1524 if (time_after(jiffies
, timeout
))
1529 printk("aurora_close: shutdown_port\n");
1531 aurora_shutdown_port(bp
, port
);
1532 if (tty
->driver
->flush_buffer
)
1533 tty
->driver
->flush_buffer(tty
);
1534 tty_ldisc_flush(tty
);
1538 if (port
->blocked_open
) {
1539 if (port
->close_delay
) {
1540 current
->state
= TASK_INTERRUPTIBLE
;
1541 schedule_timeout(port
->close_delay
);
1543 wake_up_interruptible(&port
->open_wait
);
1545 port
->flags
&= ~(ASYNC_NORMAL_ACTIVE
|ASYNC_CLOSING
);
1546 wake_up_interruptible(&port
->close_wait
);
1547 restore_flags(flags
);
1549 printk("aurora_close: end\n");
1553 static int aurora_write(struct tty_struct
* tty
,
1554 const unsigned char *buf
, int count
)
1556 struct Aurora_port
*port
= (struct Aurora_port
*) tty
->driver_data
;
1557 struct Aurora_board
*bp
;
1559 unsigned long flags
;
1563 printk("aurora_write: start %d\n",count
);
1565 if ((aurora_paranoia_check(port
, tty
->name
, "aurora_write"))
1568 chip
= AURORA_CD180(port_No(port
));
1570 bp
= port_Board(port
);
1572 if (!tty
|| !port
->xmit_buf
|| !tmp_buf
)
1578 c
= MIN(count
, MIN(SERIAL_XMIT_SIZE
- port
->xmit_cnt
- 1,
1579 SERIAL_XMIT_SIZE
- port
->xmit_head
));
1581 restore_flags(flags
);
1584 memcpy(port
->xmit_buf
+ port
->xmit_head
, buf
, c
);
1585 port
->xmit_head
= (port
->xmit_head
+ c
) & (SERIAL_XMIT_SIZE
-1);
1586 port
->xmit_cnt
+= c
;
1587 restore_flags(flags
);
1595 if (port
->xmit_cnt
&& !tty
->stopped
&& !tty
->hw_stopped
&&
1596 !(port
->SRER
& SRER_TXRDY
)) {
1597 port
->SRER
|= SRER_TXRDY
;
1598 sbus_writeb(port_No(port
) & 7,
1599 &bp
->r
[chip
]->r
[CD180_CAR
]);
1601 sbus_writeb(port
->SRER
, &bp
->r
[chip
]->r
[CD180_SRER
]);
1603 restore_flags(flags
);
1605 printk("aurora_write: end %d\n",total
);
1610 static void aurora_put_char(struct tty_struct
* tty
, unsigned char ch
)
1612 struct Aurora_port
*port
= (struct Aurora_port
*) tty
->driver_data
;
1613 unsigned long flags
;
1616 printk("aurora_put_char: start %c\n",ch
);
1618 if ((aurora_paranoia_check(port
, tty
->name
, "aurora_put_char"))
1621 if (!tty
|| !port
->xmit_buf
)
1624 save_flags(flags
); cli();
1626 if (port
->xmit_cnt
>= SERIAL_XMIT_SIZE
- 1) {
1627 restore_flags(flags
);
1631 port
->xmit_buf
[port
->xmit_head
++] = ch
;
1632 port
->xmit_head
&= SERIAL_XMIT_SIZE
- 1;
1634 restore_flags(flags
);
1636 printk("aurora_put_char: end\n");
1640 static void aurora_flush_chars(struct tty_struct
* tty
)
1642 struct Aurora_port
*port
= (struct Aurora_port
*) tty
->driver_data
;
1643 unsigned long flags
;
1646 /*#ifdef AURORA_DEBUG
1647 printk("aurora_flush_chars: start\n");
1649 if ((aurora_paranoia_check(port
, tty
->name
, "aurora_flush_chars"))
1652 chip
= AURORA_CD180(port_No(port
));
1654 if (port
->xmit_cnt
<= 0 || tty
->stopped
|| tty
->hw_stopped
||
1658 save_flags(flags
); cli();
1659 port
->SRER
|= SRER_TXRDY
;
1660 sbus_writeb(port_No(port
) & 7,
1661 &port_Board(port
)->r
[chip
]->r
[CD180_CAR
]);
1663 sbus_writeb(port
->SRER
,
1664 &port_Board(port
)->r
[chip
]->r
[CD180_SRER
]);
1665 restore_flags(flags
);
1666 /*#ifdef AURORA_DEBUG
1667 printk("aurora_flush_chars: end\n");
1671 static int aurora_write_room(struct tty_struct
* tty
)
1673 struct Aurora_port
*port
= (struct Aurora_port
*) tty
->driver_data
;
1677 printk("aurora_write_room: start\n");
1679 if ((aurora_paranoia_check(port
, tty
->name
, "aurora_write_room"))
1682 ret
= SERIAL_XMIT_SIZE
- port
->xmit_cnt
- 1;
1686 printk("aurora_write_room: end\n");
1691 static int aurora_chars_in_buffer(struct tty_struct
*tty
)
1693 struct Aurora_port
*port
= (struct Aurora_port
*) tty
->driver_data
;
1695 if ((aurora_paranoia_check(port
, tty
->name
, "aurora_chars_in_buffer"))
1698 return port
->xmit_cnt
;
1701 static void aurora_flush_buffer(struct tty_struct
*tty
)
1703 struct Aurora_port
*port
= (struct Aurora_port
*) tty
->driver_data
;
1704 unsigned long flags
;
1707 printk("aurora_flush_buffer: start\n");
1709 if ((aurora_paranoia_check(port
, tty
->name
, "aurora_flush_buffer"))
1712 save_flags(flags
); cli();
1713 port
->xmit_cnt
= port
->xmit_head
= port
->xmit_tail
= 0;
1714 restore_flags(flags
);
1718 printk("aurora_flush_buffer: end\n");
1722 static int aurora_tiocmget(struct tty_struct
*tty
, struct file
*file
)
1724 struct Aurora_port
*port
= (struct Aurora_port
*) tty
->driver_data
;
1725 struct Aurora_board
* bp
;
1726 unsigned char status
,chip
;
1727 unsigned int result
;
1728 unsigned long flags
;
1731 printk("aurora_get_modem_info: start\n");
1733 if ((aurora_paranoia_check(port
, tty
->name
, __FUNCTION__
))
1736 chip
= AURORA_CD180(port_No(port
));
1738 bp
= port_Board(port
);
1740 save_flags(flags
); cli();
1742 sbus_writeb(port_No(port
) & 7, &bp
->r
[chip
]->r
[CD180_CAR
]);
1745 status
= sbus_readb(&bp
->r
[chip
]->r
[CD180_MSVR
]);
1746 result
= 0/*bp->r[chip]->r[AURORA_RI] & (1u << port_No(port)) ? 0 : TIOCM_RNG*/;
1748 restore_flags(flags
);
1750 result
|= ((status
& bp
->RTS
) ? TIOCM_RTS
: 0)
1751 | ((status
& bp
->DTR
) ? TIOCM_DTR
: 0)
1752 | ((status
& MSVR_CD
) ? TIOCM_CAR
: 0)
1753 | ((status
& MSVR_DSR
) ? TIOCM_DSR
: 0)
1754 | ((status
& MSVR_CTS
) ? TIOCM_CTS
: 0);
1757 printk("aurora_get_modem_info: end\n");
1762 static int aurora_tiocmset(struct tty_struct
*tty
, struct file
*file
,
1763 unsigned int set
, unsigned int clear
)
1765 struct Aurora_port
*port
= (struct Aurora_port
*) tty
->driver_data
;
1767 unsigned long flags
;
1768 struct Aurora_board
*bp
= port_Board(port
);
1772 printk("aurora_set_modem_info: start\n");
1774 if ((aurora_paranoia_check(port
, tty
->name
, __FUNCTION__
))
1777 chip
= AURORA_CD180(port_No(port
));
1779 save_flags(flags
); cli();
1780 if (set
& TIOCM_RTS
)
1781 port
->MSVR
|= bp
->RTS
;
1782 if (set
& TIOCM_DTR
)
1783 port
->MSVR
|= bp
->DTR
;
1784 if (clear
& TIOCM_RTS
)
1785 port
->MSVR
&= ~bp
->RTS
;
1786 if (clear
& TIOCM_DTR
)
1787 port
->MSVR
&= ~bp
->DTR
;
1789 sbus_writeb(port_No(port
) & 7, &bp
->r
[chip
]->r
[CD180_CAR
]);
1792 sbus_writeb(port
->MSVR
, &bp
->r
[chip
]->r
[CD180_MSVR
]);
1794 restore_flags(flags
);
1796 printk("aurora_set_modem_info: end\n");
1801 static void aurora_send_break(struct Aurora_port
* port
, unsigned long length
)
1803 struct Aurora_board
*bp
= port_Board(port
);
1804 unsigned long flags
;
1808 printk("aurora_send_break: start\n");
1810 chip
= AURORA_CD180(port_No(port
));
1812 save_flags(flags
); cli();
1814 port
->break_length
= AURORA_TPS
/ HZ
* length
;
1815 port
->COR2
|= COR2_ETC
;
1816 port
->SRER
|= SRER_TXRDY
;
1817 sbus_writeb(port_No(port
) & 7, &bp
->r
[chip
]->r
[CD180_CAR
]);
1820 sbus_writeb(port
->COR2
, &bp
->r
[chip
]->r
[CD180_COR2
]);
1821 sbus_writeb(port
->SRER
, &bp
->r
[chip
]->r
[CD180_SRER
]);
1822 aurora_wait_CCR(bp
->r
[chip
]);
1824 sbus_writeb(CCR_CORCHG2
, &bp
->r
[chip
]->r
[CD180_CCR
]);
1825 aurora_wait_CCR(bp
->r
[chip
]);
1827 restore_flags(flags
);
1829 printk("aurora_send_break: end\n");
1833 static int aurora_set_serial_info(struct Aurora_port
* port
,
1834 struct serial_struct
* newinfo
)
1836 struct serial_struct tmp
;
1837 struct Aurora_board
*bp
= port_Board(port
);
1839 unsigned long flags
;
1842 printk("aurora_set_serial_info: start\n");
1844 if (copy_from_user(&tmp
, newinfo
, sizeof(tmp
)))
1847 if ((tmp
.irq
!= bp
->irq
) ||
1848 (tmp
.port
!= bp
->base
) ||
1849 (tmp
.type
!= PORT_CIRRUS
) ||
1850 (tmp
.baud_base
!= (bp
->oscfreq
+ CD180_TPC
/2) / CD180_TPC
) ||
1851 (tmp
.custom_divisor
!= 0) ||
1852 (tmp
.xmit_fifo_size
!= CD180_NFIFO
) ||
1853 (tmp
.flags
& ~AURORA_LEGAL_FLAGS
))
1857 change_speed
= ((port
->flags
& ASYNC_SPD_MASK
) !=
1858 (tmp
.flags
& ASYNC_SPD_MASK
));
1860 if (!capable(CAP_SYS_ADMIN
)) {
1861 if ((tmp
.close_delay
!= port
->close_delay
) ||
1862 (tmp
.closing_wait
!= port
->closing_wait
) ||
1863 ((tmp
.flags
& ~ASYNC_USR_MASK
) !=
1864 (port
->flags
& ~ASYNC_USR_MASK
)))
1866 port
->flags
= ((port
->flags
& ~ASYNC_USR_MASK
) |
1867 (tmp
.flags
& ASYNC_USR_MASK
));
1869 port
->flags
= ((port
->flags
& ~ASYNC_FLAGS
) |
1870 (tmp
.flags
& ASYNC_FLAGS
));
1871 port
->close_delay
= tmp
.close_delay
;
1872 port
->closing_wait
= tmp
.closing_wait
;
1875 save_flags(flags
); cli();
1876 aurora_change_speed(bp
, port
);
1877 restore_flags(flags
);
1880 printk("aurora_set_serial_info: end\n");
1885 extern int aurora_get_serial_info(struct Aurora_port
* port
,
1886 struct serial_struct
* retinfo
)
1888 struct serial_struct tmp
;
1889 struct Aurora_board
*bp
= port_Board(port
);
1892 printk("aurora_get_serial_info: start\n");
1894 if (!access_ok(VERIFY_WRITE
, (void *) retinfo
, sizeof(tmp
)))
1897 memset(&tmp
, 0, sizeof(tmp
));
1898 tmp
.type
= PORT_CIRRUS
;
1899 tmp
.line
= port
- aurora_port
;
1902 tmp
.flags
= port
->flags
;
1903 tmp
.baud_base
= (bp
->oscfreq
+ CD180_TPC
/2) / CD180_TPC
;
1904 tmp
.close_delay
= port
->close_delay
* HZ
/100;
1905 tmp
.closing_wait
= port
->closing_wait
* HZ
/100;
1906 tmp
.xmit_fifo_size
= CD180_NFIFO
;
1907 copy_to_user(retinfo
, &tmp
, sizeof(tmp
));
1909 printk("aurora_get_serial_info: end\n");
1914 static int aurora_ioctl(struct tty_struct
* tty
, struct file
* filp
,
1915 unsigned int cmd
, unsigned long arg
)
1918 struct Aurora_port
*port
= (struct Aurora_port
*) tty
->driver_data
;
1922 printk("aurora_ioctl: start\n");
1924 if ((aurora_paranoia_check(port
, tty
->name
, "aurora_ioctl"))
1928 case TCSBRK
: /* SVID version: non-zero arg --> no break */
1929 retval
= tty_check_change(tty
);
1932 tty_wait_until_sent(tty
, 0);
1934 aurora_send_break(port
, HZ
/4); /* 1/4 second */
1936 case TCSBRKP
: /* support for POSIX tcsendbreak() */
1937 retval
= tty_check_change(tty
);
1940 tty_wait_until_sent(tty
, 0);
1941 aurora_send_break(port
, arg
? arg
*(HZ
/10) : HZ
/4);
1944 return put_user(C_CLOCAL(tty
) ? 1 : 0, (unsigned long *)arg
);
1946 if (get_user(arg
,(unsigned long *)arg
))
1948 tty
->termios
->c_cflag
=
1949 ((tty
->termios
->c_cflag
& ~CLOCAL
) |
1950 (arg
? CLOCAL
: 0));
1953 return aurora_get_serial_info(port
, (struct serial_struct
*) arg
);
1955 return aurora_set_serial_info(port
, (struct serial_struct
*) arg
);
1957 return -ENOIOCTLCMD
;
1960 printk("aurora_ioctl: end\n");
1965 static void aurora_throttle(struct tty_struct
* tty
)
1967 struct Aurora_port
*port
= (struct Aurora_port
*) tty
->driver_data
;
1968 struct Aurora_board
*bp
;
1969 unsigned long flags
;
1973 printk("aurora_throttle: start\n");
1975 if ((aurora_paranoia_check(port
, tty
->name
, "aurora_throttle"))
1978 bp
= port_Board(port
);
1979 chip
= AURORA_CD180(port_No(port
));
1981 save_flags(flags
); cli();
1982 port
->MSVR
&= ~bp
->RTS
;
1983 sbus_writeb(port_No(port
) & 7, &bp
->r
[chip
]->r
[CD180_CAR
]);
1986 aurora_wait_CCR(bp
->r
[chip
]);
1987 sbus_writeb(CCR_SSCH2
, &bp
->r
[chip
]->r
[CD180_CCR
]);
1988 aurora_wait_CCR(bp
->r
[chip
]);
1990 sbus_writeb(port
->MSVR
, &bp
->r
[chip
]->r
[CD180_MSVR
]);
1991 restore_flags(flags
);
1993 printk("aurora_throttle: end\n");
1997 static void aurora_unthrottle(struct tty_struct
* tty
)
1999 struct Aurora_port
*port
= (struct Aurora_port
*) tty
->driver_data
;
2000 struct Aurora_board
*bp
;
2001 unsigned long flags
;
2005 printk("aurora_unthrottle: start\n");
2007 if ((aurora_paranoia_check(port
, tty
->name
, "aurora_unthrottle"))
2010 bp
= port_Board(port
);
2012 chip
= AURORA_CD180(port_No(port
));
2014 save_flags(flags
); cli();
2015 port
->MSVR
|= bp
->RTS
;
2016 sbus_writeb(port_No(port
) & 7,
2017 &bp
->r
[chip
]->r
[CD180_CAR
]);
2020 aurora_wait_CCR(bp
->r
[chip
]);
2021 sbus_writeb(CCR_SSCH1
,
2022 &bp
->r
[chip
]->r
[CD180_CCR
]);
2023 aurora_wait_CCR(bp
->r
[chip
]);
2025 sbus_writeb(port
->MSVR
, &bp
->r
[chip
]->r
[CD180_MSVR
]);
2026 restore_flags(flags
);
2028 printk("aurora_unthrottle: end\n");
2032 static void aurora_stop(struct tty_struct
* tty
)
2034 struct Aurora_port
*port
= (struct Aurora_port
*) tty
->driver_data
;
2035 struct Aurora_board
*bp
;
2036 unsigned long flags
;
2040 printk("aurora_stop: start\n");
2042 if ((aurora_paranoia_check(port
, tty
->name
, "aurora_stop"))
2045 bp
= port_Board(port
);
2047 chip
= AURORA_CD180(port_No(port
));
2049 save_flags(flags
); cli();
2050 port
->SRER
&= ~SRER_TXRDY
;
2051 sbus_writeb(port_No(port
) & 7,
2052 &bp
->r
[chip
]->r
[CD180_CAR
]);
2054 sbus_writeb(port
->SRER
,
2055 &bp
->r
[chip
]->r
[CD180_SRER
]);
2056 restore_flags(flags
);
2058 printk("aurora_stop: end\n");
2062 static void aurora_start(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_start: start\n");
2072 if ((aurora_paranoia_check(port
, tty
->name
, "aurora_start"))
2075 bp
= port_Board(port
);
2077 chip
= AURORA_CD180(port_No(port
));
2079 save_flags(flags
); cli();
2080 if (port
->xmit_cnt
&& port
->xmit_buf
&& !(port
->SRER
& SRER_TXRDY
)) {
2081 port
->SRER
|= SRER_TXRDY
;
2082 sbus_writeb(port_No(port
) & 7,
2083 &bp
->r
[chip
]->r
[CD180_CAR
]);
2085 sbus_writeb(port
->SRER
,
2086 &bp
->r
[chip
]->r
[CD180_SRER
]);
2088 restore_flags(flags
);
2090 printk("aurora_start: end\n");
2095 * This routine is called from the scheduler tqueue when the interrupt
2096 * routine has signalled that a hangup has occurred. The path of
2097 * hangup processing is:
2099 * serial interrupt routine -> (scheduler tqueue) ->
2100 * do_aurora_hangup() -> tty->hangup() -> aurora_hangup()
2103 static void do_aurora_hangup(void *private_
)
2105 struct Aurora_port
*port
= (struct Aurora_port
*) private_
;
2106 struct tty_struct
*tty
;
2109 printk("do_aurora_hangup: start\n");
2113 tty_hangup(tty
); /* FIXME: module removal race - AKPM */
2115 printk("do_aurora_hangup: end\n");
2120 static void aurora_hangup(struct tty_struct
* tty
)
2122 struct Aurora_port
*port
= (struct Aurora_port
*) tty
->driver_data
;
2123 struct Aurora_board
*bp
;
2126 printk("aurora_hangup: start\n");
2128 if ((aurora_paranoia_check(port
, tty
->name
, "aurora_hangup"))
2131 bp
= port_Board(port
);
2133 aurora_shutdown_port(bp
, port
);
2136 port
->flags
&= ~ASYNC_NORMAL_ACTIVE
;
2138 wake_up_interruptible(&port
->open_wait
);
2140 printk("aurora_hangup: end\n");
2144 static void aurora_set_termios(struct tty_struct
* tty
, struct termios
* old_termios
)
2146 struct Aurora_port
*port
= (struct Aurora_port
*) tty
->driver_data
;
2147 unsigned long flags
;
2150 printk("aurora_set_termios: start\n");
2152 if ((aurora_paranoia_check(port
, tty
->name
, "aurora_set_termios"))
2155 if (tty
->termios
->c_cflag
== old_termios
->c_cflag
&&
2156 tty
->termios
->c_iflag
== old_termios
->c_iflag
)
2159 save_flags(flags
); cli();
2160 aurora_change_speed(port_Board(port
), port
);
2161 restore_flags(flags
);
2163 if ((old_termios
->c_cflag
& CRTSCTS
) &&
2164 !(tty
->termios
->c_cflag
& CRTSCTS
)) {
2165 tty
->hw_stopped
= 0;
2169 printk("aurora_set_termios: end\n");
2173 static void do_aurora_bh(void)
2175 run_task_queue(&tq_aurora
);
2178 static void do_softint(void *private_
)
2180 struct Aurora_port
*port
= (struct Aurora_port
*) private_
;
2181 struct tty_struct
*tty
;
2184 printk("do_softint: start\n");
2190 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP
, &port
->event
)) {
2194 printk("do_softint: end\n");
2198 static struct tty_operations aurora_ops
= {
2199 .open
= aurora_open
,
2200 .close
= aurora_close
,
2201 .write
= aurora_write
,
2202 .put_char
= aurora_put_char
,
2203 .flush_chars
= aurora_flush_chars
,
2204 .write_room
= aurora_write_room
,
2205 .chars_in_buffer
= aurora_chars_in_buffer
,
2206 .flush_buffer
= aurora_flush_buffer
,
2207 .ioctl
= aurora_ioctl
,
2208 .throttle
= aurora_throttle
,
2209 .unthrottle
= aurora_unthrottle
,
2210 .set_termios
= aurora_set_termios
,
2211 .stop
= aurora_stop
,
2212 .start
= aurora_start
,
2213 .hangup
= aurora_hangup
,
2214 .tiocmget
= aurora_tiocmget
,
2215 .tiocmset
= aurora_tiocmset
,
2218 static int aurora_init_drivers(void)
2224 printk("aurora_init_drivers: start\n");
2226 tmp_buf
= (unsigned char *) get_zeroed_page(GFP_KERNEL
);
2227 if (tmp_buf
== NULL
) {
2228 printk(KERN_ERR
"aurora: Couldn't get free page.\n");
2231 init_bh(AURORA_BH
, do_aurora_bh
);
2232 aurora_driver
= alloc_tty_driver(AURORA_INPORTS
);
2233 if (!aurora_driver
) {
2234 printk(KERN_ERR
"aurora: Couldn't allocate tty driver.\n");
2235 free_page((unsigned long) tmp_buf
);
2238 aurora_driver
->owner
= THIS_MODULE
;
2239 aurora_driver
->name
= "ttyA";
2240 aurora_driver
->major
= AURORA_MAJOR
;
2241 aurora_driver
->type
= TTY_DRIVER_TYPE_SERIAL
;
2242 aurora_driver
->subtype
= SERIAL_TYPE_NORMAL
;
2243 aurora_driver
->init_termios
= tty_std_termios
;
2244 aurora_driver
->init_termios
.c_cflag
=
2245 B9600
| CS8
| CREAD
| HUPCL
| CLOCAL
;
2246 aurora_driver
->flags
= TTY_DRIVER_REAL_RAW
;
2247 tty_set_operations(aurora_driver
, &aurora_ops
);
2248 error
= tty_register_driver(aurora_driver
);
2250 put_tty_driver(aurora_driver
);
2251 free_page((unsigned long) tmp_buf
);
2252 printk(KERN_ERR
"aurora: Couldn't register aurora driver, error = %d\n",
2257 memset(aurora_port
, 0, sizeof(aurora_port
));
2258 for (i
= 0; i
< AURORA_TNPORTS
; i
++) {
2259 aurora_port
[i
].magic
= AURORA_MAGIC
;
2260 aurora_port
[i
].tqueue
.routine
= do_softint
;
2261 aurora_port
[i
].tqueue
.data
= &aurora_port
[i
];
2262 aurora_port
[i
].tqueue_hangup
.routine
= do_aurora_hangup
;
2263 aurora_port
[i
].tqueue_hangup
.data
= &aurora_port
[i
];
2264 aurora_port
[i
].close_delay
= 50 * HZ
/100;
2265 aurora_port
[i
].closing_wait
= 3000 * HZ
/100;
2266 init_waitqueue_head(&aurora_port
[i
].open_wait
);
2267 init_waitqueue_head(&aurora_port
[i
].close_wait
);
2270 printk("aurora_init_drivers: end\n");
2275 static void aurora_release_drivers(void)
2278 printk("aurora_release_drivers: start\n");
2280 free_page((unsigned long)tmp_buf
);
2281 tty_unregister_driver(aurora_driver
);
2282 put_tty_driver(aurora_driver
);
2284 printk("aurora_release_drivers: end\n");
2289 * Called at boot time.
2291 * You can specify IO base for up to RC_NBOARD cards,
2292 * using line "riscom8=0xiobase1,0xiobase2,.." at LILO prompt.
2293 * Note that there will be no probing at default
2294 * addresses in this case.
2297 void __init
aurora_setup(char *str
, int *ints
)
2301 for(i
=0;(i
<ints
[0])&&(i
<4);i
++) {
2302 if (ints
[i
+1]) irqs
[i
]=ints
[i
+1];
2306 static int __init
aurora_real_init(void)
2311 printk(KERN_INFO
"aurora: Driver starting.\n");
2312 if(aurora_init_drivers())
2314 found
= aurora_probe();
2316 aurora_release_drivers();
2317 printk(KERN_INFO
"aurora: No Aurora Multiport boards detected.\n");
2320 printk(KERN_INFO
"aurora: %d boards found.\n", found
);
2322 for (i
= 0; i
< found
; i
++) {
2323 int ret
= aurora_setup_board(&aurora_board
[i
]);
2327 printk(KERN_ERR
"aurora_init: error aurora_setup_board ret %d\n",
2340 module_param(irq
, int, 0);
2341 module_param(irq1
, int, 0);
2342 module_param(irq2
, int, 0);
2343 module_param(irq3
, int, 0);
2345 static int __init
aurora_init(void)
2347 if (irq
) irqs
[0]=irq
;
2348 if (irq1
) irqs
[1]=irq1
;
2349 if (irq2
) irqs
[2]=irq2
;
2350 if (irq3
) irqs
[3]=irq3
;
2351 return aurora_real_init();
2354 static void __exit
aurora_cleanup(void)
2359 printk("cleanup_module: aurora_release_drivers\n");
2362 aurora_release_drivers();
2363 for (i
= 0; i
< AURORA_NBOARD
; i
++)
2364 if (aurora_board
[i
].flags
& AURORA_BOARD_PRESENT
) {
2365 aurora_shutdown_board(&aurora_board
[i
]);
2366 aurora_release_io_range(&aurora_board
[i
]);
2370 module_init(aurora_init
);
2371 module_exit(aurora_cleanup
);
2372 MODULE_LICENSE("GPL");