2 * macserial.c: Serial port driver for Power Macintoshes.
4 * Derived from drivers/sbus/char/sunserial.c by Paul Mackerras.
6 * Copyright (C) 1996 Paul Mackerras (Paul.Mackerras@cs.anu.edu.au)
7 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
10 #include <linux/config.h>
11 #include <linux/errno.h>
12 #include <linux/signal.h>
13 #include <linux/sched.h>
14 #include <linux/timer.h>
15 #include <linux/interrupt.h>
16 #include <linux/tty.h>
17 #include <linux/tty_flip.h>
18 #include <linux/major.h>
19 #include <linux/string.h>
20 #include <linux/fcntl.h>
22 #include <linux/kernel.h>
23 #include <linux/delay.h>
24 #include <linux/init.h>
25 #ifdef CONFIG_SERIAL_CONSOLE
26 #include <linux/console.h>
30 #include <asm/pgtable.h>
33 #include <asm/system.h>
34 #include <asm/segment.h>
35 #include <asm/bitops.h>
36 #include <asm/feature.h>
44 #include "macserial.h"
47 * It would be nice to dynamically allocate everything that
48 * depends on NUM_SERIAL, so we could support any number of
49 * Z8530s, but for now...
51 #define NUM_SERIAL 2 /* Max number of ZS chips supported */
52 #define NUM_CHANNELS (NUM_SERIAL * 2) /* 2 channels per chip */
54 /* On PowerMacs, the hardware takes care of the SCC recovery time,
55 but we need the eieio to make sure that the accesses occur
56 in the order we want. */
57 #define RECOVERY_DELAY eieio()
59 struct mac_zschannel zs_channels
[NUM_CHANNELS
];
61 struct mac_serial zs_soft
[NUM_CHANNELS
];
62 int zs_channels_found
;
63 struct mac_serial
*zs_chain
; /* list of all channels */
65 struct tty_struct zs_ttys
[NUM_CHANNELS
];
67 static int is_powerbook
;
69 #ifdef CONFIG_SERIAL_CONSOLE
70 static struct console sercons
;
74 struct mac_zschannel
*zs_kgdbchan
;
75 static unsigned char scc_inittab
[] = {
76 9, 0x80, /* reset A side (CHRA) */
77 13, 0, /* set baud rate divisor */
79 14, 1, /* baud rate gen enable, src=rtxc (BRENABL) */
80 11, 0x50, /* clocks = br gen (RCBR | TCBR) */
81 5, 0x6a, /* tx 8 bits, assert RTS (Tx8 | TxENAB | RTS) */
82 4, 0x44, /* x16 clock, 1 stop (SB1 | X16CLK)*/
83 3, 0xc1, /* rx enable, 8 bits (RxENABLE | Rx8)*/
86 #define ZS_CLOCK 3686400 /* Z8530 RTxC input clock rate */
88 static DECLARE_TASK_QUEUE(tq_serial
);
90 static struct tty_driver serial_driver
, callout_driver
;
91 static int serial_refcount
;
93 /* serial subtype definitions */
94 #define SERIAL_TYPE_NORMAL 1
95 #define SERIAL_TYPE_CALLOUT 2
97 /* number of characters left in xmit buffer before we ask for more */
98 #define WAKEUP_CHARS 256
103 #undef SERIAL_DEBUG_INTR
104 #undef SERIAL_DEBUG_OPEN
105 #undef SERIAL_DEBUG_FLOW
106 #undef SERIAL_DEBUG_POWER
107 #undef SERIAL_DEBUG_THROTTLE
108 #undef SERIAL_DEBUG_STOP
109 #undef SERIAL_DEBUG_BAUDS
111 #define RS_STROBE_TIME 10
112 #define RS_ISR_PASS_LIMIT 256
114 #define _INLINE_ inline
116 static void probe_sccs(void);
117 static void change_speed(struct mac_serial
*info
, struct termios
*old
);
118 static void rs_wait_until_sent(struct tty_struct
*tty
, int timeout
);
119 static void set_scc_power(struct mac_serial
* info
, int state
);
120 static int setup_scc(struct mac_serial
* info
);
122 static struct tty_struct
*serial_table
[NUM_CHANNELS
];
123 static struct termios
*serial_termios
[NUM_CHANNELS
];
124 static struct termios
*serial_termios_locked
[NUM_CHANNELS
];
127 #define MIN(a,b) ((a) < (b) ? (a) : (b))
131 * tmp_buf is used as a temporary buffer by serial_write. We need to
132 * lock it in case the copy_from_user blocks while swapping in a page,
133 * and some other program tries to do a serial write at the same time.
134 * Since the lock will only come under contention when the system is
135 * swapping and available memory is low, it makes sense to share one
136 * buffer across all the serial ports, since it significantly saves
137 * memory if large numbers of serial ports are open.
139 static unsigned char tmp_buf
[4096]; /* This is cheating */
140 DECLARE_MUTEX(tmp_buf_sem
);
143 static inline int __pmac
144 serial_paranoia_check(struct mac_serial
*info
,
145 dev_t device
, const char *routine
)
147 #ifdef SERIAL_PARANOIA_CHECK
148 static const char *badmagic
=
149 "Warning: bad magic number for serial struct (%d, %d) in %s\n";
150 static const char *badinfo
=
151 "Warning: null mac_serial for (%d, %d) in %s\n";
154 printk(badinfo
, MAJOR(device
), MINOR(device
), routine
);
157 if (info
->magic
!= SERIAL_MAGIC
) {
158 printk(badmagic
, MAJOR(device
), MINOR(device
), routine
);
166 * Reading and writing Z8530 registers.
168 static inline unsigned char __pmac
read_zsreg(struct mac_zschannel
*channel
,
171 unsigned char retval
;
175 * We have to make this atomic.
177 spin_lock_irqsave(&channel
->lock
, flags
);
179 *channel
->control
= reg
;
182 retval
= *channel
->control
;
184 spin_unlock_irqrestore(&channel
->lock
, flags
);
188 static inline void __pmac
write_zsreg(struct mac_zschannel
*channel
,
189 unsigned char reg
, unsigned char value
)
193 spin_lock_irqsave(&channel
->lock
, flags
);
195 *channel
->control
= reg
;
198 *channel
->control
= value
;
200 spin_unlock_irqrestore(&channel
->lock
, flags
);
204 static inline unsigned char __pmac
read_zsdata(struct mac_zschannel
*channel
)
206 unsigned char retval
;
208 retval
= *channel
->data
;
213 static inline void write_zsdata(struct mac_zschannel
*channel
,
216 *channel
->data
= value
;
221 static inline void load_zsregs(struct mac_zschannel
*channel
,
224 ZS_CLEARERR(channel
);
225 ZS_CLEARFIFO(channel
);
227 write_zsreg(channel
, R4
, regs
[R4
]);
228 write_zsreg(channel
, R10
, regs
[R10
]);
229 write_zsreg(channel
, R3
, regs
[R3
] & ~RxENABLE
);
230 write_zsreg(channel
, R5
, regs
[R5
] & ~TxENAB
);
231 write_zsreg(channel
, R1
, regs
[R1
]);
232 write_zsreg(channel
, R9
, regs
[R9
]);
233 write_zsreg(channel
, R11
, regs
[R11
]);
234 write_zsreg(channel
, R12
, regs
[R12
]);
235 write_zsreg(channel
, R13
, regs
[R13
]);
236 write_zsreg(channel
, R14
, regs
[R14
]);
237 write_zsreg(channel
, R15
, regs
[R15
]);
238 write_zsreg(channel
, R3
, regs
[R3
]);
239 write_zsreg(channel
, R5
, regs
[R5
]);
243 /* Sets or clears DTR/RTS on the requested line */
244 static inline void zs_rtsdtr(struct mac_serial
*ss
, int set
)
247 ss
->curregs
[5] |= (RTS
| DTR
);
249 ss
->curregs
[5] &= ~(RTS
| DTR
);
250 write_zsreg(ss
->zs_channel
, 5, ss
->curregs
[5]);
254 /* Utility routines for the Zilog */
255 static inline int get_zsbaud(struct mac_serial
*ss
)
257 struct mac_zschannel
*channel
= ss
->zs_channel
;
260 if ((ss
->curregs
[R11
] & TCBR
) == 0) {
261 /* higher rates don't use the baud rate generator */
262 return (ss
->curregs
[R4
] & X32CLK
)? ZS_CLOCK
/32: ZS_CLOCK
/16;
264 /* The baud rate is split up between two 8-bit registers in
265 * what is termed 'BRG time constant' format in my docs for
266 * the chip, it is a function of the clk rate the chip is
267 * receiving which happens to be constant.
269 brg
= (read_zsreg(channel
, 13) << 8);
270 brg
|= read_zsreg(channel
, 12);
271 return BRG_TO_BPS(brg
, (ZS_CLOCK
/(ss
->clk_divisor
)));
274 /* On receive, this clears errors and the receiver interrupts */
275 static inline void rs_recv_clear(struct mac_zschannel
*zsc
)
277 write_zsreg(zsc
, 0, ERR_RES
);
278 write_zsreg(zsc
, 0, RES_H_IUS
); /* XXX this is unnecessary */
282 * ----------------------------------------------------------------------
284 * Here starts the interrupt handling routines. All of the following
285 * subroutines are declared as inline and are folded into
286 * rs_interrupt(). They were separated out for readability's sake.
288 * - Ted Ts'o (tytso@mit.edu), 7-Mar-93
289 * -----------------------------------------------------------------------
293 * This routine is used by the interrupt handler to schedule
294 * processing in the software interrupt portion of the driver.
296 static _INLINE_
void rs_sched_event(struct mac_serial
*info
,
299 info
->event
|= 1 << event
;
300 queue_task(&info
->tqueue
, &tq_serial
);
301 mark_bh(MACSERIAL_BH
);
304 static _INLINE_
void receive_chars(struct mac_serial
*info
,
305 struct pt_regs
*regs
)
307 struct tty_struct
*tty
= info
->tty
;
308 unsigned char ch
, stat
, flag
;
310 while ((read_zsreg(info
->zs_channel
, 0) & Rx_CH_AV
) != 0) {
312 stat
= read_zsreg(info
->zs_channel
, R1
);
313 ch
= read_zsdata(info
->zs_channel
);
316 if (info
->kgdb_channel
) {
317 if (ch
== 0x03 || ch
== '$')
319 if (stat
& (Rx_OVR
|FRM_ERR
|PAR_ERR
))
320 write_zsreg(info
->zs_channel
, 0, ERR_RES
);
326 if (tty
->flip
.count
>= TTY_FLIPBUF_SIZE
)
327 tty_flip_buffer_push(tty
);
329 if (tty
->flip
.count
>= TTY_FLIPBUF_SIZE
) {
330 static int flip_buf_ovf
;
332 printk("FB. overflow: %d\n", flip_buf_ovf
);
337 static int flip_max_cnt
;
338 if (flip_max_cnt
< tty
->flip
.count
)
339 flip_max_cnt
= tty
->flip
.count
;
343 } else if (stat
& FRM_ERR
) {
345 } else if (stat
& PAR_ERR
) {
350 /* reset the error indication */
351 write_zsreg(info
->zs_channel
, 0, ERR_RES
);
352 *tty
->flip
.flag_buf_ptr
++ = flag
;
353 *tty
->flip
.char_buf_ptr
++ = ch
;
356 tty_flip_buffer_push(tty
);
359 static void transmit_chars(struct mac_serial
*info
)
361 if ((read_zsreg(info
->zs_channel
, 0) & Tx_BUF_EMP
) == 0)
367 write_zsdata(info
->zs_channel
, info
->x_char
);
373 if ((info
->xmit_cnt
<= 0) || info
->tty
->stopped
|| info
->tx_stopped
) {
374 write_zsreg(info
->zs_channel
, 0, RES_Tx_P
);
379 write_zsdata(info
->zs_channel
, info
->xmit_buf
[info
->xmit_tail
++]);
380 info
->xmit_tail
= info
->xmit_tail
& (SERIAL_XMIT_SIZE
-1);
384 if (info
->xmit_cnt
< WAKEUP_CHARS
)
385 rs_sched_event(info
, RS_EVENT_WRITE_WAKEUP
);
388 static _INLINE_
void status_handle(struct mac_serial
*info
)
390 unsigned char status
;
392 /* Get status from Read Register 0 */
393 status
= read_zsreg(info
->zs_channel
, 0);
395 /* Check for DCD transitions */
396 if (((status
^ info
->read_reg_zero
) & DCD
) != 0
397 && info
->tty
&& !C_CLOCAL(info
->tty
)) {
399 wake_up_interruptible(&info
->open_wait
);
400 } else if (!(info
->flags
& ZILOG_CALLOUT_ACTIVE
)) {
402 tty_hangup(info
->tty
);
406 /* Check for CTS transitions */
407 if (info
->tty
&& C_CRTSCTS(info
->tty
)) {
409 * For some reason, on the Power Macintosh,
410 * it seems that the CTS bit is 1 when CTS is
411 * *negated* and 0 when it is asserted.
412 * The DCD bit doesn't seem to be inverted
415 if ((status
& CTS
) == 0) {
416 if (info
->tx_stopped
) {
417 #ifdef SERIAL_DEBUG_FLOW
420 info
->tx_stopped
= 0;
421 if (!info
->tx_active
)
422 transmit_chars(info
);
425 #ifdef SERIAL_DEBUG_FLOW
426 printk("CTS down\n");
428 info
->tx_stopped
= 1;
432 /* Clear status condition... */
433 write_zsreg(info
->zs_channel
, 0, RES_EXT_INT
);
434 info
->read_reg_zero
= status
;
438 * This is the serial driver's generic interrupt routine
440 static void rs_interrupt(int irq
, void *dev_id
, struct pt_regs
* regs
)
442 struct mac_serial
*info
= (struct mac_serial
*) dev_id
;
443 unsigned char zs_intreg
;
446 /* NOTE: The read register 3, which holds the irq status,
447 * does so for both channels on each chip. Although
448 * the status value itself must be read from the A
449 * channel and is only valid when read from channel A.
450 * Yes... broken hardware...
452 #define CHAN_IRQMASK (CHBRxIP | CHBTxIP | CHBEXT)
454 if (info
->zs_chan_a
== info
->zs_channel
)
455 shift
= 3; /* Channel A */
457 shift
= 0; /* Channel B */
460 zs_intreg
= read_zsreg(info
->zs_chan_a
, 3) >> shift
;
461 #ifdef SERIAL_DEBUG_INTR
462 printk("rs_interrupt: irq %d, zs_intreg 0x%x\n", irq
, (int)zs_intreg
);
465 if ((zs_intreg
& CHAN_IRQMASK
) == 0)
468 if (!(info
->flags
& ZILOG_INITIALIZED
)) {
469 printk("rs_interrupt: irq %d, port not initialized\n", irq
);
473 if (zs_intreg
& CHBRxIP
)
474 receive_chars(info
, regs
);
475 if (zs_intreg
& CHBTxIP
)
476 transmit_chars(info
);
477 if (zs_intreg
& CHBEXT
)
483 * -------------------------------------------------------------------
484 * Here ends the serial interrupt routines.
485 * -------------------------------------------------------------------
489 * ------------------------------------------------------------
490 * rs_stop() and rs_start()
492 * This routines are called before setting or resetting tty->stopped.
493 * ------------------------------------------------------------
495 static void rs_stop(struct tty_struct
*tty
)
497 struct mac_serial
*info
= (struct mac_serial
*)tty
->driver_data
;
499 #ifdef SERIAL_DEBUG_STOP
500 printk("rs_stop %ld....\n",
501 tty
->ldisc
.chars_in_buffer(tty
));
504 if (serial_paranoia_check(info
, tty
->device
, "rs_stop"))
508 save_flags(flags
); cli();
509 if (info
->curregs
[5] & TxENAB
) {
510 info
->curregs
[5] &= ~TxENAB
;
511 info
->pendregs
[5] &= ~TxENAB
;
512 write_zsreg(info
->zs_channel
, 5, info
->curregs
[5]);
514 restore_flags(flags
);
518 static void rs_start(struct tty_struct
*tty
)
520 struct mac_serial
*info
= (struct mac_serial
*)tty
->driver_data
;
523 #ifdef SERIAL_DEBUG_STOP
524 printk("rs_start %ld....\n",
525 tty
->ldisc
.chars_in_buffer(tty
));
528 if (serial_paranoia_check(info
, tty
->device
, "rs_start"))
531 save_flags(flags
); cli();
533 if (info
->xmit_cnt
&& info
->xmit_buf
&& !(info
->curregs
[5] & TxENAB
)) {
534 info
->curregs
[5] |= TxENAB
;
535 info
->pendregs
[5] = info
->curregs
[5];
536 write_zsreg(info
->zs_channel
, 5, info
->curregs
[5]);
539 if (info
->xmit_cnt
&& info
->xmit_buf
&& !info
->tx_active
) {
540 transmit_chars(info
);
543 restore_flags(flags
);
547 * This routine is used to handle the "bottom half" processing for the
548 * serial driver, known also the "software interrupt" processing.
549 * This processing is done at the kernel interrupt level, after the
550 * rs_interrupt() has returned, BUT WITH INTERRUPTS TURNED ON. This
551 * is where time-consuming activities which can not be done in the
552 * interrupt driver proper are done; the interrupt driver schedules
553 * them using rs_sched_event(), and they get done here.
555 static void do_serial_bh(void)
557 run_task_queue(&tq_serial
);
560 static void do_softint(void *private_
)
562 struct mac_serial
*info
= (struct mac_serial
*) private_
;
563 struct tty_struct
*tty
;
569 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP
, &info
->event
)) {
570 if ((tty
->flags
& (1 << TTY_DO_WRITE_WAKEUP
)) &&
571 tty
->ldisc
.write_wakeup
)
572 (tty
->ldisc
.write_wakeup
)(tty
);
573 wake_up_interruptible(&tty
->write_wait
);
577 static void rs_timer(void)
581 static int startup(struct mac_serial
* info
)
583 #ifdef SERIAL_DEBUG_OPEN
584 printk("startup() (ttyS%d, irq %d)\n", info
->line
, info
->irq
);
587 if (info
->flags
& ZILOG_INITIALIZED
) {
588 #ifdef SERIAL_DEBUG_OPEN
589 printk(" -> already inited\n");
594 if (!info
->xmit_buf
) {
595 info
->xmit_buf
= (unsigned char *) get_free_page(GFP_KERNEL
);
600 #ifdef SERIAL_DEBUG_OPEN
601 printk("starting up ttyS%d (irq %d)...\n", info
->line
, info
->irq
);
604 set_scc_power(info
, 1);
608 #ifdef SERIAL_DEBUG_OPEN
609 printk("enabling IRQ on ttyS%d (irq %d)...\n", info
->line
, info
->irq
);
612 info
->flags
|= ZILOG_INITIALIZED
;
613 enable_irq(info
->irq
);
618 static int setup_scc(struct mac_serial
* info
)
622 #ifdef SERIAL_DEBUG_OPEN
623 printk("setting up ttys%d SCC...\n", info
->line
);
626 save_flags(flags
); cli(); /* Disable interrupts */
631 write_zsreg(info
->zs_channel
, 9,
632 (info
->zs_channel
== info
->zs_chan_a
? CHRA
: CHRB
));
634 write_zsreg(info
->zs_channel
, 9, 0);
637 * Clear the receive FIFO.
639 ZS_CLEARFIFO(info
->zs_channel
);
640 info
->xmit_fifo_size
= 1;
643 * Clear the interrupt registers.
645 write_zsreg(info
->zs_channel
, 0, ERR_RES
);
646 write_zsreg(info
->zs_channel
, 0, RES_H_IUS
);
649 * Turn on RTS and DTR.
654 * Finally, enable sequencing and interrupts
656 info
->curregs
[1] = (info
->curregs
[1] & ~0x18) | (EXT_INT_ENAB
| INT_ALL_Rx
| TxINT_ENAB
);
657 info
->pendregs
[1] = info
->curregs
[1];
658 info
->curregs
[3] |= (RxENABLE
| Rx8
);
659 info
->pendregs
[3] = info
->curregs
[3];
660 info
->curregs
[5] |= (TxENAB
| Tx8
);
661 info
->pendregs
[5] = info
->curregs
[5];
662 info
->curregs
[9] |= (NV
| MIE
);
663 info
->pendregs
[9] = info
->curregs
[9];
664 write_zsreg(info
->zs_channel
, 3, info
->curregs
[3]);
665 write_zsreg(info
->zs_channel
, 5, info
->curregs
[5]);
666 write_zsreg(info
->zs_channel
, 9, info
->curregs
[9]);
669 clear_bit(TTY_IO_ERROR
, &info
->tty
->flags
);
670 info
->xmit_cnt
= info
->xmit_head
= info
->xmit_tail
= 0;
673 * Set the speed of the serial port
675 change_speed(info
, 0);
677 /* Save the current value of RR0 */
678 info
->read_reg_zero
= read_zsreg(info
->zs_channel
, 0);
680 restore_flags(flags
);
686 * This routine will shutdown a serial port; interrupts are disabled, and
687 * DTR is dropped if the hangup on close termio flag is on.
689 static void shutdown(struct mac_serial
* info
)
691 #ifdef SERIAL_DEBUG_OPEN
692 printk("Shutting down serial port %d (irq %d)....\n", info
->line
,
696 if (!(info
->flags
& ZILOG_INITIALIZED
)) {
697 #ifdef SERIAL_DEBUG_OPEN
698 printk("(already shutdown)\n");
704 disable_irq(info
->irq
);
706 info
->pendregs
[1] = info
->curregs
[1] = 0;
707 write_zsreg(info
->zs_channel
, 1, 0); /* no interrupts */
709 info
->curregs
[3] &= ~RxENABLE
;
710 info
->pendregs
[3] = info
->curregs
[3];
711 write_zsreg(info
->zs_channel
, 3, info
->curregs
[3]);
713 info
->curregs
[5] &= ~TxENAB
;
714 if (!info
->tty
|| C_HUPCL(info
->tty
))
715 info
->curregs
[5] &= ~(DTR
| RTS
);
716 info
->pendregs
[5] = info
->curregs
[5];
717 write_zsreg(info
->zs_channel
, 5, info
->curregs
[5]);
720 set_bit(TTY_IO_ERROR
, &info
->tty
->flags
);
722 set_scc_power(info
, 0);
724 if (info
->xmit_buf
) {
725 free_page((unsigned long) info
->xmit_buf
);
729 memset(info
->curregs
, 0, sizeof(info
->curregs
));
730 memset(info
->curregs
, 0, sizeof(info
->pendregs
));
732 info
->flags
&= ~ZILOG_INITIALIZED
;
735 static void set_scc_power(struct mac_serial
* info
, int state
)
737 if (feature_test(info
->dev_node
, FEATURE_Serial_enable
) < 0)
738 return; /* don't have serial power control */
740 /* The timings looks strange but that's the ones MacOS seems
741 to use for the internal modem. I think we can use a lot faster
742 ones, at least whe not using the modem, this should be tested.
745 #ifdef SERIAL_DEBUG_POWER
746 printk(KERN_INFO
"ttyS%02d: powering up hardware\n", info
->line
);
748 if (feature_test(info
->dev_node
, FEATURE_Serial_enable
) == 0) {
749 feature_clear(info
->dev_node
, FEATURE_Serial_reset
);
751 feature_set(info
->dev_node
, FEATURE_Serial_enable
);
753 if (info
->zs_chan_a
== info
->zs_channel
)
754 feature_set(info
->dev_node
, FEATURE_Serial_IO_A
);
756 feature_set(info
->dev_node
, FEATURE_Serial_IO_B
);
759 if (info
->is_cobalt_modem
){
760 feature_set(info
->dev_node
, FEATURE_Modem_Reset
);
762 feature_clear(info
->dev_node
, FEATURE_Modem_Reset
);
763 /* XXX Note the big 250ms, we should probably replace this
764 by something better since we have irqs disabled here
768 if (info
->is_pwbk_ir
)
771 #ifdef SERIAL_DEBUG_POWER
772 printk(KERN_INFO
"ttyS%02d: shutting down hardware\n", info
->line
);
775 if (info
->kgdb_channel
) {
776 #ifdef SERIAL_DEBUG_POWER
777 printk(KERN_INFO
" (canceled by KGDB)\n");
783 if (!info
->is_cobalt_modem
) {
784 #ifdef SERIAL_DEBUG_POWER
785 printk(KERN_INFO
" (canceled by XMON)\n");
790 if (info
->is_cobalt_modem
) {
791 #ifdef SERIAL_DEBUG_POWER
792 printk(KERN_INFO
"ttyS%02d: shutting down modem\n", info
->line
);
794 feature_set(info
->dev_node
, FEATURE_Modem_Reset
);
796 feature_clear(info
->dev_node
, FEATURE_Modem_Reset
);
799 if (info
->is_pwbk_ir
)
802 if (info
->zs_chan_a
== info
->zs_channel
) {
803 #ifdef SERIAL_DEBUG_POWER
804 printk(KERN_INFO
"ttyS%02d: shutting down SCC channel A\n", info
->line
);
806 feature_clear(info
->dev_node
, FEATURE_Serial_IO_A
);
808 #ifdef SERIAL_DEBUG_POWER
809 printk(KERN_INFO
"ttyS%02d: shutting down SCC channel B\n", info
->line
);
811 feature_clear(info
->dev_node
, FEATURE_Serial_IO_B
);
813 /* XXX for now, shut down SCC core only on powerbooks */
815 && !(feature_test(info
->dev_node
, FEATURE_Serial_IO_A
) ||
816 feature_test(info
->dev_node
, FEATURE_Serial_IO_B
))) {
817 #ifdef SERIAL_DEBUG_POWER
818 printk(KERN_INFO
"ttyS%02d: shutting down SCC core\n", info
->line
);
820 feature_set(info
->dev_node
, FEATURE_Serial_reset
);
822 feature_clear(info
->dev_node
, FEATURE_Serial_enable
);
830 * This routine is called to set the UART divisor registers to match
831 * the specified baud rate for a serial port.
833 static void change_speed(struct mac_serial
*info
, struct termios
*old_termios
)
841 if (!info
->tty
|| !info
->tty
->termios
)
843 if (!(port
= info
->port
))
846 cflag
= info
->tty
->termios
->c_cflag
;
847 baud
= tty_get_baud_rate(info
->tty
);
850 info
->tty
->termios
->c_cflag
&= ~CBAUD
;
851 info
->tty
->termios
->c_cflag
|= (old_termios
->c_cflag
& CBAUD
);
852 cflag
= info
->tty
->termios
->c_cflag
;
853 baud
= tty_get_baud_rate(info
->tty
);
856 baud
= info
->zs_baud
;
863 save_flags(flags
); cli();
864 info
->zs_baud
= baud
;
865 info
->clk_divisor
= 16;
867 #ifdef SERIAL_DEBUG_BAUDS
868 printk("set speed to %d bds, ", baud
);
872 case ZS_CLOCK
/16: /* 230400 */
873 info
->curregs
[4] = X16CLK
;
874 info
->curregs
[11] = 0;
876 case ZS_CLOCK
/32: /* 115200 */
877 info
->curregs
[4] = X32CLK
;
878 info
->curregs
[11] = 0;
881 info
->curregs
[4] = X16CLK
;
882 info
->curregs
[11] = TCBR
| RCBR
;
883 brg
= BPS_TO_BRG(baud
, ZS_CLOCK
/info
->clk_divisor
);
884 info
->curregs
[12] = (brg
& 255);
885 info
->curregs
[13] = ((brg
>> 8) & 255);
886 info
->curregs
[14] = BRENABL
;
889 /* byte size and parity */
890 info
->curregs
[3] &= ~RxNBITS_MASK
;
891 info
->curregs
[5] &= ~TxNBITS_MASK
;
892 switch (cflag
& CSIZE
) {
894 info
->curregs
[3] |= Rx5
;
895 info
->curregs
[5] |= Tx5
;
896 #ifdef SERIAL_DEBUG_BAUDS
902 info
->curregs
[3] |= Rx6
;
903 info
->curregs
[5] |= Tx6
;
904 #ifdef SERIAL_DEBUG_BAUDS
910 info
->curregs
[3] |= Rx7
;
911 info
->curregs
[5] |= Tx7
;
912 #ifdef SERIAL_DEBUG_BAUDS
918 default: /* defaults to 8 bits */
919 info
->curregs
[3] |= Rx8
;
920 info
->curregs
[5] |= Tx8
;
921 #ifdef SERIAL_DEBUG_BAUDS
927 info
->pendregs
[3] = info
->curregs
[3];
928 info
->pendregs
[5] = info
->curregs
[5];
930 info
->curregs
[4] &= ~(SB_MASK
| PAR_ENA
| PAR_EVEN
);
931 if (cflag
& CSTOPB
) {
932 info
->curregs
[4] |= SB2
;
934 #ifdef SERIAL_DEBUG_BAUDS
938 info
->curregs
[4] |= SB1
;
939 #ifdef SERIAL_DEBUG_BAUDS
943 if (cflag
& PARENB
) {
945 info
->curregs
[4] |= PAR_ENA
;
946 #ifdef SERIAL_DEBUG_BAUDS
950 if (!(cflag
& PARODD
)) {
951 info
->curregs
[4] |= PAR_EVEN
;
953 info
->pendregs
[4] = info
->curregs
[4];
955 if (!(cflag
& CLOCAL
)) {
956 if (!(info
->curregs
[15] & DCDIE
))
957 info
->read_reg_zero
= read_zsreg(info
->zs_channel
, 0);
958 info
->curregs
[15] |= DCDIE
;
960 info
->curregs
[15] &= ~DCDIE
;
961 if (cflag
& CRTSCTS
) {
962 info
->curregs
[15] |= CTSIE
;
963 if ((read_zsreg(info
->zs_channel
, 0) & CTS
) != 0)
964 info
->tx_stopped
= 1;
966 info
->curregs
[15] &= ~CTSIE
;
967 info
->tx_stopped
= 0;
969 info
->pendregs
[15] = info
->curregs
[15];
971 /* Calc timeout value. This is pretty broken with high baud rates with HZ=100.
972 This code would love a larger HZ and a >1 fifo size, but this is not
973 a priority. The resulting value must be >HZ/2
975 info
->timeout
= ((info
->xmit_fifo_size
*HZ
*bits
) / baud
);
976 info
->timeout
+= HZ
/50+1; /* Add .02 seconds of slop */
978 #ifdef SERIAL_DEBUG_BAUDS
979 printk("timeout=%d/%ds, base:%d\n", (int)info
->timeout
, (int)HZ
, (int)info
->baud_base
);
982 /* Load up the new values */
983 load_zsregs(info
->zs_channel
, info
->curregs
);
985 restore_flags(flags
);
988 static void rs_flush_chars(struct tty_struct
*tty
)
990 struct mac_serial
*info
= (struct mac_serial
*)tty
->driver_data
;
993 if (serial_paranoia_check(info
, tty
->device
, "rs_flush_chars"))
996 if (info
->xmit_cnt
<= 0 || tty
->stopped
|| info
->tx_stopped
||
1000 /* Enable transmitter */
1001 save_flags(flags
); cli();
1002 transmit_chars(info
);
1003 restore_flags(flags
);
1006 static int rs_write(struct tty_struct
* tty
, int from_user
,
1007 const unsigned char *buf
, int count
)
1010 struct mac_serial
*info
= (struct mac_serial
*)tty
->driver_data
;
1011 unsigned long flags
;
1013 if (serial_paranoia_check(info
, tty
->device
, "rs_write"))
1016 if (!tty
|| !info
->xmit_buf
)
1022 c
= MIN(count
, MIN(SERIAL_XMIT_SIZE
- info
->xmit_cnt
- 1,
1023 SERIAL_XMIT_SIZE
- info
->xmit_head
));
1029 copy_from_user(tmp_buf
, buf
, c
);
1030 c
= MIN(c
, MIN(SERIAL_XMIT_SIZE
- info
->xmit_cnt
- 1,
1031 SERIAL_XMIT_SIZE
- info
->xmit_head
));
1032 memcpy(info
->xmit_buf
+ info
->xmit_head
, tmp_buf
, c
);
1035 memcpy(info
->xmit_buf
+ info
->xmit_head
, buf
, c
);
1036 info
->xmit_head
= (info
->xmit_head
+ c
) & (SERIAL_XMIT_SIZE
-1);
1037 info
->xmit_cnt
+= c
;
1038 restore_flags(flags
);
1043 if (info
->xmit_cnt
&& !tty
->stopped
&& !info
->tx_stopped
1044 && !info
->tx_active
)
1045 transmit_chars(info
);
1046 restore_flags(flags
);
1050 static int rs_write_room(struct tty_struct
*tty
)
1052 struct mac_serial
*info
= (struct mac_serial
*)tty
->driver_data
;
1055 if (serial_paranoia_check(info
, tty
->device
, "rs_write_room"))
1057 ret
= SERIAL_XMIT_SIZE
- info
->xmit_cnt
- 1;
1063 static int rs_chars_in_buffer(struct tty_struct
*tty
)
1065 struct mac_serial
*info
= (struct mac_serial
*)tty
->driver_data
;
1067 if (serial_paranoia_check(info
, tty
->device
, "rs_chars_in_buffer"))
1069 return info
->xmit_cnt
;
1072 static void rs_flush_buffer(struct tty_struct
*tty
)
1074 struct mac_serial
*info
= (struct mac_serial
*)tty
->driver_data
;
1076 if (serial_paranoia_check(info
, tty
->device
, "rs_flush_buffer"))
1079 info
->xmit_cnt
= info
->xmit_head
= info
->xmit_tail
= 0;
1081 wake_up_interruptible(&tty
->write_wait
);
1082 if ((tty
->flags
& (1 << TTY_DO_WRITE_WAKEUP
)) &&
1083 tty
->ldisc
.write_wakeup
)
1084 (tty
->ldisc
.write_wakeup
)(tty
);
1088 * ------------------------------------------------------------
1091 * This routine is called by the upper-layer tty layer to signal that
1092 * incoming characters should be throttled.
1093 * ------------------------------------------------------------
1095 static void rs_throttle(struct tty_struct
* tty
)
1097 struct mac_serial
*info
= (struct mac_serial
*)tty
->driver_data
;
1098 unsigned long flags
;
1099 #ifdef SERIAL_DEBUG_THROTTLE
1102 printk("throttle %ld....\n",tty
->ldisc
.chars_in_buffer(tty
));
1105 if (serial_paranoia_check(info
, tty
->device
, "rs_throttle"))
1109 save_flags(flags
); cli();
1110 info
->x_char
= STOP_CHAR(tty
);
1111 if (!info
->tx_active
)
1112 transmit_chars(info
);
1113 restore_flags(flags
);
1116 if (C_CRTSCTS(tty
)) {
1118 * Here we want to turn off the RTS line. On Macintoshes,
1119 * we only get the DTR line, which goes to both DTR and
1120 * RTS on the modem. RTS doesn't go out to the serial
1121 * port socket. So you should make sure your modem is
1122 * set to ignore DTR if you're using CRTSCTS.
1124 save_flags(flags
); cli();
1125 info
->curregs
[5] &= ~(DTR
| RTS
);
1126 info
->pendregs
[5] &= ~(DTR
| RTS
);
1127 write_zsreg(info
->zs_channel
, 5, info
->curregs
[5]);
1128 restore_flags(flags
);
1132 static void rs_unthrottle(struct tty_struct
* tty
)
1134 struct mac_serial
*info
= (struct mac_serial
*)tty
->driver_data
;
1135 unsigned long flags
;
1136 #ifdef SERIAL_DEBUG_THROTTLE
1139 printk("unthrottle %s: %d....\n",tty
->ldisc
.chars_in_buffer(tty
));
1142 if (serial_paranoia_check(info
, tty
->device
, "rs_unthrottle"))
1146 save_flags(flags
); cli();
1150 info
->x_char
= START_CHAR(tty
);
1151 if (!info
->tx_active
)
1152 transmit_chars(info
);
1154 restore_flags(flags
);
1157 if (C_CRTSCTS(tty
)) {
1158 /* Assert RTS and DTR lines */
1159 save_flags(flags
); cli();
1160 info
->curregs
[5] |= DTR
| RTS
;
1161 info
->pendregs
[5] |= DTR
| RTS
;
1162 write_zsreg(info
->zs_channel
, 5, info
->curregs
[5]);
1163 restore_flags(flags
);
1168 * ------------------------------------------------------------
1169 * rs_ioctl() and friends
1170 * ------------------------------------------------------------
1173 static int get_serial_info(struct mac_serial
* info
,
1174 struct serial_struct
* retinfo
)
1176 struct serial_struct tmp
;
1180 memset(&tmp
, 0, sizeof(tmp
));
1181 tmp
.type
= info
->type
;
1182 tmp
.line
= info
->line
;
1183 tmp
.port
= info
->port
;
1184 tmp
.irq
= info
->irq
;
1185 tmp
.flags
= info
->flags
;
1186 tmp
.baud_base
= info
->baud_base
;
1187 tmp
.close_delay
= info
->close_delay
;
1188 tmp
.closing_wait
= info
->closing_wait
;
1189 tmp
.custom_divisor
= info
->custom_divisor
;
1190 return copy_to_user(retinfo
,&tmp
,sizeof(*retinfo
));
1193 static int set_serial_info(struct mac_serial
* info
,
1194 struct serial_struct
* new_info
)
1196 struct serial_struct new_serial
;
1197 struct mac_serial old_info
;
1202 copy_from_user(&new_serial
,new_info
,sizeof(new_serial
));
1205 if (!capable(CAP_SYS_ADMIN
)) {
1206 if ((new_serial
.baud_base
!= info
->baud_base
) ||
1207 (new_serial
.type
!= info
->type
) ||
1208 (new_serial
.close_delay
!= info
->close_delay
) ||
1209 ((new_serial
.flags
& ~ZILOG_USR_MASK
) !=
1210 (info
->flags
& ~ZILOG_USR_MASK
)))
1212 info
->flags
= ((info
->flags
& ~ZILOG_USR_MASK
) |
1213 (new_serial
.flags
& ZILOG_USR_MASK
));
1214 info
->custom_divisor
= new_serial
.custom_divisor
;
1215 goto check_and_exit
;
1218 if (info
->count
> 1)
1222 * OK, past this point, all the error checking has been done.
1223 * At this point, we start making changes.....
1226 info
->baud_base
= new_serial
.baud_base
;
1227 info
->flags
= ((info
->flags
& ~ZILOG_FLAGS
) |
1228 (new_serial
.flags
& ZILOG_FLAGS
));
1229 info
->type
= new_serial
.type
;
1230 info
->close_delay
= new_serial
.close_delay
;
1231 info
->closing_wait
= new_serial
.closing_wait
;
1234 if (info
->flags
& ZILOG_INITIALIZED
)
1235 retval
= setup_scc(info
);
1240 * get_lsr_info - get line status register info
1242 * Purpose: Let user call ioctl() to get info when the UART physically
1243 * is emptied. On bus types like RS485, the transmitter must
1244 * release the bus after transmitting. This must be done when
1245 * the transmit shift register is empty, not be done when the
1246 * transmit holding register is empty. This functionality
1247 * allows an RS485 driver to be written in user space.
1249 static int get_lsr_info(struct mac_serial
* info
, unsigned int *value
)
1251 unsigned char status
;
1254 status
= read_zsreg(info
->zs_channel
, 0);
1256 put_user(status
,value
);
1260 static int get_modem_info(struct mac_serial
*info
, unsigned int *value
)
1262 unsigned char control
, status
;
1263 unsigned int result
;
1266 control
= info
->curregs
[5];
1267 status
= read_zsreg(info
->zs_channel
, 0);
1269 result
= ((control
& RTS
) ? TIOCM_RTS
: 0)
1270 | ((control
& DTR
) ? TIOCM_DTR
: 0)
1271 | ((status
& DCD
) ? TIOCM_CAR
: 0)
1272 | ((status
& CTS
) ? 0: TIOCM_CTS
);
1273 put_user(result
,value
);
1277 static int set_modem_info(struct mac_serial
*info
, unsigned int cmd
,
1278 unsigned int *value
)
1281 unsigned int arg
, bits
;
1283 error
= verify_area(VERIFY_READ
, value
, sizeof(int));
1286 get_user(arg
, value
);
1287 bits
= (arg
& TIOCM_RTS
? RTS
: 0) + (arg
& TIOCM_DTR
? DTR
: 0);
1291 info
->curregs
[5] |= bits
;
1294 info
->curregs
[5] &= ~bits
;
1297 info
->curregs
[5] = (info
->curregs
[5] & ~(DTR
| RTS
)) | bits
;
1303 info
->pendregs
[5] = info
->curregs
[5];
1304 write_zsreg(info
->zs_channel
, 5, info
->curregs
[5]);
1310 * rs_break - turn transmit break condition on/off
1312 static void rs_break(struct tty_struct
*tty
, int break_state
)
1314 struct mac_serial
*info
= (struct mac_serial
*) tty
->driver_data
;
1315 unsigned long flags
;
1317 if (serial_paranoia_check(info
, tty
->device
, "rs_break"))
1322 save_flags(flags
); cli();
1323 if (break_state
== -1)
1324 info
->curregs
[5] |= SND_BRK
;
1326 info
->curregs
[5] &= ~SND_BRK
;
1327 write_zsreg(info
->zs_channel
, 5, info
->curregs
[5]);
1328 restore_flags(flags
);
1331 static int rs_ioctl(struct tty_struct
*tty
, struct file
* file
,
1332 unsigned int cmd
, unsigned long arg
)
1335 struct mac_serial
* info
= (struct mac_serial
*)tty
->driver_data
;
1338 if (info
->kgdb_channel
)
1341 if (serial_paranoia_check(info
, tty
->device
, "rs_ioctl"))
1344 if ((cmd
!= TIOCGSERIAL
) && (cmd
!= TIOCSSERIAL
) &&
1345 (cmd
!= TIOCSERCONFIG
) && (cmd
!= TIOCSERGWILD
) &&
1346 (cmd
!= TIOCSERSWILD
) && (cmd
!= TIOCSERGSTRUCT
)) {
1347 if (tty
->flags
& (1 << TTY_IO_ERROR
))
1353 error
= verify_area(VERIFY_WRITE
, (void *) arg
,
1354 sizeof(unsigned int));
1357 return get_modem_info(info
, (unsigned int *) arg
);
1361 return set_modem_info(info
, cmd
, (unsigned int *) arg
);
1363 error
= verify_area(VERIFY_WRITE
, (void *) arg
,
1364 sizeof(struct serial_struct
));
1367 return get_serial_info(info
,
1368 (struct serial_struct
*) arg
);
1370 return set_serial_info(info
,
1371 (struct serial_struct
*) arg
);
1372 case TIOCSERGETLSR
: /* Get line status register */
1373 error
= verify_area(VERIFY_WRITE
, (void *) arg
,
1374 sizeof(unsigned int));
1378 return get_lsr_info(info
, (unsigned int *) arg
);
1380 case TIOCSERGSTRUCT
:
1381 error
= verify_area(VERIFY_WRITE
, (void *) arg
,
1382 sizeof(struct mac_serial
));
1385 copy_from_user((struct mac_serial
*) arg
,
1386 info
, sizeof(struct mac_serial
));
1390 return -ENOIOCTLCMD
;
1395 static void rs_set_termios(struct tty_struct
*tty
, struct termios
*old_termios
)
1397 struct mac_serial
*info
= (struct mac_serial
*)tty
->driver_data
;
1400 if (tty
->termios
->c_cflag
== old_termios
->c_cflag
)
1402 was_stopped
= info
->tx_stopped
;
1404 change_speed(info
, old_termios
);
1406 if (was_stopped
&& !info
->tx_stopped
) {
1407 tty
->hw_stopped
= 0;
1413 * ------------------------------------------------------------
1416 * This routine is called when the serial port gets closed.
1417 * Wait for the last remaining data to be sent.
1418 * ------------------------------------------------------------
1420 static void rs_close(struct tty_struct
*tty
, struct file
* filp
)
1422 struct mac_serial
* info
= (struct mac_serial
*)tty
->driver_data
;
1423 unsigned long flags
;
1425 if (!info
|| serial_paranoia_check(info
, tty
->device
, "rs_close"))
1428 save_flags(flags
); cli();
1430 if (tty_hung_up_p(filp
)) {
1431 restore_flags(flags
);
1435 #ifdef SERIAL_DEBUG_OPEN
1436 printk("rs_close ttys%d, count = %d\n", info
->line
, info
->count
);
1438 if ((tty
->count
== 1) && (info
->count
!= 1)) {
1440 * Uh, oh. tty->count is 1, which means that the tty
1441 * structure will be freed. Info->count should always
1442 * be one in these conditions. If it's greater than
1443 * one, we've got real problems, since it means the
1444 * serial port won't be shutdown.
1446 printk("rs_close: bad serial port count; tty->count is 1, "
1447 "info->count is %d\n", info
->count
);
1450 if (--info
->count
< 0) {
1451 printk("rs_close: bad serial port count for ttys%d: %d\n",
1452 info
->line
, info
->count
);
1456 restore_flags(flags
);
1459 info
->flags
|= ZILOG_CLOSING
;
1461 * Save the termios structure, since this port may have
1462 * separate termios for callout and dialin.
1464 if (info
->flags
& ZILOG_NORMAL_ACTIVE
)
1465 info
->normal_termios
= *tty
->termios
;
1466 if (info
->flags
& ZILOG_CALLOUT_ACTIVE
)
1467 info
->callout_termios
= *tty
->termios
;
1469 * Now we wait for the transmit buffer to clear; and we notify
1470 * the line discipline to only process XON/XOFF characters.
1472 #ifdef SERIAL_DEBUG_OPEN
1473 printk("waiting end of Tx... (timeout:%d)\n", info
->closing_wait
);
1476 if (info
->closing_wait
!= ZILOG_CLOSING_WAIT_NONE
)
1477 tty_wait_until_sent(tty
, info
->closing_wait
);
1479 * At this point we stop accepting input. To do this, we
1480 * disable the receiver and receive interrupts.
1482 info
->curregs
[3] &= ~RxENABLE
;
1483 info
->pendregs
[3] = info
->curregs
[3];
1484 write_zsreg(info
->zs_channel
, 3, info
->curregs
[3]);
1485 info
->curregs
[1] &= ~(0x18); /* disable any rx ints */
1486 info
->pendregs
[1] = info
->curregs
[1];
1487 write_zsreg(info
->zs_channel
, 1, info
->curregs
[1]);
1488 ZS_CLEARFIFO(info
->zs_channel
);
1489 if (info
->flags
& ZILOG_INITIALIZED
) {
1491 * Before we drop DTR, make sure the SCC transmitter
1492 * has completely drained.
1494 #ifdef SERIAL_DEBUG_OPEN
1495 printk("waiting end of Rx...\n");
1497 rs_wait_until_sent(tty
, info
->timeout
);
1501 /* restore flags now since shutdown() will have disabled this port's
1503 restore_flags(flags
);
1505 if (tty
->driver
.flush_buffer
)
1506 tty
->driver
.flush_buffer(tty
);
1507 if (tty
->ldisc
.flush_buffer
)
1508 tty
->ldisc
.flush_buffer(tty
);
1513 if (info
->blocked_open
) {
1514 if (info
->close_delay
) {
1515 current
->state
= TASK_INTERRUPTIBLE
;
1516 schedule_timeout(info
->close_delay
);
1518 wake_up_interruptible(&info
->open_wait
);
1520 info
->flags
&= ~(ZILOG_NORMAL_ACTIVE
|ZILOG_CALLOUT_ACTIVE
|
1522 wake_up_interruptible(&info
->close_wait
);
1526 * rs_wait_until_sent() --- wait until the transmitter is empty
1528 static void rs_wait_until_sent(struct tty_struct
*tty
, int timeout
)
1530 struct mac_serial
*info
= (struct mac_serial
*) tty
->driver_data
;
1531 unsigned long orig_jiffies
, char_time
;
1533 if (serial_paranoia_check(info
, tty
->device
, "rs_wait_until_sent"))
1536 /* printk("rs_wait_until_sent, timeout:%d, tty_stopped:%d, tx_stopped:%d\n",
1537 timeout, tty->stopped, info->tx_stopped);
1539 orig_jiffies
= jiffies
;
1541 * Set the check interval to be 1/5 of the estimated time to
1542 * send a single character, and make it at least 1. The check
1543 * interval should also be less than the timeout.
1545 if (info
->timeout
<= HZ
/50) {
1546 printk("macserial: invalid info->timeout=%d\n", info
->timeout
);
1547 info
->timeout
= HZ
/50+1;
1550 char_time
= (info
->timeout
- HZ
/50) / info
->xmit_fifo_size
;
1551 char_time
= char_time
/ 5;
1552 if (char_time
> HZ
) {
1553 printk("macserial: char_time %ld >HZ !!!\n", char_time
);
1555 } else if (char_time
== 0)
1558 char_time
= MIN(char_time
, timeout
);
1559 while ((read_zsreg(info
->zs_channel
, 1) & ALL_SNT
) == 0) {
1560 current
->state
= TASK_INTERRUPTIBLE
;
1561 schedule_timeout(char_time
);
1562 if (signal_pending(current
))
1564 if (timeout
&& time_after(jiffies
, orig_jiffies
+ timeout
))
1567 current
->state
= TASK_RUNNING
;
1571 * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
1573 static void rs_hangup(struct tty_struct
*tty
)
1575 struct mac_serial
* info
= (struct mac_serial
*)tty
->driver_data
;
1577 if (serial_paranoia_check(info
, tty
->device
, "rs_hangup"))
1580 rs_flush_buffer(tty
);
1584 info
->flags
&= ~(ZILOG_NORMAL_ACTIVE
|ZILOG_CALLOUT_ACTIVE
);
1586 wake_up_interruptible(&info
->open_wait
);
1590 * ------------------------------------------------------------
1591 * rs_open() and friends
1592 * ------------------------------------------------------------
1594 static int block_til_ready(struct tty_struct
*tty
, struct file
* filp
,
1595 struct mac_serial
*info
)
1597 DECLARE_WAITQUEUE(wait
,current
);
1602 * If the device is in the middle of being closed, then block
1603 * until it's done, and then try again.
1605 if (info
->flags
& ZILOG_CLOSING
) {
1606 interruptible_sleep_on(&info
->close_wait
);
1607 #ifdef SERIAL_DO_RESTART
1608 return ((info
->flags
& ZILOG_HUP_NOTIFY
) ?
1609 -EAGAIN
: -ERESTARTSYS
);
1616 * If this is a callout device, then just make sure the normal
1617 * device isn't being used.
1619 if (tty
->driver
.subtype
== SERIAL_TYPE_CALLOUT
) {
1620 if (info
->flags
& ZILOG_NORMAL_ACTIVE
)
1622 if ((info
->flags
& ZILOG_CALLOUT_ACTIVE
) &&
1623 (info
->flags
& ZILOG_SESSION_LOCKOUT
) &&
1624 (info
->session
!= current
->session
))
1626 if ((info
->flags
& ZILOG_CALLOUT_ACTIVE
) &&
1627 (info
->flags
& ZILOG_PGRP_LOCKOUT
) &&
1628 (info
->pgrp
!= current
->pgrp
))
1630 info
->flags
|= ZILOG_CALLOUT_ACTIVE
;
1635 * If non-blocking mode is set, or the port is not enabled,
1636 * then make the check up front and then exit.
1638 if ((filp
->f_flags
& O_NONBLOCK
) ||
1639 (tty
->flags
& (1 << TTY_IO_ERROR
))) {
1640 if (info
->flags
& ZILOG_CALLOUT_ACTIVE
)
1642 info
->flags
|= ZILOG_NORMAL_ACTIVE
;
1646 if (info
->flags
& ZILOG_CALLOUT_ACTIVE
) {
1647 if (info
->normal_termios
.c_cflag
& CLOCAL
)
1650 if (tty
->termios
->c_cflag
& CLOCAL
)
1655 * Block waiting for the carrier detect and the line to become
1656 * free (i.e., not in use by the callout). While we are in
1657 * this loop, info->count is dropped by one, so that
1658 * rs_close() knows when to free things. We restore it upon
1659 * exit, either normal or abnormal.
1662 add_wait_queue(&info
->open_wait
, &wait
);
1663 #ifdef SERIAL_DEBUG_OPEN
1664 printk("block_til_ready before block: ttys%d, count = %d\n",
1665 info
->line
, info
->count
);
1668 if (!tty_hung_up_p(filp
))
1671 info
->blocked_open
++;
1674 if (!(info
->flags
& ZILOG_CALLOUT_ACTIVE
) &&
1675 (tty
->termios
->c_cflag
& CBAUD
))
1678 current
->state
= TASK_INTERRUPTIBLE
;
1679 if (tty_hung_up_p(filp
) ||
1680 !(info
->flags
& ZILOG_INITIALIZED
)) {
1681 #ifdef SERIAL_DO_RESTART
1682 if (info
->flags
& ZILOG_HUP_NOTIFY
)
1685 retval
= -ERESTARTSYS
;
1691 if (!(info
->flags
& ZILOG_CALLOUT_ACTIVE
) &&
1692 !(info
->flags
& ZILOG_CLOSING
) &&
1693 (do_clocal
|| (read_zsreg(info
->zs_channel
, 0) & DCD
)))
1695 if (signal_pending(current
)) {
1696 retval
= -ERESTARTSYS
;
1699 #ifdef SERIAL_DEBUG_OPEN
1700 printk("block_til_ready blocking: ttys%d, count = %d\n",
1701 info
->line
, info
->count
);
1705 current
->state
= TASK_RUNNING
;
1706 remove_wait_queue(&info
->open_wait
, &wait
);
1707 if (!tty_hung_up_p(filp
))
1709 info
->blocked_open
--;
1710 #ifdef SERIAL_DEBUG_OPEN
1711 printk("block_til_ready after blocking: ttys%d, count = %d\n",
1712 info
->line
, info
->count
);
1716 info
->flags
|= ZILOG_NORMAL_ACTIVE
;
1721 * This routine is called whenever a serial port is opened. It
1722 * enables interrupts for a serial port, linking in its ZILOG structure into
1723 * the IRQ chain. It also performs the serial-specific
1724 * initialization for the tty structure.
1726 static int rs_open(struct tty_struct
*tty
, struct file
* filp
)
1728 struct mac_serial
*info
;
1731 line
= MINOR(tty
->device
) - tty
->driver
.minor_start
;
1732 if ((line
< 0) || (line
>= zs_channels_found
))
1734 info
= zs_soft
+ line
;
1737 if (info
->kgdb_channel
)
1740 if (serial_paranoia_check(info
, tty
->device
, "rs_open"))
1742 #ifdef SERIAL_DEBUG_OPEN
1743 printk("rs_open %s%d, count = %d\n", tty
->driver
.name
, info
->line
,
1748 tty
->driver_data
= info
;
1752 * If the port is the middle of closing, bail out now
1754 if (tty_hung_up_p(filp
) ||
1755 (info
->flags
& ZILOG_CLOSING
)) {
1756 if (info
->flags
& ZILOG_CLOSING
)
1757 interruptible_sleep_on(&info
->close_wait
);
1758 #ifdef SERIAL_DO_RESTART
1759 return ((info
->flags
& ZILOG_HUP_NOTIFY
) ?
1760 -EAGAIN
: -ERESTARTSYS
);
1767 * Start up serial port
1770 retval
= startup(info
);
1774 retval
= block_til_ready(tty
, filp
, info
);
1776 #ifdef SERIAL_DEBUG_OPEN
1777 printk("rs_open returning after block_til_ready with %d\n",
1783 if ((info
->count
== 1) && (info
->flags
& ZILOG_SPLIT_TERMIOS
)) {
1784 if (tty
->driver
.subtype
== SERIAL_TYPE_NORMAL
)
1785 *tty
->termios
= info
->normal_termios
;
1787 *tty
->termios
= info
->callout_termios
;
1788 change_speed(info
, 0);
1790 #ifdef CONFIG_SERIAL_CONSOLE
1791 if (sercons
.cflag
&& sercons
.index
== line
) {
1792 tty
->termios
->c_cflag
= sercons
.cflag
;
1794 change_speed(info
, 0);
1798 info
->session
= current
->session
;
1799 info
->pgrp
= current
->pgrp
;
1801 #ifdef SERIAL_DEBUG_OPEN
1802 printk("rs_open ttys%d successful...\n", info
->line
);
1807 /* Finally, routines used to initialize the serial driver. */
1809 static void show_serial_version(void)
1811 printk("PowerMac Z8530 serial driver version 1.01\n");
1814 /* Ask the PROM how many Z8530s we have and initialize their zs_channels */
1818 struct device_node
*dev
, *ch
;
1819 struct mac_serial
**pp
;
1824 for (dev
= find_devices("escc"); dev
!= 0; dev
= dev
->next
) {
1825 if (n
>= NUM_CHANNELS
) {
1826 printk("Sorry, can't use %s: no more channels\n",
1830 for (ch
= dev
->child
; ch
!= 0; ch
= ch
->sibling
) {
1831 if (ch
->n_addrs
< 1 || (ch
->n_intrs
< 1)) {
1832 printk("Can't use %s: %d addrs %d intrs\n",
1833 ch
->full_name
, ch
->n_addrs
, ch
->n_intrs
);
1836 zs_channels
[n
].control
= (volatile unsigned char *)
1837 ioremap(ch
->addrs
[0].address
, 0x1000);
1838 zs_channels
[n
].data
= zs_channels
[n
].control
+ 0x10;
1839 spin_lock_init(&zs_channels
[n
].lock
);
1840 zs_soft
[n
].zs_channel
= &zs_channels
[n
];
1841 zs_soft
[n
].dev_node
= ch
;
1842 zs_soft
[n
].irq
= ch
->intrs
[0].line
;
1843 zs_soft
[n
].zs_channel
->parent
= &zs_soft
[n
];
1844 zs_soft
[n
].is_cobalt_modem
= device_is_compatible(ch
, "cobalt");
1846 /* XXX tested only with wallstreet PowerBook, should do no harm anyway */
1847 zs_soft
[n
].is_pwbk_ir
= (strcmp(get_property(ch
, "AAPL,connector",
1848 &lenp
), "infrared") == 0);
1850 /* XXX this assumes the prom puts chan A before B */
1852 zs_soft
[n
].zs_chan_a
= &zs_channels
[n
-1];
1854 zs_soft
[n
].zs_chan_a
= &zs_channels
[n
];
1857 pp
= &zs_soft
[n
].zs_next
;
1862 zs_channels_found
= n
;
1865 /* rs_init inits the driver */
1866 int macserial_init(void)
1869 unsigned long flags
;
1870 struct mac_serial
*info
;
1872 /* Setup base handler, and timer table. */
1873 init_bh(MACSERIAL_BH
, do_serial_bh
);
1874 timer_table
[RS_TIMER
].fn
= rs_timer
;
1875 timer_table
[RS_TIMER
].expires
= 0;
1877 /* Find out how many Z8530 SCCs we have */
1881 /* XXX assume it's a powerbook if we have a via-pmu */
1882 is_powerbook
= find_devices("via-pmu") != 0;
1884 /* Register the interrupt handler for each one */
1885 save_flags(flags
); cli();
1886 for (i
= 0; i
< zs_channels_found
; ++i
) {
1887 if (request_irq(zs_soft
[i
].irq
, rs_interrupt
, 0,
1888 "SCC", &zs_soft
[i
]))
1889 printk(KERN_ERR
"macserial: can't get irq %d\n",
1891 disable_irq(zs_soft
[i
].irq
);
1893 restore_flags(flags
);
1895 show_serial_version();
1897 /* Initialize the tty_driver structure */
1898 /* Not all of this is exactly right for us. */
1900 memset(&serial_driver
, 0, sizeof(struct tty_driver
));
1901 serial_driver
.magic
= TTY_DRIVER_MAGIC
;
1902 serial_driver
.name
= "ttyS";
1903 serial_driver
.major
= TTY_MAJOR
;
1904 serial_driver
.minor_start
= 64;
1905 serial_driver
.num
= zs_channels_found
;
1906 serial_driver
.type
= TTY_DRIVER_TYPE_SERIAL
;
1907 serial_driver
.subtype
= SERIAL_TYPE_NORMAL
;
1908 serial_driver
.init_termios
= tty_std_termios
;
1910 serial_driver
.init_termios
.c_cflag
=
1911 B38400
| CS8
| CREAD
| HUPCL
| CLOCAL
;
1912 serial_driver
.flags
= TTY_DRIVER_REAL_RAW
;
1913 serial_driver
.refcount
= &serial_refcount
;
1914 serial_driver
.table
= serial_table
;
1915 serial_driver
.termios
= serial_termios
;
1916 serial_driver
.termios_locked
= serial_termios_locked
;
1918 serial_driver
.open
= rs_open
;
1919 serial_driver
.close
= rs_close
;
1920 serial_driver
.write
= rs_write
;
1921 serial_driver
.flush_chars
= rs_flush_chars
;
1922 serial_driver
.write_room
= rs_write_room
;
1923 serial_driver
.chars_in_buffer
= rs_chars_in_buffer
;
1924 serial_driver
.flush_buffer
= rs_flush_buffer
;
1925 serial_driver
.ioctl
= rs_ioctl
;
1926 serial_driver
.throttle
= rs_throttle
;
1927 serial_driver
.unthrottle
= rs_unthrottle
;
1928 serial_driver
.set_termios
= rs_set_termios
;
1929 serial_driver
.stop
= rs_stop
;
1930 serial_driver
.start
= rs_start
;
1931 serial_driver
.hangup
= rs_hangup
;
1932 serial_driver
.break_ctl
= rs_break
;
1933 serial_driver
.wait_until_sent
= rs_wait_until_sent
;
1936 * The callout device is just like normal device except for
1937 * major number and the subtype code.
1939 callout_driver
= serial_driver
;
1940 callout_driver
.name
= "cua";
1941 callout_driver
.major
= TTYAUX_MAJOR
;
1942 callout_driver
.subtype
= SERIAL_TYPE_CALLOUT
;
1944 if (tty_register_driver(&serial_driver
))
1945 panic("Couldn't register serial driver\n");
1946 if (tty_register_driver(&callout_driver
))
1947 panic("Couldn't register callout driver\n");
1949 for (channel
= 0; channel
< zs_channels_found
; ++channel
) {
1951 if (zs_soft
[channel
].kgdb_channel
) {
1952 kgdb_interruptible(1);
1956 zs_soft
[channel
].clk_divisor
= 16;
1957 /* -- we are not sure the SCC is powered ON at this point
1958 zs_soft[channel].zs_baud = get_zsbaud(&zs_soft[channel]);
1960 zs_soft
[channel
].zs_baud
= 38400;
1962 /* If console serial line, then enable interrupts. */
1963 if (zs_soft
[channel
].is_cons
) {
1964 printk("macserial: console line, enabling interrupt %d\n", zs_soft
[channel
].irq
);
1965 panic("macserial: console not supported yet !");
1966 write_zsreg(zs_soft
[channel
].zs_channel
, R1
,
1967 (EXT_INT_ENAB
| INT_ALL_Rx
| TxINT_ENAB
));
1968 write_zsreg(zs_soft
[channel
].zs_channel
, R9
,
1973 for (info
= zs_chain
, i
= 0; info
; info
= info
->zs_next
, i
++)
1975 unsigned char* connector
;
1979 if (info
->kgdb_channel
) {
1983 info
->magic
= SERIAL_MAGIC
;
1984 info
->port
= (int) info
->zs_channel
->control
;
1987 info
->custom_divisor
= 16;
1989 info
->close_delay
= 50;
1990 info
->closing_wait
= 3000;
1994 info
->blocked_open
= 0;
1995 info
->tqueue
.routine
= do_softint
;
1996 info
->tqueue
.data
= info
;
1997 info
->callout_termios
=callout_driver
.init_termios
;
1998 info
->normal_termios
= serial_driver
.init_termios
;
1999 init_waitqueue_head(&info
->open_wait
);
2000 init_waitqueue_head(&info
->close_wait
);
2002 printk("tty%02d at 0x%08x (irq = %d)", info
->line
,
2003 info
->port
, info
->irq
);
2004 printk(" is a Z8530 ESCC");
2005 connector
= get_property(info
->dev_node
, "AAPL,connector", &lenp
);
2007 printk(", port = %s", connector
);
2008 if (info
->is_cobalt_modem
)
2009 printk(" (cobalt modem)");
2010 if (info
->is_pwbk_ir
)
2011 printk(" (powerbook IR)");
2015 if (info
->kgdb_channel
)
2019 if (!info
->is_cobalt_modem
)
2022 /* By default, disable the port */
2023 set_scc_power(info
, 0);
2031 * register_serial and unregister_serial allows for serial ports to be
2032 * configured at run-time, to support PCMCIA modems.
2034 /* PowerMac: Unused at this time, just here to make things link. */
2035 int register_serial(struct serial_struct
*req
)
2040 void unregister_serial(int line
)
2047 * ------------------------------------------------------------
2048 * Serial console driver
2049 * ------------------------------------------------------------
2051 #ifdef CONFIG_SERIAL_CONSOLE
2055 * Print a string to the serial port trying not to disturb
2056 * any possible real use of the port...
2058 static void serial_console_write(struct console
*co
, const char *s
,
2061 struct mac_serial
*info
= zs_soft
+ co
->index
;
2064 /* Turn of interrupts and enable the transmitter. */
2065 write_zsreg(info
->zs_channel
, R1
, info
->curregs
[1] & ~TxINT_ENAB
);
2066 write_zsreg(info
->zs_channel
, R5
, info
->curregs
[5] | TxENAB
| RTS
| DTR
);
2068 for (i
=0; i
<count
; i
++) {
2069 /* Wait for the transmit buffer to empty. */
2070 while ((read_zsreg(info
->zs_channel
, 0) & Tx_BUF_EMP
) == 0) {
2074 write_zsdata(info
->zs_channel
, s
[i
]);
2076 while ((read_zsreg(info
->zs_channel
, 0) & Tx_BUF_EMP
)
2080 write_zsdata(info
->zs_channel
, 13);
2084 /* Restore the values in the registers. */
2085 write_zsreg(info
->zs_channel
, R1
, info
->curregs
[1]);
2086 /* Don't disable the transmitter. */
2090 * Receive character from the serial port
2092 static int serial_console_wait_key(struct console
*co
)
2094 struct mac_serial
*info
= zs_soft
+ co
->index
;
2097 /* Turn of interrupts and enable the transmitter. */
2098 write_zsreg(info
->zs_channel
, R1
, info
->curregs
[1] & ~INT_ALL_Rx
);
2099 write_zsreg(info
->zs_channel
, R3
, info
->curregs
[3] | RxENABLE
);
2101 /* Wait for something in the receive buffer. */
2102 while((read_zsreg(info
->zs_channel
, 0) & Rx_CH_AV
) == 0)
2104 val
= read_zsdata(info
->zs_channel
);
2106 /* Restore the values in the registers. */
2107 write_zsreg(info
->zs_channel
, R1
, info
->curregs
[1]);
2108 write_zsreg(info
->zs_channel
, R3
, info
->curregs
[3]);
2113 static kdev_t
serial_console_device(struct console
*c
)
2115 return MKDEV(TTY_MAJOR
, 64 + c
->index
);
2119 * Setup initial baud/bits/parity. We do two things here:
2120 * - construct a cflag setting for the first rs_open()
2121 * - initialize the serial port
2122 * Return non-zero if we didn't find a serial port.
2124 __initfunc(static int serial_console_setup(struct console
*co
, char *options
))
2126 struct mac_serial
*info
= zs_soft
+ co
->index
;
2130 int cflag
= CREAD
| HUPCL
| CLOCAL
;
2135 /* Find out how many Z8530 SCCs we have */
2142 /* Reset the channel */
2143 write_zsreg(info
->zs_channel
, R9
, CHRA
);
2146 baud
= simple_strtoul(options
, NULL
, 10);
2148 while(*s
>= '0' && *s
<= '9')
2157 * Now construct a cflag setting.
2197 cflag
|= PARENB
| PARODD
;
2205 save_flags(flags
); cli();
2206 memset(info
->curregs
, 0, sizeof(info
->curregs
));
2208 info
->zs_baud
= baud
;
2209 info
->clk_divisor
= 16;
2210 switch (info
->zs_baud
) {
2211 case ZS_CLOCK
/16: /* 230400 */
2212 info
->curregs
[4] = X16CLK
;
2213 info
->curregs
[11] = 0;
2215 case ZS_CLOCK
/32: /* 115200 */
2216 info
->curregs
[4] = X32CLK
;
2217 info
->curregs
[11] = 0;
2220 info
->curregs
[4] = X16CLK
;
2221 info
->curregs
[11] = TCBR
| RCBR
;
2222 brg
= BPS_TO_BRG(info
->zs_baud
, ZS_CLOCK
/info
->clk_divisor
);
2223 info
->curregs
[12] = (brg
& 255);
2224 info
->curregs
[13] = ((brg
>> 8) & 255);
2225 info
->curregs
[14] = BRENABL
;
2228 /* byte size and parity */
2229 info
->curregs
[3] &= ~RxNBITS_MASK
;
2230 info
->curregs
[5] &= ~TxNBITS_MASK
;
2231 switch (cflag
& CSIZE
) {
2233 info
->curregs
[3] |= Rx5
;
2234 info
->curregs
[5] |= Tx5
;
2237 info
->curregs
[3] |= Rx6
;
2238 info
->curregs
[5] |= Tx6
;
2241 info
->curregs
[3] |= Rx7
;
2242 info
->curregs
[5] |= Tx7
;
2245 default: /* defaults to 8 bits */
2246 info
->curregs
[3] |= Rx8
;
2247 info
->curregs
[5] |= Tx8
;
2250 info
->curregs
[5] |= TxENAB
| RTS
| DTR
;
2251 info
->pendregs
[3] = info
->curregs
[3];
2252 info
->pendregs
[5] = info
->curregs
[5];
2254 info
->curregs
[4] &= ~(SB_MASK
| PAR_ENA
| PAR_EVEN
);
2255 if (cflag
& CSTOPB
) {
2256 info
->curregs
[4] |= SB2
;
2258 info
->curregs
[4] |= SB1
;
2260 if (cflag
& PARENB
) {
2261 info
->curregs
[4] |= PAR_ENA
;
2262 if (!(cflag
& PARODD
)) {
2263 info
->curregs
[4] |= PAR_EVEN
;
2266 info
->pendregs
[4] = info
->curregs
[4];
2268 if (!(cflag
& CLOCAL
)) {
2269 if (!(info
->curregs
[15] & DCDIE
))
2270 info
->read_reg_zero
= read_zsreg(info
->zs_channel
, 0);
2271 info
->curregs
[15] |= DCDIE
;
2273 info
->curregs
[15] &= ~DCDIE
;
2274 if (cflag
& CRTSCTS
) {
2275 info
->curregs
[15] |= CTSIE
;
2276 if ((read_zsreg(info
->zs_channel
, 0) & CTS
) != 0)
2277 info
->tx_stopped
= 1;
2279 info
->curregs
[15] &= ~CTSIE
;
2280 info
->tx_stopped
= 0;
2282 info
->pendregs
[15] = info
->curregs
[15];
2284 /* Load up the new values */
2285 load_zsregs(info
->zs_channel
, info
->curregs
);
2287 restore_flags(flags
);
2292 static struct console sercons
= {
2294 serial_console_write
,
2296 serial_console_device
,
2297 serial_console_wait_key
,
2299 serial_console_setup
,
2309 __initfunc (long serial_console_init(long kmem_start
, long kmem_end
))
2311 register_console(&sercons
);
2314 #endif /* ifdef CONFIG_SERIAL_CONSOLE */
2317 /* These are for receiving and sending characters under the kgdb
2318 * source level kernel debugger.
2320 void putDebugChar(char kgdb_char
)
2322 struct mac_zschannel
*chan
= zs_kgdbchan
;
2323 while ((read_zsreg(chan
, 0) & Tx_BUF_EMP
) == 0)
2325 write_zsdata(chan
, kgdb_char
);
2328 char getDebugChar(void)
2330 struct mac_zschannel
*chan
= zs_kgdbchan
;
2331 while((read_zsreg(chan
, 0) & Rx_CH_AV
) == 0)
2332 eieio(); /*barrier();*/
2333 return read_zsdata(chan
);
2336 void kgdb_interruptible(int yes
)
2338 struct mac_zschannel
*chan
= zs_kgdbchan
;
2340 nine
= read_zsreg(chan
, 9);
2342 one
= EXT_INT_ENAB
|INT_ALL_Rx
;
2344 printk("turning serial ints on\n");
2348 printk("turning serial ints off\n");
2350 write_zsreg(chan
, 1, one
);
2351 write_zsreg(chan
, 9, nine
);
2354 /* This sets up the serial port we're using, and turns on
2355 * interrupts for that channel, so kgdb is usable once we're done.
2357 static inline void kgdb_chaninit(struct mac_zschannel
*ms
, int intson
, int bps
)
2361 volatile char *sccc
= ms
->control
;
2362 brg
= BPS_TO_BRG(bps
, ZS_CLOCK
/16);
2363 printk("setting bps on kgdb line to %d [brg=%x]\n", bps
, brg
);
2364 for (i
= 20000; i
!= 0; --i
) {
2367 for (i
= 0; i
< sizeof(scc_inittab
); ++i
) {
2368 write_zsreg(ms
, scc_inittab
[i
], scc_inittab
[i
+1]);
2373 /* This is called at boot time to prime the kgdb serial debugging
2374 * serial line. The 'tty_num' argument is 0 for /dev/ttya and 1
2375 * for /dev/ttyb which is determined in setup_arch() from the
2376 * boot command line flags.
2377 * XXX at the moment probably only channel A will work
2379 __initfunc(void zs_kgdb_hook(int tty_num
))
2381 /* Find out how many Z8530 SCCs we have */
2385 set_scc_power(&zs_soft
[n
], 1);
2387 zs_kgdbchan
= zs_soft
[tty_num
].zs_channel
;
2388 zs_soft
[tty_num
].change_needed
= 0;
2389 zs_soft
[tty_num
].clk_divisor
= 16;
2390 zs_soft
[tty_num
].zs_baud
= 38400;
2391 zs_soft
[tty_num
].kgdb_channel
= 1; /* This runs kgdb */
2392 zs_soft
[tty_num
^ 1].kgdb_channel
= 0; /* This does not */
2394 /* Turn on transmitter/receiver at 8-bits/char */
2395 kgdb_chaninit(zs_soft
[tty_num
].zs_channel
, 1, 38400);
2396 printk("KGDB: on channel %d initialized\n", tty_num
);
2397 set_debug_traps(); /* init stub */
2399 #endif /* ifdef CONFIG_KGDB */