2 * linux/drivers/char/serial167.c
4 * Driver for MVME166/7 board serial ports, which are via a CD2401.
5 * Based very much on cyclades.c.
7 * MVME166/7 work by Richard Hirst [richard@sleepie.demon.co.uk]
9 * ==============================================================
11 * static char rcsid[] =
12 * "$Revision: 1.36.1.4 $$Date: 1995/03/29 06:14:14 $";
14 * linux/kernel/cyclades.c
16 * Maintained by Marcio Saito (cyclades@netcom.com) and
17 * Randolph Bentson (bentson@grieg.seaslug.org)
19 * Much of the design and some of the code came from serial.c
20 * which was copyright (C) 1991, 1992 Linus Torvalds. It was
21 * extensively rewritten by Theodore Ts'o, 8/16/92 -- 9/14/92,
22 * and then fixed as suggested by Michael K. Johnson 12/12/92.
24 * This version does not support shared irq's.
26 * $Log: cyclades.c,v $
27 * Revision 1.36.1.4 1995/03/29 06:14:14 bentson
28 * disambiguate between Cyclom-16Y and Cyclom-32Ye;
32 * 200 lines of changes record removed - RGH 11-10-95, starting work on
33 * converting this to drive serial ports on mvme166 (cd2401).
35 * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 2000/08/25
36 * - get rid of verify_area
37 * - use get_user to access memory from userspace in set_threshold,
38 * set_default_threshold and set_timeout
39 * - don't use the panic function in serial167_init
40 * - do resource release on failure on serial167_init
41 * - include missing restore_flags in mvme167_serial_console_setup
43 * Kars de Jong <jongk@linux-m68k.org> - 2004/09/06
44 * - replace bottom half handler with task queue handler
47 #include <linux/errno.h>
48 #include <linux/signal.h>
49 #include <linux/sched.h>
50 #include <linux/timer.h>
51 #include <linux/tty.h>
52 #include <linux/interrupt.h>
53 #include <linux/serial.h>
54 #include <linux/serialP.h>
55 #include <linux/smp_lock.h>
56 #include <linux/string.h>
57 #include <linux/fcntl.h>
58 #include <linux/ptrace.h>
59 #include <linux/serial167.h>
60 #include <linux/delay.h>
61 #include <linux/major.h>
63 #include <linux/console.h>
64 #include <linux/module.h>
65 #include <linux/bitops.h>
66 #include <linux/tty_flip.h>
67 #include <linux/gfp.h>
69 #include <asm/system.h>
71 #include <asm/mvme16xhw.h>
72 #include <asm/bootinfo.h>
73 #include <asm/setup.h>
75 #include <linux/types.h>
76 #include <linux/kernel.h>
78 #include <asm/uaccess.h>
79 #include <linux/init.h>
81 #define SERIAL_PARANOIA_CHECK
82 #undef SERIAL_DEBUG_OPEN
83 #undef SERIAL_DEBUG_THROTTLE
84 #undef SERIAL_DEBUG_OTHER
85 #undef SERIAL_DEBUG_IO
86 #undef SERIAL_DEBUG_COUNT
87 #undef SERIAL_DEBUG_DTR
88 #undef CYCLOM_16Y_HACK
89 #define CYCLOM_ENABLE_MONITORING
91 #define WAKEUP_CHARS 256
93 #define STD_COM_FLAGS (0)
95 static struct tty_driver
*cy_serial_driver
;
96 extern int serial_console
;
97 static struct cyclades_port
*serial_console_info
= NULL
;
98 static unsigned int serial_console_cflag
= 0;
99 u_char initial_console_speed
;
101 /* Base address of cd2401 chip on mvme166/7 */
103 #define BASE_ADDR (0xfff45000)
104 #define pcc2chip ((volatile u_char *)0xfff42000)
105 #define PccSCCMICR 0x1d
106 #define PccSCCTICR 0x1e
107 #define PccSCCRICR 0x1f
108 #define PccTPIACKR 0x25
109 #define PccRPIACKR 0x27
112 /* This is the per-port data structure */
113 struct cyclades_port cy_port
[] = {
121 #define NR_PORTS ARRAY_SIZE(cy_port)
124 * This is used to look up the divisor speeds and the timeouts
125 * We're normally limited to 15 distinct baud rates. The extra
126 * are accessed via settings in info->flags.
127 * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
128 * 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
131 static int baud_table
[] = {
132 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
133 1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200, 150000,
138 static char baud_co
[] = { /* 25 MHz clock option table */
139 /* value => 00 01 02 03 04 */
140 /* divide by 8 32 128 512 2048 */
141 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02,
142 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
145 static char baud_bpr
[] = { /* 25 MHz baud rate period table */
146 0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3,
147 0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15
151 /* I think 166 brd clocks 2401 at 20MHz.... */
153 /* These values are written directly to tcor, and >> 5 for writing to rcor */
154 static u_char baud_co
[] = { /* 20 MHz clock option table */
155 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x60, 0x60, 0x40,
156 0x40, 0x40, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
159 /* These values written directly to tbpr/rbpr */
160 static u_char baud_bpr
[] = { /* 20 MHz baud rate period table */
161 0x00, 0xc0, 0x80, 0x58, 0x6c, 0x40, 0xc0, 0x81, 0x40, 0x81,
162 0x57, 0x40, 0x81, 0x40, 0x81, 0x40, 0x2b, 0x20, 0x15, 0x10
165 static u_char baud_cor4
[] = { /* receive threshold */
166 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
167 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07
170 static void shutdown(struct cyclades_port
*);
171 static int startup(struct cyclades_port
*);
172 static void cy_throttle(struct tty_struct
*);
173 static void cy_unthrottle(struct tty_struct
*);
174 static void config_setup(struct cyclades_port
*);
175 #ifdef CYCLOM_SHOW_STATUS
176 static void show_status(int);
180 * I have my own version of udelay(), as it is needed when initialising
181 * the chip, before the delay loop has been calibrated. Should probably
182 * reference one of the vmechip2 or pccchip2 counter for an accurate
183 * delay, but this wild guess will do for now.
186 void my_udelay(long us
)
189 volatile u_char
*p
= &x
;
193 for (i
= 100; i
; i
--)
197 static inline int serial_paranoia_check(struct cyclades_port
*info
, char *name
,
200 #ifdef SERIAL_PARANOIA_CHECK
202 printk("Warning: null cyclades_port for (%s) in %s\n", name
,
207 if (info
< &cy_port
[0] || info
>= &cy_port
[NR_PORTS
]) {
208 printk("Warning: cyclades_port out of range for (%s) in %s\n",
213 if (info
->magic
!= CYCLADES_MAGIC
) {
214 printk("Warning: bad magic number for serial struct (%s) in "
215 "%s\n", name
, routine
);
220 } /* serial_paranoia_check */
223 /* The following diagnostic routines allow the driver to spew
224 information on the screen, even (especially!) during interrupts.
229 local_irq_save(flags
);
230 printk(KERN_EMERG
"%s", data
);
231 local_irq_restore(flags
);
238 local_irq_save(flags
);
240 printk(KERN_EMERG
"%c", scrn
);
241 local_irq_restore(flags
);
246 (data
< 10) ? CP(data
+ '0') : CP(data
+ 'A' - 10);
250 CP1((data
>> 4) & 0x0f);
255 CP2((data
>> 8) & 0xff);
260 CP4((data
>> 16) & 0xffff);
265 /* This routine waits up to 1000 micro-seconds for the previous
266 command to the Cirrus chip to complete and then issues the
267 new command. An error is returned if the previous command
268 didn't finish within the time limit.
270 u_short
write_cy_cmd(volatile u_char
* base_addr
, u_char cmd
)
275 local_irq_save(flags
);
276 /* Check to see that the previous command has completed */
277 for (i
= 0; i
< 100; i
++) {
278 if (base_addr
[CyCCR
] == 0) {
283 /* if the CCR never cleared, the previous command
284 didn't finish within the "reasonable time" */
286 local_irq_restore(flags
);
290 /* Issue the new command */
291 base_addr
[CyCCR
] = cmd
;
292 local_irq_restore(flags
);
296 /* cy_start and cy_stop provide software output flow control as a
297 function of XON/XOFF, software CTS, and other such stuff. */
299 static void cy_stop(struct tty_struct
*tty
)
301 struct cyclades_port
*info
= tty
->driver_data
;
302 volatile unsigned char *base_addr
= (unsigned char *)BASE_ADDR
;
306 #ifdef SERIAL_DEBUG_OTHER
307 printk("cy_stop %s\n", tty
->name
); /* */
310 if (serial_paranoia_check(info
, tty
->name
, "cy_stop"))
313 channel
= info
->line
;
315 local_irq_save(flags
);
316 base_addr
[CyCAR
] = (u_char
) (channel
); /* index channel */
317 base_addr
[CyIER
] &= ~(CyTxMpty
| CyTxRdy
);
318 local_irq_restore(flags
);
321 static void cy_start(struct tty_struct
*tty
)
323 struct cyclades_port
*info
= tty
->driver_data
;
324 volatile unsigned char *base_addr
= (unsigned char *)BASE_ADDR
;
328 #ifdef SERIAL_DEBUG_OTHER
329 printk("cy_start %s\n", tty
->name
); /* */
332 if (serial_paranoia_check(info
, tty
->name
, "cy_start"))
335 channel
= info
->line
;
337 local_irq_save(flags
);
338 base_addr
[CyCAR
] = (u_char
) (channel
);
339 base_addr
[CyIER
] |= CyTxMpty
;
340 local_irq_restore(flags
);
343 /* The real interrupt service routines are called
344 whenever the card wants its hand held--chars
345 received, out buffer empty, modem change, etc.
347 static irqreturn_t
cd2401_rxerr_interrupt(int irq
, void *dev_id
)
349 struct tty_struct
*tty
;
350 struct cyclades_port
*info
;
351 volatile unsigned char *base_addr
= (unsigned char *)BASE_ADDR
;
352 unsigned char err
, rfoc
;
356 /* determine the channel and change to that context */
357 channel
= (u_short
) (base_addr
[CyLICR
] >> 2);
358 info
= &cy_port
[channel
];
359 info
->last_active
= jiffies
;
361 if ((err
= base_addr
[CyRISR
]) & CyTIMEOUT
) {
362 /* This is a receive timeout interrupt, ignore it */
363 base_addr
[CyREOIR
] = CyNOTRANS
;
367 /* Read a byte of data if there is any - assume the error
368 * is associated with this character */
370 if ((rfoc
= base_addr
[CyRFOC
]) != 0)
371 data
= base_addr
[CyRDR
];
375 /* if there is nowhere to put the data, discard it */
376 if (info
->tty
== 0) {
377 base_addr
[CyREOIR
] = rfoc
? 0 : CyNOTRANS
;
379 } else { /* there is an open port for this data */
381 if (err
& info
->ignore_status_mask
) {
382 base_addr
[CyREOIR
] = rfoc
? 0 : CyNOTRANS
;
385 if (tty_buffer_request_room(tty
, 1) != 0) {
386 if (err
& info
->read_status_mask
) {
388 tty_insert_flip_char(tty
, data
,
390 if (info
->flags
& ASYNC_SAK
) {
393 } else if (err
& CyFRAME
) {
394 tty_insert_flip_char(tty
, data
,
396 } else if (err
& CyPARITY
) {
397 tty_insert_flip_char(tty
, data
,
399 } else if (err
& CyOVERRUN
) {
400 tty_insert_flip_char(tty
, 0,
403 If the flip buffer itself is
404 overflowing, we still lose
405 the next incoming character.
407 if (tty_buffer_request_room(tty
, 1) !=
409 tty_insert_flip_char(tty
, data
,
412 /* These two conditions may imply */
413 /* a normal read should be done. */
414 /* else if(data & CyTIMEOUT) */
415 /* else if(data & CySPECHAR) */
417 tty_insert_flip_char(tty
, 0,
421 tty_insert_flip_char(tty
, data
, TTY_NORMAL
);
424 /* there was a software buffer overrun
425 and nothing could be done about it!!! */
428 tty_schedule_flip(tty
);
430 base_addr
[CyREOIR
] = rfoc
? 0 : CyNOTRANS
;
432 } /* cy_rxerr_interrupt */
434 static irqreturn_t
cd2401_modem_interrupt(int irq
, void *dev_id
)
436 struct cyclades_port
*info
;
437 volatile unsigned char *base_addr
= (unsigned char *)BASE_ADDR
;
442 /* determine the channel and change to that context */
443 channel
= (u_short
) (base_addr
[CyLICR
] >> 2);
444 info
= &cy_port
[channel
];
445 info
->last_active
= jiffies
;
447 mdm_change
= base_addr
[CyMISR
];
448 mdm_status
= base_addr
[CyMSVR1
];
450 if (info
->tty
== 0) { /* nowhere to put the data, ignore it */
453 if ((mdm_change
& CyDCD
)
454 && (info
->flags
& ASYNC_CHECK_CD
)) {
455 if (mdm_status
& CyDCD
) {
457 wake_up_interruptible(&info
->open_wait
);
460 tty_hangup(info
->tty
);
461 wake_up_interruptible(&info
->open_wait
);
462 info
->flags
&= ~ASYNC_NORMAL_ACTIVE
;
465 if ((mdm_change
& CyCTS
)
466 && (info
->flags
& ASYNC_CTS_FLOW
)) {
467 if (info
->tty
->stopped
) {
468 if (mdm_status
& CyCTS
) {
469 /* !!! cy_start isn't used because... */
470 info
->tty
->stopped
= 0;
471 base_addr
[CyIER
] |= CyTxMpty
;
472 tty_wakeup(info
->tty
);
475 if (!(mdm_status
& CyCTS
)) {
476 /* !!! cy_stop isn't used because... */
477 info
->tty
->stopped
= 1;
479 ~(CyTxMpty
| CyTxRdy
);
483 if (mdm_status
& CyDSR
) {
486 base_addr
[CyMEOIR
] = 0;
488 } /* cy_modem_interrupt */
490 static irqreturn_t
cd2401_tx_interrupt(int irq
, void *dev_id
)
492 struct cyclades_port
*info
;
493 volatile unsigned char *base_addr
= (unsigned char *)BASE_ADDR
;
495 int char_count
, saved_cnt
;
498 /* determine the channel and change to that context */
499 channel
= (u_short
) (base_addr
[CyLICR
] >> 2);
501 /* validate the port number (as configured and open) */
502 if ((channel
< 0) || (NR_PORTS
<= channel
)) {
503 base_addr
[CyIER
] &= ~(CyTxMpty
| CyTxRdy
);
504 base_addr
[CyTEOIR
] = CyNOTRANS
;
507 info
= &cy_port
[channel
];
508 info
->last_active
= jiffies
;
509 if (info
->tty
== 0) {
510 base_addr
[CyIER
] &= ~(CyTxMpty
| CyTxRdy
);
511 base_addr
[CyTEOIR
] = CyNOTRANS
;
515 /* load the on-chip space available for outbound data */
516 saved_cnt
= char_count
= base_addr
[CyTFTC
];
518 if (info
->x_char
) { /* send special char */
519 outch
= info
->x_char
;
520 base_addr
[CyTDR
] = outch
;
526 /* The Cirrus chip requires the "Embedded Transmit
527 Commands" of start break, delay, and end break
528 sequences to be sent. The duration of the
529 break is given in TICs, which runs at HZ
530 (typically 100) and the PPR runs at 200 Hz,
531 so the delay is duration * 200/HZ, and thus a
532 break can run from 1/100 sec to about 5/4 sec.
533 Need to check these values - RGH 141095.
535 base_addr
[CyTDR
] = 0; /* start break */
536 base_addr
[CyTDR
] = 0x81;
537 base_addr
[CyTDR
] = 0; /* delay a bit */
538 base_addr
[CyTDR
] = 0x82;
539 base_addr
[CyTDR
] = info
->x_break
* 200 / HZ
;
540 base_addr
[CyTDR
] = 0; /* terminate break */
541 base_addr
[CyTDR
] = 0x83;
546 while (char_count
> 0) {
547 if (!info
->xmit_cnt
) {
548 base_addr
[CyIER
] &= ~(CyTxMpty
| CyTxRdy
);
551 if (info
->xmit_buf
== 0) {
552 base_addr
[CyIER
] &= ~(CyTxMpty
| CyTxRdy
);
555 if (info
->tty
->stopped
|| info
->tty
->hw_stopped
) {
556 base_addr
[CyIER
] &= ~(CyTxMpty
| CyTxRdy
);
559 /* Because the Embedded Transmit Commands have been
560 enabled, we must check to see if the escape
561 character, NULL, is being sent. If it is, we
562 must ensure that there is room for it to be
563 doubled in the output stream. Therefore we
564 no longer advance the pointer when the character
565 is fetched, but rather wait until after the check
566 for a NULL output character. (This is necessary
567 because there may not be room for the two chars
568 needed to send a NULL.
570 outch
= info
->xmit_buf
[info
->xmit_tail
];
573 info
->xmit_tail
= (info
->xmit_tail
+ 1)
575 base_addr
[CyTDR
] = outch
;
578 if (char_count
> 1) {
580 info
->xmit_tail
= (info
->xmit_tail
+ 1)
582 base_addr
[CyTDR
] = outch
;
583 base_addr
[CyTDR
] = 0;
592 if (info
->xmit_cnt
< WAKEUP_CHARS
)
593 tty_wakeup(info
->tty
);
595 base_addr
[CyTEOIR
] = (char_count
!= saved_cnt
) ? 0 : CyNOTRANS
;
597 } /* cy_tx_interrupt */
599 static irqreturn_t
cd2401_rx_interrupt(int irq
, void *dev_id
)
601 struct tty_struct
*tty
;
602 struct cyclades_port
*info
;
603 volatile unsigned char *base_addr
= (unsigned char *)BASE_ADDR
;
609 /* determine the channel and change to that context */
610 channel
= (u_short
) (base_addr
[CyLICR
] >> 2);
611 info
= &cy_port
[channel
];
612 info
->last_active
= jiffies
;
613 save_cnt
= char_count
= base_addr
[CyRFOC
];
615 /* if there is nowhere to put the data, discard it */
616 if (info
->tty
== 0) {
617 while (char_count
--) {
618 data
= base_addr
[CyRDR
];
620 } else { /* there is an open port for this data */
622 /* load # characters available from the chip */
624 #ifdef CYCLOM_ENABLE_MONITORING
625 ++info
->mon
.int_count
;
626 info
->mon
.char_count
+= char_count
;
627 if (char_count
> info
->mon
.char_max
)
628 info
->mon
.char_max
= char_count
;
629 info
->mon
.char_last
= char_count
;
631 while (char_count
--) {
632 data
= base_addr
[CyRDR
];
633 tty_insert_flip_char(tty
, data
, TTY_NORMAL
);
634 #ifdef CYCLOM_16Y_HACK
638 tty_schedule_flip(tty
);
641 base_addr
[CyREOIR
] = save_cnt
? 0 : CyNOTRANS
;
643 } /* cy_rx_interrupt */
645 /* This is called whenever a port becomes active;
646 interrupts are enabled and DTR & RTS are turned on.
648 static int startup(struct cyclades_port
*info
)
651 volatile unsigned char *base_addr
= (unsigned char *)BASE_ADDR
;
654 if (info
->flags
& ASYNC_INITIALIZED
) {
660 set_bit(TTY_IO_ERROR
, &info
->tty
->flags
);
664 if (!info
->xmit_buf
) {
665 info
->xmit_buf
= (unsigned char *)get_zeroed_page(GFP_KERNEL
);
666 if (!info
->xmit_buf
) {
673 channel
= info
->line
;
675 #ifdef SERIAL_DEBUG_OPEN
676 printk("startup channel %d\n", channel
);
679 local_irq_save(flags
);
680 base_addr
[CyCAR
] = (u_char
) channel
;
681 write_cy_cmd(base_addr
, CyENB_RCVR
| CyENB_XMTR
);
683 base_addr
[CyCAR
] = (u_char
) channel
; /* !!! Is this needed? */
684 base_addr
[CyMSVR1
] = CyRTS
;
685 /* CP('S');CP('1'); */
686 base_addr
[CyMSVR2
] = CyDTR
;
688 #ifdef SERIAL_DEBUG_DTR
689 printk("cyc: %d: raising DTR\n", __LINE__
);
690 printk(" status: 0x%x, 0x%x\n", base_addr
[CyMSVR1
],
694 base_addr
[CyIER
] |= CyRxData
;
695 info
->flags
|= ASYNC_INITIALIZED
;
698 clear_bit(TTY_IO_ERROR
, &info
->tty
->flags
);
700 info
->xmit_cnt
= info
->xmit_head
= info
->xmit_tail
= 0;
702 local_irq_restore(flags
);
704 #ifdef SERIAL_DEBUG_OPEN
710 void start_xmit(struct cyclades_port
*info
)
713 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
716 channel
= info
->line
;
717 local_irq_save(flags
);
718 base_addr
[CyCAR
] = channel
;
719 base_addr
[CyIER
] |= CyTxMpty
;
720 local_irq_restore(flags
);
724 * This routine shuts down a serial port; interrupts are disabled,
725 * and DTR is dropped if the hangup on close termio flag is on.
727 static void shutdown(struct cyclades_port
*info
)
730 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
733 if (!(info
->flags
& ASYNC_INITIALIZED
)) {
738 channel
= info
->line
;
740 #ifdef SERIAL_DEBUG_OPEN
741 printk("shutdown channel %d\n", channel
);
744 /* !!! REALLY MUST WAIT FOR LAST CHARACTER TO BE
745 SENT BEFORE DROPPING THE LINE !!! (Perhaps
746 set some flag that is read when XMTY happens.)
747 Other choices are to delay some fixed interval
748 or schedule some later processing.
750 local_irq_save(flags
);
751 if (info
->xmit_buf
) {
752 free_page((unsigned long)info
->xmit_buf
);
753 info
->xmit_buf
= NULL
;
756 base_addr
[CyCAR
] = (u_char
) channel
;
757 if (!info
->tty
|| (info
->tty
->termios
->c_cflag
& HUPCL
)) {
758 base_addr
[CyMSVR1
] = 0;
759 /* CP('C');CP('1'); */
760 base_addr
[CyMSVR2
] = 0;
761 #ifdef SERIAL_DEBUG_DTR
762 printk("cyc: %d: dropping DTR\n", __LINE__
);
763 printk(" status: 0x%x, 0x%x\n", base_addr
[CyMSVR1
],
767 write_cy_cmd(base_addr
, CyDIS_RCVR
);
768 /* it may be appropriate to clear _XMIT at
769 some later date (after testing)!!! */
772 set_bit(TTY_IO_ERROR
, &info
->tty
->flags
);
774 info
->flags
&= ~ASYNC_INITIALIZED
;
775 local_irq_restore(flags
);
777 #ifdef SERIAL_DEBUG_OPEN
783 * This routine finds or computes the various line characteristics.
785 static void config_setup(struct cyclades_port
*info
)
788 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
792 unsigned char ti
, need_init_chan
= 0;
794 if (!info
->tty
|| !info
->tty
->termios
) {
797 if (info
->line
== -1) {
800 cflag
= info
->tty
->termios
->c_cflag
;
805 /* Starting with kernel 1.1.65, there is direct support for
806 higher baud rates. The following code supports those
807 changes. The conditional aspect allows this driver to be
808 used for earlier as well as later kernel versions. (The
809 mapping is slightly different from serial.c because there
810 is still the possibility of supporting 75 kbit/sec with
816 else if (i
== B115200
)
819 else if (i
== B78600
)
823 info
->tty
->termios
->c_cflag
&= ~CBAUDEX
;
827 if ((info
->flags
& ASYNC_SPD_MASK
) == ASYNC_SPD_HI
)
829 if ((info
->flags
& ASYNC_SPD_MASK
) == ASYNC_SPD_VHI
)
832 /* Don't ever change the speed of the console port. It will
833 * run at the speed specified in bootinfo, or at 19.2K */
834 /* Actually, it should run at whatever speed 166Bug was using */
835 /* Note info->timeout isn't used at present */
836 if (info
!= serial_console_info
) {
837 info
->tbpr
= baud_bpr
[i
]; /* Tx BPR */
838 info
->tco
= baud_co
[i
]; /* Tx CO */
839 info
->rbpr
= baud_bpr
[i
]; /* Rx BPR */
840 info
->rco
= baud_co
[i
] >> 5; /* Rx CO */
841 if (baud_table
[i
] == 134) {
843 (info
->xmit_fifo_size
* HZ
* 30 / 269) + 2;
844 /* get it right for 134.5 baud */
845 } else if (baud_table
[i
]) {
847 (info
->xmit_fifo_size
* HZ
* 15 / baud_table
[i
]) +
849 /* this needs to be propagated into the card info */
854 /* By tradition (is it a standard?) a baud rate of zero
855 implies the line should be/has been closed. A bit
856 later in this routine such a test is performed. */
858 /* byte size and parity */
862 info
->cor4
= (info
->default_threshold
? info
->default_threshold
: baud_cor4
[i
]); /* receive threshold */
863 /* Following two lines added 101295, RGH. */
864 /* It is obviously wrong to access CyCORx, and not info->corx here,
865 * try and remember to fix it later! */
866 channel
= info
->line
;
867 base_addr
[CyCAR
] = (u_char
) channel
;
868 if (C_CLOCAL(info
->tty
)) {
869 if (base_addr
[CyIER
] & CyMdmCh
)
870 base_addr
[CyIER
] &= ~CyMdmCh
; /* without modem intr */
871 /* ignore 1->0 modem transitions */
872 if (base_addr
[CyCOR4
] & (CyDSR
| CyCTS
| CyDCD
))
873 base_addr
[CyCOR4
] &= ~(CyDSR
| CyCTS
| CyDCD
);
874 /* ignore 0->1 modem transitions */
875 if (base_addr
[CyCOR5
] & (CyDSR
| CyCTS
| CyDCD
))
876 base_addr
[CyCOR5
] &= ~(CyDSR
| CyCTS
| CyDCD
);
878 if ((base_addr
[CyIER
] & CyMdmCh
) != CyMdmCh
)
879 base_addr
[CyIER
] |= CyMdmCh
; /* with modem intr */
880 /* act on 1->0 modem transitions */
881 if ((base_addr
[CyCOR4
] & (CyDSR
| CyCTS
| CyDCD
)) !=
882 (CyDSR
| CyCTS
| CyDCD
))
883 base_addr
[CyCOR4
] |= CyDSR
| CyCTS
| CyDCD
;
884 /* act on 0->1 modem transitions */
885 if ((base_addr
[CyCOR5
] & (CyDSR
| CyCTS
| CyDCD
)) !=
886 (CyDSR
| CyCTS
| CyDCD
))
887 base_addr
[CyCOR5
] |= CyDSR
| CyCTS
| CyDCD
;
889 info
->cor3
= (cflag
& CSTOPB
) ? Cy_2_STOP
: Cy_1_STOP
;
891 switch (cflag
& CSIZE
) {
893 info
->cor1
= Cy_5_BITS
;
896 info
->cor1
= Cy_6_BITS
;
899 info
->cor1
= Cy_7_BITS
;
902 info
->cor1
= Cy_8_BITS
;
905 if (cflag
& PARENB
) {
906 if (cflag
& PARODD
) {
907 info
->cor1
|= CyPARITY_O
;
909 info
->cor1
|= CyPARITY_E
;
912 info
->cor1
|= CyPARITY_NONE
;
915 /* CTS flow control flag */
917 /* Don't complcate matters for now! RGH 141095 */
918 if (cflag
& CRTSCTS
) {
919 info
->flags
|= ASYNC_CTS_FLOW
;
920 info
->cor2
|= CyCtsAE
;
922 info
->flags
&= ~ASYNC_CTS_FLOW
;
923 info
->cor2
&= ~CyCtsAE
;
927 info
->flags
&= ~ASYNC_CHECK_CD
;
929 info
->flags
|= ASYNC_CHECK_CD
;
931 /***********************************************
932 The hardware option, CyRtsAO, presents RTS when
933 the chip has characters to send. Since most modems
934 use RTS as reverse (inbound) flow control, this
935 option is not used. If inbound flow control is
936 necessary, DTR can be programmed to provide the
937 appropriate signals for use with a non-standard
938 cable. Contact Marcio Saito for details.
939 ***********************************************/
941 channel
= info
->line
;
943 local_irq_save(flags
);
944 base_addr
[CyCAR
] = (u_char
) channel
;
946 /* CyCMR set once only in mvme167_init_serial() */
947 if (base_addr
[CyLICR
] != channel
<< 2)
948 base_addr
[CyLICR
] = channel
<< 2;
949 if (base_addr
[CyLIVR
] != 0x5c)
950 base_addr
[CyLIVR
] = 0x5c;
952 /* tx and rx baud rate */
954 if (base_addr
[CyCOR1
] != info
->cor1
)
956 if (base_addr
[CyTCOR
] != info
->tco
)
957 base_addr
[CyTCOR
] = info
->tco
;
958 if (base_addr
[CyTBPR
] != info
->tbpr
)
959 base_addr
[CyTBPR
] = info
->tbpr
;
960 if (base_addr
[CyRCOR
] != info
->rco
)
961 base_addr
[CyRCOR
] = info
->rco
;
962 if (base_addr
[CyRBPR
] != info
->rbpr
)
963 base_addr
[CyRBPR
] = info
->rbpr
;
965 /* set line characteristics according configuration */
967 if (base_addr
[CySCHR1
] != START_CHAR(info
->tty
))
968 base_addr
[CySCHR1
] = START_CHAR(info
->tty
);
969 if (base_addr
[CySCHR2
] != STOP_CHAR(info
->tty
))
970 base_addr
[CySCHR2
] = STOP_CHAR(info
->tty
);
971 if (base_addr
[CySCRL
] != START_CHAR(info
->tty
))
972 base_addr
[CySCRL
] = START_CHAR(info
->tty
);
973 if (base_addr
[CySCRH
] != START_CHAR(info
->tty
))
974 base_addr
[CySCRH
] = START_CHAR(info
->tty
);
975 if (base_addr
[CyCOR1
] != info
->cor1
)
976 base_addr
[CyCOR1
] = info
->cor1
;
977 if (base_addr
[CyCOR2
] != info
->cor2
)
978 base_addr
[CyCOR2
] = info
->cor2
;
979 if (base_addr
[CyCOR3
] != info
->cor3
)
980 base_addr
[CyCOR3
] = info
->cor3
;
981 if (base_addr
[CyCOR4
] != info
->cor4
)
982 base_addr
[CyCOR4
] = info
->cor4
;
983 if (base_addr
[CyCOR5
] != info
->cor5
)
984 base_addr
[CyCOR5
] = info
->cor5
;
985 if (base_addr
[CyCOR6
] != info
->cor6
)
986 base_addr
[CyCOR6
] = info
->cor6
;
987 if (base_addr
[CyCOR7
] != info
->cor7
)
988 base_addr
[CyCOR7
] = info
->cor7
;
991 write_cy_cmd(base_addr
, CyINIT_CHAN
);
993 base_addr
[CyCAR
] = (u_char
) channel
; /* !!! Is this needed? */
995 /* 2ms default rx timeout */
996 ti
= info
->default_timeout
? info
->default_timeout
: 0x02;
997 if (base_addr
[CyRTPRL
] != ti
)
998 base_addr
[CyRTPRL
] = ti
;
999 if (base_addr
[CyRTPRH
] != 0)
1000 base_addr
[CyRTPRH
] = 0;
1002 /* Set up RTS here also ????? RGH 141095 */
1003 if (i
== 0) { /* baud rate is zero, turn off line */
1004 if ((base_addr
[CyMSVR2
] & CyDTR
) == CyDTR
)
1005 base_addr
[CyMSVR2
] = 0;
1006 #ifdef SERIAL_DEBUG_DTR
1007 printk("cyc: %d: dropping DTR\n", __LINE__
);
1008 printk(" status: 0x%x, 0x%x\n", base_addr
[CyMSVR1
],
1009 base_addr
[CyMSVR2
]);
1012 if ((base_addr
[CyMSVR2
] & CyDTR
) != CyDTR
)
1013 base_addr
[CyMSVR2
] = CyDTR
;
1014 #ifdef SERIAL_DEBUG_DTR
1015 printk("cyc: %d: raising DTR\n", __LINE__
);
1016 printk(" status: 0x%x, 0x%x\n", base_addr
[CyMSVR1
],
1017 base_addr
[CyMSVR2
]);
1022 clear_bit(TTY_IO_ERROR
, &info
->tty
->flags
);
1025 local_irq_restore(flags
);
1027 } /* config_setup */
1029 static int cy_put_char(struct tty_struct
*tty
, unsigned char ch
)
1031 struct cyclades_port
*info
= tty
->driver_data
;
1032 unsigned long flags
;
1034 #ifdef SERIAL_DEBUG_IO
1035 printk("cy_put_char %s(0x%02x)\n", tty
->name
, ch
);
1038 if (serial_paranoia_check(info
, tty
->name
, "cy_put_char"))
1041 if (!info
->xmit_buf
)
1044 local_irq_save(flags
);
1045 if (info
->xmit_cnt
>= PAGE_SIZE
- 1) {
1046 local_irq_restore(flags
);
1050 info
->xmit_buf
[info
->xmit_head
++] = ch
;
1051 info
->xmit_head
&= PAGE_SIZE
- 1;
1053 local_irq_restore(flags
);
1057 static void cy_flush_chars(struct tty_struct
*tty
)
1059 struct cyclades_port
*info
= tty
->driver_data
;
1060 unsigned long flags
;
1061 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1064 #ifdef SERIAL_DEBUG_IO
1065 printk("cy_flush_chars %s\n", tty
->name
); /* */
1068 if (serial_paranoia_check(info
, tty
->name
, "cy_flush_chars"))
1071 if (info
->xmit_cnt
<= 0 || tty
->stopped
1072 || tty
->hw_stopped
|| !info
->xmit_buf
)
1075 channel
= info
->line
;
1077 local_irq_save(flags
);
1078 base_addr
[CyCAR
] = channel
;
1079 base_addr
[CyIER
] |= CyTxMpty
;
1080 local_irq_restore(flags
);
1081 } /* cy_flush_chars */
1083 /* This routine gets called when tty_write has put something into
1084 the write_queue. If the port is not already transmitting stuff,
1085 start it off by enabling interrupts. The interrupt service
1086 routine will then ensure that the characters are sent. If the
1087 port is already active, there is no need to kick it.
1089 static int cy_write(struct tty_struct
*tty
, const unsigned char *buf
, int count
)
1091 struct cyclades_port
*info
= tty
->driver_data
;
1092 unsigned long flags
;
1095 #ifdef SERIAL_DEBUG_IO
1096 printk("cy_write %s\n", tty
->name
); /* */
1099 if (serial_paranoia_check(info
, tty
->name
, "cy_write")) {
1103 if (!info
->xmit_buf
) {
1108 local_irq_save(flags
);
1109 c
= min_t(int, count
, min(SERIAL_XMIT_SIZE
- info
->xmit_cnt
- 1,
1110 SERIAL_XMIT_SIZE
- info
->xmit_head
));
1112 local_irq_restore(flags
);
1116 memcpy(info
->xmit_buf
+ info
->xmit_head
, buf
, c
);
1118 (info
->xmit_head
+ c
) & (SERIAL_XMIT_SIZE
- 1);
1119 info
->xmit_cnt
+= c
;
1120 local_irq_restore(flags
);
1127 if (info
->xmit_cnt
&& !tty
->stopped
&& !tty
->hw_stopped
) {
1133 static int cy_write_room(struct tty_struct
*tty
)
1135 struct cyclades_port
*info
= tty
->driver_data
;
1138 #ifdef SERIAL_DEBUG_IO
1139 printk("cy_write_room %s\n", tty
->name
); /* */
1142 if (serial_paranoia_check(info
, tty
->name
, "cy_write_room"))
1144 ret
= PAGE_SIZE
- info
->xmit_cnt
- 1;
1148 } /* cy_write_room */
1150 static int cy_chars_in_buffer(struct tty_struct
*tty
)
1152 struct cyclades_port
*info
= tty
->driver_data
;
1154 #ifdef SERIAL_DEBUG_IO
1155 printk("cy_chars_in_buffer %s %d\n", tty
->name
, info
->xmit_cnt
); /* */
1158 if (serial_paranoia_check(info
, tty
->name
, "cy_chars_in_buffer"))
1161 return info
->xmit_cnt
;
1162 } /* cy_chars_in_buffer */
1164 static void cy_flush_buffer(struct tty_struct
*tty
)
1166 struct cyclades_port
*info
= tty
->driver_data
;
1167 unsigned long flags
;
1169 #ifdef SERIAL_DEBUG_IO
1170 printk("cy_flush_buffer %s\n", tty
->name
); /* */
1173 if (serial_paranoia_check(info
, tty
->name
, "cy_flush_buffer"))
1175 local_irq_save(flags
);
1176 info
->xmit_cnt
= info
->xmit_head
= info
->xmit_tail
= 0;
1177 local_irq_restore(flags
);
1179 } /* cy_flush_buffer */
1181 /* This routine is called by the upper-layer tty layer to signal
1182 that incoming characters should be throttled or that the
1183 throttle should be released.
1185 static void cy_throttle(struct tty_struct
*tty
)
1187 struct cyclades_port
*info
= tty
->driver_data
;
1188 unsigned long flags
;
1189 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1192 #ifdef SERIAL_DEBUG_THROTTLE
1195 printk("throttle %s: %d....\n", tty_name(tty
, buf
),
1196 tty
->ldisc
.chars_in_buffer(tty
));
1197 printk("cy_throttle %s\n", tty
->name
);
1200 if (serial_paranoia_check(info
, tty
->name
, "cy_nthrottle")) {
1205 info
->x_char
= STOP_CHAR(tty
);
1206 /* Should use the "Send Special Character" feature!!! */
1209 channel
= info
->line
;
1211 local_irq_save(flags
);
1212 base_addr
[CyCAR
] = (u_char
) channel
;
1213 base_addr
[CyMSVR1
] = 0;
1214 local_irq_restore(flags
);
1217 static void cy_unthrottle(struct tty_struct
*tty
)
1219 struct cyclades_port
*info
= tty
->driver_data
;
1220 unsigned long flags
;
1221 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1224 #ifdef SERIAL_DEBUG_THROTTLE
1227 printk("throttle %s: %d....\n", tty_name(tty
, buf
),
1228 tty
->ldisc
.chars_in_buffer(tty
));
1229 printk("cy_unthrottle %s\n", tty
->name
);
1232 if (serial_paranoia_check(info
, tty
->name
, "cy_nthrottle")) {
1237 info
->x_char
= START_CHAR(tty
);
1238 /* Should use the "Send Special Character" feature!!! */
1241 channel
= info
->line
;
1243 local_irq_save(flags
);
1244 base_addr
[CyCAR
] = (u_char
) channel
;
1245 base_addr
[CyMSVR1
] = CyRTS
;
1246 local_irq_restore(flags
);
1247 } /* cy_unthrottle */
1250 get_serial_info(struct cyclades_port
*info
,
1251 struct serial_struct __user
* retinfo
)
1253 struct serial_struct tmp
;
1258 memset(&tmp
, 0, sizeof(tmp
));
1259 tmp
.type
= info
->type
;
1260 tmp
.line
= info
->line
;
1261 tmp
.port
= info
->line
;
1263 tmp
.flags
= info
->flags
;
1264 tmp
.baud_base
= 0; /*!!! */
1265 tmp
.close_delay
= info
->close_delay
;
1266 tmp
.custom_divisor
= 0; /*!!! */
1267 tmp
.hub6
= 0; /*!!! */
1268 return copy_to_user(retinfo
, &tmp
, sizeof(*retinfo
)) ? -EFAULT
: 0;
1269 } /* get_serial_info */
1272 set_serial_info(struct cyclades_port
*info
,
1273 struct serial_struct __user
* new_info
)
1275 struct serial_struct new_serial
;
1276 struct cyclades_port old_info
;
1281 if (copy_from_user(&new_serial
, new_info
, sizeof(new_serial
)))
1285 if (!capable(CAP_SYS_ADMIN
)) {
1286 if ((new_serial
.close_delay
!= info
->close_delay
) ||
1287 ((new_serial
.flags
& ASYNC_FLAGS
& ~ASYNC_USR_MASK
) !=
1288 (info
->flags
& ASYNC_FLAGS
& ~ASYNC_USR_MASK
)))
1290 info
->flags
= ((info
->flags
& ~ASYNC_USR_MASK
) |
1291 (new_serial
.flags
& ASYNC_USR_MASK
));
1292 goto check_and_exit
;
1296 * OK, past this point, all the error checking has been done.
1297 * At this point, we start making changes.....
1300 info
->flags
= ((info
->flags
& ~ASYNC_FLAGS
) |
1301 (new_serial
.flags
& ASYNC_FLAGS
));
1302 info
->close_delay
= new_serial
.close_delay
;
1305 if (info
->flags
& ASYNC_INITIALIZED
) {
1309 return startup(info
);
1310 } /* set_serial_info */
1312 static int cy_tiocmget(struct tty_struct
*tty
, struct file
*file
)
1314 struct cyclades_port
*info
= tty
->driver_data
;
1316 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1317 unsigned long flags
;
1318 unsigned char status
;
1320 channel
= info
->line
;
1322 local_irq_save(flags
);
1323 base_addr
[CyCAR
] = (u_char
) channel
;
1324 status
= base_addr
[CyMSVR1
] | base_addr
[CyMSVR2
];
1325 local_irq_restore(flags
);
1327 return ((status
& CyRTS
) ? TIOCM_RTS
: 0)
1328 | ((status
& CyDTR
) ? TIOCM_DTR
: 0)
1329 | ((status
& CyDCD
) ? TIOCM_CAR
: 0)
1330 | ((status
& CyDSR
) ? TIOCM_DSR
: 0)
1331 | ((status
& CyCTS
) ? TIOCM_CTS
: 0);
1335 cy_tiocmset(struct tty_struct
*tty
, struct file
*file
,
1336 unsigned int set
, unsigned int clear
)
1338 struct cyclades_port
*info
= tty
->driver_data
;
1340 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1341 unsigned long flags
;
1343 channel
= info
->line
;
1345 if (set
& TIOCM_RTS
) {
1346 local_irq_save(flags
);
1347 base_addr
[CyCAR
] = (u_char
) channel
;
1348 base_addr
[CyMSVR1
] = CyRTS
;
1349 local_irq_restore(flags
);
1351 if (set
& TIOCM_DTR
) {
1352 local_irq_save(flags
);
1353 base_addr
[CyCAR
] = (u_char
) channel
;
1354 /* CP('S');CP('2'); */
1355 base_addr
[CyMSVR2
] = CyDTR
;
1356 #ifdef SERIAL_DEBUG_DTR
1357 printk("cyc: %d: raising DTR\n", __LINE__
);
1358 printk(" status: 0x%x, 0x%x\n", base_addr
[CyMSVR1
],
1359 base_addr
[CyMSVR2
]);
1361 local_irq_restore(flags
);
1364 if (clear
& TIOCM_RTS
) {
1365 local_irq_save(flags
);
1366 base_addr
[CyCAR
] = (u_char
) channel
;
1367 base_addr
[CyMSVR1
] = 0;
1368 local_irq_restore(flags
);
1370 if (clear
& TIOCM_DTR
) {
1371 local_irq_save(flags
);
1372 base_addr
[CyCAR
] = (u_char
) channel
;
1373 /* CP('C');CP('2'); */
1374 base_addr
[CyMSVR2
] = 0;
1375 #ifdef SERIAL_DEBUG_DTR
1376 printk("cyc: %d: dropping DTR\n", __LINE__
);
1377 printk(" status: 0x%x, 0x%x\n", base_addr
[CyMSVR1
],
1378 base_addr
[CyMSVR2
]);
1380 local_irq_restore(flags
);
1384 } /* set_modem_info */
1386 static void send_break(struct cyclades_port
*info
, int duration
)
1387 { /* Let the transmit ISR take care of this (since it
1388 requires stuffing characters into the output stream).
1390 info
->x_break
= duration
;
1391 if (!info
->xmit_cnt
) {
1397 get_mon_info(struct cyclades_port
*info
, struct cyclades_monitor __user
* mon
)
1400 if (copy_to_user(mon
, &info
->mon
, sizeof(struct cyclades_monitor
)))
1402 info
->mon
.int_count
= 0;
1403 info
->mon
.char_count
= 0;
1404 info
->mon
.char_max
= 0;
1405 info
->mon
.char_last
= 0;
1409 static int set_threshold(struct cyclades_port
*info
, unsigned long __user
* arg
)
1411 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1412 unsigned long value
;
1415 if (get_user(value
, arg
))
1418 channel
= info
->line
;
1419 info
->cor4
&= ~CyREC_FIFO
;
1420 info
->cor4
|= value
& CyREC_FIFO
;
1421 base_addr
[CyCOR4
] = info
->cor4
;
1426 get_threshold(struct cyclades_port
*info
, unsigned long __user
* value
)
1428 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1432 channel
= info
->line
;
1434 tmp
= base_addr
[CyCOR4
] & CyREC_FIFO
;
1435 return put_user(tmp
, value
);
1439 set_default_threshold(struct cyclades_port
*info
, unsigned long __user
* arg
)
1441 unsigned long value
;
1443 if (get_user(value
, arg
))
1446 info
->default_threshold
= value
& 0x0f;
1451 get_default_threshold(struct cyclades_port
*info
, unsigned long __user
* value
)
1453 return put_user(info
->default_threshold
, value
);
1456 static int set_timeout(struct cyclades_port
*info
, unsigned long __user
* arg
)
1458 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1460 unsigned long value
;
1462 if (get_user(value
, arg
))
1465 channel
= info
->line
;
1467 base_addr
[CyRTPRL
] = value
& 0xff;
1468 base_addr
[CyRTPRH
] = (value
>> 8) & 0xff;
1472 static int get_timeout(struct cyclades_port
*info
, unsigned long __user
* value
)
1474 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1478 channel
= info
->line
;
1480 tmp
= base_addr
[CyRTPRL
];
1481 return put_user(tmp
, value
);
1484 static int set_default_timeout(struct cyclades_port
*info
, unsigned long value
)
1486 info
->default_timeout
= value
& 0xff;
1491 get_default_timeout(struct cyclades_port
*info
, unsigned long __user
* value
)
1493 return put_user(info
->default_timeout
, value
);
1497 cy_ioctl(struct tty_struct
*tty
, struct file
*file
,
1498 unsigned int cmd
, unsigned long arg
)
1500 struct cyclades_port
*info
= tty
->driver_data
;
1502 void __user
*argp
= (void __user
*)arg
;
1504 #ifdef SERIAL_DEBUG_OTHER
1505 printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty
->name
, cmd
, arg
); /* */
1512 ret_val
= get_mon_info(info
, argp
);
1515 ret_val
= get_threshold(info
, argp
);
1518 ret_val
= set_threshold(info
, argp
);
1520 case CYGETDEFTHRESH
:
1521 ret_val
= get_default_threshold(info
, argp
);
1523 case CYSETDEFTHRESH
:
1524 ret_val
= set_default_threshold(info
, argp
);
1527 ret_val
= get_timeout(info
, argp
);
1530 ret_val
= set_timeout(info
, argp
);
1532 case CYGETDEFTIMEOUT
:
1533 ret_val
= get_default_timeout(info
, argp
);
1535 case CYSETDEFTIMEOUT
:
1536 ret_val
= set_default_timeout(info
, (unsigned long)arg
);
1538 case TCSBRK
: /* SVID version: non-zero arg --> no break */
1539 ret_val
= tty_check_change(tty
);
1542 tty_wait_until_sent(tty
, 0);
1544 send_break(info
, HZ
/ 4); /* 1/4 second */
1546 case TCSBRKP
: /* support for POSIX tcsendbreak() */
1547 ret_val
= tty_check_change(tty
);
1550 tty_wait_until_sent(tty
, 0);
1551 send_break(info
, arg
? arg
* (HZ
/ 10) : HZ
/ 4);
1554 /* The following commands are incompletely implemented!!! */
1556 ret_val
= get_serial_info(info
, argp
);
1559 ret_val
= set_serial_info(info
, argp
);
1562 ret_val
= -ENOIOCTLCMD
;
1566 #ifdef SERIAL_DEBUG_OTHER
1567 printk("cy_ioctl done\n");
1573 static void cy_set_termios(struct tty_struct
*tty
, struct ktermios
*old_termios
)
1575 struct cyclades_port
*info
= tty
->driver_data
;
1577 #ifdef SERIAL_DEBUG_OTHER
1578 printk("cy_set_termios %s\n", tty
->name
);
1581 if (tty
->termios
->c_cflag
== old_termios
->c_cflag
)
1585 if ((old_termios
->c_cflag
& CRTSCTS
) &&
1586 !(tty
->termios
->c_cflag
& CRTSCTS
)) {
1590 #ifdef tytso_patch_94Nov25_1726
1591 if (!(old_termios
->c_cflag
& CLOCAL
) &&
1592 (tty
->termios
->c_cflag
& CLOCAL
))
1593 wake_up_interruptible(&info
->open_wait
);
1595 } /* cy_set_termios */
1597 static void cy_close(struct tty_struct
*tty
, struct file
*filp
)
1599 struct cyclades_port
*info
= tty
->driver_data
;
1602 #ifdef SERIAL_DEBUG_OTHER
1603 printk("cy_close %s\n", tty
->name
);
1606 if (!info
|| serial_paranoia_check(info
, tty
->name
, "cy_close")) {
1609 #ifdef SERIAL_DEBUG_OPEN
1610 printk("cy_close %s, count = %d\n", tty
->name
, info
->count
);
1613 if ((tty
->count
== 1) && (info
->count
!= 1)) {
1615 * Uh, oh. tty->count is 1, which means that the tty
1616 * structure will be freed. Info->count should always
1617 * be one in these conditions. If it's greater than
1618 * one, we've got real problems, since it means the
1619 * serial port won't be shutdown.
1621 printk("cy_close: bad serial port count; tty->count is 1, "
1622 "info->count is %d\n", info
->count
);
1625 #ifdef SERIAL_DEBUG_COUNT
1626 printk("cyc: %d: decrementing count to %d\n", __LINE__
,
1629 if (--info
->count
< 0) {
1630 printk("cy_close: bad serial port count for ttys%d: %d\n",
1631 info
->line
, info
->count
);
1632 #ifdef SERIAL_DEBUG_COUNT
1633 printk("cyc: %d: setting count to 0\n", __LINE__
);
1639 info
->flags
|= ASYNC_CLOSING
;
1640 if (info
->flags
& ASYNC_INITIALIZED
)
1641 tty_wait_until_sent(tty
, 3000); /* 30 seconds timeout */
1643 cy_flush_buffer(tty
);
1644 tty_ldisc_flush(tty
);
1646 if (info
->blocked_open
) {
1647 if (info
->close_delay
) {
1648 msleep_interruptible(jiffies_to_msecs
1649 (info
->close_delay
));
1651 wake_up_interruptible(&info
->open_wait
);
1653 info
->flags
&= ~(ASYNC_NORMAL_ACTIVE
| ASYNC_CLOSING
);
1654 wake_up_interruptible(&info
->close_wait
);
1656 #ifdef SERIAL_DEBUG_OTHER
1657 printk("cy_close done\n");
1662 * cy_hangup() --- called by tty_hangup() when a hangup is signaled.
1664 void cy_hangup(struct tty_struct
*tty
)
1666 struct cyclades_port
*info
= tty
->driver_data
;
1668 #ifdef SERIAL_DEBUG_OTHER
1669 printk("cy_hangup %s\n", tty
->name
); /* */
1672 if (serial_paranoia_check(info
, tty
->name
, "cy_hangup"))
1679 #ifdef SERIAL_DEBUG_COUNT
1680 printk("cyc: %d: setting count to 0\n", __LINE__
);
1684 info
->flags
&= ~ASYNC_NORMAL_ACTIVE
;
1685 wake_up_interruptible(&info
->open_wait
);
1689 * ------------------------------------------------------------
1690 * cy_open() and friends
1691 * ------------------------------------------------------------
1695 block_til_ready(struct tty_struct
*tty
, struct file
*filp
,
1696 struct cyclades_port
*info
)
1698 DECLARE_WAITQUEUE(wait
, current
);
1699 unsigned long flags
;
1702 volatile u_char
*base_addr
= (u_char
*) BASE_ADDR
;
1705 * If the device is in the middle of being closed, then block
1706 * until it's done, and then try again.
1708 if (info
->flags
& ASYNC_CLOSING
) {
1709 interruptible_sleep_on(&info
->close_wait
);
1710 if (info
->flags
& ASYNC_HUP_NOTIFY
) {
1713 return -ERESTARTSYS
;
1718 * If non-blocking mode is set, then make the check up front
1721 if (filp
->f_flags
& O_NONBLOCK
) {
1722 info
->flags
|= ASYNC_NORMAL_ACTIVE
;
1727 * Block waiting for the carrier detect and the line to become
1728 * free (i.e., not in use by the callout). While we are in
1729 * this loop, info->count is dropped by one, so that
1730 * cy_close() knows when to free things. We restore it upon
1731 * exit, either normal or abnormal.
1734 add_wait_queue(&info
->open_wait
, &wait
);
1735 #ifdef SERIAL_DEBUG_OPEN
1736 printk("block_til_ready before block: %s, count = %d\n",
1737 tty
->name
, info
->count
);
1741 #ifdef SERIAL_DEBUG_COUNT
1742 printk("cyc: %d: decrementing count to %d\n", __LINE__
, info
->count
);
1744 info
->blocked_open
++;
1746 channel
= info
->line
;
1749 local_irq_save(flags
);
1750 base_addr
[CyCAR
] = (u_char
) channel
;
1751 base_addr
[CyMSVR1
] = CyRTS
;
1752 /* CP('S');CP('4'); */
1753 base_addr
[CyMSVR2
] = CyDTR
;
1754 #ifdef SERIAL_DEBUG_DTR
1755 printk("cyc: %d: raising DTR\n", __LINE__
);
1756 printk(" status: 0x%x, 0x%x\n", base_addr
[CyMSVR1
],
1757 base_addr
[CyMSVR2
]);
1759 local_irq_restore(flags
);
1760 set_current_state(TASK_INTERRUPTIBLE
);
1761 if (tty_hung_up_p(filp
)
1762 || !(info
->flags
& ASYNC_INITIALIZED
)) {
1763 if (info
->flags
& ASYNC_HUP_NOTIFY
) {
1766 retval
= -ERESTARTSYS
;
1770 local_irq_save(flags
);
1771 base_addr
[CyCAR
] = (u_char
) channel
;
1772 /* CP('L');CP1(1 && C_CLOCAL(tty)); CP1(1 && (base_addr[CyMSVR1] & CyDCD) ); */
1773 if (!(info
->flags
& ASYNC_CLOSING
)
1775 || (base_addr
[CyMSVR1
] & CyDCD
))) {
1776 local_irq_restore(flags
);
1779 local_irq_restore(flags
);
1780 if (signal_pending(current
)) {
1781 retval
= -ERESTARTSYS
;
1784 #ifdef SERIAL_DEBUG_OPEN
1785 printk("block_til_ready blocking: %s, count = %d\n",
1786 tty
->name
, info
->count
);
1791 __set_current_state(TASK_RUNNING
);
1792 remove_wait_queue(&info
->open_wait
, &wait
);
1793 if (!tty_hung_up_p(filp
)) {
1795 #ifdef SERIAL_DEBUG_COUNT
1796 printk("cyc: %d: incrementing count to %d\n", __LINE__
,
1800 info
->blocked_open
--;
1801 #ifdef SERIAL_DEBUG_OPEN
1802 printk("block_til_ready after blocking: %s, count = %d\n",
1803 tty
->name
, info
->count
);
1808 info
->flags
|= ASYNC_NORMAL_ACTIVE
;
1810 } /* block_til_ready */
1813 * This routine is called whenever a serial port is opened. It
1814 * performs the serial-specific initialization for the tty structure.
1816 int cy_open(struct tty_struct
*tty
, struct file
*filp
)
1818 struct cyclades_port
*info
;
1823 if ((line
< 0) || (NR_PORTS
<= line
)) {
1826 info
= &cy_port
[line
];
1827 if (info
->line
< 0) {
1830 #ifdef SERIAL_DEBUG_OTHER
1831 printk("cy_open %s\n", tty
->name
); /* */
1833 if (serial_paranoia_check(info
, tty
->name
, "cy_open")) {
1836 #ifdef SERIAL_DEBUG_OPEN
1837 printk("cy_open %s, count = %d\n", tty
->name
, info
->count
);
1841 #ifdef SERIAL_DEBUG_COUNT
1842 printk("cyc: %d: incrementing count to %d\n", __LINE__
, info
->count
);
1844 tty
->driver_data
= info
;
1848 * Start up serial port
1850 retval
= startup(info
);
1855 retval
= block_til_ready(tty
, filp
, info
);
1857 #ifdef SERIAL_DEBUG_OPEN
1858 printk("cy_open returning after block_til_ready with %d\n",
1863 #ifdef SERIAL_DEBUG_OPEN
1864 printk("cy_open done\n");
1871 * ---------------------------------------------------------------------
1872 * serial167_init() and friends
1874 * serial167_init() is called at boot-time to initialize the serial driver.
1875 * ---------------------------------------------------------------------
1879 * This routine prints out the appropriate serial driver version
1880 * number, and identifies which options were configured into this
1883 static void show_version(void)
1885 printk("MVME166/167 cd2401 driver\n");
1886 } /* show_version */
1888 /* initialize chips on card -- return number of valid
1889 chips (which is number of ports/4) */
1892 * This initialises the hardware to a reasonable state. It should
1893 * probe the chip first so as to copy 166-Bug setup as a default for
1894 * port 0. It initialises CMR to CyASYNC; that is never done again, so
1895 * as to limit the number of CyINIT_CHAN commands in normal running.
1897 * ... I wonder what I should do if this fails ...
1900 void mvme167_serial_console_setup(int cflag
)
1902 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1905 u_char rcor
, rbpr
, badspeed
= 0;
1906 unsigned long flags
;
1908 local_irq_save(flags
);
1911 * First probe channel zero of the chip, to see what speed has
1915 base_addr
[CyCAR
] = 0;
1917 rcor
= base_addr
[CyRCOR
] << 5;
1918 rbpr
= base_addr
[CyRBPR
];
1920 for (spd
= 0; spd
< sizeof(baud_bpr
); spd
++)
1921 if (rbpr
== baud_bpr
[spd
] && rcor
== baud_co
[spd
])
1923 if (spd
>= sizeof(baud_bpr
)) {
1924 spd
= 14; /* 19200 */
1925 badspeed
= 1; /* Failed to identify speed */
1927 initial_console_speed
= spd
;
1929 /* OK, we have chosen a speed, now reset and reinitialise */
1931 my_udelay(20000L); /* Allow time for any active o/p to complete */
1932 if (base_addr
[CyCCR
] != 0x00) {
1933 local_irq_restore(flags
);
1934 /* printk(" chip is never idle (CCR != 0)\n"); */
1938 base_addr
[CyCCR
] = CyCHIP_RESET
; /* Reset the chip */
1941 if (base_addr
[CyGFRCR
] == 0x00) {
1942 local_irq_restore(flags
);
1943 /* printk(" chip is not responding (GFRCR stayed 0)\n"); */
1948 * System clock is 20Mhz, divided by 2048, so divide by 10 for a 1.0ms
1952 base_addr
[CyTPR
] = 10;
1954 base_addr
[CyPILR1
] = 0x01; /* Interrupt level for modem change */
1955 base_addr
[CyPILR2
] = 0x02; /* Interrupt level for tx ints */
1956 base_addr
[CyPILR3
] = 0x03; /* Interrupt level for rx ints */
1959 * Attempt to set up all channels to something reasonable, and
1960 * bang out a INIT_CHAN command. We should then be able to limit
1961 * the amount of fiddling we have to do in normal running.
1964 for (ch
= 3; ch
>= 0; ch
--) {
1965 base_addr
[CyCAR
] = (u_char
) ch
;
1966 base_addr
[CyIER
] = 0;
1967 base_addr
[CyCMR
] = CyASYNC
;
1968 base_addr
[CyLICR
] = (u_char
) ch
<< 2;
1969 base_addr
[CyLIVR
] = 0x5c;
1970 base_addr
[CyTCOR
] = baud_co
[spd
];
1971 base_addr
[CyTBPR
] = baud_bpr
[spd
];
1972 base_addr
[CyRCOR
] = baud_co
[spd
] >> 5;
1973 base_addr
[CyRBPR
] = baud_bpr
[spd
];
1974 base_addr
[CySCHR1
] = 'Q' & 0x1f;
1975 base_addr
[CySCHR2
] = 'X' & 0x1f;
1976 base_addr
[CySCRL
] = 0;
1977 base_addr
[CySCRH
] = 0;
1978 base_addr
[CyCOR1
] = Cy_8_BITS
| CyPARITY_NONE
;
1979 base_addr
[CyCOR2
] = 0;
1980 base_addr
[CyCOR3
] = Cy_1_STOP
;
1981 base_addr
[CyCOR4
] = baud_cor4
[spd
];
1982 base_addr
[CyCOR5
] = 0;
1983 base_addr
[CyCOR6
] = 0;
1984 base_addr
[CyCOR7
] = 0;
1985 base_addr
[CyRTPRL
] = 2;
1986 base_addr
[CyRTPRH
] = 0;
1987 base_addr
[CyMSVR1
] = 0;
1988 base_addr
[CyMSVR2
] = 0;
1989 write_cy_cmd(base_addr
, CyINIT_CHAN
| CyDIS_RCVR
| CyDIS_XMTR
);
1993 * Now do specials for channel zero....
1996 base_addr
[CyMSVR1
] = CyRTS
;
1997 base_addr
[CyMSVR2
] = CyDTR
;
1998 base_addr
[CyIER
] = CyRxData
;
1999 write_cy_cmd(base_addr
, CyENB_RCVR
| CyENB_XMTR
);
2001 local_irq_restore(flags
);
2003 my_udelay(20000L); /* Let it all settle down */
2005 printk("CD2401 initialised, chip is rev 0x%02x\n", base_addr
[CyGFRCR
]);
2008 (" WARNING: Failed to identify line speed, rcor=%02x,rbpr=%02x\n",
2010 } /* serial_console_init */
2012 static const struct tty_operations cy_ops
= {
2016 .put_char
= cy_put_char
,
2017 .flush_chars
= cy_flush_chars
,
2018 .write_room
= cy_write_room
,
2019 .chars_in_buffer
= cy_chars_in_buffer
,
2020 .flush_buffer
= cy_flush_buffer
,
2022 .throttle
= cy_throttle
,
2023 .unthrottle
= cy_unthrottle
,
2024 .set_termios
= cy_set_termios
,
2027 .hangup
= cy_hangup
,
2028 .tiocmget
= cy_tiocmget
,
2029 .tiocmset
= cy_tiocmset
,
2032 /* The serial driver boot-time initialization code!
2033 Hardware I/O ports are mapped to character special devices on a
2034 first found, first allocated manner. That is, this code searches
2035 for Cyclom cards in the system. As each is found, it is probed
2036 to discover how many chips (and thus how many ports) are present.
2037 These ports are mapped to the tty ports 64 and upward in monotonic
2038 fashion. If an 8-port card is replaced with a 16-port card, the
2039 port mapping on a following card will shift.
2041 This approach is different from what is used in the other serial
2042 device driver because the Cyclom is more properly a multiplexer,
2043 not just an aggregation of serial ports on one card.
2045 If there are more cards with more ports than have been statically
2046 allocated above, a warning is printed and the extra ports are ignored.
2048 static int __init
serial167_init(void)
2050 struct cyclades_port
*info
;
2057 struct sigaction sa
;
2060 if (!(mvme16x_config
& MVME16x_CONFIG_GOT_CD2401
))
2063 cy_serial_driver
= alloc_tty_driver(NR_PORTS
);
2064 if (!cy_serial_driver
)
2073 /* Has "console=0,9600n8" been used in bootinfo to change speed? */
2074 if (serial_console_cflag
)
2075 DefSpeed
= serial_console_cflag
& 0017;
2077 DefSpeed
= initial_console_speed
;
2078 serial_console_info
= &cy_port
[0];
2079 serial_console_cflag
= DefSpeed
| CS8
;
2081 serial_console
= 64; /*callout_driver.minor_start */
2085 /* Initialize the tty_driver structure */
2087 cy_serial_driver
->owner
= THIS_MODULE
;
2088 cy_serial_driver
->name
= "ttyS";
2089 cy_serial_driver
->major
= TTY_MAJOR
;
2090 cy_serial_driver
->minor_start
= 64;
2091 cy_serial_driver
->type
= TTY_DRIVER_TYPE_SERIAL
;
2092 cy_serial_driver
->subtype
= SERIAL_TYPE_NORMAL
;
2093 cy_serial_driver
->init_termios
= tty_std_termios
;
2094 cy_serial_driver
->init_termios
.c_cflag
=
2095 B9600
| CS8
| CREAD
| HUPCL
| CLOCAL
;
2096 cy_serial_driver
->flags
= TTY_DRIVER_REAL_RAW
;
2097 tty_set_operations(cy_serial_driver
, &cy_ops
);
2099 ret
= tty_register_driver(cy_serial_driver
);
2101 printk(KERN_ERR
"Couldn't register MVME166/7 serial driver\n");
2102 put_tty_driver(cy_serial_driver
);
2108 for (index
= 0; index
< 1; index
++) {
2112 if (port_num
< NR_PORTS
) {
2113 while (good_ports
-- && port_num
< NR_PORTS
) {
2114 /*** initialize port ***/
2115 info
->magic
= CYCLADES_MAGIC
;
2116 info
->type
= PORT_CIRRUS
;
2118 info
->line
= port_num
;
2119 info
->flags
= STD_COM_FLAGS
;
2121 info
->xmit_fifo_size
= 12;
2122 info
->cor1
= CyPARITY_NONE
| Cy_8_BITS
;
2124 info
->cor3
= Cy_1_STOP
;
2125 info
->cor4
= 0x08; /* _very_ small receive threshold */
2129 info
->tbpr
= baud_bpr
[DefSpeed
]; /* Tx BPR */
2130 info
->tco
= baud_co
[DefSpeed
]; /* Tx CO */
2131 info
->rbpr
= baud_bpr
[DefSpeed
]; /* Rx BPR */
2132 info
->rco
= baud_co
[DefSpeed
] >> 5; /* Rx CO */
2133 info
->close_delay
= 0;
2136 #ifdef SERIAL_DEBUG_COUNT
2137 printk("cyc: %d: setting count to 0\n",
2140 info
->blocked_open
= 0;
2141 info
->default_threshold
= 0;
2142 info
->default_timeout
= 0;
2143 init_waitqueue_head(&info
->open_wait
);
2144 init_waitqueue_head(&info
->close_wait
);
2147 /*** !!!!!!!! this may expose new bugs !!!!!!!!! *********/
2148 info
->read_status_mask
=
2149 CyTIMEOUT
| CySPECHAR
| CyBREAK
| CyPARITY
|
2150 CyFRAME
| CyOVERRUN
;
2153 printk("ttyS%d ", info
->line
);
2156 if (!(port_num
& 7)) {
2163 while (port_num
< NR_PORTS
) {
2169 ret
= request_irq(MVME167_IRQ_SER_ERR
, cd2401_rxerr_interrupt
, 0,
2170 "cd2401_errors", cd2401_rxerr_interrupt
);
2172 printk(KERN_ERR
"Could't get cd2401_errors IRQ");
2173 goto cleanup_serial_driver
;
2176 ret
= request_irq(MVME167_IRQ_SER_MODEM
, cd2401_modem_interrupt
, 0,
2177 "cd2401_modem", cd2401_modem_interrupt
);
2179 printk(KERN_ERR
"Could't get cd2401_modem IRQ");
2180 goto cleanup_irq_cd2401_errors
;
2183 ret
= request_irq(MVME167_IRQ_SER_TX
, cd2401_tx_interrupt
, 0,
2184 "cd2401_txints", cd2401_tx_interrupt
);
2186 printk(KERN_ERR
"Could't get cd2401_txints IRQ");
2187 goto cleanup_irq_cd2401_modem
;
2190 ret
= request_irq(MVME167_IRQ_SER_RX
, cd2401_rx_interrupt
, 0,
2191 "cd2401_rxints", cd2401_rx_interrupt
);
2193 printk(KERN_ERR
"Could't get cd2401_rxints IRQ");
2194 goto cleanup_irq_cd2401_txints
;
2197 /* Now we have registered the interrupt handlers, allow the interrupts */
2199 pcc2chip
[PccSCCMICR
] = 0x15; /* Serial ints are level 5 */
2200 pcc2chip
[PccSCCTICR
] = 0x15;
2201 pcc2chip
[PccSCCRICR
] = 0x15;
2203 pcc2chip
[PccIMLR
] = 3; /* Allow PCC2 ints above 3!? */
2206 cleanup_irq_cd2401_txints
:
2207 free_irq(MVME167_IRQ_SER_TX
, cd2401_tx_interrupt
);
2208 cleanup_irq_cd2401_modem
:
2209 free_irq(MVME167_IRQ_SER_MODEM
, cd2401_modem_interrupt
);
2210 cleanup_irq_cd2401_errors
:
2211 free_irq(MVME167_IRQ_SER_ERR
, cd2401_rxerr_interrupt
);
2212 cleanup_serial_driver
:
2213 if (tty_unregister_driver(cy_serial_driver
))
2215 "Couldn't unregister MVME166/7 serial driver\n");
2216 put_tty_driver(cy_serial_driver
);
2218 } /* serial167_init */
2220 module_init(serial167_init
);
2222 #ifdef CYCLOM_SHOW_STATUS
2223 static void show_status(int line_num
)
2225 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
2227 struct cyclades_port
*info
;
2228 unsigned long flags
;
2230 info
= &cy_port
[line_num
];
2231 channel
= info
->line
;
2232 printk(" channel %d\n", channel
);
2233 /**/ printk(" cy_port\n");
2234 printk(" card line flags = %d %d %x\n",
2235 info
->card
, info
->line
, info
->flags
);
2237 (" *tty read_status_mask timeout xmit_fifo_size = %lx %x %x %x\n",
2238 (long)info
->tty
, info
->read_status_mask
, info
->timeout
,
2239 info
->xmit_fifo_size
);
2240 printk(" cor1,cor2,cor3,cor4,cor5,cor6,cor7 = %x %x %x %x %x %x %x\n",
2241 info
->cor1
, info
->cor2
, info
->cor3
, info
->cor4
, info
->cor5
,
2242 info
->cor6
, info
->cor7
);
2243 printk(" tbpr,tco,rbpr,rco = %d %d %d %d\n", info
->tbpr
, info
->tco
,
2244 info
->rbpr
, info
->rco
);
2245 printk(" close_delay event count = %d %d %d\n", info
->close_delay
,
2246 info
->event
, info
->count
);
2247 printk(" x_char blocked_open = %x %x\n", info
->x_char
,
2248 info
->blocked_open
);
2249 printk(" open_wait = %lx %lx %lx\n", (long)info
->open_wait
);
2251 local_irq_save(flags
);
2253 /* Global Registers */
2255 printk(" CyGFRCR %x\n", base_addr
[CyGFRCR
]);
2256 printk(" CyCAR %x\n", base_addr
[CyCAR
]);
2257 printk(" CyRISR %x\n", base_addr
[CyRISR
]);
2258 printk(" CyTISR %x\n", base_addr
[CyTISR
]);
2259 printk(" CyMISR %x\n", base_addr
[CyMISR
]);
2260 printk(" CyRIR %x\n", base_addr
[CyRIR
]);
2261 printk(" CyTIR %x\n", base_addr
[CyTIR
]);
2262 printk(" CyMIR %x\n", base_addr
[CyMIR
]);
2263 printk(" CyTPR %x\n", base_addr
[CyTPR
]);
2265 base_addr
[CyCAR
] = (u_char
) channel
;
2267 /* Virtual Registers */
2270 printk(" CyRIVR %x\n", base_addr
[CyRIVR
]);
2271 printk(" CyTIVR %x\n", base_addr
[CyTIVR
]);
2272 printk(" CyMIVR %x\n", base_addr
[CyMIVR
]);
2273 printk(" CyMISR %x\n", base_addr
[CyMISR
]);
2276 /* Channel Registers */
2278 printk(" CyCCR %x\n", base_addr
[CyCCR
]);
2279 printk(" CyIER %x\n", base_addr
[CyIER
]);
2280 printk(" CyCOR1 %x\n", base_addr
[CyCOR1
]);
2281 printk(" CyCOR2 %x\n", base_addr
[CyCOR2
]);
2282 printk(" CyCOR3 %x\n", base_addr
[CyCOR3
]);
2283 printk(" CyCOR4 %x\n", base_addr
[CyCOR4
]);
2284 printk(" CyCOR5 %x\n", base_addr
[CyCOR5
]);
2286 printk(" CyCCSR %x\n", base_addr
[CyCCSR
]);
2287 printk(" CyRDCR %x\n", base_addr
[CyRDCR
]);
2289 printk(" CySCHR1 %x\n", base_addr
[CySCHR1
]);
2290 printk(" CySCHR2 %x\n", base_addr
[CySCHR2
]);
2292 printk(" CySCHR3 %x\n", base_addr
[CySCHR3
]);
2293 printk(" CySCHR4 %x\n", base_addr
[CySCHR4
]);
2294 printk(" CySCRL %x\n", base_addr
[CySCRL
]);
2295 printk(" CySCRH %x\n", base_addr
[CySCRH
]);
2296 printk(" CyLNC %x\n", base_addr
[CyLNC
]);
2297 printk(" CyMCOR1 %x\n", base_addr
[CyMCOR1
]);
2298 printk(" CyMCOR2 %x\n", base_addr
[CyMCOR2
]);
2300 printk(" CyRTPRL %x\n", base_addr
[CyRTPRL
]);
2301 printk(" CyRTPRH %x\n", base_addr
[CyRTPRH
]);
2302 printk(" CyMSVR1 %x\n", base_addr
[CyMSVR1
]);
2303 printk(" CyMSVR2 %x\n", base_addr
[CyMSVR2
]);
2304 printk(" CyRBPR %x\n", base_addr
[CyRBPR
]);
2305 printk(" CyRCOR %x\n", base_addr
[CyRCOR
]);
2306 printk(" CyTBPR %x\n", base_addr
[CyTBPR
]);
2307 printk(" CyTCOR %x\n", base_addr
[CyTCOR
]);
2309 local_irq_restore(flags
);
2314 /* Dummy routine in mvme16x/config.c for now */
2316 /* Serial console setup. Called from linux/init/main.c */
2318 void console_setup(char *str
, int *ints
)
2321 int baud
, bits
, parity
;
2325 if (ints
[0] > 3 || ints
[1] > 3)
2328 /* Get baud, bits and parity */
2334 if ((s
= strchr(str
, ','))) {
2337 } while (*s
>= '0' && *s
<= '9');
2344 /* Now construct a cflag setting. */
2383 serial_console_info
= &cy_port
[ints
[1]];
2384 serial_console_cflag
= cflag
;
2385 serial_console
= ints
[1] + 64; /*callout_driver.minor_start */
2390 * The following is probably out of date for 2.1.x serial console stuff.
2392 * The console is registered early on from arch/m68k/kernel/setup.c, and
2393 * it therefore relies on the chip being setup correctly by 166-Bug. This
2394 * seems reasonable, as the serial port has been used to invoke the system
2395 * boot. It also means that this function must not rely on any data
2396 * initialisation performed by serial167_init() etc.
2398 * Of course, once the console has been registered, we had better ensure
2399 * that serial167_init() doesn't leave the chip non-functional.
2401 * The console must be locked when we get here.
2404 void serial167_console_write(struct console
*co
, const char *str
,
2407 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
2408 unsigned long flags
;
2409 volatile u_char sink
;
2415 local_irq_save(flags
);
2417 /* Ensure transmitter is enabled! */
2420 base_addr
[CyCAR
] = (u_char
) port
;
2421 while (base_addr
[CyCCR
])
2423 base_addr
[CyCCR
] = CyENB_XMTR
;
2425 ier
= base_addr
[CyIER
];
2426 base_addr
[CyIER
] = CyTxMpty
;
2429 if (pcc2chip
[PccSCCTICR
] & 0x20) {
2430 /* We have a Tx int. Acknowledge it */
2431 sink
= pcc2chip
[PccTPIACKR
];
2432 if ((base_addr
[CyLICR
] >> 2) == port
) {
2434 /* Last char of string is now output */
2435 base_addr
[CyTEOIR
] = CyNOTRANS
;
2439 base_addr
[CyTDR
] = '\n';
2443 } else if (*str
== '\n') {
2444 base_addr
[CyTDR
] = '\r';
2447 base_addr
[CyTDR
] = *str
++;
2450 base_addr
[CyTEOIR
] = 0;
2452 base_addr
[CyTEOIR
] = CyNOTRANS
;
2456 base_addr
[CyIER
] = ier
;
2458 local_irq_restore(flags
);
2461 static struct tty_driver
*serial167_console_device(struct console
*c
,
2465 return cy_serial_driver
;
2468 static struct console sercons
= {
2470 .write
= serial167_console_write
,
2471 .device
= serial167_console_device
,
2472 .flags
= CON_PRINTBUFFER
,
2476 static int __init
serial167_console_init(void)
2478 if (vme_brdtype
== VME_TYPE_MVME166
||
2479 vme_brdtype
== VME_TYPE_MVME167
||
2480 vme_brdtype
== VME_TYPE_MVME177
) {
2481 mvme167_serial_console_setup(0);
2482 register_console(&sercons
);
2487 console_initcall(serial167_console_init
);
2489 MODULE_LICENSE("GPL");