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>
51 #include <linux/device.h>
53 #include <linux/uaccess.h>
56 #include "riscom8_reg.h"
58 /* Am I paranoid or not ? ;-) */
59 #define RISCOM_PARANOIA_CHECK
62 * Crazy InteliCom/8 boards sometimes have swapped CTS & DSR signals.
63 * You can slightly speed up things by #undefing the following option,
64 * if you are REALLY sure that your board is correct one.
67 #define RISCOM_BRAIN_DAMAGED_CTS
70 * The following defines are mostly for testing purposes. But if you need
71 * some nice reporting in your syslog, you can define them also.
74 #undef RC_REPORT_OVERRUN
77 #define RISCOM_LEGAL_FLAGS \
78 (ASYNC_HUP_NOTIFY | ASYNC_SAK | ASYNC_SPLIT_TERMIOS | \
79 ASYNC_SPD_HI | ASYNC_SPEED_VHI | ASYNC_SESSION_LOCKOUT | \
80 ASYNC_PGRP_LOCKOUT | ASYNC_CALLOUT_NOHUP)
82 static struct tty_driver
*riscom_driver
;
84 static DEFINE_SPINLOCK(riscom_lock
);
86 static struct riscom_board rc_board
[RC_NBOARD
] = {
101 static struct riscom_port rc_port
[RC_NBOARD
* RC_NPORT
];
103 /* RISCom/8 I/O ports addresses (without address translation) */
104 static unsigned short rc_ioport
[] = {
106 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0c,
108 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0c, 0x10,
109 0x11, 0x12, 0x18, 0x28, 0x31, 0x32, 0x39, 0x3a, 0x40, 0x41, 0x61, 0x62,
110 0x63, 0x64, 0x6b, 0x70, 0x71, 0x78, 0x7a, 0x7b, 0x7f, 0x100, 0x101
113 #define RC_NIOPORT ARRAY_SIZE(rc_ioport)
116 static int rc_paranoia_check(struct riscom_port
const *port
,
117 char *name
, const char *routine
)
119 #ifdef RISCOM_PARANOIA_CHECK
120 static const char badmagic
[] = KERN_INFO
121 "rc: Warning: bad riscom port magic number for device %s in %s\n";
122 static const char badinfo
[] = KERN_INFO
123 "rc: Warning: null riscom port for device %s in %s\n";
126 printk(badinfo
, name
, routine
);
129 if (port
->magic
!= RISCOM8_MAGIC
) {
130 printk(badmagic
, name
, routine
);
139 * Service functions for RISCom/8 driver.
143 /* Get board number from pointer */
144 static inline int board_No(struct riscom_board
const *bp
)
146 return bp
- rc_board
;
149 /* Get port number from pointer */
150 static inline int port_No(struct riscom_port
const *port
)
152 return RC_PORT(port
- rc_port
);
155 /* Get pointer to board from pointer to port */
156 static inline struct riscom_board
*port_Board(struct riscom_port
const *port
)
158 return &rc_board
[RC_BOARD(port
- rc_port
)];
161 /* Input Byte from CL CD180 register */
162 static inline unsigned char rc_in(struct riscom_board
const *bp
,
165 return inb(bp
->base
+ RC_TO_ISA(reg
));
168 /* Output Byte to CL CD180 register */
169 static inline void rc_out(struct riscom_board
const *bp
, unsigned short reg
,
172 outb(val
, bp
->base
+ RC_TO_ISA(reg
));
175 /* Wait for Channel Command Register ready */
176 static void rc_wait_CCR(struct riscom_board
const *bp
)
180 /* FIXME: need something more descriptive then 100000 :) */
181 for (delay
= 100000; delay
; delay
--)
182 if (!rc_in(bp
, CD180_CCR
))
185 printk(KERN_INFO
"rc%d: Timeout waiting for CCR.\n", board_No(bp
));
189 * RISCom/8 probe functions.
192 static int rc_request_io_range(struct riscom_board
* const bp
)
196 for (i
= 0; i
< RC_NIOPORT
; i
++)
197 if (!request_region(RC_TO_ISA(rc_ioport
[i
]) + bp
->base
, 1,
203 printk(KERN_INFO
"rc%d: Skipping probe at 0x%03x. IO address in use.\n",
204 board_No(bp
), bp
->base
);
206 release_region(RC_TO_ISA(rc_ioport
[i
]) + bp
->base
, 1);
210 static void rc_release_io_range(struct riscom_board
* const bp
)
214 for (i
= 0; i
< RC_NIOPORT
; i
++)
215 release_region(RC_TO_ISA(rc_ioport
[i
]) + bp
->base
, 1);
218 /* Reset and setup CD180 chip */
219 static void __init
rc_init_CD180(struct riscom_board
const *bp
)
223 spin_lock_irqsave(&riscom_lock
, flags
);
225 rc_out(bp
, RC_CTOUT
, 0); /* Clear timeout */
226 rc_wait_CCR(bp
); /* Wait for CCR ready */
227 rc_out(bp
, CD180_CCR
, CCR_HARDRESET
); /* Reset CD180 chip */
228 spin_unlock_irqrestore(&riscom_lock
, flags
);
229 msleep(50); /* Delay 0.05 sec */
230 spin_lock_irqsave(&riscom_lock
, flags
);
231 rc_out(bp
, CD180_GIVR
, RC_ID
); /* Set ID for this chip */
232 rc_out(bp
, CD180_GICR
, 0); /* Clear all bits */
233 rc_out(bp
, CD180_PILR1
, RC_ACK_MINT
); /* Prio for modem intr */
234 rc_out(bp
, CD180_PILR2
, RC_ACK_TINT
); /* Prio for tx intr */
235 rc_out(bp
, CD180_PILR3
, RC_ACK_RINT
); /* Prio for rx intr */
237 /* Setting up prescaler. We need 4 ticks per 1 ms */
238 rc_out(bp
, CD180_PPRH
, (RC_OSCFREQ
/(1000000/RISCOM_TPS
)) >> 8);
239 rc_out(bp
, CD180_PPRL
, (RC_OSCFREQ
/(1000000/RISCOM_TPS
)) & 0xff);
241 spin_unlock_irqrestore(&riscom_lock
, flags
);
244 /* Main probing routine, also sets irq. */
245 static int __init
rc_probe(struct riscom_board
*bp
)
247 unsigned char val1
, val2
;
253 if (rc_request_io_range(bp
))
256 /* Are the I/O ports here ? */
257 rc_out(bp
, CD180_PPRL
, 0x5a);
259 val1
= rc_in(bp
, CD180_PPRL
);
260 rc_out(bp
, CD180_PPRL
, 0xa5);
262 val2
= rc_in(bp
, CD180_PPRL
);
264 if ((val1
!= 0x5a) || (val2
!= 0xa5)) {
265 printk(KERN_ERR
"rc%d: RISCom/8 Board at 0x%03x not found.\n",
266 board_No(bp
), bp
->base
);
270 /* It's time to find IRQ for this board */
271 for (retries
= 0; retries
< 5 && irqs
<= 0; retries
++) {
272 irqs
= probe_irq_on();
273 rc_init_CD180(bp
); /* Reset CD180 chip */
274 rc_out(bp
, CD180_CAR
, 2); /* Select port 2 */
276 rc_out(bp
, CD180_CCR
, CCR_TXEN
); /* Enable transmitter */
277 rc_out(bp
, CD180_IER
, IER_TXRDY
);/* Enable tx empty intr */
279 irqs
= probe_irq_off(irqs
);
280 val1
= rc_in(bp
, RC_BSR
); /* Get Board Status reg */
281 val2
= rc_in(bp
, RC_ACK_TINT
); /* ACK interrupt */
282 rc_init_CD180(bp
); /* Reset CD180 again */
284 if ((val1
& RC_BSR_TINT
) || (val2
!= (RC_ID
| GIVR_IT_TX
))) {
285 printk(KERN_ERR
"rc%d: RISCom/8 Board at 0x%03x not "
286 "found.\n", board_No(bp
), bp
->base
);
292 printk(KERN_ERR
"rc%d: Can't find IRQ for RISCom/8 board "
293 "at 0x%03x.\n", board_No(bp
), bp
->base
);
297 bp
->flags
|= RC_BOARD_PRESENT
;
299 printk(KERN_INFO
"rc%d: RISCom/8 Rev. %c board detected at "
302 (rc_in(bp
, CD180_GFRCR
) & 0x0f) + 'A', /* Board revision */
307 rc_release_io_range(bp
);
313 * Interrupt processing routines.
317 static struct riscom_port
*rc_get_port(struct riscom_board
const *bp
,
318 unsigned char const *what
)
320 unsigned char channel
;
321 struct riscom_port
*port
;
323 channel
= rc_in(bp
, CD180_GICR
) >> GICR_CHAN_OFF
;
324 if (channel
< CD180_NCH
) {
325 port
= &rc_port
[board_No(bp
) * RC_NPORT
+ channel
];
326 if (port
->port
.flags
& ASYNC_INITIALIZED
)
329 printk(KERN_ERR
"rc%d: %s interrupt from invalid port %d\n",
330 board_No(bp
), what
, channel
);
334 static void rc_receive_exc(struct riscom_board
const *bp
)
336 struct riscom_port
*port
;
337 struct tty_struct
*tty
;
338 unsigned char status
;
339 unsigned char ch
, flag
;
341 port
= rc_get_port(bp
, "Receive");
345 tty
= tty_port_tty_get(&port
->port
);
347 #ifdef RC_REPORT_OVERRUN
348 status
= rc_in(bp
, CD180_RCSR
);
349 if (status
& RCSR_OE
)
351 status
&= port
->mark_mask
;
353 status
= rc_in(bp
, CD180_RCSR
) & port
->mark_mask
;
355 ch
= rc_in(bp
, CD180_RDR
);
358 if (status
& RCSR_TOUT
) {
359 printk(KERN_WARNING
"rc%d: port %d: Receiver timeout. "
360 "Hardware problems ?\n",
361 board_No(bp
), port_No(port
));
364 } else if (status
& RCSR_BREAK
) {
365 printk(KERN_INFO
"rc%d: port %d: Handling break...\n",
366 board_No(bp
), port_No(port
));
368 if (tty
&& (port
->port
.flags
& ASYNC_SAK
))
371 } else if (status
& RCSR_PE
)
374 else if (status
& RCSR_FE
)
377 else if (status
& RCSR_OE
)
383 tty_insert_flip_char(tty
, ch
, flag
);
384 tty_flip_buffer_push(tty
);
390 static void rc_receive(struct riscom_board
const *bp
)
392 struct riscom_port
*port
;
393 struct tty_struct
*tty
;
396 port
= rc_get_port(bp
, "Receive");
400 tty
= tty_port_tty_get(&port
->port
);
402 count
= rc_in(bp
, CD180_RDCR
);
404 #ifdef RC_REPORT_FIFO
405 port
->hits
[count
> 8 ? 9 : count
]++;
409 u8 ch
= rc_in(bp
, CD180_RDR
);
411 tty_insert_flip_char(tty
, ch
, TTY_NORMAL
);
414 tty_flip_buffer_push(tty
);
419 static void rc_transmit(struct riscom_board
const *bp
)
421 struct riscom_port
*port
;
422 struct tty_struct
*tty
;
425 port
= rc_get_port(bp
, "Transmit");
429 tty
= tty_port_tty_get(&port
->port
);
431 if (port
->IER
& IER_TXEMPTY
) {
433 rc_out(bp
, CD180_CAR
, port_No(port
));
434 port
->IER
&= ~IER_TXEMPTY
;
435 rc_out(bp
, CD180_IER
, port
->IER
);
439 if ((port
->xmit_cnt
<= 0 && !port
->break_length
)
440 || (tty
&& (tty
->stopped
|| tty
->hw_stopped
))) {
441 rc_out(bp
, CD180_CAR
, port_No(port
));
442 port
->IER
&= ~IER_TXRDY
;
443 rc_out(bp
, CD180_IER
, port
->IER
);
447 if (port
->break_length
) {
448 if (port
->break_length
> 0) {
449 if (port
->COR2
& COR2_ETC
) {
450 rc_out(bp
, CD180_TDR
, CD180_C_ESC
);
451 rc_out(bp
, CD180_TDR
, CD180_C_SBRK
);
452 port
->COR2
&= ~COR2_ETC
;
454 count
= min_t(int, port
->break_length
, 0xff);
455 rc_out(bp
, CD180_TDR
, CD180_C_ESC
);
456 rc_out(bp
, CD180_TDR
, CD180_C_DELAY
);
457 rc_out(bp
, CD180_TDR
, count
);
458 port
->break_length
-= count
;
459 if (port
->break_length
== 0)
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
->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 (tty
&& port
->xmit_cnt
<= port
->wakeup_chars
)
491 static void rc_check_modem(struct riscom_board
const *bp
)
493 struct riscom_port
*port
;
494 struct tty_struct
*tty
;
497 port
= rc_get_port(bp
, "Modem");
501 tty
= tty_port_tty_get(&port
->port
);
503 mcr
= rc_in(bp
, CD180_MCR
);
504 if (mcr
& MCR_CDCHG
) {
505 if (rc_in(bp
, CD180_MSVR
) & MSVR_CD
)
506 wake_up_interruptible(&port
->port
.open_wait
);
511 #ifdef RISCOM_BRAIN_DAMAGED_CTS
512 if (mcr
& MCR_CTSCHG
) {
513 if (rc_in(bp
, CD180_MSVR
) & MSVR_CTS
) {
514 port
->IER
|= IER_TXRDY
;
517 if (port
->xmit_cnt
<= port
->wakeup_chars
)
523 port
->IER
&= ~IER_TXRDY
;
525 rc_out(bp
, CD180_IER
, port
->IER
);
527 if (mcr
& MCR_DSRCHG
) {
528 if (rc_in(bp
, CD180_MSVR
) & MSVR_DSR
) {
529 port
->IER
|= IER_TXRDY
;
532 if (port
->xmit_cnt
<= port
->wakeup_chars
)
538 port
->IER
&= ~IER_TXRDY
;
540 rc_out(bp
, CD180_IER
, port
->IER
);
542 #endif /* RISCOM_BRAIN_DAMAGED_CTS */
544 /* Clear change bits */
545 rc_out(bp
, CD180_MCR
, 0);
549 /* The main interrupt processing routine */
550 static irqreturn_t
rc_interrupt(int dummy
, void *dev_id
)
552 unsigned char status
;
554 struct riscom_board
*bp
= dev_id
;
555 unsigned long loop
= 0;
558 if (!(bp
->flags
& RC_BOARD_ACTIVE
))
561 while ((++loop
< 16) && ((status
= ~(rc_in(bp
, RC_BSR
))) &
562 (RC_BSR_TOUT
| RC_BSR_TINT
|
563 RC_BSR_MINT
| RC_BSR_RINT
))) {
565 if (status
& RC_BSR_TOUT
)
566 printk(KERN_WARNING
"rc%d: Got timeout. Hardware "
567 "error?\n", board_No(bp
));
568 else if (status
& RC_BSR_RINT
) {
569 ack
= rc_in(bp
, RC_ACK_RINT
);
570 if (ack
== (RC_ID
| GIVR_IT_RCV
))
572 else if (ack
== (RC_ID
| GIVR_IT_REXC
))
575 printk(KERN_WARNING
"rc%d: Bad receive ack "
578 } else if (status
& RC_BSR_TINT
) {
579 ack
= rc_in(bp
, RC_ACK_TINT
);
580 if (ack
== (RC_ID
| GIVR_IT_TX
))
583 printk(KERN_WARNING
"rc%d: Bad transmit ack "
586 } else /* if (status & RC_BSR_MINT) */ {
587 ack
= rc_in(bp
, RC_ACK_MINT
);
588 if (ack
== (RC_ID
| GIVR_IT_MODEM
))
591 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 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 bp
->flags
|= RC_BOARD_ACTIVE
;
627 /* Called with disabled interrupts */
628 static void rc_shutdown_board(struct riscom_board
*bp
)
630 if (!(bp
->flags
& RC_BOARD_ACTIVE
))
633 bp
->flags
&= ~RC_BOARD_ACTIVE
;
635 free_irq(bp
->irq
, NULL
);
638 rc_out(bp
, RC_DTR
, bp
->DTR
); /* Drop DTR on all ports */
643 * Setting up port characteristics.
644 * Must be called with disabled interrupts
646 static void rc_change_speed(struct tty_struct
*tty
, struct riscom_board
*bp
,
647 struct riscom_port
*port
)
651 unsigned char cor1
= 0, cor3
= 0;
652 unsigned char mcor1
= 0, mcor2
= 0;
656 port
->MSVR
= MSVR_RTS
;
658 baud
= tty_get_baud_rate(tty
);
660 /* Select port on the board */
661 rc_out(bp
, CD180_CAR
, port_No(port
));
664 /* Drop DTR & exit */
665 bp
->DTR
|= (1u << port_No(port
));
666 rc_out(bp
, RC_DTR
, bp
->DTR
);
670 bp
->DTR
&= ~(1u << port_No(port
));
671 rc_out(bp
, RC_DTR
, bp
->DTR
);
675 * Now we must calculate some speed depended things
678 /* Set baud rate for port */
679 tmp
= (((RC_OSCFREQ
+ baud
/2) / baud
+
680 CD180_TPC
/2) / CD180_TPC
);
682 rc_out(bp
, CD180_RBPRH
, (tmp
>> 8) & 0xff);
683 rc_out(bp
, CD180_TBPRH
, (tmp
>> 8) & 0xff);
684 rc_out(bp
, CD180_RBPRL
, tmp
& 0xff);
685 rc_out(bp
, CD180_TBPRL
, tmp
& 0xff);
687 baud
= (baud
+ 5) / 10; /* Estimated CPS */
689 /* Two timer ticks seems enough to wakeup something like SLIP driver */
690 tmp
= ((baud
+ HZ
/2) / HZ
) * 2 - CD180_NFIFO
;
691 port
->wakeup_chars
= (tmp
< 0) ? 0 : ((tmp
>= SERIAL_XMIT_SIZE
) ?
692 SERIAL_XMIT_SIZE
- 1 : tmp
);
694 /* Receiver timeout will be transmission time for 1.5 chars */
695 tmp
= (RISCOM_TPS
+ RISCOM_TPS
/2 + baud
/2) / baud
;
696 tmp
= (tmp
> 0xff) ? 0xff : tmp
;
697 rc_out(bp
, CD180_RTPR
, tmp
);
699 switch (C_CSIZE(tty
)) {
718 cor1
|= COR1_NORMPAR
;
722 cor1
&= ~COR1_IGNORE
;
724 /* Set marking of some errors */
725 port
->mark_mask
= RCSR_OE
| RCSR_TOUT
;
727 port
->mark_mask
|= RCSR_FE
| RCSR_PE
;
728 if (I_BRKINT(tty
) || I_PARMRK(tty
))
729 port
->mark_mask
|= RCSR_BREAK
;
731 port
->mark_mask
&= ~(RCSR_FE
| RCSR_PE
);
733 port
->mark_mask
&= ~RCSR_BREAK
;
735 /* Real raw mode. Ignore all */
736 port
->mark_mask
&= ~RCSR_OE
;
738 /* Enable Hardware Flow Control */
739 if (C_CRTSCTS(tty
)) {
740 #ifdef RISCOM_BRAIN_DAMAGED_CTS
741 port
->IER
|= IER_DSR
| IER_CTS
;
742 mcor1
|= MCOR1_DSRZD
| MCOR1_CTSZD
;
743 mcor2
|= MCOR2_DSROD
| MCOR2_CTSOD
;
744 tty
->hw_stopped
= !(rc_in(bp
, CD180_MSVR
) &
745 (MSVR_CTS
|MSVR_DSR
));
747 port
->COR2
|= COR2_CTSAE
;
750 /* Enable Software Flow Control. FIXME: I'm not sure about this */
751 /* Some people reported that it works, but I still doubt */
753 port
->COR2
|= COR2_TXIBE
;
754 cor3
|= (COR3_FCT
| COR3_SCDE
);
756 port
->COR2
|= COR2_IXM
;
757 rc_out(bp
, CD180_SCHR1
, START_CHAR(tty
));
758 rc_out(bp
, CD180_SCHR2
, STOP_CHAR(tty
));
759 rc_out(bp
, CD180_SCHR3
, START_CHAR(tty
));
760 rc_out(bp
, CD180_SCHR4
, STOP_CHAR(tty
));
762 if (!C_CLOCAL(tty
)) {
763 /* Enable CD check */
770 /* Enable receiver */
771 port
->IER
|= IER_RXD
;
773 /* Set input FIFO size (1-8 bytes) */
774 cor3
|= RISCOM_RXFIFO
;
775 /* Setting up CD180 channel registers */
776 rc_out(bp
, CD180_COR1
, cor1
);
777 rc_out(bp
, CD180_COR2
, port
->COR2
);
778 rc_out(bp
, CD180_COR3
, cor3
);
779 /* Make CD180 know about registers change */
781 rc_out(bp
, CD180_CCR
, CCR_CORCHG1
| CCR_CORCHG2
| CCR_CORCHG3
);
782 /* Setting up modem option registers */
783 rc_out(bp
, CD180_MCOR1
, mcor1
);
784 rc_out(bp
, CD180_MCOR2
, mcor2
);
785 /* Enable CD180 transmitter & receiver */
787 rc_out(bp
, CD180_CCR
, CCR_TXEN
| CCR_RXEN
);
788 /* Enable interrupts */
789 rc_out(bp
, CD180_IER
, port
->IER
);
790 /* And finally set RTS on */
791 rc_out(bp
, CD180_MSVR
, port
->MSVR
);
794 /* Must be called with interrupts enabled */
795 static int rc_activate_port(struct tty_port
*port
, struct tty_struct
*tty
)
797 struct riscom_port
*rp
= container_of(port
, struct riscom_port
, port
);
798 struct riscom_board
*bp
= port_Board(rp
);
801 if (tty_port_alloc_xmit_buf(port
) < 0)
804 spin_lock_irqsave(&riscom_lock
, flags
);
806 clear_bit(TTY_IO_ERROR
, &tty
->flags
);
808 rp
->xmit_cnt
= rp
->xmit_head
= rp
->xmit_tail
= 0;
809 rc_change_speed(tty
, bp
, rp
);
810 spin_unlock_irqrestore(&riscom_lock
, flags
);
814 /* Must be called with interrupts disabled */
815 static void rc_shutdown_port(struct tty_struct
*tty
,
816 struct riscom_board
*bp
, struct riscom_port
*port
)
818 #ifdef RC_REPORT_OVERRUN
819 printk(KERN_INFO
"rc%d: port %d: Total %ld overruns were detected.\n",
820 board_No(bp
), port_No(port
), port
->overrun
);
822 #ifdef RC_REPORT_FIFO
826 printk(KERN_INFO
"rc%d: port %d: FIFO hits [ ",
827 board_No(bp
), port_No(port
));
828 for (i
= 0; i
< 10; i
++)
829 printk("%ld ", port
->hits
[i
]);
833 tty_port_free_xmit_buf(&port
->port
);
836 rc_out(bp
, CD180_CAR
, port_No(port
));
839 rc_out(bp
, CD180_CCR
, CCR_SOFTRESET
);
840 /* Disable all interrupts from this port */
842 rc_out(bp
, CD180_IER
, port
->IER
);
844 set_bit(TTY_IO_ERROR
, &tty
->flags
);
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 void dtr_rts(struct tty_port
*port
, int onoff
)
879 struct riscom_port
*p
= container_of(port
, struct riscom_port
, port
);
880 struct riscom_board
*bp
= port_Board(p
);
883 spin_lock_irqsave(&riscom_lock
, flags
);
884 bp
->DTR
&= ~(1u << port_No(p
));
886 bp
->DTR
|= (1u << port_No(p
));
887 rc_out(bp
, RC_DTR
, bp
->DTR
);
888 spin_unlock_irqrestore(&riscom_lock
, flags
);
891 static int rc_open(struct tty_struct
*tty
, struct file
*filp
)
895 struct riscom_port
*port
;
896 struct riscom_board
*bp
;
898 board
= RC_BOARD(tty
->index
);
899 if (board
>= RC_NBOARD
|| !(rc_board
[board
].flags
& RC_BOARD_PRESENT
))
902 bp
= &rc_board
[board
];
903 port
= rc_port
+ board
* RC_NPORT
+ RC_PORT(tty
->index
);
904 if (rc_paranoia_check(port
, tty
->name
, "rc_open"))
907 error
= rc_setup_board(bp
);
911 tty
->driver_data
= port
;
912 return tty_port_open(&port
->port
, tty
, filp
);
915 static void rc_flush_buffer(struct tty_struct
*tty
)
917 struct riscom_port
*port
= tty
->driver_data
;
920 if (rc_paranoia_check(port
, tty
->name
, "rc_flush_buffer"))
923 spin_lock_irqsave(&riscom_lock
, flags
);
924 port
->xmit_cnt
= port
->xmit_head
= port
->xmit_tail
= 0;
925 spin_unlock_irqrestore(&riscom_lock
, flags
);
930 static void rc_close_port(struct tty_port
*port
)
933 struct riscom_port
*rp
= container_of(port
, struct riscom_port
, port
);
934 struct riscom_board
*bp
= port_Board(rp
);
935 unsigned long timeout
;
938 * At this point we stop accepting input. To do this, we
939 * disable the receive line status interrupts, and tell the
940 * interrupt driver to stop checking the data ready bit in the
941 * line status register.
944 spin_lock_irqsave(&riscom_lock
, flags
);
947 rp
->IER
&= ~IER_TXRDY
;
948 rp
->IER
|= IER_TXEMPTY
;
949 rc_out(bp
, CD180_CAR
, port_No(rp
));
950 rc_out(bp
, CD180_IER
, rp
->IER
);
952 * Before we drop DTR, make sure the UART transmitter
953 * has completely drained; this is especially
954 * important if there is a transmit FIFO!
956 timeout
= jiffies
+ HZ
;
957 while (rp
->IER
& IER_TXEMPTY
) {
958 spin_unlock_irqrestore(&riscom_lock
, flags
);
959 msleep_interruptible(jiffies_to_msecs(rp
->timeout
));
960 spin_lock_irqsave(&riscom_lock
, flags
);
961 if (time_after(jiffies
, timeout
))
964 rc_shutdown_port(port
->tty
, bp
, rp
);
965 spin_unlock_irqrestore(&riscom_lock
, flags
);
968 static void rc_close(struct tty_struct
*tty
, struct file
*filp
)
970 struct riscom_port
*port
= tty
->driver_data
;
972 if (!port
|| rc_paranoia_check(port
, tty
->name
, "close"))
974 tty_port_close(&port
->port
, tty
, filp
);
977 static int rc_write(struct tty_struct
*tty
,
978 const unsigned char *buf
, int count
)
980 struct riscom_port
*port
= tty
->driver_data
;
981 struct riscom_board
*bp
;
985 if (rc_paranoia_check(port
, tty
->name
, "rc_write"))
988 bp
= port_Board(port
);
991 spin_lock_irqsave(&riscom_lock
, flags
);
993 c
= min_t(int, count
, min(SERIAL_XMIT_SIZE
- port
->xmit_cnt
- 1,
994 SERIAL_XMIT_SIZE
- port
->xmit_head
));
996 break; /* lock continues to be held */
998 memcpy(port
->port
.xmit_buf
+ port
->xmit_head
, buf
, c
);
999 port
->xmit_head
= (port
->xmit_head
+ c
) & (SERIAL_XMIT_SIZE
-1);
1000 port
->xmit_cnt
+= c
;
1002 spin_unlock_irqrestore(&riscom_lock
, flags
);
1009 if (port
->xmit_cnt
&& !tty
->stopped
&& !tty
->hw_stopped
&&
1010 !(port
->IER
& IER_TXRDY
)) {
1011 port
->IER
|= IER_TXRDY
;
1012 rc_out(bp
, CD180_CAR
, port_No(port
));
1013 rc_out(bp
, CD180_IER
, port
->IER
);
1016 spin_unlock_irqrestore(&riscom_lock
, flags
);
1021 static int rc_put_char(struct tty_struct
*tty
, unsigned char ch
)
1023 struct riscom_port
*port
= tty
->driver_data
;
1024 unsigned long flags
;
1027 if (rc_paranoia_check(port
, tty
->name
, "rc_put_char"))
1030 spin_lock_irqsave(&riscom_lock
, flags
);
1032 if (port
->xmit_cnt
>= SERIAL_XMIT_SIZE
- 1)
1035 port
->port
.xmit_buf
[port
->xmit_head
++] = ch
;
1036 port
->xmit_head
&= SERIAL_XMIT_SIZE
- 1;
1041 spin_unlock_irqrestore(&riscom_lock
, flags
);
1045 static void rc_flush_chars(struct tty_struct
*tty
)
1047 struct riscom_port
*port
= tty
->driver_data
;
1048 unsigned long flags
;
1050 if (rc_paranoia_check(port
, tty
->name
, "rc_flush_chars"))
1053 if (port
->xmit_cnt
<= 0 || tty
->stopped
|| tty
->hw_stopped
)
1056 spin_lock_irqsave(&riscom_lock
, flags
);
1058 port
->IER
|= IER_TXRDY
;
1059 rc_out(port_Board(port
), CD180_CAR
, port_No(port
));
1060 rc_out(port_Board(port
), CD180_IER
, port
->IER
);
1062 spin_unlock_irqrestore(&riscom_lock
, flags
);
1065 static int rc_write_room(struct tty_struct
*tty
)
1067 struct riscom_port
*port
= tty
->driver_data
;
1070 if (rc_paranoia_check(port
, tty
->name
, "rc_write_room"))
1073 ret
= SERIAL_XMIT_SIZE
- port
->xmit_cnt
- 1;
1079 static int rc_chars_in_buffer(struct tty_struct
*tty
)
1081 struct riscom_port
*port
= tty
->driver_data
;
1083 if (rc_paranoia_check(port
, tty
->name
, "rc_chars_in_buffer"))
1086 return port
->xmit_cnt
;
1089 static int rc_tiocmget(struct tty_struct
*tty
, struct file
*file
)
1091 struct riscom_port
*port
= tty
->driver_data
;
1092 struct riscom_board
*bp
;
1093 unsigned char status
;
1094 unsigned int result
;
1095 unsigned long flags
;
1097 if (rc_paranoia_check(port
, tty
->name
, __func__
))
1100 bp
= port_Board(port
);
1102 spin_lock_irqsave(&riscom_lock
, flags
);
1104 rc_out(bp
, CD180_CAR
, port_No(port
));
1105 status
= rc_in(bp
, CD180_MSVR
);
1106 result
= rc_in(bp
, RC_RI
) & (1u << port_No(port
)) ? 0 : TIOCM_RNG
;
1108 spin_unlock_irqrestore(&riscom_lock
, flags
);
1110 result
|= ((status
& MSVR_RTS
) ? TIOCM_RTS
: 0)
1111 | ((status
& MSVR_DTR
) ? TIOCM_DTR
: 0)
1112 | ((status
& MSVR_CD
) ? TIOCM_CAR
: 0)
1113 | ((status
& MSVR_DSR
) ? TIOCM_DSR
: 0)
1114 | ((status
& MSVR_CTS
) ? TIOCM_CTS
: 0);
1118 static int rc_tiocmset(struct tty_struct
*tty
, struct file
*file
,
1119 unsigned int set
, unsigned int clear
)
1121 struct riscom_port
*port
= tty
->driver_data
;
1122 unsigned long flags
;
1123 struct riscom_board
*bp
;
1125 if (rc_paranoia_check(port
, tty
->name
, __func__
))
1128 bp
= port_Board(port
);
1130 spin_lock_irqsave(&riscom_lock
, flags
);
1132 if (set
& TIOCM_RTS
)
1133 port
->MSVR
|= MSVR_RTS
;
1134 if (set
& TIOCM_DTR
)
1135 bp
->DTR
&= ~(1u << port_No(port
));
1137 if (clear
& TIOCM_RTS
)
1138 port
->MSVR
&= ~MSVR_RTS
;
1139 if (clear
& TIOCM_DTR
)
1140 bp
->DTR
|= (1u << port_No(port
));
1142 rc_out(bp
, CD180_CAR
, port_No(port
));
1143 rc_out(bp
, CD180_MSVR
, port
->MSVR
);
1144 rc_out(bp
, RC_DTR
, bp
->DTR
);
1146 spin_unlock_irqrestore(&riscom_lock
, flags
);
1151 static int rc_send_break(struct tty_struct
*tty
, int length
)
1153 struct riscom_port
*port
= tty
->driver_data
;
1154 struct riscom_board
*bp
= port_Board(port
);
1155 unsigned long flags
;
1157 if (length
== 0 || length
== -1)
1160 spin_lock_irqsave(&riscom_lock
, flags
);
1162 port
->break_length
= RISCOM_TPS
/ HZ
* length
;
1163 port
->COR2
|= COR2_ETC
;
1164 port
->IER
|= IER_TXRDY
;
1165 rc_out(bp
, CD180_CAR
, port_No(port
));
1166 rc_out(bp
, CD180_COR2
, port
->COR2
);
1167 rc_out(bp
, CD180_IER
, port
->IER
);
1169 rc_out(bp
, CD180_CCR
, CCR_CORCHG2
);
1172 spin_unlock_irqrestore(&riscom_lock
, flags
);
1176 static int rc_set_serial_info(struct tty_struct
*tty
, struct riscom_port
*port
,
1177 struct serial_struct __user
*newinfo
)
1179 struct serial_struct tmp
;
1180 struct riscom_board
*bp
= port_Board(port
);
1183 if (copy_from_user(&tmp
, newinfo
, sizeof(tmp
)))
1186 mutex_lock(&port
->port
.mutex
);
1187 change_speed
= ((port
->port
.flags
& ASYNC_SPD_MASK
) !=
1188 (tmp
.flags
& ASYNC_SPD_MASK
));
1190 if (!capable(CAP_SYS_ADMIN
)) {
1191 if ((tmp
.close_delay
!= port
->port
.close_delay
) ||
1192 (tmp
.closing_wait
!= port
->port
.closing_wait
) ||
1193 ((tmp
.flags
& ~ASYNC_USR_MASK
) !=
1194 (port
->port
.flags
& ~ASYNC_USR_MASK
))) {
1195 mutex_unlock(&port
->port
.mutex
);
1198 port
->port
.flags
= ((port
->port
.flags
& ~ASYNC_USR_MASK
) |
1199 (tmp
.flags
& ASYNC_USR_MASK
));
1201 port
->port
.flags
= ((port
->port
.flags
& ~ASYNC_FLAGS
) |
1202 (tmp
.flags
& ASYNC_FLAGS
));
1203 port
->port
.close_delay
= tmp
.close_delay
;
1204 port
->port
.closing_wait
= tmp
.closing_wait
;
1207 unsigned long flags
;
1209 spin_lock_irqsave(&riscom_lock
, flags
);
1210 rc_change_speed(tty
, bp
, port
);
1211 spin_unlock_irqrestore(&riscom_lock
, flags
);
1213 mutex_unlock(&port
->port
.mutex
);
1217 static int rc_get_serial_info(struct riscom_port
*port
,
1218 struct serial_struct __user
*retinfo
)
1220 struct serial_struct tmp
;
1221 struct riscom_board
*bp
= port_Board(port
);
1223 memset(&tmp
, 0, sizeof(tmp
));
1224 tmp
.type
= PORT_CIRRUS
;
1225 tmp
.line
= port
- rc_port
;
1227 mutex_lock(&port
->port
.mutex
);
1228 tmp
.port
= bp
->base
;
1230 tmp
.flags
= port
->port
.flags
;
1231 tmp
.baud_base
= (RC_OSCFREQ
+ CD180_TPC
/2) / CD180_TPC
;
1232 tmp
.close_delay
= port
->port
.close_delay
* HZ
/100;
1233 tmp
.closing_wait
= port
->port
.closing_wait
* HZ
/100;
1234 mutex_unlock(&port
->port
.mutex
);
1235 tmp
.xmit_fifo_size
= CD180_NFIFO
;
1236 return copy_to_user(retinfo
, &tmp
, sizeof(tmp
)) ? -EFAULT
: 0;
1239 static int rc_ioctl(struct tty_struct
*tty
, struct file
*filp
,
1240 unsigned int cmd
, unsigned long arg
)
1242 struct riscom_port
*port
= tty
->driver_data
;
1243 void __user
*argp
= (void __user
*)arg
;
1246 if (rc_paranoia_check(port
, tty
->name
, "rc_ioctl"))
1251 retval
= rc_get_serial_info(port
, argp
);
1254 retval
= rc_set_serial_info(tty
, port
, argp
);
1257 retval
= -ENOIOCTLCMD
;
1262 static void rc_throttle(struct tty_struct
*tty
)
1264 struct riscom_port
*port
= tty
->driver_data
;
1265 struct riscom_board
*bp
;
1266 unsigned long flags
;
1268 if (rc_paranoia_check(port
, tty
->name
, "rc_throttle"))
1270 bp
= port_Board(port
);
1272 spin_lock_irqsave(&riscom_lock
, flags
);
1273 port
->MSVR
&= ~MSVR_RTS
;
1274 rc_out(bp
, CD180_CAR
, port_No(port
));
1277 rc_out(bp
, CD180_CCR
, CCR_SSCH2
);
1280 rc_out(bp
, CD180_MSVR
, port
->MSVR
);
1281 spin_unlock_irqrestore(&riscom_lock
, flags
);
1284 static void rc_unthrottle(struct tty_struct
*tty
)
1286 struct riscom_port
*port
= tty
->driver_data
;
1287 struct riscom_board
*bp
;
1288 unsigned long flags
;
1290 if (rc_paranoia_check(port
, tty
->name
, "rc_unthrottle"))
1292 bp
= port_Board(port
);
1294 spin_lock_irqsave(&riscom_lock
, flags
);
1295 port
->MSVR
|= MSVR_RTS
;
1296 rc_out(bp
, CD180_CAR
, port_No(port
));
1299 rc_out(bp
, CD180_CCR
, CCR_SSCH1
);
1302 rc_out(bp
, CD180_MSVR
, port
->MSVR
);
1303 spin_unlock_irqrestore(&riscom_lock
, flags
);
1306 static void rc_stop(struct tty_struct
*tty
)
1308 struct riscom_port
*port
= tty
->driver_data
;
1309 struct riscom_board
*bp
;
1310 unsigned long flags
;
1312 if (rc_paranoia_check(port
, tty
->name
, "rc_stop"))
1315 bp
= port_Board(port
);
1317 spin_lock_irqsave(&riscom_lock
, flags
);
1318 port
->IER
&= ~IER_TXRDY
;
1319 rc_out(bp
, CD180_CAR
, port_No(port
));
1320 rc_out(bp
, CD180_IER
, port
->IER
);
1321 spin_unlock_irqrestore(&riscom_lock
, flags
);
1324 static void rc_start(struct tty_struct
*tty
)
1326 struct riscom_port
*port
= tty
->driver_data
;
1327 struct riscom_board
*bp
;
1328 unsigned long flags
;
1330 if (rc_paranoia_check(port
, tty
->name
, "rc_start"))
1333 bp
= port_Board(port
);
1335 spin_lock_irqsave(&riscom_lock
, flags
);
1337 if (port
->xmit_cnt
&& port
->port
.xmit_buf
&& !(port
->IER
& IER_TXRDY
)) {
1338 port
->IER
|= IER_TXRDY
;
1339 rc_out(bp
, CD180_CAR
, port_No(port
));
1340 rc_out(bp
, CD180_IER
, port
->IER
);
1342 spin_unlock_irqrestore(&riscom_lock
, flags
);
1345 static void rc_hangup(struct tty_struct
*tty
)
1347 struct riscom_port
*port
= tty
->driver_data
;
1349 if (rc_paranoia_check(port
, tty
->name
, "rc_hangup"))
1352 tty_port_hangup(&port
->port
);
1355 static void rc_set_termios(struct tty_struct
*tty
,
1356 struct ktermios
*old_termios
)
1358 struct riscom_port
*port
= tty
->driver_data
;
1359 unsigned long flags
;
1361 if (rc_paranoia_check(port
, tty
->name
, "rc_set_termios"))
1364 spin_lock_irqsave(&riscom_lock
, flags
);
1365 rc_change_speed(tty
, port_Board(port
), port
);
1366 spin_unlock_irqrestore(&riscom_lock
, flags
);
1368 if ((old_termios
->c_cflag
& CRTSCTS
) &&
1369 !(tty
->termios
->c_cflag
& CRTSCTS
)) {
1370 tty
->hw_stopped
= 0;
1375 static const struct tty_operations riscom_ops
= {
1379 .put_char
= rc_put_char
,
1380 .flush_chars
= rc_flush_chars
,
1381 .write_room
= rc_write_room
,
1382 .chars_in_buffer
= rc_chars_in_buffer
,
1383 .flush_buffer
= rc_flush_buffer
,
1385 .throttle
= rc_throttle
,
1386 .unthrottle
= rc_unthrottle
,
1387 .set_termios
= rc_set_termios
,
1390 .hangup
= rc_hangup
,
1391 .tiocmget
= rc_tiocmget
,
1392 .tiocmset
= rc_tiocmset
,
1393 .break_ctl
= rc_send_break
,
1396 static const struct tty_port_operations riscom_port_ops
= {
1397 .carrier_raised
= carrier_raised
,
1399 .shutdown
= rc_close_port
,
1400 .activate
= rc_activate_port
,
1404 static int __init
rc_init_drivers(void)
1409 riscom_driver
= alloc_tty_driver(RC_NBOARD
* RC_NPORT
);
1413 riscom_driver
->owner
= THIS_MODULE
;
1414 riscom_driver
->name
= "ttyL";
1415 riscom_driver
->major
= RISCOM8_NORMAL_MAJOR
;
1416 riscom_driver
->type
= TTY_DRIVER_TYPE_SERIAL
;
1417 riscom_driver
->subtype
= SERIAL_TYPE_NORMAL
;
1418 riscom_driver
->init_termios
= tty_std_termios
;
1419 riscom_driver
->init_termios
.c_cflag
=
1420 B9600
| CS8
| CREAD
| HUPCL
| CLOCAL
;
1421 riscom_driver
->init_termios
.c_ispeed
= 9600;
1422 riscom_driver
->init_termios
.c_ospeed
= 9600;
1423 riscom_driver
->flags
= TTY_DRIVER_REAL_RAW
| TTY_DRIVER_HARDWARE_BREAK
;
1424 tty_set_operations(riscom_driver
, &riscom_ops
);
1425 error
= tty_register_driver(riscom_driver
);
1427 put_tty_driver(riscom_driver
);
1428 printk(KERN_ERR
"rc: Couldn't register RISCom/8 driver, "
1429 "error = %d\n", error
);
1432 memset(rc_port
, 0, sizeof(rc_port
));
1433 for (i
= 0; i
< RC_NPORT
* RC_NBOARD
; i
++) {
1434 tty_port_init(&rc_port
[i
].port
);
1435 rc_port
[i
].port
.ops
= &riscom_port_ops
;
1436 rc_port
[i
].magic
= RISCOM8_MAGIC
;
1441 static void rc_release_drivers(void)
1443 tty_unregister_driver(riscom_driver
);
1444 put_tty_driver(riscom_driver
);
1449 * Called at boot time.
1451 * You can specify IO base for up to RC_NBOARD cards,
1452 * using line "riscom8=0xiobase1,0xiobase2,.." at LILO prompt.
1453 * Note that there will be no probing at default
1454 * addresses in this case.
1457 static int __init
riscom8_setup(char *str
)
1459 int ints
[RC_NBOARD
];
1462 str
= get_options(str
, ARRAY_SIZE(ints
), ints
);
1464 for (i
= 0; i
< RC_NBOARD
; i
++) {
1466 rc_board
[i
].base
= ints
[i
+1];
1468 rc_board
[i
].base
= 0;
1473 __setup("riscom8=", riscom8_setup
);
1476 static char banner
[] __initdata
=
1477 KERN_INFO
"rc: SDL RISCom/8 card driver v1.1, (c) D.Gorodchanin "
1479 static char no_boards_msg
[] __initdata
=
1480 KERN_INFO
"rc: No RISCom/8 boards detected.\n";
1483 * This routine must be called by kernel at boot time
1485 static int __init
riscom8_init(void)
1492 if (rc_init_drivers())
1495 for (i
= 0; i
< RC_NBOARD
; i
++)
1496 if (rc_board
[i
].base
&& !rc_probe(&rc_board
[i
]))
1499 rc_release_drivers();
1500 printk(no_boards_msg
);
1511 module_param(iobase
, int, 0);
1512 module_param(iobase1
, int, 0);
1513 module_param(iobase2
, int, 0);
1514 module_param(iobase3
, int, 0);
1516 MODULE_LICENSE("GPL");
1517 MODULE_ALIAS_CHARDEV_MAJOR(RISCOM8_NORMAL_MAJOR
);
1521 * You can setup up to 4 boards (current value of RC_NBOARD)
1522 * by specifying "iobase=0xXXX iobase1=0xXXX ..." as insmod parameter.
1525 static int __init
riscom8_init_module(void)
1530 if (iobase
|| iobase1
|| iobase2
|| iobase3
) {
1531 for (i
= 0; i
< RC_NBOARD
; i
++)
1532 rc_board
[i
].base
= 0;
1536 rc_board
[0].base
= iobase
;
1538 rc_board
[1].base
= iobase1
;
1540 rc_board
[2].base
= iobase2
;
1542 rc_board
[3].base
= iobase3
;
1545 return riscom8_init();
1548 static void __exit
riscom8_exit_module(void)
1552 rc_release_drivers();
1553 for (i
= 0; i
< RC_NBOARD
; i
++)
1554 if (rc_board
[i
].flags
& RC_BOARD_PRESENT
)
1555 rc_release_io_range(&rc_board
[i
]);
1559 module_init(riscom8_init_module
);
1560 module_exit(riscom8_exit_module
);