Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Do a fairly large internal restructuring to accomoda...



details:   https://anonhg.NetBSD.org/src/rev/5a3b211675bc
branches:  trunk
changeset: 472929:5a3b211675bc
user:      mjacob <mjacob%NetBSD.org@localhost>
date:      Wed May 12 18:59:23 1999 +0000

description:
Do a fairly large internal restructuring to accomodate dual-bus host adapters
(e.g., the 1240). Include the new 1080/1240 NVRAM layout reading code. Some
moderately significant mailbox changes were necessary also to accomodate a
second channel.

diffstat:

 sys/dev/ic/isp.c        |  997 +++++++++++++++++++++++++++++++----------------
 sys/dev/ic/isp_netbsd.c |   55 +-
 sys/dev/ic/isp_netbsd.h |   20 +-
 sys/dev/ic/ispreg.h     |  136 ++++++-
 sys/dev/ic/ispvar.h     |   44 +-
 sys/dev/pci/isp_pci.c   |   31 +-
 6 files changed, 873 insertions(+), 410 deletions(-)

diffs (truncated from 2315 to 300 lines):

diff -r d0f7553c5339 -r 5a3b211675bc sys/dev/ic/isp.c
--- a/sys/dev/ic/isp.c  Wed May 12 18:50:51 1999 +0000
+++ b/sys/dev/ic/isp.c  Wed May 12 18:59:23 1999 +0000
@@ -1,5 +1,5 @@
-/* $NetBSD: isp.c,v 1.35 1999/04/04 02:28:53 mjacob Exp $ */
-/* release_4_3_99 */
+/* $NetBSD: isp.c,v 1.36 1999/05/12 18:59:23 mjacob Exp $ */
+/* release_5_11_99 */
 /*
  * Machine and OS Independent (well, as best as possible)
  * code for the Qlogic ISP SCSI adapters.
@@ -108,6 +108,8 @@
 static void isp_parse_status
 __P((struct ispsoftc *, ispstatusreq_t *, ISP_SCSI_XFER_T *));
 static void isp_fastpost_complete __P((struct ispsoftc *, int));
+static void isp_scsi_init __P((struct ispsoftc *));
+static void isp_scsi_channel_init __P((struct ispsoftc *, int));
 static void isp_fibre_init __P((struct ispsoftc *));
 static void isp_mark_getpdb_all __P((struct ispsoftc *));
 static int isp_getpdb __P((struct ispsoftc *, int, isp_pdb_t *));
@@ -117,8 +119,9 @@
 static void isp_dumpxflist __P((struct ispsoftc *));
 static void isp_mboxcmd __P((struct ispsoftc *, mbreg_t *));
 
-static void isp_update  __P((struct ispsoftc *));
-static void isp_setdfltparm __P((struct ispsoftc *));
+static void isp_update __P((struct ispsoftc *));
+static void isp_update_bus __P((struct ispsoftc *, int));
+static void isp_setdfltparm __P((struct ispsoftc *, int));
 static int isp_read_nvram __P((struct ispsoftc *));
 static void isp_rdnvram_word __P((struct ispsoftc *, int, u_int16_t *));
 
@@ -202,11 +205,14 @@
 
        if (IS_FC(isp)) {
                revname = "2100";
+       } else if (IS_12X0(isp)) {
+               revname = "12X0";
+               isp->isp_clock = 60;
        } else if (IS_1080(isp)) {
                u_int16_t l;
                sdparam *sdp = isp->isp_param;
                revname = "1080";
-               sdp->isp_clock = 100;
+               isp->isp_clock = 100;
                l = ISP_READ(isp, SXP_PINS_DIFF) & ISP1080_MODE_MASK;
                switch (l) {
                case ISP1080_LVD_MODE:
@@ -241,7 +247,7 @@
                case 1:
                        revname = "1020";
                        isp->isp_type = ISP_HA_SCSI_1020;
-                       sdp->isp_clock = 40;
+                       isp->isp_clock = 40;
                        break;
                case 2:
                        /*
@@ -251,27 +257,27 @@
                         */
                        revname = "1020A";
                        isp->isp_type = ISP_HA_SCSI_1020A;
-                       sdp->isp_clock = 40;
+                       isp->isp_clock = 40;
                        break;
                case 3:
                        revname = "1040";
                        isp->isp_type = ISP_HA_SCSI_1040;
