Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc Split si & sw drivers.



details:   https://anonhg.NetBSD.org/src/rev/1f4929b8ce01
branches:  trunk
changeset: 493908:1f4929b8ce01
user:      pk <pk%NetBSD.org@localhost>
date:      Mon Jun 26 19:54:08 2000 +0000

description:
Split si & sw drivers.

diffstat:

 sys/arch/sparc/conf/files.sparc |    6 +-
 sys/arch/sparc/dev/si.c         |  617 +-----------------------
 sys/arch/sparc/dev/sireg.h      |   84 ++-
 sys/arch/sparc/dev/sw.c         |  986 ++++++++++++++++++++++++++++++++++++++++
 sys/arch/sparc/dev/swreg.h      |  108 ++++
 5 files changed, 1191 insertions(+), 610 deletions(-)

diffs (truncated from 2095 to 300 lines):

diff -r 67c05ee3635b -r 1f4929b8ce01 sys/arch/sparc/conf/files.sparc
--- a/sys/arch/sparc/conf/files.sparc   Mon Jun 26 19:46:24 2000 +0000
+++ b/sys/arch/sparc/conf/files.sparc   Mon Jun 26 19:54:08 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.sparc,v 1.92 2000/05/05 14:19:25 augustss Exp $
+#      $NetBSD: files.sparc,v 1.93 2000/06/26 19:54:08 pk Exp $
 
 # @(#)files.sparc      8.1 (Berkeley) 7/19/93
 # sparc-specific configuration info
@@ -219,9 +219,11 @@
 
 device si: scsi, ncr5380sbc
 attach si at vme
+file   arch/sparc/dev/si.c             si
+
 device sw: scsi, ncr5380sbc
 attach sw at obio
-file   arch/sparc/dev/si.c             si | sw
+file   arch/sparc/dev/sw.c             sw
 
 #
 # Generic Sun stuff
diff -r 67c05ee3635b -r 1f4929b8ce01 sys/arch/sparc/dev/si.c
--- a/sys/arch/sparc/dev/si.c   Mon Jun 26 19:46:24 2000 +0000
+++ b/sys/arch/sparc/dev/si.c   Mon Jun 26 19:54:08 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: si.c,v 1.62 2000/06/26 09:50:00 pk Exp $       */
+/*     $NetBSD: si.c,v 1.63 2000/06/26 19:54:08 pk Exp $       */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -101,19 +101,9 @@
 #include <sys/errno.h>
 #include <sys/device.h>
 #include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/user.h>
-
-#include <vm/vm.h>
 
 #include <machine/bus.h>
 #include <machine/intr.h>
-#include <machine/autoconf.h>
-#include <machine/cpu.h>
-#include <machine/pmap.h>
-
-#include <sparc/sparc/vaddrs.h>
-#include <sparc/sparc/cpuvar.h>
 
 #include <dev/vme/vmereg.h>
 #include <dev/vme/vmevar.h>
@@ -131,8 +121,6 @@
 #define DEBUG XXX
 #endif
 
-#define COUNT_SW_LEFTOVERS     XXX     /* See sw DMA completion code */
-
 #include <dev/ic/ncr5380reg.h>
 #include <dev/ic/ncr5380var.h>
 
@@ -164,9 +152,7 @@
        int             dh_flags;
 #define        SIDH_BUSY       0x01            /* This DH is in use */
 #define        SIDH_OUT        0x02            /* DMA does data out (write) */
-       u_char *        dh_addr;        /* KVA of start of buffer */
        int             dh_maplen;      /* Original data length */
-       long            dh_startingpa;  /* PA of buffer; for "sw" */
        bus_dmamap_t    dh_dmamap;
 #define dh_dvma        dh_dmamap->dm_segs[0].ds_addr /* VA of buffer in DVMA space */
 };
@@ -181,10 +167,6 @@
        bus_dma_tag_t           sc_dmatag;
        vme_chipset_tag_t       sc_vctag;
 
-       int             sc_adapter_type;
-#define BOARD_ID_SI    0
-#define BOARD_ID_SW    1
-
        int             sc_adapter_iv_am; /* int. vec + address modifier */
        struct si_dma_handle *sc_dma;
        int             sc_xlen;        /* length of current DMA segment. */
@@ -200,9 +182,6 @@
  * mechanism.  The sc_options member of the softc is OR'd with
  * the value in si_options.
  *
- * On the "sw", interrupts (and thus) reselection don't work, so they're
- * disabled by default.  DMA is still a little dangerous, too.
- *
  * Note, there's a separate sw_options to make life easier.
  */
 #define        SI_ENABLE_DMA   0x01    /* Use DMA (maybe polled) */
