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 struct riscom_board rc_board[RC_NBOARD] = {
100 static struct riscom_port rc_port[RC_NBOARD * RC_NPORT];
102 /* RISCom/8 I/O ports addresses (without address translation) */
103 static unsigned short rc_ioport[] = {
105 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0c,
107 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0c, 0x10,
108 0x11, 0x12, 0x18, 0x28, 0x31, 0x32, 0x39, 0x3a, 0x40, 0x41, 0x61, 0x62,
109 0x63, 0x64, 0x6b, 0x70, 0x71, 0x78, 0x7a, 0x7b, 0x7f, 0x100, 0x101
112 #define RC_NIOPORT ARRAY_SIZE(rc_ioport)
115 static inline int rc_paranoia_check(struct riscom_port const * port,
116 char *name, const char *routine)
118 #ifdef RISCOM_PARANOIA_CHECK
119 static const char badmagic[] = KERN_INFO
120 "rc: Warning: bad riscom port magic number for device %s in %s\n";
121 static const char badinfo[] = KERN_INFO
122 "rc: Warning: null riscom port for device %s in %s\n";
125 printk(badinfo, name, routine);
128 if (port->magic != RISCOM8_MAGIC) {
129 printk(badmagic, name, routine);
138 * Service functions for RISCom/8 driver.
142 /* Get board number from pointer */
143 static inline int board_No (struct riscom_board const * bp)
145 return bp - rc_board;
148 /* Get port number from pointer */
149 static inline int port_No (struct riscom_port const * port)
151 return RC_PORT(port - rc_port);
154 /* Get pointer to board from pointer to port */
155 static inline struct riscom_board * port_Board(struct riscom_port const * port)
157 return &rc_board[RC_BOARD(port - rc_port)];
160 /* Input Byte from CL CD180 register */
161 static inline unsigned char rc_in(struct riscom_board const * bp, unsigned short reg)
163 return inb(bp->base + RC_TO_ISA(reg));
166 /* Output Byte to CL CD180 register */
167 static inline void rc_out(struct riscom_board const * bp, unsigned short reg,
170 outb(val, bp->base + RC_TO_ISA(reg));
173 /* Wait for Channel Command Register ready */
174 static inline void rc_wait_CCR(struct riscom_board const * bp)
178 /* FIXME: need something more descriptive then 100000 :) */
179 for (delay = 100000; delay; delay--)
180 if (!rc_in(bp, CD180_CCR))
183 printk(KERN_INFO "rc%d: Timeout waiting for CCR.\n", board_No(bp));
187 * RISCom/8 probe functions.
190 static inline int rc_request_io_range(struct riscom_board * const bp)
194 for (i = 0; i < RC_NIOPORT; i++)
195 if (!request_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1,
201 printk(KERN_INFO "rc%d: Skipping probe at 0x%03x. IO address in use.\n",
202 board_No(bp), bp->base);
204 release_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1);
208 static inline void rc_release_io_range(struct riscom_board * const bp)
212 for (i = 0; i < RC_NIOPORT; i++)
213 release_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1);
216 /* Must be called with enabled interrupts */
217 static inline void rc_long_delay(unsigned long delay)
221 for (i = jiffies + delay; time_after(i,jiffies); ) ;
224 /* Reset and setup CD180 chip */
225 static void __init rc_init_CD180(struct riscom_board const * bp)
229 save_flags(flags); cli();
230 rc_out(bp, RC_CTOUT, 0); /* Clear timeout */
231 rc_wait_CCR(bp); /* Wait for CCR ready */
232 rc_out(bp, CD180_CCR, CCR_HARDRESET); /* Reset CD180 chip */
234 rc_long_delay(HZ/20); /* Delay 0.05 sec */
236 rc_out(bp, CD180_GIVR, RC_ID); /* Set ID for this chip */
237 rc_out(bp, CD180_GICR, 0); /* Clear all bits */
238 rc_out(bp, CD180_PILR1, RC_ACK_MINT); /* Prio for modem intr */
239 rc_out(bp, CD180_PILR2, RC_ACK_TINT); /* Prio for transmitter intr */
240 rc_out(bp, CD180_PILR3, RC_ACK_RINT); /* Prio for receiver intr */
242 /* Setting up prescaler. We need 4 ticks per 1 ms */
243 rc_out(bp, CD180_PPRH, (RC_OSCFREQ/(1000000/RISCOM_TPS)) >> 8);
244 rc_out(bp, CD180_PPRL, (RC_OSCFREQ/(1000000/RISCOM_TPS)) & 0xff);
246 restore_flags(flags);
249 /* Main probing routine, also sets irq. */
250 static int __init rc_probe(struct riscom_board *bp)
252 unsigned char val1, val2;
258 if (rc_request_io_range(bp))
261 /* Are the I/O ports here ? */
262 rc_out(bp, CD180_PPRL, 0x5a);
264 val1 = rc_in(bp, CD180_PPRL);
265 rc_out(bp, CD180_PPRL, 0xa5);
267 val2 = rc_in(bp, CD180_PPRL);
269 if ((val1 != 0x5a) || (val2 != 0xa5)) {
270 printk(KERN_ERR "rc%d: RISCom/8 Board at 0x%03x not found.\n",
271 board_No(bp), bp->base);
275 /* It's time to find IRQ for this board */
276 for (retries = 0; retries < 5 && irqs <= 0; retries++) {
277 irqs = probe_irq_on();
278 rc_init_CD180(bp); /* Reset CD180 chip */
279 rc_out(bp, CD180_CAR, 2); /* Select port 2 */
281 rc_out(bp, CD180_CCR, CCR_TXEN); /* Enable transmitter */
282 rc_out(bp, CD180_IER, IER_TXRDY); /* Enable tx empty intr */
283 rc_long_delay(HZ/20);
284 irqs = probe_irq_off(irqs);
285 val1 = rc_in(bp, RC_BSR); /* Get Board Status reg */
286 val2 = rc_in(bp, RC_ACK_TINT); /* ACK interrupt */
287 rc_init_CD180(bp); /* Reset CD180 again */
289 if ((val1 & RC_BSR_TINT) || (val2 != (RC_ID | GIVR_IT_TX))) {
290 printk(KERN_ERR "rc%d: RISCom/8 Board at 0x%03x not "
291 "found.\n", board_No(bp), bp->base);
297 printk(KERN_ERR "rc%d: Can't find IRQ for RISCom/8 board "
298 "at 0x%03x.\n", board_No(bp), bp->base);
302 bp->flags |= RC_BOARD_PRESENT;
304 printk(KERN_INFO "rc%d: RISCom/8 Rev. %c board detected at "
307 (rc_in(bp, CD180_GFRCR) & 0x0f) + 'A', /* Board revision */
312 rc_release_io_range(bp);
318 * Interrupt processing routines.
322 static inline void rc_mark_event(struct riscom_port * port, int event)
324 set_bit(event, &port->event);
325 schedule_work(&port->tqueue);
328 static inline struct riscom_port * rc_get_port(struct riscom_board const * bp,
329 unsigned char const * what)
331 unsigned char channel;
332 struct riscom_port * port;
334 channel = rc_in(bp, CD180_GICR) >> GICR_CHAN_OFF;
335 if (channel < CD180_NCH) {
336 port = &rc_port[board_No(bp) * RC_NPORT + channel];
337 if (port->flags & ASYNC_INITIALIZED) {
341 printk(KERN_ERR "rc%d: %s interrupt from invalid port %d\n",
342 board_No(bp), what, channel);
346 static inline void rc_receive_exc(struct riscom_board const * bp)
348 struct riscom_port *port;
349 struct tty_struct *tty;
350 unsigned char status;
351 unsigned char ch, flag;
353 if (!(port = rc_get_port(bp, "Receive")))
358 #ifdef RC_REPORT_OVERRUN
359 status = rc_in(bp, CD180_RCSR);
360 if (status & RCSR_OE)
362 status &= port->mark_mask;
364 status = rc_in(bp, CD180_RCSR) & port->mark_mask;
366 ch = rc_in(bp, CD180_RDR);
370 if (status & RCSR_TOUT) {
371 printk(KERN_WARNING "rc%d: port %d: Receiver timeout. "
372 "Hardware problems ?\n",
373 board_No(bp), port_No(port));
376 } else if (status & RCSR_BREAK) {
377 printk(KERN_INFO "rc%d: port %d: Handling break...\n",
378 board_No(bp), port_No(port));
380 if (port->flags & ASYNC_SAK)
383 } else if (status & RCSR_PE)
386 else if (status & RCSR_FE)
389 else if (status & RCSR_OE)
395 tty_insert_flip_char(tty, ch, flag);
396 tty_flip_buffer_push(tty);
399 static inline void rc_receive(struct riscom_board const * bp)
401 struct riscom_port *port;
402 struct tty_struct *tty;
405 if (!(port = rc_get_port(bp, "Receive")))
410 count = rc_in(bp, CD180_RDCR);
412 #ifdef RC_REPORT_FIFO
413 port->hits[count > 8 ? 9 : count]++;
417 if (tty_buffer_request_room(tty, 1) == 0) {
418 printk(KERN_WARNING "rc%d: port %d: Working around "
419 "flip buffer overflow.\n",
420 board_No(bp), port_No(port));
423 tty_insert_flip_char(tty, rc_in(bp, CD180_RDR), TTY_NORMAL);
425 tty_flip_buffer_push(tty);
428 static inline void rc_transmit(struct riscom_board const * bp)
430 struct riscom_port *port;
431 struct tty_struct *tty;
435 if (!(port = rc_get_port(bp, "Transmit")))
440 if (port->IER & IER_TXEMPTY) {
442 rc_out(bp, CD180_CAR, port_No(port));
443 port->IER &= ~IER_TXEMPTY;
444 rc_out(bp, CD180_IER, port->IER);
448 if ((port->xmit_cnt <= 0 && !port->break_length)
449 || tty->stopped || tty->hw_stopped) {
450 rc_out(bp, CD180_CAR, port_No(port));
451 port->IER &= ~IER_TXRDY;
452 rc_out(bp, CD180_IER, port->IER);
456 if (port->break_length) {
457 if (port->break_length > 0) {
458 if (port->COR2 & COR2_ETC) {
459 rc_out(bp, CD180_TDR, CD180_C_ESC);
460 rc_out(bp, CD180_TDR, CD180_C_SBRK);
461 port->COR2 &= ~COR2_ETC;
463 count = min_t(int, port->break_length, 0xff);
464 rc_out(bp, CD180_TDR, CD180_C_ESC);
465 rc_out(bp, CD180_TDR, CD180_C_DELAY);
466 rc_out(bp, CD180_TDR, count);
467 if (!(port->break_length -= count))
468 port->break_length--;
470 rc_out(bp, CD180_TDR, CD180_C_ESC);
471 rc_out(bp, CD180_TDR, CD180_C_EBRK);
472 rc_out(bp, CD180_COR2, port->COR2);
474 rc_out(bp, CD180_CCR, CCR_CORCHG2);
475 port->break_length = 0;
482 rc_out(bp, CD180_TDR, port->xmit_buf[port->xmit_tail++]);
483 port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE-1);
484 if (--port->xmit_cnt <= 0)
486 } while (--count > 0);
488 if (port->xmit_cnt <= 0) {
489 rc_out(bp, CD180_CAR, port_No(port));
490 port->IER &= ~IER_TXRDY;
491 rc_out(bp, CD180_IER, port->IER);
493 if (port->xmit_cnt <= port->wakeup_chars)
494 rc_mark_event(port, RS_EVENT_WRITE_WAKEUP);
497 static inline void rc_check_modem(struct riscom_board const * bp)
499 struct riscom_port *port;
500 struct tty_struct *tty;
503 if (!(port = rc_get_port(bp, "Modem")))
508 mcr = rc_in(bp, CD180_MCR);
509 if (mcr & MCR_CDCHG) {
510 if (rc_in(bp, CD180_MSVR) & MSVR_CD)
511 wake_up_interruptible(&port->open_wait);
513 schedule_work(&port->tqueue_hangup);
516 #ifdef RISCOM_BRAIN_DAMAGED_CTS
517 if (mcr & MCR_CTSCHG) {
518 if (rc_in(bp, CD180_MSVR) & MSVR_CTS) {
520 port->IER |= IER_TXRDY;
521 if (port->xmit_cnt <= port->wakeup_chars)
522 rc_mark_event(port, RS_EVENT_WRITE_WAKEUP);
525 port->IER &= ~IER_TXRDY;
527 rc_out(bp, CD180_IER, port->IER);
529 if (mcr & MCR_DSRCHG) {
530 if (rc_in(bp, CD180_MSVR) & MSVR_DSR) {
532 port->IER |= IER_TXRDY;
533 if (port->xmit_cnt <= port->wakeup_chars)
534 rc_mark_event(port, RS_EVENT_WRITE_WAKEUP);
537 port->IER &= ~IER_TXRDY;
539 rc_out(bp, CD180_IER, port->IER);
541 #endif /* RISCOM_BRAIN_DAMAGED_CTS */
543 /* Clear change bits */
544 rc_out(bp, CD180_MCR, 0);
547 /* The main interrupt processing routine */
548 static irqreturn_t rc_interrupt(int irq, void * dev_id)
550 unsigned char status;
552 struct riscom_board *bp;
553 unsigned long loop = 0;
556 bp = IRQ_to_board[irq];
558 if (!(bp->flags & RC_BOARD_ACTIVE))
561 while ((++loop < 16) && ((status = ~(rc_in(bp, RC_BSR))) &
562 (RC_BSR_TOUT | RC_BSR_TINT |
563 RC_BSR_MINT | RC_BSR_RINT))) {
565 if (status & RC_BSR_TOUT)
566 printk(KERN_WARNING "rc%d: Got timeout. Hardware "
567 "error?\n", board_No(bp));
569 else if (status & RC_BSR_RINT) {
570 ack = rc_in(bp, RC_ACK_RINT);
572 if (ack == (RC_ID | GIVR_IT_RCV))
574 else if (ack == (RC_ID | GIVR_IT_REXC))
577 printk(KERN_WARNING "rc%d: Bad receive ack "
581 } else if (status & RC_BSR_TINT) {
582 ack = rc_in(bp, RC_ACK_TINT);
584 if (ack == (RC_ID | GIVR_IT_TX))
587 printk(KERN_WARNING "rc%d: Bad transmit ack "
591 } else /* if (status & RC_BSR_MINT) */ {
592 ack = rc_in(bp, RC_ACK_MINT);
594 if (ack == (RC_ID | GIVR_IT_MODEM))
597 printk(KERN_WARNING "rc%d: Bad modem ack "
603 rc_out(bp, CD180_EOIR, 0); /* Mark end of interrupt */
604 rc_out(bp, RC_CTOUT, 0); /* Clear timeout flag */
606 return IRQ_RETVAL(handled);
610 * Routines for open & close processing.
613 /* Called with disabled interrupts */
614 static inline int rc_setup_board(struct riscom_board * bp)
618 if (bp->flags & RC_BOARD_ACTIVE)
621 error = request_irq(bp->irq, rc_interrupt, IRQF_DISABLED,
626 rc_out(bp, RC_CTOUT, 0); /* Just in case */
628 rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */
630 IRQ_to_board[bp->irq] = bp;
631 bp->flags |= RC_BOARD_ACTIVE;
636 /* Called with disabled interrupts */
637 static inline void rc_shutdown_board(struct riscom_board *bp)
639 if (!(bp->flags & RC_BOARD_ACTIVE))
642 bp->flags &= ~RC_BOARD_ACTIVE;
644 free_irq(bp->irq, NULL);
645 IRQ_to_board[bp->irq] = NULL;
648 rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */
653 * Setting up port characteristics.
654 * Must be called with disabled interrupts
656 static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
658 struct tty_struct *tty;
661 unsigned char cor1 = 0, cor3 = 0;
662 unsigned char mcor1 = 0, mcor2 = 0;
664 if (!(tty = port->tty) || !tty->termios)
669 port->MSVR = MSVR_RTS;
671 baud = tty_get_baud_rate(tty);
673 /* Select port on the board */
674 rc_out(bp, CD180_CAR, port_No(port));
677 /* Drop DTR & exit */
678 bp->DTR |= (1u << port_No(port));
679 rc_out(bp, RC_DTR, bp->DTR);
683 bp->DTR &= ~(1u << port_No(port));
684 rc_out(bp, RC_DTR, bp->DTR);
688 * Now we must calculate some speed depended things
691 /* Set baud rate for port */
692 tmp = (((RC_OSCFREQ + baud/2) / baud +
693 CD180_TPC/2) / CD180_TPC);
695 rc_out(bp, CD180_RBPRH, (tmp >> 8) & 0xff);
696 rc_out(bp, CD180_TBPRH, (tmp >> 8) & 0xff);
697 rc_out(bp, CD180_RBPRL, tmp & 0xff);
698 rc_out(bp, CD180_TBPRL, tmp & 0xff);
700 baud = (baud + 5) / 10; /* Estimated CPS */
702 /* Two timer ticks seems enough to wakeup something like SLIP driver */
703 tmp = ((baud + HZ/2) / HZ) * 2 - CD180_NFIFO;
704 port->wakeup_chars = (tmp < 0) ? 0 : ((tmp >= SERIAL_XMIT_SIZE) ?
705 SERIAL_XMIT_SIZE - 1 : tmp);
707 /* Receiver timeout will be transmission time for 1.5 chars */
708 tmp = (RISCOM_TPS + RISCOM_TPS/2 + baud/2) / baud;
709 tmp = (tmp > 0xff) ? 0xff : tmp;
710 rc_out(bp, CD180_RTPR, tmp);
712 switch (C_CSIZE(tty)) {
732 cor1 |= COR1_NORMPAR;
736 cor1 &= ~COR1_IGNORE;
738 /* Set marking of some errors */
739 port->mark_mask = RCSR_OE | RCSR_TOUT;
741 port->mark_mask |= RCSR_FE | RCSR_PE;
742 if (I_BRKINT(tty) || I_PARMRK(tty))
743 port->mark_mask |= RCSR_BREAK;
745 port->mark_mask &= ~(RCSR_FE | RCSR_PE);
747 port->mark_mask &= ~RCSR_BREAK;
749 /* Real raw mode. Ignore all */
750 port->mark_mask &= ~RCSR_OE;
752 /* Enable Hardware Flow Control */
753 if (C_CRTSCTS(tty)) {
754 #ifdef RISCOM_BRAIN_DAMAGED_CTS
755 port->IER |= IER_DSR | IER_CTS;
756 mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD;
757 mcor2 |= MCOR2_DSROD | MCOR2_CTSOD;
758 tty->hw_stopped = !(rc_in(bp, CD180_MSVR) & (MSVR_CTS|MSVR_DSR));
760 port->COR2 |= COR2_CTSAE;
763 /* Enable Software Flow Control. FIXME: I'm not sure about this */
764 /* Some people reported that it works, but I still doubt */
766 port->COR2 |= COR2_TXIBE;
767 cor3 |= (COR3_FCT | COR3_SCDE);
769 port->COR2 |= COR2_IXM;
770 rc_out(bp, CD180_SCHR1, START_CHAR(tty));
771 rc_out(bp, CD180_SCHR2, STOP_CHAR(tty));
772 rc_out(bp, CD180_SCHR3, START_CHAR(tty));
773 rc_out(bp, CD180_SCHR4, STOP_CHAR(tty));
775 if (!C_CLOCAL(tty)) {
776 /* Enable CD check */
783 /* Enable receiver */
784 port->IER |= IER_RXD;
786 /* Set input FIFO size (1-8 bytes) */
787 cor3 |= RISCOM_RXFIFO;
788 /* Setting up CD180 channel registers */
789 rc_out(bp, CD180_COR1, cor1);
790 rc_out(bp, CD180_COR2, port->COR2);
791 rc_out(bp, CD180_COR3, cor3);
792 /* Make CD180 know about registers change */
794 rc_out(bp, CD180_CCR, CCR_CORCHG1 | CCR_CORCHG2 | CCR_CORCHG3);
795 /* Setting up modem option registers */
796 rc_out(bp, CD180_MCOR1, mcor1);
797 rc_out(bp, CD180_MCOR2, mcor2);
798 /* Enable CD180 transmitter & receiver */
800 rc_out(bp, CD180_CCR, CCR_TXEN | CCR_RXEN);
801 /* Enable interrupts */
802 rc_out(bp, CD180_IER, port->IER);
803 /* And finally set RTS on */
804 rc_out(bp, CD180_MSVR, port->MSVR);
807 /* Must be called with interrupts enabled */
808 static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
812 if (port->flags & ASYNC_INITIALIZED)
815 if (!port->xmit_buf) {
816 /* We may sleep in get_zeroed_page() */
819 if (!(tmp = get_zeroed_page(GFP_KERNEL)))
822 if (port->xmit_buf) {
826 port->xmit_buf = (unsigned char *) tmp;
829 save_flags(flags); cli();
832 clear_bit(TTY_IO_ERROR, &port->tty->flags);
834 if (port->count == 1)
837 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
838 rc_change_speed(bp, port);
839 port->flags |= ASYNC_INITIALIZED;
841 restore_flags(flags);
845 /* Must be called with interrupts disabled */
846 static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
848 struct tty_struct *tty;
850 if (!(port->flags & ASYNC_INITIALIZED))
853 #ifdef RC_REPORT_OVERRUN
854 printk(KERN_INFO "rc%d: port %d: Total %ld overruns were detected.\n",
855 board_No(bp), port_No(port), port->overrun);
857 #ifdef RC_REPORT_FIFO
861 printk(KERN_INFO "rc%d: port %d: FIFO hits [ ",
862 board_No(bp), port_No(port));
863 for (i = 0; i < 10; i++) {
864 printk("%ld ", port->hits[i]);
869 if (port->xmit_buf) {
870 free_page((unsigned long) port->xmit_buf);
871 port->xmit_buf = NULL;
874 if (!(tty = port->tty) || C_HUPCL(tty)) {
876 bp->DTR |= (1u << port_No(port));
877 rc_out(bp, RC_DTR, bp->DTR);
881 rc_out(bp, CD180_CAR, port_No(port));
884 rc_out(bp, CD180_CCR, CCR_SOFTRESET);
885 /* Disable all interrupts from this port */
887 rc_out(bp, CD180_IER, port->IER);
890 set_bit(TTY_IO_ERROR, &tty->flags);
891 port->flags &= ~ASYNC_INITIALIZED;
893 if (--bp->count < 0) {
894 printk(KERN_INFO "rc%d: rc_shutdown_port: "
895 "bad board count: %d\n",
896 board_No(bp), bp->count);
901 * If this is the last opened port on the board
902 * shutdown whole board
905 rc_shutdown_board(bp);
909 static int block_til_ready(struct tty_struct *tty, struct file * filp,
910 struct riscom_port *port)
912 DECLARE_WAITQUEUE(wait, current);
913 struct riscom_board *bp = port_Board(port);
919 * If the device is in the middle of being closed, then block
920 * until it's done, and then try again.
922 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) {
923 interruptible_sleep_on(&port->close_wait);
924 if (port->flags & ASYNC_HUP_NOTIFY)
931 * If non-blocking mode is set, or the port is not enabled,
932 * then make the check up front and then exit.
934 if ((filp->f_flags & O_NONBLOCK) ||
935 (tty->flags & (1 << TTY_IO_ERROR))) {
936 port->flags |= ASYNC_NORMAL_ACTIVE;
944 * Block waiting for the carrier detect and the line to become
945 * free (i.e., not in use by the callout). While we are in
946 * this loop, info->count is dropped by one, so that
947 * rs_close() knows when to free things. We restore it upon
948 * exit, either normal or abnormal.
951 add_wait_queue(&port->open_wait, &wait);
953 if (!tty_hung_up_p(filp))
956 port->blocked_open++;
959 rc_out(bp, CD180_CAR, port_No(port));
960 CD = rc_in(bp, CD180_MSVR) & MSVR_CD;
961 rc_out(bp, CD180_MSVR, MSVR_RTS);
962 bp->DTR &= ~(1u << port_No(port));
963 rc_out(bp, RC_DTR, bp->DTR);
965 set_current_state(TASK_INTERRUPTIBLE);
966 if (tty_hung_up_p(filp) ||
967 !(port->flags & ASYNC_INITIALIZED)) {
968 if (port->flags & ASYNC_HUP_NOTIFY)
971 retval = -ERESTARTSYS;
974 if (!(port->flags & ASYNC_CLOSING) &&
977 if (signal_pending(current)) {
978 retval = -ERESTARTSYS;
983 current->state = TASK_RUNNING;
984 remove_wait_queue(&port->open_wait, &wait);
985 if (!tty_hung_up_p(filp))
987 port->blocked_open--;
991 port->flags |= ASYNC_NORMAL_ACTIVE;
995 static int rc_open(struct tty_struct * tty, struct file * filp)
999 struct riscom_port * port;
1000 struct riscom_board * bp;
1002 board = RC_BOARD(tty->index);
1003 if (board >= RC_NBOARD || !(rc_board[board].flags & RC_BOARD_PRESENT))
1006 bp = &rc_board[board];
1007 port = rc_port + board * RC_NPORT + RC_PORT(tty->index);
1008 if (rc_paranoia_check(port, tty->name, "rc_open"))
1011 if ((error = rc_setup_board(bp)))
1015 tty->driver_data = port;
1018 if ((error = rc_setup_port(bp, port)))
1021 if ((error = block_til_ready(tty, filp, port)))
1027 static void rc_close(struct tty_struct * tty, struct file * filp)
1029 struct riscom_port *port = (struct riscom_port *) tty->driver_data;
1030 struct riscom_board *bp;
1031 unsigned long flags;
1032 unsigned long timeout;
1034 if (!port || rc_paranoia_check(port, tty->name, "close"))
1037 save_flags(flags); cli();
1038 if (tty_hung_up_p(filp))
1041 bp = port_Board(port);
1042 if ((tty->count == 1) && (port->count != 1)) {
1043 printk(KERN_INFO "rc%d: rc_close: bad port count;"
1044 " tty->count is 1, port count is %d\n",
1045 board_No(bp), port->count);
1048 if (--port->count < 0) {
1049 printk(KERN_INFO "rc%d: rc_close: bad port count "
1051 board_No(bp), port_No(port), port->count);
1056 port->flags |= ASYNC_CLOSING;
1058 * Now we wait for the transmit buffer to clear; and we notify
1059 * the line discipline to only process XON/XOFF characters.
1062 if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
1063 tty_wait_until_sent(tty, port->closing_wait);
1065 * At this point we stop accepting input. To do this, we
1066 * disable the receive line status interrupts, and tell the
1067 * interrupt driver to stop checking the data ready bit in the
1068 * line status register.
1070 port->IER &= ~IER_RXD;
1071 if (port->flags & ASYNC_INITIALIZED) {
1072 port->IER &= ~IER_TXRDY;
1073 port->IER |= IER_TXEMPTY;
1074 rc_out(bp, CD180_CAR, port_No(port));
1075 rc_out(bp, CD180_IER, port->IER);
1077 * Before we drop DTR, make sure the UART transmitter
1078 * has completely drained; this is especially
1079 * important if there is a transmit FIFO!
1081 timeout = jiffies+HZ;
1082 while(port->IER & IER_TXEMPTY) {
1083 msleep_interruptible(jiffies_to_msecs(port->timeout));
1084 if (time_after(jiffies, timeout))
1088 rc_shutdown_port(bp, port);
1089 if (tty->driver->flush_buffer)
1090 tty->driver->flush_buffer(tty);
1091 tty_ldisc_flush(tty);
1096 if (port->blocked_open) {
1097 if (port->close_delay) {
1098 msleep_interruptible(jiffies_to_msecs(port->close_delay));
1100 wake_up_interruptible(&port->open_wait);
1102 port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
1103 wake_up_interruptible(&port->close_wait);
1104 out: restore_flags(flags);
1107 static int rc_write(struct tty_struct * tty,
1108 const unsigned char *buf, int count)
1110 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1111 struct riscom_board *bp;
1113 unsigned long flags;
1115 if (rc_paranoia_check(port, tty->name, "rc_write"))
1118 bp = port_Board(port);
1120 if (!tty || !port->xmit_buf)
1126 c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
1127 SERIAL_XMIT_SIZE - port->xmit_head));
1129 restore_flags(flags);
1133 memcpy(port->xmit_buf + port->xmit_head, buf, c);
1134 port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
1135 port->xmit_cnt += c;
1136 restore_flags(flags);
1144 if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped &&
1145 !(port->IER & IER_TXRDY)) {
1146 port->IER |= IER_TXRDY;
1147 rc_out(bp, CD180_CAR, port_No(port));
1148 rc_out(bp, CD180_IER, port->IER);
1150 restore_flags(flags);
1155 static void rc_put_char(struct tty_struct * tty, unsigned char ch)
1157 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1158 unsigned long flags;
1160 if (rc_paranoia_check(port, tty->name, "rc_put_char"))
1163 if (!tty || !port->xmit_buf)
1166 save_flags(flags); cli();
1168 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
1171 port->xmit_buf[port->xmit_head++] = ch;
1172 port->xmit_head &= SERIAL_XMIT_SIZE - 1;
1174 out: restore_flags(flags);
1177 static void rc_flush_chars(struct tty_struct * tty)
1179 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1180 unsigned long flags;
1182 if (rc_paranoia_check(port, tty->name, "rc_flush_chars"))
1185 if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
1189 save_flags(flags); cli();
1190 port->IER |= IER_TXRDY;
1191 rc_out(port_Board(port), CD180_CAR, port_No(port));
1192 rc_out(port_Board(port), CD180_IER, port->IER);
1193 restore_flags(flags);
1196 static int rc_write_room(struct tty_struct * tty)
1198 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1201 if (rc_paranoia_check(port, tty->name, "rc_write_room"))
1204 ret = SERIAL_XMIT_SIZE - port->xmit_cnt - 1;
1210 static int rc_chars_in_buffer(struct tty_struct *tty)
1212 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1214 if (rc_paranoia_check(port, tty->name, "rc_chars_in_buffer"))
1217 return port->xmit_cnt;
1220 static void rc_flush_buffer(struct tty_struct *tty)
1222 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1223 unsigned long flags;
1225 if (rc_paranoia_check(port, tty->name, "rc_flush_buffer"))
1228 save_flags(flags); cli();
1229 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
1230 restore_flags(flags);
1232 wake_up_interruptible(&tty->write_wait);
1236 static int rc_tiocmget(struct tty_struct *tty, struct file *file)
1238 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1239 struct riscom_board * bp;
1240 unsigned char status;
1241 unsigned int result;
1242 unsigned long flags;
1244 if (rc_paranoia_check(port, tty->name, __FUNCTION__))
1247 bp = port_Board(port);
1248 save_flags(flags); cli();
1249 rc_out(bp, CD180_CAR, port_No(port));
1250 status = rc_in(bp, CD180_MSVR);
1251 result = rc_in(bp, RC_RI) & (1u << port_No(port)) ? 0 : TIOCM_RNG;
1252 restore_flags(flags);
1253 result |= ((status & MSVR_RTS) ? TIOCM_RTS : 0)
1254 | ((status & MSVR_DTR) ? TIOCM_DTR : 0)
1255 | ((status & MSVR_CD) ? TIOCM_CAR : 0)
1256 | ((status & MSVR_DSR) ? TIOCM_DSR : 0)
1257 | ((status & MSVR_CTS) ? TIOCM_CTS : 0);
1261 static int rc_tiocmset(struct tty_struct *tty, struct file *file,
1262 unsigned int set, unsigned int clear)
1264 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1265 unsigned long flags;
1266 struct riscom_board *bp;
1268 if (rc_paranoia_check(port, tty->name, __FUNCTION__))
1271 bp = port_Board(port);
1273 save_flags(flags); cli();
1274 if (set & TIOCM_RTS)
1275 port->MSVR |= MSVR_RTS;
1276 if (set & TIOCM_DTR)
1277 bp->DTR &= ~(1u << port_No(port));
1279 if (clear & TIOCM_RTS)
1280 port->MSVR &= ~MSVR_RTS;
1281 if (clear & TIOCM_DTR)
1282 bp->DTR |= (1u << port_No(port));
1284 rc_out(bp, CD180_CAR, port_No(port));
1285 rc_out(bp, CD180_MSVR, port->MSVR);
1286 rc_out(bp, RC_DTR, bp->DTR);
1287 restore_flags(flags);
1291 static inline void rc_send_break(struct riscom_port * port, unsigned long length)
1293 struct riscom_board *bp = port_Board(port);
1294 unsigned long flags;
1296 save_flags(flags); cli();
1297 port->break_length = RISCOM_TPS / HZ * length;
1298 port->COR2 |= COR2_ETC;
1299 port->IER |= IER_TXRDY;
1300 rc_out(bp, CD180_CAR, port_No(port));
1301 rc_out(bp, CD180_COR2, port->COR2);
1302 rc_out(bp, CD180_IER, port->IER);
1304 rc_out(bp, CD180_CCR, CCR_CORCHG2);
1306 restore_flags(flags);
1309 static inline int rc_set_serial_info(struct riscom_port * port,
1310 struct serial_struct __user * newinfo)
1312 struct serial_struct tmp;
1313 struct riscom_board *bp = port_Board(port);
1315 unsigned long flags;
1317 if (copy_from_user(&tmp, newinfo, sizeof(tmp)))
1321 if ((tmp.irq != bp->irq) ||
1322 (tmp.port != bp->base) ||
1323 (tmp.type != PORT_CIRRUS) ||
1324 (tmp.baud_base != (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC) ||
1325 (tmp.custom_divisor != 0) ||
1326 (tmp.xmit_fifo_size != CD180_NFIFO) ||
1327 (tmp.flags & ~RISCOM_LEGAL_FLAGS))
1331 change_speed = ((port->flags & ASYNC_SPD_MASK) !=
1332 (tmp.flags & ASYNC_SPD_MASK));
1334 if (!capable(CAP_SYS_ADMIN)) {
1335 if ((tmp.close_delay != port->close_delay) ||
1336 (tmp.closing_wait != port->closing_wait) ||
1337 ((tmp.flags & ~ASYNC_USR_MASK) !=
1338 (port->flags & ~ASYNC_USR_MASK)))
1340 port->flags = ((port->flags & ~ASYNC_USR_MASK) |
1341 (tmp.flags & ASYNC_USR_MASK));
1343 port->flags = ((port->flags & ~ASYNC_FLAGS) |
1344 (tmp.flags & ASYNC_FLAGS));
1345 port->close_delay = tmp.close_delay;
1346 port->closing_wait = tmp.closing_wait;
1349 save_flags(flags); cli();
1350 rc_change_speed(bp, port);
1351 restore_flags(flags);
1356 static inline int rc_get_serial_info(struct riscom_port * port,
1357 struct serial_struct __user *retinfo)
1359 struct serial_struct tmp;
1360 struct riscom_board *bp = port_Board(port);
1362 memset(&tmp, 0, sizeof(tmp));
1363 tmp.type = PORT_CIRRUS;
1364 tmp.line = port - rc_port;
1365 tmp.port = bp->base;
1367 tmp.flags = port->flags;
1368 tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC;
1369 tmp.close_delay = port->close_delay * HZ/100;
1370 tmp.closing_wait = port->closing_wait * HZ/100;
1371 tmp.xmit_fifo_size = CD180_NFIFO;
1372 return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0;
1375 static int rc_ioctl(struct tty_struct * tty, struct file * filp,
1376 unsigned int cmd, unsigned long arg)
1379 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1380 void __user *argp = (void __user *)arg;
1383 if (rc_paranoia_check(port, tty->name, "rc_ioctl"))
1387 case TCSBRK: /* SVID version: non-zero arg --> no break */
1388 retval = tty_check_change(tty);
1391 tty_wait_until_sent(tty, 0);
1393 rc_send_break(port, HZ/4); /* 1/4 second */
1395 case TCSBRKP: /* support for POSIX tcsendbreak() */
1396 retval = tty_check_change(tty);
1399 tty_wait_until_sent(tty, 0);
1400 rc_send_break(port, arg ? arg*(HZ/10) : HZ/4);
1403 return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned __user *)argp);
1405 if (get_user(arg,(unsigned __user *) argp))
1407 tty->termios->c_cflag =
1408 ((tty->termios->c_cflag & ~CLOCAL) |
1409 (arg ? CLOCAL : 0));
1412 return rc_get_serial_info(port, argp);
1414 return rc_set_serial_info(port, argp);
1416 return -ENOIOCTLCMD;
1421 static void rc_throttle(struct tty_struct * tty)
1423 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1424 struct riscom_board *bp;
1425 unsigned long flags;
1427 if (rc_paranoia_check(port, tty->name, "rc_throttle"))
1430 bp = port_Board(port);
1432 save_flags(flags); cli();
1433 port->MSVR &= ~MSVR_RTS;
1434 rc_out(bp, CD180_CAR, port_No(port));
1437 rc_out(bp, CD180_CCR, CCR_SSCH2);
1440 rc_out(bp, CD180_MSVR, port->MSVR);
1441 restore_flags(flags);
1444 static void rc_unthrottle(struct tty_struct * tty)
1446 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1447 struct riscom_board *bp;
1448 unsigned long flags;
1450 if (rc_paranoia_check(port, tty->name, "rc_unthrottle"))
1453 bp = port_Board(port);
1455 save_flags(flags); cli();
1456 port->MSVR |= MSVR_RTS;
1457 rc_out(bp, CD180_CAR, port_No(port));
1460 rc_out(bp, CD180_CCR, CCR_SSCH1);
1463 rc_out(bp, CD180_MSVR, port->MSVR);
1464 restore_flags(flags);
1467 static void rc_stop(struct tty_struct * tty)
1469 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1470 struct riscom_board *bp;
1471 unsigned long flags;
1473 if (rc_paranoia_check(port, tty->name, "rc_stop"))
1476 bp = port_Board(port);
1478 save_flags(flags); cli();
1479 port->IER &= ~IER_TXRDY;
1480 rc_out(bp, CD180_CAR, port_No(port));
1481 rc_out(bp, CD180_IER, port->IER);
1482 restore_flags(flags);
1485 static void rc_start(struct tty_struct * tty)
1487 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1488 struct riscom_board *bp;
1489 unsigned long flags;
1491 if (rc_paranoia_check(port, tty->name, "rc_start"))
1494 bp = port_Board(port);
1496 save_flags(flags); cli();
1497 if (port->xmit_cnt && port->xmit_buf && !(port->IER & IER_TXRDY)) {
1498 port->IER |= IER_TXRDY;
1499 rc_out(bp, CD180_CAR, port_No(port));
1500 rc_out(bp, CD180_IER, port->IER);
1502 restore_flags(flags);
1506 * This routine is called from the work queue when the interrupt
1507 * routine has signalled that a hangup has occurred. The path of
1508 * hangup processing is:
1510 * serial interrupt routine -> (workqueue) ->
1511 * do_rc_hangup() -> tty->hangup() -> rc_hangup()
1514 static void do_rc_hangup(struct work_struct *ugly_api)
1516 struct riscom_port *port = container_of(ugly_api, struct riscom_port, tqueue_hangup);
1517 struct tty_struct *tty;
1521 tty_hangup(tty); /* FIXME: module removal race still here */
1524 static void rc_hangup(struct tty_struct * tty)
1526 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1527 struct riscom_board *bp;
1529 if (rc_paranoia_check(port, tty->name, "rc_hangup"))
1532 bp = port_Board(port);
1534 rc_shutdown_port(bp, port);
1537 port->flags &= ~ASYNC_NORMAL_ACTIVE;
1539 wake_up_interruptible(&port->open_wait);
1542 static void rc_set_termios(struct tty_struct * tty, struct termios * old_termios)
1544 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1545 unsigned long flags;
1547 if (rc_paranoia_check(port, tty->name, "rc_set_termios"))
1550 if (tty->termios->c_cflag == old_termios->c_cflag &&
1551 tty->termios->c_iflag == old_termios->c_iflag)
1554 save_flags(flags); cli();
1555 rc_change_speed(port_Board(port), port);
1556 restore_flags(flags);
1558 if ((old_termios->c_cflag & CRTSCTS) &&
1559 !(tty->termios->c_cflag & CRTSCTS)) {
1560 tty->hw_stopped = 0;
1565 static void do_softint(struct work_struct *ugly_api)
1567 struct riscom_port *port = container_of(ugly_api, struct riscom_port, tqueue);
1568 struct tty_struct *tty;
1570 if(!(tty = port->tty))
1573 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event)) {
1575 wake_up_interruptible(&tty->write_wait);
1579 static const struct tty_operations riscom_ops = {
1583 .put_char = rc_put_char,
1584 .flush_chars = rc_flush_chars,
1585 .write_room = rc_write_room,
1586 .chars_in_buffer = rc_chars_in_buffer,
1587 .flush_buffer = rc_flush_buffer,
1589 .throttle = rc_throttle,
1590 .unthrottle = rc_unthrottle,
1591 .set_termios = rc_set_termios,
1594 .hangup = rc_hangup,
1595 .tiocmget = rc_tiocmget,
1596 .tiocmset = rc_tiocmset,
1599 static inline int rc_init_drivers(void)
1604 riscom_driver = alloc_tty_driver(RC_NBOARD * RC_NPORT);
1608 memset(IRQ_to_board, 0, sizeof(IRQ_to_board));
1609 riscom_driver->owner = THIS_MODULE;
1610 riscom_driver->name = "ttyL";
1611 riscom_driver->major = RISCOM8_NORMAL_MAJOR;
1612 riscom_driver->type = TTY_DRIVER_TYPE_SERIAL;
1613 riscom_driver->subtype = SERIAL_TYPE_NORMAL;
1614 riscom_driver->init_termios = tty_std_termios;
1615 riscom_driver->init_termios.c_cflag =
1616 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1617 riscom_driver->flags = TTY_DRIVER_REAL_RAW;
1618 tty_set_operations(riscom_driver, &riscom_ops);
1619 if ((error = tty_register_driver(riscom_driver))) {
1620 put_tty_driver(riscom_driver);
1621 printk(KERN_ERR "rc: Couldn't register RISCom/8 driver, "
1627 memset(rc_port, 0, sizeof(rc_port));
1628 for (i = 0; i < RC_NPORT * RC_NBOARD; i++) {
1629 rc_port[i].magic = RISCOM8_MAGIC;
1630 INIT_WORK(&rc_port[i].tqueue, do_softint);
1631 INIT_WORK(&rc_port[i].tqueue_hangup, do_rc_hangup);
1632 rc_port[i].close_delay = 50 * HZ/100;
1633 rc_port[i].closing_wait = 3000 * HZ/100;
1634 init_waitqueue_head(&rc_port[i].open_wait);
1635 init_waitqueue_head(&rc_port[i].close_wait);
1641 static void rc_release_drivers(void)
1643 unsigned long flags;
1647 tty_unregister_driver(riscom_driver);
1648 put_tty_driver(riscom_driver);
1649 restore_flags(flags);
1654 * Called at boot time.
1656 * You can specify IO base for up to RC_NBOARD cards,
1657 * using line "riscom8=0xiobase1,0xiobase2,.." at LILO prompt.
1658 * Note that there will be no probing at default
1659 * addresses in this case.
1662 static int __init riscom8_setup(char *str)
1664 int ints[RC_NBOARD];
1667 str = get_options(str, ARRAY_SIZE(ints), ints);
1669 for (i = 0; i < RC_NBOARD; i++) {
1671 rc_board[i].base = ints[i+1];
1673 rc_board[i].base = 0;
1678 __setup("riscom8=", riscom8_setup);
1681 static char banner[] __initdata =
1682 KERN_INFO "rc: SDL RISCom/8 card driver v1.1, (c) D.Gorodchanin "
1684 static char no_boards_msg[] __initdata =
1685 KERN_INFO "rc: No RISCom/8 boards detected.\n";
1688 * This routine must be called by kernel at boot time
1690 static int __init riscom8_init(void)
1697 if (rc_init_drivers())
1700 for (i = 0; i < RC_NBOARD; i++)
1701 if (rc_board[i].base && !rc_probe(&rc_board[i]))
1705 rc_release_drivers();
1706 printk(no_boards_msg);
1717 module_param(iobase, int, 0);
1718 module_param(iobase1, int, 0);
1719 module_param(iobase2, int, 0);
1720 module_param(iobase3, int, 0);
1722 MODULE_LICENSE("GPL");
1726 * You can setup up to 4 boards (current value of RC_NBOARD)
1727 * by specifying "iobase=0xXXX iobase1=0xXXX ..." as insmod parameter.
1730 static int __init riscom8_init_module (void)
1735 if (iobase || iobase1 || iobase2 || iobase3) {
1736 for(i = 0; i < RC_NBOARD; i++)
1737 rc_board[0].base = 0;
1741 rc_board[0].base = iobase;
1743 rc_board[1].base = iobase1;
1745 rc_board[2].base = iobase2;
1747 rc_board[3].base = iobase3;
1750 return riscom8_init();
1753 static void __exit riscom8_exit_module (void)
1757 rc_release_drivers();
1758 for (i = 0; i < RC_NBOARD; i++)
1759 if (rc_board[i].flags & RC_BOARD_PRESENT)
1760 rc_release_io_range(&rc_board[i]);
1764 module_init(riscom8_init_module);
1765 module_exit(riscom8_exit_module);