-                       sdp->isp_clock = 60;
+                       isp->isp_clock = 60;
                        break;
                case 4:
                        revname = "1040A";
                        isp->isp_type = ISP_HA_SCSI_1040A;
-                       sdp->isp_clock = 60;
+                       isp->isp_clock = 60;
                        break;
                case 5:
                        revname = "1040B";
                        isp->isp_type = ISP_HA_SCSI_1040B;
-                       sdp->isp_clock = 60;
+                       isp->isp_clock = 60;
                        break;
                case 6: 
                        revname = "1040C(?)";
                        isp->isp_type = ISP_HA_SCSI_1040C;
-                       sdp->isp_clock = 60;
+                       isp->isp_clock = 60;
                         break; 
                }
                /*
@@ -297,7 +303,7 @@
                         * If we're in Ultra Mode, we have to be 60Mhz clock-
                         * even for the SBus version.
                         */
-                       sdp->isp_clock = 60;
+                       isp->isp_clock = 60;
                } else {
                        sdp->isp_ultramode = 0;
                        /*
@@ -310,8 +316,8 @@
                 * our generic determinations.
                 */
                if (isp->isp_mdvec->dv_clock) {
-                       if (isp->isp_mdvec->dv_clock < sdp->isp_clock) {
-                               sdp->isp_clock = isp->isp_mdvec->dv_clock;
+                       if (isp->isp_mdvec->dv_clock < isp->isp_clock) {
+                               isp->isp_clock = isp->isp_mdvec->dv_clock;
                        }
                }
 
@@ -567,20 +573,19 @@
        isp_mboxcmd(isp, &mbs);
 
        if (isp->isp_type & ISP_HA_SCSI) {
-               sdparam *sdp = isp->isp_param;
                /*
                 * Set CLOCK RATE, but only if asked to.
                 */
-               if (sdp->isp_clock) {
+               if (isp->isp_clock) {
                        mbs.param[0] = MBOX_SET_CLOCK_RATE;
-                       mbs.param[1] = sdp->isp_clock;
+                       mbs.param[1] = isp->isp_clock;
                        isp_mboxcmd(isp, &mbs);
                        if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
                                isp_dumpregs(isp, "failed to set CLOCKRATE");
                                /* but continue */
                        } else {
                                IDPRINTF(3, ("%s: setting input clock to %d\n",
-                                   isp->isp_name, sdp->isp_clock));
+                                   isp->isp_name, isp->isp_clock));
                        }
                }
        }
@@ -608,6 +613,13 @@
                    isp->isp_romfw_rev[2]);
        }
        isp_fw_state(isp);
+       /*
+        * Set up DMA for the request and result mailboxes.
+        */
+       if (ISP_MBOXDMASETUP(isp) != 0) {
+               PRINTF("%s: can't setup dma mailboxes\n", isp->isp_name);
+               return;
+       }
        isp->isp_state = ISP_RESETSTATE;
 }
 
