diff --git a/sys/arch/alpha/alpha/dec_3000_300.c b/sys/arch/alpha/alpha/dec_3000_300.c index dc2e2a9e04a3..ab5e33d95871 100644 --- a/sys/arch/alpha/alpha/dec_3000_300.c +++ b/sys/arch/alpha/alpha/dec_3000_300.c @@ -1,4 +1,4 @@ -/* $NetBSD: dec_3000_300.c,v 1.30 2000/05/22 20:13:32 thorpej Exp $ */ +/* $NetBSD: dec_3000_300.c,v 1.31 2000/07/04 02:22:08 nisimura Exp $ */ /* * Copyright (c) 1995, 1996 Carnegie-Mellon University. @@ -33,7 +33,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: dec_3000_300.c,v 1.30 2000/05/22 20:13:32 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dec_3000_300.c,v 1.31 2000/07/04 02:22:08 nisimura Exp $"); #include "opt_new_scc_driver.h" @@ -47,7 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: dec_3000_300.c,v 1.30 2000/05/22 20:13:32 thorpej Ex #include #include -#include +#include #include #ifndef NEW_SCC_DRIVER #include diff --git a/sys/arch/alpha/alpha/dec_3000_500.c b/sys/arch/alpha/alpha/dec_3000_500.c index 372d0188c6c3..2679ce7025bd 100644 --- a/sys/arch/alpha/alpha/dec_3000_500.c +++ b/sys/arch/alpha/alpha/dec_3000_500.c @@ -1,4 +1,4 @@ -/* $NetBSD: dec_3000_500.c,v 1.29 2000/05/22 20:13:32 thorpej Exp $ */ +/* $NetBSD: dec_3000_500.c,v 1.30 2000/07/04 02:22:09 nisimura Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. @@ -32,7 +32,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: dec_3000_500.c,v 1.29 2000/05/22 20:13:32 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dec_3000_500.c,v 1.30 2000/07/04 02:22:09 nisimura Exp $"); #include "opt_new_scc_driver.h" @@ -47,7 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: dec_3000_500.c,v 1.29 2000/05/22 20:13:32 thorpej Ex #include #include -#include +#include #include #ifndef NEW_SCC_DRIVER #include diff --git a/sys/arch/alpha/conf/files.alpha b/sys/arch/alpha/conf/files.alpha index da6126becab7..c697b67ec641 100644 --- a/sys/arch/alpha/conf/files.alpha +++ b/sys/arch/alpha/conf/files.alpha @@ -1,4 +1,4 @@ -# $NetBSD: files.alpha,v 1.119 2000/06/25 17:21:57 thorpej Exp $ +# $NetBSD: files.alpha,v 1.120 2000/07/04 02:22:10 nisimura Exp $ # # alpha-specific configuration info @@ -193,13 +193,12 @@ file dev/dec/zskbd.c zskbd needs-flag # the TCDS ASIC device tcds { chip = -1 } attach tcds at tc -file arch/alpha/tc/tcds.c tcds +file dev/tc/tcds.c tcds # 53C[F]90 SCSI device asc: scsi, ncr53c9x attach asc at tcds with asc_tcds -file arch/alpha/tc/asc.c asc -file arch/alpha/tc/tcds_dma.c asc +file dev/tc/asc_tcds.c asc_tcds # TC and baseboard ioasic Lance ethernet are in files.tc diff --git a/sys/arch/alpha/tc/asc.c b/sys/arch/alpha/tc/asc.c deleted file mode 100644 index 83d8c6eb6d45..000000000000 --- a/sys/arch/alpha/tc/asc.c +++ /dev/null @@ -1,340 +0,0 @@ -/* $NetBSD: asc.c,v 1.17 2000/06/05 07:59:50 nisimura Exp $ */ - -/*- - * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Charles M. Hannum; Jason R. Thorpe of the Numerical Aerospace - * Simulation Facility, NASA Ames Research Center; Paul Kranenburg. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 1994 Peter Galbavy - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Peter Galbavy - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Based on aic6360 by Jarle Greipsland - * - * Acknowledgements: Many of the algorithms used in this driver are - * inspired by the work of Julian Elischer (julian@tfs.com) and - * Charles Hannum (mycroft@duality.gnu.ai.mit.edu). Thanks a million! - */ - -#include /* RCS ID & Copyright macro defns */ - -__KERNEL_RCSID(0, "$NetBSD: asc.c,v 1.17 2000/06/05 07:59:50 nisimura Exp $"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include - -int asc_tcds_match __P((struct device *, struct cfdata *, void *)); -void asc_tcds_attach __P((struct device *, struct device *, void *)); - -/* Linkup to the rest of the kernel */ -struct cfattach asc_tcds_ca = { - sizeof(struct asc_tcds_softc), asc_tcds_match, asc_tcds_attach -}; - -/* - * Functions and the switch for the MI code. - */ -u_char asc_tcds_read_reg __P((struct ncr53c9x_softc *, int)); -void asc_tcds_write_reg __P((struct ncr53c9x_softc *, int, u_char)); -int asc_tcds_dma_isintr __P((struct ncr53c9x_softc *)); -void asc_tcds_dma_reset __P((struct ncr53c9x_softc *)); -int asc_tcds_dma_intr __P((struct ncr53c9x_softc *)); -int asc_tcds_dma_setup __P((struct ncr53c9x_softc *, caddr_t *, - size_t *, int, size_t *)); -void asc_tcds_dma_go __P((struct ncr53c9x_softc *)); -void asc_tcds_dma_stop __P((struct ncr53c9x_softc *)); -int asc_tcds_dma_isactive __P((struct ncr53c9x_softc *)); -void asc_tcds_clear_latched_intr __P((struct ncr53c9x_softc *)); - -struct ncr53c9x_glue asc_tcds_glue = { - asc_tcds_read_reg, - asc_tcds_write_reg, - asc_tcds_dma_isintr, - asc_tcds_dma_reset, - asc_tcds_dma_intr, - asc_tcds_dma_setup, - asc_tcds_dma_go, - asc_tcds_dma_stop, - asc_tcds_dma_isactive, - asc_tcds_clear_latched_intr, -}; - -int -asc_tcds_match(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; -{ - - /* We always exist. */ - return (1); -} - -/* - * Attach this instance, and then all the sub-devices - */ -void -asc_tcds_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct tcdsdev_attach_args *tcdsdev = aux; - struct asc_tcds_softc *asc = (void *)self; - struct ncr53c9x_softc *sc = &asc->sc_ncr53c9x; - - /* - * Set up glue for MI code early; we use some of it here. - */ - sc->sc_glue = &asc_tcds_glue; - - asc->sc_bst = tcdsdev->tcdsda_bst; - asc->sc_bsh = tcdsdev->tcdsda_bsh; - asc->sc_dma = tcdsdev->tcdsda_sc; - - sc->sc_id = tcdsdev->tcdsda_id; - sc->sc_freq = tcdsdev->tcdsda_freq; - - /* gimme Mhz */ - sc->sc_freq /= 1000000; - - asc->sc_dma->sc_asc = asc; /* XXX */ - - tcds_intr_establish(parent, tcdsdev->tcdsda_chip, ncr53c9x_intr, sc); - - /* - * XXX More of this should be in ncr53c9x_attach(), but - * XXX should we really poke around the chip that much in - * XXX the MI code? Think about this more... - */ - - /* - * Set up static configuration info. - */ - sc->sc_cfg1 = sc->sc_id | NCRCFG1_PARENB; - sc->sc_cfg2 = NCRCFG2_SCSI2; - sc->sc_cfg3 = NCRCFG3_CDB; - if (sc->sc_freq > 25) - sc->sc_cfg3 |= NCRF9XCFG3_FCLK; - sc->sc_rev = tcdsdev->tcdsda_variant; - if (tcdsdev->tcdsda_fast) { - sc->sc_features |= NCR_F_FASTSCSI; - sc->sc_cfg3_fscsi = NCRF9XCFG3_FSCSI; - } - - /* - * XXX minsync and maxxfer _should_ be set up in MI code, - * XXX but it appears to have some dependency on what sort - * XXX of DMA we're hooked up to, etc. - */ - - /* - * This is the value used to start sync negotiations - * Note that the NCR register "SYNCTP" is programmed - * in "clocks per byte", and has a minimum value of 4. - * The SCSI period used in negotiation is one-fourth - * of the time (in nanoseconds) needed to transfer one byte. - * Since the chip's clock is given in MHz, we have the following - * formula: 4 * period = (1000 / freq) * 4 - */ - sc->sc_minsync = (1000 / sc->sc_freq) * tcdsdev->tcdsda_period / 4; - - sc->sc_maxxfer = 64 * 1024; - - /* Do the common parts of attachment. */ - ncr53c9x_attach(sc, NULL, NULL); -} - -/* - * Glue functions. - */ - -u_char -asc_tcds_read_reg(sc, reg) - struct ncr53c9x_softc *sc; - int reg; -{ - struct asc_tcds_softc *asc = (struct asc_tcds_softc *)sc; - u_char v; - - v = bus_space_read_4(asc->sc_bst, asc->sc_bsh, - reg * sizeof(u_int32_t)) & 0xff; - - return (v); -} - -void -asc_tcds_write_reg(sc, reg, val) - struct ncr53c9x_softc *sc; - int reg; - u_char val; -{ - struct asc_tcds_softc *asc = (struct asc_tcds_softc *)sc; - - bus_space_write_4(asc->sc_bst, asc->sc_bsh, - reg * sizeof(u_int32_t), val); -} - -int -asc_tcds_dma_isintr(sc) - struct ncr53c9x_softc *sc; -{ - struct asc_tcds_softc *asc = (struct asc_tcds_softc *)sc; - - return (tcds_dma_isintr(asc->sc_dma)); -} - -void -asc_tcds_dma_reset(sc) - struct ncr53c9x_softc *sc; -{ - struct asc_tcds_softc *asc = (struct asc_tcds_softc *)sc; - - tcds_dma_reset(asc->sc_dma); -} - -int -asc_tcds_dma_intr(sc) - struct ncr53c9x_softc *sc; -{ - struct asc_tcds_softc *asc = (struct asc_tcds_softc *)sc; - - return (tcds_dma_intr(asc->sc_dma)); -} - -int -asc_tcds_dma_setup(sc, addr, len, datain, dmasize) - struct ncr53c9x_softc *sc; - caddr_t *addr; - size_t *len; - int datain; - size_t *dmasize; -{ - struct asc_tcds_softc *asc = (struct asc_tcds_softc *)sc; - - return (tcds_dma_setup(asc->sc_dma, addr, len, datain, dmasize)); -} - -void -asc_tcds_dma_go(sc) - struct ncr53c9x_softc *sc; -{ - struct asc_tcds_softc *asc = (struct asc_tcds_softc *)sc; - - tcds_dma_go(asc->sc_dma); -} - -void -asc_tcds_dma_stop(sc) - struct ncr53c9x_softc *sc; -{ -#if 0 - struct asc_tcds_softc *asc = (struct asc_tcds_softc *)sc; -#endif - - /* - * XXX STOP DMA HERE! - */ -} - -int -asc_tcds_dma_isactive(sc) - struct ncr53c9x_softc *sc; -{ - struct asc_tcds_softc *asc = (struct asc_tcds_softc *)sc; - - return (tcds_dma_isactive(asc->sc_dma)); -} - -void -asc_tcds_clear_latched_intr(sc) - struct ncr53c9x_softc *sc; -{ - struct asc_tcds_softc *asc = (struct asc_tcds_softc *)sc; - - /* Clear the TCDS interrupt bit. */ - (void)tcds_scsi_isintr(asc->sc_dma, 1); -} diff --git a/sys/arch/alpha/tc/ascvar.h b/sys/arch/alpha/tc/ascvar.h deleted file mode 100644 index 9467a42f15d2..000000000000 --- a/sys/arch/alpha/tc/ascvar.h +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: ascvar.h,v 1.6 1998/05/26 23:37:44 thorpej Exp $ */ - -/*- - * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -struct asc_tcds_softc { - struct ncr53c9x_softc sc_ncr53c9x; /* glue to MI code */ - - bus_space_tag_t sc_bst; /* bus space tag */ - bus_space_handle_t sc_bsh; /* bus space handle */ - - struct tcds_slotconfig *sc_dma; /* DMA/slot info lives here */ -}; diff --git a/sys/arch/alpha/tc/tcds_dma.c b/sys/arch/alpha/tc/tcds_dma.c deleted file mode 100644 index ec528000f198..000000000000 --- a/sys/arch/alpha/tc/tcds_dma.c +++ /dev/null @@ -1,359 +0,0 @@ -/* $NetBSD: tcds_dma.c,v 1.30 2000/06/29 09:02:58 mrg Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 1994 Peter Galbavy. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Peter Galbavy. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include /* RCS ID & Copyright macro defns */ - -__KERNEL_RCSID(0, "$NetBSD: tcds_dma.c,v 1.30 2000/06/29 09:02:58 mrg Exp $"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include - -void -tcds_dma_reset(sc) - struct tcds_slotconfig *sc; -{ - /* TCDS SCSI disable/reset/enable. */ - tcds_scsi_reset(sc); /* XXX */ - - sc->sc_active = 0; /* and of course we aren't */ -} - -int -tcds_dma_isintr(sc) - struct tcds_slotconfig *sc; -{ - int x; - - x = tcds_scsi_isintr(sc, 1); - - /* XXX */ - return x; -} - -/* - * Pseudo (chained) interrupt from the asc driver to kick the - * current running DMA transfer. I am relying on ascintr() to - * pickup and clean errors for now - * - * return 1 if it was a DMA continue. - */ -int -tcds_dma_intr(sc) - struct tcds_slotconfig *sc; -{ - struct ncr53c9x_softc *nsc = &sc->sc_asc->sc_ncr53c9x; - bus_dmamap_t map = sc->sc_dmamap; - u_int32_t dud; - int trans, resid; - u_int32_t *addr, dudmask; - u_int8_t tcl, tcm, tch; - bus_addr_t pa; - - NCR_DMA(("tcds_dma %d: intr", sc->sc_slot)); - - if (tcds_scsi_iserr(sc)) - return (0); - - /* This is an "assertion" :) */ - if (sc->sc_active == 0) - panic("tcds_dma_intr: DMA wasn't active"); - - /* DMA has stopped */ - tcds_dma_enable(sc, 0); - sc->sc_active = 0; - - if (sc->sc_dmasize == 0) { - /* A "Transfer Pad" operation completed */ - tcl = NCR_READ_REG(nsc, NCR_TCL); - tcm = NCR_READ_REG(nsc, NCR_TCM); - NCR_DMA(("tcds_dma_intr: discarded %d bytes (tcl=%d, tcm=%d)\n", - tcl | (tcm << 8), tcl, tcm)); - return 0; - } - - resid = 0; - if (!sc->sc_ispullup && - (resid = (NCR_READ_REG(nsc, NCR_FFLAG) & NCRFIFO_FF)) != 0) { - NCR_DMA(("dmaintr: empty esp FIFO of %d ", resid)); - DELAY(1); - } - - resid += (tcl = NCR_READ_REG(nsc, NCR_TCL)); - resid += (tcm = NCR_READ_REG(nsc, NCR_TCM)) << 8; - if (nsc->sc_rev == NCR_VARIANT_ESP200) - resid += (tch = NCR_READ_REG(nsc, NCR_TCH)) << 16; - else - tch = 0; - - if (resid == 0 && (nsc->sc_rev <= NCR_VARIANT_ESP100A) && - (nsc->sc_espstat & NCRSTAT_TC) == 0) - resid = 65536; - - trans = sc->sc_dmasize - resid; - if (trans < 0) { /* transferred < 0 ? */ - printf("tcds_dma %d: xfer (%d) > req (%d)\n", - sc->sc_slot, trans, (int)sc->sc_dmasize); - trans = sc->sc_dmasize; - } - - NCR_DMA(("tcds_dma_intr: tcl=%d, tcm=%d, tch=%d; trans=%d, resid=%d\n", - tcl, tcm, tch, trans, resid)); - - bus_dmamap_sync(sc->sc_dmat, map, 0, map->dm_mapsize, - (sc->sc_ispullup ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE)); - - /* - * Clean up unaligned DMAs into main memory. - */ - if (sc->sc_ispullup) { - /* Handle unaligned starting address, length. */ - dud = bus_space_read_4(sc->sc_bst, sc->sc_bsh, sc->sc_dud0); - if ((dud & TCDS_DUD0_VALIDBITS) != 0) { - addr = (u_int32_t *) - ((paddr_t)*sc->sc_dmaaddr & ~0x3); - dudmask = 0; - if (dud & TCDS_DUD0_VALID00) - panic("tcds_dma: dud0 byte 0 valid"); - if (dud & TCDS_DUD0_VALID01) - dudmask |= TCDS_DUD_BYTE01; - if (dud & TCDS_DUD0_VALID10) - dudmask |= TCDS_DUD_BYTE10; -#ifdef DIAGNOSTIC - if (dud & TCDS_DUD0_VALID11) - dudmask |= TCDS_DUD_BYTE11; -#endif - NCR_DMA(("dud0 at 0x%p dudmask 0x%x\n", - addr, dudmask)); - *addr = (*addr & ~dudmask) | (dud & dudmask); - } - dud = bus_space_read_4(sc->sc_bst, sc->sc_bsh, sc->sc_dud1); - if ((dud & TCDS_DUD1_VALIDBITS) != 0) { - pa = bus_space_read_4(sc->sc_bst, sc->sc_bsh, - sc->sc_sda) << 2; - dudmask = 0; - if (dud & TCDS_DUD1_VALID00) - dudmask |= TCDS_DUD_BYTE00; - if (dud & TCDS_DUD1_VALID01) - dudmask |= TCDS_DUD_BYTE01; - if (dud & TCDS_DUD1_VALID10) - dudmask |= TCDS_DUD_BYTE10; -#ifdef DIAGNOSTIC - if (dud & TCDS_DUD1_VALID11) - panic("tcds_dma: dud1 byte 3 valid"); -#endif - NCR_DMA(("dud1 at 0x%lx dudmask 0x%x\n", - pa, dudmask)); - /* XXX Fix TC_PHYS_TO_UNCACHED() */ -#if defined(__alpha__) - addr = (u_int32_t *)ALPHA_PHYS_TO_K0SEG(pa); -#elif defined(__mips__) - addr = (u_int32_t *)MIPS_PHYS_TO_KSEG1(pa); -#else -#error TurboChannel only exists on DECs, folks... -#endif - *addr = (*addr & ~dudmask) | (dud & dudmask); - } - /* XXX deal with saved residual byte? */ - } - - bus_dmamap_unload(sc->sc_dmat, map); - - *sc->sc_dmalen -= trans; - *sc->sc_dmaaddr += trans; - -#if 0 /* this is not normal operation just yet */ - if (*sc->sc_dmalen == 0 || - nsc->sc_phase != nsc->sc_prevphase) - return 0; - - /* and again */ - dma_start(sc, sc->sc_dmaaddr, sc->sc_dmalen, sc->sc_ispullup); - return 1; -#endif - return 0; -} - -#define DMAMAX(a) (0x02000 - ((a) & 0x1fff)) - -/* - * start a dma transfer or keep it going - */ -int -tcds_dma_setup(sc, addr, len, datain, dmasize) - struct tcds_slotconfig *sc; - caddr_t *addr; - size_t *len, *dmasize; - int datain; /* DMA into main memory */ -{ - bus_dmamap_t map = sc->sc_dmamap; - u_int32_t dic; - size_t size; - - sc->sc_dmaaddr = addr; - sc->sc_dmalen = len; - sc->sc_ispullup = datain; - - NCR_DMA(("tcds_dma %d: start %d@%p,%d\n", sc->sc_slot, - (int)*sc->sc_dmalen, *sc->sc_dmaaddr, sc->sc_ispullup)); - - /* - * the rules say we cannot transfer more than the limit - * of this DMA chip (64k) and we cannot cross a 8k boundary. - */ - - size = min(*dmasize, DMAMAX((size_t) *sc->sc_dmaaddr)); - *dmasize = sc->sc_dmasize = size; - - NCR_DMA(("dma_start: dmasize = %d\n", (int)sc->sc_dmasize)); - - if (bus_dmamap_load(sc->sc_dmat, map, *addr, size, - NULL, BUS_DMA_NOWAIT)) { - /* - * XXX Should return an error, here, but the upper-layer - * XXX doesn't check the return value! - */ - panic("tcds_dma_setup: dmamap load failed"); - } - - bus_dmamap_sync(sc->sc_dmat, map, 0, map->dm_mapsize, - (sc->sc_ispullup ? BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE)); - - /* Load address, set/clear unaligned transfer and read/write bits. */ - bus_space_write_4(sc->sc_bst, sc->sc_bsh, sc->sc_sda, - map->dm_segs[0].ds_addr >> 2); - dic = bus_space_read_4(sc->sc_bst, sc->sc_bsh, sc->sc_dic); - dic &= ~TCDS_DIC_ADDRMASK; - dic |= map->dm_segs[0].ds_addr & TCDS_DIC_ADDRMASK; - if (datain) - dic |= TCDS_DIC_WRITE; - else - dic &= ~TCDS_DIC_WRITE; - bus_space_write_4(sc->sc_bst, sc->sc_bsh, sc->sc_dic, dic); - - return (0); -} - -void -tcds_dma_go(sc) - struct tcds_slotconfig *sc; -{ - - /* mark unit as DMA-active */ - sc->sc_active = 1; - - /* Start DMA */ - tcds_dma_enable(sc, 1); -} - -int -tcds_dma_isactive(sc) - struct tcds_slotconfig *sc; -{ - - return (sc->sc_active); -} - -int -tcds_dma_init(sc) - struct tcds_slotconfig *sc; -{ - - /* - * The TCDS ASIC cannot DMA across 8k boundaries, and this - * driver is written such that each DMA segment gets a new - * call to tcds_dma_setup(). Thus, the DMA map only needs - * to support 8k transfers. - */ - return (bus_dmamap_create(sc->sc_dmat, 0x2000, 1, 0x2000, - 0x2000, BUS_DMA_NOWAIT, &sc->sc_dmamap)); -} diff --git a/sys/dev/tc/asc_tcds.c b/sys/dev/tc/asc_tcds.c new file mode 100644 index 000000000000..5a1052425f21 --- /dev/null +++ b/sys/dev/tc/asc_tcds.c @@ -0,0 +1,534 @@ +/* $NetBSD: asc_tcds.c,v 1.1 2000/07/04 02:22:19 nisimura Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (c) 1994 Peter Galbavy. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Peter Galbavy. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include /* RCS ID & Copyright macro defns */ + +__KERNEL_RCSID(0, "$NetBSD: asc_tcds.c,v 1.1 2000/07/04 02:22:19 nisimura Exp $"); + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + +struct asc_softc { + struct ncr53c9x_softc sc_ncr53c9x; /* glue to MI code */ + bus_space_tag_t sc_bst; /* bus space tag */ + bus_space_handle_t sc_scsi_bsh; /* ASC register handle */ + bus_dma_tag_t sc_dmat; /* bus dma tag */ + bus_dmamap_t sc_dmamap; /* bus dmamap */ + caddr_t *sc_dmaaddr; + size_t *sc_dmalen; + size_t sc_dmasize; + unsigned sc_flags; +#define ASC_ISPULLUP 0x01 +#define ASC_DMAACTIVE 0x02 +#define ASC_MAPLOADED 0x04 + struct tcds_slotconfig *sc_tcds; /* DMA/slot info lives here */ +}; + +static int asc_tcds_match __P((struct device *, struct cfdata *, void *)); +static void asc_tcds_attach __P((struct device *, struct device *, void *)); + +/* Linkup to the rest of the kernel */ +struct cfattach asc_tcds_ca = { + sizeof(struct asc_softc), asc_tcds_match, asc_tcds_attach +}; + +/* + * Functions and the switch for the MI code. + */ +static u_char asc_read_reg __P((struct ncr53c9x_softc *, int)); +static void asc_write_reg __P((struct ncr53c9x_softc *, int, u_char)); +static int tcds_dma_isintr __P((struct ncr53c9x_softc *)); +static void tcds_dma_reset __P((struct ncr53c9x_softc *)); +static int tcds_dma_intr __P((struct ncr53c9x_softc *)); +static int tcds_dma_setup __P((struct ncr53c9x_softc *, caddr_t *, + size_t *, int, size_t *)); +static void tcds_dma_go __P((struct ncr53c9x_softc *)); +static void tcds_dma_stop __P((struct ncr53c9x_softc *)); +static int tcds_dma_isactive __P((struct ncr53c9x_softc *)); +static void tcds_clear_latched_intr __P((struct ncr53c9x_softc *)); + +static struct ncr53c9x_glue asc_tcds_glue = { + asc_read_reg, + asc_write_reg, + tcds_dma_isintr, + tcds_dma_reset, + tcds_dma_intr, + tcds_dma_setup, + tcds_dma_go, + tcds_dma_stop, + tcds_dma_isactive, + tcds_clear_latched_intr, +}; + +static int +asc_tcds_match(parent, cf, aux) + struct device *parent; + struct cfdata *cf; + void *aux; +{ + + /* We always exist. */ + return 1; +} + +#define DMAMAX(a) (NBPG - ((a) & (NBPG - 1))) + +/* + * Attach this instance, and then all the sub-devices + */ +static void +asc_tcds_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct tcdsdev_attach_args *tcdsdev = aux; + struct asc_softc *asc = (struct asc_softc *)self; + struct ncr53c9x_softc *sc = &asc->sc_ncr53c9x; + int error; + + /* + * Set up glue for MI code early; we use some of it here. + */ + sc->sc_glue = &asc_tcds_glue; + + asc->sc_bst = tcdsdev->tcdsda_bst; + asc->sc_scsi_bsh = tcdsdev->tcdsda_bsh; + asc->sc_tcds = tcdsdev->tcdsda_sc; + + /* + * The TCDS ASIC cannot DMA across 8k boundaries, and this + * driver is written such that each DMA segment gets a new + * call to tcds_dma_setup(). Thus, the DMA map only needs + * to support 8k transfers. + */ + asc->sc_dmat = tcdsdev->tcdsda_dmat; + if ((error = bus_dmamap_create(asc->sc_dmat, NBPG, 1, NBPG, + NBPG, BUS_DMA_NOWAIT, &asc->sc_dmamap)) < 0) { + printf("failed to create dma map, error = %d\n", error); + } + + sc->sc_id = tcdsdev->tcdsda_id; + sc->sc_freq = tcdsdev->tcdsda_freq; + + /* gimme Mhz */ + sc->sc_freq /= 1000000; + + tcds_intr_establish(parent, tcdsdev->tcdsda_chip, ncr53c9x_intr, sc); + + /* + * XXX More of this should be in ncr53c9x_attach(), but + * XXX should we really poke around the chip that much in + * XXX the MI code? Think about this more... + */ + + /* + * Set up static configuration info. + */ + sc->sc_cfg1 = sc->sc_id | NCRCFG1_PARENB; + sc->sc_cfg2 = NCRCFG2_SCSI2; + sc->sc_cfg3 = NCRCFG3_CDB; + if (sc->sc_freq > 25) + sc->sc_cfg3 |= NCRF9XCFG3_FCLK; + sc->sc_rev = tcdsdev->tcdsda_variant; + if (tcdsdev->tcdsda_fast) { + sc->sc_features |= NCR_F_FASTSCSI; + sc->sc_cfg3_fscsi = NCRF9XCFG3_FSCSI; + } + + /* + * XXX minsync and maxxfer _should_ be set up in MI code, + * XXX but it appears to have some dependency on what sort + * XXX of DMA we're hooked up to, etc. + */ + + /* + * This is the value used to start sync negotiations + * Note that the NCR register "SYNCTP" is programmed + * in "clocks per byte", and has a minimum value of 4. + * The SCSI period used in negotiation is one-fourth + * of the time (in nanoseconds) needed to transfer one byte. + * Since the chip's clock is given in MHz, we have the following + * formula: 4 * period = (1000 / freq) * 4 + */ + sc->sc_minsync = (1000 / sc->sc_freq) * tcdsdev->tcdsda_period / 4; + + sc->sc_maxxfer = 64 * 1024; + + /* Do the common parts of attachment. */ + ncr53c9x_attach(sc, NULL, NULL); +} + +static void +tcds_dma_reset(sc) + struct ncr53c9x_softc *sc; +{ + struct asc_softc *asc = (struct asc_softc *)sc; + + /* TCDS SCSI disable/reset/enable. */ + tcds_scsi_reset(asc->sc_tcds); /* XXX */ + + if (asc->sc_flags & ASC_MAPLOADED) + bus_dmamap_unload(asc->sc_dmat, asc->sc_dmamap); + asc->sc_flags &= ~(ASC_DMAACTIVE|ASC_MAPLOADED); +} + +/* + * start a dma transfer or keep it going + */ +int +tcds_dma_setup(sc, addr, len, ispullup, dmasize) + struct ncr53c9x_softc *sc; + caddr_t *addr; + size_t *len, *dmasize; + int ispullup; /* DMA into main memory */ +{ + struct asc_softc *asc = (struct asc_softc *)sc; + struct tcds_slotconfig *tcds = asc->sc_tcds; + size_t size; + u_int32_t dic; + + NCR_DMA(("tcds_dma %d: start %d@%p,%s\n", tcds->sc_slot, + (int)*asc->sc_dmalen, *asc->sc_dmaaddr, + (ispullup) ? "IN" : "OUT")); + + /* + * the rules say we cannot transfer more than the limit + * of this DMA chip (64k) and we cannot cross a 8k boundary. + */ + size = min(*dmasize, DMAMAX((size_t)*addr)); + asc->sc_dmaaddr = addr; + asc->sc_dmalen = len; + asc->sc_flags = (ispullup) ? ASC_ISPULLUP : 0; + *dmasize = asc->sc_dmasize = size; + + NCR_DMA(("dma_start: dmasize = %d\n", (int)size)); + + if (size == 0) + return 0; + + if (bus_dmamap_load(asc->sc_dmat, asc->sc_dmamap, *addr, size, + NULL, BUS_DMA_NOWAIT)) { + /* + * XXX Should return an error, here, but the upper-layer + * XXX doesn't check the return value! + */ + panic("tcds_dma_setup: dmamap load failed"); + } + + /* synchronize dmamap contents with memory image */ + bus_dmamap_sync(asc->sc_dmat, asc->sc_dmamap, 0, size, + (ispullup) ? BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE); + + /* load address, set/clear unaligned transfer and read/write bits. */ + bus_space_write_4(tcds->sc_bst, tcds->sc_bsh, tcds->sc_sda, + asc->sc_dmamap->dm_segs[0].ds_addr >> 2); + dic = bus_space_read_4(tcds->sc_bst, tcds->sc_bsh, tcds->sc_dic); + dic &= ~TCDS_DIC_ADDRMASK; + dic |= asc->sc_dmamap->dm_segs[0].ds_addr & TCDS_DIC_ADDRMASK; + if (ispullup) + dic |= TCDS_DIC_WRITE; + else + dic &= ~TCDS_DIC_WRITE; + bus_space_write_4(tcds->sc_bst, tcds->sc_bsh, tcds->sc_dic, dic); + + asc->sc_flags |= ASC_MAPLOADED; + return 0; +} + +static void +tcds_dma_go(sc) + struct ncr53c9x_softc *sc; +{ + struct asc_softc *asc = (struct asc_softc *)sc; + + /* mark unit as DMA-active */ + asc->sc_flags |= ASC_DMAACTIVE; + + /* start DMA */ + tcds_dma_enable(asc->sc_tcds, 1); +} + +static void +tcds_dma_stop(sc) + struct ncr53c9x_softc *sc; +{ +#if 0 + struct asc_softc *asc = (struct asc_softc *)sc; +#endif + + /* + * XXX STOP DMA HERE! + */ +} + +/* + * Pseudo (chained) interrupt from the asc driver to kick the + * current running DMA transfer. Called from ncr53c9x_intr() + * for now. + * + * return 1 if it was a DMA continue. + */ +static int +tcds_dma_intr(sc) + struct ncr53c9x_softc *sc; +{ + struct asc_softc *asc = (struct asc_softc *)sc; + struct tcds_slotconfig *tcds = asc->sc_tcds; + int trans, resid; + u_int32_t tcl, tcm; + u_int32_t dud, dudmask, *addr; + bus_addr_t pa; + + NCR_DMA(("tcds_dma %d: intr", tcds->sc_slot)); + + if (tcds_scsi_iserr(tcds)) + return 0; + + /* This is an "assertion" :) */ + if ((asc->sc_flags & ASC_DMAACTIVE) == 0) + panic("tcds_dma_intr: DMA wasn't active"); + + /* DMA has stopped */ + tcds_dma_enable(tcds, 0); + asc->sc_flags &= ~ASC_DMAACTIVE; + + if (asc->sc_dmasize == 0) { + /* A "Transfer Pad" operation completed */ + tcl = NCR_READ_REG(sc, NCR_TCL); + tcm = NCR_READ_REG(sc, NCR_TCM); + NCR_DMA(("dma_intr: discarded %d bytes (tcl=%d, tcm=%d)\n", + tcl | (tcm << 8), tcl, tcm)); + return 0; + } + + resid = 0; + if ((asc->sc_flags & ASC_ISPULLUP) == 0 && + (resid = (NCR_READ_REG(sc, NCR_FFLAG) & NCRFIFO_FF)) != 0) { + NCR_DMA(("dma_intr: empty esp FIFO of %d ", resid)); + DELAY(1); + } + + resid += (tcl = NCR_READ_REG(sc, NCR_TCL)); + resid += (tcm = NCR_READ_REG(sc, NCR_TCM)) << 8; + + trans = asc->sc_dmasize - resid; + if (trans < 0) { /* transferred < 0 ? */ + printf("tcds_dma %d: xfer (%d) > req (%d)\n", + tcds->sc_slot, trans, (int)asc->sc_dmasize); + trans = asc->sc_dmasize; + } + + NCR_DMA(("dma_intr: tcl=%d, tcm=%d; trans=%d, resid=%d\n", + tcl, tcm, trans, resid)); + + *asc->sc_dmalen -= trans; + *asc->sc_dmaaddr += trans; + + bus_dmamap_sync(asc->sc_dmat, asc->sc_dmamap, + 0, asc->sc_dmamap->dm_mapsize, + (sc->sc_flags & ASC_ISPULLUP) + ? BUS_DMASYNC_POSTREAD + : BUS_DMASYNC_POSTWRITE); + + /* + * Clean up unaligned DMAs into main memory. + */ + if (asc->sc_flags & ASC_ISPULLUP) { + /* Handle unaligned starting address, length. */ + dud = bus_space_read_4(tcds->sc_bst, + tcds->sc_bsh, tcds->sc_dud0); + if ((dud & TCDS_DUD0_VALIDBITS) != 0) { + addr = (u_int32_t *) + ((paddr_t)*asc->sc_dmaaddr & ~0x3); + dudmask = 0; + if (dud & TCDS_DUD0_VALID00) + panic("tcds_dma: dud0 byte 0 valid"); + if (dud & TCDS_DUD0_VALID01) + dudmask |= TCDS_DUD_BYTE01; + if (dud & TCDS_DUD0_VALID10) + dudmask |= TCDS_DUD_BYTE10; +#ifdef DIAGNOSTIC + if (dud & TCDS_DUD0_VALID11) + dudmask |= TCDS_DUD_BYTE11; +#endif + NCR_DMA(("dud0 at 0x%p dudmask 0x%x\n", + addr, dudmask)); + *addr = (*addr & ~dudmask) | (dud & dudmask); + } + dud = bus_space_read_4(tcds->sc_bst, + tcds->sc_bsh, tcds->sc_dud1); + if ((dud & TCDS_DUD1_VALIDBITS) != 0) { + pa = bus_space_read_4(tcds->sc_bst, tcds->sc_bsh, + tcds->sc_sda) << 2; + dudmask = 0; + if (dud & TCDS_DUD1_VALID00) + dudmask |= TCDS_DUD_BYTE00; + if (dud & TCDS_DUD1_VALID01) + dudmask |= TCDS_DUD_BYTE01; + if (dud & TCDS_DUD1_VALID10) + dudmask |= TCDS_DUD_BYTE10; +#ifdef DIAGNOSTIC + if (dud & TCDS_DUD1_VALID11) + panic("tcds_dma: dud1 byte 3 valid"); +#endif + NCR_DMA(("dud1 at 0x%lx dudmask 0x%x\n", + pa, dudmask)); + /* XXX Fix TC_PHYS_TO_UNCACHED() */ +#if defined(__alpha__) + addr = (u_int32_t *)ALPHA_PHYS_TO_K0SEG(pa); +#elif defined(__mips__) + addr = (u_int32_t *)MIPS_PHYS_TO_KSEG1(pa); +#else +#error TURBOchannel only exists on DECs, folks... +#endif + *addr = (*addr & ~dudmask) | (dud & dudmask); + } + /* XXX deal with saved residual byte? */ + } + + bus_dmamap_unload(asc->sc_dmat, asc->sc_dmamap); + asc->sc_flags &= ~ASC_MAPLOADED; + + return 0; +} + +/* + * Glue functions. + */ +static u_char +asc_read_reg(sc, reg) + struct ncr53c9x_softc *sc; + int reg; +{ + struct asc_softc *asc = (struct asc_softc *)sc; + u_int32_t v; + + v = bus_space_read_4(asc->sc_bst, asc->sc_scsi_bsh, + reg * sizeof(u_int32_t)); + + return v & 0xff; +} + +static void +asc_write_reg(sc, reg, val) + struct ncr53c9x_softc *sc; + int reg; + u_char val; +{ + struct asc_softc *asc = (struct asc_softc *)sc; + + bus_space_write_4(asc->sc_bst, asc->sc_scsi_bsh, + reg * sizeof(u_int32_t), val); +} + +static int +tcds_dma_isintr(sc) + struct ncr53c9x_softc *sc; +{ + struct asc_softc *asc = (struct asc_softc *)sc; + int x; + + x = tcds_scsi_isintr(asc->sc_tcds, 1); + + /* XXX */ + return x; +} + +static int +tcds_dma_isactive(sc) + struct ncr53c9x_softc *sc; +{ + struct asc_softc *asc = (struct asc_softc *)sc; + + return !!(asc->sc_flags & ASC_DMAACTIVE); +} + +static void +tcds_clear_latched_intr(sc) + struct ncr53c9x_softc *sc; +{ + struct asc_softc *asc = (struct asc_softc *)sc; + + /* Clear the TCDS interrupt bit. */ + (void)tcds_scsi_isintr(asc->sc_tcds, 1); +} diff --git a/sys/arch/alpha/tc/tcds.c b/sys/dev/tc/tcds.c similarity index 96% rename from sys/arch/alpha/tc/tcds.c rename to sys/dev/tc/tcds.c index e8b8b0298e32..90f9552f4c48 100644 --- a/sys/arch/alpha/tc/tcds.c +++ b/sys/dev/tc/tcds.c @@ -1,4 +1,4 @@ -/* $NetBSD: tcds.c,v 1.30 2000/06/05 21:47:32 thorpej Exp $ */ +/* $NetBSD: tcds.c,v 1.1 2000/07/04 02:22:19 nisimura Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: tcds.c,v 1.30 2000/06/05 21:47:32 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcds.c,v 1.1 2000/07/04 02:22:19 nisimura Exp $"); #include #include @@ -78,33 +78,27 @@ __KERNEL_RCSID(0, "$NetBSD: tcds.c,v 1.30 2000/06/05 21:47:32 thorpej Exp $"); #include #endif /* __alpha__ */ -#include - -#include -#include -#include -#include - -#include #include -#include +#include +#include #include +#include + +#include +#include +#include + #include "locators.h" struct tcds_softc { struct device sc_dv; - bus_space_tag_t sc_bst; bus_space_handle_t sc_bsh; - bus_dma_tag_t sc_dmat; - void *sc_cookie; - int sc_flags; - struct tcds_slotconfig sc_slots[2]; }; @@ -176,7 +170,7 @@ tcdsattach(parent, self, aux) struct tcds_slotconfig *slotc; struct tcds_device *td; bus_space_handle_t sbsh[2]; - int i, error, gpi2; + int i, gpi2; const struct evcnt *pevcnt; char *cp; @@ -255,15 +249,8 @@ tcdsattach(parent, self, aux) slotc->sc_slot = i; slotc->sc_bst = sc->sc_bst; slotc->sc_bsh = sc->sc_bsh; - slotc->sc_asc = NULL; slotc->sc_intrhand = tcds_intrnull; slotc->sc_intrarg = (void *)(long)i; - slotc->sc_dmat = sc->sc_dmat; - if ((error = tcds_dma_init(slotc)) != 0) { - printf("%s: tcds_dma_init failed, error = %d\n", - sc->sc_dv.dv_xname, error); - return; - } } /* information for slot 0 */ @@ -299,6 +286,7 @@ tcdsattach(parent, self, aux) tcdsdev.tcdsda_bst = sc->sc_bst; tcdsdev.tcdsda_bsh = sbsh[i]; + tcdsdev.tcdsda_dmat = sc->sc_dmat; tcdsdev.tcdsda_chip = i; tcdsdev.tcdsda_sc = &sc->sc_slots[i]; /* diff --git a/sys/arch/alpha/tc/tcdsreg.h b/sys/dev/tc/tcdsreg.h similarity index 99% rename from sys/arch/alpha/tc/tcdsreg.h rename to sys/dev/tc/tcdsreg.h index 4fafb0e5d0f9..fd6054bb06c8 100644 --- a/sys/arch/alpha/tc/tcdsreg.h +++ b/sys/dev/tc/tcdsreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: tcdsreg.h,v 1.5 1998/05/26 22:48:01 thorpej Exp $ */ +/* $NetBSD: tcdsreg.h,v 1.1 2000/07/04 02:22:20 nisimura Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. diff --git a/sys/arch/alpha/tc/tcdsvar.h b/sys/dev/tc/tcdsvar.h similarity index 74% rename from sys/arch/alpha/tc/tcdsvar.h rename to sys/dev/tc/tcdsvar.h index 83660f96b6bd..8d1673293bd2 100644 --- a/sys/arch/alpha/tc/tcdsvar.h +++ b/sys/dev/tc/tcdsvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: tcdsvar.h,v 1.13 2000/06/05 21:47:33 thorpej Exp $ */ +/* $NetBSD: tcdsvar.h,v 1.1 2000/07/04 02:22:21 nisimura Exp $ */ /* * Copyright (c) 1995, 1996 Carnegie-Mellon University. @@ -36,8 +36,6 @@ struct tcds_slotconfig { bus_space_tag_t sc_bst; /* to frob TCDS regs */ bus_space_handle_t sc_bsh; - struct asc_tcds_softc *sc_asc; /* to frob child's regs */ - int (*sc_intrhand) __P((void *)); /* intr. handler */ void *sc_intrarg; /* intr. handler arg. */ struct evcnt sc_evcnt; /* intr. count */ @@ -59,22 +57,12 @@ struct tcds_slotconfig { bus_size_t sc_dic; bus_size_t sc_dud0; bus_size_t sc_dud1; - - /* - * DMA bookkeeping information. - */ - bus_dma_tag_t sc_dmat; - bus_dmamap_t sc_dmamap; - int sc_active; /* DMA active ? */ - int sc_ispullup; /* DMA into main memory? */ - size_t sc_dmasize; - caddr_t *sc_dmaaddr; - size_t *sc_dmalen; }; struct tcdsdev_attach_args { bus_space_tag_t tcdsda_bst; /* bus space tag */ bus_space_handle_t tcdsda_bsh; /* bus space handle */ + bus_dma_tag_t tcdsda_dmat; /* bus dma tag */ struct tcds_slotconfig *tcdsda_sc; /* slot configuration */ int tcdsda_chip; /* chip number */ int tcdsda_id; /* SCSI ID */ @@ -95,19 +83,3 @@ void tcds_scsi_enable __P((struct tcds_slotconfig *, int)); int tcds_scsi_iserr __P((struct tcds_slotconfig *)); int tcds_scsi_isintr __P((struct tcds_slotconfig *, int)); void tcds_scsi_reset __P((struct tcds_slotconfig *)); - -/* - * TCDS DMA functions (used by the 53c94 driver) - */ -int tcds_dma_isintr __P((struct tcds_slotconfig *)); -void tcds_dma_reset __P((struct tcds_slotconfig *)); -int tcds_dma_intr __P((struct tcds_slotconfig *)); -int tcds_dma_setup __P((struct tcds_slotconfig *, caddr_t *, size_t *, - int, size_t *)); -void tcds_dma_go __P((struct tcds_slotconfig *)); -int tcds_dma_isactive __P((struct tcds_slotconfig *)); - -/* - * TCDS DMA functions (private to TCDS) - */ -int tcds_dma_init __P((struct tcds_slotconfig *));