[BACK]Return to sshdma.c CVS log [TXT][DIR] Up to [local] / sys / arch / mvme68k / dev

Annotation of sys/arch/mvme68k/dev/sshdma.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: sshdma.c,v 1.14 2006/11/28 23:59:45 dlg Exp $ */
        !             2:
        !             3: /*
        !             4:  * Copyright (c) 1995 Theo de Raadt
        !             5:  * Copyright (c) 1994 Michael L. Hitch
        !             6:  * Copyright (c) 1982, 1990 The Regents of the University of California.
        !             7:  * All rights reserved.
        !             8:  *
        !             9:  * Redistribution and use in source and binary forms, with or without
        !            10:  * modification, are permitted provided that the following conditions
        !            11:  * are met:
        !            12:  * 1. Redistributions of source code must retain the above copyright
        !            13:  *    notice, this list of conditions and the following disclaimer.
        !            14:  * 2. Redistributions in binary form must reproduce the above copyright
        !            15:  *    notice, this list of conditions and the following disclaimer in the
        !            16:  *    documentation and/or other materials provided with the distribution.
        !            17:  * 3. Neither the name of the University nor the names of its contributors
        !            18:  *    may be used to endorse or promote products derived from this software
        !            19:  *    without specific prior written permission.
        !            20:  *
        !            21:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            22:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            23:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            24:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            25:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            26:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            27:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            28:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            29:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            30:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            31:  * SUCH DAMAGE.
        !            32:  *
        !            33:  *     @(#)dma.c
        !            34:  */
        !            35:
        !            36: #include <sys/param.h>
        !            37: #include <sys/systm.h>
        !            38: #include <sys/kernel.h>
        !            39: #include <sys/device.h>
        !            40:
        !            41: #include <scsi/scsi_all.h>
        !            42: #include <scsi/scsiconf.h>
        !            43:
        !            44: #include <machine/autoconf.h>
        !            45: #include <mvme68k/dev/sshreg.h>
        !            46: #include <mvme68k/dev/sshvar.h>
        !            47:
        !            48: #include "mc.h"
        !            49: #include "pcctwo.h"
        !            50:
        !            51: #if NMC > 0
        !            52: #include <mvme68k/dev/mcreg.h>
        !            53: #endif
        !            54: #if NPCCTWO > 0
        !            55: #include <mvme68k/dev/pcctworeg.h>
        !            56: #endif
        !            57:
        !            58: int   afscmatch(struct device *, void *, void *);
        !            59: void  afscattach(struct device *, struct device *, void *);
        !            60:
        !            61: void  sshintr(struct ssh_softc *);
        !            62: int   afsc_dmaintr(void *);
        !            63:
        !            64: extern void sshinitialize(struct ssh_softc *);
        !            65:
        !            66: struct scsi_adapter afsc_scsiswitch = {
        !            67:        ssh_scsicmd,
        !            68:        ssh_minphys,
        !            69:        0,                      /* no lun support */
        !            70:        0,                      /* no lun support */
        !            71: };
        !            72:
        !            73: struct scsi_device afsc_scsidev = {
        !            74:        NULL,           /* use default error handler */
        !            75:        NULL,           /* do not have a start function */
        !            76:        NULL,           /* have no async handler */
        !            77:        NULL,           /* Use default done routine */
        !            78: };
        !            79:
        !            80: struct cfattach ssh_ca = {
        !            81:        sizeof(struct ssh_softc), afscmatch, afscattach,
        !            82: };
        !            83:
        !            84: struct cfdriver ssh_cd = {
        !            85:        NULL, "ssh", DV_DULL
        !            86: };
        !            87:
        !            88: int
        !            89: afscmatch(pdp, vcf, args)
        !            90: struct device *pdp;
        !            91: void *vcf, *args;
        !            92: {
        !            93:        struct confargs *ca = args;
        !            94:
        !            95:        return (!badvaddr((vaddr_t)ca->ca_vaddr, 4));
        !            96: }
        !            97:
        !            98: void
        !            99: afscattach(parent, self, auxp)
        !           100: struct device *parent, *self;
        !           101: void *auxp;
        !           102: {
        !           103:        struct ssh_softc *sc = (struct ssh_softc *)self;
        !           104:        struct confargs *ca = auxp;
        !           105:        struct scsibus_attach_args saa;
        !           106:        ssh_regmap_p rp;
        !           107:        int tmp;
        !           108:        extern int cpuspeed;
        !           109:
        !           110:        sc->sc_sshp = rp = (void *)ca->ca_vaddr;
        !           111:        /*
        !           112:         * ssh uses sc_clock_freq to define the dcntl & ctest7 reg values
        !           113:         * (was 0x0221, but i added SSH_CTEST7_SC0 for snooping control)
        !           114:         * XXX does the clock frequency change for the 33MHz processors?
        !           115:         */
        !           116:        sc->sc_clock_freq = cpuspeed * 2;
        !           117: #ifdef MVME177
        !           118:        /* MVME177 ssh clock documented as fixed 50MHz in VME177A/HX */
        !           119:        if (cputyp == CPU_177)
        !           120:                sc->sc_clock_freq = 50;
        !           121: #endif
        !           122: #ifdef MVME172
        !           123:        /* XXX this is a guess! Same as MVME177?*/
        !           124:        if (cputyp == CPU_172)
        !           125:                sc->sc_clock_freq = 50;
        !           126: #endif
        !           127:        sc->sc_dcntl = SSH_DCNTL_EA;
        !           128: /*XXX*/        if (sc->sc_clock_freq <= 25)
        !           129: /*XXX*/                sc->sc_dcntl |= (2 << 6);
        !           130: /*XXX*/        else if (sc->sc_clock_freq <= 37)
        !           131: /*XXX*/                sc->sc_dcntl |= (1 << 6);
        !           132: /*XXX*/        else if (sc->sc_clock_freq <= 50)
        !           133: /*XXX*/                sc->sc_dcntl |= (0 << 6);
        !           134: /*XXX*/        else
        !           135: /*XXX*/                sc->sc_dcntl |= (3 << 6);
        !           136:
        !           137: #if defined(MVME172) || defined(MVME177)
        !           138:        /* No Select timouts on MC68060 */
        !           139:        /* XXX 177 works better with them! */
        !           140:        if (cputyp == CPU_172 /* || cputyp == CPU_177 */)
        !           141:                sc->sc_ctest7 = SSH_CTEST7_SNOOP | SSH_CTEST7_TT1 | SSH_CTEST7_STD;
        !           142:        else
        !           143: #endif
        !           144:                sc->sc_ctest7 = SSH_CTEST7_SNOOP | SSH_CTEST7_TT1;
        !           145:
        !           146:        sc->sc_link.adapter_softc = sc;
        !           147:        sc->sc_link.adapter_target = 7;         /* XXXX should ask ROM */
        !           148:        sc->sc_link.adapter = &afsc_scsiswitch;
        !           149:        sc->sc_link.device = &afsc_scsidev;
        !           150:        sc->sc_link.openings = 1;
        !           151:
        !           152:        sc->sc_ih.ih_fn = afsc_dmaintr;
        !           153:        sc->sc_ih.ih_arg = sc;
        !           154:        sc->sc_ih.ih_ipl = ca->ca_ipl;
        !           155:
        !           156:        sshinitialize(sc);
        !           157:
        !           158:        switch (ca->ca_bustype) {
        !           159: #if NMC > 0
        !           160:        case BUS_MC:
        !           161:                mcintr_establish(MCV_NCR, &sc->sc_ih, self->dv_xname);
        !           162:                sys_mc->mc_ncrirq = ca->ca_ipl | MC_IRQ_IEN;
        !           163:                break;
        !           164: #endif
        !           165: #if NPCCTWO > 0
        !           166:        case BUS_PCCTWO:
        !           167:                pcctwointr_establish(PCC2V_NCR, &sc->sc_ih, self->dv_xname);
        !           168:                sys_pcc2->pcc2_ncrirq = ca->ca_ipl | PCC2_IRQ_IEN;
        !           169:                break;
        !           170: #endif
        !           171:        }
        !           172:
        !           173:        /*
        !           174:         * attach all scsi units on us, watching for boot device
        !           175:         * (see device_register).
        !           176:         */
        !           177:        tmp = bootpart;
        !           178:        if (ca->ca_paddr != bootaddr)
        !           179:                bootpart = -1;          /* invalid flag to device_register */
        !           180:
        !           181:        bzero(&saa, sizeof(saa));
        !           182:        saa.saa_sc_link = &sc->sc_link;
        !           183:
        !           184:        config_found(self, &saa, scsiprint);
        !           185:        bootpart = tmp;                          /* restore old value */
        !           186:
        !           187: }
        !           188:
        !           189: int
        !           190: afsc_dmaintr(arg)
        !           191:        void *arg;
        !           192: {
        !           193:        struct ssh_softc *sc = (struct ssh_softc *)arg;
        !           194:        ssh_regmap_p rp;
        !           195:        u_char   istat;
        !           196:
        !           197:        rp = sc->sc_sshp;
        !           198:        istat = rp->ssh_istat;
        !           199:        if ((istat & (SSH_ISTAT_SIP | SSH_ISTAT_DIP)) == 0)
        !           200:                return (0);
        !           201:        if ((rp->ssh_sien | rp->ssh_dien) == 0)
        !           202:                return (0);     /* no interrupts enabled */
        !           203:
        !           204:        /*
        !           205:         * save interrupt status, DMA status, and SCSI status 0
        !           206:         * (may need to deal with stacked interrupts?)
        !           207:         */
        !           208:        sc->sc_istat = istat;
        !           209:        sc->sc_dstat = rp->ssh_dstat;
        !           210:        sc->sc_sstat0 = rp->ssh_sstat0;
        !           211:        sshintr(sc);
        !           212:        return (1);
        !           213: }
        !           214:
        !           215: #ifdef DEBUG
        !           216: void
        !           217: afsc_dump()
        !           218: {
        !           219:        int i;
        !           220:
        !           221:        for (i = 0; i < afsccd.cd_ndevs; ++i)
        !           222:                if (afsccd.cd_devs[i])
        !           223:                        ssh_dump(afsccd.cd_devs[i]);
        !           224: }
        !           225: #endif

CVSweb