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>
50 #include <linux/spinlock.h>
52 #include <asm/uaccess.h>
55 #include "riscom8_reg.h"
57 /* Am I paranoid or not ? ;-) */
58 #define RISCOM_PARANOIA_CHECK
61 * Crazy InteliCom/8 boards sometimes has swapped CTS & DSR signals.
62 * You can slightly speed up things by #undefing the following option,
63 * if you are REALLY sure that your board is correct one.
66 #define RISCOM_BRAIN_DAMAGED_CTS
69 * The following defines are mostly for testing purposes. But if you need
70 * some nice reporting in your syslog, you can define them also.
73 #undef RC_REPORT_OVERRUN
76 #define RISCOM_LEGAL_FLAGS \
77 (ASYNC_HUP_NOTIFY | ASYNC_SAK | ASYNC_SPLIT_TERMIOS | \
78 ASYNC_SPD_HI | ASYNC_SPEED_VHI | ASYNC_SESSION_LOCKOUT | \
79 ASYNC_PGRP_LOCKOUT | ASYNC_CALLOUT_NOHUP)
81 static struct tty_driver *riscom_driver;
83 static DEFINE_SPINLOCK(riscom_lock);
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 /* Reset and setup CD180 chip */
217 static void __init rc_init_CD180(struct riscom_board const * bp)
221 spin_lock_irqsave(&riscom_lock, flags);
223 rc_out(bp, RC_CTOUT, 0); /* Clear timeout */
224 rc_wait_CCR(bp); /* Wait for CCR ready */
225 rc_out(bp, CD180_CCR, CCR_HARDRESET); /* Reset CD180 chip */
226 spin_unlock_irqrestore(&riscom_lock, flags);
227 msleep(50); /* Delay 0.05 sec */
228 spin_lock_irqsave(&riscom_lock, flags);
229 rc_out(bp, CD180_GIVR, RC_ID); /* Set ID for this chip */
230 rc_out(bp, CD180_GICR, 0); /* Clear all bits */
231 rc_out(bp, CD180_PILR1, RC_ACK_MINT); /* Prio for modem intr */
232 rc_out(bp, CD180_PILR2, RC_ACK_TINT); /* Prio for transmitter intr */
233 rc_out(bp, CD180_PILR3, RC_ACK_RINT); /* Prio for receiver intr */
235 /* Setting up prescaler. We need 4 ticks per 1 ms */
236 rc_out(bp, CD180_PPRH, (RC_OSCFREQ/(1000000/RISCOM_TPS)) >> 8);
237 rc_out(bp, CD180_PPRL, (RC_OSCFREQ/(1000000/RISCOM_TPS)) & 0xff);
239 spin_unlock_irqrestore(&riscom_lock, flags);
242 /* Main probing routine, also sets irq. */
243 static int __init rc_probe(struct riscom_board *bp)
245 unsigned char val1, val2;
251 if (rc_request_io_range(bp))
254 /* Are the I/O ports here ? */
255 rc_out(bp, CD180_PPRL, 0x5a);
257 val1 = rc_in(bp, CD180_PPRL);
258 rc_out(bp, CD180_PPRL, 0xa5);
260 val2 = rc_in(bp, CD180_PPRL);
262 if ((val1 != 0x5a) || (val2 != 0xa5)) {
263 printk(KERN_ERR "rc%d: RISCom/8 Board at 0x%03x not found.\n",
264 board_No(bp), bp->base);
268 /* It's time to find IRQ for this board */
269 for (retries = 0; retries < 5 && irqs <= 0; retries++) {
270 irqs = probe_irq_on();
271 rc_init_CD180(bp); /* Reset CD180 chip */
272 rc_out(bp, CD180_CAR, 2); /* Select port 2 */
274 rc_out(bp, CD180_CCR, CCR_TXEN); /* Enable transmitter */
275 rc_out(bp, CD180_IER, IER_TXRDY); /* Enable tx empty intr */
277 irqs = probe_irq_off(irqs);
278 val1 = rc_in(bp, RC_BSR); /* Get Board Status reg */
279 val2 = rc_in(bp, RC_ACK_TINT); /* ACK interrupt */
280 rc_init_CD180(bp); /* Reset CD180 again */
282 if ((val1 & RC_BSR_TINT) || (val2 != (RC_ID | GIVR_IT_TX))) {
283 printk(KERN_ERR "rc%d: RISCom/8 Board at 0x%03x not "
284 "found.\n", board_No(bp), bp->base);
290 printk(KERN_ERR "rc%d: Can't find IRQ for RISCom/8 board "
291 "at 0x%03x.\n", board_No(bp), bp->base);
295 bp->flags |= RC_BOARD_PRESENT;
297 printk(KERN_INFO "rc%d: RISCom/8 Rev. %c board detected at "
300 (rc_in(bp, CD180_GFRCR) & 0x0f) + 'A', /* Board revision */
305 rc_release_io_range(bp);
311 * Interrupt processing routines.
315 static inline struct riscom_port * rc_get_port(struct riscom_board const * bp,
316 unsigned char const * what)
318 unsigned char channel;
319 struct riscom_port * port;
321 channel = rc_in(bp, CD180_GICR) >> GICR_CHAN_OFF;
322 if (channel < CD180_NCH) {
323 port = &rc_port[board_No(bp) * RC_NPORT + channel];
324 if (port->flags & ASYNC_INITIALIZED) {
328 printk(KERN_ERR "rc%d: %s interrupt from invalid port %d\n",
329 board_No(bp), what, channel);
333 static inline void rc_receive_exc(struct riscom_board const * bp)
335 struct riscom_port *port;
336 struct tty_struct *tty;
337 unsigned char status;
338 unsigned char ch, flag;
340 if (!(port = rc_get_port(bp, "Receive")))
345 #ifdef RC_REPORT_OVERRUN
346 status = rc_in(bp, CD180_RCSR);
347 if (status & RCSR_OE)
349 status &= port->mark_mask;
351 status = rc_in(bp, CD180_RCSR) & port->mark_mask;
353 ch = rc_in(bp, CD180_RDR);
357 if (status & RCSR_TOUT) {
358 printk(KERN_WARNING "rc%d: port %d: Receiver timeout. "
359 "Hardware problems ?\n",
360 board_No(bp), port_No(port));
363 } else if (status & RCSR_BREAK) {
364 printk(KERN_INFO "rc%d: port %d: Handling break...\n",
365 board_No(bp), port_No(port));
367 if (port->flags & ASYNC_SAK)
370 } else if (status & RCSR_PE)
373 else if (status & RCSR_FE)
376 else if (status & RCSR_OE)
382 tty_insert_flip_char(tty, ch, flag);
383 tty_flip_buffer_push(tty);
386 static inline void rc_receive(struct riscom_board const * bp)
388 struct riscom_port *port;
389 struct tty_struct *tty;
392 if (!(port = rc_get_port(bp, "Receive")))
397 count = rc_in(bp, CD180_RDCR);
399 #ifdef RC_REPORT_FIFO
400 port->hits[count > 8 ? 9 : count]++;
404 if (tty_buffer_request_room(tty, 1) == 0) {
405 printk(KERN_WARNING "rc%d: port %d: Working around "
406 "flip buffer overflow.\n",
407 board_No(bp), port_No(port));
410 tty_insert_flip_char(tty, rc_in(bp, CD180_RDR), TTY_NORMAL);
412 tty_flip_buffer_push(tty);
415 static inline void rc_transmit(struct riscom_board const * bp)
417 struct riscom_port *port;
418 struct tty_struct *tty;
422 if (!(port = rc_get_port(bp, "Transmit")))
427 if (port->IER & IER_TXEMPTY) {
429 rc_out(bp, CD180_CAR, port_No(port));
430 port->IER &= ~IER_TXEMPTY;
431 rc_out(bp, CD180_IER, port->IER);
435 if ((port->xmit_cnt <= 0 && !port->break_length)
436 || tty->stopped || tty->hw_stopped) {
437 rc_out(bp, CD180_CAR, port_No(port));
438 port->IER &= ~IER_TXRDY;
439 rc_out(bp, CD180_IER, port->IER);
443 if (port->break_length) {
444 if (port->break_length > 0) {
445 if (port->COR2 & COR2_ETC) {
446 rc_out(bp, CD180_TDR, CD180_C_ESC);
447 rc_out(bp, CD180_TDR, CD180_C_SBRK);
448 port->COR2 &= ~COR2_ETC;
450 count = min_t(int, port->break_length, 0xff);
451 rc_out(bp, CD180_TDR, CD180_C_ESC);
452 rc_out(bp, CD180_TDR, CD180_C_DELAY);
453 rc_out(bp, CD180_TDR, count);
454 if (!(port->break_length -= count))
455 port->break_length--;
457 rc_out(bp, CD180_TDR, CD180_C_ESC);
458 rc_out(bp, CD180_TDR, CD180_C_EBRK);
459 rc_out(bp, CD180_COR2, port->COR2);
461 rc_out(bp, CD180_CCR, CCR_CORCHG2);
462 port->break_length = 0;
469 rc_out(bp, CD180_TDR, port->xmit_buf[port->xmit_tail++]);
470 port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE-1);
471 if (--port->xmit_cnt <= 0)
473 } while (--count > 0);
475 if (port->xmit_cnt <= 0) {
476 rc_out(bp, CD180_CAR, port_No(port));
477 port->IER &= ~IER_TXRDY;
478 rc_out(bp, CD180_IER, port->IER);
480 if (port->xmit_cnt <= port->wakeup_chars)
484 static inline void rc_check_modem(struct riscom_board const * bp)
486 struct riscom_port *port;
487 struct tty_struct *tty;
490 if (!(port = rc_get_port(bp, "Modem")))
495 mcr = rc_in(bp, CD180_MCR);
496 if (mcr & MCR_CDCHG) {
497 if (rc_in(bp, CD180_MSVR) & MSVR_CD)
498 wake_up_interruptible(&port->open_wait);
503 #ifdef RISCOM_BRAIN_DAMAGED_CTS
504 if (mcr & MCR_CTSCHG) {
505 if (rc_in(bp, CD180_MSVR) & MSVR_CTS) {
507 port->IER |= IER_TXRDY;
508 if (port->xmit_cnt <= port->wakeup_chars)
512 port->IER &= ~IER_TXRDY;
514 rc_out(bp, CD180_IER, port->IER);
516 if (mcr & MCR_DSRCHG) {
517 if (rc_in(bp, CD180_MSVR) & MSVR_DSR) {
519 port->IER |= IER_TXRDY;
520 if (port->xmit_cnt <= port->wakeup_chars)
524 port->IER &= ~IER_TXRDY;
526 rc_out(bp, CD180_IER, port->IER);
528 #endif /* RISCOM_BRAIN_DAMAGED_CTS */
530 /* Clear change bits */
531 rc_out(bp, CD180_MCR, 0);
534 /* The main interrupt processing routine */
535 static irqreturn_t rc_interrupt(int dummy, void * dev_id)
537 unsigned char status;
539 struct riscom_board *bp = dev_id;
540 unsigned long loop = 0;
543 if (!(bp->flags & RC_BOARD_ACTIVE))
546 while ((++loop < 16) && ((status = ~(rc_in(bp, RC_BSR))) &
547 (RC_BSR_TOUT | RC_BSR_TINT |
548 RC_BSR_MINT | RC_BSR_RINT))) {
550 if (status & RC_BSR_TOUT)
551 printk(KERN_WARNING "rc%d: Got timeout. Hardware "
552 "error?\n", board_No(bp));
554 else if (status & RC_BSR_RINT) {
555 ack = rc_in(bp, RC_ACK_RINT);
557 if (ack == (RC_ID | GIVR_IT_RCV))
559 else if (ack == (RC_ID | GIVR_IT_REXC))
562 printk(KERN_WARNING "rc%d: Bad receive ack "
566 } else if (status & RC_BSR_TINT) {
567 ack = rc_in(bp, RC_ACK_TINT);
569 if (ack == (RC_ID | GIVR_IT_TX))
572 printk(KERN_WARNING "rc%d: Bad transmit ack "
576 } else /* if (status & RC_BSR_MINT) */ {
577 ack = rc_in(bp, RC_ACK_MINT);
579 if (ack == (RC_ID | GIVR_IT_MODEM))
582 printk(KERN_WARNING "rc%d: Bad modem ack "
588 rc_out(bp, CD180_EOIR, 0); /* Mark end of interrupt */
589 rc_out(bp, RC_CTOUT, 0); /* Clear timeout flag */
591 return IRQ_RETVAL(handled);
595 * Routines for open & close processing.
598 /* Called with disabled interrupts */
599 static int rc_setup_board(struct riscom_board * bp)
603 if (bp->flags & RC_BOARD_ACTIVE)
606 error = request_irq(bp->irq, rc_interrupt, IRQF_DISABLED,
611 rc_out(bp, RC_CTOUT, 0); /* Just in case */
613 rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */
615 bp->flags |= RC_BOARD_ACTIVE;
620 /* Called with disabled interrupts */
621 static void rc_shutdown_board(struct riscom_board *bp)
623 if (!(bp->flags & RC_BOARD_ACTIVE))
626 bp->flags &= ~RC_BOARD_ACTIVE;
628 free_irq(bp->irq, NULL);
631 rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */
636 * Setting up port characteristics.
637 * Must be called with disabled interrupts
639 static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
641 struct tty_struct *tty;
644 unsigned char cor1 = 0, cor3 = 0;
645 unsigned char mcor1 = 0, mcor2 = 0;
647 if (!(tty = port->tty) || !tty->termios)
652 port->MSVR = MSVR_RTS;
654 baud = tty_get_baud_rate(tty);
656 /* Select port on the board */
657 rc_out(bp, CD180_CAR, port_No(port));
660 /* Drop DTR & exit */
661 bp->DTR |= (1u << port_No(port));
662 rc_out(bp, RC_DTR, bp->DTR);
666 bp->DTR &= ~(1u << port_No(port));
667 rc_out(bp, RC_DTR, bp->DTR);
671 * Now we must calculate some speed depended things
674 /* Set baud rate for port */
675 tmp = (((RC_OSCFREQ + baud/2) / baud +
676 CD180_TPC/2) / CD180_TPC);
678 rc_out(bp, CD180_RBPRH, (tmp >> 8) & 0xff);
679 rc_out(bp, CD180_TBPRH, (tmp >> 8) & 0xff);
680 rc_out(bp, CD180_RBPRL, tmp & 0xff);
681 rc_out(bp, CD180_TBPRL, tmp & 0xff);
683 baud = (baud + 5) / 10; /* Estimated CPS */
685 /* Two timer ticks seems enough to wakeup something like SLIP driver */
686 tmp = ((baud + HZ/2) / HZ) * 2 - CD180_NFIFO;
687 port->wakeup_chars = (tmp < 0) ? 0 : ((tmp >= SERIAL_XMIT_SIZE) ?
688 SERIAL_XMIT_SIZE - 1 : tmp);
690 /* Receiver timeout will be transmission time for 1.5 chars */
691 tmp = (RISCOM_TPS + RISCOM_TPS/2 + baud/2) / baud;
692 tmp = (tmp > 0xff) ? 0xff : tmp;
693 rc_out(bp, CD180_RTPR, tmp);
695 switch (C_CSIZE(tty)) {
715 cor1 |= COR1_NORMPAR;
719 cor1 &= ~COR1_IGNORE;
721 /* Set marking of some errors */
722 port->mark_mask = RCSR_OE | RCSR_TOUT;
724 port->mark_mask |= RCSR_FE | RCSR_PE;
725 if (I_BRKINT(tty) || I_PARMRK(tty))
726 port->mark_mask |= RCSR_BREAK;
728 port->mark_mask &= ~(RCSR_FE | RCSR_PE);
730 port->mark_mask &= ~RCSR_BREAK;
732 /* Real raw mode. Ignore all */
733 port->mark_mask &= ~RCSR_OE;
735 /* Enable Hardware Flow Control */
736 if (C_CRTSCTS(tty)) {
737 #ifdef RISCOM_BRAIN_DAMAGED_CTS
738 port->IER |= IER_DSR | IER_CTS;
739 mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD;
740 mcor2 |= MCOR2_DSROD | MCOR2_CTSOD;
741 tty->hw_stopped = !(rc_in(bp, CD180_MSVR) & (MSVR_CTS|MSVR_DSR));
743 port->COR2 |= COR2_CTSAE;
746 /* Enable Software Flow Control. FIXME: I'm not sure about this */
747 /* Some people reported that it works, but I still doubt */
749 port->COR2 |= COR2_TXIBE;
750 cor3 |= (COR3_FCT | COR3_SCDE);
752 port->COR2 |= COR2_IXM;
753 rc_out(bp, CD180_SCHR1, START_CHAR(tty));
754 rc_out(bp, CD180_SCHR2, STOP_CHAR(tty));
755 rc_out(bp, CD180_SCHR3, START_CHAR(tty));
756 rc_out(bp, CD180_SCHR4, STOP_CHAR(tty));
758 if (!C_CLOCAL(tty)) {
759 /* Enable CD check */
766 /* Enable receiver */
767 port->IER |= IER_RXD;
769 /* Set input FIFO size (1-8 bytes) */
770 cor3 |= RISCOM_RXFIFO;
771 /* Setting up CD180 channel registers */
772 rc_out(bp, CD180_COR1, cor1);
773 rc_out(bp, CD180_COR2, port->COR2);
774 rc_out(bp, CD180_COR3, cor3);
775 /* Make CD180 know about registers change */
777 rc_out(bp, CD180_CCR, CCR_CORCHG1 | CCR_CORCHG2 | CCR_CORCHG3);
778 /* Setting up modem option registers */
779 rc_out(bp, CD180_MCOR1, mcor1);
780 rc_out(bp, CD180_MCOR2, mcor2);
781 /* Enable CD180 transmitter & receiver */
783 rc_out(bp, CD180_CCR, CCR_TXEN | CCR_RXEN);
784 /* Enable interrupts */
785 rc_out(bp, CD180_IER, port->IER);
786 /* And finally set RTS on */
787 rc_out(bp, CD180_MSVR, port->MSVR);
790 /* Must be called with interrupts enabled */
791 static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
795 if (port->flags & ASYNC_INITIALIZED)
798 if (!port->xmit_buf) {
799 /* We may sleep in get_zeroed_page() */
802 if (!(tmp = get_zeroed_page(GFP_KERNEL)))
805 if (port->xmit_buf) {
809 port->xmit_buf = (unsigned char *) tmp;
812 spin_lock_irqsave(&riscom_lock, flags);
815 clear_bit(TTY_IO_ERROR, &port->tty->flags);
817 if (port->count == 1)
820 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
821 rc_change_speed(bp, port);
822 port->flags |= ASYNC_INITIALIZED;
824 spin_unlock_irqrestore(&riscom_lock, flags);
828 /* Must be called with interrupts disabled */
829 static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
831 struct tty_struct *tty;
833 if (!(port->flags & ASYNC_INITIALIZED))
836 #ifdef RC_REPORT_OVERRUN
837 printk(KERN_INFO "rc%d: port %d: Total %ld overruns were detected.\n",
838 board_No(bp), port_No(port), port->overrun);
840 #ifdef RC_REPORT_FIFO
844 printk(KERN_INFO "rc%d: port %d: FIFO hits [ ",
845 board_No(bp), port_No(port));
846 for (i = 0; i < 10; i++) {
847 printk("%ld ", port->hits[i]);
852 if (port->xmit_buf) {
853 free_page((unsigned long) port->xmit_buf);
854 port->xmit_buf = NULL;
857 if (!(tty = port->tty) || C_HUPCL(tty)) {
859 bp->DTR |= (1u << port_No(port));
860 rc_out(bp, RC_DTR, bp->DTR);
864 rc_out(bp, CD180_CAR, port_No(port));
867 rc_out(bp, CD180_CCR, CCR_SOFTRESET);
868 /* Disable all interrupts from this port */
870 rc_out(bp, CD180_IER, port->IER);
873 set_bit(TTY_IO_ERROR, &tty->flags);
874 port->flags &= ~ASYNC_INITIALIZED;
876 if (--bp->count < 0) {
877 printk(KERN_INFO "rc%d: rc_shutdown_port: "
878 "bad board count: %d\n",
879 board_No(bp), bp->count);
884 * If this is the last opened port on the board
885 * shutdown whole board
888 rc_shutdown_board(bp);
892 static int block_til_ready(struct tty_struct *tty, struct file * filp,
893 struct riscom_port *port)
895 DECLARE_WAITQUEUE(wait, current);
896 struct riscom_board *bp = port_Board(port);
903 * If the device is in the middle of being closed, then block
904 * until it's done, and then try again.
906 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) {
907 interruptible_sleep_on(&port->close_wait);
908 if (port->flags & ASYNC_HUP_NOTIFY)
915 * If non-blocking mode is set, or the port is not enabled,
916 * then make the check up front and then exit.
918 if ((filp->f_flags & O_NONBLOCK) ||
919 (tty->flags & (1 << TTY_IO_ERROR))) {
920 port->flags |= ASYNC_NORMAL_ACTIVE;
928 * Block waiting for the carrier detect and the line to become
929 * free (i.e., not in use by the callout). While we are in
930 * this loop, info->count is dropped by one, so that
931 * rs_close() knows when to free things. We restore it upon
932 * exit, either normal or abnormal.
935 add_wait_queue(&port->open_wait, &wait);
937 spin_lock_irqsave(&riscom_lock, flags);
939 if (!tty_hung_up_p(filp))
942 spin_unlock_irqrestore(&riscom_lock, flags);
944 port->blocked_open++;
946 spin_lock_irqsave(&riscom_lock, flags);
948 rc_out(bp, CD180_CAR, port_No(port));
949 CD = rc_in(bp, CD180_MSVR) & MSVR_CD;
950 rc_out(bp, CD180_MSVR, MSVR_RTS);
951 bp->DTR &= ~(1u << port_No(port));
952 rc_out(bp, RC_DTR, bp->DTR);
954 spin_unlock_irqrestore(&riscom_lock, flags);
956 set_current_state(TASK_INTERRUPTIBLE);
957 if (tty_hung_up_p(filp) ||
958 !(port->flags & ASYNC_INITIALIZED)) {
959 if (port->flags & ASYNC_HUP_NOTIFY)
962 retval = -ERESTARTSYS;
965 if (!(port->flags & ASYNC_CLOSING) &&
968 if (signal_pending(current)) {
969 retval = -ERESTARTSYS;
974 __set_current_state(TASK_RUNNING);
975 remove_wait_queue(&port->open_wait, &wait);
976 if (!tty_hung_up_p(filp))
978 port->blocked_open--;
982 port->flags |= ASYNC_NORMAL_ACTIVE;
986 static int rc_open(struct tty_struct * tty, struct file * filp)
990 struct riscom_port * port;
991 struct riscom_board * bp;
993 board = RC_BOARD(tty->index);
994 if (board >= RC_NBOARD || !(rc_board[board].flags & RC_BOARD_PRESENT))
997 bp = &rc_board[board];
998 port = rc_port + board * RC_NPORT + RC_PORT(tty->index);
999 if (rc_paranoia_check(port, tty->name, "rc_open"))
1002 if ((error = rc_setup_board(bp)))
1006 tty->driver_data = port;
1009 if ((error = rc_setup_port(bp, port)))
1012 if ((error = block_til_ready(tty, filp, port)))
1018 static void rc_close(struct tty_struct * tty, struct file * filp)
1020 struct riscom_port *port = (struct riscom_port *) tty->driver_data;
1021 struct riscom_board *bp;
1022 unsigned long flags;
1023 unsigned long timeout;
1025 if (!port || rc_paranoia_check(port, tty->name, "close"))
1028 spin_lock_irqsave(&riscom_lock, flags);
1030 if (tty_hung_up_p(filp))
1033 bp = port_Board(port);
1034 if ((tty->count == 1) && (port->count != 1)) {
1035 printk(KERN_INFO "rc%d: rc_close: bad port count;"
1036 " tty->count is 1, port count is %d\n",
1037 board_No(bp), port->count);
1040 if (--port->count < 0) {
1041 printk(KERN_INFO "rc%d: rc_close: bad port count "
1043 board_No(bp), port_No(port), port->count);
1048 port->flags |= ASYNC_CLOSING;
1050 * Now we wait for the transmit buffer to clear; and we notify
1051 * the line discipline to only process XON/XOFF characters.
1054 if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
1055 tty_wait_until_sent(tty, port->closing_wait);
1057 * At this point we stop accepting input. To do this, we
1058 * disable the receive line status interrupts, and tell the
1059 * interrupt driver to stop checking the data ready bit in the
1060 * line status register.
1062 port->IER &= ~IER_RXD;
1063 if (port->flags & ASYNC_INITIALIZED) {
1064 port->IER &= ~IER_TXRDY;
1065 port->IER |= IER_TXEMPTY;
1066 rc_out(bp, CD180_CAR, port_No(port));
1067 rc_out(bp, CD180_IER, port->IER);
1069 * Before we drop DTR, make sure the UART transmitter
1070 * has completely drained; this is especially
1071 * important if there is a transmit FIFO!
1073 timeout = jiffies+HZ;
1074 while(port->IER & IER_TXEMPTY) {
1075 msleep_interruptible(jiffies_to_msecs(port->timeout));
1076 if (time_after(jiffies, timeout))
1080 rc_shutdown_port(bp, port);
1081 if (tty->driver->flush_buffer)
1082 tty->driver->flush_buffer(tty);
1083 tty_ldisc_flush(tty);
1087 if (port->blocked_open) {
1088 if (port->close_delay) {
1089 msleep_interruptible(jiffies_to_msecs(port->close_delay));
1091 wake_up_interruptible(&port->open_wait);
1093 port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
1094 wake_up_interruptible(&port->close_wait);
1097 spin_unlock_irqrestore(&riscom_lock, flags);
1100 static int rc_write(struct tty_struct * tty,
1101 const unsigned char *buf, int count)
1103 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1104 struct riscom_board *bp;
1106 unsigned long flags;
1108 if (rc_paranoia_check(port, tty->name, "rc_write"))
1111 bp = port_Board(port);
1113 if (!tty || !port->xmit_buf)
1117 spin_lock_irqsave(&riscom_lock, flags);
1119 c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
1120 SERIAL_XMIT_SIZE - port->xmit_head));
1122 break; /* lock continues to be held */
1124 memcpy(port->xmit_buf + port->xmit_head, buf, c);
1125 port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
1126 port->xmit_cnt += c;
1128 spin_unlock_irqrestore(&riscom_lock, flags);
1135 if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped &&
1136 !(port->IER & IER_TXRDY)) {
1137 port->IER |= IER_TXRDY;
1138 rc_out(bp, CD180_CAR, port_No(port));
1139 rc_out(bp, CD180_IER, port->IER);
1142 spin_unlock_irqrestore(&riscom_lock, flags);
1147 static void rc_put_char(struct tty_struct * tty, unsigned char ch)
1149 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1150 unsigned long flags;
1152 if (rc_paranoia_check(port, tty->name, "rc_put_char"))
1155 if (!tty || !port->xmit_buf)
1158 spin_lock_irqsave(&riscom_lock, flags);
1160 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
1163 port->xmit_buf[port->xmit_head++] = ch;
1164 port->xmit_head &= SERIAL_XMIT_SIZE - 1;
1168 spin_unlock_irqrestore(&riscom_lock, flags);
1171 static void rc_flush_chars(struct tty_struct * tty)
1173 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1174 unsigned long flags;
1176 if (rc_paranoia_check(port, tty->name, "rc_flush_chars"))
1179 if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
1183 spin_lock_irqsave(&riscom_lock, flags);
1185 port->IER |= IER_TXRDY;
1186 rc_out(port_Board(port), CD180_CAR, port_No(port));
1187 rc_out(port_Board(port), CD180_IER, port->IER);
1189 spin_unlock_irqrestore(&riscom_lock, flags);
1192 static int rc_write_room(struct tty_struct * tty)
1194 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1197 if (rc_paranoia_check(port, tty->name, "rc_write_room"))
1200 ret = SERIAL_XMIT_SIZE - port->xmit_cnt - 1;
1206 static int rc_chars_in_buffer(struct tty_struct *tty)
1208 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1210 if (rc_paranoia_check(port, tty->name, "rc_chars_in_buffer"))
1213 return port->xmit_cnt;
1216 static void rc_flush_buffer(struct tty_struct *tty)
1218 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1219 unsigned long flags;
1221 if (rc_paranoia_check(port, tty->name, "rc_flush_buffer"))
1224 spin_lock_irqsave(&riscom_lock, flags);
1226 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
1228 spin_unlock_irqrestore(&riscom_lock, flags);
1233 static int rc_tiocmget(struct tty_struct *tty, struct file *file)
1235 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1236 struct riscom_board * bp;
1237 unsigned char status;
1238 unsigned int result;
1239 unsigned long flags;
1241 if (rc_paranoia_check(port, tty->name, __FUNCTION__))
1244 bp = port_Board(port);
1246 spin_lock_irqsave(&riscom_lock, flags);
1248 rc_out(bp, CD180_CAR, port_No(port));
1249 status = rc_in(bp, CD180_MSVR);
1250 result = rc_in(bp, RC_RI) & (1u << port_No(port)) ? 0 : TIOCM_RNG;
1252 spin_unlock_irqrestore(&riscom_lock, flags);
1254 result |= ((status & MSVR_RTS) ? TIOCM_RTS : 0)
1255 | ((status & MSVR_DTR) ? TIOCM_DTR : 0)
1256 | ((status & MSVR_CD) ? TIOCM_CAR : 0)
1257 | ((status & MSVR_DSR) ? TIOCM_DSR : 0)
1258 | ((status & MSVR_CTS) ? TIOCM_CTS : 0);
1262 static int rc_tiocmset(struct tty_struct *tty, struct file *file,
1263 unsigned int set, unsigned int clear)
1265 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1266 unsigned long flags;
1267 struct riscom_board *bp;
1269 if (rc_paranoia_check(port, tty->name, __FUNCTION__))
1272 bp = port_Board(port);
1274 spin_lock_irqsave(&riscom_lock, flags);
1276 if (set & TIOCM_RTS)
1277 port->MSVR |= MSVR_RTS;
1278 if (set & TIOCM_DTR)
1279 bp->DTR &= ~(1u << port_No(port));
1281 if (clear & TIOCM_RTS)
1282 port->MSVR &= ~MSVR_RTS;
1283 if (clear & TIOCM_DTR)
1284 bp->DTR |= (1u << port_No(port));
1286 rc_out(bp, CD180_CAR, port_No(port));
1287 rc_out(bp, CD180_MSVR, port->MSVR);
1288 rc_out(bp, RC_DTR, bp->DTR);
1290 spin_unlock_irqrestore(&riscom_lock, flags);
1295 static inline void rc_send_break(struct riscom_port * port, unsigned long length)
1297 struct riscom_board *bp = port_Board(port);
1298 unsigned long flags;
1300 spin_lock_irqsave(&riscom_lock, flags);
1302 port->break_length = RISCOM_TPS / HZ * length;
1303 port->COR2 |= COR2_ETC;
1304 port->IER |= IER_TXRDY;
1305 rc_out(bp, CD180_CAR, port_No(port));
1306 rc_out(bp, CD180_COR2, port->COR2);
1307 rc_out(bp, CD180_IER, port->IER);
1309 rc_out(bp, CD180_CCR, CCR_CORCHG2);
1312 spin_unlock_irqrestore(&riscom_lock, 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);
1322 if (copy_from_user(&tmp, newinfo, sizeof(tmp)))
1326 if ((tmp.irq != bp->irq) ||
1327 (tmp.port != bp->base) ||
1328 (tmp.type != PORT_CIRRUS) ||
1329 (tmp.baud_base != (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC) ||
1330 (tmp.custom_divisor != 0) ||
1331 (tmp.xmit_fifo_size != CD180_NFIFO) ||
1332 (tmp.flags & ~RISCOM_LEGAL_FLAGS))
1336 change_speed = ((port->flags & ASYNC_SPD_MASK) !=
1337 (tmp.flags & ASYNC_SPD_MASK));
1339 if (!capable(CAP_SYS_ADMIN)) {
1340 if ((tmp.close_delay != port->close_delay) ||
1341 (tmp.closing_wait != port->closing_wait) ||
1342 ((tmp.flags & ~ASYNC_USR_MASK) !=
1343 (port->flags & ~ASYNC_USR_MASK)))
1345 port->flags = ((port->flags & ~ASYNC_USR_MASK) |
1346 (tmp.flags & ASYNC_USR_MASK));
1348 port->flags = ((port->flags & ~ASYNC_FLAGS) |
1349 (tmp.flags & ASYNC_FLAGS));
1350 port->close_delay = tmp.close_delay;
1351 port->closing_wait = tmp.closing_wait;
1354 unsigned long flags;
1356 spin_lock_irqsave(&riscom_lock, flags);
1357 rc_change_speed(bp, port);
1358 spin_unlock_irqrestore(&riscom_lock, flags);
1363 static inline int rc_get_serial_info(struct riscom_port * port,
1364 struct serial_struct __user *retinfo)
1366 struct serial_struct tmp;
1367 struct riscom_board *bp = port_Board(port);
1369 memset(&tmp, 0, sizeof(tmp));
1370 tmp.type = PORT_CIRRUS;
1371 tmp.line = port - rc_port;
1372 tmp.port = bp->base;
1374 tmp.flags = port->flags;
1375 tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC;
1376 tmp.close_delay = port->close_delay * HZ/100;
1377 tmp.closing_wait = port->closing_wait * HZ/100;
1378 tmp.xmit_fifo_size = CD180_NFIFO;
1379 return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0;
1382 static int rc_ioctl(struct tty_struct * tty, struct file * filp,
1383 unsigned int cmd, unsigned long arg)
1386 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1387 void __user *argp = (void __user *)arg;
1390 if (rc_paranoia_check(port, tty->name, "rc_ioctl"))
1394 case TCSBRK: /* SVID version: non-zero arg --> no break */
1395 retval = tty_check_change(tty);
1398 tty_wait_until_sent(tty, 0);
1400 rc_send_break(port, HZ/4); /* 1/4 second */
1402 case TCSBRKP: /* support for POSIX tcsendbreak() */
1403 retval = tty_check_change(tty);
1406 tty_wait_until_sent(tty, 0);
1407 rc_send_break(port, arg ? arg*(HZ/10) : HZ/4);
1410 return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned __user *)argp);
1412 if (get_user(arg,(unsigned __user *) argp))
1414 tty->termios->c_cflag =
1415 ((tty->termios->c_cflag & ~CLOCAL) |
1416 (arg ? CLOCAL : 0));
1419 return rc_get_serial_info(port, argp);
1421 return rc_set_serial_info(port, argp);
1423 return -ENOIOCTLCMD;
1428 static void rc_throttle(struct tty_struct * tty)
1430 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1431 struct riscom_board *bp;
1432 unsigned long flags;
1434 if (rc_paranoia_check(port, tty->name, "rc_throttle"))
1437 bp = port_Board(port);
1439 spin_lock_irqsave(&riscom_lock, flags);
1441 port->MSVR &= ~MSVR_RTS;
1442 rc_out(bp, CD180_CAR, port_No(port));
1445 rc_out(bp, CD180_CCR, CCR_SSCH2);
1448 rc_out(bp, CD180_MSVR, port->MSVR);
1450 spin_unlock_irqrestore(&riscom_lock, flags);
1453 static void rc_unthrottle(struct tty_struct * tty)
1455 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1456 struct riscom_board *bp;
1457 unsigned long flags;
1459 if (rc_paranoia_check(port, tty->name, "rc_unthrottle"))
1462 bp = port_Board(port);
1464 spin_lock_irqsave(&riscom_lock, flags);
1466 port->MSVR |= MSVR_RTS;
1467 rc_out(bp, CD180_CAR, port_No(port));
1470 rc_out(bp, CD180_CCR, CCR_SSCH1);
1473 rc_out(bp, CD180_MSVR, port->MSVR);
1475 spin_unlock_irqrestore(&riscom_lock, flags);
1478 static void rc_stop(struct tty_struct * tty)
1480 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1481 struct riscom_board *bp;
1482 unsigned long flags;
1484 if (rc_paranoia_check(port, tty->name, "rc_stop"))
1487 bp = port_Board(port);
1489 spin_lock_irqsave(&riscom_lock, flags);
1491 port->IER &= ~IER_TXRDY;
1492 rc_out(bp, CD180_CAR, port_No(port));
1493 rc_out(bp, CD180_IER, port->IER);
1495 spin_unlock_irqrestore(&riscom_lock, flags);
1498 static void rc_start(struct tty_struct * tty)
1500 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1501 struct riscom_board *bp;
1502 unsigned long flags;
1504 if (rc_paranoia_check(port, tty->name, "rc_start"))
1507 bp = port_Board(port);
1509 spin_lock_irqsave(&riscom_lock, flags);
1511 if (port->xmit_cnt && port->xmit_buf && !(port->IER & IER_TXRDY)) {
1512 port->IER |= IER_TXRDY;
1513 rc_out(bp, CD180_CAR, port_No(port));
1514 rc_out(bp, CD180_IER, port->IER);
1517 spin_unlock_irqrestore(&riscom_lock, flags);
1520 static void rc_hangup(struct tty_struct * tty)
1522 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1523 struct riscom_board *bp;
1525 if (rc_paranoia_check(port, tty->name, "rc_hangup"))
1528 bp = port_Board(port);
1530 rc_shutdown_port(bp, port);
1532 port->flags &= ~ASYNC_NORMAL_ACTIVE;
1534 wake_up_interruptible(&port->open_wait);
1537 static void rc_set_termios(struct tty_struct * tty, struct ktermios * old_termios)
1539 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1540 unsigned long flags;
1542 if (rc_paranoia_check(port, tty->name, "rc_set_termios"))
1545 if (tty->termios->c_cflag == old_termios->c_cflag &&
1546 tty->termios->c_iflag == old_termios->c_iflag)
1549 spin_lock_irqsave(&riscom_lock, flags);
1550 rc_change_speed(port_Board(port), port);
1551 spin_unlock_irqrestore(&riscom_lock, flags);
1553 if ((old_termios->c_cflag & CRTSCTS) &&
1554 !(tty->termios->c_cflag & CRTSCTS)) {
1555 tty->hw_stopped = 0;
1560 static const struct tty_operations riscom_ops = {
1564 .put_char = rc_put_char,
1565 .flush_chars = rc_flush_chars,
1566 .write_room = rc_write_room,
1567 .chars_in_buffer = rc_chars_in_buffer,
1568 .flush_buffer = rc_flush_buffer,
1570 .throttle = rc_throttle,
1571 .unthrottle = rc_unthrottle,
1572 .set_termios = rc_set_termios,
1575 .hangup = rc_hangup,
1576 .tiocmget = rc_tiocmget,
1577 .tiocmset = rc_tiocmset,
1580 static int __init rc_init_drivers(void)
1585 riscom_driver = alloc_tty_driver(RC_NBOARD * RC_NPORT);
1589 riscom_driver->owner = THIS_MODULE;
1590 riscom_driver->name = "ttyL";
1591 riscom_driver->major = RISCOM8_NORMAL_MAJOR;
1592 riscom_driver->type = TTY_DRIVER_TYPE_SERIAL;
1593 riscom_driver->subtype = SERIAL_TYPE_NORMAL;
1594 riscom_driver->init_termios = tty_std_termios;
1595 riscom_driver->init_termios.c_cflag =
1596 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1597 riscom_driver->init_termios.c_ispeed = 9600;
1598 riscom_driver->init_termios.c_ospeed = 9600;
1599 riscom_driver->flags = TTY_DRIVER_REAL_RAW;
1600 tty_set_operations(riscom_driver, &riscom_ops);
1601 if ((error = tty_register_driver(riscom_driver))) {
1602 put_tty_driver(riscom_driver);
1603 printk(KERN_ERR "rc: Couldn't register RISCom/8 driver, "
1609 memset(rc_port, 0, sizeof(rc_port));
1610 for (i = 0; i < RC_NPORT * RC_NBOARD; i++) {
1611 rc_port[i].magic = RISCOM8_MAGIC;
1612 rc_port[i].close_delay = 50 * HZ/100;
1613 rc_port[i].closing_wait = 3000 * HZ/100;
1614 init_waitqueue_head(&rc_port[i].open_wait);
1615 init_waitqueue_head(&rc_port[i].close_wait);
1621 static void rc_release_drivers(void)
1623 tty_unregister_driver(riscom_driver);
1624 put_tty_driver(riscom_driver);
1629 * Called at boot time.
1631 * You can specify IO base for up to RC_NBOARD cards,
1632 * using line "riscom8=0xiobase1,0xiobase2,.." at LILO prompt.
1633 * Note that there will be no probing at default
1634 * addresses in this case.
1637 static int __init riscom8_setup(char *str)
1639 int ints[RC_NBOARD];
1642 str = get_options(str, ARRAY_SIZE(ints), ints);
1644 for (i = 0; i < RC_NBOARD; i++) {
1646 rc_board[i].base = ints[i+1];
1648 rc_board[i].base = 0;
1653 __setup("riscom8=", riscom8_setup);
1656 static char banner[] __initdata =
1657 KERN_INFO "rc: SDL RISCom/8 card driver v1.1, (c) D.Gorodchanin "
1659 static char no_boards_msg[] __initdata =
1660 KERN_INFO "rc: No RISCom/8 boards detected.\n";
1663 * This routine must be called by kernel at boot time
1665 static int __init riscom8_init(void)
1672 if (rc_init_drivers())
1675 for (i = 0; i < RC_NBOARD; i++)
1676 if (rc_board[i].base && !rc_probe(&rc_board[i]))
1680 rc_release_drivers();
1681 printk(no_boards_msg);
1692 module_param(iobase, int, 0);
1693 module_param(iobase1, int, 0);
1694 module_param(iobase2, int, 0);
1695 module_param(iobase3, int, 0);
1697 MODULE_LICENSE("GPL");
1701 * You can setup up to 4 boards (current value of RC_NBOARD)
1702 * by specifying "iobase=0xXXX iobase1=0xXXX ..." as insmod parameter.
1705 static int __init riscom8_init_module (void)
1710 if (iobase || iobase1 || iobase2 || iobase3) {
1711 for(i = 0; i < RC_NBOARD; i++)
1712 rc_board[i].base = 0;
1716 rc_board[0].base = iobase;
1718 rc_board[1].base = iobase1;
1720 rc_board[2].base = iobase2;
1722 rc_board[3].base = iobase3;
1725 return riscom8_init();
1728 static void __exit riscom8_exit_module (void)
1732 rc_release_drivers();
1733 for (i = 0; i < RC_NBOARD; i++)
1734 if (rc_board[i].flags & RC_BOARD_PRESENT)
1735 rc_release_io_range(&rc_board[i]);
1739 module_init(riscom8_init_module);
1740 module_exit(riscom8_exit_module);