@@ -621,60 +633,57 @@
 isp_init(isp)
        struct ispsoftc *isp;
 {
-       sdparam *sdp;
-       mbreg_t mbs;
-       int tgt;
-
        /*
-        * Must do first.
+        * Must do this first to get defaults established.
         */
-       isp_setdfltparm(isp);
-
-       /*
-        * Set up DMA for the request and result mailboxes.
-        */
-       if (ISP_MBOXDMASETUP(isp) != 0) {
-               PRINTF("%s: can't setup dma mailboxes\n", isp->isp_name);
-               return;
+       isp_setdfltparm(isp, 0);
+       if (IS_12X0(isp)) {
+               isp_setdfltparm(isp, 1);
        }
 
-       /*
-        * If we're fibre, we have a completely different
-        * initialization method.
-        */
        if (IS_FC(isp)) {
                isp_fibre_init(isp);
-               return;
+       } else {
+               isp_scsi_init(isp);
        }
-       sdp = isp->isp_param;
+}
+
+static void
+isp_scsi_init(isp)
+       struct ispsoftc *isp;
+{
+       sdparam *sdp_chan0, *sdp_chan1;
+       mbreg_t mbs;
+
+       sdp_chan0 = isp->isp_param;
+       sdp_chan1 = sdp_chan0;
+       if (IS_12X0(isp)) {
+               sdp_chan1++;
+       }
+
+       /* First do overall per-card settings. */
 
        /*
         * If we have fast memory timing enabled, turn it on.
         */
-       if (sdp->isp_fast_mttr) {
+       if (isp->isp_fast_mttr) {
                ISP_WRITE(isp, RISC_MTR, 0x1313);
        }
 
        /*
-        * Set (possibly new) Initiator ID.
+        * Set Retry Delay and Count.
+        * You set both channels at the same time.
         */
-       mbs.param[0] = MBOX_SET_INIT_SCSI_ID;
-       mbs.param[1] = sdp->isp_initiator_id;
+       mbs.param[0] = MBOX_SET_RETRY_COUNT;
+       mbs.param[1] = sdp_chan0->isp_retry_count;
+       mbs.param[2] = sdp_chan0->isp_retry_delay;
+       mbs.param[6] = sdp_chan1->isp_retry_count;
+       mbs.param[7] = sdp_chan1->isp_retry_delay;
+
        isp_mboxcmd(isp, &mbs);
        if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
-               isp_dumpregs(isp, "failed to set initiator id");
-               return;
-       }
-
-       /*
-        * Set Retry Delay and Count
-        */
-       mbs.param[0] = MBOX_SET_RETRY_COUNT;
-       mbs.param[1] = sdp->isp_retry_count;
-       mbs.param[2] = sdp->isp_retry_delay;
-       isp_mboxcmd(isp, &mbs);
-       if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
-               isp_dumpregs(isp, "failed to set retry count and delay");
+               PRINTF("%s: failed to set retry count and retry delay\n",
+                   isp->isp_name);
                return;
        }
 
@@ -682,146 +691,73 @@
         * Set ASYNC DATA SETUP time. This is very important.
         */
        mbs.param[0] = MBOX_SET_ASYNC_DATA_SETUP_TIME;
-       mbs.param[1] = sdp->isp_async_data_setup;
+       mbs.param[1] = sdp_chan0->isp_async_data_setup;
+       mbs.param[2] = sdp_chan1->isp_async_data_setup;
        isp_mboxcmd(isp, &mbs);
        if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
-               isp_dumpregs(isp, "failed to set async data setup time");
+               PRINTF("%s: failed to set asynchronous data setup time\n",
+                   isp->isp_name);
                return;
        }
 
        /*
         * Set ACTIVE Negation State.
         */
-       mbs.param[0] = MBOX_SET_ACTIVE_NEG_STATE;
+       mbs.param[0] = MBOX_SET_ACT_NEG_STATE;
        mbs.param[1] =
-           (sdp->isp_req_ack_active_neg << 4) |
-           (sdp->isp_data_line_active_neg << 5);
+           (sdp_chan0->isp_req_ack_active_neg << 4) |
+           (sdp_chan0->isp_data_line_active_neg << 5);
+       mbs.param[2] =
+           (sdp_chan1->isp_req_ack_active_neg << 4) |
+           (sdp_chan1->isp_data_line_active_neg << 5);
+
        isp_mboxcmd(isp, &mbs);
        if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
-               isp_dumpregs(isp, "failed to set active neg state");
-               return;
+               PRINTF("%s: failed to set active negation state "
+                   "(%d,%d),(%d,%d)\n", isp->isp_name,
+                   sdp_chan0->isp_req_ack_active_neg,
+                   sdp_chan0->isp_data_line_active_neg,
+                   sdp_chan1->isp_req_ack_active_neg,
+                   sdp_chan1->isp_data_line_active_neg);
+               /*
+                * But don't return.
+                */
        }
 
        /*
         * Set the Tag Aging limit
         */
-
        mbs.param[0] = MBOX_SET_TAG_AGE_LIMIT;
-       mbs.param[1] = sdp->isp_tag_aging;
+       mbs.param[1] = sdp_chan0->isp_tag_aging;
+       mbs.param[2] = sdp_chan1->isp_tag_aging;
        isp_mboxcmd(isp, &mbs);
        if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
-               isp_dumpregs(isp, "failed to set tag age limit");
+               PRINTF("%s: failed to set tag age limit (%d,%d)\n",
+                   isp->isp_name, sdp_chan0->isp_tag_aging,
+                   sdp_chan1->isp_tag_aging);



Home | Main Index | Thread Index | Old Index