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 /* Reset and setup CD180 chip */
217 static void __init rc_init_CD180(struct riscom_board const * bp)
221 save_flags(flags); cli();
222 rc_out(bp, RC_CTOUT, 0); /* Clear timeout */
223 rc_wait_CCR(bp); /* Wait for CCR ready */
224 rc_out(bp, CD180_CCR, CCR_HARDRESET); /* Reset CD180 chip */
226 msleep(50); /* Delay 0.05 sec */
228 rc_out(bp, CD180_GIVR, RC_ID); /* Set ID for this chip */
229 rc_out(bp, CD180_GICR, 0); /* Clear all bits */
230 rc_out(bp, CD180_PILR1, RC_ACK_MINT); /* Prio for modem intr */
231 rc_out(bp, CD180_PILR2, RC_ACK_TINT); /* Prio for transmitter intr */
232 rc_out(bp, CD180_PILR3, RC_ACK_RINT); /* Prio for receiver intr */
234 /* Setting up prescaler. We need 4 ticks per 1 ms */
235 rc_out(bp, CD180_PPRH, (RC_OSCFREQ/(1000000/RISCOM_TPS)) >> 8);
236 rc_out(bp, CD180_PPRL, (RC_OSCFREQ/(1000000/RISCOM_TPS)) & 0xff);
238 restore_flags(flags);
241 /* Main probing routine, also sets irq. */
242 static int __init rc_probe(struct riscom_board *bp)
244 unsigned char val1, val2;
250 if (rc_request_io_range(bp))
253 /* Are the I/O ports here ? */
254 rc_out(bp, CD180_PPRL, 0x5a);
256 val1 = rc_in(bp, CD180_PPRL);
257 rc_out(bp, CD180_PPRL, 0xa5);
259 val2 = rc_in(bp, CD180_PPRL);
261 if ((val1 != 0x5a) || (val2 != 0xa5)) {
262 printk(KERN_ERR "rc%d: RISCom/8 Board at 0x%03x not found.\n",
263 board_No(bp), bp->base);
267 /* It's time to find IRQ for this board */
268 for (retries = 0; retries < 5 && irqs <= 0; retries++) {
269 irqs = probe_irq_on();
270 rc_init_CD180(bp); /* Reset CD180 chip */
271 rc_out(bp, CD180_CAR, 2); /* Select port 2 */
273 rc_out(bp, CD180_CCR, CCR_TXEN); /* Enable transmitter */
274 rc_out(bp, CD180_IER, IER_TXRDY); /* Enable tx empty intr */
276 irqs = probe_irq_off(irqs);
277 val1 = rc_in(bp, RC_BSR); /* Get Board Status reg */
278 val2 = rc_in(bp, RC_ACK_TINT); /* ACK interrupt */
279 rc_init_CD180(bp); /* Reset CD180 again */
281 if ((val1 & RC_BSR_TINT) || (val2 != (RC_ID | GIVR_IT_TX))) {
282 printk(KERN_ERR "rc%d: RISCom/8 Board at 0x%03x not "
283 "found.\n", board_No(bp), bp->base);
289 printk(KERN_ERR "rc%d: Can't find IRQ for RISCom/8 board "
290 "at 0x%03x.\n", board_No(bp), bp->base);
294 bp->flags |= RC_BOARD_PRESENT;
296 printk(KERN_INFO "rc%d: RISCom/8 Rev. %c board detected at "
299 (rc_in(bp, CD180_GFRCR) & 0x0f) + 'A', /* Board revision */
304 rc_release_io_range(bp);
310 * Interrupt processing routines.
314 static inline void rc_mark_event(struct riscom_port * port, int event)
316 set_bit(event, &port->event);
317 schedule_work(&port->tqueue);
320 static inline struct riscom_port * rc_get_port(struct riscom_board const * bp,
321 unsigned char const * what)
323 unsigned char channel;
324 struct riscom_port * port;
326 channel = rc_in(bp, CD180_GICR) >> GICR_CHAN_OFF;
327 if (channel < CD180_NCH) {
328 port = &rc_port[board_No(bp) * RC_NPORT + channel];
329 if (port->flags & ASYNC_INITIALIZED) {
333 printk(KERN_ERR "rc%d: %s interrupt from invalid port %d\n",
334 board_No(bp), what, channel);
338 static inline void rc_receive_exc(struct riscom_board const * bp)
340 struct riscom_port *port;
341 struct tty_struct *tty;
342 unsigned char status;
343 unsigned char ch, flag;
345 if (!(port = rc_get_port(bp, "Receive")))
350 #ifdef RC_REPORT_OVERRUN
351 status = rc_in(bp, CD180_RCSR);
352 if (status & RCSR_OE)
354 status &= port->mark_mask;
356 status = rc_in(bp, CD180_RCSR) & port->mark_mask;
358 ch = rc_in(bp, CD180_RDR);
362 if (status & RCSR_TOUT) {
363 printk(KERN_WARNING "rc%d: port %d: Receiver timeout. "
364 "Hardware problems ?\n",
365 board_No(bp), port_No(port));
368 } else if (status & RCSR_BREAK) {
369 printk(KERN_INFO "rc%d: port %d: Handling break...\n",
370 board_No(bp), port_No(port));
372 if (port->flags & ASYNC_SAK)
375 } else if (status & RCSR_PE)
378 else if (status & RCSR_FE)
381 else if (status & RCSR_OE)
387 tty_insert_flip_char(tty, ch, flag);
388 tty_flip_buffer_push(tty);
391 static inline void rc_receive(struct riscom_board const * bp)
393 struct riscom_port *port;
394 struct tty_struct *tty;
397 if (!(port = rc_get_port(bp, "Receive")))
402 count = rc_in(bp, CD180_RDCR);
404 #ifdef RC_REPORT_FIFO
405 port->hits[count > 8 ? 9 : count]++;
409 if (tty_buffer_request_room(tty, 1) == 0) {
410 printk(KERN_WARNING "rc%d: port %d: Working around "
411 "flip buffer overflow.\n",
412 board_No(bp), port_No(port));
415 tty_insert_flip_char(tty, rc_in(bp, CD180_RDR), TTY_NORMAL);
417 tty_flip_buffer_push(tty);
420 static inline void rc_transmit(struct riscom_board const * bp)
422 struct riscom_port *port;
423 struct tty_struct *tty;
427 if (!(port = rc_get_port(bp, "Transmit")))
432 if (port->IER & IER_TXEMPTY) {
434 rc_out(bp, CD180_CAR, port_No(port));
435 port->IER &= ~IER_TXEMPTY;
436 rc_out(bp, CD180_IER, port->IER);
440 if ((port->xmit_cnt <= 0 && !port->break_length)
441 || tty->stopped || tty->hw_stopped) {
442 rc_out(bp, CD180_CAR, port_No(port));
443 port->IER &= ~IER_TXRDY;
444 rc_out(bp, CD180_IER, port->IER);
448 if (port->break_length) {
449 if (port->break_length > 0) {
450 if (port->COR2 & COR2_ETC) {
451 rc_out(bp, CD180_TDR, CD180_C_ESC);
452 rc_out(bp, CD180_TDR, CD180_C_SBRK);
453 port->COR2 &= ~COR2_ETC;
455 count = min_t(int, port->break_length, 0xff);
456 rc_out(bp, CD180_TDR, CD180_C_ESC);
457 rc_out(bp, CD180_TDR, CD180_C_DELAY);
458 rc_out(bp, CD180_TDR, count);
459 if (!(port->break_length -= count))
460 port->break_length--;
462 rc_out(bp, CD180_TDR, CD180_C_ESC);
463 rc_out(bp, CD180_TDR, CD180_C_EBRK);
464 rc_out(bp, CD180_COR2, port->COR2);
466 rc_out(bp, CD180_CCR, CCR_CORCHG2);
467 port->break_length = 0;
474 rc_out(bp, CD180_TDR, port->xmit_buf[port->xmit_tail++]);
475 port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE-1);
476 if (--port->xmit_cnt <= 0)
478 } while (--count > 0);
480 if (port->xmit_cnt <= 0) {
481 rc_out(bp, CD180_CAR, port_No(port));
482 port->IER &= ~IER_TXRDY;
483 rc_out(bp, CD180_IER, port->IER);
485 if (port->xmit_cnt <= port->wakeup_chars)
486 rc_mark_event(port, RS_EVENT_WRITE_WAKEUP);
489 static inline void rc_check_modem(struct riscom_board const * bp)
491 struct riscom_port *port;
492 struct tty_struct *tty;
495 if (!(port = rc_get_port(bp, "Modem")))
500 mcr = rc_in(bp, CD180_MCR);
501 if (mcr & MCR_CDCHG) {
502 if (rc_in(bp, CD180_MSVR) & MSVR_CD)
503 wake_up_interruptible(&port->open_wait);
505 schedule_work(&port->tqueue_hangup);
508 #ifdef RISCOM_BRAIN_DAMAGED_CTS
509 if (mcr & MCR_CTSCHG) {
510 if (rc_in(bp, CD180_MSVR) & MSVR_CTS) {
512 port->IER |= IER_TXRDY;
513 if (port->xmit_cnt <= port->wakeup_chars)
514 rc_mark_event(port, RS_EVENT_WRITE_WAKEUP);
517 port->IER &= ~IER_TXRDY;
519 rc_out(bp, CD180_IER, port->IER);
521 if (mcr & MCR_DSRCHG) {
522 if (rc_in(bp, CD180_MSVR) & MSVR_DSR) {
524 port->IER |= IER_TXRDY;
525 if (port->xmit_cnt <= port->wakeup_chars)
526 rc_mark_event(port, RS_EVENT_WRITE_WAKEUP);
529 port->IER &= ~IER_TXRDY;
531 rc_out(bp, CD180_IER, port->IER);
533 #endif /* RISCOM_BRAIN_DAMAGED_CTS */
535 /* Clear change bits */
536 rc_out(bp, CD180_MCR, 0);
539 /* The main interrupt processing routine */
540 static irqreturn_t rc_interrupt(int irq, void * dev_id)
542 unsigned char status;
544 struct riscom_board *bp;
545 unsigned long loop = 0;
548 bp = IRQ_to_board[irq];
550 if (!(bp->flags & RC_BOARD_ACTIVE))
553 while ((++loop < 16) && ((status = ~(rc_in(bp, RC_BSR))) &
554 (RC_BSR_TOUT | RC_BSR_TINT |
555 RC_BSR_MINT | RC_BSR_RINT))) {
557 if (status & RC_BSR_TOUT)
558 printk(KERN_WARNING "rc%d: Got timeout. Hardware "
559 "error?\n", board_No(bp));
561 else if (status & RC_BSR_RINT) {
562 ack = rc_in(bp, RC_ACK_RINT);
564 if (ack == (RC_ID | GIVR_IT_RCV))
566 else if (ack == (RC_ID | GIVR_IT_REXC))
569 printk(KERN_WARNING "rc%d: Bad receive ack "
573 } else if (status & RC_BSR_TINT) {
574 ack = rc_in(bp, RC_ACK_TINT);
576 if (ack == (RC_ID | GIVR_IT_TX))
579 printk(KERN_WARNING "rc%d: Bad transmit ack "
583 } else /* if (status & RC_BSR_MINT) */ {
584 ack = rc_in(bp, RC_ACK_MINT);
586 if (ack == (RC_ID | GIVR_IT_MODEM))
589 printk(KERN_WARNING "rc%d: Bad modem ack "
595 rc_out(bp, CD180_EOIR, 0); /* Mark end of interrupt */
596 rc_out(bp, RC_CTOUT, 0); /* Clear timeout flag */
598 return IRQ_RETVAL(handled);
602 * Routines for open & close processing.
605 /* Called with disabled interrupts */
606 static inline int rc_setup_board(struct riscom_board * bp)
610 if (bp->flags & RC_BOARD_ACTIVE)
613 error = request_irq(bp->irq, rc_interrupt, IRQF_DISABLED,
618 rc_out(bp, RC_CTOUT, 0); /* Just in case */
620 rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */
622 IRQ_to_board[bp->irq] = bp;
623 bp->flags |= RC_BOARD_ACTIVE;
628 /* Called with disabled interrupts */
629 static inline void rc_shutdown_board(struct riscom_board *bp)
631 if (!(bp->flags & RC_BOARD_ACTIVE))
634 bp->flags &= ~RC_BOARD_ACTIVE;
636 free_irq(bp->irq, NULL);
637 IRQ_to_board[bp->irq] = NULL;
640 rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */
645 * Setting up port characteristics.
646 * Must be called with disabled interrupts
648 static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
650 struct tty_struct *tty;
653 unsigned char cor1 = 0, cor3 = 0;
654 unsigned char mcor1 = 0, mcor2 = 0;
656 if (!(tty = port->tty) || !tty->termios)
661 port->MSVR = MSVR_RTS;
663 baud = tty_get_baud_rate(tty);
665 /* Select port on the board */
666 rc_out(bp, CD180_CAR, port_No(port));
669 /* Drop DTR & exit */
670 bp->DTR |= (1u << port_No(port));
671 rc_out(bp, RC_DTR, bp->DTR);
675 bp->DTR &= ~(1u << port_No(port));
676 rc_out(bp, RC_DTR, bp->DTR);
680 * Now we must calculate some speed depended things
683 /* Set baud rate for port */
684 tmp = (((RC_OSCFREQ + baud/2) / baud +
685 CD180_TPC/2) / CD180_TPC);
687 rc_out(bp, CD180_RBPRH, (tmp >> 8) & 0xff);
688 rc_out(bp, CD180_TBPRH, (tmp >> 8) & 0xff);
689 rc_out(bp, CD180_RBPRL, tmp & 0xff);
690 rc_out(bp, CD180_TBPRL, tmp & 0xff);
692 baud = (baud + 5) / 10; /* Estimated CPS */
694 /* Two timer ticks seems enough to wakeup something like SLIP driver */
695 tmp = ((baud + HZ/2) / HZ) * 2 - CD180_NFIFO;
696 port->wakeup_chars = (tmp < 0) ? 0 : ((tmp >= SERIAL_XMIT_SIZE) ?
697 SERIAL_XMIT_SIZE - 1 : tmp);
699 /* Receiver timeout will be transmission time for 1.5 chars */
700 tmp = (RISCOM_TPS + RISCOM_TPS/2 + baud/2) / baud;
701 tmp = (tmp > 0xff) ? 0xff : tmp;
702 rc_out(bp, CD180_RTPR, tmp);
704 switch (C_CSIZE(tty)) {
724 cor1 |= COR1_NORMPAR;
728 cor1 &= ~COR1_IGNORE;
730 /* Set marking of some errors */
731 port->mark_mask = RCSR_OE | RCSR_TOUT;
733 port->mark_mask |= RCSR_FE | RCSR_PE;
734 if (I_BRKINT(tty) || I_PARMRK(tty))
735 port->mark_mask |= RCSR_BREAK;
737 port->mark_mask &= ~(RCSR_FE | RCSR_PE);
739 port->mark_mask &= ~RCSR_BREAK;
741 /* Real raw mode. Ignore all */
742 port->mark_mask &= ~RCSR_OE;
744 /* Enable Hardware Flow Control */
745 if (C_CRTSCTS(tty)) {
746 #ifdef RISCOM_BRAIN_DAMAGED_CTS
747 port->IER |= IER_DSR | IER_CTS;
748 mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD;
749 mcor2 |= MCOR2_DSROD | MCOR2_CTSOD;
750 tty->hw_stopped = !(rc_in(bp, CD180_MSVR) & (MSVR_CTS|MSVR_DSR));
752 port->COR2 |= COR2_CTSAE;
755 /* Enable Software Flow Control. FIXME: I'm not sure about this */
756 /* Some people reported that it works, but I still doubt */
758 port->COR2 |= COR2_TXIBE;
759 cor3 |= (COR3_FCT | COR3_SCDE);
761 port->COR2 |= COR2_IXM;
762 rc_out(bp, CD180_SCHR1, START_CHAR(tty));
763 rc_out(bp, CD180_SCHR2, STOP_CHAR(tty));
764 rc_out(bp, CD180_SCHR3, START_CHAR(tty));
765 rc_out(bp, CD180_SCHR4, STOP_CHAR(tty));
767 if (!C_CLOCAL(tty)) {
768 /* Enable CD check */
775 /* Enable receiver */
776 port->IER |= IER_RXD;
778 /* Set input FIFO size (1-8 bytes) */
779 cor3 |= RISCOM_RXFIFO;
780 /* Setting up CD180 channel registers */
781 rc_out(bp, CD180_COR1, cor1);
782 rc_out(bp, CD180_COR2, port->COR2);
783 rc_out(bp, CD180_COR3, cor3);
784 /* Make CD180 know about registers change */
786 rc_out(bp, CD180_CCR, CCR_CORCHG1 | CCR_CORCHG2 | CCR_CORCHG3);
787 /* Setting up modem option registers */
788 rc_out(bp, CD180_MCOR1, mcor1);
789 rc_out(bp, CD180_MCOR2, mcor2);
790 /* Enable CD180 transmitter & receiver */
792 rc_out(bp, CD180_CCR, CCR_TXEN | CCR_RXEN);
793 /* Enable interrupts */
794 rc_out(bp, CD180_IER, port->IER);
795 /* And finally set RTS on */
796 rc_out(bp, CD180_MSVR, port->MSVR);
799 /* Must be called with interrupts enabled */
800 static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
804 if (port->flags & ASYNC_INITIALIZED)
807 if (!port->xmit_buf) {
808 /* We may sleep in get_zeroed_page() */
811 if (!(tmp = get_zeroed_page(GFP_KERNEL)))
814 if (port->xmit_buf) {
818 port->xmit_buf = (unsigned char *) tmp;
821 save_flags(flags); cli();
824 clear_bit(TTY_IO_ERROR, &port->tty->flags);
826 if (port->count == 1)
829 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
830 rc_change_speed(bp, port);
831 port->flags |= ASYNC_INITIALIZED;
833 restore_flags(flags);
837 /* Must be called with interrupts disabled */
838 static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
840 struct tty_struct *tty;
842 if (!(port->flags & ASYNC_INITIALIZED))
845 #ifdef RC_REPORT_OVERRUN
846 printk(KERN_INFO "rc%d: port %d: Total %ld overruns were detected.\n",
847 board_No(bp), port_No(port), port->overrun);
849 #ifdef RC_REPORT_FIFO
853 printk(KERN_INFO "rc%d: port %d: FIFO hits [ ",
854 board_No(bp), port_No(port));
855 for (i = 0; i < 10; i++) {
856 printk("%ld ", port->hits[i]);
861 if (port->xmit_buf) {
862 free_page((unsigned long) port->xmit_buf);
863 port->xmit_buf = NULL;
866 if (!(tty = port->tty) || C_HUPCL(tty)) {
868 bp->DTR |= (1u << port_No(port));
869 rc_out(bp, RC_DTR, bp->DTR);
873 rc_out(bp, CD180_CAR, port_No(port));
876 rc_out(bp, CD180_CCR, CCR_SOFTRESET);
877 /* Disable all interrupts from this port */
879 rc_out(bp, CD180_IER, port->IER);
882 set_bit(TTY_IO_ERROR, &tty->flags);
883 port->flags &= ~ASYNC_INITIALIZED;
885 if (--bp->count < 0) {
886 printk(KERN_INFO "rc%d: rc_shutdown_port: "
887 "bad board count: %d\n",
888 board_No(bp), bp->count);
893 * If this is the last opened port on the board
894 * shutdown whole board
897 rc_shutdown_board(bp);
901 static int block_til_ready(struct tty_struct *tty, struct file * filp,
902 struct riscom_port *port)
904 DECLARE_WAITQUEUE(wait, current);
905 struct riscom_board *bp = port_Board(port);
911 * If the device is in the middle of being closed, then block
912 * until it's done, and then try again.
914 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) {
915 interruptible_sleep_on(&port->close_wait);
916 if (port->flags & ASYNC_HUP_NOTIFY)
923 * If non-blocking mode is set, or the port is not enabled,
924 * then make the check up front and then exit.
926 if ((filp->f_flags & O_NONBLOCK) ||
927 (tty->flags & (1 << TTY_IO_ERROR))) {
928 port->flags |= ASYNC_NORMAL_ACTIVE;
936 * Block waiting for the carrier detect and the line to become
937 * free (i.e., not in use by the callout). While we are in
938 * this loop, info->count is dropped by one, so that
939 * rs_close() knows when to free things. We restore it upon
940 * exit, either normal or abnormal.
943 add_wait_queue(&port->open_wait, &wait);
945 if (!tty_hung_up_p(filp))
948 port->blocked_open++;
951 rc_out(bp, CD180_CAR, port_No(port));
952 CD = rc_in(bp, CD180_MSVR) & MSVR_CD;
953 rc_out(bp, CD180_MSVR, MSVR_RTS);
954 bp->DTR &= ~(1u << port_No(port));
955 rc_out(bp, RC_DTR, bp->DTR);
957 set_current_state(TASK_INTERRUPTIBLE);
958 if (tty_hung_up_p(filp) ||
959 !(port->flags & ASYNC_INITIALIZED)) {
960 if (port->flags & ASYNC_HUP_NOTIFY)
963 retval = -ERESTARTSYS;
966 if (!(port->flags & ASYNC_CLOSING) &&
969 if (signal_pending(current)) {
970 retval = -ERESTARTSYS;
975 __set_current_state(TASK_RUNNING);
976 remove_wait_queue(&port->open_wait, &wait);
977 if (!tty_hung_up_p(filp))
979 port->blocked_open--;
983 port->flags |= ASYNC_NORMAL_ACTIVE;
987 static int rc_open(struct tty_struct * tty, struct file * filp)
991 struct riscom_port * port;
992 struct riscom_board * bp;
994 board = RC_BOARD(tty->index);
995 if (board >= RC_NBOARD || !(rc_board[board].flags & RC_BOARD_PRESENT))
998 bp = &rc_board[board];
999 port = rc_port + board * RC_NPORT + RC_PORT(tty->index);
1000 if (rc_paranoia_check(port, tty->name, "rc_open"))
1003 if ((error = rc_setup_board(bp)))
1007 tty->driver_data = port;
1010 if ((error = rc_setup_port(bp, port)))
1013 if ((error = block_til_ready(tty, filp, port)))
1019 static void rc_close(struct tty_struct * tty, struct file * filp)
1021 struct riscom_port *port = (struct riscom_port *) tty->driver_data;
1022 struct riscom_board *bp;
1023 unsigned long flags;
1024 unsigned long timeout;
1026 if (!port || rc_paranoia_check(port, tty->name, "close"))
1029 save_flags(flags); cli();
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);
1088 if (port->blocked_open) {
1089 if (port->close_delay) {
1090 msleep_interruptible(jiffies_to_msecs(port->close_delay));
1092 wake_up_interruptible(&port->open_wait);
1094 port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
1095 wake_up_interruptible(&port->close_wait);
1096 out: restore_flags(flags);
1099 static int rc_write(struct tty_struct * tty,
1100 const unsigned char *buf, int count)
1102 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1103 struct riscom_board *bp;
1105 unsigned long flags;
1107 if (rc_paranoia_check(port, tty->name, "rc_write"))
1110 bp = port_Board(port);
1112 if (!tty || !port->xmit_buf)
1118 c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
1119 SERIAL_XMIT_SIZE - port->xmit_head));
1121 restore_flags(flags);
1125 memcpy(port->xmit_buf + port->xmit_head, buf, c);
1126 port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
1127 port->xmit_cnt += c;
1128 restore_flags(flags);
1136 if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped &&
1137 !(port->IER & IER_TXRDY)) {
1138 port->IER |= IER_TXRDY;
1139 rc_out(bp, CD180_CAR, port_No(port));
1140 rc_out(bp, CD180_IER, port->IER);
1142 restore_flags(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 save_flags(flags); cli();
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;
1166 out: restore_flags(flags);
1169 static void rc_flush_chars(struct tty_struct * tty)
1171 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1172 unsigned long flags;
1174 if (rc_paranoia_check(port, tty->name, "rc_flush_chars"))
1177 if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
1181 save_flags(flags); cli();
1182 port->IER |= IER_TXRDY;
1183 rc_out(port_Board(port), CD180_CAR, port_No(port));
1184 rc_out(port_Board(port), CD180_IER, port->IER);
1185 restore_flags(flags);
1188 static int rc_write_room(struct tty_struct * tty)
1190 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1193 if (rc_paranoia_check(port, tty->name, "rc_write_room"))
1196 ret = SERIAL_XMIT_SIZE - port->xmit_cnt - 1;
1202 static int rc_chars_in_buffer(struct tty_struct *tty)
1204 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1206 if (rc_paranoia_check(port, tty->name, "rc_chars_in_buffer"))
1209 return port->xmit_cnt;
1212 static void rc_flush_buffer(struct tty_struct *tty)
1214 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1215 unsigned long flags;
1217 if (rc_paranoia_check(port, tty->name, "rc_flush_buffer"))
1220 save_flags(flags); cli();
1221 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
1222 restore_flags(flags);
1227 static int rc_tiocmget(struct tty_struct *tty, struct file *file)
1229 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1230 struct riscom_board * bp;
1231 unsigned char status;
1232 unsigned int result;
1233 unsigned long flags;
1235 if (rc_paranoia_check(port, tty->name, __FUNCTION__))
1238 bp = port_Board(port);
1239 save_flags(flags); cli();
1240 rc_out(bp, CD180_CAR, port_No(port));
1241 status = rc_in(bp, CD180_MSVR);
1242 result = rc_in(bp, RC_RI) & (1u << port_No(port)) ? 0 : TIOCM_RNG;
1243 restore_flags(flags);
1244 result |= ((status & MSVR_RTS) ? TIOCM_RTS : 0)
1245 | ((status & MSVR_DTR) ? TIOCM_DTR : 0)
1246 | ((status & MSVR_CD) ? TIOCM_CAR : 0)
1247 | ((status & MSVR_DSR) ? TIOCM_DSR : 0)
1248 | ((status & MSVR_CTS) ? TIOCM_CTS : 0);
1252 static int rc_tiocmset(struct tty_struct *tty, struct file *file,
1253 unsigned int set, unsigned int clear)
1255 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1256 unsigned long flags;
1257 struct riscom_board *bp;
1259 if (rc_paranoia_check(port, tty->name, __FUNCTION__))
1262 bp = port_Board(port);
1264 save_flags(flags); cli();
1265 if (set & TIOCM_RTS)
1266 port->MSVR |= MSVR_RTS;
1267 if (set & TIOCM_DTR)
1268 bp->DTR &= ~(1u << port_No(port));
1270 if (clear & TIOCM_RTS)
1271 port->MSVR &= ~MSVR_RTS;
1272 if (clear & TIOCM_DTR)
1273 bp->DTR |= (1u << port_No(port));
1275 rc_out(bp, CD180_CAR, port_No(port));
1276 rc_out(bp, CD180_MSVR, port->MSVR);
1277 rc_out(bp, RC_DTR, bp->DTR);
1278 restore_flags(flags);
1282 static inline void rc_send_break(struct riscom_port * port, unsigned long length)
1284 struct riscom_board *bp = port_Board(port);
1285 unsigned long flags;
1287 save_flags(flags); cli();
1288 port->break_length = RISCOM_TPS / HZ * length;
1289 port->COR2 |= COR2_ETC;
1290 port->IER |= IER_TXRDY;
1291 rc_out(bp, CD180_CAR, port_No(port));
1292 rc_out(bp, CD180_COR2, port->COR2);
1293 rc_out(bp, CD180_IER, port->IER);
1295 rc_out(bp, CD180_CCR, CCR_CORCHG2);
1297 restore_flags(flags);
1300 static inline int rc_set_serial_info(struct riscom_port * port,
1301 struct serial_struct __user * newinfo)
1303 struct serial_struct tmp;
1304 struct riscom_board *bp = port_Board(port);
1306 unsigned long flags;
1308 if (copy_from_user(&tmp, newinfo, sizeof(tmp)))
1312 if ((tmp.irq != bp->irq) ||
1313 (tmp.port != bp->base) ||
1314 (tmp.type != PORT_CIRRUS) ||
1315 (tmp.baud_base != (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC) ||
1316 (tmp.custom_divisor != 0) ||
1317 (tmp.xmit_fifo_size != CD180_NFIFO) ||
1318 (tmp.flags & ~RISCOM_LEGAL_FLAGS))
1322 change_speed = ((port->flags & ASYNC_SPD_MASK) !=
1323 (tmp.flags & ASYNC_SPD_MASK));
1325 if (!capable(CAP_SYS_ADMIN)) {
1326 if ((tmp.close_delay != port->close_delay) ||
1327 (tmp.closing_wait != port->closing_wait) ||
1328 ((tmp.flags & ~ASYNC_USR_MASK) !=
1329 (port->flags & ~ASYNC_USR_MASK)))
1331 port->flags = ((port->flags & ~ASYNC_USR_MASK) |
1332 (tmp.flags & ASYNC_USR_MASK));
1334 port->flags = ((port->flags & ~ASYNC_FLAGS) |
1335 (tmp.flags & ASYNC_FLAGS));
1336 port->close_delay = tmp.close_delay;
1337 port->closing_wait = tmp.closing_wait;
1340 save_flags(flags); cli();
1341 rc_change_speed(bp, port);
1342 restore_flags(flags);
1347 static inline int rc_get_serial_info(struct riscom_port * port,
1348 struct serial_struct __user *retinfo)
1350 struct serial_struct tmp;
1351 struct riscom_board *bp = port_Board(port);
1353 memset(&tmp, 0, sizeof(tmp));
1354 tmp.type = PORT_CIRRUS;
1355 tmp.line = port - rc_port;
1356 tmp.port = bp->base;
1358 tmp.flags = port->flags;
1359 tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC;
1360 tmp.close_delay = port->close_delay * HZ/100;
1361 tmp.closing_wait = port->closing_wait * HZ/100;
1362 tmp.xmit_fifo_size = CD180_NFIFO;
1363 return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0;
1366 static int rc_ioctl(struct tty_struct * tty, struct file * filp,
1367 unsigned int cmd, unsigned long arg)
1370 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1371 void __user *argp = (void __user *)arg;
1374 if (rc_paranoia_check(port, tty->name, "rc_ioctl"))
1378 case TCSBRK: /* SVID version: non-zero arg --> no break */
1379 retval = tty_check_change(tty);
1382 tty_wait_until_sent(tty, 0);
1384 rc_send_break(port, HZ/4); /* 1/4 second */
1386 case TCSBRKP: /* support for POSIX tcsendbreak() */
1387 retval = tty_check_change(tty);
1390 tty_wait_until_sent(tty, 0);
1391 rc_send_break(port, arg ? arg*(HZ/10) : HZ/4);
1394 return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned __user *)argp);
1396 if (get_user(arg,(unsigned __user *) argp))
1398 tty->termios->c_cflag =
1399 ((tty->termios->c_cflag & ~CLOCAL) |
1400 (arg ? CLOCAL : 0));
1403 return rc_get_serial_info(port, argp);
1405 return rc_set_serial_info(port, argp);
1407 return -ENOIOCTLCMD;
1412 static void rc_throttle(struct tty_struct * tty)
1414 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1415 struct riscom_board *bp;
1416 unsigned long flags;
1418 if (rc_paranoia_check(port, tty->name, "rc_throttle"))
1421 bp = port_Board(port);
1423 save_flags(flags); cli();
1424 port->MSVR &= ~MSVR_RTS;
1425 rc_out(bp, CD180_CAR, port_No(port));
1428 rc_out(bp, CD180_CCR, CCR_SSCH2);
1431 rc_out(bp, CD180_MSVR, port->MSVR);
1432 restore_flags(flags);
1435 static void rc_unthrottle(struct tty_struct * tty)
1437 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1438 struct riscom_board *bp;
1439 unsigned long flags;
1441 if (rc_paranoia_check(port, tty->name, "rc_unthrottle"))
1444 bp = port_Board(port);
1446 save_flags(flags); cli();
1447 port->MSVR |= MSVR_RTS;
1448 rc_out(bp, CD180_CAR, port_No(port));
1451 rc_out(bp, CD180_CCR, CCR_SSCH1);
1454 rc_out(bp, CD180_MSVR, port->MSVR);
1455 restore_flags(flags);
1458 static void rc_stop(struct tty_struct * tty)
1460 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1461 struct riscom_board *bp;
1462 unsigned long flags;
1464 if (rc_paranoia_check(port, tty->name, "rc_stop"))
1467 bp = port_Board(port);
1469 save_flags(flags); cli();
1470 port->IER &= ~IER_TXRDY;
1471 rc_out(bp, CD180_CAR, port_No(port));
1472 rc_out(bp, CD180_IER, port->IER);
1473 restore_flags(flags);
1476 static void rc_start(struct tty_struct * tty)
1478 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1479 struct riscom_board *bp;
1480 unsigned long flags;
1482 if (rc_paranoia_check(port, tty->name, "rc_start"))
1485 bp = port_Board(port);
1487 save_flags(flags); cli();
1488 if (port->xmit_cnt && port->xmit_buf && !(port->IER & IER_TXRDY)) {
1489 port->IER |= IER_TXRDY;
1490 rc_out(bp, CD180_CAR, port_No(port));
1491 rc_out(bp, CD180_IER, port->IER);
1493 restore_flags(flags);
1497 * This routine is called from the work queue when the interrupt
1498 * routine has signalled that a hangup has occurred. The path of
1499 * hangup processing is:
1501 * serial interrupt routine -> (workqueue) ->
1502 * do_rc_hangup() -> tty->hangup() -> rc_hangup()
1505 static void do_rc_hangup(struct work_struct *ugly_api)
1507 struct riscom_port *port = container_of(ugly_api, struct riscom_port, tqueue_hangup);
1508 struct tty_struct *tty;
1512 tty_hangup(tty); /* FIXME: module removal race still here */
1515 static void rc_hangup(struct tty_struct * tty)
1517 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1518 struct riscom_board *bp;
1520 if (rc_paranoia_check(port, tty->name, "rc_hangup"))
1523 bp = port_Board(port);
1525 rc_shutdown_port(bp, port);
1528 port->flags &= ~ASYNC_NORMAL_ACTIVE;
1530 wake_up_interruptible(&port->open_wait);
1533 static void rc_set_termios(struct tty_struct * tty, struct ktermios * old_termios)
1535 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1536 unsigned long flags;
1538 if (rc_paranoia_check(port, tty->name, "rc_set_termios"))
1541 if (tty->termios->c_cflag == old_termios->c_cflag &&
1542 tty->termios->c_iflag == old_termios->c_iflag)
1545 save_flags(flags); cli();
1546 rc_change_speed(port_Board(port), port);
1547 restore_flags(flags);
1549 if ((old_termios->c_cflag & CRTSCTS) &&
1550 !(tty->termios->c_cflag & CRTSCTS)) {
1551 tty->hw_stopped = 0;
1556 static void do_softint(struct work_struct *ugly_api)
1558 struct riscom_port *port = container_of(ugly_api, struct riscom_port, tqueue);
1559 struct tty_struct *tty;
1561 if(!(tty = port->tty))
1564 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event))
1568 static const struct tty_operations riscom_ops = {
1572 .put_char = rc_put_char,
1573 .flush_chars = rc_flush_chars,
1574 .write_room = rc_write_room,
1575 .chars_in_buffer = rc_chars_in_buffer,
1576 .flush_buffer = rc_flush_buffer,
1578 .throttle = rc_throttle,
1579 .unthrottle = rc_unthrottle,
1580 .set_termios = rc_set_termios,
1583 .hangup = rc_hangup,
1584 .tiocmget = rc_tiocmget,
1585 .tiocmset = rc_tiocmset,
1588 static inline int rc_init_drivers(void)
1593 riscom_driver = alloc_tty_driver(RC_NBOARD * RC_NPORT);
1597 memset(IRQ_to_board, 0, sizeof(IRQ_to_board));
1598 riscom_driver->owner = THIS_MODULE;
1599 riscom_driver->name = "ttyL";
1600 riscom_driver->major = RISCOM8_NORMAL_MAJOR;
1601 riscom_driver->type = TTY_DRIVER_TYPE_SERIAL;
1602 riscom_driver->subtype = SERIAL_TYPE_NORMAL;
1603 riscom_driver->init_termios = tty_std_termios;
1604 riscom_driver->init_termios.c_cflag =
1605 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1606 riscom_driver->init_termios.c_ispeed = 9600;
1607 riscom_driver->init_termios.c_ospeed = 9600;
1608 riscom_driver->flags = TTY_DRIVER_REAL_RAW;
1609 tty_set_operations(riscom_driver, &riscom_ops);
1610 if ((error = tty_register_driver(riscom_driver))) {
1611 put_tty_driver(riscom_driver);
1612 printk(KERN_ERR "rc: Couldn't register RISCom/8 driver, "
1618 memset(rc_port, 0, sizeof(rc_port));
1619 for (i = 0; i < RC_NPORT * RC_NBOARD; i++) {
1620 rc_port[i].magic = RISCOM8_MAGIC;
1621 INIT_WORK(&rc_port[i].tqueue, do_softint);
1622 INIT_WORK(&rc_port[i].tqueue_hangup, do_rc_hangup);
1623 rc_port[i].close_delay = 50 * HZ/100;
1624 rc_port[i].closing_wait = 3000 * HZ/100;
1625 init_waitqueue_head(&rc_port[i].open_wait);
1626 init_waitqueue_head(&rc_port[i].close_wait);
1632 static void rc_release_drivers(void)
1634 unsigned long flags;
1638 tty_unregister_driver(riscom_driver);
1639 put_tty_driver(riscom_driver);
1640 restore_flags(flags);
1645 * Called at boot time.
1647 * You can specify IO base for up to RC_NBOARD cards,
1648 * using line "riscom8=0xiobase1,0xiobase2,.." at LILO prompt.
1649 * Note that there will be no probing at default
1650 * addresses in this case.
1653 static int __init riscom8_setup(char *str)
1655 int ints[RC_NBOARD];
1658 str = get_options(str, ARRAY_SIZE(ints), ints);
1660 for (i = 0; i < RC_NBOARD; i++) {
1662 rc_board[i].base = ints[i+1];
1664 rc_board[i].base = 0;
1669 __setup("riscom8=", riscom8_setup);
1672 static char banner[] __initdata =
1673 KERN_INFO "rc: SDL RISCom/8 card driver v1.1, (c) D.Gorodchanin "
1675 static char no_boards_msg[] __initdata =
1676 KERN_INFO "rc: No RISCom/8 boards detected.\n";
1679 * This routine must be called by kernel at boot time
1681 static int __init riscom8_init(void)
1688 if (rc_init_drivers())
1691 for (i = 0; i < RC_NBOARD; i++)
1692 if (rc_board[i].base && !rc_probe(&rc_board[i]))
1696 rc_release_drivers();
1697 printk(no_boards_msg);
1708 module_param(iobase, int, 0);
1709 module_param(iobase1, int, 0);
1710 module_param(iobase2, int, 0);
1711 module_param(iobase3, int, 0);
1713 MODULE_LICENSE("GPL");
1717 * You can setup up to 4 boards (current value of RC_NBOARD)
1718 * by specifying "iobase=0xXXX iobase1=0xXXX ..." as insmod parameter.
1721 static int __init riscom8_init_module (void)
1726 if (iobase || iobase1 || iobase2 || iobase3) {
1727 for(i = 0; i < RC_NBOARD; i++)
1728 rc_board[0].base = 0;
1732 rc_board[0].base = iobase;
1734 rc_board[1].base = iobase1;
1736 rc_board[2].base = iobase2;
1738 rc_board[3].base = iobase3;
1741 return riscom8_init();
1744 static void __exit riscom8_exit_module (void)
1748 rc_release_drivers();
1749 for (i = 0; i < RC_NBOARD; i++)
1750 if (rc_board[i].flags & RC_BOARD_PRESENT)
1751 rc_release_io_range(&rc_board[i]);
1755 module_init(riscom8_init_module);
1756 module_exit(riscom8_exit_module);