1 /* $NetBSD: cd18xx.c,v 1.26 2008/06/12 22:30:30 cegger Exp $ */
3 /* XXXad does this even compile? */
6 * Copyright (c) 1998, 2001 Matthew R. Green
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
33 * All rights reserved.
35 * This code is derived from software contributed to The NetBSD Foundation
36 * by Charles M. Hannum.
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
47 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
48 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
49 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
50 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
51 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
52 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
53 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
54 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
55 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
56 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
57 * POSSIBILITY OF SUCH DAMAGE.
61 * Copyright (c) 1991 The Regents of the University of California.
62 * All rights reserved.
64 * Redistribution and use in source and binary forms, with or without
65 * modification, are permitted provided that the following conditions
67 * 1. Redistributions of source code must retain the above copyright
68 * notice, this list of conditions and the following disclaimer.
69 * 2. Redistributions in binary form must reproduce the above copyright
70 * notice, this list of conditions and the following disclaimer in the
71 * documentation and/or other materials provided with the distribution.
72 * 3. Neither the name of the University nor the names of its contributors
73 * may be used to endorse or promote products derived from this software
74 * without specific prior written permission.
76 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
77 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
78 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
79 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
80 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
81 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
82 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
83 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
84 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
85 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
88 * @(#)com.c 7.5 (Berkeley) 5/16/91
92 * cirrus logic CL-CD180/CD1864/CD1865 driver, based in (large) parts on
93 * the com and z8530 drivers. thanks charles.
96 #include <sys/cdefs.h>
97 __KERNEL_RCSID(0, "$NetBSD: cd18xx.c,v 1.26 2008/06/12 22:30:30 cegger Exp $");
99 #include <sys/param.h>
100 #include <sys/conf.h>
101 #include <sys/device.h>
102 #include <sys/systm.h>
103 #include <sys/malloc.h>
104 #include <sys/proc.h>
105 #include <sys/kernel.h>
107 #include <sys/fcntl.h>
108 #include <sys/kauth.h>
109 #include <sys/intr.h>
113 #include <dev/ic/cd18xxvar.h>
114 #include <dev/ic/cd18xxreg.h>
122 /* macros to clear/set/test flags. */
123 #define SET(t, f) (t) |= (f)
124 #define CLR(t, f) (t) &= ~(f)
125 #define ISSET(t, f) ((t) & (f))
127 static void cdtty_attach(struct cd18xx_softc
*, int);
129 static inline void cd18xx_rint(struct cd18xx_softc
*, int *);
130 static inline void cd18xx_tint(struct cd18xx_softc
*, int *);
131 static inline void cd18xx_mint(struct cd18xx_softc
*, int *);
133 void cdtty_rxsoft(struct cd18xx_softc
*, struct cdtty_port
*, struct tty
*);
134 void cdtty_txsoft(struct cd18xx_softc
*, struct cdtty_port
*, struct tty
*);
135 void cdtty_stsoft(struct cd18xx_softc
*, struct cdtty_port
*, struct tty
*);
136 void cd18xx_softintr(void *);
138 dev_type_open(cdttyopen
);
139 dev_type_close(cdttyclose
);
140 dev_type_read(cdttyread
);
141 dev_type_write(cdttywrite
);
142 dev_type_ioctl(cdttyioctl
);
143 dev_type_stop(cdttystop
);
144 dev_type_tty(cdttytty
);
145 dev_type_poll(cdttypoll
);
147 const struct cdevsw cdtty_cdevsw
= {
148 cdttyopen
, cdttyclose
, cdttyread
, cdttywrite
, cdttyioctl
,
149 cdttystop
, cdttytty
, cdttypoll
, nommap
, ttykqfilter
, D_TTY
152 static void cdtty_shutdown(struct cd18xx_softc
*, struct cdtty_port
*);
153 static void cdttystart(struct tty
*);
154 static int cdttyparam(struct tty
*, struct termios
*);
155 static void cdtty_break(struct cd18xx_softc
*, struct cdtty_port
*, int);
156 static void cdtty_modem(struct cd18xx_softc
*, struct cdtty_port
*, int);
157 static int cdttyhwiflow(struct tty
*, int);
158 static void cdtty_hwiflow(struct cd18xx_softc
*, struct cdtty_port
*);
160 static void cdtty_loadchannelregs(struct cd18xx_softc
*,
161 struct cdtty_port
*);
163 /* default read buffer size */
164 u_int cdtty_rbuf_size
= CDTTY_RING_SIZE
;
166 /* Stop input when 3/4 of the ring is full; restart when only 1/4 is full. */
167 u_int cdtty_rbuf_hiwat
= (CDTTY_RING_SIZE
* 1) / 4;
168 u_int cdtty_rbuf_lowat
= (CDTTY_RING_SIZE
* 3) / 4;
172 #define CDD_INFO 0x0001
173 #define CDD_INTR 0x0002
174 int cd18xx_debug
= CDD_INTR
|CDD_INFO
;
175 # define DPRINTF(l, x) if (cd18xx_debug & l) printf x
177 # define DPRINTF(l, x) /* nothing */
180 /* Known supported revisions. */
183 u_char onehundred_pin
;
186 { CD180_GFRCR_REV_B
, 0, "CL-CD180 rev. B" },
187 { CD180_GFRCR_REV_C
, 0, "CL-CD180 rev. C" },
188 { CD1864_GFRCR_REVISION_A
, 1, "CL-CD1864 rev. A" },
189 { CD1865_GFRCR_REVISION_A
, 1, "CL-CD1865 rev. A" },
190 { CD1865_GFRCR_REVISION_B
, 1, "CL-CD1865 rev. B" },
191 { CD1865_GFRCR_REVISION_C
, 1, "CL-CD1865 rev. C" },
195 /* wait for the CCR to go to zero */
196 static inline int cd18xx_wait_ccr(struct cd18xx_softc
*);
198 cd18xx_wait_ccr(struct cd18xx_softc
*sc
)
203 bus_space_read_1(sc
->sc_tag
, sc
->sc_handle
, CD18xx_CCR
) != 0)
209 * device attach routine, high-end portion
212 cd18xx_attach(struct cd18xx_softc
*sc
)
214 static int chip_id_next
= 1;
215 int onehundred_pin
, revision
, i
, port
;
217 /* read and print the revision */
218 revision
= cd18xx_read(sc
, CD18xx_GFRCR
);
219 onehundred_pin
= ISSET(cd18xx_read(sc
, CD18xx_SRCR
),CD18xx_SRCR_PKGTYP
);
220 for (i
= 0; cd18xx_revs
[i
].name
; i
++)
221 if (revision
== cd18xx_revs
[i
].revision
||
222 onehundred_pin
== cd18xx_revs
[i
].onehundred_pin
) {
223 printf(": %s", cd18xx_revs
[i
].name
);
227 if (cd18xx_revs
[i
].name
== NULL
) {
228 aprint_error_dev(&sc
->sc_dev
, "unknown revision, bailing.\n");
232 /* prepare for reset */
233 cd18xx_set_car(sc
, 0);
234 cd18xx_write(sc
, CD18xx_GSVR
, CD18xx_GSVR_CLEAR
);
236 /* wait for CCR to go to zero */
237 if (cd18xx_wait_ccr(sc
)) {
238 printf("cd18xx_attach: reset change command timed out\n");
242 /* full reset of all channels */
243 cd18xx_write(sc
, CD18xx_CCR
,
244 CD18xx_CCR_RESET
|CD18xx_CCR_RESET_HARD
);
246 /* loop until the GSVR is ready */
248 while (--i
&& cd18xx_read(sc
, CD18xx_GSVR
) == CD18xx_GSVR_READY
)
252 aprint_error_dev(&sc
->sc_dev
, "did not reset!\n");
256 /* write the chip_id */
257 sc
->sc_chip_id
= chip_id_next
++;
259 if (sc
->sc_chip_id
> 31)
260 panic("more than 31 cd18xx's? help.");
262 cd18xx_write(sc
, CD18xx_GSVR
, CD18xx_GSVR_SETID(sc
));
264 /* rx/tx/modem service match vectors, initalised by higher level */
265 cd18xx_write(sc
, CD18xx_MSMR
, sc
->sc_msmr
| 0x80);
266 cd18xx_write(sc
, CD18xx_TSMR
, sc
->sc_tsmr
| 0x80);
267 cd18xx_write(sc
, CD18xx_RSMR
, sc
->sc_rsmr
| 0x80);
269 printf(", gsvr %x msmr %x tsmr %x rsmr %x",
270 cd18xx_read(sc
, CD18xx_GSVR
),
271 cd18xx_read(sc
, CD18xx_MSMR
),
272 cd18xx_read(sc
, CD18xx_TSMR
),
273 cd18xx_read(sc
, CD18xx_RSMR
));
275 /* prescale registers */
278 cd18xx_write(sc
, CD18xx_PPRH
, sc
->sc_pprh
);
279 cd18xx_write(sc
, CD18xx_PPRL
, sc
->sc_pprl
);
281 /* establish our soft interrupt. */
282 sc
->sc_si
= softint_establish(SOFTINT_SERIAL
, cd18xx_softintr
, sc
);
284 printf(", 8 ports ready (chip id %d)\n", sc
->sc_chip_id
);
287 * finally, we loop over all 8 channels initialising them
289 for (port
= 0; port
< 8; port
++)
290 cdtty_attach(sc
, port
);
293 /* tty portion of the code */
296 * tty portion attach routine
299 cdtty_attach(struct cd18xx_softc
*sc
, int port
)
301 struct cdtty_port
*p
= &sc
->sc_ports
[port
];
304 /* load CAR with channel number */
305 cd18xx_set_car(sc
, port
);
307 /* wait for CCR to go to zero */
308 if (cd18xx_wait_ccr(sc
)) {
309 printf("cd18xx_attach: change command timed out setting "
310 "CAR for port %d\n", i
);
314 /* set the RPTR to (arbitrary) 8 */
315 cd18xx_write(sc
, CD18xx_RTPR
, 8);
317 /* reset the modem signal value register */
318 sc
->sc_ports
[port
].p_msvr
= CD18xx_MSVR_RESET
;
320 /* zero the service request enable register */
321 cd18xx_write(sc
, CD18xx_SRER
, 0);
323 /* enable the transmitter & receiver */
324 SET(p
->p_chanctl
, CD18xx_CCR_CHANCTL
|
325 CD18xx_CCR_CHANCTL_TxEN
|
326 CD18xx_CCR_CHANCTL_RxEN
);
328 /* XXX no console or kgdb support yet! */
330 /* get a tty structure */
331 p
->p_tty
= ttymalloc();
332 p
->p_tty
->t_oproc
= cdttystart
;
333 p
->p_tty
->t_param
= cdttyparam
;
334 p
->p_tty
->t_hwiflow
= cdttyhwiflow
;
336 p
->p_rbuf
= malloc(cdtty_rbuf_size
<< 1, M_DEVBUF
, M_WAITOK
);
337 p
->p_rbput
= p
->p_rbget
= p
->p_rbuf
;
338 p
->p_rbavail
= cdtty_rbuf_size
;
339 if (p
->p_rbuf
== NULL
) {
340 aprint_error_dev(&sc
->sc_dev
, "unable to allocate ring buffer for tty %d\n", port
);
343 p
->p_ebuf
= p
->p_rbuf
+ (cdtty_rbuf_size
<< 1);
345 tty_attach(p
->p_tty
);
349 * cdtty_shutdown: called when the device is last closed.
352 cdtty_shutdown(struct cd18xx_softc
*sc
, struct cdtty_port
*p
)
354 struct tty
*tp
= p
->p_tty
;
359 /* If we were asserting flow control, then deassert it. */
360 SET(p
->p_rx_flags
, RX_IBUF_BLOCKED
);
361 cdtty_hwiflow(sc
, p
);
363 /* Clear any break condition set with TIOCSBRK. */
364 cdtty_break(sc
, p
, 0);
367 * Hang up if necessary. Wait a bit, so the other side has time to
368 * notice even if we immediately open the port again.
369 * Avoid tsleeping above splhigh().
371 if (ISSET(tp
->t_cflag
, HUPCL
)) {
372 cdtty_modem(sc
, p
, 0);
374 /* XXX tsleep will only timeout */
375 (void) tsleep(sc
, TTIPRI
, ttclos
, hz
);
379 /* Turn off interrupts. */
381 cd18xx_write(sc
, CD18xx_SRER
, p
->p_srer
);
387 * cdttyopen: open syscall for cdtty terminals..
390 cdttyopen(dev_t dev
, int flag
, int mode
, struct proc
*p
)
393 struct cd18xx_softc
*sc
;
394 struct cdtty_port
*port
;
395 int channel
, instance
, s
, error
;
397 channel
= CD18XX_CHANNEL(dev
);
398 instance
= CD18XX_INSTANCE(dev
);
400 /* ensure instance is valid */
401 if (instance
>= clcd_cd
.cd_ndevs
)
404 /* get softc and port */
405 sc
= device_lookup_private(&clcd_cd
, instance
);
408 port
= &sc
->sc_ports
[channel
];
409 if (port
== NULL
|| port
->p_rbuf
== NULL
)
412 /* kgdb support? maybe later... */
416 if (kauth_authorize_device_tty(l
->l_cred
, KAUTH_DEVICE_TTY_OPEN
, tp
))
422 * Do the following iff this is a first open.
424 if (!ISSET(tp
->t_state
, TS_ISOPEN
) && tp
->t_wopen
== 0) {
427 /* set up things in tp as necessary */
431 * Initialize the termios status to the defaults. Add in the
432 * sticky bits from TIOCSFLAGS.
435 t
.c_ospeed
= TTYDEF_SPEED
;
436 t
.c_cflag
= TTYDEF_CFLAG
;
438 if (ISSET(port
->p_swflags
, TIOCFLAG_CLOCAL
))
439 SET(t
.c_cflag
, CLOCAL
);
440 if (ISSET(port
->p_swflags
, TIOCFLAG_CRTSCTS
))
441 SET(t
.c_cflag
, CRTSCTS
);
442 if (ISSET(port
->p_swflags
, TIOCFLAG_CDTRCTS
))
443 SET(t
.c_cflag
, CDTRCTS
);
444 if (ISSET(port
->p_swflags
, TIOCFLAG_MDMBUF
))
445 SET(t
.c_cflag
, MDMBUF
);
447 /* Make sure param will see changes. */
448 tp
->t_ospeed
= 0; /* XXX set above ignored? */
449 (void)cdttyparam(tp
, &t
);
451 tp
->t_iflag
= TTYDEF_IFLAG
;
452 tp
->t_oflag
= TTYDEF_OFLAG
;
453 tp
->t_lflag
= TTYDEF_LFLAG
;
459 /* turn on rx and modem interrupts */
460 cd18xx_set_car(sc
, CD18XX_CHANNEL(dev
));
461 SET(port
->p_srer
, CD18xx_SRER_Rx
|
464 cd18xx_write(sc
, CD18xx_SRER
, port
->p_srer
);
466 /* always turn on DTR when open */
467 cdtty_modem(sc
, port
, 1);
469 /* initialise ring buffer */
470 port
->p_rbget
= port
->p_rbput
= port
->p_rbuf
;
471 port
->p_rbavail
= cdtty_rbuf_size
;
472 CLR(port
->p_rx_flags
, RX_ANY_BLOCK
);
473 cdtty_hwiflow(sc
, port
);
476 /* drop spl back before going into the line open */
479 error
= ttyopen(tp
, CD18XX_DIALOUT(dev
), ISSET(flag
, O_NONBLOCK
));
481 error
= (*tp
->t_linesw
->l_open
)(dev
, tp
);
487 * cdttyclose: close syscall for cdtty terminals..
490 cdttyclose(dev_t dev
, int flag
, int mode
, struct proc
*p
)
492 struct cd18xx_softc
*sc
;
493 struct cdtty_port
*port
;
495 int channel
, instance
;
497 channel
= CD18XX_CHANNEL(dev
);
498 instance
= CD18XX_INSTANCE(dev
);
500 /* ensure instance is valid */
501 if (instance
>= clcd_cd
.cd_ndevs
)
504 /* get softc and port */
505 sc
= device_lookup_private(&clcd_cd
, instance
);
508 port
= &sc
->sc_ports
[channel
];
512 (*tp
->t_linesw
->l_close
)(tp
, flag
);
515 if (!ISSET(tp
->t_state
, TS_ISOPEN
) && tp
->t_wopen
== 0) {
517 * Although we got a last close, the device may still be in
518 * use; e.g. if this was the dialout node, and there are still
519 * processes waiting for carrier on the non-dialout node.
521 cdtty_shutdown(sc
, port
);
528 * cdttyread: read syscall for cdtty terminals..
531 cdttyread(dev_t dev
, struct uio
*uio
, int flag
)
533 struct cd18xx_softc
*sc
= device_lookup_private(&clcd_cd
, CD18XX_INSTANCE(dev
));
534 struct cdtty_port
*port
= &sc
->sc_ports
[CD18XX_CHANNEL(dev
)];
535 struct tty
*tp
= port
->p_tty
;
537 return ((*tp
->t_linesw
->l_read
)(tp
, uio
, flag
));
541 * cdttywrite: write syscall for cdtty terminals..
544 cdttywrite(dev_t dev
, struct uio
*uio
, int flag
)
546 struct cd18xx_softc
*sc
= device_lookup_private(&clcd_cd
, CD18XX_INSTANCE(dev
));
547 struct cdtty_port
*port
= &sc
->sc_ports
[CD18XX_CHANNEL(dev
)];
548 struct tty
*tp
= port
->p_tty
;
550 return ((*tp
->t_linesw
->l_write
)(tp
, uio
, flag
));
554 cdttypoll(dev_t dev
, int events
, struct proc
*p
)
556 struct cd18xx_softc
*sc
= device_lookup_private(&clcd_cd
, CD18XX_INSTANCE(dev
));
557 struct cdtty_port
*port
= &sc
->sc_ports
[CD18XX_CHANNEL(dev
)];
558 struct tty
*tp
= port
->p_tty
;
560 return ((*tp
->t_linesw
->l_poll
)(tp
, events
, p
));
564 * cdttytty: return a pointer to our (cdtty) tp.
569 struct cd18xx_softc
*sc
= device_lookup_private(&clcd_cd
, CD18XX_INSTANCE(dev
));
570 struct cdtty_port
*port
= &sc
->sc_ports
[CD18XX_CHANNEL(dev
)];
572 return (port
->p_tty
);
576 * cdttyioctl: ioctl syscall for cdtty terminals..
579 cdttyioctl(dev_t dev
, u_long cmd
, void *data
, int flag
, struct proc
*p
)
581 struct cd18xx_softc
*sc
= device_lookup_private(&clcd_cd
, CD18XX_INSTANCE(dev
));
582 struct cdtty_port
*port
= &sc
->sc_ports
[CD18XX_CHANNEL(dev
)];
583 struct tty
*tp
= port
->p_tty
;
586 error
= (*tp
->t_linesw
->l_ioctl
)(tp
, cmd
, data
, flag
, p
);
587 if (error
!= EPASSTHROUGH
)
590 error
= ttioctl(tp
, cmd
, data
, flag
, p
);
591 if (error
!= EPASSTHROUGH
)
598 cdtty_break(sc
, port
, 1);
602 cdtty_break(sc
, port
, 0);
606 cdtty_modem(sc
, port
, 1);
610 cdtty_modem(sc
, port
, 0);
614 *(int *)data
= port
->p_swflags
;
618 error
= kauth_authorize_device_tty(l
->l_cred
,
619 KAUTH_DEVICE_TTY_PRIVSET
, tp
);
622 port
->p_swflags
= *(int *)data
;
630 return (EPASSTHROUGH
);
638 * Start or restart transmission.
641 cdttystart(struct tty
*tp
)
643 struct cd18xx_softc
*sc
= device_lookup_private(&clcd_cd
, CD18XX_INSTANCE(tp
->t_dev
));
644 struct cdtty_port
*p
= &sc
->sc_ports
[CD18XX_CHANNEL(tp
->t_dev
)];
648 if (ISSET(tp
->t_state
, TS_BUSY
| TS_TIMEOUT
| TS_TTSTOP
))
656 /* Grab the first contiguous region of buffer space. */
661 tba
= tp
->t_outq
.c_cf
;
662 tbc
= ndqb(&tp
->t_outq
, 0);
670 SET(tp
->t_state
, TS_BUSY
);
673 /* turn on tx interrupts */
674 if ((p
->p_srer
& CD18xx_SRER_Tx
) == 0) {
675 cd18xx_set_car(sc
, CD18XX_CHANNEL(tp
->t_dev
));
676 SET(p
->p_srer
, CD18xx_SRER_Tx
);
677 cd18xx_write(sc
, CD18xx_SRER
, p
->p_srer
);
681 * Now bail; we can't actually transmit bytes until we're in a
682 * transmit interrupt service routine.
690 * cdttystop: handing ^S or other stop signals, for a cdtty
693 cdttystop(struct tty
*tp
, int flag
)
695 struct cd18xx_softc
*sc
= device_lookup_private(&clcd_cd
, CD18XX_INSTANCE(tp
->t_dev
));
696 struct cdtty_port
*p
= &sc
->sc_ports
[CD18XX_CHANNEL(tp
->t_dev
)];
700 if (ISSET(tp
->t_state
, TS_BUSY
)) {
701 /* Stop transmitting at the next chunk. */
704 if (!ISSET(tp
->t_state
, TS_TTSTOP
))
705 SET(tp
->t_state
, TS_FLUSH
);
711 * load a channel's registers.
714 cdtty_loadchannelregs(struct cd18xx_softc
*sc
, struct cdtty_port
*p
)
717 cd18xx_set_car(sc
, CD18XX_CHANNEL(p
->p_tty
->t_dev
));
718 cd18xx_write(sc
, CD18xx_SRER
, p
->p_srer
);
719 cd18xx_write(sc
, CD18xx_MSVR
, p
->p_msvr_active
= p
->p_msvr
);
720 cd18xx_write(sc
, CD18xx_COR1
, p
->p_cor1
);
721 cd18xx_write(sc
, CD18xx_COR2
, p
->p_cor2
);
722 cd18xx_write(sc
, CD18xx_COR3
, p
->p_cor3
);
724 * COR2 and COR3 change commands are not required here for
725 * the CL-CD1865 but we do them anyway for simplicity.
727 cd18xx_write(sc
, CD18xx_CCR
, CD18xx_CCR_CORCHG
|
728 CD18xx_CCR_CORCHG_COR1
|
729 CD18xx_CCR_CORCHG_COR2
|
730 CD18xx_CCR_CORCHG_COR3
);
731 cd18xx_write(sc
, CD18xx_RBPRH
, p
->p_rbprh
);
732 cd18xx_write(sc
, CD18xx_RBPRL
, p
->p_rbprl
);
733 cd18xx_write(sc
, CD18xx_TBPRH
, p
->p_tbprh
);
734 cd18xx_write(sc
, CD18xx_TBPRL
, p
->p_tbprl
);
735 if (cd18xx_wait_ccr(sc
)) {
737 ("%s: cdtty_loadchannelregs ccr wait timed out\n",
738 device_xname(&sc
->sc_dev
)));
740 cd18xx_write(sc
, CD18xx_CCR
, p
->p_chanctl
);
744 * Set tty parameters from termios.
745 * XXX - Should just copy the whole termios after
746 * making sure all the changes could be done.
749 cdttyparam(struct tty
*tp
, struct termios
*t
)
751 struct cd18xx_softc
*sc
= device_lookup_private(&clcd_cd
, CD18XX_INSTANCE(tp
->t_dev
));
752 struct cdtty_port
*p
= &sc
->sc_ports
[CD18XX_CHANNEL(tp
->t_dev
)];
755 /* Check requested parameters. */
758 if (t
->c_ispeed
&& t
->c_ispeed
!= t
->c_ospeed
)
762 * For the console, always force CLOCAL and !HUPCL, so that the port
765 if (ISSET(p
->p_swflags
, TIOCFLAG_SOFTCAR
)) {
766 SET(t
->c_cflag
, CLOCAL
);
767 CLR(t
->c_cflag
, HUPCL
);
771 * If there were no changes, don't do anything. This avoids dropping
772 * input and improves performance when all we did was frob things like
775 if (tp
->t_ospeed
== t
->c_ospeed
&&
776 tp
->t_cflag
== t
->c_cflag
)
780 * Block interrupts so that state will not
781 * be altered until we are done setting it up.
786 * Copy across the size, parity and stop bit info.
788 switch (t
->c_cflag
& CSIZE
) {
790 p
->p_cor1
= CD18xx_COR1_CS5
;
793 p
->p_cor1
= CD18xx_COR1_CS6
;
796 p
->p_cor1
= CD18xx_COR1_CS7
;
799 p
->p_cor1
= CD18xx_COR1_CS8
;
802 if (ISSET(t
->c_cflag
, PARENB
)) {
803 SET(p
->p_cor1
, CD18xx_COR1_PARITY_NORMAL
);
804 if (ISSET(t
->c_cflag
, PARODD
))
805 SET(p
->p_cor1
, CD18xx_COR1_PARITY_ODD
);
807 if (!ISSET(t
->c_iflag
, INPCK
))
808 SET(p
->p_cor1
, CD18xx_COR1_IGNORE
);
809 if (ISSET(t
->c_cflag
, CSTOPB
))
810 SET(p
->p_cor1
, CD18xx_COR1_STOPBIT_2
);
813 * If we're not in a mode that assumes a connection is present, then
814 * ignore carrier changes.
816 if (ISSET(t
->c_cflag
, CLOCAL
| MDMBUF
))
819 p
->p_msvr_dcd
= CD18xx_MSVR_CD
;
822 * Set the flow control pins depending on the current flow control
825 if (ISSET(t
->c_cflag
, CRTSCTS
)) {
826 p
->p_mcor1_dtr
= CD18xx_MCOR1_DTR
;
827 p
->p_msvr_rts
= CD18xx_MSVR_RTS
;
828 p
->p_msvr_cts
= CD18xx_MSVR_CTS
;
829 p
->p_cor2
= CD18xx_COR2_RTSAOE
|CD18xx_COR2_CTSAE
;
830 } else if (ISSET(t
->c_cflag
, MDMBUF
)) {
832 * For DTR/DCD flow control, make sure we don't toggle DTR for
836 p
->p_msvr_rts
= CD18xx_MSVR_DTR
;
837 p
->p_msvr_cts
= CD18xx_MSVR_CD
;
841 * If no flow control, then always set RTS. This will make
842 * the other side happy if it mistakenly thinks we're doing
843 * RTS/CTS flow control.
845 p
->p_mcor1_dtr
= CD18xx_MSVR_DTR
;
850 p
->p_msvr_mask
= p
->p_msvr_cts
| p
->p_msvr_dcd
;
853 * Set the FIFO threshold based on the receive speed.
855 * * If it's a low speed, it's probably a mouse or some other
856 * interactive device, so set the threshold low.
857 * * If it's a high speed, trim the trigger level down to prevent
859 * * Otherwise set it a bit higher.
861 p
->p_cor3
= (t
->c_ospeed
<= 1200 ? 1 : t
->c_ospeed
<= 38400 ? 8 : 4);
863 #define PORT_RATE(o, s) \
864 (((((o) + (s)/2) / (s)) + CD18xx_xBRPR_TPC/2) / CD18xx_xBRPR_TPC)
865 /* Compute BPS for the requested speeds */
867 u_int32_t tbpr
= PORT_RATE(sc
->sc_osc
, t
->c_ospeed
);
869 if (tbpr
== 0 || tbpr
> 0xffff)
872 p
->p_tbprh
= tbpr
>> 8;
873 p
->p_tbprl
= tbpr
& 0xff;
877 u_int32_t rbpr
= PORT_RATE(sc
->sc_osc
, t
->c_ispeed
);
879 if (rbpr
== 0 || rbpr
> 0xffff)
882 p
->p_rbprh
= rbpr
>> 8;
883 p
->p_rbprl
= rbpr
& 0xff;
886 /* And copy to tty. */
888 tp
->t_ospeed
= t
->c_ospeed
;
889 tp
->t_cflag
= t
->c_cflag
;
891 if (!p
->p_heldchange
) {
893 p
->p_heldtbc
= p
->p_tbc
;
897 cdtty_loadchannelregs(sc
, p
);
900 if (!ISSET(t
->c_cflag
, CHWFLOW
)) {
901 /* Disable the high water mark. */
904 if (ISSET(p
->p_rx_flags
, RX_TTY_OVERFLOWED
)) {
905 CLR(p
->p_rx_flags
, RX_TTY_OVERFLOWED
);
906 softint_schedule(sc
->sc_si
);
908 if (ISSET(p
->p_rx_flags
, RX_TTY_BLOCKED
|RX_IBUF_BLOCKED
)) {
909 CLR(p
->p_rx_flags
, RX_TTY_BLOCKED
|RX_IBUF_BLOCKED
);
910 cdtty_hwiflow(sc
, p
);
913 p
->p_r_hiwat
= cdtty_rbuf_hiwat
;
914 p
->p_r_lowat
= cdtty_rbuf_lowat
;
920 * Update the tty layer's idea of the carrier bit, in case we changed
921 * CLOCAL or MDMBUF. We don't hang up here; we only do that by
924 (void) (*tp
->t_linesw
->l_modem
)(tp
, ISSET(p
->p_msvr
, CD18xx_MSVR_CD
));
926 if (!ISSET(t
->c_cflag
, CHWFLOW
)) {
927 if (p
->p_tx_stopped
) {
937 cdtty_break(struct cd18xx_softc
*sc
, struct cdtty_port
*p
, int onoff
)
940 /* tell tx intr handler we need a break */
941 p
->p_needbreak
= !!onoff
;
943 /* turn on tx interrupts if break has changed */
944 if (p
->p_needbreak
!= p
->p_break
)
945 SET(p
->p_srer
, CD18xx_SRER_Tx
);
947 if (!p
->p_heldchange
) {
949 p
->p_heldtbc
= p
->p_tbc
;
953 cdtty_loadchannelregs(sc
, p
);
958 * Raise or lower modem control (DTR/RTS) signals. If a character is
959 * in transmission, the change is deferred.
962 cdtty_modem(struct cd18xx_softc
*sc
, struct cdtty_port
*p
, int onoff
)
965 if (p
->p_mcor1_dtr
== 0)
969 CLR(p
->p_mcor1
, p
->p_mcor1_dtr
);
971 SET(p
->p_mcor1
, p
->p_mcor1_dtr
);
973 if (!p
->p_heldchange
) {
975 p
->p_heldtbc
= p
->p_tbc
;
979 cdtty_loadchannelregs(sc
, p
);
984 * Try to block or unblock input using hardware flow-control.
985 * This is called by kern/tty.c if MDMBUF|CRTSCTS is set, and
986 * if this function returns non-zero, the TS_TBLOCK flag will
987 * be set or cleared according to the "block" arg passed.
990 cdttyhwiflow(struct tty
*tp
, int block
)
992 struct cd18xx_softc
*sc
= device_lookup_private(&clcd_cd
, CD18XX_INSTANCE(tp
->t_dev
));
993 struct cdtty_port
*p
= &sc
->sc_ports
[CD18XX_CHANNEL(tp
->t_dev
)];
996 if (p
->p_msvr_rts
== 0)
1001 if (!ISSET(p
->p_rx_flags
, RX_TTY_BLOCKED
)) {
1002 SET(p
->p_rx_flags
, RX_TTY_BLOCKED
);
1003 cdtty_hwiflow(sc
, p
);
1006 if (ISSET(p
->p_rx_flags
, RX_TTY_OVERFLOWED
)) {
1007 CLR(p
->p_rx_flags
, RX_TTY_OVERFLOWED
);
1008 softint_schedule(sc
->sc_si
);
1010 if (ISSET(p
->p_rx_flags
, RX_TTY_BLOCKED
)) {
1011 CLR(p
->p_rx_flags
, RX_TTY_BLOCKED
);
1012 cdtty_hwiflow(sc
, p
);
1020 * Internal version of cdttyhwiflow, called at cdtty's priority.
1023 cdtty_hwiflow(struct cd18xx_softc
*sc
, struct cdtty_port
*p
)
1026 if (p
->p_msvr_rts
== 0)
1029 if (ISSET(p
->p_rx_flags
, RX_ANY_BLOCK
)) {
1030 CLR(p
->p_msvr
, p
->p_msvr_rts
);
1031 CLR(p
->p_msvr_active
, p
->p_msvr_rts
);
1033 SET(p
->p_msvr
, p
->p_msvr_rts
);
1034 SET(p
->p_msvr_active
, p
->p_msvr_rts
);
1036 cd18xx_set_car(sc
, CD18XX_CHANNEL(p
->p_tty
->t_dev
));
1037 cd18xx_write(sc
, CD18xx_MSVR
, p
->p_msvr_active
);
1041 * indiviual interrupt routines.
1045 * this is the number of interrupts allowed, total. set it to 0
1046 * to allow unlimited interrpts
1048 #define INTR_MAX_ALLOWED 0
1050 #if INTR_MAX_ALLOWED == 0
1051 #define GOTINTR(sc, p) /* nothing */
1054 #define GOTINTR(sc, p) \
1056 if (intrcount++ == INTR_MAX_ALLOWED) { \
1057 CLR(p->p_srer, CD18xx_SRER_Tx); \
1058 cd18xx_write(sc, CD18xx_SRER, p->p_srer); \
1060 DPRINTF(CDD_INTR, (", intrcount %d srer %x", intrcount, p->p_srer)); \
1064 /* receiver interrupt */
1066 cd18xx_rint(struct cd18xx_softc
*sc
, int *ns
)
1068 struct cdtty_port
*p
;
1069 u_int channel
, count
;
1073 /* work out the channel and softc */
1074 channel
= cd18xx_get_gscr1_channel(sc
);
1075 p
= &sc
->sc_ports
[channel
];
1076 DPRINTF(CDD_INTR
, ("%s: rint: channel %d", device_xname(&sc
->sc_dev
), channel
));
1083 /* read as many bytes as necessary */
1084 count
= cd18xx_read(sc
, CD18xx_RDCR
);
1085 DPRINTF(CDD_INTR
, (", %d bytes available: ", count
));
1087 while (cc
> 0 && count
> 0) {
1088 u_char rcsr
= cd18xx_read(sc
, CD18xx_RCSR
);
1090 put
[0] = cd18xx_read(sc
, CD18xx_RDR
);
1100 DPRINTF(CDD_INTR
, ("."));
1105 DPRINTF(CDD_INTR
, (" finished reading"));
1108 * Current string of incoming characters ended because
1109 * no more data was available or we ran out of space.
1110 * If we're out of space, turn off receive interrupts.
1114 if (!ISSET(p
->p_rx_flags
, RX_TTY_OVERFLOWED
)) {
1119 * If we're out of space, disable receive interrupts
1120 * until the queue has drained a bit.
1123 SET(p
->p_rx_flags
, RX_IBUF_OVERFLOWED
);
1124 CLR(p
->p_srer
, CD18xx_SRER_Rx
|
1127 cd18xx_write(sc
, CD18xx_SRER
, p
->p_srer
);
1130 /* finish the interrupt transaction with the IC */
1131 cd18xx_write(sc
, CD18xx_EOSRR
, 0);
1132 DPRINTF(CDD_INTR
, (", done\n"));
1136 * transmitter interrupt
1138 * note this relys on the fact that we allow the transmitter FIFO to
1142 cd18xx_tint(struct cd18xx_softc
*sc
, int *ns
)
1144 struct cdtty_port
*p
;
1147 /* work out the channel and softc */
1148 channel
= cd18xx_get_gscr1_channel(sc
);
1149 p
= &sc
->sc_ports
[channel
];
1150 DPRINTF(CDD_INTR
, ("%s: tint: channel %d", device_xname(&sc
->sc_dev
),
1154 /* if the current break condition is wrong, fix it */
1155 if (p
->p_break
!= p
->p_needbreak
) {
1158 DPRINTF(CDD_INTR
, (", changing break to %d", p
->p_needbreak
));
1160 /* turn on ETC processing */
1161 cd18xx_write(sc
, CD18xx_COR2
, p
->p_cor2
| CD18xx_COR2_ETC
);
1163 buf
[0] = CD18xx_TDR_ETC_BYTE
;
1164 buf
[1] = p
->p_needbreak
? CD18xx_TDR_BREAK_BYTE
:
1165 CD18xx_TDR_NOBREAK_BYTE
;
1166 cd18xx_write_multi(sc
, CD18xx_TDR
, buf
, 2);
1168 p
->p_break
= p
->p_needbreak
;
1170 /* turn off ETC processing */
1171 cd18xx_write(sc
, CD18xx_COR2
, p
->p_cor2
);
1175 * If we've delayed a parameter change, do it now, and restart
1178 if (p
->p_heldchange
) {
1179 cdtty_loadchannelregs(sc
, p
);
1180 p
->p_heldchange
= 0;
1181 p
->p_tbc
= p
->p_heldtbc
;
1185 /* Output the next chunk of the contiguous buffer, if any. */
1190 if (n
> 8) /* write up to 8 entries */
1192 DPRINTF(CDD_INTR
, (", writing %d bytes to TDR", n
));
1193 cd18xx_write_multi(sc
, CD18xx_TDR
, p
->p_tba
, n
);
1198 /* Disable transmit completion interrupts if we ran out of bytes. */
1199 if (p
->p_tbc
== 0) {
1200 /* Note that Tx interrupts should already be enabled */
1201 if (ISSET(p
->p_srer
, CD18xx_SRER_Tx
)) {
1202 DPRINTF(CDD_INTR
, (", disabling tx interrupts"));
1203 CLR(p
->p_srer
, CD18xx_SRER_Tx
);
1204 cd18xx_write(sc
, CD18xx_SRER
, p
->p_srer
);
1213 /* finish the interrupt transaction with the IC */
1214 cd18xx_write(sc
, CD18xx_EOSRR
, 0);
1215 DPRINTF(CDD_INTR
, (", done\n"));
1218 /* modem signal change interrupt */
1220 cd18xx_mint(struct cd18xx_softc
*sc
, int *ns
)
1222 struct cdtty_port
*p
;
1226 /* work out the channel and softc */
1227 channel
= cd18xx_get_gscr1_channel(sc
);
1228 p
= &sc
->sc_ports
[channel
];
1229 DPRINTF(CDD_INTR
, ("%s: mint: channel %d", device_xname(&sc
->sc_dev
), channel
));
1233 * We ignore the MCR register, and handle detecting deltas
1234 * via software, like many other serial drivers.
1236 msvr
= cd18xx_read(sc
, CD18xx_MSVR
);
1237 delta
= msvr
^ p
->p_msvr
;
1238 DPRINTF(CDD_INTR
, (", msvr %d", msvr
));
1241 * Process normal status changes
1243 if (ISSET(delta
, p
->p_msvr_mask
)) {
1244 SET(p
->p_msvr_delta
, delta
);
1246 DPRINTF(CDD_INTR
, (", status changed delta %d", delta
));
1248 * Stop output immediately if we lose the output
1249 * flow control signal or carrier detect.
1251 if (ISSET(~msvr
, p
->p_msvr_mask
)) {
1254 /* Stop modem interrupt processing */
1260 /* reset the modem signal register */
1261 cd18xx_write(sc
, CD18xx_MCR
, 0);
1263 /* finish the interrupt transaction with the IC */
1264 cd18xx_write(sc
, CD18xx_EOSRR
, 0);
1265 DPRINTF(CDD_INTR
, (", done\n"));
1269 * hardware interrupt routine. call the relevant interrupt routines until
1270 * no interrupts are pending.
1272 * note: we do receive interrupts before all others (as we'd rather lose
1273 * a chance to transmit, than lose a character). and we do transmit
1274 * interrupts before modem interrupts.
1276 * we have to traverse all of the cd18xx's attached, unfortunately.
1279 cd18xx_hardintr(void *v
)
1284 DPRINTF(CDD_INTR
, ("cd18xx_hardintr (ndevs %d):\n", clcd_cd
.cd_ndevs
));
1285 for (i
= 0; i
< clcd_cd
.cd_ndevs
; i
++)
1287 struct cd18xx_softc
*sc
= device_lookup_private(&clcd_cd
, i
);
1289 int count
= 1; /* process only 1 interrupts at a time for now */
1294 DPRINTF(CDD_INTR
, ("%s:", device_xname(&sc
->sc_dev
)));
1296 (status
= (cd18xx_read(sc
, CD18xx_SRSR
) &
1297 CD18xx_SRSR_PENDING
))) {
1300 DPRINTF(CDD_INTR
, (" status %x:", status
));
1301 if (ISSET(status
, CD18xx_SRSR_RxPEND
)) {
1302 ack
= (*sc
->sc_ackfunc
)(sc
->sc_ackfunc_arg
,
1303 CD18xx_INTRACK_RxINT
);
1304 DPRINTF(CDD_INTR
, (" rx: ack1 %x\n", ack
));
1305 cd18xx_rint(sc
, &ns
);
1307 if (ISSET(status
, CD18xx_SRSR_TxPEND
)) {
1308 ack
= (*sc
->sc_ackfunc
)(sc
->sc_ackfunc_arg
,
1309 CD18xx_INTRACK_TxINT
);
1310 DPRINTF(CDD_INTR
, (" tx: ack1 %x\n", ack
));
1311 cd18xx_tint(sc
, &ns
);
1314 if (ISSET(status
, CD18xx_SRSR_MxPEND
)) {
1315 ack
= (*sc
->sc_ackfunc
)(sc
->sc_ackfunc_arg
,
1316 CD18xx_INTRACK_MxINT
);
1317 DPRINTF(CDD_INTR
, (" mx: ack1 %x\n", ack
));
1318 cd18xx_mint(sc
, &ns
);
1322 softint_schedule(sc
->sc_si
);
1329 * software interrupt
1333 cdtty_rxsoft(struct cd18xx_softc
*sc
, struct cdtty_port
*p
, struct tty
*tp
)
1343 scc
= cc
= cdtty_rbuf_size
- p
->p_rbavail
;
1345 if (cc
== cdtty_rbuf_size
) {
1348 if (p
->p_errors
++ == 0)
1349 callout_reset(&p
->p_diag_callout
, 60 * hz
,
1357 if (ISSET(rcsr
, CD18xx_RCSR_OVERRUNERR
| CD18xx_RCSR_BREAK
|
1358 CD18xx_RCSR_FRAMERR
| CD18xx_RCSR_PARITYERR
)) {
1359 if (ISSET(rcsr
, CD18xx_RCSR_OVERRUNERR
)) {
1362 if (p
->p_errors
++ == 0)
1363 callout_reset(&p
->p_diag_callout
,
1364 60 * hz
, cdttydiag
, p
);
1367 if (ISSET(rcsr
, CD18xx_RCSR_BREAK
|CD18xx_RCSR_FRAMERR
))
1369 if (ISSET(rcsr
, CD18xx_RCSR_PARITYERR
))
1372 if ((*tp
->t_linesw
->l_rint
)(code
, tp
) == -1) {
1374 * The line discipline's buffer is out of space.
1376 if (!ISSET(p
->p_rx_flags
, RX_TTY_BLOCKED
)) {
1378 * We're either not using flow control, or the
1379 * line discipline didn't tell us to block for
1380 * some reason. Either way, we have no way to
1381 * know when there's more space available, so
1382 * just drop the rest of the data.
1386 get
-= cdtty_rbuf_size
<< 1;
1390 * Don't schedule any more receive processing
1391 * until the line discipline tells us there's
1392 * space available (through cdttyhwiflow()).
1393 * Leave the rest of the data in the input
1396 SET(p
->p_rx_flags
, RX_TTY_OVERFLOWED
);
1410 cc
= p
->p_rbavail
+= scc
- cc
;
1411 /* Buffers should be ok again, release possible block. */
1412 if (cc
>= p
->p_r_lowat
) {
1413 if (ISSET(p
->p_rx_flags
, RX_IBUF_OVERFLOWED
)) {
1414 CLR(p
->p_rx_flags
, RX_IBUF_OVERFLOWED
);
1415 cd18xx_set_car(sc
, CD18XX_CHANNEL(tp
->t_dev
));
1416 SET(p
->p_srer
, CD18xx_SRER_Rx
|
1419 cd18xx_write(sc
, CD18xx_SRER
, p
->p_srer
);
1421 if (ISSET(p
->p_rx_flags
, RX_IBUF_BLOCKED
)) {
1422 CLR(p
->p_rx_flags
, RX_IBUF_BLOCKED
);
1423 cdtty_hwiflow(sc
, p
);
1431 cdtty_txsoft(struct cd18xx_softc
*sc
, struct cdtty_port
*p
, struct tty
*tp
)
1434 CLR(tp
->t_state
, TS_BUSY
);
1435 if (ISSET(tp
->t_state
, TS_FLUSH
))
1436 CLR(tp
->t_state
, TS_FLUSH
);
1438 ndflush(&tp
->t_outq
, (int)(p
->p_tba
- tp
->t_outq
.c_cf
));
1439 (*tp
->t_linesw
->l_start
)(tp
);
1443 cdtty_stsoft(struct cd18xx_softc
*sc
, struct cdtty_port
*p
, struct tty
*tp
)
1450 delta
= p
->p_msvr_delta
;
1451 p
->p_msvr_delta
= 0;
1454 if (ISSET(delta
, p
->p_msvr_dcd
)) {
1456 * Inform the tty layer that carrier detect changed.
1458 (void) (*tp
->t_linesw
->l_modem
)(tp
, ISSET(msvr
, CD18xx_MSVR_CD
));
1461 if (ISSET(delta
, p
->p_msvr_cts
)) {
1462 /* Block or unblock output according to flow control. */
1463 if (ISSET(msvr
, p
->p_msvr_cts
)) {
1464 p
->p_tx_stopped
= 0;
1465 (*tp
->t_linesw
->l_start
)(tp
);
1467 p
->p_tx_stopped
= 1;
1473 cd18xx_softintr(void *v
)
1475 struct cd18xx_softc
*sc
= v
;
1476 struct cdtty_port
*p
;
1480 for (i
= 0; i
< 8; i
++) {
1481 p
= &sc
->sc_ports
[i
];
1486 if (!ISSET(tp
->t_state
, TS_ISOPEN
) && tp
->t_wopen
== 0)
1489 if (p
->p_rx_ready
) {
1491 cdtty_rxsoft(sc
, p
, tp
);
1494 if (p
->p_st_check
) {
1496 cdtty_stsoft(sc
, p
, tp
);
1501 cdtty_txsoft(sc
, p
, tp
);