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/string.h>
56 #include <linux/fcntl.h>
57 #include <linux/ptrace.h>
58 #include <linux/serial167.h>
59 #include <linux/delay.h>
60 #include <linux/major.h>
62 #include <linux/console.h>
63 #include <linux/module.h>
64 #include <linux/bitops.h>
65 #include <linux/tty_flip.h>
66 #include <linux/gfp.h>
68 #include <asm/system.h>
70 #include <asm/mvme16xhw.h>
71 #include <asm/bootinfo.h>
72 #include <asm/setup.h>
74 #include <linux/types.h>
75 #include <linux/kernel.h>
77 #include <asm/uaccess.h>
78 #include <linux/init.h>
80 #define SERIAL_PARANOIA_CHECK
81 #undef SERIAL_DEBUG_OPEN
82 #undef SERIAL_DEBUG_THROTTLE
83 #undef SERIAL_DEBUG_OTHER
84 #undef SERIAL_DEBUG_IO
85 #undef SERIAL_DEBUG_COUNT
86 #undef SERIAL_DEBUG_DTR
87 #undef CYCLOM_16Y_HACK
88 #define CYCLOM_ENABLE_MONITORING
90 #define WAKEUP_CHARS 256
92 #define STD_COM_FLAGS (0)
94 static struct tty_driver
*cy_serial_driver
;
95 extern int serial_console
;
96 static struct cyclades_port
*serial_console_info
= NULL
;
97 static unsigned int serial_console_cflag
= 0;
98 u_char initial_console_speed
;
100 /* Base address of cd2401 chip on mvme166/7 */
102 #define BASE_ADDR (0xfff45000)
103 #define pcc2chip ((volatile u_char *)0xfff42000)
104 #define PccSCCMICR 0x1d
105 #define PccSCCTICR 0x1e
106 #define PccSCCRICR 0x1f
107 #define PccTPIACKR 0x25
108 #define PccRPIACKR 0x27
111 /* This is the per-port data structure */
112 struct cyclades_port cy_port
[] = {
120 #define NR_PORTS ARRAY_SIZE(cy_port)
123 * This is used to look up the divisor speeds and the timeouts
124 * We're normally limited to 15 distinct baud rates. The extra
125 * are accessed via settings in info->flags.
126 * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
127 * 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
130 static int baud_table
[] = {
131 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
132 1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200, 150000,
137 static char baud_co
[] = { /* 25 MHz clock option table */
138 /* value => 00 01 02 03 04 */
139 /* divide by 8 32 128 512 2048 */
140 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02,
141 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
144 static char baud_bpr
[] = { /* 25 MHz baud rate period table */
145 0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3,
146 0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15
150 /* I think 166 brd clocks 2401 at 20MHz.... */
152 /* These values are written directly to tcor, and >> 5 for writing to rcor */
153 static u_char baud_co
[] = { /* 20 MHz clock option table */
154 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x60, 0x60, 0x40,
155 0x40, 0x40, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
158 /* These values written directly to tbpr/rbpr */
159 static u_char baud_bpr
[] = { /* 20 MHz baud rate period table */
160 0x00, 0xc0, 0x80, 0x58, 0x6c, 0x40, 0xc0, 0x81, 0x40, 0x81,
161 0x57, 0x40, 0x81, 0x40, 0x81, 0x40, 0x2b, 0x20, 0x15, 0x10
164 static u_char baud_cor4
[] = { /* receive threshold */
165 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
166 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07
169 static void shutdown(struct cyclades_port
*);
170 static int startup(struct cyclades_port
*);
171 static void cy_throttle(struct tty_struct
*);
172 static void cy_unthrottle(struct tty_struct
*);
173 static void config_setup(struct cyclades_port
*);
174 #ifdef CYCLOM_SHOW_STATUS
175 static void show_status(int);
179 * I have my own version of udelay(), as it is needed when initialising
180 * the chip, before the delay loop has been calibrated. Should probably
181 * reference one of the vmechip2 or pccchip2 counter for an accurate
182 * delay, but this wild guess will do for now.
185 void my_udelay(long us
)
188 volatile u_char
*p
= &x
;
192 for (i
= 100; i
; i
--)
196 static inline int serial_paranoia_check(struct cyclades_port
*info
, char *name
,
199 #ifdef SERIAL_PARANOIA_CHECK
201 printk("Warning: null cyclades_port for (%s) in %s\n", name
,
206 if (info
< &cy_port
[0] || info
>= &cy_port
[NR_PORTS
]) {
207 printk("Warning: cyclades_port out of range for (%s) in %s\n",
212 if (info
->magic
!= CYCLADES_MAGIC
) {
213 printk("Warning: bad magic number for serial struct (%s) in "
214 "%s\n", name
, routine
);
219 } /* serial_paranoia_check */
222 /* The following diagnostic routines allow the driver to spew
223 information on the screen, even (especially!) during interrupts.
228 local_irq_save(flags
);
229 printk(KERN_EMERG
"%s", data
);
230 local_irq_restore(flags
);
237 local_irq_save(flags
);
239 printk(KERN_EMERG
"%c", scrn
);
240 local_irq_restore(flags
);
245 (data
< 10) ? CP(data
+ '0') : CP(data
+ 'A' - 10);
249 CP1((data
>> 4) & 0x0f);
254 CP2((data
>> 8) & 0xff);
259 CP4((data
>> 16) & 0xffff);
264 /* This routine waits up to 1000 micro-seconds for the previous
265 command to the Cirrus chip to complete and then issues the
266 new command. An error is returned if the previous command
267 didn't finish within the time limit.
269 u_short
write_cy_cmd(volatile u_char
* base_addr
, u_char cmd
)
274 local_irq_save(flags
);
275 /* Check to see that the previous command has completed */
276 for (i
= 0; i
< 100; i
++) {
277 if (base_addr
[CyCCR
] == 0) {
282 /* if the CCR never cleared, the previous command
283 didn't finish within the "reasonable time" */
285 local_irq_restore(flags
);
289 /* Issue the new command */
290 base_addr
[CyCCR
] = cmd
;
291 local_irq_restore(flags
);
295 /* cy_start and cy_stop provide software output flow control as a
296 function of XON/XOFF, software CTS, and other such stuff. */
298 static void cy_stop(struct tty_struct
*tty
)
300 struct cyclades_port
*info
= tty
->driver_data
;
301 volatile unsigned char *base_addr
= (unsigned char *)BASE_ADDR
;
305 #ifdef SERIAL_DEBUG_OTHER
306 printk("cy_stop %s\n", tty
->name
); /* */
309 if (serial_paranoia_check(info
, tty
->name
, "cy_stop"))
312 channel
= info
->line
;
314 local_irq_save(flags
);
315 base_addr
[CyCAR
] = (u_char
) (channel
); /* index channel */
316 base_addr
[CyIER
] &= ~(CyTxMpty
| CyTxRdy
);
317 local_irq_restore(flags
);
320 static void cy_start(struct tty_struct
*tty
)
322 struct cyclades_port
*info
= tty
->driver_data
;
323 volatile unsigned char *base_addr
= (unsigned char *)BASE_ADDR
;
327 #ifdef SERIAL_DEBUG_OTHER
328 printk("cy_start %s\n", tty
->name
); /* */
331 if (serial_paranoia_check(info
, tty
->name
, "cy_start"))
334 channel
= info
->line
;
336 local_irq_save(flags
);
337 base_addr
[CyCAR
] = (u_char
) (channel
);
338 base_addr
[CyIER
] |= CyTxMpty
;
339 local_irq_restore(flags
);
342 /* The real interrupt service routines are called
343 whenever the card wants its hand held--chars
344 received, out buffer empty, modem change, etc.
346 static irqreturn_t
cd2401_rxerr_interrupt(int irq
, void *dev_id
)
348 struct tty_struct
*tty
;
349 struct cyclades_port
*info
;
350 volatile unsigned char *base_addr
= (unsigned char *)BASE_ADDR
;
351 unsigned char err
, rfoc
;
355 /* determine the channel and change to that context */
356 channel
= (u_short
) (base_addr
[CyLICR
] >> 2);
357 info
= &cy_port
[channel
];
358 info
->last_active
= jiffies
;
360 if ((err
= base_addr
[CyRISR
]) & CyTIMEOUT
) {
361 /* This is a receive timeout interrupt, ignore it */
362 base_addr
[CyREOIR
] = CyNOTRANS
;
366 /* Read a byte of data if there is any - assume the error
367 * is associated with this character */
369 if ((rfoc
= base_addr
[CyRFOC
]) != 0)
370 data
= base_addr
[CyRDR
];
374 /* if there is nowhere to put the data, discard it */
375 if (info
->tty
== 0) {
376 base_addr
[CyREOIR
] = rfoc
? 0 : CyNOTRANS
;
378 } else { /* there is an open port for this data */
380 if (err
& info
->ignore_status_mask
) {
381 base_addr
[CyREOIR
] = rfoc
? 0 : CyNOTRANS
;
384 if (tty_buffer_request_room(tty
, 1) != 0) {
385 if (err
& info
->read_status_mask
) {
387 tty_insert_flip_char(tty
, data
,
389 if (info
->flags
& ASYNC_SAK
) {
392 } else if (err
& CyFRAME
) {
393 tty_insert_flip_char(tty
, data
,
395 } else if (err
& CyPARITY
) {
396 tty_insert_flip_char(tty
, data
,
398 } else if (err
& CyOVERRUN
) {
399 tty_insert_flip_char(tty
, 0,
402 If the flip buffer itself is
403 overflowing, we still lose
404 the next incoming character.
406 if (tty_buffer_request_room(tty
, 1) !=
408 tty_insert_flip_char(tty
, data
,
411 /* These two conditions may imply */
412 /* a normal read should be done. */
413 /* else if(data & CyTIMEOUT) */
414 /* else if(data & CySPECHAR) */
416 tty_insert_flip_char(tty
, 0,
420 tty_insert_flip_char(tty
, data
, TTY_NORMAL
);
423 /* there was a software buffer overrun
424 and nothing could be done about it!!! */
427 tty_schedule_flip(tty
);
429 base_addr
[CyREOIR
] = rfoc
? 0 : CyNOTRANS
;
431 } /* cy_rxerr_interrupt */
433 static irqreturn_t
cd2401_modem_interrupt(int irq
, void *dev_id
)
435 struct cyclades_port
*info
;
436 volatile unsigned char *base_addr
= (unsigned char *)BASE_ADDR
;
441 /* determine the channel and change to that context */
442 channel
= (u_short
) (base_addr
[CyLICR
] >> 2);
443 info
= &cy_port
[channel
];
444 info
->last_active
= jiffies
;
446 mdm_change
= base_addr
[CyMISR
];
447 mdm_status
= base_addr
[CyMSVR1
];
449 if (info
->tty
== 0) { /* nowhere to put the data, ignore it */
452 if ((mdm_change
& CyDCD
)
453 && (info
->flags
& ASYNC_CHECK_CD
)) {
454 if (mdm_status
& CyDCD
) {
456 wake_up_interruptible(&info
->open_wait
);
459 tty_hangup(info
->tty
);
460 wake_up_interruptible(&info
->open_wait
);
461 info
->flags
&= ~ASYNC_NORMAL_ACTIVE
;
464 if ((mdm_change
& CyCTS
)
465 && (info
->flags
& ASYNC_CTS_FLOW
)) {
466 if (info
->tty
->stopped
) {
467 if (mdm_status
& CyCTS
) {
468 /* !!! cy_start isn't used because... */
469 info
->tty
->stopped
= 0;
470 base_addr
[CyIER
] |= CyTxMpty
;
471 tty_wakeup(info
->tty
);
474 if (!(mdm_status
& CyCTS
)) {
475 /* !!! cy_stop isn't used because... */
476 info
->tty
->stopped
= 1;
478 ~(CyTxMpty
| CyTxRdy
);
482 if (mdm_status
& CyDSR
) {
485 base_addr
[CyMEOIR
] = 0;
487 } /* cy_modem_interrupt */
489 static irqreturn_t
cd2401_tx_interrupt(int irq
, void *dev_id
)
491 struct cyclades_port
*info
;
492 volatile unsigned char *base_addr
= (unsigned char *)BASE_ADDR
;
494 int char_count
, saved_cnt
;
497 /* determine the channel and change to that context */
498 channel
= (u_short
) (base_addr
[CyLICR
] >> 2);
500 /* validate the port number (as configured and open) */
501 if ((channel
< 0) || (NR_PORTS
<= channel
)) {
502 base_addr
[CyIER
] &= ~(CyTxMpty
| CyTxRdy
);
503 base_addr
[CyTEOIR
] = CyNOTRANS
;
506 info
= &cy_port
[channel
];
507 info
->last_active
= jiffies
;
508 if (info
->tty
== 0) {
509 base_addr
[CyIER
] &= ~(CyTxMpty
| CyTxRdy
);
510 base_addr
[CyTEOIR
] = CyNOTRANS
;
514 /* load the on-chip space available for outbound data */
515 saved_cnt
= char_count
= base_addr
[CyTFTC
];
517 if (info
->x_char
) { /* send special char */
518 outch
= info
->x_char
;
519 base_addr
[CyTDR
] = outch
;
525 /* The Cirrus chip requires the "Embedded Transmit
526 Commands" of start break, delay, and end break
527 sequences to be sent. The duration of the
528 break is given in TICs, which runs at HZ
529 (typically 100) and the PPR runs at 200 Hz,
530 so the delay is duration * 200/HZ, and thus a
531 break can run from 1/100 sec to about 5/4 sec.
532 Need to check these values - RGH 141095.
534 base_addr
[CyTDR
] = 0; /* start break */
535 base_addr
[CyTDR
] = 0x81;
536 base_addr
[CyTDR
] = 0; /* delay a bit */
537 base_addr
[CyTDR
] = 0x82;
538 base_addr
[CyTDR
] = info
->x_break
* 200 / HZ
;
539 base_addr
[CyTDR
] = 0; /* terminate break */
540 base_addr
[CyTDR
] = 0x83;
545 while (char_count
> 0) {
546 if (!info
->xmit_cnt
) {
547 base_addr
[CyIER
] &= ~(CyTxMpty
| CyTxRdy
);
550 if (info
->xmit_buf
== 0) {
551 base_addr
[CyIER
] &= ~(CyTxMpty
| CyTxRdy
);
554 if (info
->tty
->stopped
|| info
->tty
->hw_stopped
) {
555 base_addr
[CyIER
] &= ~(CyTxMpty
| CyTxRdy
);
558 /* Because the Embedded Transmit Commands have been
559 enabled, we must check to see if the escape
560 character, NULL, is being sent. If it is, we
561 must ensure that there is room for it to be
562 doubled in the output stream. Therefore we
563 no longer advance the pointer when the character
564 is fetched, but rather wait until after the check
565 for a NULL output character. (This is necessary
566 because there may not be room for the two chars
567 needed to send a NULL.
569 outch
= info
->xmit_buf
[info
->xmit_tail
];
572 info
->xmit_tail
= (info
->xmit_tail
+ 1)
574 base_addr
[CyTDR
] = outch
;
577 if (char_count
> 1) {
579 info
->xmit_tail
= (info
->xmit_tail
+ 1)
581 base_addr
[CyTDR
] = outch
;
582 base_addr
[CyTDR
] = 0;
591 if (info
->xmit_cnt
< WAKEUP_CHARS
)
592 tty_wakeup(info
->tty
);
594 base_addr
[CyTEOIR
] = (char_count
!= saved_cnt
) ? 0 : CyNOTRANS
;
596 } /* cy_tx_interrupt */
598 static irqreturn_t
cd2401_rx_interrupt(int irq
, void *dev_id
)
600 struct tty_struct
*tty
;
601 struct cyclades_port
*info
;
602 volatile unsigned char *base_addr
= (unsigned char *)BASE_ADDR
;
608 /* determine the channel and change to that context */
609 channel
= (u_short
) (base_addr
[CyLICR
] >> 2);
610 info
= &cy_port
[channel
];
611 info
->last_active
= jiffies
;
612 save_cnt
= char_count
= base_addr
[CyRFOC
];
614 /* if there is nowhere to put the data, discard it */
615 if (info
->tty
== 0) {
616 while (char_count
--) {
617 data
= base_addr
[CyRDR
];
619 } else { /* there is an open port for this data */
621 /* load # characters available from the chip */
623 #ifdef CYCLOM_ENABLE_MONITORING
624 ++info
->mon
.int_count
;
625 info
->mon
.char_count
+= char_count
;
626 if (char_count
> info
->mon
.char_max
)
627 info
->mon
.char_max
= char_count
;
628 info
->mon
.char_last
= char_count
;
630 while (char_count
--) {
631 data
= base_addr
[CyRDR
];
632 tty_insert_flip_char(tty
, data
, TTY_NORMAL
);
633 #ifdef CYCLOM_16Y_HACK
637 tty_schedule_flip(tty
);
640 base_addr
[CyREOIR
] = save_cnt
? 0 : CyNOTRANS
;
642 } /* cy_rx_interrupt */
644 /* This is called whenever a port becomes active;
645 interrupts are enabled and DTR & RTS are turned on.
647 static int startup(struct cyclades_port
*info
)
650 volatile unsigned char *base_addr
= (unsigned char *)BASE_ADDR
;
653 if (info
->flags
& ASYNC_INITIALIZED
) {
659 set_bit(TTY_IO_ERROR
, &info
->tty
->flags
);
663 if (!info
->xmit_buf
) {
664 info
->xmit_buf
= (unsigned char *)get_zeroed_page(GFP_KERNEL
);
665 if (!info
->xmit_buf
) {
672 channel
= info
->line
;
674 #ifdef SERIAL_DEBUG_OPEN
675 printk("startup channel %d\n", channel
);
678 local_irq_save(flags
);
679 base_addr
[CyCAR
] = (u_char
) channel
;
680 write_cy_cmd(base_addr
, CyENB_RCVR
| CyENB_XMTR
);
682 base_addr
[CyCAR
] = (u_char
) channel
; /* !!! Is this needed? */
683 base_addr
[CyMSVR1
] = CyRTS
;
684 /* CP('S');CP('1'); */
685 base_addr
[CyMSVR2
] = CyDTR
;
687 #ifdef SERIAL_DEBUG_DTR
688 printk("cyc: %d: raising DTR\n", __LINE__
);
689 printk(" status: 0x%x, 0x%x\n", base_addr
[CyMSVR1
],
693 base_addr
[CyIER
] |= CyRxData
;
694 info
->flags
|= ASYNC_INITIALIZED
;
697 clear_bit(TTY_IO_ERROR
, &info
->tty
->flags
);
699 info
->xmit_cnt
= info
->xmit_head
= info
->xmit_tail
= 0;
701 local_irq_restore(flags
);
703 #ifdef SERIAL_DEBUG_OPEN
709 void start_xmit(struct cyclades_port
*info
)
712 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
715 channel
= info
->line
;
716 local_irq_save(flags
);
717 base_addr
[CyCAR
] = channel
;
718 base_addr
[CyIER
] |= CyTxMpty
;
719 local_irq_restore(flags
);
723 * This routine shuts down a serial port; interrupts are disabled,
724 * and DTR is dropped if the hangup on close termio flag is on.
726 static void shutdown(struct cyclades_port
*info
)
729 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
732 if (!(info
->flags
& ASYNC_INITIALIZED
)) {
737 channel
= info
->line
;
739 #ifdef SERIAL_DEBUG_OPEN
740 printk("shutdown channel %d\n", channel
);
743 /* !!! REALLY MUST WAIT FOR LAST CHARACTER TO BE
744 SENT BEFORE DROPPING THE LINE !!! (Perhaps
745 set some flag that is read when XMTY happens.)
746 Other choices are to delay some fixed interval
747 or schedule some later processing.
749 local_irq_save(flags
);
750 if (info
->xmit_buf
) {
751 free_page((unsigned long)info
->xmit_buf
);
752 info
->xmit_buf
= NULL
;
755 base_addr
[CyCAR
] = (u_char
) channel
;
756 if (!info
->tty
|| (info
->tty
->termios
->c_cflag
& HUPCL
)) {
757 base_addr
[CyMSVR1
] = 0;
758 /* CP('C');CP('1'); */
759 base_addr
[CyMSVR2
] = 0;
760 #ifdef SERIAL_DEBUG_DTR
761 printk("cyc: %d: dropping DTR\n", __LINE__
);
762 printk(" status: 0x%x, 0x%x\n", base_addr
[CyMSVR1
],
766 write_cy_cmd(base_addr
, CyDIS_RCVR
);
767 /* it may be appropriate to clear _XMIT at
768 some later date (after testing)!!! */
771 set_bit(TTY_IO_ERROR
, &info
->tty
->flags
);
773 info
->flags
&= ~ASYNC_INITIALIZED
;
774 local_irq_restore(flags
);
776 #ifdef SERIAL_DEBUG_OPEN
782 * This routine finds or computes the various line characteristics.
784 static void config_setup(struct cyclades_port
*info
)
787 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
791 unsigned char ti
, need_init_chan
= 0;
793 if (!info
->tty
|| !info
->tty
->termios
) {
796 if (info
->line
== -1) {
799 cflag
= info
->tty
->termios
->c_cflag
;
804 /* Starting with kernel 1.1.65, there is direct support for
805 higher baud rates. The following code supports those
806 changes. The conditional aspect allows this driver to be
807 used for earlier as well as later kernel versions. (The
808 mapping is slightly different from serial.c because there
809 is still the possibility of supporting 75 kbit/sec with
815 else if (i
== B115200
)
818 else if (i
== B78600
)
822 info
->tty
->termios
->c_cflag
&= ~CBAUDEX
;
826 if ((info
->flags
& ASYNC_SPD_MASK
) == ASYNC_SPD_HI
)
828 if ((info
->flags
& ASYNC_SPD_MASK
) == ASYNC_SPD_VHI
)
831 /* Don't ever change the speed of the console port. It will
832 * run at the speed specified in bootinfo, or at 19.2K */
833 /* Actually, it should run at whatever speed 166Bug was using */
834 /* Note info->timeout isn't used at present */
835 if (info
!= serial_console_info
) {
836 info
->tbpr
= baud_bpr
[i
]; /* Tx BPR */
837 info
->tco
= baud_co
[i
]; /* Tx CO */
838 info
->rbpr
= baud_bpr
[i
]; /* Rx BPR */
839 info
->rco
= baud_co
[i
] >> 5; /* Rx CO */
840 if (baud_table
[i
] == 134) {
842 (info
->xmit_fifo_size
* HZ
* 30 / 269) + 2;
843 /* get it right for 134.5 baud */
844 } else if (baud_table
[i
]) {
846 (info
->xmit_fifo_size
* HZ
* 15 / baud_table
[i
]) +
848 /* this needs to be propagated into the card info */
853 /* By tradition (is it a standard?) a baud rate of zero
854 implies the line should be/has been closed. A bit
855 later in this routine such a test is performed. */
857 /* byte size and parity */
861 info
->cor4
= (info
->default_threshold
? info
->default_threshold
: baud_cor4
[i
]); /* receive threshold */
862 /* Following two lines added 101295, RGH. */
863 /* It is obviously wrong to access CyCORx, and not info->corx here,
864 * try and remember to fix it later! */
865 channel
= info
->line
;
866 base_addr
[CyCAR
] = (u_char
) channel
;
867 if (C_CLOCAL(info
->tty
)) {
868 if (base_addr
[CyIER
] & CyMdmCh
)
869 base_addr
[CyIER
] &= ~CyMdmCh
; /* without modem intr */
870 /* ignore 1->0 modem transitions */
871 if (base_addr
[CyCOR4
] & (CyDSR
| CyCTS
| CyDCD
))
872 base_addr
[CyCOR4
] &= ~(CyDSR
| CyCTS
| CyDCD
);
873 /* ignore 0->1 modem transitions */
874 if (base_addr
[CyCOR5
] & (CyDSR
| CyCTS
| CyDCD
))
875 base_addr
[CyCOR5
] &= ~(CyDSR
| CyCTS
| CyDCD
);
877 if ((base_addr
[CyIER
] & CyMdmCh
) != CyMdmCh
)
878 base_addr
[CyIER
] |= CyMdmCh
; /* with modem intr */
879 /* act on 1->0 modem transitions */
880 if ((base_addr
[CyCOR4
] & (CyDSR
| CyCTS
| CyDCD
)) !=
881 (CyDSR
| CyCTS
| CyDCD
))
882 base_addr
[CyCOR4
] |= CyDSR
| CyCTS
| CyDCD
;
883 /* act on 0->1 modem transitions */
884 if ((base_addr
[CyCOR5
] & (CyDSR
| CyCTS
| CyDCD
)) !=
885 (CyDSR
| CyCTS
| CyDCD
))
886 base_addr
[CyCOR5
] |= CyDSR
| CyCTS
| CyDCD
;
888 info
->cor3
= (cflag
& CSTOPB
) ? Cy_2_STOP
: Cy_1_STOP
;
890 switch (cflag
& CSIZE
) {
892 info
->cor1
= Cy_5_BITS
;
895 info
->cor1
= Cy_6_BITS
;
898 info
->cor1
= Cy_7_BITS
;
901 info
->cor1
= Cy_8_BITS
;
904 if (cflag
& PARENB
) {
905 if (cflag
& PARODD
) {
906 info
->cor1
|= CyPARITY_O
;
908 info
->cor1
|= CyPARITY_E
;
911 info
->cor1
|= CyPARITY_NONE
;
914 /* CTS flow control flag */
916 /* Don't complcate matters for now! RGH 141095 */
917 if (cflag
& CRTSCTS
) {
918 info
->flags
|= ASYNC_CTS_FLOW
;
919 info
->cor2
|= CyCtsAE
;
921 info
->flags
&= ~ASYNC_CTS_FLOW
;
922 info
->cor2
&= ~CyCtsAE
;
926 info
->flags
&= ~ASYNC_CHECK_CD
;
928 info
->flags
|= ASYNC_CHECK_CD
;
930 /***********************************************
931 The hardware option, CyRtsAO, presents RTS when
932 the chip has characters to send. Since most modems
933 use RTS as reverse (inbound) flow control, this
934 option is not used. If inbound flow control is
935 necessary, DTR can be programmed to provide the
936 appropriate signals for use with a non-standard
937 cable. Contact Marcio Saito for details.
938 ***********************************************/
940 channel
= info
->line
;
942 local_irq_save(flags
);
943 base_addr
[CyCAR
] = (u_char
) channel
;
945 /* CyCMR set once only in mvme167_init_serial() */
946 if (base_addr
[CyLICR
] != channel
<< 2)
947 base_addr
[CyLICR
] = channel
<< 2;
948 if (base_addr
[CyLIVR
] != 0x5c)
949 base_addr
[CyLIVR
] = 0x5c;
951 /* tx and rx baud rate */
953 if (base_addr
[CyCOR1
] != info
->cor1
)
955 if (base_addr
[CyTCOR
] != info
->tco
)
956 base_addr
[CyTCOR
] = info
->tco
;
957 if (base_addr
[CyTBPR
] != info
->tbpr
)
958 base_addr
[CyTBPR
] = info
->tbpr
;
959 if (base_addr
[CyRCOR
] != info
->rco
)
960 base_addr
[CyRCOR
] = info
->rco
;
961 if (base_addr
[CyRBPR
] != info
->rbpr
)
962 base_addr
[CyRBPR
] = info
->rbpr
;
964 /* set line characteristics according configuration */
966 if (base_addr
[CySCHR1
] != START_CHAR(info
->tty
))
967 base_addr
[CySCHR1
] = START_CHAR(info
->tty
);
968 if (base_addr
[CySCHR2
] != STOP_CHAR(info
->tty
))
969 base_addr
[CySCHR2
] = STOP_CHAR(info
->tty
);
970 if (base_addr
[CySCRL
] != START_CHAR(info
->tty
))
971 base_addr
[CySCRL
] = START_CHAR(info
->tty
);
972 if (base_addr
[CySCRH
] != START_CHAR(info
->tty
))
973 base_addr
[CySCRH
] = START_CHAR(info
->tty
);
974 if (base_addr
[CyCOR1
] != info
->cor1
)
975 base_addr
[CyCOR1
] = info
->cor1
;
976 if (base_addr
[CyCOR2
] != info
->cor2
)
977 base_addr
[CyCOR2
] = info
->cor2
;
978 if (base_addr
[CyCOR3
] != info
->cor3
)
979 base_addr
[CyCOR3
] = info
->cor3
;
980 if (base_addr
[CyCOR4
] != info
->cor4
)
981 base_addr
[CyCOR4
] = info
->cor4
;
982 if (base_addr
[CyCOR5
] != info
->cor5
)
983 base_addr
[CyCOR5
] = info
->cor5
;
984 if (base_addr
[CyCOR6
] != info
->cor6
)
985 base_addr
[CyCOR6
] = info
->cor6
;
986 if (base_addr
[CyCOR7
] != info
->cor7
)
987 base_addr
[CyCOR7
] = info
->cor7
;
990 write_cy_cmd(base_addr
, CyINIT_CHAN
);
992 base_addr
[CyCAR
] = (u_char
) channel
; /* !!! Is this needed? */
994 /* 2ms default rx timeout */
995 ti
= info
->default_timeout
? info
->default_timeout
: 0x02;
996 if (base_addr
[CyRTPRL
] != ti
)
997 base_addr
[CyRTPRL
] = ti
;
998 if (base_addr
[CyRTPRH
] != 0)
999 base_addr
[CyRTPRH
] = 0;
1001 /* Set up RTS here also ????? RGH 141095 */
1002 if (i
== 0) { /* baud rate is zero, turn off line */
1003 if ((base_addr
[CyMSVR2
] & CyDTR
) == CyDTR
)
1004 base_addr
[CyMSVR2
] = 0;
1005 #ifdef SERIAL_DEBUG_DTR
1006 printk("cyc: %d: dropping DTR\n", __LINE__
);
1007 printk(" status: 0x%x, 0x%x\n", base_addr
[CyMSVR1
],
1008 base_addr
[CyMSVR2
]);
1011 if ((base_addr
[CyMSVR2
] & CyDTR
) != CyDTR
)
1012 base_addr
[CyMSVR2
] = CyDTR
;
1013 #ifdef SERIAL_DEBUG_DTR
1014 printk("cyc: %d: raising DTR\n", __LINE__
);
1015 printk(" status: 0x%x, 0x%x\n", base_addr
[CyMSVR1
],
1016 base_addr
[CyMSVR2
]);
1021 clear_bit(TTY_IO_ERROR
, &info
->tty
->flags
);
1024 local_irq_restore(flags
);
1026 } /* config_setup */
1028 static int cy_put_char(struct tty_struct
*tty
, unsigned char ch
)
1030 struct cyclades_port
*info
= tty
->driver_data
;
1031 unsigned long flags
;
1033 #ifdef SERIAL_DEBUG_IO
1034 printk("cy_put_char %s(0x%02x)\n", tty
->name
, ch
);
1037 if (serial_paranoia_check(info
, tty
->name
, "cy_put_char"))
1040 if (!info
->xmit_buf
)
1043 local_irq_save(flags
);
1044 if (info
->xmit_cnt
>= PAGE_SIZE
- 1) {
1045 local_irq_restore(flags
);
1049 info
->xmit_buf
[info
->xmit_head
++] = ch
;
1050 info
->xmit_head
&= PAGE_SIZE
- 1;
1052 local_irq_restore(flags
);
1056 static void cy_flush_chars(struct tty_struct
*tty
)
1058 struct cyclades_port
*info
= tty
->driver_data
;
1059 unsigned long flags
;
1060 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1063 #ifdef SERIAL_DEBUG_IO
1064 printk("cy_flush_chars %s\n", tty
->name
); /* */
1067 if (serial_paranoia_check(info
, tty
->name
, "cy_flush_chars"))
1070 if (info
->xmit_cnt
<= 0 || tty
->stopped
1071 || tty
->hw_stopped
|| !info
->xmit_buf
)
1074 channel
= info
->line
;
1076 local_irq_save(flags
);
1077 base_addr
[CyCAR
] = channel
;
1078 base_addr
[CyIER
] |= CyTxMpty
;
1079 local_irq_restore(flags
);
1080 } /* cy_flush_chars */
1082 /* This routine gets called when tty_write has put something into
1083 the write_queue. If the port is not already transmitting stuff,
1084 start it off by enabling interrupts. The interrupt service
1085 routine will then ensure that the characters are sent. If the
1086 port is already active, there is no need to kick it.
1088 static int cy_write(struct tty_struct
*tty
, const unsigned char *buf
, int count
)
1090 struct cyclades_port
*info
= tty
->driver_data
;
1091 unsigned long flags
;
1094 #ifdef SERIAL_DEBUG_IO
1095 printk("cy_write %s\n", tty
->name
); /* */
1098 if (serial_paranoia_check(info
, tty
->name
, "cy_write")) {
1102 if (!info
->xmit_buf
) {
1107 local_irq_save(flags
);
1108 c
= min_t(int, count
, min(SERIAL_XMIT_SIZE
- info
->xmit_cnt
- 1,
1109 SERIAL_XMIT_SIZE
- info
->xmit_head
));
1111 local_irq_restore(flags
);
1115 memcpy(info
->xmit_buf
+ info
->xmit_head
, buf
, c
);
1117 (info
->xmit_head
+ c
) & (SERIAL_XMIT_SIZE
- 1);
1118 info
->xmit_cnt
+= c
;
1119 local_irq_restore(flags
);
1126 if (info
->xmit_cnt
&& !tty
->stopped
&& !tty
->hw_stopped
) {
1132 static int cy_write_room(struct tty_struct
*tty
)
1134 struct cyclades_port
*info
= tty
->driver_data
;
1137 #ifdef SERIAL_DEBUG_IO
1138 printk("cy_write_room %s\n", tty
->name
); /* */
1141 if (serial_paranoia_check(info
, tty
->name
, "cy_write_room"))
1143 ret
= PAGE_SIZE
- info
->xmit_cnt
- 1;
1147 } /* cy_write_room */
1149 static int cy_chars_in_buffer(struct tty_struct
*tty
)
1151 struct cyclades_port
*info
= tty
->driver_data
;
1153 #ifdef SERIAL_DEBUG_IO
1154 printk("cy_chars_in_buffer %s %d\n", tty
->name
, info
->xmit_cnt
); /* */
1157 if (serial_paranoia_check(info
, tty
->name
, "cy_chars_in_buffer"))
1160 return info
->xmit_cnt
;
1161 } /* cy_chars_in_buffer */
1163 static void cy_flush_buffer(struct tty_struct
*tty
)
1165 struct cyclades_port
*info
= tty
->driver_data
;
1166 unsigned long flags
;
1168 #ifdef SERIAL_DEBUG_IO
1169 printk("cy_flush_buffer %s\n", tty
->name
); /* */
1172 if (serial_paranoia_check(info
, tty
->name
, "cy_flush_buffer"))
1174 local_irq_save(flags
);
1175 info
->xmit_cnt
= info
->xmit_head
= info
->xmit_tail
= 0;
1176 local_irq_restore(flags
);
1178 } /* cy_flush_buffer */
1180 /* This routine is called by the upper-layer tty layer to signal
1181 that incoming characters should be throttled or that the
1182 throttle should be released.
1184 static void cy_throttle(struct tty_struct
*tty
)
1186 struct cyclades_port
*info
= tty
->driver_data
;
1187 unsigned long flags
;
1188 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1191 #ifdef SERIAL_DEBUG_THROTTLE
1194 printk("throttle %s: %d....\n", tty_name(tty
, buf
),
1195 tty
->ldisc
.chars_in_buffer(tty
));
1196 printk("cy_throttle %s\n", tty
->name
);
1199 if (serial_paranoia_check(info
, tty
->name
, "cy_nthrottle")) {
1204 info
->x_char
= STOP_CHAR(tty
);
1205 /* Should use the "Send Special Character" feature!!! */
1208 channel
= info
->line
;
1210 local_irq_save(flags
);
1211 base_addr
[CyCAR
] = (u_char
) channel
;
1212 base_addr
[CyMSVR1
] = 0;
1213 local_irq_restore(flags
);
1216 static void cy_unthrottle(struct tty_struct
*tty
)
1218 struct cyclades_port
*info
= tty
->driver_data
;
1219 unsigned long flags
;
1220 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1223 #ifdef SERIAL_DEBUG_THROTTLE
1226 printk("throttle %s: %d....\n", tty_name(tty
, buf
),
1227 tty
->ldisc
.chars_in_buffer(tty
));
1228 printk("cy_unthrottle %s\n", tty
->name
);
1231 if (serial_paranoia_check(info
, tty
->name
, "cy_nthrottle")) {
1236 info
->x_char
= START_CHAR(tty
);
1237 /* Should use the "Send Special Character" feature!!! */
1240 channel
= info
->line
;
1242 local_irq_save(flags
);
1243 base_addr
[CyCAR
] = (u_char
) channel
;
1244 base_addr
[CyMSVR1
] = CyRTS
;
1245 local_irq_restore(flags
);
1246 } /* cy_unthrottle */
1249 get_serial_info(struct cyclades_port
*info
,
1250 struct serial_struct __user
* retinfo
)
1252 struct serial_struct tmp
;
1257 memset(&tmp
, 0, sizeof(tmp
));
1258 tmp
.type
= info
->type
;
1259 tmp
.line
= info
->line
;
1260 tmp
.port
= info
->line
;
1262 tmp
.flags
= info
->flags
;
1263 tmp
.baud_base
= 0; /*!!! */
1264 tmp
.close_delay
= info
->close_delay
;
1265 tmp
.custom_divisor
= 0; /*!!! */
1266 tmp
.hub6
= 0; /*!!! */
1267 return copy_to_user(retinfo
, &tmp
, sizeof(*retinfo
)) ? -EFAULT
: 0;
1268 } /* get_serial_info */
1271 set_serial_info(struct cyclades_port
*info
,
1272 struct serial_struct __user
* new_info
)
1274 struct serial_struct new_serial
;
1275 struct cyclades_port old_info
;
1280 if (copy_from_user(&new_serial
, new_info
, sizeof(new_serial
)))
1284 if (!capable(CAP_SYS_ADMIN
)) {
1285 if ((new_serial
.close_delay
!= info
->close_delay
) ||
1286 ((new_serial
.flags
& ASYNC_FLAGS
& ~ASYNC_USR_MASK
) !=
1287 (info
->flags
& ASYNC_FLAGS
& ~ASYNC_USR_MASK
)))
1289 info
->flags
= ((info
->flags
& ~ASYNC_USR_MASK
) |
1290 (new_serial
.flags
& ASYNC_USR_MASK
));
1291 goto check_and_exit
;
1295 * OK, past this point, all the error checking has been done.
1296 * At this point, we start making changes.....
1299 info
->flags
= ((info
->flags
& ~ASYNC_FLAGS
) |
1300 (new_serial
.flags
& ASYNC_FLAGS
));
1301 info
->close_delay
= new_serial
.close_delay
;
1304 if (info
->flags
& ASYNC_INITIALIZED
) {
1308 return startup(info
);
1309 } /* set_serial_info */
1311 static int cy_tiocmget(struct tty_struct
*tty
)
1313 struct cyclades_port
*info
= tty
->driver_data
;
1315 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1316 unsigned long flags
;
1317 unsigned char status
;
1319 channel
= info
->line
;
1321 local_irq_save(flags
);
1322 base_addr
[CyCAR
] = (u_char
) channel
;
1323 status
= base_addr
[CyMSVR1
] | base_addr
[CyMSVR2
];
1324 local_irq_restore(flags
);
1326 return ((status
& CyRTS
) ? TIOCM_RTS
: 0)
1327 | ((status
& CyDTR
) ? TIOCM_DTR
: 0)
1328 | ((status
& CyDCD
) ? TIOCM_CAR
: 0)
1329 | ((status
& CyDSR
) ? TIOCM_DSR
: 0)
1330 | ((status
& CyCTS
) ? TIOCM_CTS
: 0);
1334 cy_tiocmset(struct tty_struct
*tty
, unsigned int set
, unsigned int clear
)
1336 struct cyclades_port
*info
= tty
->driver_data
;
1338 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1339 unsigned long flags
;
1341 channel
= info
->line
;
1343 if (set
& TIOCM_RTS
) {
1344 local_irq_save(flags
);
1345 base_addr
[CyCAR
] = (u_char
) channel
;
1346 base_addr
[CyMSVR1
] = CyRTS
;
1347 local_irq_restore(flags
);
1349 if (set
& TIOCM_DTR
) {
1350 local_irq_save(flags
);
1351 base_addr
[CyCAR
] = (u_char
) channel
;
1352 /* CP('S');CP('2'); */
1353 base_addr
[CyMSVR2
] = CyDTR
;
1354 #ifdef SERIAL_DEBUG_DTR
1355 printk("cyc: %d: raising DTR\n", __LINE__
);
1356 printk(" status: 0x%x, 0x%x\n", base_addr
[CyMSVR1
],
1357 base_addr
[CyMSVR2
]);
1359 local_irq_restore(flags
);
1362 if (clear
& TIOCM_RTS
) {
1363 local_irq_save(flags
);
1364 base_addr
[CyCAR
] = (u_char
) channel
;
1365 base_addr
[CyMSVR1
] = 0;
1366 local_irq_restore(flags
);
1368 if (clear
& TIOCM_DTR
) {
1369 local_irq_save(flags
);
1370 base_addr
[CyCAR
] = (u_char
) channel
;
1371 /* CP('C');CP('2'); */
1372 base_addr
[CyMSVR2
] = 0;
1373 #ifdef SERIAL_DEBUG_DTR
1374 printk("cyc: %d: dropping DTR\n", __LINE__
);
1375 printk(" status: 0x%x, 0x%x\n", base_addr
[CyMSVR1
],
1376 base_addr
[CyMSVR2
]);
1378 local_irq_restore(flags
);
1382 } /* set_modem_info */
1384 static void send_break(struct cyclades_port
*info
, int duration
)
1385 { /* Let the transmit ISR take care of this (since it
1386 requires stuffing characters into the output stream).
1388 info
->x_break
= duration
;
1389 if (!info
->xmit_cnt
) {
1395 get_mon_info(struct cyclades_port
*info
, struct cyclades_monitor __user
* mon
)
1398 if (copy_to_user(mon
, &info
->mon
, sizeof(struct cyclades_monitor
)))
1400 info
->mon
.int_count
= 0;
1401 info
->mon
.char_count
= 0;
1402 info
->mon
.char_max
= 0;
1403 info
->mon
.char_last
= 0;
1407 static int set_threshold(struct cyclades_port
*info
, unsigned long __user
* arg
)
1409 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1410 unsigned long value
;
1413 if (get_user(value
, arg
))
1416 channel
= info
->line
;
1417 info
->cor4
&= ~CyREC_FIFO
;
1418 info
->cor4
|= value
& CyREC_FIFO
;
1419 base_addr
[CyCOR4
] = info
->cor4
;
1424 get_threshold(struct cyclades_port
*info
, unsigned long __user
* value
)
1426 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1430 channel
= info
->line
;
1432 tmp
= base_addr
[CyCOR4
] & CyREC_FIFO
;
1433 return put_user(tmp
, value
);
1437 set_default_threshold(struct cyclades_port
*info
, unsigned long __user
* arg
)
1439 unsigned long value
;
1441 if (get_user(value
, arg
))
1444 info
->default_threshold
= value
& 0x0f;
1449 get_default_threshold(struct cyclades_port
*info
, unsigned long __user
* value
)
1451 return put_user(info
->default_threshold
, value
);
1454 static int set_timeout(struct cyclades_port
*info
, unsigned long __user
* arg
)
1456 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1458 unsigned long value
;
1460 if (get_user(value
, arg
))
1463 channel
= info
->line
;
1465 base_addr
[CyRTPRL
] = value
& 0xff;
1466 base_addr
[CyRTPRH
] = (value
>> 8) & 0xff;
1470 static int get_timeout(struct cyclades_port
*info
, unsigned long __user
* value
)
1472 volatile unsigned char *base_addr
= (u_char
*) BASE_ADDR
;
1476 channel
= info
->line
;
1478 tmp
= base_addr
[CyRTPRL
];
1479 return put_user(tmp
, value
);
1482 static int set_default_timeout(struct cyclades_port
*info
, unsigned long value
)
1484 info
->default_timeout
= value
& 0xff;
1489 get_default_timeout(struct cyclades_port
*info
, unsigned long __user
* value
)
1491 return put_user(info
->default_timeout
, value
);
1495 cy_ioctl(struct tty_struct
*tty
,
1496 unsigned int cmd
, unsigned long arg
)
1498 struct cyclades_port
*info
= tty
->driver_data
;
1500 void __user
*argp
= (void __user
*)arg
;
1502 #ifdef SERIAL_DEBUG_OTHER
1503 printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty
->name
, cmd
, arg
); /* */
1510 ret_val
= get_mon_info(info
, argp
);
1513 ret_val
= get_threshold(info
, argp
);
1516 ret_val
= set_threshold(info
, argp
);
1518 case CYGETDEFTHRESH
:
1519 ret_val
= get_default_threshold(info
, argp
);
1521 case CYSETDEFTHRESH
:
1522 ret_val
= set_default_threshold(info
, argp
);
1525 ret_val
= get_timeout(info
, argp
);
1528 ret_val
= set_timeout(info
, argp
);
1530 case CYGETDEFTIMEOUT
:
1531 ret_val
= get_default_timeout(info
, argp
);
1533 case CYSETDEFTIMEOUT
:
1534 ret_val
= set_default_timeout(info
, (unsigned long)arg
);
1536 case TCSBRK
: /* SVID version: non-zero arg --> no break */
1537 ret_val
= tty_check_change(tty
);
1540 tty_wait_until_sent(tty
, 0);
1542 send_break(info
, HZ
/ 4); /* 1/4 second */
1544 case TCSBRKP
: /* support for POSIX tcsendbreak() */
1545 ret_val
= tty_check_change(tty
);
1548 tty_wait_until_sent(tty
, 0);
1549 send_break(info
, arg
? arg
* (HZ
/ 10) : HZ
/ 4);
1552 /* The following commands are incompletely implemented!!! */
1554 ret_val
= get_serial_info(info
, argp
);
1557 ret_val
= set_serial_info(info
, argp
);
1560 ret_val
= -ENOIOCTLCMD
;
1564 #ifdef SERIAL_DEBUG_OTHER
1565 printk("cy_ioctl done\n");
1571 static void cy_set_termios(struct tty_struct
*tty
, struct ktermios
*old_termios
)
1573 struct cyclades_port
*info
= tty
->driver_data
;
1575 #ifdef SERIAL_DEBUG_OTHER
1576 printk("cy_set_termios %s\n", tty
->name
);
1579 if (tty
->termios
->c_cflag
== old_termios
->c_cflag
)
1583 if ((old_termios
->c_cflag
& CRTSCTS
) &&
1584 !(tty
->termios
->c_cflag
& CRTSCTS
)) {
1588 #ifdef tytso_patch_94Nov25_1726
1589 if (!(old_termios
->c_cflag
& CLOCAL
) &&
1590 (tty
->termios
->c_cflag
& CLOCAL
))
1591 wake_up_interruptible(&info
->open_wait
);
1593 } /* cy_set_termios */
1595 static void cy_close(struct tty_struct
*tty
, struct file
*filp
)
1597 struct cyclades_port
*info
= tty
->driver_data
;
1600 #ifdef SERIAL_DEBUG_OTHER
1601 printk("cy_close %s\n", tty
->name
);
1604 if (!info
|| serial_paranoia_check(info
, tty
->name
, "cy_close")) {
1607 #ifdef SERIAL_DEBUG_OPEN
1608 printk("cy_close %s, count = %d\n", tty
->name
, info
->count
);
1611 if ((tty
->count
== 1) && (info
->count
!= 1)) {
1613 * Uh, oh. tty->count is 1, which means that the tty
1614 * structure will be freed. Info->count should always
1615 * be one in these conditions. If it's greater than
1616 * one, we've got real problems, since it means the
1617 * serial port won't be shutdown.
1619 printk("cy_close: bad serial port count; tty->count is 1, "
1620 "info->count is %d\n", info
->count
);
1623 #ifdef SERIAL_DEBUG_COUNT
1624 printk("cyc: %d: decrementing count to %d\n", __LINE__
,
1627 if (--info
->count
< 0) {
1628 printk("cy_close: bad serial port count for ttys%d: %d\n",
1629 info
->line
, info
->count
);
1630 #ifdef SERIAL_DEBUG_COUNT
1631 printk("cyc: %d: setting count to 0\n", __LINE__
);
1637 info
->flags
|= ASYNC_CLOSING
;
1638 if (info
->flags
& ASYNC_INITIALIZED
)
1639 tty_wait_until_sent(tty
, 3000); /* 30 seconds timeout */
1641 cy_flush_buffer(tty
);
1642 tty_ldisc_flush(tty
);
1644 if (info
->blocked_open
) {
1645 if (info
->close_delay
) {
1646 msleep_interruptible(jiffies_to_msecs
1647 (info
->close_delay
));
1649 wake_up_interruptible(&info
->open_wait
);
1651 info
->flags
&= ~(ASYNC_NORMAL_ACTIVE
| ASYNC_CLOSING
);
1652 wake_up_interruptible(&info
->close_wait
);
1654 #ifdef SERIAL_DEBUG_OTHER
1655 printk("cy_close done\n");
1660 * cy_hangup() --- called by tty_hangup() when a hangup is signaled.
1662 void cy_hangup(struct tty_struct
*tty
)
1664 struct cyclades_port
*info
= tty
->driver_data
;
1666 #ifdef SERIAL_DEBUG_OTHER
1667 printk("cy_hangup %s\n", tty
->name
); /* */
1670 if (serial_paranoia_check(info
, tty
->name
, "cy_hangup"))
1677 #ifdef SERIAL_DEBUG_COUNT
1678 printk("cyc: %d: setting count to 0\n", __LINE__
);
1682 info
->flags
&= ~ASYNC_NORMAL_ACTIVE
;
1683 wake_up_interruptible(&info
->open_wait
);
1687 * ------------------------------------------------------------
1688 * cy_open() and friends
1689 * ------------------------------------------------------------
1693 block_til_ready(struct tty_struct
*tty
, struct file
*filp
,
1694 struct cyclades_port
*info
)
1696 DECLARE_WAITQUEUE(wait
, current
);
1697 unsigned long flags
;
1700 volatile u_char
*base_addr
= (u_char
*) BASE_ADDR
;
1703 * If the device is in the middle of being closed, then block
1704 * until it's done, and then try again.
1706 if (info
->flags
& ASYNC_CLOSING
) {
1707 interruptible_sleep_on(&info
->close_wait
);
1708 if (info
->flags
& ASYNC_HUP_NOTIFY
) {
1711 return -ERESTARTSYS
;
1716 * If non-blocking mode is set, then make the check up front
1719 if (filp
->f_flags
& O_NONBLOCK
) {
1720 info
->flags
|= ASYNC_NORMAL_ACTIVE
;
1725 * Block waiting for the carrier detect and the line to become
1726 * free (i.e., not in use by the callout). While we are in
1727 * this loop, info->count is dropped by one, so that
1728 * cy_close() knows when to free things. We restore it upon
1729 * exit, either normal or abnormal.
1732 add_wait_queue(&info
->open_wait
, &wait
);
1733 #ifdef SERIAL_DEBUG_OPEN
1734 printk("block_til_ready before block: %s, count = %d\n",
1735 tty
->name
, info
->count
);
1739 #ifdef SERIAL_DEBUG_COUNT
1740 printk("cyc: %d: decrementing count to %d\n", __LINE__
, info
->count
);
1742 info
->blocked_open
++;
1744 channel
= info
->line
;
1747 local_irq_save(flags
);
1748 base_addr
[CyCAR
] = (u_char
) channel
;
1749 base_addr
[CyMSVR1
] = CyRTS
;
1750 /* CP('S');CP('4'); */
1751 base_addr
[CyMSVR2
] = CyDTR
;
1752 #ifdef SERIAL_DEBUG_DTR
1753 printk("cyc: %d: raising DTR\n", __LINE__
);
1754 printk(" status: 0x%x, 0x%x\n", base_addr
[CyMSVR1
],
1755 base_addr
[CyMSVR2
]);
1757 local_irq_restore(flags
);
1758 set_current_state(TASK_INTERRUPTIBLE
);
1759 if (tty_hung_up_p(filp
)
1760 || !(info
->flags
& ASYNC_INITIALIZED
)) {
1761 if (info
->flags
& ASYNC_HUP_NOTIFY
) {
1764 retval
= -ERESTARTSYS
;
1768 local_irq_save(flags
);
1769 base_addr
[CyCAR
] = (u_char
) channel
;
1770 /* CP('L');CP1(1 && C_CLOCAL(tty)); CP1(1 && (base_addr[CyMSVR1] & CyDCD) ); */
1771 if (!(info
->flags
& ASYNC_CLOSING
)
1773 || (base_addr
[CyMSVR1
] & CyDCD
))) {
1774 local_irq_restore(flags
);
1777 local_irq_restore(flags
);
1778 if (signal_pending(current
)) {
1779 retval
= -ERESTARTSYS
;
1782 #ifdef SERIAL_DEBUG_OPEN
1783 printk("block_til_ready blocking: %s, count = %d\n",
1784 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");