Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Deal with the strange SCC wiring on TC IOASIC machin...



details:   https://anonhg.NetBSD.org/src/rev/c0a6a6956faf
branches:  trunk
changeset: 536934:c0a6a6956faf
user:      ad <ad%NetBSD.org@localhost>
date:      Tue Sep 24 13:23:31 2002 +0000

description:
Deal with the strange SCC wiring on TC IOASIC machines. Thanks to Bill
Studenmund and Jonathan Stone for useful comments.

diffstat:

 sys/dev/ic/z8530sc.c      |  23 ++++++++++++++++++-----
 sys/dev/ic/z8530sc.h      |   9 ++++++++-
 sys/dev/ic/z8530tty.c     |  44 ++++++++++++++++++++++++++------------------
 sys/dev/tc/zs_ioasic.c    |  35 ++++++++++++++++++++++-------------
 sys/dev/tc/zs_ioasicvar.h |   3 ++-
 5 files changed, 76 insertions(+), 38 deletions(-)

diffs (truncated from 327 to 300 lines):

diff -r d8143d28febe -r c0a6a6956faf sys/dev/ic/z8530sc.c
--- a/sys/dev/ic/z8530sc.c      Tue Sep 24 13:06:07 2002 +0000
+++ b/sys/dev/ic/z8530sc.c      Tue Sep 24 13:23:31 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: z8530sc.c,v 1.16 2001/11/13 13:14:46 lukem Exp $       */
+/*     $NetBSD: z8530sc.c,v 1.17 2002/09/24 13:23:31 ad Exp $  */
 
 /*
  * Copyright (c) 1994 Gordon W. Ross
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: z8530sc.c,v 1.16 2001/11/13 13:14:46 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: z8530sc.c,v 1.17 2002/09/24 13:23:31 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -132,7 +132,7 @@
 zs_loadchannelregs(cs)
        struct zs_chanstate *cs;
 {
-       u_char *reg;
+       u_char *reg, v;
 
        zs_write_csr(cs, ZSM_RESET_ERR); /* XXX: reset error condition */
 
@@ -144,8 +144,14 @@
        zs_iflush(cs);  /* XXX */
 #endif
 
-       if (memcmp((caddr_t)cs->cs_preg, (caddr_t)cs->cs_creg, 16) == 0)
-           return;     /* only change if values are different */
+       if (cs->cs_ctl_chan != NULL)
+               v = ((cs->cs_ctl_chan->cs_creg[5] & (ZSWR5_RTS | ZSWR5_DTR)) !=
+                   (cs->cs_ctl_chan->cs_preg[5] & (ZSWR5_RTS | ZSWR5_DTR)));
+       else
+               v = 0;
+
+       if (memcmp((caddr_t)cs->cs_preg, (caddr_t)cs->cs_creg, 16) == 0 && !v)
+               return; /* only change if values are different */
 
        /* Copy "pending" regs to "current" */
        memcpy((caddr_t)cs->cs_creg, (caddr_t)cs->cs_preg, 16);
@@ -216,6 +222,13 @@
        zs_write_reg(cs, 3, reg[3]);
        zs_write_reg(cs, 5, reg[5]);
 
+       /* Write the status bits on the alternate channel also. */
+       if (cs->cs_ctl_chan != NULL) {
+               v = cs->cs_ctl_chan->cs_preg[5];
+               cs->cs_ctl_chan->cs_creg[5] = v;
+               zs_write_reg(cs->cs_ctl_chan, 5, v);
+       }
+
        /* interrupt enables: RX, TX, STATUS */
        zs_write_reg(cs, 1, reg[1]);
 }
diff -r d8143d28febe -r c0a6a6956faf sys/dev/ic/z8530sc.h
--- a/sys/dev/ic/z8530sc.h      Tue Sep 24 13:06:07 2002 +0000
+++ b/sys/dev/ic/z8530sc.h      Tue Sep 24 13:23:31 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: z8530sc.h,v 1.16 2002/09/06 13:18:43 gehenna Exp $     */
+/*     $NetBSD: z8530sc.h,v 1.17 2002/09/24 13:23:31 ad Exp $  */
 
 /*
  * Copyright (c) 1994 Gordon W. Ross
@@ -114,6 +114,13 @@
        char    cs_softreq;             /* need soft interrupt call */
        char    cs_spare1;      /* (for skippy :) */
 
+       /*
+        * For strange systems that have oddly wired serial ports, we
+        * provide a pointer to the channel state of the port that has
+        * our status lines on it.
+        */
+       struct  zs_chanstate *cs_ctl_chan;
+
        /* power management hooks */
        int     (*enable) __P((struct zs_chanstate *));
        void    (*disable) __P((struct zs_chanstate *));