@@ -211,51 +190,30 @@
 #define        SI_OPTIONS_MASK (SI_ENABLE_DMA|SI_DMA_INTR|SI_DO_RESELECT)
 #define SI_OPTIONS_BITS        "\10\3RESELECT\2DMA_INTR\1DMA"
 int si_options = SI_ENABLE_DMA|SI_DMA_INTR;
-int sw_options = SI_ENABLE_DMA;
-
-/* How long to wait for DMA before declaring an error. */
-int si_dma_intr_timo = 500;    /* ticks (sec. X 100) */
 
 static int     si_match __P((struct device *, struct cfdata *, void *));
-static int     sw_match __P((struct device *, struct cfdata *, void *));
 static void    si_attach __P((struct device *, struct device *, void *));
-static void    sw_attach __P((struct device *, struct device *, void *));
-static void    si_attach_common __P((struct device *, struct si_softc *));
 static int     si_intr __P((void *));
 static void    si_reset_adapter __P((struct ncr5380_softc *));
-static void    sw_reset_adapter __P((struct ncr5380_softc *));
-static void    (*reset_adapter) __P((struct ncr5380_softc *));
 static void    si_minphys __P((struct buf *));
 
-void si_dma_alloc __P((struct ncr5380_softc *));
-void si_dma_free __P((struct ncr5380_softc *));
-void si_dma_poll __P((struct ncr5380_softc *));
-
-void si_vme_dma_setup __P((struct ncr5380_softc *));
-void si_vme_dma_start __P((struct ncr5380_softc *));
-void si_vme_dma_eop __P((struct ncr5380_softc *));
-void si_vme_dma_stop __P((struct ncr5380_softc *));
+void   si_dma_alloc __P((struct ncr5380_softc *));
+void   si_dma_free __P((struct ncr5380_softc *));
+void   si_dma_poll __P((struct ncr5380_softc *));
 
-void si_vme_intr_on  __P((struct ncr5380_softc *));
-void si_vme_intr_off __P((struct ncr5380_softc *));
+void   si_dma_setup __P((struct ncr5380_softc *));
+void   si_dma_start __P((struct ncr5380_softc *));
+void   si_dma_eop __P((struct ncr5380_softc *));
+void   si_dma_stop __P((struct ncr5380_softc *));
 
-void si_obio_dma_setup __P((struct ncr5380_softc *));
-void si_obio_dma_start __P((struct ncr5380_softc *));
-void si_obio_dma_eop __P((struct ncr5380_softc *));
-void si_obio_dma_stop __P((struct ncr5380_softc *));
-
-void si_obio_intr_on __P((struct ncr5380_softc *));
-void si_obio_intr_off __P((struct ncr5380_softc *));
+void   si_intr_on  __P((struct ncr5380_softc *));
+void   si_intr_off __P((struct ncr5380_softc *));
 
 /* Shorthand bus space access */
 #define SIREG_READ(sc, index) \
        bus_space_read_2((sc)->sc_regt, (sc)->sc_regh, index)
 #define SIREG_WRITE(sc, index, v) \
        bus_space_write_2((sc)->sc_regt, (sc)->sc_regh, index, v)
-#define SWREG_READ(sc, index) \
-       bus_space_read_4((sc)->sc_regt, (sc)->sc_regh, index)
-#define SWREG_WRITE(sc, index, v) \
-       bus_space_write_4((sc)->sc_regt, (sc)->sc_regh, index, v)
 
 
 /* The Sun SCSI-3 VME controller. */
@@ -263,36 +221,6 @@
        sizeof(struct si_softc), si_match, si_attach
 };
 
-/* The Sun "SCSI Weird" 4/100 obio controller. */
-struct cfattach sw_ca = {
-       sizeof(struct si_softc), sw_match, sw_attach
-};
-
-static int
-sw_match(parent, cf, aux)
-       struct device   *parent;
-       struct cfdata *cf;
-       void *aux;
-{
-       union obio_attach_args *uoba = aux;
-       struct obio4_attach_args *oba;
-
-       /* Nothing but a Sun 4/100 is going to have these devices. */
-       if (cpuinfo.cpu_type != CPUTYP_4_100)
-               return (0);
-
-       if (uoba->uoba_isobio4 == 0)
-               return (0);
-
-       /* Make sure there is something there... */
-       oba = &uoba->uoba_oba4;
-       return (bus_space_probe(oba->oba_bustag, 0, oba->oba_paddr,
-                               1,      /* probe size */
-                               1,      /* offset */
-                               0,      /* flags */
-                               NULL, NULL));
-}
-
 static int
 si_match(parent, cf, aux)
        struct device   *parent;
