dz.c revision 1.1.8.2 1 /* $NetBSD: dz.c,v 1.1.8.2 2002/03/16 16:00:50 jdolecek Exp $ */
2 /*
3 * Copyright (c) 1996 Ken C. Wellsch. All rights reserved.
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Ralph Campbell and Rick Macklem.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 */
38
39 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: dz.c,v 1.1.8.2 2002/03/16 16:00:50 jdolecek Exp $");
41
42 #include "opt_ddb.h"
43
44 #include <sys/param.h>
45 #include <sys/systm.h>
46 #include <sys/callout.h>
47 #include <sys/ioctl.h>
48 #include <sys/tty.h>
49 #include <sys/proc.h>
50 #include <sys/map.h>
51 #include <sys/buf.h>
52 #include <sys/conf.h>
53 #include <sys/file.h>
54 #include <sys/uio.h>
55 #include <sys/kernel.h>
56 #include <sys/syslog.h>
57 #include <sys/device.h>
58
59 #include <machine/bus.h>
60
61 #include <dev/dec/dzreg.h>
62 #include <dev/dec/dzvar.h>
63
64 #define DZ_READ_BYTE(adr) \
65 bus_space_read_1(sc->sc_iot, sc->sc_ioh, sc->sc_dr.adr)
66 #define DZ_READ_WORD(adr) \
67 bus_space_read_2(sc->sc_iot, sc->sc_ioh, sc->sc_dr.adr)
68 #define DZ_WRITE_BYTE(adr, val) \
69 bus_space_write_1(sc->sc_iot, sc->sc_ioh, sc->sc_dr.adr, val)
70 #define DZ_WRITE_WORD(adr, val) \
71 bus_space_write_2(sc->sc_iot, sc->sc_ioh, sc->sc_dr.adr, val)
72
73 #include "ioconf.h"
74
75 /* A DZ-11 has 8 ports while a DZV/DZQ-11 has only 4. We use 8 by default */
76
77 #define NDZLINE 8
78
79 #define DZ_C2I(c) ((c)<<3) /* convert controller # to index */
80 #define DZ_I2C(c) ((c)>>3) /* convert minor to controller # */
81 #define DZ_PORT(u) ((u)&07) /* extract the port # */
82
83 /* Flags used to monitor modem bits, make them understood outside driver */
84
85 #define DML_DTR TIOCM_DTR
86 #define DML_DCD TIOCM_CD
87 #define DML_RI TIOCM_RI
88 #define DML_BRK 0100000 /* no equivalent, we will mask */
89
90 static struct speedtab dzspeedtab[] =
91 {
92 { 0, 0 },
93 { 50, DZ_LPR_B50 },
94 { 75, DZ_LPR_B75 },
95 { 110, DZ_LPR_B110 },
96 { 134, DZ_LPR_B134 },
97 { 150, DZ_LPR_B150 },
98 { 300, DZ_LPR_B300 },
99 { 600, DZ_LPR_B600 },
100 { 1200, DZ_LPR_B1200 },
101 { 1800, DZ_LPR_B1800 },
102 { 2000, DZ_LPR_B2000 },
103 { 2400, DZ_LPR_B2400 },
104 { 3600, DZ_LPR_B3600 },
105 { 4800, DZ_LPR_B4800 },
106 { 7200, DZ_LPR_B7200 },
107 { 9600, DZ_LPR_B9600 },
108 { 19200, DZ_LPR_B19200 },
109 { -1, -1 }
110 };
111
112 static void dzstart(struct tty *);
113 static int dzparam(struct tty *, struct termios *);
114 static unsigned dzmctl(struct dz_softc *, int, int, int);
115 static void dzscan(void *);
116 cdev_decl(dz);
117
118 /*
119 * The DZ series doesn't interrupt on carrier transitions,
120 * so we have to use a timer to watch it.
121 */
122 int dz_timer; /* true if timer started */
123 struct callout dzscan_ch;
124
125 #define DZ_DZ 8 /* Unibus DZ-11 board linecount */
126 #define DZ_DZV 4 /* Q-bus DZV-11 or DZQ-11 */
127
128 void
129 dzattach(struct dz_softc *sc, struct evcnt *parent_evcnt)
130 {
131 int n;
132
133 sc->sc_rxint = sc->sc_brk = 0;
134
135 sc->sc_dr.dr_tcrw = sc->sc_dr.dr_tcr;
136 DZ_WRITE_WORD(dr_csr, DZ_CSR_MSE | DZ_CSR_RXIE | DZ_CSR_TXIE);
137 DZ_WRITE_BYTE(dr_dtr, 0);
138 DZ_WRITE_BYTE(dr_break, 0);
139
140 /* Initialize our softc structure. Should be done in open? */
141
142 for (n = 0; n < sc->sc_type; n++)
143 sc->sc_dz[n].dz_tty = ttymalloc();
144
145 evcnt_attach_dynamic(&sc->sc_rintrcnt, EVCNT_TYPE_INTR, parent_evcnt,
146 sc->sc_dev.dv_xname, "rintr");
147 evcnt_attach_dynamic(&sc->sc_tintrcnt, EVCNT_TYPE_INTR, parent_evcnt,
148 sc->sc_dev.dv_xname, "tintr");
149
150 /* Alas no interrupt on modem bit changes, so we manually scan */
151
152 if (dz_timer == 0) {
153 dz_timer = 1;
154 callout_init(&dzscan_ch);
155 callout_reset(&dzscan_ch, hz, dzscan, NULL);
156 }
157 printf("\n");
158 return;
159 }
160
161 /* Receiver Interrupt */
162
163 void
164 dzrint(void *arg)
165 {
166 struct dz_softc *sc = arg;
167 struct tty *tp;
168 int cc, line;
169 unsigned c;
170 int overrun = 0;
171
172 sc->sc_rxint++;
173
174 while ((c = DZ_READ_WORD(dr_rbuf)) & DZ_RBUF_DATA_VALID) {
175 cc = c & 0xFF;
176 line = DZ_PORT(c>>8);
177 tp = sc->sc_dz[line].dz_tty;
178
179 /* Must be caught early */
180 if (sc->sc_dz[line].dz_catch &&
181 (*sc->sc_dz[line].dz_catch)(sc->sc_dz[line].dz_private, cc))
182 continue;
183
184 if (!(tp->t_state & TS_ISOPEN)) {
185 wakeup((caddr_t)&tp->t_rawq);
186 continue;
187 }
188
189 if ((c & DZ_RBUF_OVERRUN_ERR) && overrun == 0) {
190 log(LOG_WARNING, "%s: silo overflow, line %d\n",
191 sc->sc_dev.dv_xname, line);
192 overrun = 1;
193 }
194
195 /* A BREAK key will appear as a NULL with a framing error */
196 if (c & DZ_RBUF_FRAMING_ERR)
197 cc |= TTY_FE;
198 if (c & DZ_RBUF_PARITY_ERR)
199 cc |= TTY_PE;
200
201 (*tp->t_linesw->l_rint)(cc, tp);
202 }
203 }
204
205 /* Transmitter Interrupt */
206
207 void
208 dzxint(void *arg)
209 {
210 struct dz_softc *sc = arg;
211 struct tty *tp;
212 struct clist *cl;
213 int line, ch, csr;
214 u_char tcr;
215
216 /*
217 * Switch to POLLED mode.
218 * Some simple measurements indicated that even on
219 * one port, by freeing the scanner in the controller
220 * by either providing a character or turning off
221 * the port when output is complete, the transmitter
222 * was ready to accept more output when polled again.
223 * With just two ports running the game "worms,"
224 * almost every interrupt serviced both transmitters!
225 * Each UART is double buffered, so if the scanner
226 * is quick enough and timing works out, we can even
227 * feed the same port twice.
228 *
229 * Ragge 980517:
230 * Do not need to turn off interrupts, already at interrupt level.
231 * Remove the pdma stuff; no great need of it right now.
232 */
233
234 while (((csr = DZ_READ_WORD(dr_csr)) & DZ_CSR_TX_READY) != 0) {
235
236 line = DZ_PORT(csr>>8);
237
238 tp = sc->sc_dz[line].dz_tty;
239 cl = &tp->t_outq;
240 tp->t_state &= ~TS_BUSY;
241
242 /* Just send out a char if we have one */
243 /* As long as we can fill the chip buffer, we just loop here */
244 if (cl->c_cc) {
245 tp->t_state |= TS_BUSY;
246 ch = getc(cl);
247 DZ_WRITE_BYTE(dr_tbuf, ch);
248 continue;
249 }
250 /* Nothing to send; clear the scan bit */
251 /* Clear xmit scanner bit; dzstart may set it again */
252 tcr = DZ_READ_WORD(dr_tcrw);
253 tcr &= 255;
254 tcr &= ~(1 << line);
255 DZ_WRITE_BYTE(dr_tcr, tcr);
256 if (sc->sc_dz[line].dz_catch)
257 continue;
258
259 if (tp->t_state & TS_FLUSH)
260 tp->t_state &= ~TS_FLUSH;
261 else
262 ndflush (&tp->t_outq, cl->c_cc);
263
264 (*tp->t_linesw->l_start)(tp);
265 }
266 }
267
268 int
269 dzopen(dev_t dev, int flag, int mode, struct proc *p)
270 {
271 struct tty *tp;
272 int unit, line;
273 struct dz_softc *sc;
274 int s, error = 0;
275
276 unit = DZ_I2C(minor(dev));
277 line = DZ_PORT(minor(dev));
278 if (unit >= dz_cd.cd_ndevs || dz_cd.cd_devs[unit] == NULL)
279 return (ENXIO);
280
281 sc = dz_cd.cd_devs[unit];
282
283 if (line >= sc->sc_type)
284 return ENXIO;
285
286 /* if some other device is using the line, it's busy */
287 if (sc->sc_dz[line].dz_catch)
288 return EBUSY;
289
290 tp = sc->sc_dz[line].dz_tty;
291 if (tp == NULL)
292 return (ENODEV);
293 tp->t_oproc = dzstart;
294 tp->t_param = dzparam;
295 tp->t_dev = dev;
296 if ((tp->t_state & TS_ISOPEN) == 0) {
297 ttychars(tp);
298 if (tp->t_ispeed == 0) {
299 tp->t_iflag = TTYDEF_IFLAG;
300 tp->t_oflag = TTYDEF_OFLAG;
301 tp->t_cflag = TTYDEF_CFLAG;
302 tp->t_lflag = TTYDEF_LFLAG;
303 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
304 }
305 (void) dzparam(tp, &tp->t_termios);
306 ttsetwater(tp);
307 } else if ((tp->t_state & TS_XCLUDE) && p->p_ucred->cr_uid != 0)
308 return (EBUSY);
309 /* Use DMBIS and *not* DMSET or else we clobber incoming bits */
310 if (dzmctl(sc, line, DML_DTR, DMBIS) & DML_DCD)
311 tp->t_state |= TS_CARR_ON;
312 s = spltty();
313 while (!(flag & O_NONBLOCK) && !(tp->t_cflag & CLOCAL) &&
314 !(tp->t_state & TS_CARR_ON)) {
315 tp->t_wopen++;
316 error = ttysleep(tp, (caddr_t)&tp->t_rawq,
317 TTIPRI | PCATCH, ttopen, 0);
318 tp->t_wopen--;
319 if (error)
320 break;
321 }
322 (void) splx(s);
323 if (error)
324 return (error);
325 return ((*tp->t_linesw->l_open)(dev, tp));
326 }
327
328 /*ARGSUSED*/
329 int
330 dzclose(dev_t dev, int flag, int mode, struct proc *p)
331 {
332 struct dz_softc *sc;
333 struct tty *tp;
334 int unit, line;
335
336
337 unit = DZ_I2C(minor(dev));
338 line = DZ_PORT(minor(dev));
339 sc = dz_cd.cd_devs[unit];
340
341 tp = sc->sc_dz[line].dz_tty;
342
343 (*tp->t_linesw->l_close)(tp, flag);
344
345 /* Make sure a BREAK state is not left enabled. */
346 (void) dzmctl(sc, line, DML_BRK, DMBIC);
347
348 /* Do a hangup if so required. */
349 if ((tp->t_cflag & HUPCL) || tp->t_wopen || !(tp->t_state & TS_ISOPEN))
350 (void) dzmctl(sc, line, 0, DMSET);
351
352 return (ttyclose(tp));
353 }
354
355 int
356 dzread(dev_t dev, struct uio *uio, int flag)
357 {
358 struct tty *tp;
359 struct dz_softc *sc;
360
361 sc = dz_cd.cd_devs[DZ_I2C(minor(dev))];
362
363 tp = sc->sc_dz[DZ_PORT(minor(dev))].dz_tty;
364 return ((*tp->t_linesw->l_read)(tp, uio, flag));
365 }
366
367 int
368 dzwrite(dev_t dev, struct uio *uio, int flag)
369 {
370 struct tty *tp;
371 struct dz_softc *sc;
372
373 sc = dz_cd.cd_devs[DZ_I2C(minor(dev))];
374
375 tp = sc->sc_dz[DZ_PORT(minor(dev))].dz_tty;
376 return ((*tp->t_linesw->l_write)(tp, uio, flag));
377 }
378
379 int
380 dzpoll(dev, events, p)
381 dev_t dev;
382 int events;
383 struct proc *p;
384 {
385 struct tty *tp;
386 struct dz_softc *sc;
387
388 sc = dz_cd.cd_devs[DZ_I2C(minor(dev))];
389
390 tp = sc->sc_dz[DZ_PORT(minor(dev))].dz_tty;
391 return ((*tp->t_linesw->l_poll)(tp, events, p));
392 }
393
394 /*ARGSUSED*/
395 int
396 dzioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
397 {
398 struct dz_softc *sc;
399 struct tty *tp;
400 int unit, line;
401 int error;
402
403 unit = DZ_I2C(minor(dev));
404 line = DZ_PORT(minor(dev));
405 sc = dz_cd.cd_devs[unit];
406 tp = sc->sc_dz[line].dz_tty;
407
408 error = (*tp->t_linesw->l_ioctl)(tp, cmd, data, flag, p);
409 if (error >= 0)
410 return (error);
411 error = ttioctl(tp, cmd, data, flag, p);
412 if (error >= 0)
413 return (error);
414
415 switch (cmd) {
416
417 case TIOCSBRK:
418 (void) dzmctl(sc, line, DML_BRK, DMBIS);
419 break;
420
421 case TIOCCBRK:
422 (void) dzmctl(sc, line, DML_BRK, DMBIC);
423 break;
424
425 case TIOCSDTR:
426 (void) dzmctl(sc, line, DML_DTR, DMBIS);
427 break;
428
429 case TIOCCDTR:
430 (void) dzmctl(sc, line, DML_DTR, DMBIC);
431 break;
432
433 case TIOCMSET:
434 (void) dzmctl(sc, line, *(int *)data, DMSET);
435 break;
436
437 case TIOCMBIS:
438 (void) dzmctl(sc, line, *(int *)data, DMBIS);
439 break;
440
441 case TIOCMBIC:
442 (void) dzmctl(sc, line, *(int *)data, DMBIC);
443 break;
444
445 case TIOCMGET:
446 *(int *)data = (dzmctl(sc, line, 0, DMGET) & ~DML_BRK);
447 break;
448
449 default:
450 return (ENOTTY);
451 }
452 return (0);
453 }
454
455 struct tty *
456 dztty(dev_t dev)
457 {
458 struct dz_softc *sc = dz_cd.cd_devs[DZ_I2C(minor(dev))];
459 struct tty *tp = sc->sc_dz[DZ_PORT(minor(dev))].dz_tty;
460
461 return (tp);
462 }
463
464 /*ARGSUSED*/
465 void
466 dzstop(struct tty *tp, int flag)
467 {
468 if (tp->t_state & TS_BUSY)
469 if (!(tp->t_state & TS_TTSTOP))
470 tp->t_state |= TS_FLUSH;
471 }
472
473 void
474 dzstart(struct tty *tp)
475 {
476 struct dz_softc *sc;
477 struct clist *cl;
478 int unit, line, s;
479 char state;
480
481 unit = DZ_I2C(minor(tp->t_dev));
482 line = DZ_PORT(minor(tp->t_dev));
483 sc = dz_cd.cd_devs[unit];
484
485 s = spltty();
486 if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP))
487 return;
488 cl = &tp->t_outq;
489 if (cl->c_cc <= tp->t_lowat) {
490 if (tp->t_state & TS_ASLEEP) {
491 tp->t_state &= ~TS_ASLEEP;
492 wakeup((caddr_t)cl);
493 }
494 selwakeup(&tp->t_wsel);
495 }
496 if (cl->c_cc == 0)
497 return;
498
499 tp->t_state |= TS_BUSY;
500
501 state = DZ_READ_WORD(dr_tcrw) & 255;
502 if ((state & (1 << line)) == 0) {
503 DZ_WRITE_BYTE(dr_tcr, state | (1 << line));
504 }
505 dzxint(sc);
506 splx(s);
507 }
508
509 static int
510 dzparam(struct tty *tp, struct termios *t)
511 {
512 struct dz_softc *sc;
513 int cflag = t->c_cflag;
514 int unit, line;
515 int ispeed = ttspeedtab(t->c_ispeed, dzspeedtab);
516 int ospeed = ttspeedtab(t->c_ospeed, dzspeedtab);
517 unsigned lpr;
518 int s;
519
520 unit = DZ_I2C(minor(tp->t_dev));
521 line = DZ_PORT(minor(tp->t_dev));
522 sc = dz_cd.cd_devs[unit];
523
524 /* check requested parameters */
525 if (ospeed < 0 || ispeed < 0 || ispeed != ospeed)
526 return (EINVAL);
527
528 tp->t_ispeed = t->c_ispeed;
529 tp->t_ospeed = t->c_ospeed;
530 tp->t_cflag = cflag;
531
532 if (ospeed == 0) {
533 (void) dzmctl(sc, line, 0, DMSET); /* hang up line */
534 return (0);
535 }
536
537 s = spltty();
538
539 lpr = DZ_LPR_RX_ENABLE | ((ispeed&0xF)<<8) | line;
540
541 switch (cflag & CSIZE)
542 {
543 case CS5:
544 lpr |= DZ_LPR_5_BIT_CHAR;
545 break;
546 case CS6:
547 lpr |= DZ_LPR_6_BIT_CHAR;
548 break;
549 case CS7:
550 lpr |= DZ_LPR_7_BIT_CHAR;
551 break;
552 default:
553 lpr |= DZ_LPR_8_BIT_CHAR;
554 break;
555 }
556 if (cflag & PARENB)
557 lpr |= DZ_LPR_PARENB;
558 if (cflag & PARODD)
559 lpr |= DZ_LPR_OPAR;
560 if (cflag & CSTOPB)
561 lpr |= DZ_LPR_2_STOP;
562
563 DZ_WRITE_WORD(dr_lpr, lpr);
564
565 (void) splx(s);
566 return (0);
567 }
568
569 static unsigned
570 dzmctl(struct dz_softc *sc, int line, int bits, int how)
571 {
572 unsigned status;
573 unsigned mbits;
574 unsigned bit;
575 int s;
576
577 s = spltty();
578
579 mbits = 0;
580
581 bit = (1 << line);
582
583 /* external signals as seen from the port */
584
585 status = DZ_READ_BYTE(dr_dcd) | sc->sc_dsr;
586
587 if (status & bit)
588 mbits |= DML_DCD;
589
590 status = DZ_READ_BYTE(dr_ring);
591
592 if (status & bit)
593 mbits |= DML_RI;
594
595 /* internal signals/state delivered to port */
596
597 status = DZ_READ_BYTE(dr_dtr);
598
599 if (status & bit)
600 mbits |= DML_DTR;
601
602 if (sc->sc_brk & bit)
603 mbits |= DML_BRK;
604
605 switch (how)
606 {
607 case DMSET:
608 mbits = bits;
609 break;
610
611 case DMBIS:
612 mbits |= bits;
613 break;
614
615 case DMBIC:
616 mbits &= ~bits;
617 break;
618
619 case DMGET:
620 (void) splx(s);
621 return (mbits);
622 }
623
624 if (mbits & DML_DTR) {
625 DZ_WRITE_BYTE(dr_dtr, DZ_READ_BYTE(dr_dtr) | bit);
626 } else {
627 DZ_WRITE_BYTE(dr_dtr, DZ_READ_BYTE(dr_dtr) & ~bit);
628 }
629
630 if (mbits & DML_BRK) {
631 sc->sc_brk |= bit;
632 DZ_WRITE_BYTE(dr_break, sc->sc_brk);
633 } else {
634 sc->sc_brk &= ~bit;
635 DZ_WRITE_BYTE(dr_break, sc->sc_brk);
636 }
637
638 (void) splx(s);
639 return (mbits);
640 }
641
642 /*
643 * This is called by timeout() periodically.
644 * Check to see if modem status bits have changed.
645 */
646 static void
647 dzscan(void *arg)
648 {
649 struct dz_softc *sc;
650 struct tty *tp;
651 int n, bit, port;
652 unsigned csr;
653 int s;
654
655 s = spltty();
656
657 for (n = 0; n < dz_cd.cd_ndevs; n++) {
658
659 if (dz_cd.cd_devs[n] == NULL)
660 continue;
661
662 sc = dz_cd.cd_devs[n];
663
664 for (port = 0; port < sc->sc_type; port++) {
665
666 tp = sc->sc_dz[port].dz_tty;
667 bit = (1 << port);
668
669 if ((DZ_READ_BYTE(dr_dcd) | sc->sc_dsr) & bit) {
670 if (!(tp->t_state & TS_CARR_ON))
671 (*tp->t_linesw->l_modem) (tp, 1);
672 } else if ((tp->t_state & TS_CARR_ON) &&
673 (*tp->t_linesw->l_modem)(tp, 0) == 0) {
674 DZ_WRITE_BYTE(dr_tcr,
675 (DZ_READ_WORD(dr_tcrw) & 255) & ~bit);
676 }
677 }
678
679 /*
680 * If the RX interrupt rate is this high, switch
681 * the controller to Silo Alarm - which means don't
682 * interrupt until the RX silo has 16 characters in
683 * it (the silo is 64 characters in all).
684 * Avoid oscillating SA on and off by not turning
685 * if off unless the rate is appropriately low.
686 */
687
688 csr = DZ_READ_WORD(dr_csr);
689
690 if (sc->sc_rxint > (16*10)) {
691 if ((csr & DZ_CSR_SAE) == 0)
692 DZ_WRITE_WORD(dr_csr, csr | DZ_CSR_SAE);
693 } else if ((csr & DZ_CSR_SAE) != 0)
694 if (sc->sc_rxint < 10)
695 DZ_WRITE_WORD(dr_csr, csr & ~(DZ_CSR_SAE));
696
697 sc->sc_rxint = 0;
698 }
699 (void) splx(s);
700 callout_reset(&dzscan_ch, hz, dzscan, NULL);
701 return;
702 }
703
704 /*
705 * Called after an ubareset. The DZ card is reset, but the only thing
706 * that must be done is to start the receiver and transmitter again.
707 * No DMA setup to care about.
708 */
709 void
710 dzreset(struct device *dev)
711 {
712 struct dz_softc *sc = (void *)dev;
713 struct tty *tp;
714 int i;
715
716 for (i = 0; i < sc->sc_type; i++) {
717 tp = sc->sc_dz[i].dz_tty;
718
719 if (((tp->t_state & TS_ISOPEN) == 0) || (tp->t_wopen == 0))
720 continue;
721
722 dzparam(tp, &tp->t_termios);
723 dzmctl(sc, i, DML_DTR, DMSET);
724 tp->t_state &= ~TS_BUSY;
725 dzstart(tp); /* Kick off transmitter again */
726 }
727 }
728