2 * linux/drivers/sbus/char/aurora.c -- Aurora multiport driver
4 * Copyright (c) 1999 by Oliver Aldulea (oli@bv.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.
38 #include <linux/module.h>
40 #include <linux/errno.h>
41 #include <linux/sched.h>
42 #ifdef AURORA_INT_DEBUG
43 #include <linux/timer.h>
45 #include <linux/interrupt.h>
46 #include <linux/tty.h>
47 #include <linux/tty_flip.h>
48 #include <linux/major.h>
49 #include <linux/string.h>
50 #include <linux/fcntl.h>
52 #include <linux/kernel.h>
53 #include <linux/init.h>
54 #include <linux/tqueue.h>
55 #include <linux/delay.h>
59 #include <asm/oplib.h>
60 #include <asm/system.h>
61 #include <asm/segment.h>
62 #include <asm/bitops.h>
63 #include <asm/kdebug.h>
65 #include <asm/uaccess.h>
70 unsigned char irqs
[4] = {
74 #ifdef AURORA_INT_DEBUG
79 #define MIN(a,b) ((a) < (b) ? (a) : (b))
82 #define AURORA_TYPE_NORMAL 1
84 static struct tty_driver aurora_driver
;
85 static struct Aurora_board aurora_board
[AURORA_NBOARD
] = {
89 static struct Aurora_port aurora_port
[AURORA_TNPORTS
] = {
93 /* no longer used. static struct Aurora_board * IRQ_to_board[16] = { NULL, } ;*/
94 static unsigned char * tmp_buf
= NULL
;
95 static DECLARE_MUTEX(tmp_buf_sem
);
96 static int aurora_refcount
= 0;
97 static struct tty_struct
* aurora_table
[AURORA_TNPORTS
] = { NULL
, };
98 static struct termios
* aurora_termios
[AURORA_TNPORTS
] = { NULL
, };
99 static struct termios
* aurora_termios_locked
[AURORA_TNPORTS
] = { NULL
, };
101 DECLARE_TASK_QUEUE(tq_aurora
);
103 /* Yes, the board can support 115.2 bit rates, but only on a few ports. The
104 * total badwidth of one chip (ports 0-7 or 8-15) is equal to OSC_FREQ div
105 * 16. In case of my board, each chip can take 6 channels of 115.2 kbaud.
106 * This information is not well-tested.
108 static unsigned long baud_table
[] = {
109 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
110 9600, 19200, 38400, 57600, 115200, 0,
113 static inline int aurora_paranoia_check(struct Aurora_port
const * port
,
114 kdev_t device
, const char *routine
)
116 #ifdef AURORA_PARANOIA_CHECK
117 static const char *badmagic
=
118 KERN_DEBUG
"aurora: Warning: bad aurora port magic number for device %s in %s\n";
119 static const char *badinfo
=
120 KERN_DEBUG
"aurora: Warning: null aurora port for device %s in %s\n";
123 printk(badinfo
, kdevname(device
), routine
);
126 if (port
->magic
!= AURORA_MAGIC
) {
127 printk(badmagic
, kdevname(device
), routine
);
136 * Service functions for aurora driver.
140 /* Get board number from pointer */
141 extern inline int board_No (struct Aurora_board
const * bp
)
143 return bp
- aurora_board
;
146 /* Get port number from pointer */
147 extern inline int port_No (struct Aurora_port
const * port
)
149 return AURORA_PORT(port
- aurora_port
);
152 /* Get pointer to board from pointer to port */
153 extern inline struct Aurora_board
* port_Board(struct Aurora_port
const * port
)
155 return &aurora_board
[AURORA_BOARD(port
- aurora_port
)];
158 /* Wait for Channel Command Register ready */
159 extern inline void aurora_wait_CCR(struct aurora_reg128
* r
)
164 printk("aurora_wait_CCR\n");
166 /* FIXME: need something more descriptive than 100000 :) */
167 for (delay
= 100000; delay
; delay
--)
168 if (!r
->r
[CD180_CCR
])
170 printk(KERN_DEBUG
"aurora: Timeout waiting for CCR.\n");
174 * aurora probe functions.
177 /* Must be called with enabled interrupts */
178 extern inline void aurora_long_delay(unsigned long delay
)
182 printk("aurora_long_delay: start\n");
184 for (i
= jiffies
+ delay
; i
> jiffies
; ) ;
186 printk("aurora_long_delay: end\n");
190 /* Reset and setup CD180 chip */
191 static int aurora_init_CD180(struct Aurora_board
* bp
, int chip
)
197 printk("aurora_init_CD180: start %d:%d\n",board_No(bp
),chip
);
199 save_flags(flags
); cli();
200 bp
->r
[chip
]->r
[CD180_CAR
]=0;
201 bp
->r
[chip
]->r
[CD180_GSVR
]=0;
202 aurora_wait_CCR(bp
->r
[chip
]); /* Wait for CCR ready */
203 bp
->r
[chip
]->r
[CD180_CCR
]=CCR_HARDRESET
; /* Reset CD180 chip */
207 while((--id
)&&(bp
->r
[chip
]->r
[CD180_GSVR
]!=0xff))udelay(100);
209 printk(KERN_ERR
"aurora%d: Chip %d failed init.\n",board_No(bp
),chip
);
210 restore_flags(flags
);
214 bp
->r
[chip
]->r
[CD180_GSVR
]=(board_No(bp
)<<5)|((chip
+1)<<3); /* Set ID for this chip */
215 bp
->r
[chip
]->r
[CD180_MSMR
]=0x80|bp
->ACK_MINT
; /* Prio for modem intr */
216 bp
->r
[chip
]->r
[CD180_TSMR
]=0x80|bp
->ACK_TINT
; /* Prio for transmitter intr */
217 bp
->r
[chip
]->r
[CD180_RSMR
]=0x80|bp
->ACK_RINT
; /* Prio for receiver intr */
218 /* Setting up prescaler. We need 4 tick per 1 ms */
219 bp
->r
[chip
]->r
[CD180_PPRH
]=(bp
->oscfreq
/(1000000/AURORA_TPS
)) >> 8;
220 bp
->r
[chip
]->r
[CD180_PPRL
]=(bp
->oscfreq
/(1000000/AURORA_TPS
)) & 0xff;
222 bp
->r
[chip
]->r
[CD180_SRCR
]=SRCR_AUTOPRI
|SRCR_GLOBPRI
;
224 id
=bp
->r
[chip
]->r
[CD180_GFRCR
];
225 printk(KERN_INFO
"aurora%d: Chip %d id %02x: ",board_No(bp
),chip
,id
);
226 if(bp
->r
[chip
]->r
[CD180_SRCR
]&128)
228 case 0x82:printk("CL-CD1864 rev A\n");break;
229 case 0x83:printk("CL-CD1865 rev A\n");break;
230 case 0x84:printk("CL-CD1865 rev B\n");break;
231 case 0x85:printk("CL-CD1865 rev C\n");break;
232 default:printk("Unknown.\n");
235 case 0x81:printk("CL-CD180 rev B\n");break;
236 case 0x82:printk("CL-CD180 rev C\n");break;
237 default:printk("Unknown.\n");
239 restore_flags(flags
);
241 printk("aurora_init_CD180: end\n");
246 static int valid_irq(unsigned char irq
)
249 for(i
=0;i
<TYPE_1_IRQS
;i
++)
250 if (type_1_irq
[i
]==irq
) return 1;
254 static void aurora_interrupt(int irq
, void * dev_id
, struct pt_regs
* regs
);
256 /* Main probing routine, also sets irq. */
257 static int aurora_probe(void) {
258 struct linux_sbus
*sbus
;
259 struct linux_sbus_device
*sdev
;
263 struct Aurora_board
*bp
;
265 for_each_sbus(sbus
) {
266 for_each_sbusdev(sdev
, sbus
) {
267 /* printk("Try: %x %s\n",sdev,sdev->prom_name);*/
268 if (!strcmp(sdev
->prom_name
, "sio16")) {
270 printk(KERN_INFO
"aurora: sio16 at %p\n",sdev
);
272 prom_apply_sbus_ranges(sdev
->my_bus
, sdev
->reg_addrs
, sdev
->num_registers
, sdev
);
273 if((sdev
->reg_addrs
[0].reg_size
!=1)&&(sdev
->reg_addrs
[1].reg_size
!=128)&&
274 (sdev
->reg_addrs
[2].reg_size
!=128)&&(sdev
->reg_addrs
[3].reg_size
!=4)){
275 printk(KERN_ERR
"aurora%d: registers' sizes do not match.\n",bn
);
278 bp
=&aurora_board
[bn
];
279 bp
->r0
= (struct aurora_reg1
*) sparc_alloc_io(sdev
->reg_addrs
[0].phys_addr
, 0,
280 sdev
->reg_addrs
[0].reg_size
, "sio16",sdev
->reg_addrs
[0].which_io
, 0x0);
282 printk(KERN_ERR
"aurora%d: can't map reg_addrs[0]\n",bn
);
286 printk("Map reg 0: %x\n",bp
->r0
);
288 bp
->r
[0] = (struct aurora_reg128
*) sparc_alloc_io(sdev
->reg_addrs
[1].phys_addr
, 0,
289 sdev
->reg_addrs
[1].reg_size
, "sio16", sdev
->reg_addrs
[1].which_io
, 0x0);
291 printk(KERN_ERR
"aurora%d: can't map reg_addrs[1]\n",bn
);
295 printk("Map reg 1: %x\n",bp
->r
[0]);
297 bp
->r
[1] = (struct aurora_reg128
*) sparc_alloc_io(sdev
->reg_addrs
[2].phys_addr
, 0,
298 sdev
->reg_addrs
[2].reg_size
, "sio16", sdev
->reg_addrs
[2].which_io
, 0x0);
300 printk(KERN_ERR
"aurora%d: can't map reg_addrs[2]\n",bn
);
304 printk("Map reg 2: %x\n",bp
->r
[1]);
306 bp
->r3
= (struct aurora_reg4
*) sparc_alloc_io(sdev
->reg_addrs
[3].phys_addr
, 0,
307 sdev
->reg_addrs
[3].reg_size
, "sio16", sdev
->reg_addrs
[3].which_io
, 0x0);
309 printk(KERN_ERR
"aurora%d: can't map reg_addrs[3]\n",bn
);
313 printk("Map reg 3: %x\n",bp
->r3
);
315 /* Variables setup */
318 grrr
=prom_getint(sdev
->prom_node
,"intr");
319 printk("intr pri %d\n",grrr
);
321 if ((bp
->irq
=irqs
[bn
]) && valid_irq(bp
->irq
) &&
322 !request_irq(bp
->irq
|0x30, aurora_interrupt
, SA_SHIRQ
, "sio16", bp
)) {
323 free_irq(bp
->irq
|0x30, bp
);
325 if ((bp
->irq
=prom_getint(sdev
->prom_node
, "bintr")) && valid_irq(bp
->irq
) &&
326 !request_irq(bp
->irq
|0x30, aurora_interrupt
, SA_SHIRQ
, "sio16", bp
)) {
327 free_irq(bp
->irq
|0x30, bp
);
329 if ((bp
->irq
=prom_getint(sdev
->prom_node
, "intr")) && valid_irq(bp
->irq
) &&
330 !request_irq(bp
->irq
|0x30, aurora_interrupt
, SA_SHIRQ
, "sio16", bp
)) {
331 free_irq(bp
->irq
|0x30, bp
);
333 for(grrr
=0;grrr
<TYPE_1_IRQS
;grrr
++) {
334 if ((bp
->irq
=type_1_irq
[grrr
])&&!request_irq(bp
->irq
|0x30, aurora_interrupt
, SA_SHIRQ
, "sio16", bp
)) {
335 free_irq(bp
->irq
|0x30, bp
);
338 printk(KERN_ERR
"aurora%d: Could not get an irq for this board !!!\n",bn
);
342 if(bp
->flags
==0xff)break;
343 printk(KERN_INFO
"aurora%d: irq %d\n",bn
,bp
->irq
&0x0f);
345 grrr
=prom_getproperty(sdev
->prom_node
,"dtr_rts",buf
,sizeof(buf
));
346 if(!strcmp(buf
,"swapped")){
347 printk(KERN_INFO
"aurora%d: Swapped DTR and RTS\n",bn
);
350 bp
->MSVDTR
=CD180_MSVRTS
;
351 bp
->MSVRTS
=CD180_MSVDTR
;
352 bp
->flags
|=AURORA_BOARD_DTR_FLOW_OK
;
354 #ifdef AURORA_FORCE_DTR_FLOW
355 printk(KERN_INFO
"aurora%d: Forcing swapped DTR-RTS\n",bn
);
358 bp
->MSVDTR
=CD180_MSVRTS
;
359 bp
->MSVRTS
=CD180_MSVDTR
;
360 bp
->flags
|=AURORA_BOARD_DTR_FLOW_OK
;
362 printk(KERN_INFO
"aurora%d: Normal DTR and RTS\n",bn
);
365 bp
->MSVDTR
=CD180_MSVDTR
;
366 bp
->MSVRTS
=CD180_MSVRTS
;
369 bp
->oscfreq
=prom_getint(sdev
->prom_node
,"clk")*100;
370 printk(KERN_INFO
"aurora%d: Oscillator: %d Hz\n",bn
,bp
->oscfreq
);
371 grrr
=prom_getproperty(sdev
->prom_node
,"chip",buf
,sizeof(buf
));
372 printk(KERN_INFO
"aurora%d: Chips: %s\n",bn
,buf
);
373 grrr
=prom_getproperty(sdev
->prom_node
,"manu",buf
,sizeof(buf
));
374 printk(KERN_INFO
"aurora%d: Manufacturer: %s\n",bn
,buf
);
375 grrr
=prom_getproperty(sdev
->prom_node
,"model",buf
,sizeof(buf
));
376 printk(KERN_INFO
"aurora%d: Model: %s\n",bn
,buf
);
377 grrr
=prom_getproperty(sdev
->prom_node
,"rev",buf
,sizeof(buf
));
378 printk(KERN_INFO
"aurora%d: Revision: %s\n",bn
,buf
);
379 grrr
=prom_getproperty(sdev
->prom_node
,"mode",buf
,sizeof(buf
));
380 printk(KERN_INFO
"aurora%d: Mode: %s\n",bn
,buf
);
384 bp
->flags
= AURORA_BOARD_PRESENT
;
396 static void aurora_release_io_range(struct Aurora_board
*bp
)
398 sparc_free_io(bp
->r0
,1);
399 sparc_free_io(bp
->r
[0],128);
400 sparc_free_io(bp
->r
[1],128);
401 sparc_free_io(bp
->r3
,4);
404 extern inline void aurora_mark_event(struct Aurora_port
* port
, int event
)
407 printk("aurora_mark_event: start\n");
409 set_bit(event
, &port
->event
);
410 queue_task(&port
->tqueue
, &tq_aurora
);
413 printk("aurora_mark_event: end\n");
417 extern inline struct Aurora_port
* aurora_get_port(struct Aurora_board
const * bp
,
418 int chip
, unsigned char const * what
)
420 unsigned char channel
;
421 struct Aurora_port
* port
;
423 channel
= (chip
<<3)|((bp
->r
[chip
]->r
[CD180_GSCR
]&GSCR_CHAN
)>>GSCR_CHAN_OFF
);
424 port
= &aurora_port
[board_No(bp
) * AURORA_NPORT
* AURORA_NCD180
+ channel
];
425 if (port
->flags
& ASYNC_INITIALIZED
) {
428 printk(KERN_DEBUG
"aurora%d: %s interrupt from invalid port %d\n",
429 board_No(bp
), what
, channel
);
433 extern inline void aurora_receive_exc(struct Aurora_board
const * bp
, int chip
)
435 struct Aurora_port
*port
;
436 struct tty_struct
*tty
;
437 unsigned char status
;
440 if (!(port
= aurora_get_port(bp
, chip
, "Receive_x")))
444 if (tty
->flip
.count
>= TTY_FLIPBUF_SIZE
) {
445 #ifdef AURORA_INTNORM
446 printk("aurora%d: port %d: Working around flip buffer overflow.\n",
447 board_No(bp
), port_No(port
));
452 #ifdef AURORA_REPORT_OVERRUN
453 status
= bp
->r
[chip
]->r
[CD180_RCSR
];
454 if (status
& RCSR_OE
) {
457 printk("aurora%d: port %d: Overrun. Total %ld overruns.\n",
458 board_No(bp
), port_No(port
), port
->overrun
);
461 status
&= port
->mark_mask
;
463 status
= bp
->r
[chip
]->r
[CD180_RCSR
] & port
->mark_mask
;
465 ch
= bp
->r
[chip
]->r
[CD180_RDR
];
469 if (status
& RCSR_TOUT
) {
470 /* printk("aurora%d: port %d: Receiver timeout. Hardware problems ?\n",
471 board_No(bp), port_No(port));*/
474 } else if (status
& RCSR_BREAK
) {
475 printk(KERN_DEBUG
"aurora%d: port %d: Handling break...\n",
476 board_No(bp
), port_No(port
));
477 *tty
->flip
.flag_buf_ptr
++ = TTY_BREAK
;
478 if (port
->flags
& ASYNC_SAK
)
481 } else if (status
& RCSR_PE
)
482 *tty
->flip
.flag_buf_ptr
++ = TTY_PARITY
;
484 else if (status
& RCSR_FE
)
485 *tty
->flip
.flag_buf_ptr
++ = TTY_FRAME
;
487 else if (status
& RCSR_OE
)
488 *tty
->flip
.flag_buf_ptr
++ = TTY_OVERRUN
;
491 *tty
->flip
.flag_buf_ptr
++ = 0;
493 *tty
->flip
.char_buf_ptr
++ = ch
;
495 queue_task(&tty
->flip
.tqueue
, &tq_timer
);
498 extern inline void aurora_receive(struct Aurora_board
const * bp
, int chip
)
500 struct Aurora_port
*port
;
501 struct tty_struct
*tty
;
502 unsigned char count
,cnt
;
504 if (!(port
= aurora_get_port(bp
, chip
, "Receive")))
509 count
= bp
->r
[chip
]->r
[CD180_RDCR
];
511 #ifdef AURORA_REPORT_FIFO
512 port
->hits
[count
> 8 ? 9 : count
]++;
516 if (tty
->flip
.count
>= TTY_FLIPBUF_SIZE
) {
517 #ifdef AURORA_INTNORM
518 printk("aurora%d: port %d: Working around flip buffer overflow.\n",
519 board_No(bp
), port_No(port
));
523 cnt
=bp
->r
[chip
]->r
[CD180_RDR
];
524 *tty
->flip
.char_buf_ptr
++ = cnt
;
525 *tty
->flip
.flag_buf_ptr
++ = 0;
528 queue_task(&tty
->flip
.tqueue
, &tq_timer
);
531 extern inline void aurora_transmit(struct Aurora_board
const * bp
, int chip
)
533 struct Aurora_port
*port
;
534 struct tty_struct
*tty
;
538 if (!(port
= aurora_get_port(bp
, chip
, "Transmit")))
543 if (port
->SRER
& SRER_TXEMPTY
) {
545 bp
->r
[chip
]->r
[CD180_CAR
]=port_No(port
)&7;
547 port
->SRER
&= ~SRER_TXEMPTY
;
548 bp
->r
[chip
]->r
[CD180_SRER
]=port
->SRER
;
552 if ((port
->xmit_cnt
<= 0 && !port
->break_length
)
553 || tty
->stopped
|| tty
->hw_stopped
) {
554 bp
->r
[chip
]->r
[CD180_CAR
]=port_No(port
)&7;
556 port
->SRER
&= ~SRER_TXRDY
;
557 bp
->r
[chip
]->r
[CD180_SRER
]=port
->SRER
;
561 if (port
->break_length
) {
562 if (port
->break_length
> 0) {
563 if (port
->COR2
& COR2_ETC
) {
564 bp
->r
[chip
]->r
[CD180_TDR
]=CD180_C_ESC
;
565 bp
->r
[chip
]->r
[CD180_TDR
]=CD180_C_SBRK
;
566 port
->COR2
&= ~COR2_ETC
;
568 count
= MIN(port
->break_length
, 0xff);
569 bp
->r
[chip
]->r
[CD180_TDR
]=CD180_C_ESC
;
570 bp
->r
[chip
]->r
[CD180_TDR
]=CD180_C_DELAY
;
571 bp
->r
[chip
]->r
[CD180_TDR
]=count
;
572 if (!(port
->break_length
-= count
))
573 port
->break_length
--;
575 bp
->r
[chip
]->r
[CD180_TDR
]=CD180_C_ESC
;
576 bp
->r
[chip
]->r
[CD180_TDR
]=CD180_C_EBRK
;
577 bp
->r
[chip
]->r
[CD180_COR2
]=port
->COR2
;
578 aurora_wait_CCR(bp
->r
[chip
]);
579 bp
->r
[chip
]->r
[CD180_CCR
]=CCR_CORCHG2
;
580 port
->break_length
= 0;
587 bp
->r
[chip
]->r
[CD180_TDR
]=port
->xmit_buf
[port
->xmit_tail
++];
588 port
->xmit_tail
= port
->xmit_tail
& (SERIAL_XMIT_SIZE
-1);
589 if (--port
->xmit_cnt
<= 0)
591 } while (--count
> 0);
593 if (port
->xmit_cnt
<= 0) {
594 bp
->r
[chip
]->r
[CD180_CAR
]=port_No(port
)&7;
596 port
->SRER
&= ~SRER_TXRDY
;
597 bp
->r
[chip
]->r
[CD180_SRER
]=port
->SRER
;
599 if (port
->xmit_cnt
<= port
->wakeup_chars
)
600 aurora_mark_event(port
, RS_EVENT_WRITE_WAKEUP
);
603 extern inline void aurora_check_modem(struct Aurora_board
const * bp
, int chip
)
605 struct Aurora_port
*port
;
606 struct tty_struct
*tty
;
609 if (!(port
= aurora_get_port(bp
, chip
, "Modem")))
614 mcr
= bp
->r
[chip
]->r
[CD180_MCR
];
615 if (mcr
& MCR_CDCHG
) {
616 if (bp
->r
[chip
]->r
[CD180_MSVR
] & MSVR_CD
)
617 wake_up_interruptible(&port
->open_wait
);
618 else if (!((port
->flags
& ASYNC_CALLOUT_ACTIVE
) &&
619 (port
->flags
& ASYNC_CALLOUT_NOHUP
)))
620 queue_task(&port
->tqueue_hangup
,
624 /* 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
625 * Aurora didn't made any boards with CTS or DSR broken...
627 /* #ifdef AURORA_BRAIN_DAMAGED_CTS
628 if (mcr & MCR_CTSCHG) {
629 if (aurora_in(bp, CD180_MSVR) & MSVR_CTS) {
631 port->SRER |= SRER_TXRDY;
632 if (port->xmit_cnt <= port->wakeup_chars)
633 aurora_mark_event(port, RS_EVENT_WRITE_WAKEUP);
636 port->SRER &= ~SRER_TXRDY;
638 bp->r[chip]->r[CD180_SRER, port->SRER);
640 if (mcr & MCR_DSRCHG) {
641 if (aurora_in(bp, CD180_MSVR) & MSVR_DSR) {
643 port->SRER |= SRER_TXRDY;
644 if (port->xmit_cnt <= port->wakeup_chars)
645 aurora_mark_event(port, RS_EVENT_WRITE_WAKEUP);
648 port->SRER &= ~SRER_TXRDY;
650 bp->r[chip]->r[CD180_SRER, port->SRER);
652 #endif AURORA_BRAIN_DAMAGED_CTS */
654 /* Clear change bits */
655 bp
->r
[chip
]->r
[CD180_MCR
]=0;
658 /* The main interrupt processing routine */
659 static void aurora_interrupt(int irq
, void * dev_id
, struct pt_regs
* regs
)
661 unsigned char status
;
662 unsigned char ack
,chip
/*,chip_id*/;
663 struct Aurora_board
* bp
= (struct Aurora_board
*) dev_id
;
664 unsigned long loop
=0;
666 #ifdef AURORA_INT_DEBUG
667 printk("IRQ%d %d\n",irq
,++irqhit
);
668 #ifdef AURORA_FLOODPRO
669 if (irqhit
>=AURORA_FLOODPRO
)
674 /* old bp = IRQ_to_board[irq&0x0f];*/
676 if (!bp
|| !(bp
->flags
& AURORA_BOARD_ACTIVE
)) {
680 /* The while() below takes care of this.
681 status=bp->r[0]->r[CD180_SRSR];
682 #ifdef AURORA_INT_DEBUG
683 printk("mumu: %02x\n",status);
685 if (!(status&SRSR_ANYINT)) return; * Nobody has anything to say, so exit *
687 while ((loop
++ < 48)&&(status
=bp
->r
[0]->r
[CD180_SRSR
]&SRSR_ANYINT
)){
688 #ifdef AURORA_INT_DEBUG
689 printk("SRSR: %02x\n",status
);
691 if (status
&SRSR_REXT
) {
692 ack
=bp
->r3
->r
[bp
->ACK_RINT
];
693 #ifdef AURORA_INT_DEBUG
694 printk("R-ACK %02x\n",ack
);
696 if ((ack
>>5)==board_No(bp
)) {
697 if ((chip
=((ack
>>3)&3)-1) < AURORA_NCD180
) {
698 if ((ack
&GSVR_ITMASK
)==GSVR_IT_RGD
) {
699 aurora_receive(bp
,chip
);
700 bp
->r
[chip
]->r
[CD180_EOSRR
]=0;
702 if ((ack
&GSVR_ITMASK
)==GSVR_IT_REXC
) {
703 aurora_receive_exc(bp
,chip
);
704 bp
->r
[chip
]->r
[CD180_EOSRR
]=0;
709 if (status
&SRSR_TEXT
) {
710 ack
=bp
->r3
->r
[bp
->ACK_TINT
];
711 #ifdef AURORA_INT_DEBUG
712 printk("T-ACK %02x\n",ack
);
714 if ((ack
>>5)==board_No(bp
)) {
715 if ((chip
=((ack
>>3)&3)-1) < AURORA_NCD180
) {
716 if ((ack
&GSVR_ITMASK
)==GSVR_IT_TX
) {
717 aurora_transmit(bp
,chip
);
718 bp
->r
[chip
]->r
[CD180_EOSRR
]=0;
723 if (status
&SRSR_MEXT
) {
724 ack
=bp
->r3
->r
[bp
->ACK_MINT
];
725 #ifdef AURORA_INT_DEBUG
726 printk("M-ACK %02x\n",ack
);
728 if ((ack
>>5)==board_No(bp
)) {
729 if ((chip
=((ack
>>3)&3)-1) < AURORA_NCD180
) {
730 if ((ack
&GSVR_ITMASK
)==GSVR_IT_MDM
) {
731 aurora_check_modem(bp
,chip
);
732 bp
->r
[chip
]->r
[CD180_EOSRR
]=0;
738 /* I guess this faster code can be used with CD1865, using AUROPRI and GLOBPRI.
739 while ((loop++ < 48)&&(status=bp->r[0]->r[CD180_SRSR]&SRSR_ANYINT)){
740 #ifdef AURORA_INT_DEBUG
741 printk("SRSR: %02x\n",status);
744 #ifdef AURORA_INT_DEBUG
745 printk("ACK: %02x\n",ack);
747 if ((ack>>5)==board_No(bp)) {
748 if ((chip=((ack>>3)&3)-1) < AURORA_NCD180) {
750 if (ack==GSVR_IT_RGD) {
751 aurora_receive(bp,chip);
752 bp->r[chip]->r[CD180_EOSRR]=0;
754 if (ack==GSVR_IT_REXC) {
755 aurora_receive_exc(bp,chip);
756 bp->r[chip]->r[CD180_EOSRR]=0;
758 if (ack==GSVR_IT_TX) {
759 aurora_transmit(bp,chip);
760 bp->r[chip]->r[CD180_EOSRR]=0;
762 if (ack==GSVR_IT_MDM) {
763 aurora_check_modem(bp,chip);
764 bp->r[chip]->r[CD180_EOSRR]=0;
770 /* This is the old handling routine, used in riscom8 for only one CD180. I keep it here for reference.
771 for(chip=0;chip<AURORA_NCD180;chip++){
772 chip_id=(board_No(bp)<<5)|((chip+1)<<3);
774 while ((loop++ < 1) && ((status = bp->r[chip]->r[CD180_SRSR]) &
775 (SRSR_TEXT | SRSR_MEXT | SRSR_REXT))) {
777 if (status & SRSR_REXT) {
778 ack = bp->r3->r[bp->ACK_RINT];
779 if (ack == (chip_id | GSVR_IT_RGD)){
783 aurora_receive(bp,chip);
785 else if (ack == (chip_id | GSVR_IT_REXC)){
789 aurora_receive_exc(bp,chip);
792 #ifdef AURORA_INTNORM
793 printk("aurora%d-%d: Bad receive ack 0x%02x.\n",
794 board_No(bp), chip, ack)
798 } else if (status & SRSR_TEXT) {
799 ack = bp->r3->r[bp->ACK_TINT];
800 if (ack == (chip_id | GSVR_IT_TX)){
804 aurora_transmit(bp,chip);
807 #ifdef AURORA_INTNORM
808 printk("aurora%d-%d: Bad transmit ack 0x%02x.\n",
809 board_No(bp), chip, ack);
813 } else if (status & SRSR_MEXT) {
814 ack = bp->r3->r[bp->ACK_MINT];
815 if (ack == (chip_id | GSVR_IT_MDM)){
819 aurora_check_modem(bp,chip);
822 #ifdef AURORA_INTNORM
823 printk("aurora%d-%d: Bad modem ack 0x%02x.\n",
824 board_No(bp), chip, ack)
829 bp->r[chip]->r[CD180_EOSRR]=0;
836 #ifdef AURORA_INT_DEBUG
837 static void aurora_timer (unsigned long ignored
);
839 static struct timer_list
840 aurora_poll_timer
= { NULL
, NULL
, 0, 0, aurora_timer
};
843 aurora_timer (unsigned long ignored
)
848 save_flags(flags
); cli();
850 printk("SRSR: %02x,%02x - ",aurora_board
[0].r
[0]->r
[CD180_SRSR
],aurora_board
[0].r
[1]->r
[CD180_SRSR
]);
853 printk("%02x ",aurora_board
[0].r3
->r
[i
]);
857 aurora_poll_timer
.expires
= jiffies
+ 300;
858 add_timer (&aurora_poll_timer
);
860 restore_flags(flags
);
865 * Routines for open & close processing.
868 /* Called with disabled interrupts */
869 extern inline int aurora_setup_board(struct Aurora_board
* bp
)
875 for(i
=0;i
<AURORA_ALLIRQ
;i
++){
876 error
= request_irq(allirq
[i
]|0x30, aurora_interrupt
, SA_SHIRQ
, "sio16", bp
);
878 printk(KERN_ERR
"IRQ%d request error %d\n",allirq
[i
],error
);
882 error
= request_irq(bp
->irq
|0x30, aurora_interrupt
, SA_SHIRQ
, "sio16", bp
);
884 printk(KERN_ERR
"IRQ request error %d\n",error
);
891 if(bp
->flags
&AURORA_BOARD_TYPE_2
){
894 bp
->r0
->r
=AURORA_CFG_ENABLE_IO
|AURORA_CFG_ENABLE_IRQ
|(((bp
->irq
)&0x0f)>>2);
898 if (aurora_init_CD180(bp
,0))error
=1;error
=0;
899 if (aurora_init_CD180(bp
,1))error
++;
900 if (error
==AURORA_NCD180
) {
901 printk(KERN_ERR
"Both chips failed initialisation.\n");
905 #ifdef AURORA_INT_DEBUG
906 aurora_poll_timer
.expires
=jiffies
+1;
907 add_timer(&aurora_poll_timer
);
910 printk("aurora_setup_board: end\n");
915 /* Called with disabled interrupts */
916 extern inline void aurora_shutdown_board(struct Aurora_board
*bp
)
921 printk("aurora_shutdown_board: start\n");
924 #ifdef AURORA_INT_DEBUG
925 del_timer(&aurora_poll_timer
);
929 for(i
=0;i
<AURORA_ALLIRQ
;i
++){
930 free_irq(allirq
[i
]|0x30, bp
);
931 /* IRQ_to_board[allirq[i]&0xf] = NULL;*/
934 free_irq(bp
->irq
|0x30, bp
);
935 /* IRQ_to_board[bp->irq&0xf] = NULL;*/
939 bp
->r
[i
>>3]->r
[CD180_CAR
]=i
&7;
941 bp
->r
[i
>>3]->r
[CD180_MSVR
]=0;
948 printk("aurora_shutdown_board: end\n");
953 * Setting up port characteristics.
954 * Must be called with disabled interrupts
956 static void aurora_change_speed(struct Aurora_board
*bp
, struct Aurora_port
*port
)
958 struct tty_struct
*tty
;
961 unsigned char cor1
= 0, cor3
= 0;
962 unsigned char mcor1
= 0, mcor2
= 0,chip
;
965 printk("aurora_change_speed: start\n");
967 if (!(tty
= port
->tty
) || !tty
->termios
)
970 chip
=AURORA_CD180(port_No(port
));
974 port
->MSVR
= MSVR_RTS
|MSVR_DTR
;
978 if (baud
& CBAUDEX
) {
980 if (baud
< 1 || baud
> 2)
981 port
->tty
->termios
->c_cflag
&= ~CBAUDEX
;
986 if ((port
->flags
& ASYNC_SPD_MASK
) == ASYNC_SPD_HI
)
988 if ((port
->flags
& ASYNC_SPD_MASK
) == ASYNC_SPD_VHI
)
992 /* Select port on the board */
993 bp
->r
[chip
]->r
[CD180_CAR
]=port_No(port
)&7;
996 if (!baud_table
[baud
]) {
997 /* Drop DTR & exit */
998 port
->MSVR
&= ~(bp
->DTR
|bp
->RTS
);
999 bp
->r
[chip
]->r
[CD180_MSVR
]=port
->MSVR
;
1003 port
->MSVR
|= bp
->DTR
;
1004 bp
->r
[chip
]->r
[CD180_MSVR
]=port
->MSVR
;
1008 * Now we must calculate some speed depended things
1011 /* Set baud rate for port */
1012 tmp
= (((bp
->oscfreq
+ baud_table
[baud
]/2) / baud_table
[baud
] +
1013 CD180_TPC
/2) / CD180_TPC
);
1015 /* tmp = (bp->oscfreq/7)/baud_table[baud];
1016 if((tmp%10)>4)tmp=tmp/10+1;else tmp=tmp/10;*/
1017 /* printk("Prescaler period: %d\n",tmp);*/
1019 bp
->r
[chip
]->r
[CD180_RBPRH
]=(tmp
>> 8) & 0xff;
1020 bp
->r
[chip
]->r
[CD180_TBPRH
]=(tmp
>> 8) & 0xff;
1021 bp
->r
[chip
]->r
[CD180_RBPRL
]=tmp
& 0xff;
1022 bp
->r
[chip
]->r
[CD180_TBPRL
]=tmp
& 0xff;
1024 baud
= (baud_table
[baud
] + 5) / 10; /* Estimated CPS */
1026 /* Two timer ticks seems enough to wakeup something like SLIP driver */
1027 tmp
= ((baud
+ HZ
/2) / HZ
) * 2 - CD180_NFIFO
;
1028 port
->wakeup_chars
= (tmp
< 0) ? 0 : ((tmp
>= SERIAL_XMIT_SIZE
) ?
1029 SERIAL_XMIT_SIZE
- 1 : tmp
);
1031 /* Receiver timeout will be transmission time for 1.5 chars */
1032 tmp
= (AURORA_TPS
+ AURORA_TPS
/2 + baud
/2) / baud
;
1033 tmp
= (tmp
> 0xff) ? 0xff : tmp
;
1034 bp
->r
[chip
]->r
[CD180_RTPR
]=tmp
;
1036 switch (C_CSIZE(tty
)) {
1054 cor1
|= COR1_IGNORE
;
1055 if (C_PARENB(tty
)) {
1056 cor1
|= COR1_NORMPAR
;
1060 cor1
&= ~COR1_IGNORE
;
1062 /* Set marking of some errors */
1063 port
->mark_mask
= RCSR_OE
| RCSR_TOUT
;
1065 port
->mark_mask
|= RCSR_FE
| RCSR_PE
;
1066 if (I_BRKINT(tty
) || I_PARMRK(tty
))
1067 port
->mark_mask
|= RCSR_BREAK
;
1069 port
->mark_mask
&= ~(RCSR_FE
| RCSR_PE
);
1070 if (I_IGNBRK(tty
)) {
1071 port
->mark_mask
&= ~RCSR_BREAK
;
1073 /* Real raw mode. Ignore all */
1074 port
->mark_mask
&= ~RCSR_OE
;
1076 /* Enable Hardware Flow Control */
1077 if (C_CRTSCTS(tty
)) {
1078 /*#ifdef AURORA_BRAIN_DAMAGED_CTS
1079 port->SRER |= SRER_DSR | SRER_CTS;
1080 mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD;
1081 mcor2 |= MCOR2_DSROD | MCOR2_CTSOD;
1082 tty->hw_stopped = !(aurora_in(bp, CD180_MSVR) & (MSVR_CTS|MSVR_DSR));
1084 port
->COR2
|= COR2_CTSAE
;
1086 if (bp
->flags
&AURORA_BOARD_DTR_FLOW_OK
) {
1087 mcor1
|= AURORA_RXTH
;
1090 /* Enable Software Flow Control. FIXME: I'm not sure about this */
1091 /* Some people reported that it works, but I still doubt */
1093 port
->COR2
|= COR2_TXIBE
;
1094 cor3
|= (COR3_FCT
| COR3_SCDE
);
1096 port
->COR2
|= COR2_IXM
;
1097 bp
->r
[chip
]->r
[CD180_SCHR1
]=START_CHAR(tty
);
1098 bp
->r
[chip
]->r
[CD180_SCHR2
]=STOP_CHAR(tty
);
1099 bp
->r
[chip
]->r
[CD180_SCHR3
]=START_CHAR(tty
);
1100 bp
->r
[chip
]->r
[CD180_SCHR4
]=STOP_CHAR(tty
);
1102 if (!C_CLOCAL(tty
)) {
1103 /* Enable CD check */
1104 port
->SRER
|= SRER_CD
;
1105 mcor1
|= MCOR1_CDZD
;
1106 mcor2
|= MCOR2_CDOD
;
1110 /* Enable receiver */
1111 port
->SRER
|= SRER_RXD
;
1113 /* Set input FIFO size (1-8 bytes) */
1114 cor3
|= AURORA_RXFIFO
;
1115 /* Setting up CD180 channel registers */
1116 bp
->r
[chip
]->r
[CD180_COR1
]=cor1
;
1117 bp
->r
[chip
]->r
[CD180_COR2
]=port
->COR2
;
1118 bp
->r
[chip
]->r
[CD180_COR3
]=cor3
;
1119 /* Make CD180 know about registers change */
1120 aurora_wait_CCR(bp
->r
[chip
]);
1121 bp
->r
[chip
]->r
[CD180_CCR
]=CCR_CORCHG1
| CCR_CORCHG2
| CCR_CORCHG3
;
1122 /* Setting up modem option registers */
1123 bp
->r
[chip
]->r
[CD180_MCOR1
]=mcor1
;
1124 bp
->r
[chip
]->r
[CD180_MCOR2
]=mcor2
;
1125 /* Enable CD180 transmitter & receiver */
1126 aurora_wait_CCR(bp
->r
[chip
]);
1127 bp
->r
[chip
]->r
[CD180_CCR
]=CCR_TXEN
| CCR_RXEN
;
1128 /* Enable interrupts */
1129 bp
->r
[chip
]->r
[CD180_SRER
]=port
->SRER
;
1130 /* And finally set RTS on */
1131 bp
->r
[chip
]->r
[CD180_MSVR
]=port
->MSVR
;
1133 printk("aurora_change_speed: end\n");
1137 /* Must be called with interrupts enabled */
1138 static int aurora_setup_port(struct Aurora_board
*bp
, struct Aurora_port
*port
)
1140 unsigned long flags
;
1143 printk("aurora_setup_port: start %d\n",port_No(port
));
1145 if (port
->flags
& ASYNC_INITIALIZED
)
1148 if (!port
->xmit_buf
) {
1149 /* We may sleep in get_free_page() */
1152 if (!(tmp
= get_free_page(GFP_KERNEL
)))
1155 if (port
->xmit_buf
) {
1157 return -ERESTARTSYS
;
1159 port
->xmit_buf
= (unsigned char *) tmp
;
1162 save_flags(flags
); cli();
1165 clear_bit(TTY_IO_ERROR
, &port
->tty
->flags
);
1168 if (port
->count
== 1) {
1170 if((++bp
->count
)==1)
1171 bp
->flags
|=AURORA_BOARD_ACTIVE
;
1175 port
->xmit_cnt
= port
->xmit_head
= port
->xmit_tail
= 0;
1176 aurora_change_speed(bp
, port
);
1177 port
->flags
|= ASYNC_INITIALIZED
;
1179 restore_flags(flags
);
1181 printk("aurora_setup_port: end\n");
1186 /* Must be called with interrupts disabled */
1187 static void aurora_shutdown_port(struct Aurora_board
*bp
, struct Aurora_port
*port
)
1189 struct tty_struct
*tty
;
1193 printk("aurora_shutdown_port: start\n");
1195 if (!(port
->flags
& ASYNC_INITIALIZED
))
1198 chip
=AURORA_CD180(port_No(port
));
1200 #ifdef AURORA_REPORT_OVERRUN
1201 printk("aurora%d: port %d: Total %ld overruns were detected.\n",
1202 board_No(bp
), port_No(port
), port
->overrun
);
1204 #ifdef AURORA_REPORT_FIFO
1208 printk("aurora%d: port %d: FIFO hits [ ",
1209 board_No(bp
), port_No(port
));
1210 for (i
= 0; i
< 10; i
++) {
1211 printk("%ld ", port
->hits
[i
]);
1216 if (port
->xmit_buf
) {
1217 free_page((unsigned long) port
->xmit_buf
);
1218 port
->xmit_buf
= NULL
;
1221 if (!(tty
= port
->tty
) || C_HUPCL(tty
)) {
1223 port
->MSVR
&= ~(bp
->DTR
|bp
->RTS
);
1224 bp
->r
[chip
]->r
[CD180_MSVR
]=port
->MSVR
;
1228 bp
->r
[chip
]->r
[CD180_CAR
]=port_No(port
)&7;
1231 aurora_wait_CCR(bp
->r
[chip
]);
1232 bp
->r
[chip
]->r
[CD180_CCR
]=CCR_SOFTRESET
;
1233 /* Disable all interrupts from this port */
1235 bp
->r
[chip
]->r
[CD180_SRER
]=port
->SRER
;
1238 set_bit(TTY_IO_ERROR
, &tty
->flags
);
1239 port
->flags
&= ~ASYNC_INITIALIZED
;
1242 if (--bp
->count
< 0) {
1243 printk(KERN_DEBUG
"aurora%d: aurora_shutdown_port: bad board count: %d\n",
1244 board_No(bp
), bp
->count
);
1250 bp
->flags
&=~AURORA_BOARD_ACTIVE
;
1254 printk("aurora_shutdown_port: end\n");
1259 static int block_til_ready(struct tty_struct
*tty
, struct file
* filp
,
1260 struct Aurora_port
*port
)
1262 DECLARE_WAITQUEUE(wait
, current
);
1263 struct Aurora_board
*bp
= port_Board(port
);
1270 printk("block_til_ready: start\n");
1272 chip
=AURORA_CD180(port_No(port
));
1275 * If the device is in the middle of being closed, then block
1276 * until it's done, and then try again.
1278 if (tty_hung_up_p(filp
) || port
->flags
& ASYNC_CLOSING
) {
1279 interruptible_sleep_on(&port
->close_wait
);
1280 if (port
->flags
& ASYNC_HUP_NOTIFY
)
1283 return -ERESTARTSYS
;
1287 * If non-blocking mode is set, or the port is not enabled,
1288 * then make the check up front and then exit.
1290 if ((filp
->f_flags
& O_NONBLOCK
) ||
1291 (tty
->flags
& (1 << TTY_IO_ERROR
))) {
1292 if (port
->flags
& ASYNC_CALLOUT_ACTIVE
)
1294 port
->flags
|= ASYNC_NORMAL_ACTIVE
;
1298 if (port
->flags
& ASYNC_CALLOUT_ACTIVE
) {
1299 if (port
->normal_termios
.c_cflag
& CLOCAL
)
1307 * Block waiting for the carrier detect and the line to become
1308 * free (i.e., not in use by the callout). While we are in
1309 * this loop, info->count is dropped by one, so that
1310 * rs_close() knows when to free things. We restore it upon
1311 * exit, either normal or abnormal.
1314 add_wait_queue(&port
->open_wait
, &wait
);
1316 if (!tty_hung_up_p(filp
))
1319 port
->blocked_open
++;
1322 bp
->r
[chip
]->r
[CD180_CAR
]=port_No(port
)&7;
1324 CD
= bp
->r
[chip
]->r
[CD180_MSVR
] & MSVR_CD
;
1325 if (!(port
->flags
& ASYNC_CALLOUT_ACTIVE
)) {
1327 bp
->r
[chip
]->r
[CD180_MSVR
]=port
->MSVR
;/* auto drops DTR */
1330 set_current_state(TASK_INTERRUPTIBLE
);
1331 if (tty_hung_up_p(filp
) ||
1332 !(port
->flags
& ASYNC_INITIALIZED
)) {
1333 if (port
->flags
& ASYNC_HUP_NOTIFY
)
1336 retval
= -ERESTARTSYS
;
1339 if (/*!(port->flags & ASYNC_CALLOUT_ACTIVE) &&*/
1340 !(port
->flags
& ASYNC_CLOSING
) &&
1343 if (signal_pending(current
)) {
1344 retval
= -ERESTARTSYS
;
1349 current
->state
= TASK_RUNNING
;
1350 remove_wait_queue(&port
->open_wait
, &wait
);
1351 if (!tty_hung_up_p(filp
))
1353 port
->blocked_open
--;
1357 port
->flags
|= ASYNC_NORMAL_ACTIVE
;
1359 printk("block_til_ready: end\n");
1364 static int aurora_open(struct tty_struct
* tty
, struct file
* filp
)
1368 struct Aurora_port
* port
;
1369 struct Aurora_board
* bp
;
1370 unsigned long flags
;
1373 printk("aurora_open: start\n");
1376 board
= AURORA_BOARD(MINOR(tty
->device
));
1377 if (board
> AURORA_NBOARD
|| !(aurora_board
[board
].flags
& AURORA_BOARD_PRESENT
)){
1379 printk("aurora_open: error board %d present %d\n",board
,aurora_board
[board
].flags
&AURORA_BOARD_PRESENT
);
1384 bp
= &aurora_board
[board
];
1385 port
= aurora_port
+ board
* AURORA_NPORT
* AURORA_NCD180
+ AURORA_PORT(MINOR(tty
->device
));
1386 if (aurora_paranoia_check(port
, tty
->device
, "aurora_open")){
1388 printk("aurora_open: error paranoia check\n");
1394 tty
->driver_data
= port
;
1397 if ((error
= aurora_setup_port(bp
, port
))) {
1399 printk("aurora_open: error aurora_setup_port ret %d\n",error
);
1404 if ((error
= block_til_ready(tty
, filp
, port
))){
1406 printk("aurora_open: error block_til_ready ret %d\n",error
);
1411 if ((port
->count
== 1) && (port
->flags
& ASYNC_SPLIT_TERMIOS
)) {
1412 *tty
->termios
= port
->normal_termios
;
1413 save_flags(flags
); cli();
1414 aurora_change_speed(bp
, port
);
1415 restore_flags(flags
);
1418 port
->session
= current
->session
;
1419 port
->pgrp
= current
->pgrp
;
1421 printk("aurora_open: end\n");
1426 static void aurora_close(struct tty_struct
* tty
, struct file
* filp
)
1428 struct Aurora_port
*port
= (struct Aurora_port
*) tty
->driver_data
;
1429 struct Aurora_board
*bp
;
1430 unsigned long flags
;
1431 unsigned long timeout
;
1435 printk("aurora_close: start\n");
1438 if (!port
|| aurora_paranoia_check(port
, tty
->device
, "close"))
1441 chip
=AURORA_CD180(port_No(port
));
1443 save_flags(flags
); cli();
1444 if (tty_hung_up_p(filp
)) {
1445 restore_flags(flags
);
1449 bp
= port_Board(port
);
1450 if ((tty
->count
== 1) && (port
->count
!= 1)) {
1451 printk(KERN_DEBUG
"aurora%d: aurora_close: bad port count; tty->count is 1, port count is %d\n",
1452 board_No(bp
), port
->count
);
1455 if (--port
->count
< 0) {
1456 printk(KERN_DEBUG
"aurora%d: aurora_close: bad port count for tty%d: %d\n",
1457 board_No(bp
), port_No(port
), port
->count
);
1461 restore_flags(flags
);
1464 port
->flags
|= ASYNC_CLOSING
;
1466 * Save the termios structure, since this port may have
1467 * separate termios for callout and dialin.
1469 if (port
->flags
& ASYNC_NORMAL_ACTIVE
)
1470 port
->normal_termios
= *tty
->termios
;
1471 /* if (port->flags & ASYNC_CALLOUT_ACTIVE)
1472 port->callout_termios = *tty->termios;*/
1474 * Now we wait for the transmit buffer to clear; and we notify
1475 * the line discipline to only process XON/XOFF characters.
1478 if (port
->closing_wait
!= ASYNC_CLOSING_WAIT_NONE
){
1480 printk("aurora_close: waiting to flush...\n");
1482 tty_wait_until_sent(tty
, port
->closing_wait
);
1485 * At this point we stop accepting input. To do this, we
1486 * disable the receive line status interrupts, and tell the
1487 * interrupt driver to stop checking the data ready bit in the
1488 * line status register.
1490 port
->SRER
&= ~SRER_RXD
;
1491 if (port
->flags
& ASYNC_INITIALIZED
) {
1492 port
->SRER
&= ~SRER_TXRDY
;
1493 port
->SRER
|= SRER_TXEMPTY
;
1494 bp
->r
[chip
]->r
[CD180_CAR
]=port_No(port
)&7;
1496 bp
->r
[chip
]->r
[CD180_SRER
]=port
->SRER
;
1498 * Before we drop DTR, make sure the UART transmitter
1499 * has completely drained; this is especially
1500 * important if there is a transmit FIFO!
1502 timeout
= jiffies
+HZ
;
1503 while(port
->SRER
& SRER_TXEMPTY
) {
1504 current
->state
= TASK_INTERRUPTIBLE
;
1505 schedule_timeout(port
->timeout
);
1506 if (time_after(jiffies
, timeout
))
1511 printk("aurora_close: shutdown_port\n");
1513 aurora_shutdown_port(bp
, port
);
1514 if (tty
->driver
.flush_buffer
)
1515 tty
->driver
.flush_buffer(tty
);
1516 if (tty
->ldisc
.flush_buffer
)
1517 tty
->ldisc
.flush_buffer(tty
);
1521 if (port
->blocked_open
) {
1522 if (port
->close_delay
) {
1523 current
->state
= TASK_INTERRUPTIBLE
;
1524 schedule_timeout(port
->close_delay
);
1526 wake_up_interruptible(&port
->open_wait
);
1528 port
->flags
&= ~(ASYNC_NORMAL_ACTIVE
|ASYNC_CALLOUT_ACTIVE
|
1530 wake_up_interruptible(&port
->close_wait
);
1531 restore_flags(flags
);
1533 printk("aurora_close: end\n");
1537 static int aurora_write(struct tty_struct
* tty
, int from_user
,
1538 const unsigned char *buf
, int count
)
1540 struct Aurora_port
*port
= (struct Aurora_port
*)tty
->driver_data
;
1541 struct Aurora_board
*bp
;
1543 unsigned long flags
;
1547 printk("aurora_write: start %d\n",count
);
1549 if (aurora_paranoia_check(port
, tty
->device
, "aurora_write"))
1552 chip
=AURORA_CD180(port_No(port
));
1554 bp
= port_Board(port
);
1556 if (!tty
|| !port
->xmit_buf
|| !tmp_buf
)
1565 c
= MIN(count
, MIN(SERIAL_XMIT_SIZE
- port
->xmit_cnt
- 1,
1566 SERIAL_XMIT_SIZE
- port
->xmit_head
));
1571 copy_from_user(tmp_buf
, buf
, c
);
1572 c
= MIN(c
, MIN(SERIAL_XMIT_SIZE
- port
->xmit_cnt
- 1,
1573 SERIAL_XMIT_SIZE
- port
->xmit_head
));
1574 memcpy(port
->xmit_buf
+ port
->xmit_head
, tmp_buf
, c
);
1576 memcpy(port
->xmit_buf
+ port
->xmit_head
, buf
, c
);
1577 port
->xmit_head
= (port
->xmit_head
+ c
) & (SERIAL_XMIT_SIZE
-1);
1578 port
->xmit_cnt
+= c
;
1579 restore_flags(flags
);
1586 if (port
->xmit_cnt
&& !tty
->stopped
&& !tty
->hw_stopped
&&
1587 !(port
->SRER
& SRER_TXRDY
)) {
1588 port
->SRER
|= SRER_TXRDY
;
1589 bp
->r
[chip
]->r
[CD180_CAR
]=port_No(port
)&7;
1591 bp
->r
[chip
]->r
[CD180_SRER
]=port
->SRER
;
1593 restore_flags(flags
);
1595 printk("aurora_write: end %d\n",total
);
1600 static void aurora_put_char(struct tty_struct
* tty
, unsigned char ch
)
1602 struct Aurora_port
*port
= (struct Aurora_port
*)tty
->driver_data
;
1603 unsigned long flags
;
1606 printk("aurora_put_char: start %c\n",ch
);
1608 if (aurora_paranoia_check(port
, tty
->device
, "aurora_put_char"))
1611 if (!tty
|| !port
->xmit_buf
)
1614 save_flags(flags
); cli();
1616 if (port
->xmit_cnt
>= SERIAL_XMIT_SIZE
- 1) {
1617 restore_flags(flags
);
1621 port
->xmit_buf
[port
->xmit_head
++] = ch
;
1622 port
->xmit_head
&= SERIAL_XMIT_SIZE
- 1;
1624 restore_flags(flags
);
1626 printk("aurora_put_char: end\n");
1630 static void aurora_flush_chars(struct tty_struct
* tty
)
1632 struct Aurora_port
*port
= (struct Aurora_port
*)tty
->driver_data
;
1633 unsigned long flags
;
1636 /*#ifdef AURORA_DEBUG
1637 printk("aurora_flush_chars: start\n");
1639 if (aurora_paranoia_check(port
, tty
->device
, "aurora_flush_chars"))
1642 chip
=AURORA_CD180(port_No(port
));
1644 if (port
->xmit_cnt
<= 0 || tty
->stopped
|| tty
->hw_stopped
||
1648 save_flags(flags
); cli();
1649 port
->SRER
|= SRER_TXRDY
;
1650 port_Board(port
)->r
[chip
]->r
[CD180_CAR
]=port_No(port
)&7;
1652 port_Board(port
)->r
[chip
]->r
[CD180_SRER
]=port
->SRER
;
1653 restore_flags(flags
);
1654 /*#ifdef AURORA_DEBUG
1655 printk("aurora_flush_chars: end\n");
1659 static int aurora_write_room(struct tty_struct
* tty
)
1661 struct Aurora_port
*port
= (struct Aurora_port
*)tty
->driver_data
;
1665 printk("aurora_write_room: start\n");
1667 if (aurora_paranoia_check(port
, tty
->device
, "aurora_write_room"))
1670 ret
= SERIAL_XMIT_SIZE
- port
->xmit_cnt
- 1;
1674 printk("aurora_write_room: end\n");
1679 static int aurora_chars_in_buffer(struct tty_struct
*tty
)
1681 struct Aurora_port
*port
= (struct Aurora_port
*)tty
->driver_data
;
1683 if (aurora_paranoia_check(port
, tty
->device
, "aurora_chars_in_buffer"))
1686 return port
->xmit_cnt
;
1689 static void aurora_flush_buffer(struct tty_struct
*tty
)
1691 struct Aurora_port
*port
= (struct Aurora_port
*)tty
->driver_data
;
1692 unsigned long flags
;
1695 printk("aurora_flush_buffer: start\n");
1697 if (aurora_paranoia_check(port
, tty
->device
, "aurora_flush_buffer"))
1700 save_flags(flags
); cli();
1701 port
->xmit_cnt
= port
->xmit_head
= port
->xmit_tail
= 0;
1702 restore_flags(flags
);
1704 wake_up_interruptible(&tty
->write_wait
);
1705 if ((tty
->flags
& (1 << TTY_DO_WRITE_WAKEUP
)) &&
1706 tty
->ldisc
.write_wakeup
)
1707 (tty
->ldisc
.write_wakeup
)(tty
);
1709 printk("aurora_flush_buffer: end\n");
1713 static int aurora_get_modem_info(struct Aurora_port
* port
, unsigned int *value
)
1715 struct Aurora_board
* bp
;
1716 unsigned char status
,chip
;
1717 unsigned int result
;
1718 unsigned long flags
;
1721 printk("aurora_get_modem_info: start\n");
1723 chip
=AURORA_CD180(port_No(port
));
1725 bp
= port_Board(port
);
1726 save_flags(flags
); cli();
1727 bp
->r
[chip
]->r
[CD180_CAR
]=port_No(port
)&7;
1729 status
= bp
->r
[chip
]->r
[CD180_MSVR
];
1730 result
= 0/*bp->r[chip]->r[AURORA_RI] & (1u << port_No(port)) ? 0 : TIOCM_RNG*/;
1731 restore_flags(flags
);
1732 result
|= ((status
& bp
->RTS
) ? TIOCM_RTS
: 0)
1733 | ((status
& bp
->DTR
) ? TIOCM_DTR
: 0)
1734 | ((status
& MSVR_CD
) ? TIOCM_CAR
: 0)
1735 | ((status
& MSVR_DSR
) ? TIOCM_DSR
: 0)
1736 | ((status
& MSVR_CTS
) ? TIOCM_CTS
: 0);
1737 put_user(result
,(unsigned long *) value
);
1739 printk("aurora_get_modem_info: end\n");
1744 static int aurora_set_modem_info(struct Aurora_port
* port
, unsigned int cmd
,
1745 unsigned int *value
)
1749 unsigned long flags
;
1750 struct Aurora_board
*bp
= port_Board(port
);
1754 printk("aurora_set_modem_info: start\n");
1756 error
= get_user(arg
, value
);
1759 chip
=AURORA_CD180(port_No(port
));
1762 if (arg
& TIOCM_RTS
)
1763 port
->MSVR
|= bp
->RTS
;
1764 if (arg
& TIOCM_DTR
)
1765 port
->MSVR
|= bp
->DTR
;
1768 if (arg
& TIOCM_RTS
)
1769 port
->MSVR
&= ~bp
->RTS
;
1770 if (arg
& TIOCM_DTR
)
1771 port
->MSVR
&= ~bp
->DTR
;
1774 port
->MSVR
= (arg
& TIOCM_RTS
) ? (port
->MSVR
| bp
->RTS
) :
1775 (port
->MSVR
& ~bp
->RTS
);
1776 port
->MSVR
= (arg
& TIOCM_DTR
) ? (port
->MSVR
| bp
->RTS
) :
1777 (port
->MSVR
& ~bp
->RTS
);
1782 save_flags(flags
); cli();
1783 bp
->r
[chip
]->r
[CD180_CAR
]=port_No(port
)&7;
1785 bp
->r
[chip
]->r
[CD180_MSVR
]=port
->MSVR
;
1786 restore_flags(flags
);
1788 printk("aurora_set_modem_info: end\n");
1793 extern inline void aurora_send_break(struct Aurora_port
* port
, unsigned long length
)
1795 struct Aurora_board
*bp
= port_Board(port
);
1796 unsigned long flags
;
1800 printk("aurora_send_break: start\n");
1802 chip
=AURORA_CD180(port_No(port
));
1804 save_flags(flags
); cli();
1805 port
->break_length
= AURORA_TPS
/ HZ
* length
;
1806 port
->COR2
|= COR2_ETC
;
1807 port
->SRER
|= SRER_TXRDY
;
1808 bp
->r
[chip
]->r
[CD180_CAR
]=port_No(port
)&7;
1810 bp
->r
[chip
]->r
[CD180_COR2
]=port
->COR2
;
1811 bp
->r
[chip
]->r
[CD180_SRER
]=port
->SRER
;
1812 aurora_wait_CCR(bp
->r
[chip
]);
1813 bp
->r
[chip
]->r
[CD180_CCR
]=CCR_CORCHG2
;
1814 aurora_wait_CCR(bp
->r
[chip
]);
1815 restore_flags(flags
);
1817 printk("aurora_send_break: end\n");
1821 extern inline int aurora_set_serial_info(struct Aurora_port
* port
,
1822 struct serial_struct
* newinfo
)
1824 struct serial_struct tmp
;
1825 struct Aurora_board
*bp
= port_Board(port
);
1827 unsigned long flags
;
1831 printk("aurora_set_serial_info: start\n");
1833 error
= verify_area(VERIFY_READ
, (void *) newinfo
, sizeof(tmp
));
1836 copy_from_user(&tmp
, newinfo
, sizeof(tmp
));
1839 if ((tmp
.irq
!= bp
->irq
) ||
1840 (tmp
.port
!= bp
->base
) ||
1841 (tmp
.type
!= PORT_CIRRUS
) ||
1842 (tmp
.baud_base
!= (bp
->oscfreq
+ CD180_TPC
/2) / CD180_TPC
) ||
1843 (tmp
.custom_divisor
!= 0) ||
1844 (tmp
.xmit_fifo_size
!= CD180_NFIFO
) ||
1845 (tmp
.flags
& ~AURORA_LEGAL_FLAGS
))
1849 change_speed
= ((port
->flags
& ASYNC_SPD_MASK
) !=
1850 (tmp
.flags
& ASYNC_SPD_MASK
));
1853 if ((tmp
.close_delay
!= port
->close_delay
) ||
1854 (tmp
.closing_wait
!= port
->closing_wait
) ||
1855 ((tmp
.flags
& ~ASYNC_USR_MASK
) !=
1856 (port
->flags
& ~ASYNC_USR_MASK
)))
1858 port
->flags
= ((port
->flags
& ~ASYNC_USR_MASK
) |
1859 (tmp
.flags
& ASYNC_USR_MASK
));
1861 port
->flags
= ((port
->flags
& ~ASYNC_FLAGS
) |
1862 (tmp
.flags
& ASYNC_FLAGS
));
1863 port
->close_delay
= tmp
.close_delay
;
1864 port
->closing_wait
= tmp
.closing_wait
;
1867 save_flags(flags
); cli();
1868 aurora_change_speed(bp
, port
);
1869 restore_flags(flags
);
1872 printk("aurora_set_serial_info: end\n");
1877 extern inline int aurora_get_serial_info(struct Aurora_port
* port
,
1878 struct serial_struct
* retinfo
)
1880 struct serial_struct tmp
;
1881 struct Aurora_board
*bp
= port_Board(port
);
1885 printk("aurora_get_serial_info: start\n");
1887 error
= verify_area(VERIFY_WRITE
, (void *) retinfo
, sizeof(tmp
));
1891 memset(&tmp
, 0, sizeof(tmp
));
1892 tmp
.type
= PORT_CIRRUS
;
1893 tmp
.line
= port
- aurora_port
;
1896 tmp
.flags
= port
->flags
;
1897 tmp
.baud_base
= (bp
->oscfreq
+ CD180_TPC
/2) / CD180_TPC
;
1898 tmp
.close_delay
= port
->close_delay
* HZ
/100;
1899 tmp
.closing_wait
= port
->closing_wait
* HZ
/100;
1900 tmp
.xmit_fifo_size
= CD180_NFIFO
;
1901 copy_to_user(retinfo
, &tmp
, sizeof(tmp
));
1903 printk("aurora_get_serial_info: end\n");
1908 static int aurora_ioctl(struct tty_struct
* tty
, struct file
* filp
,
1909 unsigned int cmd
, unsigned long arg
)
1912 struct Aurora_port
*port
= (struct Aurora_port
*)tty
->driver_data
;
1917 printk("aurora_ioctl: start\n");
1919 if (aurora_paranoia_check(port
, tty
->device
, "aurora_ioctl"))
1923 case TCSBRK
: /* SVID version: non-zero arg --> no break */
1924 retval
= tty_check_change(tty
);
1927 tty_wait_until_sent(tty
, 0);
1929 aurora_send_break(port
, HZ
/4); /* 1/4 second */
1931 case TCSBRKP
: /* support for POSIX tcsendbreak() */
1932 retval
= tty_check_change(tty
);
1935 tty_wait_until_sent(tty
, 0);
1936 aurora_send_break(port
, arg
? arg
*(HZ
/10) : HZ
/4);
1939 error
= verify_area(VERIFY_WRITE
, (void *) arg
, sizeof(long));
1942 put_user(C_CLOCAL(tty
) ? 1 : 0,
1943 (unsigned long *) arg
);
1946 retval
= get_user(arg
,(unsigned long *) arg
);
1949 tty
->termios
->c_cflag
=
1950 ((tty
->termios
->c_cflag
& ~CLOCAL
) |
1951 (arg
? CLOCAL
: 0));
1954 error
= verify_area(VERIFY_WRITE
, (void *) arg
,
1955 sizeof(unsigned int));
1958 return aurora_get_modem_info(port
, (unsigned int *) arg
);
1962 return aurora_set_modem_info(port
, cmd
, (unsigned int *) arg
);
1964 return aurora_get_serial_info(port
, (struct serial_struct
*) arg
);
1966 return aurora_set_serial_info(port
, (struct serial_struct
*) arg
);
1968 return -ENOIOCTLCMD
;
1971 printk("aurora_ioctl: end\n");
1976 static void aurora_throttle(struct tty_struct
* tty
)
1978 struct Aurora_port
*port
= (struct Aurora_port
*)tty
->driver_data
;
1979 struct Aurora_board
*bp
;
1980 unsigned long flags
;
1984 printk("aurora_throttle: start\n");
1986 if (aurora_paranoia_check(port
, tty
->device
, "aurora_throttle"))
1989 bp
= port_Board(port
);
1990 chip
=AURORA_CD180(port_No(port
));
1992 save_flags(flags
); cli();
1993 port
->MSVR
&= ~bp
->RTS
;
1994 bp
->r
[chip
]->r
[CD180_CAR
]=port_No(port
)&7;
1997 aurora_wait_CCR(bp
->r
[chip
]);
1998 bp
->r
[chip
]->r
[CD180_CCR
]=CCR_SSCH2
;
1999 aurora_wait_CCR(bp
->r
[chip
]);
2001 bp
->r
[chip
]->r
[CD180_MSVR
]=port
->MSVR
;
2002 restore_flags(flags
);
2004 printk("aurora_throttle: end\n");
2008 static void aurora_unthrottle(struct tty_struct
* tty
)
2010 struct Aurora_port
*port
= (struct Aurora_port
*)tty
->driver_data
;
2011 struct Aurora_board
*bp
;
2012 unsigned long flags
;
2016 printk("aurora_unthrottle: start\n");
2018 if (aurora_paranoia_check(port
, tty
->device
, "aurora_unthrottle"))
2021 bp
= port_Board(port
);
2023 chip
=AURORA_CD180(port_No(port
));
2025 save_flags(flags
); cli();
2026 port
->MSVR
|= bp
->RTS
;
2027 bp
->r
[chip
]->r
[CD180_CAR
]=port_No(port
)&7;
2030 aurora_wait_CCR(bp
->r
[chip
]);
2031 bp
->r
[chip
]->r
[CD180_CCR
]=CCR_SSCH1
;
2032 aurora_wait_CCR(bp
->r
[chip
]);
2034 bp
->r
[chip
]->r
[CD180_MSVR
]=port
->MSVR
;
2035 restore_flags(flags
);
2037 printk("aurora_unthrottle: end\n");
2041 static void aurora_stop(struct tty_struct
* tty
)
2043 struct Aurora_port
*port
= (struct Aurora_port
*)tty
->driver_data
;
2044 struct Aurora_board
*bp
;
2045 unsigned long flags
;
2049 printk("aurora_stop: start\n");
2051 if (aurora_paranoia_check(port
, tty
->device
, "aurora_stop"))
2054 bp
= port_Board(port
);
2056 chip
=AURORA_CD180(port_No(port
));
2058 save_flags(flags
); cli();
2059 port
->SRER
&= ~SRER_TXRDY
;
2060 bp
->r
[chip
]->r
[CD180_CAR
]=port_No(port
)&7;
2062 bp
->r
[chip
]->r
[CD180_SRER
]=port
->SRER
;
2063 restore_flags(flags
);
2065 printk("aurora_stop: end\n");
2069 static void aurora_start(struct tty_struct
* tty
)
2071 struct Aurora_port
*port
= (struct Aurora_port
*)tty
->driver_data
;
2072 struct Aurora_board
*bp
;
2073 unsigned long flags
;
2077 printk("aurora_start: start\n");
2079 if (aurora_paranoia_check(port
, tty
->device
, "aurora_start"))
2082 bp
= port_Board(port
);
2084 chip
=AURORA_CD180(port_No(port
));
2086 save_flags(flags
); cli();
2087 if (port
->xmit_cnt
&& port
->xmit_buf
&& !(port
->SRER
& SRER_TXRDY
)) {
2088 port
->SRER
|= SRER_TXRDY
;
2089 bp
->r
[chip
]->r
[CD180_CAR
]=port_No(port
)&7;
2091 bp
->r
[chip
]->r
[CD180_SRER
]=port
->SRER
;
2093 restore_flags(flags
);
2095 printk("aurora_start: end\n");
2100 * This routine is called from the scheduler tqueue when the interrupt
2101 * routine has signalled that a hangup has occurred. The path of
2102 * hangup processing is:
2104 * serial interrupt routine -> (scheduler tqueue) ->
2105 * do_aurora_hangup() -> tty->hangup() -> aurora_hangup()
2108 static void do_aurora_hangup(void *private_
)
2110 struct Aurora_port
*port
= (struct Aurora_port
*) private_
;
2111 struct tty_struct
*tty
;
2114 printk("do_aurora_hangup: start\n");
2122 printk("do_aurora_hangup: end\n");
2126 static void aurora_hangup(struct tty_struct
* tty
)
2128 struct Aurora_port
*port
= (struct Aurora_port
*)tty
->driver_data
;
2129 struct Aurora_board
*bp
;
2132 printk("aurora_hangup: start\n");
2134 if (aurora_paranoia_check(port
, tty
->device
, "aurora_hangup"))
2137 bp
= port_Board(port
);
2139 aurora_shutdown_port(bp
, port
);
2142 port
->flags
&= ~(ASYNC_NORMAL_ACTIVE
|ASYNC_CALLOUT_ACTIVE
);
2144 wake_up_interruptible(&port
->open_wait
);
2146 printk("aurora_hangup: end\n");
2150 static void aurora_set_termios(struct tty_struct
* tty
, struct termios
* old_termios
)
2152 struct Aurora_port
*port
= (struct Aurora_port
*)tty
->driver_data
;
2153 unsigned long flags
;
2156 printk("aurora_set_termios: start\n");
2158 if (aurora_paranoia_check(port
, tty
->device
, "aurora_set_termios"))
2161 if (tty
->termios
->c_cflag
== old_termios
->c_cflag
&&
2162 tty
->termios
->c_iflag
== old_termios
->c_iflag
)
2165 save_flags(flags
); cli();
2166 aurora_change_speed(port_Board(port
), port
);
2167 restore_flags(flags
);
2169 if ((old_termios
->c_cflag
& CRTSCTS
) &&
2170 !(tty
->termios
->c_cflag
& CRTSCTS
)) {
2171 tty
->hw_stopped
= 0;
2175 printk("aurora_set_termios: end\n");
2179 static void do_aurora_bh(void)
2181 run_task_queue(&tq_aurora
);
2184 static void do_softint(void *private_
)
2186 struct Aurora_port
*port
= (struct Aurora_port
*) private_
;
2187 struct tty_struct
*tty
;
2190 printk("do_softint: start\n");
2192 if(!(tty
= port
->tty
))
2195 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP
, &port
->event
)) {
2196 if ((tty
->flags
& (1 << TTY_DO_WRITE_WAKEUP
)) &&
2197 tty
->ldisc
.write_wakeup
)
2198 (tty
->ldisc
.write_wakeup
)(tty
);
2199 wake_up_interruptible(&tty
->write_wait
);
2202 printk("do_softint: end\n");
2206 static int aurora_init_drivers(void)
2212 printk("aurora_init_drivers: start\n");
2214 if (!(tmp_buf
= (unsigned char *) get_free_page(GFP_KERNEL
))) {
2215 printk(KERN_ERR
"aurora: Couldn't get free page.\n");
2218 init_bh(AURORA_BH
, do_aurora_bh
);
2219 /* memset(IRQ_to_board, 0, sizeof(IRQ_to_board));*/
2220 memset(&aurora_driver
, 0, sizeof(aurora_driver
));
2221 aurora_driver
.magic
= TTY_DRIVER_MAGIC
;
2222 aurora_driver
.name
= "ttyA";
2223 aurora_driver
.major
= AURORA_MAJOR
;
2224 aurora_driver
.num
= AURORA_TNPORTS
;
2225 aurora_driver
.type
= TTY_DRIVER_TYPE_SERIAL
;
2226 aurora_driver
.subtype
= AURORA_TYPE_NORMAL
;
2227 aurora_driver
.init_termios
= tty_std_termios
;
2228 aurora_driver
.init_termios
.c_cflag
=
2229 B9600
| CS8
| CREAD
| HUPCL
| CLOCAL
;
2230 aurora_driver
.flags
= TTY_DRIVER_REAL_RAW
;
2231 aurora_driver
.refcount
= &aurora_refcount
;
2232 aurora_driver
.table
= aurora_table
;
2233 aurora_driver
.termios
= aurora_termios
;
2234 aurora_driver
.termios_locked
= aurora_termios_locked
;
2236 aurora_driver
.open
= aurora_open
;
2237 aurora_driver
.close
= aurora_close
;
2238 aurora_driver
.write
= aurora_write
;
2239 aurora_driver
.put_char
= aurora_put_char
;
2240 aurora_driver
.flush_chars
= aurora_flush_chars
;
2241 aurora_driver
.write_room
= aurora_write_room
;
2242 aurora_driver
.chars_in_buffer
= aurora_chars_in_buffer
;
2243 aurora_driver
.flush_buffer
= aurora_flush_buffer
;
2244 aurora_driver
.ioctl
= aurora_ioctl
;
2245 aurora_driver
.throttle
= aurora_throttle
;
2246 aurora_driver
.unthrottle
= aurora_unthrottle
;
2247 aurora_driver
.set_termios
= aurora_set_termios
;
2248 aurora_driver
.stop
= aurora_stop
;
2249 aurora_driver
.start
= aurora_start
;
2250 aurora_driver
.hangup
= aurora_hangup
;
2252 if ((error
= tty_register_driver(&aurora_driver
))) {
2253 free_page((unsigned long)tmp_buf
);
2254 printk(KERN_ERR
"aurora: Couldn't register aurora driver, error = %d\n",
2259 memset(aurora_port
, 0, sizeof(aurora_port
));
2260 for (i
= 0; i
< AURORA_TNPORTS
; i
++) {
2261 aurora_port
[i
].normal_termios
= aurora_driver
.init_termios
;
2262 aurora_port
[i
].magic
= AURORA_MAGIC
;
2263 aurora_port
[i
].tqueue
.routine
= do_softint
;
2264 aurora_port
[i
].tqueue
.data
= &aurora_port
[i
];
2265 aurora_port
[i
].tqueue_hangup
.routine
= do_aurora_hangup
;
2266 aurora_port
[i
].tqueue_hangup
.data
= &aurora_port
[i
];
2267 aurora_port
[i
].close_delay
= 50 * HZ
/100;
2268 aurora_port
[i
].closing_wait
= 3000 * HZ
/100;
2269 init_waitqueue_head(&aurora_port
[i
].open_wait
);
2270 init_waitqueue_head(&aurora_port
[i
].close_wait
);
2273 printk("aurora_init_drivers: end\n");
2278 static void aurora_release_drivers(void)
2281 printk("aurora_release_drivers: start\n");
2283 free_page((unsigned long)tmp_buf
);
2284 tty_unregister_driver(&aurora_driver
);
2286 printk("aurora_release_drivers: end\n");
2292 * Called at boot time.
2294 * You can specify IO base for up to RC_NBOARD cards,
2295 * using line "riscom8=0xiobase1,0xiobase2,.." at LILO prompt.
2296 * Note that there will be no probing at default
2297 * addresses in this case.
2300 __init_func(void aurora_setup(char *str
, int *ints
))
2304 for(i
=0;(i
<ints
[0])&&(i
<4);i
++) {
2305 if (ints
[i
+1]) irqs
[i
]=ints
[i
+1];
2309 __init_func(int aurora_init(void))
2311 int aurora_init(void)
2317 printk(KERN_INFO
"aurora: Driver starting.\n");
2318 if(aurora_init_drivers())return -EIO
;
2319 found
=aurora_probe();
2321 aurora_release_drivers();
2322 printk(KERN_INFO
"aurora: No Aurora Multiport boards detected.\n");
2325 printk(KERN_INFO
"aurora: %d boards found.\n",found
);
2327 for(i
=0;i
<found
;i
++){
2328 if ((grrr
= aurora_setup_board(&aurora_board
[i
]))) {
2330 printk(KERN_ERR
"aurora_init: error aurora_setup_board ret %d\n",grrr
);
2343 MODULE_PARM(irq
, "i");
2344 MODULE_PARM(irq1
, "i");
2345 MODULE_PARM(irq2
, "i");
2346 MODULE_PARM(irq3
, "i");
2348 int init_module(void)
2350 if (irq
) irqs
[0]=irq
;
2351 if (irq1
) irqs
[1]=irq1
;
2352 if (irq2
) irqs
[2]=irq2
;
2353 if (irq3
) irqs
[3]=irq3
;
2354 return aurora_init();
2357 void cleanup_module(void)
2362 printk("cleanup_module: aurora_release_drivers\n");
2365 aurora_release_drivers();
2366 for (i
= 0; i
< AURORA_NBOARD
; i
++)
2367 if (aurora_board
[i
].flags
& AURORA_BOARD_PRESENT
) {
2368 aurora_shutdown_board(&aurora_board
[i
]);
2369 aurora_release_io_range(&aurora_board
[i
]);