@@ -334,6 +262,8 @@
        vme_mapresc_t resc;
        vme_intr_handle_t       ih;
        vme_am_t                mod;
+       char bits[64];
+       int i;
 
        sc->sc_dmatag = va->va_bdt;
        sc->sc_vctag = ct;
@@ -348,13 +278,11 @@
        ncr_sc->sc_regh = bh;
 
        sc->sc_options = si_options;
-       sc->sc_adapter_type = BOARD_ID_SI;
-       reset_adapter = si_reset_adapter;
 
-       ncr_sc->sc_dma_setup = si_vme_dma_setup;
-       ncr_sc->sc_dma_start = si_vme_dma_start;
-       ncr_sc->sc_dma_eop   = si_vme_dma_stop;
-       ncr_sc->sc_dma_stop  = si_vme_dma_stop;
+       ncr_sc->sc_dma_setup = si_dma_setup;
+       ncr_sc->sc_dma_start = si_dma_start;
+       ncr_sc->sc_dma_eop   = si_dma_stop;
+       ncr_sc->sc_dma_stop  = si_dma_stop;
 
        vme_intr_map(ct, va->ilevel, va->ivector, &ih);
        vme_intr_establish(ct, ih, IPL_BIO, si_intr, sc);
@@ -363,81 +291,6 @@
 
        sc->sc_adapter_iv_am = (mod << 8) | (va->ivector & 0xFF);
 
-       si_attach_common(parent, sc);
-
-       if (sc->sc_options & SI_DO_RESELECT) {
-               /*
-                * Need to enable interrupts (and DMA!)
-                * on this H/W for reselect to work.
-                */
-               ncr_sc->sc_intr_on   = si_vme_intr_on;
-               ncr_sc->sc_intr_off  = si_vme_intr_off;
-       }
-}
-
-static void
-sw_attach(parent, self, aux)
-       struct device   *parent, *self;
-       void            *aux;
-{
-       struct si_softc *sc = (struct si_softc *) self;
-       struct ncr5380_softc *ncr_sc = &sc->ncr_sc;
-       union obio_attach_args *uoba = aux;
-       struct obio4_attach_args *oba = &uoba->uoba_oba4;
-       bus_space_handle_t bh;
-
-       sc->sc_dmatag = oba->oba_dmatag;
-
-       /* Map the controller registers. */
-       if (obio_bus_map(oba->oba_bustag, oba->oba_paddr,
-                        0,
-                        SWREG_BANK_SZ,
-                        BUS_SPACE_MAP_LINEAR,
-                        0, &bh) != 0) {
-               printf("%s: cannot map registers\n", self->dv_xname);
-               return;
-       }
-
-       ncr_sc->sc_regt = oba->oba_bustag;
-       ncr_sc->sc_regh = bh;
-
-       sc->sc_options = sw_options;
-       sc->sc_adapter_type = BOARD_ID_SW;
-       reset_adapter = sw_reset_adapter;
-
-       ncr_sc->sc_dma_setup = si_obio_dma_setup;
-       ncr_sc->sc_dma_start = si_obio_dma_start;
-       ncr_sc->sc_dma_eop   = si_obio_dma_stop;
-       ncr_sc->sc_dma_stop  = si_obio_dma_stop;
-       ncr_sc->sc_intr_on   = si_obio_intr_on;
-       ncr_sc->sc_intr_off  = si_obio_intr_off;
-
-       /*
-        * Establish interrupt channel.
-        * Default interrupt priority always is 3.  At least, that's
-        * what my board seems to be at.  --thorpej
-        */
-       if (oba->oba_pri == -1)
-               oba->oba_pri = 3;
-
-       (void)bus_intr_establish(oba->oba_bustag,
-                                oba->oba_pri, 0,
-                                si_intr, sc);
-
-       printf(" pri %d\n", oba->oba_pri);
-
-       si_attach_common(parent, sc);
-}
-
-static void
-si_attach_common(parent, sc)
-       struct device   *parent;
-       struct si_softc *sc;
-{
-       struct ncr5380_softc *ncr_sc = &sc->ncr_sc;
-       char bits[64];
-       int error, i;
-
        /*
         * Pull in the options flags.  Allow the user to completely
         * override the default values.
@@ -478,7 +331,6 @@
                ncr_sc->sc_flags |= NCR5380_FORCE_POLLING;



Home | Main Index | Thread Index | Old Index