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

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

1.1       nbrk        1: /*     $OpenBSD: adv_pci.c,v 1.9 2007/04/10 17:47:55 miod Exp $        */
                      2: /*     $NetBSD: adv_pci.c,v 1.5 1998/09/26 15:52:55 dante Exp $        */
                      3:
                      4: /*
                      5:  * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved.
                      6:  *
                      7:  * Author: Baldassare Dante Profeta <dante@mclink.it>
                      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. All advertising materials mentioning features or use of this software
                     18:  *    must display the following acknowledgement:
                     19:  *        This product includes software developed by the NetBSD
                     20:  *        Foundation, Inc. and its contributors.
                     21:  * 4. Neither the name of The NetBSD Foundation nor the names of its
                     22:  *    contributors may be used to endorse or promote products derived
                     23:  *    from this software without specific prior written permission.
                     24:  *
                     25:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     26:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     27:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     28:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     29:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     30:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     31:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     32:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     33:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     34:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     35:  * POSSIBILITY OF SUCH DAMAGE.
                     36:  */
                     37: /*
                     38:  * Device probe and attach routines for the following
                     39:  * Advanced Systems Inc. SCSI controllers:
                     40:  *
                     41:  *    Connectivity Products:
                     42:  *      ABP920 - Bus-Master PCI (16 CDB)
                     43:  *      ABP930 - Bus-Master PCI (16 CDB)               (Footnote 1)
                     44:  *      ABP930U - Bus-Master PCI Ultra (16 CDB)
                     45:  *      ABP930UA - Bus-Master PCI Ultra (16 CDB)
                     46:  *      ABP960 - Bus-Master PCI MAC/PC (16 CDB)                (Footnote 2)
                     47:  *      ABP960U - Bus-Master PCI MAC/PC Ultra (16 CDB) (Footnote 2)
                     48:  *
                     49:  *   Single Channel Products:
                     50:  *      ABP940 - Bus-Master PCI (240 CDB)
                     51:  *      ABP940U - Bus-Master PCI Ultra (240 CDB)
                     52:  *      ABP970 - Bus-Master PCI MAC/PC (240 CDB)
                     53:  *      ABP970U - Bus-Master PCI MAC/PC Ultra (240 CDB)
                     54:  *
                     55:  *   Multi Channel Products:
                     56:  *      ABP950 - Dual Channel Bus-Master PCI (240 CDB Per Channel)
                     57:  *      ABP980 - Four Channel Bus-Master PCI (240 CDB Per Channel)
                     58:  *      ABP980U - Four Channel Bus-Master PCI Ultra (240 CDB Per Channel)
                     59:  *
                     60:  *   Footnotes:
                     61:  *     1. This board has been sold by SIIG as the Fast SCSI Pro PCI.
                     62:  *     2. This board has been sold by Iomega as a Jaz Jet PCI adapter.
                     63:  */
                     64:
                     65: #include <sys/types.h>
                     66: #include <sys/param.h>
                     67: #include <sys/systm.h>
                     68: #include <sys/malloc.h>
                     69: #include <sys/kernel.h>
                     70: #include <sys/queue.h>
                     71: #include <sys/device.h>
                     72:
                     73: #include <machine/bus.h>
                     74: #include <machine/intr.h>
                     75:
                     76: #include <scsi/scsi_all.h>
                     77: #include <scsi/scsiconf.h>
                     78:
                     79: #include <dev/pci/pcireg.h>
                     80: #include <dev/pci/pcivar.h>
                     81: #include <dev/pci/pcidevs.h>
                     82:
                     83: #include <dev/ic/adv.h>
                     84: #include <dev/ic/advlib.h>
                     85:
                     86: /******************************************************************************/
                     87:
                     88: #define PCI_CBIO        0x10
                     89:
                     90: /******************************************************************************/
                     91:
                     92: int    adv_pci_match(struct device *, void *, void *);
                     93: void   adv_pci_attach(struct device *, struct device *, void *);
                     94:
                     95: struct cfattach adv_pci_ca =
                     96: {
                     97:        sizeof(ASC_SOFTC), adv_pci_match, adv_pci_attach
                     98: };
                     99:
                    100: const struct pci_matchid adv_pci_devices[] = {
                    101:        { PCI_VENDOR_ADVSYS, PCI_PRODUCT_ADVSYS_1200A },
                    102:        { PCI_VENDOR_ADVSYS, PCI_PRODUCT_ADVSYS_1200B },
                    103:        { PCI_VENDOR_ADVSYS, PCI_PRODUCT_ADVSYS_ULTRA },
                    104: };
                    105:
                    106: /******************************************************************************/
                    107: /*
                    108:  * Check the slots looking for a board we recognise
                    109:  * If we find one, note its address (slot) and call
                    110:  * the actual probe routine to check it out.
                    111:  */
                    112: int
                    113: adv_pci_match(parent, match, aux)
                    114:        struct device *parent;
                    115:        void *match, *aux;
                    116: {
                    117:        return (pci_matchbyid((struct pci_attach_args *)aux, adv_pci_devices,
                    118:            sizeof(adv_pci_devices)/sizeof(adv_pci_devices[0])));
                    119: }
                    120:
                    121:
                    122: void
                    123: adv_pci_attach(parent, self, aux)
                    124:        struct device *parent, *self;
                    125:        void *aux;
                    126: {
                    127:        struct pci_attach_args *pa = aux;
                    128:        ASC_SOFTC      *sc = (void *) self;
                    129:        bus_space_handle_t ioh;
                    130:        bus_size_t advsize;
                    131:        pci_intr_handle_t ih;
                    132:        pci_chipset_tag_t pc = pa->pa_pc;
                    133:        const char     *intrstr;
                    134:        int retval;
                    135:
                    136:        sc->sc_flags = 0x0;
                    137:
                    138:        /*
                    139:         * Latency timer settings.
                    140:         */
                    141:        {
                    142:                u_int32_t       bhlcr;
                    143:
                    144:                bhlcr = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG);
                    145:
                    146:                if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_ADVSYS_1200A ||
                    147:                    PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_ADVSYS_1200B) {
                    148:                        bhlcr &= 0xFFFF00FFul;
                    149:                        pci_conf_write(pa->pa_pc, pa->pa_tag,
                    150:                                        PCI_BHLC_REG, bhlcr);
                    151:                } else if ((PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_ADVSYS_ULTRA) &&
                    152:                           (PCI_LATTIMER(bhlcr) < 0x20)) {
                    153:                        bhlcr &= 0xFFFF00FFul;
                    154:                        bhlcr |= 0x00002000ul;
                    155:                        pci_conf_write(pa->pa_pc, pa->pa_tag,
                    156:                                        PCI_BHLC_REG, bhlcr);
                    157:                }
                    158:        }
                    159:
                    160:
                    161:        /*
                    162:         * Map Device Registers for I/O
                    163:         */
                    164:        retval = pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0,
                    165:            &sc->sc_iot, &ioh, NULL, &advsize, 0);
                    166:        if (retval) {
                    167:                printf(": unable to map device registers\n");
                    168:                return;
                    169:        }
                    170:        sc->sc_ioh = ioh;
                    171:        sc->sc_dmat = pa->pa_dmat;
                    172:        sc->pci_device_id = pa->pa_id;
                    173:        sc->bus_type = ASC_IS_PCI;
                    174:
                    175:        /*
                    176:         * Initialize the board
                    177:         */
                    178:        if (adv_init(sc)) {
                    179:                printf(": adv_init failed\n");
                    180:                bus_space_unmap(sc->sc_iot, ioh, advsize);
                    181:                return;
                    182:        }
                    183:
                    184:        /*
                    185:         * Map Interrupt line
                    186:         */
                    187:        if (pci_intr_map(pa, &ih)) {
                    188:                printf(": couldn't map interrupt\n");
                    189:                bus_space_unmap(sc->sc_iot, ioh, advsize);
                    190:                return;
                    191:        }
                    192:        intrstr = pci_intr_string(pc, ih);
                    193:
                    194:        /*
                    195:         * Establish Interrupt handler
                    196:         */
                    197:        sc->sc_ih = pci_intr_establish(pc, ih, IPL_BIO, adv_intr, sc,
                    198:                                       sc->sc_dev.dv_xname);
                    199:        if (sc->sc_ih == NULL) {
                    200:                printf(": couldn't establish interrupt");
                    201:                if (intrstr != NULL)
                    202:                        printf(" at %s", intrstr);
                    203:                printf("\n");
                    204:                bus_space_unmap(sc->sc_iot, ioh, advsize);
                    205:                return;
                    206:        }
                    207:        printf(": %s\n", intrstr);
                    208:
                    209:        /*
                    210:         * Attach all the sub-devices we can find
                    211:         */
                    212:        adv_attach(sc);
                    213: }
                    214: /******************************************************************************/

CVSweb