[BACK]Return to dpt_pci.c CVS log [TXT][DIR] Up to [local] / sys / dev / pci

Annotation of sys/dev/pci/dpt_pci.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: dpt_pci.c,v 1.5 2005/08/09 04:10:11 mickey Exp $      */
                      2: /*     $NetBSD: dpt_pci.c,v 1.2 1999/09/29 17:33:02 ad Exp $   */
                      3:
                      4: /*
                      5:  * Copyright (c) 1999 Andy Doran <ad@NetBSD.org>
                      6:  * All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  *
                     17:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
                     18:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     19:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     20:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                     21:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     22:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     23:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     24:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     25:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     26:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     27:  * SUCH DAMAGE.
                     28:  *
                     29:  */
                     30:
                     31: /*
                     32:  * PCI front-end for DPT EATA SCSI driver.
                     33:  */
                     34:
                     35: #include <sys/cdefs.h>
                     36: #ifdef __NetBSD__
                     37: __KERNEL_RCSID(0, "$NetBSD: dpt_pci.c,v 1.2 1999/09/29 17:33:02 ad Exp $");
                     38: #endif /* __NetBSD__ */
                     39:
                     40: #include <sys/param.h>
                     41: #include <sys/systm.h>
                     42: #include <sys/kernel.h>
                     43: #include <sys/device.h>
                     44: #include <sys/queue.h>
                     45: #include <sys/proc.h>
                     46:
                     47: #include <machine/endian.h>
                     48: #include <machine/bus.h>
                     49:
                     50: #ifdef __NetBSD__
                     51: #include <dev/scsipi/scsi_all.h>
                     52: #include <dev/scsipi/scsipi_all.h>
                     53: #include <dev/scsipi/scsiconf.h>
                     54: #endif /* __NetBSD__ */
                     55: #ifdef __OpenBSD__
                     56: #include <scsi/scsi_all.h>
                     57: #include <scsi/scsiconf.h>
                     58: #endif /* __OpenBSD__ */
                     59:
                     60: #include <dev/pci/pcidevs.h>
                     61: #include <dev/pci/pcivar.h>
                     62:
                     63: #include <dev/ic/dptreg.h>
                     64: #include <dev/ic/dptvar.h>
                     65:
                     66: #define        PCI_CBMA        0x14    /* Configuration base memory address */
                     67: #define        PCI_CBIO        0x10    /* Configuration base I/O address */
                     68:
                     69: #ifdef __NetBSD__
                     70: int    dpt_pci_match(struct device *, struct cfdata *, void *);
                     71: #endif /* __NetBSD__ */
                     72: #ifdef __OpenBSD__
                     73: int    dpt_pci_match(struct device *, void *, void *);
                     74: #endif /* __OpenBSD__ */
                     75: void   dpt_pci_attach(struct device *, struct device *, void *);
                     76:
                     77: struct cfattach dpt_pci_ca = {
                     78:        sizeof(struct dpt_softc), dpt_pci_match, dpt_pci_attach
                     79: };
                     80:
                     81: int
                     82: dpt_pci_match(parent, match, aux)
                     83:        struct device *parent;
                     84: #ifdef __NetBSD__
                     85:        struct cfdata *match;
                     86: #endif /* __NetBSD__ */
                     87: #ifdef __OpenBSD__
                     88:        void *match;
                     89: #endif /* __OpenBSD__ */
                     90:        void *aux;
                     91: {
                     92:        struct pci_attach_args *pa = (struct pci_attach_args *) aux;
                     93:
                     94:        if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_DPT &&
                     95:            PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_DPT_SC_RAID)
                     96:                return (1);
                     97:
                     98:        return (0);
                     99: }
                    100:
                    101: void
                    102: dpt_pci_attach(parent, self, aux)
                    103:        struct device *parent;
                    104:        struct device *self;
                    105:        void *aux;
                    106: {
                    107:        struct pci_attach_args *pa;
                    108:        struct dpt_softc *sc;
                    109:        pci_chipset_tag_t pc;
                    110:        pci_intr_handle_t ih;
                    111:        const char *intrstr;
                    112:
                    113:        sc = (struct dpt_softc *)self;
                    114:        pa = (struct pci_attach_args *)aux;
                    115:        pc = pa->pa_pc;
                    116:        printf(": ");
                    117:
                    118:        if (pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0, &sc->sc_iot,
                    119:            &sc->sc_ioh, NULL, NULL, 0)) {
                    120:                printf("can't map i/o space\n");
                    121:                return;
                    122:        }
                    123:
                    124:        sc->sc_dmat = pa->pa_dmat;
                    125:
                    126:        /* Map and establish the interrupt. */
                    127:        if (pci_intr_map(pa, &ih)) {
                    128:                printf("can't map interrupt\n");
                    129:                return;
                    130:        }
                    131:        intrstr = pci_intr_string(pc, ih);
                    132: #ifdef __NetBSD__
                    133:        sc->sc_ih = pci_intr_establish(pc, ih, IPL_BIO, dpt_intr, sc);
                    134: #endif /* __NetBSD__ */
                    135: #ifdef __OpenBSD__
                    136:        sc->sc_ih = pci_intr_establish(pc, ih, IPL_BIO, dpt_intr, sc,
                    137:                                       sc->sc_dv.dv_xname);
                    138: #endif /* __OpenBSD__ */
                    139:        if (sc->sc_ih == NULL) {
                    140:                printf("can't establish interrupt");
                    141:                if (intrstr != NULL)
                    142:                        printf(" at %s", intrstr);
                    143:                printf("\n");
                    144:                return;
                    145:        }
                    146:
                    147:        /* Read the EATA configuration */
                    148:        if (dpt_readcfg(sc)) {
                    149:                printf("%s: readcfg failed - see dpt(4)\n",
                    150:                    sc->sc_dv.dv_xname);
                    151:                return;
                    152:        }
                    153:
                    154:        /* Now attach to the bus-independant code */
                    155:        dpt_init(sc, intrstr);
                    156: }

CVSweb