2 * linux/drivers/char/riscom.c -- RISCom/8 multiport serial driver.
4 * Copyright (C) 1994-1996 Dmitry Gorodchanin (pgmdsg@ibi.com)
6 * This code is loosely based on the Linux serial driver, written by
7 * Linus Torvalds, Theodore T'so and others. The RISCom/8 card
8 * programming info was obtained from various drivers for other OSes
9 * (FreeBSD, ISC, etc), but no source code from those drivers were
10 * directly included in this driver.
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 27-Jun-2001
31 * - get rid of check_region and several cleanups
34 #include <linux/module.h>
37 #include <linux/kernel.h>
38 #include <linux/sched.h>
39 #include <linux/ioport.h>
40 #include <linux/interrupt.h>
41 #include <linux/errno.h>
42 #include <linux/tty.h>
44 #include <linux/serial.h>
45 #include <linux/fcntl.h>
46 #include <linux/major.h>
47 #include <linux/init.h>
48 #include <linux/delay.h>
49 #include <linux/tty_flip.h>
51 #include <asm/uaccess.h>
54 #include "riscom8_reg.h"
56 /* Am I paranoid or not ? ;-) */
57 #define RISCOM_PARANOIA_CHECK
60 * Crazy InteliCom/8 boards sometimes has swapped CTS & DSR signals.
61 * You can slightly speed up things by #undefing the following option,
62 * if you are REALLY sure that your board is correct one.
65 #define RISCOM_BRAIN_DAMAGED_CTS
68 * The following defines are mostly for testing purposes. But if you need
69 * some nice reporting in your syslog, you can define them also.
72 #undef RC_REPORT_OVERRUN
75 #define RISCOM_LEGAL_FLAGS \
76 (ASYNC_HUP_NOTIFY | ASYNC_SAK | ASYNC_SPLIT_TERMIOS | \
77 ASYNC_SPD_HI | ASYNC_SPEED_VHI | ASYNC_SESSION_LOCKOUT | \
78 ASYNC_PGRP_LOCKOUT | ASYNC_CALLOUT_NOHUP)
80 #define RS_EVENT_WRITE_WAKEUP 0
82 static struct riscom_board * IRQ_to_board[16];
83 static struct tty_driver *riscom_driver;
85 static unsigned long baud_table[] = {
86 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
87 9600, 19200, 38400, 57600, 76800, 0,
90 static struct riscom_board rc_board[RC_NBOARD] = {
105 static struct riscom_port rc_port[RC_NBOARD * RC_NPORT];
107 /* RISCom/8 I/O ports addresses (without address translation) */
108 static unsigned short rc_ioport[] = {
110 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0c,
112 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0c, 0x10,
113 0x11, 0x12, 0x18, 0x28, 0x31, 0x32, 0x39, 0x3a, 0x40, 0x41, 0x61, 0x62,
114 0x63, 0x64, 0x6b, 0x70, 0x71, 0x78, 0x7a, 0x7b, 0x7f, 0x100, 0x101
117 #define RC_NIOPORT ARRAY_SIZE(rc_ioport)
120 static inline int rc_paranoia_check(struct riscom_port const * port,
121 char *name, const char *routine)
123 #ifdef RISCOM_PARANOIA_CHECK
124 static const char badmagic[] = KERN_INFO
125 "rc: Warning: bad riscom port magic number for device %s in %s\n";
126 static const char badinfo[] = KERN_INFO
127 "rc: Warning: null riscom port for device %s in %s\n";
130 printk(badinfo, name, routine);
133 if (port->magic != RISCOM8_MAGIC) {
134 printk(badmagic, name, routine);
143 * Service functions for RISCom/8 driver.
147 /* Get board number from pointer */
148 static inline int board_No (struct riscom_board const * bp)
150 return bp - rc_board;
153 /* Get port number from pointer */
154 static inline int port_No (struct riscom_port const * port)
156 return RC_PORT(port - rc_port);
159 /* Get pointer to board from pointer to port */
160 static inline struct riscom_board * port_Board(struct riscom_port const * port)
162 return &rc_board[RC_BOARD(port - rc_port)];
165 /* Input Byte from CL CD180 register */
166 static inline unsigned char rc_in(struct riscom_board const * bp, unsigned short reg)
168 return inb(bp->base + RC_TO_ISA(reg));
171 /* Output Byte to CL CD180 register */
172 static inline void rc_out(struct riscom_board const * bp, unsigned short reg,
175 outb(val, bp->base + RC_TO_ISA(reg));
178 /* Wait for Channel Command Register ready */
179 static inline void rc_wait_CCR(struct riscom_board const * bp)
183 /* FIXME: need something more descriptive then 100000 :) */
184 for (delay = 100000; delay; delay--)
185 if (!rc_in(bp, CD180_CCR))
188 printk(KERN_INFO "rc%d: Timeout waiting for CCR.\n", board_No(bp));
192 * RISCom/8 probe functions.
195 static inline int rc_request_io_range(struct riscom_board * const bp)
199 for (i = 0; i < RC_NIOPORT; i++)
200 if (!request_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1,
206 printk(KERN_INFO "rc%d: Skipping probe at 0x%03x. IO address in use.\n",
207 board_No(bp), bp->base);
209 release_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1);
213 static inline void rc_release_io_range(struct riscom_board * const bp)
217 for (i = 0; i < RC_NIOPORT; i++)
218 release_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1);
221 /* Must be called with enabled interrupts */
222 static inline void rc_long_delay(unsigned long delay)
226 for (i = jiffies + delay; time_after(i,jiffies); ) ;
229 /* Reset and setup CD180 chip */
230 static void __init rc_init_CD180(struct riscom_board const * bp)
234 save_flags(flags); cli();
235 rc_out(bp, RC_CTOUT, 0); /* Clear timeout */
236 rc_wait_CCR(bp); /* Wait for CCR ready */
237 rc_out(bp, CD180_CCR, CCR_HARDRESET); /* Reset CD180 chip */
239 rc_long_delay(HZ/20); /* Delay 0.05 sec */
241 rc_out(bp, CD180_GIVR, RC_ID); /* Set ID for this chip */
242 rc_out(bp, CD180_GICR, 0); /* Clear all bits */
243 rc_out(bp, CD180_PILR1, RC_ACK_MINT); /* Prio for modem intr */
244 rc_out(bp, CD180_PILR2, RC_ACK_TINT); /* Prio for transmitter intr */
245 rc_out(bp, CD180_PILR3, RC_ACK_RINT); /* Prio for receiver intr */
247 /* Setting up prescaler. We need 4 ticks per 1 ms */
248 rc_out(bp, CD180_PPRH, (RC_OSCFREQ/(1000000/RISCOM_TPS)) >> 8);
249 rc_out(bp, CD180_PPRL, (RC_OSCFREQ/(1000000/RISCOM_TPS)) & 0xff);
251 restore_flags(flags);
254 /* Main probing routine, also sets irq. */
255 static int __init rc_probe(struct riscom_board *bp)
257 unsigned char val1, val2;
263 if (rc_request_io_range(bp))
266 /* Are the I/O ports here ? */
267 rc_out(bp, CD180_PPRL, 0x5a);
269 val1 = rc_in(bp, CD180_PPRL);
270 rc_out(bp, CD180_PPRL, 0xa5);
272 val2 = rc_in(bp, CD180_PPRL);
274 if ((val1 != 0x5a) || (val2 != 0xa5)) {
275 printk(KERN_ERR "rc%d: RISCom/8 Board at 0x%03x not found.\n",
276 board_No(bp), bp->base);
280 /* It's time to find IRQ for this board */
281 for (retries = 0; retries < 5 && irqs <= 0; retries++) {
282 irqs = probe_irq_on();
283 rc_init_CD180(bp); /* Reset CD180 chip */
284 rc_out(bp, CD180_CAR, 2); /* Select port 2 */
286 rc_out(bp, CD180_CCR, CCR_TXEN); /* Enable transmitter */
287 rc_out(bp, CD180_IER, IER_TXRDY); /* Enable tx empty intr */
288 rc_long_delay(HZ/20);
289 irqs = probe_irq_off(irqs);
290 val1 = rc_in(bp, RC_BSR); /* Get Board Status reg */
291 val2 = rc_in(bp, RC_ACK_TINT); /* ACK interrupt */
292 rc_init_CD180(bp); /* Reset CD180 again */
294 if ((val1 & RC_BSR_TINT) || (val2 != (RC_ID | GIVR_IT_TX))) {
295 printk(KERN_ERR "rc%d: RISCom/8 Board at 0x%03x not "
296 "found.\n", board_No(bp), bp->base);
302 printk(KERN_ERR "rc%d: Can't find IRQ for RISCom/8 board "
303 "at 0x%03x.\n", board_No(bp), bp->base);
307 bp->flags |= RC_BOARD_PRESENT;
309 printk(KERN_INFO "rc%d: RISCom/8 Rev. %c board detected at "
312 (rc_in(bp, CD180_GFRCR) & 0x0f) + 'A', /* Board revision */
317 rc_release_io_range(bp);
323 * Interrupt processing routines.
327 static inline void rc_mark_event(struct riscom_port * port, int event)
329 set_bit(event, &port->event);
330 schedule_work(&port->tqueue);
333 static inline struct riscom_port * rc_get_port(struct riscom_board const * bp,
334 unsigned char const * what)
336 unsigned char channel;
337 struct riscom_port * port;
339 channel = rc_in(bp, CD180_GICR) >> GICR_CHAN_OFF;
340 if (channel < CD180_NCH) {
341 port = &rc_port[board_No(bp) * RC_NPORT + channel];
342 if (port->flags & ASYNC_INITIALIZED) {
346 printk(KERN_ERR "rc%d: %s interrupt from invalid port %d\n",
347 board_No(bp), what, channel);
351 static inline void rc_receive_exc(struct riscom_board const * bp)
353 struct riscom_port *port;
354 struct tty_struct *tty;
355 unsigned char status;
356 unsigned char ch, flag;
358 if (!(port = rc_get_port(bp, "Receive")))
363 #ifdef RC_REPORT_OVERRUN
364 status = rc_in(bp, CD180_RCSR);
365 if (status & RCSR_OE)
367 status &= port->mark_mask;
369 status = rc_in(bp, CD180_RCSR) & port->mark_mask;
371 ch = rc_in(bp, CD180_RDR);
375 if (status & RCSR_TOUT) {
376 printk(KERN_WARNING "rc%d: port %d: Receiver timeout. "
377 "Hardware problems ?\n",
378 board_No(bp), port_No(port));
381 } else if (status & RCSR_BREAK) {
382 printk(KERN_INFO "rc%d: port %d: Handling break...\n",
383 board_No(bp), port_No(port));
385 if (port->flags & ASYNC_SAK)
388 } else if (status & RCSR_PE)
391 else if (status & RCSR_FE)
394 else if (status & RCSR_OE)
400 tty_insert_flip_char(tty, ch, flag);
401 tty_flip_buffer_push(tty);
404 static inline void rc_receive(struct riscom_board const * bp)
406 struct riscom_port *port;
407 struct tty_struct *tty;
410 if (!(port = rc_get_port(bp, "Receive")))
415 count = rc_in(bp, CD180_RDCR);
417 #ifdef RC_REPORT_FIFO
418 port->hits[count > 8 ? 9 : count]++;
422 if (tty_buffer_request_room(tty, 1) == 0) {
423 printk(KERN_WARNING "rc%d: port %d: Working around "
424 "flip buffer overflow.\n",
425 board_No(bp), port_No(port));
428 tty_insert_flip_char(tty, rc_in(bp, CD180_RDR), TTY_NORMAL);
430 tty_flip_buffer_push(tty);
433 static inline void rc_transmit(struct riscom_board const * bp)
435 struct riscom_port *port;
436 struct tty_struct *tty;
440 if (!(port = rc_get_port(bp, "Transmit")))
445 if (port->IER & IER_TXEMPTY) {
447 rc_out(bp, CD180_CAR, port_No(port));
448 port->IER &= ~IER_TXEMPTY;
449 rc_out(bp, CD180_IER, port->IER);
453 if ((port->xmit_cnt <= 0 && !port->break_length)
454 || tty->stopped || tty->hw_stopped) {
455 rc_out(bp, CD180_CAR, port_No(port));
456 port->IER &= ~IER_TXRDY;
457 rc_out(bp, CD180_IER, port->IER);
461 if (port->break_length) {
462 if (port->break_length > 0) {
463 if (port->COR2 & COR2_ETC) {
464 rc_out(bp, CD180_TDR, CD180_C_ESC);
465 rc_out(bp, CD180_TDR, CD180_C_SBRK);
466 port->COR2 &= ~COR2_ETC;
468 count = min_t(int, port->break_length, 0xff);
469 rc_out(bp, CD180_TDR, CD180_C_ESC);
470 rc_out(bp, CD180_TDR, CD180_C_DELAY);
471 rc_out(bp, CD180_TDR, count);
472 if (!(port->break_length -= count))
473 port->break_length--;
475 rc_out(bp, CD180_TDR, CD180_C_ESC);
476 rc_out(bp, CD180_TDR, CD180_C_EBRK);
477 rc_out(bp, CD180_COR2, port->COR2);
479 rc_out(bp, CD180_CCR, CCR_CORCHG2);
480 port->break_length = 0;
487 rc_out(bp, CD180_TDR, port->xmit_buf[port->xmit_tail++]);
488 port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE-1);
489 if (--port->xmit_cnt <= 0)
491 } while (--count > 0);
493 if (port->xmit_cnt <= 0) {
494 rc_out(bp, CD180_CAR, port_No(port));
495 port->IER &= ~IER_TXRDY;
496 rc_out(bp, CD180_IER, port->IER);
498 if (port->xmit_cnt <= port->wakeup_chars)
499 rc_mark_event(port, RS_EVENT_WRITE_WAKEUP);
502 static inline void rc_check_modem(struct riscom_board const * bp)
504 struct riscom_port *port;
505 struct tty_struct *tty;
508 if (!(port = rc_get_port(bp, "Modem")))
513 mcr = rc_in(bp, CD180_MCR);
514 if (mcr & MCR_CDCHG) {
515 if (rc_in(bp, CD180_MSVR) & MSVR_CD)
516 wake_up_interruptible(&port->open_wait);
518 schedule_work(&port->tqueue_hangup);
521 #ifdef RISCOM_BRAIN_DAMAGED_CTS
522 if (mcr & MCR_CTSCHG) {
523 if (rc_in(bp, CD180_MSVR) & MSVR_CTS) {
525 port->IER |= IER_TXRDY;
526 if (port->xmit_cnt <= port->wakeup_chars)
527 rc_mark_event(port, RS_EVENT_WRITE_WAKEUP);
530 port->IER &= ~IER_TXRDY;
532 rc_out(bp, CD180_IER, port->IER);
534 if (mcr & MCR_DSRCHG) {
535 if (rc_in(bp, CD180_MSVR) & MSVR_DSR) {
537 port->IER |= IER_TXRDY;
538 if (port->xmit_cnt <= port->wakeup_chars)
539 rc_mark_event(port, RS_EVENT_WRITE_WAKEUP);
542 port->IER &= ~IER_TXRDY;
544 rc_out(bp, CD180_IER, port->IER);
546 #endif /* RISCOM_BRAIN_DAMAGED_CTS */
548 /* Clear change bits */
549 rc_out(bp, CD180_MCR, 0);
552 /* The main interrupt processing routine */
553 static irqreturn_t rc_interrupt(int irq, void * dev_id)
555 unsigned char status;
557 struct riscom_board *bp;
558 unsigned long loop = 0;
561 bp = IRQ_to_board[irq];
563 if (!bp || !(bp->flags & RC_BOARD_ACTIVE)) {
567 while ((++loop < 16) && ((status = ~(rc_in(bp, RC_BSR))) &
568 (RC_BSR_TOUT | RC_BSR_TINT |
569 RC_BSR_MINT | RC_BSR_RINT))) {
571 if (status & RC_BSR_TOUT)
572 printk(KERN_WARNING "rc%d: Got timeout. Hardware "
573 "error?\n", board_No(bp));
575 else if (status & RC_BSR_RINT) {
576 ack = rc_in(bp, RC_ACK_RINT);
578 if (ack == (RC_ID | GIVR_IT_RCV))
580 else if (ack == (RC_ID | GIVR_IT_REXC))
583 printk(KERN_WARNING "rc%d: Bad receive ack "
587 } else if (status & RC_BSR_TINT) {
588 ack = rc_in(bp, RC_ACK_TINT);
590 if (ack == (RC_ID | GIVR_IT_TX))
593 printk(KERN_WARNING "rc%d: Bad transmit ack "
597 } else /* if (status & RC_BSR_MINT) */ {
598 ack = rc_in(bp, RC_ACK_MINT);
600 if (ack == (RC_ID | GIVR_IT_MODEM))
603 printk(KERN_WARNING "rc%d: Bad modem ack "
609 rc_out(bp, CD180_EOIR, 0); /* Mark end of interrupt */
610 rc_out(bp, RC_CTOUT, 0); /* Clear timeout flag */
612 return IRQ_RETVAL(handled);
616 * Routines for open & close processing.
619 /* Called with disabled interrupts */
620 static inline int rc_setup_board(struct riscom_board * bp)
624 if (bp->flags & RC_BOARD_ACTIVE)
627 error = request_irq(bp->irq, rc_interrupt, IRQF_DISABLED,
632 rc_out(bp, RC_CTOUT, 0); /* Just in case */
634 rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */
636 IRQ_to_board[bp->irq] = bp;
637 bp->flags |= RC_BOARD_ACTIVE;
642 /* Called with disabled interrupts */
643 static inline void rc_shutdown_board(struct riscom_board *bp)
645 if (!(bp->flags & RC_BOARD_ACTIVE))
648 bp->flags &= ~RC_BOARD_ACTIVE;
650 free_irq(bp->irq, NULL);
651 IRQ_to_board[bp->irq] = NULL;
654 rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */
659 * Setting up port characteristics.
660 * Must be called with disabled interrupts
662 static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
664 struct tty_struct *tty;
667 unsigned char cor1 = 0, cor3 = 0;
668 unsigned char mcor1 = 0, mcor2 = 0;
670 if (!(tty = port->tty) || !tty->termios)
675 port->MSVR = MSVR_RTS;
677 baud = tty_get_baud_rate(tty);
679 /* Select port on the board */
680 rc_out(bp, CD180_CAR, port_No(port));
683 /* Drop DTR & exit */
684 bp->DTR |= (1u << port_No(port));
685 rc_out(bp, RC_DTR, bp->DTR);
689 bp->DTR &= ~(1u << port_No(port));
690 rc_out(bp, RC_DTR, bp->DTR);
694 * Now we must calculate some speed depended things
697 /* Set baud rate for port */
698 tmp = (((RC_OSCFREQ + baud/2) / baud +
699 CD180_TPC/2) / CD180_TPC);
701 rc_out(bp, CD180_RBPRH, (tmp >> 8) & 0xff);
702 rc_out(bp, CD180_TBPRH, (tmp >> 8) & 0xff);
703 rc_out(bp, CD180_RBPRL, tmp & 0xff);
704 rc_out(bp, CD180_TBPRL, tmp & 0xff);
706 baud = (baud + 5) / 10; /* Estimated CPS */
708 /* Two timer ticks seems enough to wakeup something like SLIP driver */
709 tmp = ((baud + HZ/2) / HZ) * 2 - CD180_NFIFO;
710 port->wakeup_chars = (tmp < 0) ? 0 : ((tmp >= SERIAL_XMIT_SIZE) ?
711 SERIAL_XMIT_SIZE - 1 : tmp);
713 /* Receiver timeout will be transmission time for 1.5 chars */
714 tmp = (RISCOM_TPS + RISCOM_TPS/2 + baud/2) / baud;
715 tmp = (tmp > 0xff) ? 0xff : tmp;
716 rc_out(bp, CD180_RTPR, tmp);
718 switch (C_CSIZE(tty)) {
738 cor1 |= COR1_NORMPAR;
742 cor1 &= ~COR1_IGNORE;
744 /* Set marking of some errors */
745 port->mark_mask = RCSR_OE | RCSR_TOUT;
747 port->mark_mask |= RCSR_FE | RCSR_PE;
748 if (I_BRKINT(tty) || I_PARMRK(tty))
749 port->mark_mask |= RCSR_BREAK;
751 port->mark_mask &= ~(RCSR_FE | RCSR_PE);
753 port->mark_mask &= ~RCSR_BREAK;
755 /* Real raw mode. Ignore all */
756 port->mark_mask &= ~RCSR_OE;
758 /* Enable Hardware Flow Control */
759 if (C_CRTSCTS(tty)) {
760 #ifdef RISCOM_BRAIN_DAMAGED_CTS
761 port->IER |= IER_DSR | IER_CTS;
762 mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD;
763 mcor2 |= MCOR2_DSROD | MCOR2_CTSOD;
764 tty->hw_stopped = !(rc_in(bp, CD180_MSVR) & (MSVR_CTS|MSVR_DSR));
766 port->COR2 |= COR2_CTSAE;
769 /* Enable Software Flow Control. FIXME: I'm not sure about this */
770 /* Some people reported that it works, but I still doubt */
772 port->COR2 |= COR2_TXIBE;
773 cor3 |= (COR3_FCT | COR3_SCDE);
775 port->COR2 |= COR2_IXM;
776 rc_out(bp, CD180_SCHR1, START_CHAR(tty));
777 rc_out(bp, CD180_SCHR2, STOP_CHAR(tty));
778 rc_out(bp, CD180_SCHR3, START_CHAR(tty));
779 rc_out(bp, CD180_SCHR4, STOP_CHAR(tty));
781 if (!C_CLOCAL(tty)) {
782 /* Enable CD check */
789 /* Enable receiver */
790 port->IER |= IER_RXD;
792 /* Set input FIFO size (1-8 bytes) */
793 cor3 |= RISCOM_RXFIFO;
794 /* Setting up CD180 channel registers */
795 rc_out(bp, CD180_COR1, cor1);
796 rc_out(bp, CD180_COR2, port->COR2);
797 rc_out(bp, CD180_COR3, cor3);
798 /* Make CD180 know about registers change */
800 rc_out(bp, CD180_CCR, CCR_CORCHG1 | CCR_CORCHG2 | CCR_CORCHG3);
801 /* Setting up modem option registers */
802 rc_out(bp, CD180_MCOR1, mcor1);
803 rc_out(bp, CD180_MCOR2, mcor2);
804 /* Enable CD180 transmitter & receiver */
806 rc_out(bp, CD180_CCR, CCR_TXEN | CCR_RXEN);
807 /* Enable interrupts */
808 rc_out(bp, CD180_IER, port->IER);
809 /* And finally set RTS on */
810 rc_out(bp, CD180_MSVR, port->MSVR);
813 /* Must be called with interrupts enabled */
814 static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
818 if (port->flags & ASYNC_INITIALIZED)
821 if (!port->xmit_buf) {
822 /* We may sleep in get_zeroed_page() */
825 if (!(tmp = get_zeroed_page(GFP_KERNEL)))
828 if (port->xmit_buf) {
832 port->xmit_buf = (unsigned char *) tmp;
835 save_flags(flags); cli();
838 clear_bit(TTY_IO_ERROR, &port->tty->flags);
840 if (port->count == 1)
843 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
844 rc_change_speed(bp, port);
845 port->flags |= ASYNC_INITIALIZED;
847 restore_flags(flags);
851 /* Must be called with interrupts disabled */
852 static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
854 struct tty_struct *tty;
856 if (!(port->flags & ASYNC_INITIALIZED))
859 #ifdef RC_REPORT_OVERRUN
860 printk(KERN_INFO "rc%d: port %d: Total %ld overruns were detected.\n",
861 board_No(bp), port_No(port), port->overrun);
863 #ifdef RC_REPORT_FIFO
867 printk(KERN_INFO "rc%d: port %d: FIFO hits [ ",
868 board_No(bp), port_No(port));
869 for (i = 0; i < 10; i++) {
870 printk("%ld ", port->hits[i]);
875 if (port->xmit_buf) {
876 free_page((unsigned long) port->xmit_buf);
877 port->xmit_buf = NULL;
880 if (!(tty = port->tty) || C_HUPCL(tty)) {
882 bp->DTR |= (1u << port_No(port));
883 rc_out(bp, RC_DTR, bp->DTR);
887 rc_out(bp, CD180_CAR, port_No(port));
890 rc_out(bp, CD180_CCR, CCR_SOFTRESET);
891 /* Disable all interrupts from this port */
893 rc_out(bp, CD180_IER, port->IER);
896 set_bit(TTY_IO_ERROR, &tty->flags);
897 port->flags &= ~ASYNC_INITIALIZED;
899 if (--bp->count < 0) {
900 printk(KERN_INFO "rc%d: rc_shutdown_port: "
901 "bad board count: %d\n",
902 board_No(bp), bp->count);
907 * If this is the last opened port on the board
908 * shutdown whole board
911 rc_shutdown_board(bp);
915 static int block_til_ready(struct tty_struct *tty, struct file * filp,
916 struct riscom_port *port)
918 DECLARE_WAITQUEUE(wait, current);
919 struct riscom_board *bp = port_Board(port);
925 * If the device is in the middle of being closed, then block
926 * until it's done, and then try again.
928 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) {
929 interruptible_sleep_on(&port->close_wait);
930 if (port->flags & ASYNC_HUP_NOTIFY)
937 * If non-blocking mode is set, or the port is not enabled,
938 * then make the check up front and then exit.
940 if ((filp->f_flags & O_NONBLOCK) ||
941 (tty->flags & (1 << TTY_IO_ERROR))) {
942 port->flags |= ASYNC_NORMAL_ACTIVE;
950 * Block waiting for the carrier detect and the line to become
951 * free (i.e., not in use by the callout). While we are in
952 * this loop, info->count is dropped by one, so that
953 * rs_close() knows when to free things. We restore it upon
954 * exit, either normal or abnormal.
957 add_wait_queue(&port->open_wait, &wait);
959 if (!tty_hung_up_p(filp))
962 port->blocked_open++;
965 rc_out(bp, CD180_CAR, port_No(port));
966 CD = rc_in(bp, CD180_MSVR) & MSVR_CD;
967 rc_out(bp, CD180_MSVR, MSVR_RTS);
968 bp->DTR &= ~(1u << port_No(port));
969 rc_out(bp, RC_DTR, bp->DTR);
971 set_current_state(TASK_INTERRUPTIBLE);
972 if (tty_hung_up_p(filp) ||
973 !(port->flags & ASYNC_INITIALIZED)) {
974 if (port->flags & ASYNC_HUP_NOTIFY)
977 retval = -ERESTARTSYS;
980 if (!(port->flags & ASYNC_CLOSING) &&
983 if (signal_pending(current)) {
984 retval = -ERESTARTSYS;
989 current->state = TASK_RUNNING;
990 remove_wait_queue(&port->open_wait, &wait);
991 if (!tty_hung_up_p(filp))
993 port->blocked_open--;
997 port->flags |= ASYNC_NORMAL_ACTIVE;
1001 static int rc_open(struct tty_struct * tty, struct file * filp)
1005 struct riscom_port * port;
1006 struct riscom_board * bp;
1008 board = RC_BOARD(tty->index);
1009 if (board >= RC_NBOARD || !(rc_board[board].flags & RC_BOARD_PRESENT))
1012 bp = &rc_board[board];
1013 port = rc_port + board * RC_NPORT + RC_PORT(tty->index);
1014 if (rc_paranoia_check(port, tty->name, "rc_open"))
1017 if ((error = rc_setup_board(bp)))
1021 tty->driver_data = port;
1024 if ((error = rc_setup_port(bp, port)))
1027 if ((error = block_til_ready(tty, filp, port)))
1033 static void rc_close(struct tty_struct * tty, struct file * filp)
1035 struct riscom_port *port = (struct riscom_port *) tty->driver_data;
1036 struct riscom_board *bp;
1037 unsigned long flags;
1038 unsigned long timeout;
1040 if (!port || rc_paranoia_check(port, tty->name, "close"))
1043 save_flags(flags); cli();
1044 if (tty_hung_up_p(filp))
1047 bp = port_Board(port);
1048 if ((tty->count == 1) && (port->count != 1)) {
1049 printk(KERN_INFO "rc%d: rc_close: bad port count;"
1050 " tty->count is 1, port count is %d\n",
1051 board_No(bp), port->count);
1054 if (--port->count < 0) {
1055 printk(KERN_INFO "rc%d: rc_close: bad port count "
1057 board_No(bp), port_No(port), port->count);
1062 port->flags |= ASYNC_CLOSING;
1064 * Now we wait for the transmit buffer to clear; and we notify
1065 * the line discipline to only process XON/XOFF characters.
1068 if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
1069 tty_wait_until_sent(tty, port->closing_wait);
1071 * At this point we stop accepting input. To do this, we
1072 * disable the receive line status interrupts, and tell the
1073 * interrupt driver to stop checking the data ready bit in the
1074 * line status register.
1076 port->IER &= ~IER_RXD;
1077 if (port->flags & ASYNC_INITIALIZED) {
1078 port->IER &= ~IER_TXRDY;
1079 port->IER |= IER_TXEMPTY;
1080 rc_out(bp, CD180_CAR, port_No(port));
1081 rc_out(bp, CD180_IER, port->IER);
1083 * Before we drop DTR, make sure the UART transmitter
1084 * has completely drained; this is especially
1085 * important if there is a transmit FIFO!
1087 timeout = jiffies+HZ;
1088 while(port->IER & IER_TXEMPTY) {
1089 msleep_interruptible(jiffies_to_msecs(port->timeout));
1090 if (time_after(jiffies, timeout))
1094 rc_shutdown_port(bp, port);
1095 if (tty->driver->flush_buffer)
1096 tty->driver->flush_buffer(tty);
1097 tty_ldisc_flush(tty);
1102 if (port->blocked_open) {
1103 if (port->close_delay) {
1104 msleep_interruptible(jiffies_to_msecs(port->close_delay));
1106 wake_up_interruptible(&port->open_wait);
1108 port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
1109 wake_up_interruptible(&port->close_wait);
1110 out: restore_flags(flags);
1113 static int rc_write(struct tty_struct * tty,
1114 const unsigned char *buf, int count)
1116 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1117 struct riscom_board *bp;
1119 unsigned long flags;
1121 if (rc_paranoia_check(port, tty->name, "rc_write"))
1124 bp = port_Board(port);
1126 if (!tty || !port->xmit_buf)
1132 c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
1133 SERIAL_XMIT_SIZE - port->xmit_head));
1135 restore_flags(flags);
1139 memcpy(port->xmit_buf + port->xmit_head, buf, c);
1140 port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
1141 port->xmit_cnt += c;
1142 restore_flags(flags);
1150 if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped &&
1151 !(port->IER & IER_TXRDY)) {
1152 port->IER |= IER_TXRDY;
1153 rc_out(bp, CD180_CAR, port_No(port));
1154 rc_out(bp, CD180_IER, port->IER);
1156 restore_flags(flags);
1161 static void rc_put_char(struct tty_struct * tty, unsigned char ch)
1163 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1164 unsigned long flags;
1166 if (rc_paranoia_check(port, tty->name, "rc_put_char"))
1169 if (!tty || !port->xmit_buf)
1172 save_flags(flags); cli();
1174 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
1177 port->xmit_buf[port->xmit_head++] = ch;
1178 port->xmit_head &= SERIAL_XMIT_SIZE - 1;
1180 out: restore_flags(flags);
1183 static void rc_flush_chars(struct tty_struct * tty)
1185 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1186 unsigned long flags;
1188 if (rc_paranoia_check(port, tty->name, "rc_flush_chars"))
1191 if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
1195 save_flags(flags); cli();
1196 port->IER |= IER_TXRDY;
1197 rc_out(port_Board(port), CD180_CAR, port_No(port));
1198 rc_out(port_Board(port), CD180_IER, port->IER);
1199 restore_flags(flags);
1202 static int rc_write_room(struct tty_struct * tty)
1204 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1207 if (rc_paranoia_check(port, tty->name, "rc_write_room"))
1210 ret = SERIAL_XMIT_SIZE - port->xmit_cnt - 1;
1216 static int rc_chars_in_buffer(struct tty_struct *tty)
1218 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1220 if (rc_paranoia_check(port, tty->name, "rc_chars_in_buffer"))
1223 return port->xmit_cnt;
1226 static void rc_flush_buffer(struct tty_struct *tty)
1228 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1229 unsigned long flags;
1231 if (rc_paranoia_check(port, tty->name, "rc_flush_buffer"))
1234 save_flags(flags); cli();
1235 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
1236 restore_flags(flags);
1238 wake_up_interruptible(&tty->write_wait);
1242 static int rc_tiocmget(struct tty_struct *tty, struct file *file)
1244 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1245 struct riscom_board * bp;
1246 unsigned char status;
1247 unsigned int result;
1248 unsigned long flags;
1250 if (rc_paranoia_check(port, tty->name, __FUNCTION__))
1253 bp = port_Board(port);
1254 save_flags(flags); cli();
1255 rc_out(bp, CD180_CAR, port_No(port));
1256 status = rc_in(bp, CD180_MSVR);
1257 result = rc_in(bp, RC_RI) & (1u << port_No(port)) ? 0 : TIOCM_RNG;
1258 restore_flags(flags);
1259 result |= ((status & MSVR_RTS) ? TIOCM_RTS : 0)
1260 | ((status & MSVR_DTR) ? TIOCM_DTR : 0)
1261 | ((status & MSVR_CD) ? TIOCM_CAR : 0)
1262 | ((status & MSVR_DSR) ? TIOCM_DSR : 0)
1263 | ((status & MSVR_CTS) ? TIOCM_CTS : 0);
1267 static int rc_tiocmset(struct tty_struct *tty, struct file *file,
1268 unsigned int set, unsigned int clear)
1270 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1271 unsigned long flags;
1272 struct riscom_board *bp;
1274 if (rc_paranoia_check(port, tty->name, __FUNCTION__))
1277 bp = port_Board(port);
1279 save_flags(flags); cli();
1280 if (set & TIOCM_RTS)
1281 port->MSVR |= MSVR_RTS;
1282 if (set & TIOCM_DTR)
1283 bp->DTR &= ~(1u << port_No(port));
1285 if (clear & TIOCM_RTS)
1286 port->MSVR &= ~MSVR_RTS;
1287 if (clear & TIOCM_DTR)
1288 bp->DTR |= (1u << port_No(port));
1290 rc_out(bp, CD180_CAR, port_No(port));
1291 rc_out(bp, CD180_MSVR, port->MSVR);
1292 rc_out(bp, RC_DTR, bp->DTR);
1293 restore_flags(flags);
1297 static inline void rc_send_break(struct riscom_port * port, unsigned long length)
1299 struct riscom_board *bp = port_Board(port);
1300 unsigned long flags;
1302 save_flags(flags); cli();
1303 port->break_length = RISCOM_TPS / HZ * length;
1304 port->COR2 |= COR2_ETC;
1305 port->IER |= IER_TXRDY;
1306 rc_out(bp, CD180_CAR, port_No(port));
1307 rc_out(bp, CD180_COR2, port->COR2);
1308 rc_out(bp, CD180_IER, port->IER);
1310 rc_out(bp, CD180_CCR, CCR_CORCHG2);
1312 restore_flags(flags);
1315 static inline int rc_set_serial_info(struct riscom_port * port,
1316 struct serial_struct __user * newinfo)
1318 struct serial_struct tmp;
1319 struct riscom_board *bp = port_Board(port);
1321 unsigned long flags;
1323 if (copy_from_user(&tmp, newinfo, sizeof(tmp)))
1327 if ((tmp.irq != bp->irq) ||
1328 (tmp.port != bp->base) ||
1329 (tmp.type != PORT_CIRRUS) ||
1330 (tmp.baud_base != (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC) ||
1331 (tmp.custom_divisor != 0) ||
1332 (tmp.xmit_fifo_size != CD180_NFIFO) ||
1333 (tmp.flags & ~RISCOM_LEGAL_FLAGS))
1337 change_speed = ((port->flags & ASYNC_SPD_MASK) !=
1338 (tmp.flags & ASYNC_SPD_MASK));
1340 if (!capable(CAP_SYS_ADMIN)) {
1341 if ((tmp.close_delay != port->close_delay) ||
1342 (tmp.closing_wait != port->closing_wait) ||
1343 ((tmp.flags & ~ASYNC_USR_MASK) !=
1344 (port->flags & ~ASYNC_USR_MASK)))
1346 port->flags = ((port->flags & ~ASYNC_USR_MASK) |
1347 (tmp.flags & ASYNC_USR_MASK));
1349 port->flags = ((port->flags & ~ASYNC_FLAGS) |
1350 (tmp.flags & ASYNC_FLAGS));
1351 port->close_delay = tmp.close_delay;
1352 port->closing_wait = tmp.closing_wait;
1355 save_flags(flags); cli();
1356 rc_change_speed(bp, port);
1357 restore_flags(flags);
1362 static inline int rc_get_serial_info(struct riscom_port * port,
1363 struct serial_struct __user *retinfo)
1365 struct serial_struct tmp;
1366 struct riscom_board *bp = port_Board(port);
1368 memset(&tmp, 0, sizeof(tmp));
1369 tmp.type = PORT_CIRRUS;
1370 tmp.line = port - rc_port;
1371 tmp.port = bp->base;
1373 tmp.flags = port->flags;
1374 tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC;
1375 tmp.close_delay = port->close_delay * HZ/100;
1376 tmp.closing_wait = port->closing_wait * HZ/100;
1377 tmp.xmit_fifo_size = CD180_NFIFO;
1378 return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0;
1381 static int rc_ioctl(struct tty_struct * tty, struct file * filp,
1382 unsigned int cmd, unsigned long arg)
1385 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1386 void __user *argp = (void __user *)arg;
1389 if (rc_paranoia_check(port, tty->name, "rc_ioctl"))
1393 case TCSBRK: /* SVID version: non-zero arg --> no break */
1394 retval = tty_check_change(tty);
1397 tty_wait_until_sent(tty, 0);
1399 rc_send_break(port, HZ/4); /* 1/4 second */
1401 case TCSBRKP: /* support for POSIX tcsendbreak() */
1402 retval = tty_check_change(tty);
1405 tty_wait_until_sent(tty, 0);
1406 rc_send_break(port, arg ? arg*(HZ/10) : HZ/4);
1409 return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned __user *)argp);
1411 if (get_user(arg,(unsigned __user *) argp))
1413 tty->termios->c_cflag =
1414 ((tty->termios->c_cflag & ~CLOCAL) |
1415 (arg ? CLOCAL : 0));
1418 return rc_get_serial_info(port, argp);
1420 return rc_set_serial_info(port, argp);
1422 return -ENOIOCTLCMD;
1427 static void rc_throttle(struct tty_struct * tty)
1429 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1430 struct riscom_board *bp;
1431 unsigned long flags;
1433 if (rc_paranoia_check(port, tty->name, "rc_throttle"))
1436 bp = port_Board(port);
1438 save_flags(flags); cli();
1439 port->MSVR &= ~MSVR_RTS;
1440 rc_out(bp, CD180_CAR, port_No(port));
1443 rc_out(bp, CD180_CCR, CCR_SSCH2);
1446 rc_out(bp, CD180_MSVR, port->MSVR);
1447 restore_flags(flags);
1450 static void rc_unthrottle(struct tty_struct * tty)
1452 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1453 struct riscom_board *bp;
1454 unsigned long flags;
1456 if (rc_paranoia_check(port, tty->name, "rc_unthrottle"))
1459 bp = port_Board(port);
1461 save_flags(flags); cli();
1462 port->MSVR |= MSVR_RTS;
1463 rc_out(bp, CD180_CAR, port_No(port));
1466 rc_out(bp, CD180_CCR, CCR_SSCH1);
1469 rc_out(bp, CD180_MSVR, port->MSVR);
1470 restore_flags(flags);
1473 static void rc_stop(struct tty_struct * tty)
1475 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1476 struct riscom_board *bp;
1477 unsigned long flags;
1479 if (rc_paranoia_check(port, tty->name, "rc_stop"))
1482 bp = port_Board(port);
1484 save_flags(flags); cli();
1485 port->IER &= ~IER_TXRDY;
1486 rc_out(bp, CD180_CAR, port_No(port));
1487 rc_out(bp, CD180_IER, port->IER);
1488 restore_flags(flags);
1491 static void rc_start(struct tty_struct * tty)
1493 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1494 struct riscom_board *bp;
1495 unsigned long flags;
1497 if (rc_paranoia_check(port, tty->name, "rc_start"))
1500 bp = port_Board(port);
1502 save_flags(flags); cli();
1503 if (port->xmit_cnt && port->xmit_buf && !(port->IER & IER_TXRDY)) {
1504 port->IER |= IER_TXRDY;
1505 rc_out(bp, CD180_CAR, port_No(port));
1506 rc_out(bp, CD180_IER, port->IER);
1508 restore_flags(flags);
1512 * This routine is called from the work queue when the interrupt
1513 * routine has signalled that a hangup has occurred. The path of
1514 * hangup processing is:
1516 * serial interrupt routine -> (workqueue) ->
1517 * do_rc_hangup() -> tty->hangup() -> rc_hangup()
1520 static void do_rc_hangup(void *private_)
1522 struct riscom_port *port = (struct riscom_port *) private_;
1523 struct tty_struct *tty;
1527 tty_hangup(tty); /* FIXME: module removal race still here */
1530 static void rc_hangup(struct tty_struct * tty)
1532 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1533 struct riscom_board *bp;
1535 if (rc_paranoia_check(port, tty->name, "rc_hangup"))
1538 bp = port_Board(port);
1540 rc_shutdown_port(bp, port);
1543 port->flags &= ~ASYNC_NORMAL_ACTIVE;
1545 wake_up_interruptible(&port->open_wait);
1548 static void rc_set_termios(struct tty_struct * tty, struct termios * old_termios)
1550 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1551 unsigned long flags;
1553 if (rc_paranoia_check(port, tty->name, "rc_set_termios"))
1556 if (tty->termios->c_cflag == old_termios->c_cflag &&
1557 tty->termios->c_iflag == old_termios->c_iflag)
1560 save_flags(flags); cli();
1561 rc_change_speed(port_Board(port), port);
1562 restore_flags(flags);
1564 if ((old_termios->c_cflag & CRTSCTS) &&
1565 !(tty->termios->c_cflag & CRTSCTS)) {
1566 tty->hw_stopped = 0;
1571 static void do_softint(void *private_)
1573 struct riscom_port *port = (struct riscom_port *) private_;
1574 struct tty_struct *tty;
1576 if(!(tty = port->tty))
1579 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event)) {
1581 wake_up_interruptible(&tty->write_wait);
1585 static const struct tty_operations riscom_ops = {
1589 .put_char = rc_put_char,
1590 .flush_chars = rc_flush_chars,
1591 .write_room = rc_write_room,
1592 .chars_in_buffer = rc_chars_in_buffer,
1593 .flush_buffer = rc_flush_buffer,
1595 .throttle = rc_throttle,
1596 .unthrottle = rc_unthrottle,
1597 .set_termios = rc_set_termios,
1600 .hangup = rc_hangup,
1601 .tiocmget = rc_tiocmget,
1602 .tiocmset = rc_tiocmset,
1605 static inline int rc_init_drivers(void)
1610 riscom_driver = alloc_tty_driver(RC_NBOARD * RC_NPORT);
1614 memset(IRQ_to_board, 0, sizeof(IRQ_to_board));
1615 riscom_driver->owner = THIS_MODULE;
1616 riscom_driver->name = "ttyL";
1617 riscom_driver->major = RISCOM8_NORMAL_MAJOR;
1618 riscom_driver->type = TTY_DRIVER_TYPE_SERIAL;
1619 riscom_driver->subtype = SERIAL_TYPE_NORMAL;
1620 riscom_driver->init_termios = tty_std_termios;
1621 riscom_driver->init_termios.c_cflag =
1622 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1623 riscom_driver->flags = TTY_DRIVER_REAL_RAW;
1624 tty_set_operations(riscom_driver, &riscom_ops);
1625 if ((error = tty_register_driver(riscom_driver))) {
1626 put_tty_driver(riscom_driver);
1627 printk(KERN_ERR "rc: Couldn't register RISCom/8 driver, "
1633 memset(rc_port, 0, sizeof(rc_port));
1634 for (i = 0; i < RC_NPORT * RC_NBOARD; i++) {
1635 rc_port[i].magic = RISCOM8_MAGIC;
1636 INIT_WORK(&rc_port[i].tqueue, do_softint, &rc_port[i]);
1637 INIT_WORK(&rc_port[i].tqueue_hangup, do_rc_hangup, &rc_port[i]);
1638 rc_port[i].close_delay = 50 * HZ/100;
1639 rc_port[i].closing_wait = 3000 * HZ/100;
1640 init_waitqueue_head(&rc_port[i].open_wait);
1641 init_waitqueue_head(&rc_port[i].close_wait);
1647 static void rc_release_drivers(void)
1649 unsigned long flags;
1653 tty_unregister_driver(riscom_driver);
1654 put_tty_driver(riscom_driver);
1655 restore_flags(flags);
1660 * Called at boot time.
1662 * You can specify IO base for up to RC_NBOARD cards,
1663 * using line "riscom8=0xiobase1,0xiobase2,.." at LILO prompt.
1664 * Note that there will be no probing at default
1665 * addresses in this case.
1668 static int __init riscom8_setup(char *str)
1670 int ints[RC_NBOARD];
1673 str = get_options(str, ARRAY_SIZE(ints), ints);
1675 for (i = 0; i < RC_NBOARD; i++) {
1677 rc_board[i].base = ints[i+1];
1679 rc_board[i].base = 0;
1684 __setup("riscom8=", riscom8_setup);
1687 static char banner[] __initdata =
1688 KERN_INFO "rc: SDL RISCom/8 card driver v1.1, (c) D.Gorodchanin "
1690 static char no_boards_msg[] __initdata =
1691 KERN_INFO "rc: No RISCom/8 boards detected.\n";
1694 * This routine must be called by kernel at boot time
1696 static int __init riscom8_init(void)
1703 if (rc_init_drivers())
1706 for (i = 0; i < RC_NBOARD; i++)
1707 if (rc_board[i].base && !rc_probe(&rc_board[i]))
1711 rc_release_drivers();
1712 printk(no_boards_msg);
1723 module_param(iobase, int, 0);
1724 module_param(iobase1, int, 0);
1725 module_param(iobase2, int, 0);
1726 module_param(iobase3, int, 0);
1728 MODULE_LICENSE("GPL");
1732 * You can setup up to 4 boards (current value of RC_NBOARD)
1733 * by specifying "iobase=0xXXX iobase1=0xXXX ..." as insmod parameter.
1736 static int __init riscom8_init_module (void)
1741 if (iobase || iobase1 || iobase2 || iobase3) {
1742 for(i = 0; i < RC_NBOARD; i++)
1743 rc_board[0].base = 0;
1747 rc_board[0].base = iobase;
1749 rc_board[1].base = iobase1;
1751 rc_board[2].base = iobase2;
1753 rc_board[3].base = iobase3;
1756 return riscom8_init();
1759 static void __exit riscom8_exit_module (void)
1763 rc_release_drivers();
1764 for (i = 0; i < RC_NBOARD; i++)
1765 if (rc_board[i].flags & RC_BOARD_PRESENT)
1766 rc_release_io_range(&rc_board[i]);
1770 module_init(riscom8_init_module);
1771 module_exit(riscom8_exit_module);