diff -r d8143d28febe -r c0a6a6956faf sys/dev/ic/z8530tty.c
--- a/sys/dev/ic/z8530tty.c     Tue Sep 24 13:06:07 2002 +0000
+++ b/sys/dev/ic/z8530tty.c     Tue Sep 24 13:23:31 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: z8530tty.c,v 1.80 2002/09/06 13:18:43 gehenna Exp $    */
+/*     $NetBSD: z8530tty.c,v 1.81 2002/09/24 13:23:31 ad Exp $ */
 
 /*-
  * Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998, 1999
@@ -99,7 +99,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.80 2002/09/06 13:18:43 gehenna Exp $");
+__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.81 2002/09/24 13:23:31 ad Exp $");
 
 #include "opt_kgdb.h"
 
@@ -1233,15 +1233,17 @@
        struct zstty_softc *zst;
        int onoff;
 {
-       struct zs_chanstate *cs = zst->zst_cs;
+       struct zs_chanstate *cs = zst->zst_cs, *ccs;
 
        if (cs->cs_wr5_dtr == 0)
                return;
 
+       ccs = (cs->cs_ctl_chan != NULL ? cs->cs_ctl_chan : cs);
+
        if (onoff)
-               SET(cs->cs_preg[5], cs->cs_wr5_dtr);
+               SET(ccs->cs_preg[5], cs->cs_wr5_dtr);
        else
-               CLR(cs->cs_preg[5], cs->cs_wr5_dtr);
+               CLR(ccs->cs_preg[5], cs->cs_wr5_dtr);
 
        if (!cs->cs_heldchange) {
                if (zst->zst_tx_busy) {
@@ -1259,9 +1261,11 @@
        u_long how;
        int ttybits;
 {
-       struct zs_chanstate *cs = zst->zst_cs;
+       struct zs_chanstate *cs = zst->zst_cs, *ccs;
        u_char zsbits;
 
+       ccs = (cs->cs_ctl_chan != NULL ? cs->cs_ctl_chan : cs);
+
        zsbits = 0;
        if (ISSET(ttybits, TIOCM_DTR))
                SET(zsbits, ZSWR5_DTR);
@@ -1270,16 +1274,16 @@
 
        switch (how) {
        case TIOCMBIC:
-               CLR(cs->cs_preg[5], zsbits);
+               CLR(ccs->cs_preg[5], zsbits);
                break;
 
        case TIOCMBIS:
-               SET(cs->cs_preg[5], zsbits);
+               SET(ccs->cs_preg[5], zsbits);
                break;
 
        case TIOCMSET:
-               CLR(cs->cs_preg[5], ZSWR5_RTS | ZSWR5_DTR);
-               SET(cs->cs_preg[5], zsbits);
+               CLR(ccs->cs_preg[5], ZSWR5_RTS | ZSWR5_DTR);
+               SET(ccs->cs_preg[5], zsbits);
                break;
        }
 
@@ -1297,11 +1301,13 @@
 zs_to_tiocm(zst)
        struct zstty_softc *zst;
 {
-       struct zs_chanstate *cs = zst->zst_cs;
+       struct zs_chanstate *cs = zst->zst_cs, *ccs;
        u_char zsbits;
        int ttybits = 0;
 
-       zsbits = cs->cs_preg[5];
+       ccs = (cs->cs_ctl_chan != NULL ? cs->cs_ctl_chan : cs);
+
+       zsbits = ccs->cs_preg[5];
        if (ISSET(zsbits, ZSWR5_DTR))
                SET(ttybits, TIOCM_DTR);
        if (ISSET(zsbits, ZSWR5_RTS))
@@ -1363,19 +1369,21 @@
 zs_hwiflow(zst)
        struct zstty_softc *zst;
 {
-       struct zs_chanstate *cs = zst->zst_cs;
+       struct zs_chanstate *cs = zst->zst_cs, *ccs;
 
        if (cs->cs_wr5_rts == 0)
                return;
 
+       ccs = (cs->cs_ctl_chan != NULL ? cs->cs_ctl_chan : cs);
+
        if (ISSET(zst->zst_rx_flags, RX_ANY_BLOCK)) {
-               CLR(cs->cs_preg[5], cs->cs_wr5_rts);
-               CLR(cs->cs_creg[5], cs->cs_wr5_rts);
+               CLR(ccs->cs_preg[5], cs->cs_wr5_rts);
+               CLR(ccs->cs_creg[5], cs->cs_wr5_rts);
        } else {
-               SET(cs->cs_preg[5], cs->cs_wr5_rts);
-               SET(cs->cs_creg[5], cs->cs_wr5_rts);
+               SET(ccs->cs_preg[5], cs->cs_wr5_rts);
+               SET(ccs->cs_creg[5], cs->cs_wr5_rts);
        }
-       zs_write_reg(cs, 5, cs->cs_creg[5]);
+       zs_write_reg(ccs, 5, ccs->cs_creg[5]);
 }
 
 
diff -r d8143d28febe -r c0a6a6956faf sys/dev/tc/zs_ioasic.c
--- a/sys/dev/tc/zs_ioasic.c    Tue Sep 24 13:06:07 2002 +0000
+++ b/sys/dev/tc/zs_ioasic.c    Tue Sep 24 13:23:31 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: zs_ioasic.c,v 1.11 2002/09/06 13:18:43 gehenna Exp $ */
+/* $NetBSD: zs_ioasic.c,v 1.12 2002/09/24 13:23:32 ad Exp $ */
 
 /*-
  * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zs_ioasic.c,v 1.11 2002/09/06 13:18:43 gehenna Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zs_ioasic.c,v 1.12 2002/09/24 13:23:32 ad Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -261,6 +261,7 @@
        struct ioasicdev_attach_args *d = aux;
        struct zshan *zc;
        int s, channel;
+       u_long zflg;
 
        printf("\n");
 
@@ -296,17 +297,19 @@
 
                /*
                 * DCD and CTS interrupts are only meaningful on
-                * SCC 0/B.
+                * SCC 0/B, and RTS and DTR only on B of SCC 0 & 1.
                 *
                 * XXX This is sorta gross.
                 */
                if (d->iada_offset == 0x00100000 && channel == 1) {
                        cs->cs_creg[15] |= ZSWR15_DCD_IE;
                        cs->cs_preg[15] |= ZSWR15_DCD_IE;
-                       (u_long)cs->cs_private = ZIP_FLAGS_DCDCTS;
-               }
-               else
-                       cs->cs_private = NULL;
+                       zflg = ZIP_FLAGS_DCDCTS;
+               } else
+                       zflg = 0;
+               if (channel == 1)
+                       zflg |= ZIP_FLAGS_DTRRTS;
+               (u_long)cs->cs_private = zflg;
 
                /*
                 * Clear the master interrupt enable.
@@ -317,7 +320,6 @@
                        zs_write_reg(cs, 9, 0);
                }
 
-#ifdef notyet /* XXX thorpej */
                /*
                 * Set up the flow/modem control channel pointer to
                 * deal with the weird wiring on the TC Alpha and
@@ -327,7 +329,6 @@
                        cs->cs_ctl_chan = zs->zsc_cs[0];
                else
                        cs->cs_ctl_chan = NULL;
-#endif
 
                /*
                 * Look for a child driver for this channel.
@@ -552,6 +553,10 @@
                cs->cs_rr0_dcd &= ~(ZSRR0_CTS|ZSRR0_DCD);
                cs->cs_rr0_cts &= ~(ZSRR0_CTS|ZSRR0_DCD);
        }
+       if ((privflags & ZIP_FLAGS_DTRRTS) == 0) {
+               cs->cs_wr5_dtr &= ~(ZSWR5_RTS|ZSWR5_DTR);
+               cs->cs_wr5_rts &= ~(ZSWR5_RTS|ZSWR5_DTR);
+       }
        splx(s);
 
        /* Caller will stuff the pending registers. */
@@ -746,6 +751,7 @@
        struct zs_chanstate *cs;
        tc_addr_t zs_addr;
        struct zshan *zc;
+       u_long zflg;
 
        /*
         * Initialize the console finder helpers.
@@ -780,18 +786,21 @@
 
        /* Initialize the pending registers. */
        bcopy(zs_ioasic_init_reg, cs->cs_preg, 16);
-       cs->cs_preg[5] |= (ZSWR5_DTR | ZSWR5_RTS);
+       /* cs->cs_preg[5] |= (ZSWR5_DTR | ZSWR5_RTS); */
 
        /*
         * DCD and CTS interrupts are only meaningful on
-        * SCC 0/B.
+        * SCC 0/B, and RTS and DTR only on B of SCC 0 & 1.
         *
         * XXX This is sorta gross.
         */
        if (zs_offset == 0x00100000 && channel == 1)
-               (u_long)cs->cs_private = ZIP_FLAGS_DCDCTS;



Home | Main Index | Thread Index | Old Index