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 <linux/uaccess.h>
55 #include "riscom8_reg.h"
57 /* Am I paranoid or not ? ;-) */
58 #define RISCOM_PARANOIA_CHECK
61 * Crazy InteliCom/8 boards sometimes have 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 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,
164 return inb(bp->base + RC_TO_ISA(reg));
167 /* Output Byte to CL CD180 register */
168 static inline void rc_out(struct riscom_board const *bp, unsigned short reg,
171 outb(val, bp->base + RC_TO_ISA(reg));
174 /* Wait for Channel Command Register ready */
175 static void rc_wait_CCR(struct riscom_board const *bp)
179 /* FIXME: need something more descriptive then 100000 :) */
180 for (delay = 100000; delay; delay--)
181 if (!rc_in(bp, CD180_CCR))
184 printk(KERN_INFO "rc%d: Timeout waiting for CCR.\n", board_No(bp));
188 * RISCom/8 probe functions.
191 static int rc_request_io_range(struct riscom_board * const bp)
195 for (i = 0; i < RC_NIOPORT; i++)
196 if (!request_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1,
202 printk(KERN_INFO "rc%d: Skipping probe at 0x%03x. IO address in use.\n",
203 board_No(bp), bp->base);
205 release_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1);
209 static void rc_release_io_range(struct riscom_board * const bp)
213 for (i = 0; i < RC_NIOPORT; i++)
214 release_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1);
217 /* Reset and setup CD180 chip */
218 static void __init rc_init_CD180(struct riscom_board const *bp)
222 spin_lock_irqsave(&riscom_lock, flags);
224 rc_out(bp, RC_CTOUT, 0); /* Clear timeout */
225 rc_wait_CCR(bp); /* Wait for CCR ready */
226 rc_out(bp, CD180_CCR, CCR_HARDRESET); /* Reset CD180 chip */
227 spin_unlock_irqrestore(&riscom_lock, flags);
228 msleep(50); /* Delay 0.05 sec */
229 spin_lock_irqsave(&riscom_lock, flags);
230 rc_out(bp, CD180_GIVR, RC_ID); /* Set ID for this chip */
231 rc_out(bp, CD180_GICR, 0); /* Clear all bits */
232 rc_out(bp, CD180_PILR1, RC_ACK_MINT); /* Prio for modem intr */
233 rc_out(bp, CD180_PILR2, RC_ACK_TINT); /* Prio for tx intr */
234 rc_out(bp, CD180_PILR3, RC_ACK_RINT); /* Prio for rx intr */
236 /* Setting up prescaler. We need 4 ticks per 1 ms */
237 rc_out(bp, CD180_PPRH, (RC_OSCFREQ/(1000000/RISCOM_TPS)) >> 8);
238 rc_out(bp, CD180_PPRL, (RC_OSCFREQ/(1000000/RISCOM_TPS)) & 0xff);
240 spin_unlock_irqrestore(&riscom_lock, flags);
243 /* Main probing routine, also sets irq. */
244 static int __init rc_probe(struct riscom_board *bp)
246 unsigned char val1, val2;
252 if (rc_request_io_range(bp))
255 /* Are the I/O ports here ? */
256 rc_out(bp, CD180_PPRL, 0x5a);
258 val1 = rc_in(bp, CD180_PPRL);
259 rc_out(bp, CD180_PPRL, 0xa5);
261 val2 = rc_in(bp, CD180_PPRL);
263 if ((val1 != 0x5a) || (val2 != 0xa5)) {
264 printk(KERN_ERR "rc%d: RISCom/8 Board at 0x%03x not found.\n",
265 board_No(bp), bp->base);
269 /* It's time to find IRQ for this board */
270 for (retries = 0; retries < 5 && irqs <= 0; retries++) {
271 irqs = probe_irq_on();
272 rc_init_CD180(bp); /* Reset CD180 chip */
273 rc_out(bp, CD180_CAR, 2); /* Select port 2 */
275 rc_out(bp, CD180_CCR, CCR_TXEN); /* Enable transmitter */
276 rc_out(bp, CD180_IER, IER_TXRDY);/* Enable tx empty intr */
278 irqs = probe_irq_off(irqs);
279 val1 = rc_in(bp, RC_BSR); /* Get Board Status reg */
280 val2 = rc_in(bp, RC_ACK_TINT); /* ACK interrupt */
281 rc_init_CD180(bp); /* Reset CD180 again */
283 if ((val1 & RC_BSR_TINT) || (val2 != (RC_ID | GIVR_IT_TX))) {
284 printk(KERN_ERR "rc%d: RISCom/8 Board at 0x%03x not "
285 "found.\n", board_No(bp), bp->base);
291 printk(KERN_ERR "rc%d: Can't find IRQ for RISCom/8 board "
292 "at 0x%03x.\n", board_No(bp), bp->base);
296 bp->flags |= RC_BOARD_PRESENT;
298 printk(KERN_INFO "rc%d: RISCom/8 Rev. %c board detected at "
301 (rc_in(bp, CD180_GFRCR) & 0x0f) + 'A', /* Board revision */
306 rc_release_io_range(bp);
312 * Interrupt processing routines.
316 static struct riscom_port *rc_get_port(struct riscom_board const *bp,
317 unsigned char const *what)
319 unsigned char channel;
320 struct riscom_port *port;
322 channel = rc_in(bp, CD180_GICR) >> GICR_CHAN_OFF;
323 if (channel < CD180_NCH) {
324 port = &rc_port[board_No(bp) * RC_NPORT + channel];
325 if (port->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 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 port = rc_get_port(bp, "Receive");
344 tty = port->port.tty;
346 #ifdef RC_REPORT_OVERRUN
347 status = rc_in(bp, CD180_RCSR);
348 if (status & RCSR_OE)
350 status &= port->mark_mask;
352 status = rc_in(bp, CD180_RCSR) & port->mark_mask;
354 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->port.flags & ASYNC_SAK)
370 } else if (status & RCSR_PE)
373 else if (status & RCSR_FE)
376 else if (status & RCSR_OE)
381 tty_insert_flip_char(tty, ch, flag);
382 tty_flip_buffer_push(tty);
385 static void rc_receive(struct riscom_board const *bp)
387 struct riscom_port *port;
388 struct tty_struct *tty;
391 port = rc_get_port(bp, "Receive");
395 tty = port->port.tty;
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 void rc_transmit(struct riscom_board const *bp)
417 struct riscom_port *port;
418 struct tty_struct *tty;
421 port = rc_get_port(bp, "Transmit");
425 tty = port->port.tty;
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 port->break_length -= count;
455 if (port->break_length == 0)
456 port->break_length--;
458 rc_out(bp, CD180_TDR, CD180_C_ESC);
459 rc_out(bp, CD180_TDR, CD180_C_EBRK);
460 rc_out(bp, CD180_COR2, port->COR2);
462 rc_out(bp, CD180_CCR, CCR_CORCHG2);
463 port->break_length = 0;
470 rc_out(bp, CD180_TDR, port->port.xmit_buf[port->xmit_tail++]);
471 port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE-1);
472 if (--port->xmit_cnt <= 0)
474 } while (--count > 0);
476 if (port->xmit_cnt <= 0) {
477 rc_out(bp, CD180_CAR, port_No(port));
478 port->IER &= ~IER_TXRDY;
479 rc_out(bp, CD180_IER, port->IER);
481 if (port->xmit_cnt <= port->wakeup_chars)
485 static void rc_check_modem(struct riscom_board const *bp)
487 struct riscom_port *port;
488 struct tty_struct *tty;
491 port = rc_get_port(bp, "Modem");
495 tty = port->port.tty;
497 mcr = rc_in(bp, CD180_MCR);
498 if (mcr & MCR_CDCHG) {
499 if (rc_in(bp, CD180_MSVR) & MSVR_CD)
500 wake_up_interruptible(&port->port.open_wait);
505 #ifdef RISCOM_BRAIN_DAMAGED_CTS
506 if (mcr & MCR_CTSCHG) {
507 if (rc_in(bp, CD180_MSVR) & MSVR_CTS) {
509 port->IER |= IER_TXRDY;
510 if (port->xmit_cnt <= port->wakeup_chars)
514 port->IER &= ~IER_TXRDY;
516 rc_out(bp, CD180_IER, port->IER);
518 if (mcr & MCR_DSRCHG) {
519 if (rc_in(bp, CD180_MSVR) & MSVR_DSR) {
521 port->IER |= IER_TXRDY;
522 if (port->xmit_cnt <= port->wakeup_chars)
526 port->IER &= ~IER_TXRDY;
528 rc_out(bp, CD180_IER, port->IER);
530 #endif /* RISCOM_BRAIN_DAMAGED_CTS */
532 /* Clear change bits */
533 rc_out(bp, CD180_MCR, 0);
536 /* The main interrupt processing routine */
537 static irqreturn_t rc_interrupt(int dummy, void *dev_id)
539 unsigned char status;
541 struct riscom_board *bp = dev_id;
542 unsigned long loop = 0;
545 if (!(bp->flags & RC_BOARD_ACTIVE))
548 while ((++loop < 16) && ((status = ~(rc_in(bp, RC_BSR))) &
549 (RC_BSR_TOUT | RC_BSR_TINT |
550 RC_BSR_MINT | RC_BSR_RINT))) {
552 if (status & RC_BSR_TOUT)
553 printk(KERN_WARNING "rc%d: Got timeout. Hardware "
554 "error?\n", board_No(bp));
555 else if (status & RC_BSR_RINT) {
556 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 "
565 } else if (status & RC_BSR_TINT) {
566 ack = rc_in(bp, RC_ACK_TINT);
567 if (ack == (RC_ID | GIVR_IT_TX))
570 printk(KERN_WARNING "rc%d: Bad transmit ack "
573 } else /* if (status & RC_BSR_MINT) */ {
574 ack = rc_in(bp, RC_ACK_MINT);
575 if (ack == (RC_ID | GIVR_IT_MODEM))
578 printk(KERN_WARNING "rc%d: Bad modem ack "
582 rc_out(bp, CD180_EOIR, 0); /* Mark end of interrupt */
583 rc_out(bp, RC_CTOUT, 0); /* Clear timeout flag */
585 return IRQ_RETVAL(handled);
589 * Routines for open & close processing.
592 /* Called with disabled interrupts */
593 static int rc_setup_board(struct riscom_board *bp)
597 if (bp->flags & RC_BOARD_ACTIVE)
600 error = request_irq(bp->irq, rc_interrupt, IRQF_DISABLED,
605 rc_out(bp, RC_CTOUT, 0); /* Just in case */
607 rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */
609 bp->flags |= RC_BOARD_ACTIVE;
614 /* Called with disabled interrupts */
615 static void rc_shutdown_board(struct riscom_board *bp)
617 if (!(bp->flags & RC_BOARD_ACTIVE))
620 bp->flags &= ~RC_BOARD_ACTIVE;
622 free_irq(bp->irq, NULL);
625 rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */
630 * Setting up port characteristics.
631 * Must be called with disabled interrupts
633 static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
635 struct tty_struct *tty = port->port.tty;
638 unsigned char cor1 = 0, cor3 = 0;
639 unsigned char mcor1 = 0, mcor2 = 0;
643 port->MSVR = MSVR_RTS;
645 baud = tty_get_baud_rate(tty);
647 /* Select port on the board */
648 rc_out(bp, CD180_CAR, port_No(port));
651 /* Drop DTR & exit */
652 bp->DTR |= (1u << port_No(port));
653 rc_out(bp, RC_DTR, bp->DTR);
657 bp->DTR &= ~(1u << port_No(port));
658 rc_out(bp, RC_DTR, bp->DTR);
662 * Now we must calculate some speed depended things
665 /* Set baud rate for port */
666 tmp = (((RC_OSCFREQ + baud/2) / baud +
667 CD180_TPC/2) / CD180_TPC);
669 rc_out(bp, CD180_RBPRH, (tmp >> 8) & 0xff);
670 rc_out(bp, CD180_TBPRH, (tmp >> 8) & 0xff);
671 rc_out(bp, CD180_RBPRL, tmp & 0xff);
672 rc_out(bp, CD180_TBPRL, tmp & 0xff);
674 baud = (baud + 5) / 10; /* Estimated CPS */
676 /* Two timer ticks seems enough to wakeup something like SLIP driver */
677 tmp = ((baud + HZ/2) / HZ) * 2 - CD180_NFIFO;
678 port->wakeup_chars = (tmp < 0) ? 0 : ((tmp >= SERIAL_XMIT_SIZE) ?
679 SERIAL_XMIT_SIZE - 1 : tmp);
681 /* Receiver timeout will be transmission time for 1.5 chars */
682 tmp = (RISCOM_TPS + RISCOM_TPS/2 + baud/2) / baud;
683 tmp = (tmp > 0xff) ? 0xff : tmp;
684 rc_out(bp, CD180_RTPR, tmp);
686 switch (C_CSIZE(tty)) {
705 cor1 |= COR1_NORMPAR;
709 cor1 &= ~COR1_IGNORE;
711 /* Set marking of some errors */
712 port->mark_mask = RCSR_OE | RCSR_TOUT;
714 port->mark_mask |= RCSR_FE | RCSR_PE;
715 if (I_BRKINT(tty) || I_PARMRK(tty))
716 port->mark_mask |= RCSR_BREAK;
718 port->mark_mask &= ~(RCSR_FE | RCSR_PE);
720 port->mark_mask &= ~RCSR_BREAK;
722 /* Real raw mode. Ignore all */
723 port->mark_mask &= ~RCSR_OE;
725 /* Enable Hardware Flow Control */
726 if (C_CRTSCTS(tty)) {
727 #ifdef RISCOM_BRAIN_DAMAGED_CTS
728 port->IER |= IER_DSR | IER_CTS;
729 mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD;
730 mcor2 |= MCOR2_DSROD | MCOR2_CTSOD;
731 tty->hw_stopped = !(rc_in(bp, CD180_MSVR) &
732 (MSVR_CTS|MSVR_DSR));
734 port->COR2 |= COR2_CTSAE;
737 /* Enable Software Flow Control. FIXME: I'm not sure about this */
738 /* Some people reported that it works, but I still doubt */
740 port->COR2 |= COR2_TXIBE;
741 cor3 |= (COR3_FCT | COR3_SCDE);
743 port->COR2 |= COR2_IXM;
744 rc_out(bp, CD180_SCHR1, START_CHAR(tty));
745 rc_out(bp, CD180_SCHR2, STOP_CHAR(tty));
746 rc_out(bp, CD180_SCHR3, START_CHAR(tty));
747 rc_out(bp, CD180_SCHR4, STOP_CHAR(tty));
749 if (!C_CLOCAL(tty)) {
750 /* Enable CD check */
757 /* Enable receiver */
758 port->IER |= IER_RXD;
760 /* Set input FIFO size (1-8 bytes) */
761 cor3 |= RISCOM_RXFIFO;
762 /* Setting up CD180 channel registers */
763 rc_out(bp, CD180_COR1, cor1);
764 rc_out(bp, CD180_COR2, port->COR2);
765 rc_out(bp, CD180_COR3, cor3);
766 /* Make CD180 know about registers change */
768 rc_out(bp, CD180_CCR, CCR_CORCHG1 | CCR_CORCHG2 | CCR_CORCHG3);
769 /* Setting up modem option registers */
770 rc_out(bp, CD180_MCOR1, mcor1);
771 rc_out(bp, CD180_MCOR2, mcor2);
772 /* Enable CD180 transmitter & receiver */
774 rc_out(bp, CD180_CCR, CCR_TXEN | CCR_RXEN);
775 /* Enable interrupts */
776 rc_out(bp, CD180_IER, port->IER);
777 /* And finally set RTS on */
778 rc_out(bp, CD180_MSVR, port->MSVR);
781 /* Must be called with interrupts enabled */
782 static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
786 if (port->port.flags & ASYNC_INITIALIZED)
789 if (tty_port_alloc_xmit_buf(&port->port) < 0)
792 spin_lock_irqsave(&riscom_lock, flags);
794 clear_bit(TTY_IO_ERROR, &port->port.tty->flags);
795 if (port->port.count == 1)
797 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
798 rc_change_speed(bp, port);
799 port->port.flags |= ASYNC_INITIALIZED;
801 spin_unlock_irqrestore(&riscom_lock, flags);
805 /* Must be called with interrupts disabled */
806 static void rc_shutdown_port(struct tty_struct *tty,
807 struct riscom_board *bp, struct riscom_port *port)
809 if (!(port->port.flags & ASYNC_INITIALIZED))
812 #ifdef RC_REPORT_OVERRUN
813 printk(KERN_INFO "rc%d: port %d: Total %ld overruns were detected.\n",
814 board_No(bp), port_No(port), port->overrun);
816 #ifdef RC_REPORT_FIFO
820 printk(KERN_INFO "rc%d: port %d: FIFO hits [ ",
821 board_No(bp), port_No(port));
822 for (i = 0; i < 10; i++)
823 printk("%ld ", port->hits[i]);
827 tty_port_free_xmit_buf(&port->port);
830 bp->DTR |= (1u << port_No(port));
831 rc_out(bp, RC_DTR, bp->DTR);
835 rc_out(bp, CD180_CAR, port_No(port));
838 rc_out(bp, CD180_CCR, CCR_SOFTRESET);
839 /* Disable all interrupts from this port */
841 rc_out(bp, CD180_IER, port->IER);
843 set_bit(TTY_IO_ERROR, &tty->flags);
844 port->port.flags &= ~ASYNC_INITIALIZED;
846 if (--bp->count < 0) {
847 printk(KERN_INFO "rc%d: rc_shutdown_port: "
848 "bad board count: %d\n",
849 board_No(bp), bp->count);
853 * If this is the last opened port on the board
854 * shutdown whole board
857 rc_shutdown_board(bp);
860 static int carrier_raised(struct tty_port *port)
862 struct riscom_port *p = container_of(port, struct riscom_port, port);
863 struct riscom_board *bp = port_Board(p);
867 spin_lock_irqsave(&riscom_lock, flags);
868 rc_out(bp, CD180_CAR, port_No(p));
869 CD = rc_in(bp, CD180_MSVR) & MSVR_CD;
870 rc_out(bp, CD180_MSVR, MSVR_RTS);
871 bp->DTR &= ~(1u << port_No(p));
872 rc_out(bp, RC_DTR, bp->DTR);
873 spin_unlock_irqrestore(&riscom_lock, flags);
877 static int block_til_ready(struct tty_struct *tty, struct file *filp,
878 struct riscom_port *rp)
880 DECLARE_WAITQUEUE(wait, current);
885 struct tty_port *port = &rp->port;
888 * If the device is in the middle of being closed, then block
889 * until it's done, and then try again.
891 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) {
892 interruptible_sleep_on(&port->close_wait);
893 if (port->flags & ASYNC_HUP_NOTIFY)
900 * If non-blocking mode is set, or the port is not enabled,
901 * then make the check up front and then exit.
903 if ((filp->f_flags & O_NONBLOCK) ||
904 (tty->flags & (1 << TTY_IO_ERROR))) {
905 port->flags |= ASYNC_NORMAL_ACTIVE;
913 * Block waiting for the carrier detect and the line to become
914 * free (i.e., not in use by the callout). While we are in
915 * this loop, info->count is dropped by one, so that
916 * rs_close() knows when to free things. We restore it upon
917 * exit, either normal or abnormal.
920 add_wait_queue(&port->open_wait, &wait);
922 spin_lock_irqsave(&port->lock, flags);
923 if (!tty_hung_up_p(filp))
925 port->blocked_open++;
926 spin_unlock_irqrestore(&port->lock, flags);
930 CD = tty_port_carrier_raised(port);
931 set_current_state(TASK_INTERRUPTIBLE);
932 if (tty_hung_up_p(filp) ||
933 !(port->flags & ASYNC_INITIALIZED)) {
934 if (port->flags & ASYNC_HUP_NOTIFY)
937 retval = -ERESTARTSYS;
940 if (!(port->flags & ASYNC_CLOSING) &&
943 if (signal_pending(current)) {
944 retval = -ERESTARTSYS;
949 __set_current_state(TASK_RUNNING);
950 remove_wait_queue(&port->open_wait, &wait);
951 spin_lock_irqsave(&port->lock, flags);
952 if (!tty_hung_up_p(filp))
954 port->blocked_open--;
956 port->flags |= ASYNC_NORMAL_ACTIVE;
957 spin_unlock_irqrestore(&port->lock, flags);
961 static int rc_open(struct tty_struct *tty, struct file *filp)
965 struct riscom_port *port;
966 struct riscom_board *bp;
968 board = RC_BOARD(tty->index);
969 if (board >= RC_NBOARD || !(rc_board[board].flags & RC_BOARD_PRESENT))
972 bp = &rc_board[board];
973 port = rc_port + board * RC_NPORT + RC_PORT(tty->index);
974 if (rc_paranoia_check(port, tty->name, "rc_open"))
977 error = rc_setup_board(bp);
982 tty->driver_data = port;
983 port->port.tty = tty;
985 error = rc_setup_port(bp, port);
987 error = block_til_ready(tty, filp, port);
991 static void rc_flush_buffer(struct tty_struct *tty)
993 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
996 if (rc_paranoia_check(port, tty->name, "rc_flush_buffer"))
999 spin_lock_irqsave(&riscom_lock, flags);
1000 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
1001 spin_unlock_irqrestore(&riscom_lock, flags);
1006 static void rc_close(struct tty_struct *tty, struct file *filp)
1008 struct riscom_port *port = (struct riscom_port *) tty->driver_data;
1009 struct riscom_board *bp;
1010 unsigned long flags;
1011 unsigned long timeout;
1013 if (!port || rc_paranoia_check(port, tty->name, "close"))
1016 spin_lock_irqsave(&port->port.lock, flags);
1018 if (tty_hung_up_p(filp))
1021 bp = port_Board(port);
1022 if ((tty->count == 1) && (port->port.count != 1)) {
1023 printk(KERN_INFO "rc%d: rc_close: bad port count;"
1024 " tty->count is 1, port count is %d\n",
1025 board_No(bp), port->port.count);
1026 port->port.count = 1;
1028 if (--port->port.count < 0) {
1029 printk(KERN_INFO "rc%d: rc_close: bad port count "
1031 board_No(bp), port_No(port), port->port.count);
1032 port->port.count = 0;
1034 if (port->port.count)
1036 port->port.flags |= ASYNC_CLOSING;
1038 * Now we wait for the transmit buffer to clear; and we notify
1039 * the line discipline to only process XON/XOFF characters.
1042 spin_unlock_irqrestore(&port->port.lock, flags);
1043 if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
1044 tty_wait_until_sent(tty, port->port.closing_wait);
1046 * At this point we stop accepting input. To do this, we
1047 * disable the receive line status interrupts, and tell the
1048 * interrupt driver to stop checking the data ready bit in the
1049 * line status register.
1052 spin_lock_irqsave(&riscom_lock, flags);
1053 port->IER &= ~IER_RXD;
1054 if (port->port.flags & ASYNC_INITIALIZED) {
1055 port->IER &= ~IER_TXRDY;
1056 port->IER |= IER_TXEMPTY;
1057 rc_out(bp, CD180_CAR, port_No(port));
1058 rc_out(bp, CD180_IER, port->IER);
1060 * Before we drop DTR, make sure the UART transmitter
1061 * has completely drained; this is especially
1062 * important if there is a transmit FIFO!
1064 timeout = jiffies + HZ;
1065 while (port->IER & IER_TXEMPTY) {
1066 spin_unlock_irqrestore(&riscom_lock, flags);
1067 msleep_interruptible(jiffies_to_msecs(port->timeout));
1068 spin_lock_irqsave(&riscom_lock, flags);
1069 if (time_after(jiffies, timeout))
1073 rc_shutdown_port(tty, bp, port);
1074 rc_flush_buffer(tty);
1075 spin_unlock_irqrestore(&riscom_lock, flags);
1076 tty_ldisc_flush(tty);
1078 spin_lock_irqsave(&port->port.lock, flags);
1080 port->port.tty = NULL;
1081 if (port->port.blocked_open) {
1082 spin_unlock_irqrestore(&port->port.lock, flags);
1083 if (port->port.close_delay)
1084 msleep_interruptible(jiffies_to_msecs(port->port.close_delay));
1085 wake_up_interruptible(&port->port.open_wait);
1086 spin_lock_irqsave(&port->port.lock, flags);
1088 port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
1089 wake_up_interruptible(&port->port.close_wait);
1092 spin_unlock_irqrestore(&riscom_lock, flags);
1095 static int rc_write(struct tty_struct *tty,
1096 const unsigned char *buf, int count)
1098 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1099 struct riscom_board *bp;
1101 unsigned long flags;
1103 if (rc_paranoia_check(port, tty->name, "rc_write"))
1106 bp = port_Board(port);
1109 spin_lock_irqsave(&riscom_lock, flags);
1111 c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
1112 SERIAL_XMIT_SIZE - port->xmit_head));
1114 break; /* lock continues to be held */
1116 memcpy(port->port.xmit_buf + port->xmit_head, buf, c);
1117 port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
1118 port->xmit_cnt += c;
1120 spin_unlock_irqrestore(&riscom_lock, flags);
1127 if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped &&
1128 !(port->IER & IER_TXRDY)) {
1129 port->IER |= IER_TXRDY;
1130 rc_out(bp, CD180_CAR, port_No(port));
1131 rc_out(bp, CD180_IER, port->IER);
1134 spin_unlock_irqrestore(&riscom_lock, flags);
1139 static int rc_put_char(struct tty_struct *tty, unsigned char ch)
1141 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1142 unsigned long flags;
1145 if (rc_paranoia_check(port, tty->name, "rc_put_char"))
1148 spin_lock_irqsave(&riscom_lock, flags);
1150 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
1153 port->port.xmit_buf[port->xmit_head++] = ch;
1154 port->xmit_head &= SERIAL_XMIT_SIZE - 1;
1159 spin_unlock_irqrestore(&riscom_lock, flags);
1163 static void rc_flush_chars(struct tty_struct *tty)
1165 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1166 unsigned long flags;
1168 if (rc_paranoia_check(port, tty->name, "rc_flush_chars"))
1171 if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped)
1174 spin_lock_irqsave(&riscom_lock, flags);
1176 port->IER |= IER_TXRDY;
1177 rc_out(port_Board(port), CD180_CAR, port_No(port));
1178 rc_out(port_Board(port), CD180_IER, port->IER);
1180 spin_unlock_irqrestore(&riscom_lock, flags);
1183 static int rc_write_room(struct tty_struct *tty)
1185 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1188 if (rc_paranoia_check(port, tty->name, "rc_write_room"))
1191 ret = SERIAL_XMIT_SIZE - port->xmit_cnt - 1;
1197 static int rc_chars_in_buffer(struct tty_struct *tty)
1199 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1201 if (rc_paranoia_check(port, tty->name, "rc_chars_in_buffer"))
1204 return port->xmit_cnt;
1207 static int rc_tiocmget(struct tty_struct *tty, struct file *file)
1209 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1210 struct riscom_board *bp;
1211 unsigned char status;
1212 unsigned int result;
1213 unsigned long flags;
1215 if (rc_paranoia_check(port, tty->name, __func__))
1218 bp = port_Board(port);
1220 spin_lock_irqsave(&riscom_lock, flags);
1222 rc_out(bp, CD180_CAR, port_No(port));
1223 status = rc_in(bp, CD180_MSVR);
1224 result = rc_in(bp, RC_RI) & (1u << port_No(port)) ? 0 : TIOCM_RNG;
1226 spin_unlock_irqrestore(&riscom_lock, flags);
1228 result |= ((status & MSVR_RTS) ? TIOCM_RTS : 0)
1229 | ((status & MSVR_DTR) ? TIOCM_DTR : 0)
1230 | ((status & MSVR_CD) ? TIOCM_CAR : 0)
1231 | ((status & MSVR_DSR) ? TIOCM_DSR : 0)
1232 | ((status & MSVR_CTS) ? TIOCM_CTS : 0);
1236 static int rc_tiocmset(struct tty_struct *tty, struct file *file,
1237 unsigned int set, unsigned int clear)
1239 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1240 unsigned long flags;
1241 struct riscom_board *bp;
1243 if (rc_paranoia_check(port, tty->name, __func__))
1246 bp = port_Board(port);
1248 spin_lock_irqsave(&riscom_lock, flags);
1250 if (set & TIOCM_RTS)
1251 port->MSVR |= MSVR_RTS;
1252 if (set & TIOCM_DTR)
1253 bp->DTR &= ~(1u << port_No(port));
1255 if (clear & TIOCM_RTS)
1256 port->MSVR &= ~MSVR_RTS;
1257 if (clear & TIOCM_DTR)
1258 bp->DTR |= (1u << port_No(port));
1260 rc_out(bp, CD180_CAR, port_No(port));
1261 rc_out(bp, CD180_MSVR, port->MSVR);
1262 rc_out(bp, RC_DTR, bp->DTR);
1264 spin_unlock_irqrestore(&riscom_lock, flags);
1269 static int rc_send_break(struct tty_struct *tty, int length)
1271 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1272 struct riscom_board *bp = port_Board(port);
1273 unsigned long flags;
1275 if (length == 0 || length == -1)
1278 spin_lock_irqsave(&riscom_lock, flags);
1280 port->break_length = RISCOM_TPS / HZ * length;
1281 port->COR2 |= COR2_ETC;
1282 port->IER |= IER_TXRDY;
1283 rc_out(bp, CD180_CAR, port_No(port));
1284 rc_out(bp, CD180_COR2, port->COR2);
1285 rc_out(bp, CD180_IER, port->IER);
1287 rc_out(bp, CD180_CCR, CCR_CORCHG2);
1290 spin_unlock_irqrestore(&riscom_lock, flags);
1294 static int rc_set_serial_info(struct riscom_port *port,
1295 struct serial_struct __user *newinfo)
1297 struct serial_struct tmp;
1298 struct riscom_board *bp = port_Board(port);
1301 if (copy_from_user(&tmp, newinfo, sizeof(tmp)))
1305 if ((tmp.irq != bp->irq) ||
1306 (tmp.port != bp->base) ||
1307 (tmp.type != PORT_CIRRUS) ||
1308 (tmp.baud_base != (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC) ||
1309 (tmp.custom_divisor != 0) ||
1310 (tmp.xmit_fifo_size != CD180_NFIFO) ||
1311 (tmp.flags & ~RISCOM_LEGAL_FLAGS))
1315 change_speed = ((port->port.flags & ASYNC_SPD_MASK) !=
1316 (tmp.flags & ASYNC_SPD_MASK));
1318 if (!capable(CAP_SYS_ADMIN)) {
1319 if ((tmp.close_delay != port->port.close_delay) ||
1320 (tmp.closing_wait != port->port.closing_wait) ||
1321 ((tmp.flags & ~ASYNC_USR_MASK) !=
1322 (port->port.flags & ~ASYNC_USR_MASK)))
1324 port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
1325 (tmp.flags & ASYNC_USR_MASK));
1327 port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) |
1328 (tmp.flags & ASYNC_FLAGS));
1329 port->port.close_delay = tmp.close_delay;
1330 port->port.closing_wait = tmp.closing_wait;
1333 unsigned long flags;
1335 spin_lock_irqsave(&riscom_lock, flags);
1336 rc_change_speed(bp, port);
1337 spin_unlock_irqrestore(&riscom_lock, flags);
1342 static int rc_get_serial_info(struct riscom_port *port,
1343 struct serial_struct __user *retinfo)
1345 struct serial_struct tmp;
1346 struct riscom_board *bp = port_Board(port);
1348 memset(&tmp, 0, sizeof(tmp));
1349 tmp.type = PORT_CIRRUS;
1350 tmp.line = port - rc_port;
1351 tmp.port = bp->base;
1353 tmp.flags = port->port.flags;
1354 tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC;
1355 tmp.close_delay = port->port.close_delay * HZ/100;
1356 tmp.closing_wait = port->port.closing_wait * HZ/100;
1357 tmp.xmit_fifo_size = CD180_NFIFO;
1358 return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0;
1361 static int rc_ioctl(struct tty_struct *tty, struct file *filp,
1362 unsigned int cmd, unsigned long arg)
1364 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1365 void __user *argp = (void __user *)arg;
1368 if (rc_paranoia_check(port, tty->name, "rc_ioctl"))
1374 retval = rc_get_serial_info(port, argp);
1379 retval = rc_set_serial_info(port, argp);
1383 retval = -ENOIOCTLCMD;
1388 static void rc_throttle(struct tty_struct *tty)
1390 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1391 struct riscom_board *bp;
1392 unsigned long flags;
1394 if (rc_paranoia_check(port, tty->name, "rc_throttle"))
1396 bp = port_Board(port);
1398 spin_lock_irqsave(&riscom_lock, flags);
1399 port->MSVR &= ~MSVR_RTS;
1400 rc_out(bp, CD180_CAR, port_No(port));
1403 rc_out(bp, CD180_CCR, CCR_SSCH2);
1406 rc_out(bp, CD180_MSVR, port->MSVR);
1407 spin_unlock_irqrestore(&riscom_lock, flags);
1410 static void rc_unthrottle(struct tty_struct *tty)
1412 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1413 struct riscom_board *bp;
1414 unsigned long flags;
1416 if (rc_paranoia_check(port, tty->name, "rc_unthrottle"))
1418 bp = port_Board(port);
1420 spin_lock_irqsave(&riscom_lock, flags);
1421 port->MSVR |= MSVR_RTS;
1422 rc_out(bp, CD180_CAR, port_No(port));
1425 rc_out(bp, CD180_CCR, CCR_SSCH1);
1428 rc_out(bp, CD180_MSVR, port->MSVR);
1429 spin_unlock_irqrestore(&riscom_lock, flags);
1432 static void rc_stop(struct tty_struct *tty)
1434 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1435 struct riscom_board *bp;
1436 unsigned long flags;
1438 if (rc_paranoia_check(port, tty->name, "rc_stop"))
1441 bp = port_Board(port);
1443 spin_lock_irqsave(&riscom_lock, flags);
1444 port->IER &= ~IER_TXRDY;
1445 rc_out(bp, CD180_CAR, port_No(port));
1446 rc_out(bp, CD180_IER, port->IER);
1447 spin_unlock_irqrestore(&riscom_lock, flags);
1450 static void rc_start(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_start"))
1459 bp = port_Board(port);
1461 spin_lock_irqsave(&riscom_lock, flags);
1463 if (port->xmit_cnt && port->port.xmit_buf && !(port->IER & IER_TXRDY)) {
1464 port->IER |= IER_TXRDY;
1465 rc_out(bp, CD180_CAR, port_No(port));
1466 rc_out(bp, CD180_IER, port->IER);
1468 spin_unlock_irqrestore(&riscom_lock, flags);
1471 static void rc_hangup(struct tty_struct *tty)
1473 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1474 struct riscom_board *bp;
1475 unsigned long flags;
1477 if (rc_paranoia_check(port, tty->name, "rc_hangup"))
1480 bp = port_Board(port);
1482 rc_shutdown_port(tty, bp, port);
1483 spin_lock_irqsave(&port->port.lock, flags);
1484 port->port.count = 0;
1485 port->port.flags &= ~ASYNC_NORMAL_ACTIVE;
1486 port->port.tty = NULL;
1487 wake_up_interruptible(&port->port.open_wait);
1488 spin_unlock_irqrestore(&port->port.lock, flags);
1491 static void rc_set_termios(struct tty_struct *tty,
1492 struct ktermios *old_termios)
1494 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1495 unsigned long flags;
1497 if (rc_paranoia_check(port, tty->name, "rc_set_termios"))
1500 spin_lock_irqsave(&riscom_lock, flags);
1501 rc_change_speed(port_Board(port), port);
1502 spin_unlock_irqrestore(&riscom_lock, flags);
1504 if ((old_termios->c_cflag & CRTSCTS) &&
1505 !(tty->termios->c_cflag & CRTSCTS)) {
1506 tty->hw_stopped = 0;
1511 static const struct tty_operations riscom_ops = {
1515 .put_char = rc_put_char,
1516 .flush_chars = rc_flush_chars,
1517 .write_room = rc_write_room,
1518 .chars_in_buffer = rc_chars_in_buffer,
1519 .flush_buffer = rc_flush_buffer,
1521 .throttle = rc_throttle,
1522 .unthrottle = rc_unthrottle,
1523 .set_termios = rc_set_termios,
1526 .hangup = rc_hangup,
1527 .tiocmget = rc_tiocmget,
1528 .tiocmset = rc_tiocmset,
1529 .break_ctl = rc_send_break,
1532 static const struct tty_port_operations riscom_port_ops = {
1533 .carrier_raised = carrier_raised,
1537 static int __init rc_init_drivers(void)
1542 riscom_driver = alloc_tty_driver(RC_NBOARD * RC_NPORT);
1546 riscom_driver->owner = THIS_MODULE;
1547 riscom_driver->name = "ttyL";
1548 riscom_driver->major = RISCOM8_NORMAL_MAJOR;
1549 riscom_driver->type = TTY_DRIVER_TYPE_SERIAL;
1550 riscom_driver->subtype = SERIAL_TYPE_NORMAL;
1551 riscom_driver->init_termios = tty_std_termios;
1552 riscom_driver->init_termios.c_cflag =
1553 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1554 riscom_driver->init_termios.c_ispeed = 9600;
1555 riscom_driver->init_termios.c_ospeed = 9600;
1556 riscom_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_HARDWARE_BREAK;
1557 tty_set_operations(riscom_driver, &riscom_ops);
1558 error = tty_register_driver(riscom_driver);
1560 put_tty_driver(riscom_driver);
1561 printk(KERN_ERR "rc: Couldn't register RISCom/8 driver, "
1562 "error = %d\n", error);
1565 memset(rc_port, 0, sizeof(rc_port));
1566 for (i = 0; i < RC_NPORT * RC_NBOARD; i++) {
1567 tty_port_init(&rc_port[i].port);
1568 rc_port[i].port.ops = &riscom_port_ops;
1569 rc_port[i].magic = RISCOM8_MAGIC;
1574 static void rc_release_drivers(void)
1576 tty_unregister_driver(riscom_driver);
1577 put_tty_driver(riscom_driver);
1582 * Called at boot time.
1584 * You can specify IO base for up to RC_NBOARD cards,
1585 * using line "riscom8=0xiobase1,0xiobase2,.." at LILO prompt.
1586 * Note that there will be no probing at default
1587 * addresses in this case.
1590 static int __init riscom8_setup(char *str)
1592 int ints[RC_NBOARD];
1595 str = get_options(str, ARRAY_SIZE(ints), ints);
1597 for (i = 0; i < RC_NBOARD; i++) {
1599 rc_board[i].base = ints[i+1];
1601 rc_board[i].base = 0;
1606 __setup("riscom8=", riscom8_setup);
1609 static char banner[] __initdata =
1610 KERN_INFO "rc: SDL RISCom/8 card driver v1.1, (c) D.Gorodchanin "
1612 static char no_boards_msg[] __initdata =
1613 KERN_INFO "rc: No RISCom/8 boards detected.\n";
1616 * This routine must be called by kernel at boot time
1618 static int __init riscom8_init(void)
1625 if (rc_init_drivers())
1628 for (i = 0; i < RC_NBOARD; i++)
1629 if (rc_board[i].base && !rc_probe(&rc_board[i]))
1632 rc_release_drivers();
1633 printk(no_boards_msg);
1644 module_param(iobase, int, 0);
1645 module_param(iobase1, int, 0);
1646 module_param(iobase2, int, 0);
1647 module_param(iobase3, int, 0);
1649 MODULE_LICENSE("GPL");
1653 * You can setup up to 4 boards (current value of RC_NBOARD)
1654 * by specifying "iobase=0xXXX iobase1=0xXXX ..." as insmod parameter.
1657 static int __init riscom8_init_module(void)
1662 if (iobase || iobase1 || iobase2 || iobase3) {
1663 for (i = 0; i < RC_NBOARD; i++)
1664 rc_board[i].base = 0;
1668 rc_board[0].base = iobase;
1670 rc_board[1].base = iobase1;
1672 rc_board[2].base = iobase2;
1674 rc_board[3].base = iobase3;
1677 return riscom8_init();
1680 static void __exit riscom8_exit_module(void)
1684 rc_release_drivers();
1685 for (i = 0; i < RC_NBOARD; i++)
1686 if (rc_board[i].flags & RC_BOARD_PRESENT)
1687 rc_release_io_range(&rc_board[i]);
1691 module_init(riscom8_init_module);
1692 module_exit(riscom8_exit_module);