Source-Changes-HG archive

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

[src/netbsd-1-5]: src/sys/arch/macppc/dev Pull up revisions 1.6-1.7 (requeste...



details:   https://anonhg.NetBSD.org/src/rev/1e0c1e518775
branches:  netbsd-1-5
changeset: 490730:1e0c1e518775
user:      he <he%NetBSD.org@localhost>
date:      Mon Feb 26 21:16:35 2001 +0000

description:
Pull up revisions 1.6-1.7 (requested by briggs):
  Match "chrp,mesh0", and fix Conner CFP1080 problem (PR#7612),
  and add debugging messages.

diffstat:

 sys/arch/macppc/dev/mesh.c |  253 ++++++++++++++++++++++++++++----------------
 1 files changed, 162 insertions(+), 91 deletions(-)

diffs (truncated from 574 to 300 lines):

diff -r fadf0b23c392 -r 1e0c1e518775 sys/arch/macppc/dev/mesh.c
--- a/sys/arch/macppc/dev/mesh.c        Mon Feb 26 21:13:31 2001 +0000
+++ b/sys/arch/macppc/dev/mesh.c        Mon Feb 26 21:16:35 2001 +0000
@@ -1,7 +1,8 @@
-/*     $NetBSD: mesh.c,v 1.4 2000/03/23 06:40:34 thorpej Exp $ */
+/*     $NetBSD: mesh.c,v 1.4.4.1 2001/02/26 21:16:35 he Exp $  */
 
 /*-
- * Copyright (C) 1999  Internet Research Institute, Inc.
+ * Copyright (c) 2000  Tsubai Masanari.
+ * Copyright (c) 1999  Internet Research Institute, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -56,6 +57,12 @@
 #include <macppc/dev/dbdma.h>
 #include <macppc/dev/meshreg.h>
 
+#ifdef MESH_DEBUG
+# define DPRINTF printf
+#else
+# define DPRINTF while (0) printf
+#endif
+
 #define T_SYNCMODE 0x01                /* target uses sync mode */
 #define T_SYNCNEGO 0x02                /* sync negotiation done */
 
@@ -111,7 +118,6 @@
 
        int sc_msgout;
        int sc_imsglen;
-       int sc_omsglen;
        u_char sc_imsg[16];
        u_char sc_omsg[16];
 
@@ -189,11 +195,17 @@
        void *aux;
 {
        struct confargs *ca = aux;
+       char compat[32];
 
-       if (strcmp(ca->ca_name, "mesh") != 0)
-               return 0;
+       if (strcmp(ca->ca_name, "mesh") == 0)
+               return 1;
 
-       return 1;
+       bzero(compat, sizeof(compat));
+       OF_getprop(ca->ca_node, "compatible", compat, sizeof(compat));
+       if (strcmp(compat, "chrp,mesh0") == 0)
+               return 1;
+
+       return 0;
 }
 
 void
@@ -297,6 +309,19 @@
        mesh_set_reg(sc, MESH_SYNC_PARAM, 2);
 }
 
+#ifdef MESH_DEBUG
+static char scsi_phase[][8] = {
+       "DATAOUT",
+       "DATAIN",
+       "COMMAND",
+       "STATUS",
+       "",
+       "",
+       "MSGOUT",
+       "MSGIN"
+};
+#endif
+
 int
 mesh_intr(arg)
        void *arg;
@@ -305,16 +330,12 @@
        struct mesh_scb *scb;
        int fifocnt;
        u_char intr, exception, error, status0, status1;
-       int i;
 
        intr = mesh_read_reg(sc, MESH_INTERRUPT);
-
-#ifdef MESH_DEBUG
        if (intr == 0) {
-               printf("mesh: stray interrupt\n");
+               DPRINTF("%s: stray interrupt\n", sc->sc_dev.dv_xname);
                return 0;
        }
-#endif
 
        exception = mesh_read_reg(sc, MESH_EXCEPTION);
        error = mesh_read_reg(sc, MESH_ERROR);
@@ -324,11 +345,20 @@
        /* clear interrupt */
        mesh_set_reg(sc, MESH_INTERRUPT, intr);
 
+#ifdef MESH_DEBUG
+{
+       char buf1[64], buf2[64];
+
+       bitmask_snprintf(status0, MESH_STATUS0_BITMASK, buf1, sizeof buf1);
+       bitmask_snprintf(exception, MESH_EXC_BITMASK, buf2, sizeof buf2);
+       printf("mesh_intr status0 = 0x%s (%s), exc = 0x%s\n",
+           buf1, scsi_phase[status0 & 7], buf2);
+}
+#endif
+
        scb = sc->sc_nexus;
        if (scb == NULL) {
-#ifdef MESH_DEBUG
-               printf("mesh: NULL nexus\n");
-#endif
+               DPRINTF("%s: NULL nexus\n", sc->sc_dev.dv_xname);
                return 1;
        }
 
@@ -342,6 +372,8 @@
                if (fifocnt != 0 && (scb->flags & MESH_READ)) {
                        char *cp = (char *)scb->daddr + scb->dlen - fifocnt;
 
+                       DPRINTF("fifocnt = %d, resid = %d\n", fifocnt,
+                               scb->resid);
                        while (fifocnt > 0) {
                                *cp++ = mesh_read_reg(sc, MESH_FIFO);
                                fifocnt--;
@@ -364,15 +396,12 @@
 
                /* phase mismatch */
                if (exception & MESH_EXC_PHASEMM) {
+                       DPRINTF("%s: PHASE MISMATCH; nextstate = %d -> ",
+                               sc->sc_dev.dv_xname, sc->sc_nextstate);
                        sc->sc_nextstate = status0 & MESH_PHASE_MASK;
-#if 0
-                       printf("mesh: PHASE MISMATCH cdb =");
-                       printf(" %02x", scb->cmd.opcode);
-                       for (i = 0; i < 5; i++) {
-                               printf(" %02x", scb->cmd.bytes[i]);
-                       }
-                       printf("\n");
-#endif
+
+                       DPRINTF("%d, resid = %d\n",
+                               sc->sc_nextstate, scb->resid);
                }
        }
 
@@ -402,7 +431,10 @@
                break;
 
        default:
-               panic("mesh: unknown state (0x%x)", sc->sc_nextstate);
+               printf("%s: unknown state (%d)\n", sc->sc_dev.dv_xname,
+                   sc->sc_nextstate);
+               scb->xs->error = XS_DRIVER_STUFFUP;
+               mesh_done(sc, scb);
        }
 
        return 1;
@@ -415,7 +447,7 @@
        int error, exception;
 {
        if (error & MESH_ERR_SCSI_RESET) {
-               printf("mesh: SCSI RESET\n");
+               printf("%s: SCSI RESET\n", sc->sc_dev.dv_xname);
 
                /* Wait until the RST signal is deasserted. */
                while (mesh_read_reg(sc, MESH_BUS_STATUS1) & MESH_STATUS1_RST);
@@ -424,19 +456,19 @@
        }
 
        if (error & MESH_ERR_PARITY_ERR0) {
-               printf("mesh: parity error\n");
+               printf("%s: parity error\n", sc->sc_dev.dv_xname);
                scb->xs->error = XS_DRIVER_STUFFUP;
        }
 
        if (error & MESH_ERR_DISCONNECT) {
-               printf("mesh: unexpected disconnect\n");
+               printf("%s: unexpected disconnect\n", sc->sc_dev.dv_xname);
                if (sc->sc_nextstate != MESH_COMPLETE)
                        scb->xs->error = XS_DRIVER_STUFFUP;
        }
 
        if (exception & MESH_EXC_SELTO) {
                /* XXX should reset bus here? */
-               scb->xs->error = XS_DRIVER_STUFFUP;
+               scb->xs->error = XS_SELTIMEOUT;
        }
 
        mesh_done(sc, scb);
@@ -449,6 +481,8 @@
 {
        struct mesh_tinfo *ti = &sc->sc_tinfo[scb->target];
 
+       DPRINTF("mesh_select\n");
+
        mesh_setsync(sc, ti);
        MESH_SET_XFER(sc, 0);
 
@@ -482,10 +516,20 @@
        struct mesh_softc *sc;
        struct mesh_scb *scb;
 {
+       struct mesh_tinfo *ti = &sc->sc_tinfo[scb->target];
+
+       DPRINTF("mesh_identify\n");
        mesh_set_reg(sc, MESH_SEQUENCE, MESH_CMD_FLUSH_FIFO);
-       mesh_msgout(sc, SEND_IDENTIFY);
 
-       sc->sc_nextstate = MESH_COMMAND;
+       if ((ti->flags & T_SYNCNEGO) == 0) {
+               ti->period = sc->sc_minsync;
+               ti->offset = 15;
+               mesh_msgout(sc, SEND_IDENTIFY | SEND_SDTR);
+               sc->sc_nextstate = MESH_MSGIN;
+       } else {
+               mesh_msgout(sc, SEND_IDENTIFY);
+               sc->sc_nextstate = MESH_COMMAND;
+       }
 }
 
 void
@@ -493,18 +537,15 @@
        struct mesh_softc *sc;
        struct mesh_scb *scb;
 {
-       struct mesh_tinfo *ti = &sc->sc_tinfo[scb->target];
        int i;
        char *cmdp;
 
-       if ((ti->flags & T_SYNCNEGO) == 0) {
-               ti->period = sc->sc_minsync;
-               ti->offset = 15;
-               mesh_msgout(sc, SEND_SDTR);
-               sc->sc_prevphase = MESH_COMMAND;
-               sc->sc_nextstate = MESH_MSGIN;
-               return;
-       }
+#ifdef MESH_DEBUG
+       printf("mesh_command cdb = %02x", scb->cmd.opcode);
+       for (i = 0; i < 5; i++)
+               printf(" %02x", scb->cmd.bytes[i]);
+       printf("\n");
+#endif
 
        mesh_set_reg(sc, MESH_SEQUENCE, MESH_CMD_FLUSH_FIFO);
 
@@ -526,7 +567,6 @@
        struct mesh_softc *sc;
        struct mesh_scb *scb;
 {
-       struct scsipi_xfer *xs = scb->xs;
        int datain = scb->flags & MESH_READ;
        dbdma_command_t *cmdp;
        u_int cmd;
@@ -582,6 +622,9 @@
        struct mesh_softc *sc;
        struct mesh_scb *scb;
 {
+       DPRINTF("mesh_dataio len = %ld (%s)\n", scb->dlen,
+               scb->flags & MESH_READ ? "read" : "write");
+
        mesh_dma_setup(sc, scb);
 
        if (scb->dlen == 65536)
@@ -604,6 +647,7 @@
        struct mesh_scb *scb;
 {
        if (mesh_read_reg(sc, MESH_FIFO_COUNT) == 0) {  /* XXX cheat */
+               DPRINTF("mesh_status(0)\n");
                MESH_SET_XFER(sc, 1);
                mesh_set_reg(sc, MESH_SEQUENCE, MESH_CMD_STATUS);
                sc->sc_nextstate = MESH_STATUS;
@@ -611,6 +655,9 @@
        }
 
        scb->status = mesh_read_reg(sc, MESH_FIFO);
+       DPRINTF("mesh_status(1): status = 0x%x\n", scb->status);
+       if (mesh_read_reg(sc, MESH_FIFO_COUNT) != 0)
+               DPRINTF("FIFO_COUNT=%d\n", mesh_read_reg(sc, MESH_FIFO_COUNT));
 
        mesh_set_reg(sc, MESH_SEQUENCE, MESH_CMD_FLUSH_FIFO);
        MESH_SET_XFER(sc, 1);
@@ -630,6 +677,8 @@
 {
        int i;
 
+       DPRINTF("mesh_msgin\n");
+
        if (mesh_read_reg(sc, MESH_FIFO_COUNT) == 0) {  /* XXX cheat */
                MESH_SET_XFER(sc, 1);
                mesh_set_reg(sc, MESH_SEQUENCE, MESH_CMD_MSGIN);
@@ -654,7 +703,7 @@
        return;
 
 gotit:
-#ifdef DEBUG
+#ifdef MESH_DEBUG



Home | Main Index | Thread Index | Old Index