The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/stg/tmc18c30_pci.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  *      Copyright (c) 2003 Bob Bishop
    3  *      All rights reserved.
    4  * [Ported for FreeBSD]
    5  *  Copyright (c) 2000
    6  *      Noriaki Mitsunaga, Mitsuru Iwasaki and Takanori Watanabe.
    7  *      All rights reserved.
    8  * [NetBSD for NEC PC-98 series]
    9  *  Copyright (c) 1996, 1997, 1998
   10  *      NetBSD/pc98 porting staff. All rights reserved.
   11  *  Copyright (c) 1996, 1997, 1998
   12  *      Naofumi HONDA. All rights reserved.
   13  *  Copyright (c) 1996, 1997, 1998
   14  *      Kouichi Matsuda. All rights reserved.
   15  * 
   16  *  Redistribution and use in source and binary forms, with or without
   17  *  modification, are permitted provided that the following conditions
   18  *  are met:
   19  *  1. Redistributions of source code must retain the above copyright
   20  *     notice, this list of conditions and the following disclaimer.
   21  *  2. Redistributions in binary form must reproduce the above copyright
   22  *     notice, this list of conditions and the following disclaimer in the
   23  *     documentation and/or other materials provided with the distribution.
   24  *  3. The name of the author may not be used to endorse or promote products
   25  *     derived from this software without specific prior written permission.
   26  * 
   27  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   28  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   29  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   30  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
   31  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   32  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   33  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   35  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   36  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   37  * POSSIBILITY OF SUCH DAMAGE.
   38  */
   39 
   40 #include <sys/cdefs.h>
   41 __FBSDID("$FreeBSD$");
   42 
   43 #include <sys/param.h>
   44 #include <sys/systm.h>
   45 #include <sys/kernel.h>
   46 #include <sys/module.h>
   47 #include <sys/bus.h>
   48 #include <sys/malloc.h>
   49 #include <sys/errno.h>
   50 
   51 #include <machine/bus.h>
   52 #include <machine/resource.h>
   53 #include <sys/rman.h>
   54 
   55 #include <dev/pci/pcireg.h>
   56 #include <dev/pci/pcivar.h>
   57 
   58 #include <cam/scsi/scsi_low.h>
   59 #include <cam/scsi/scsi_low_pisa.h>
   60 
   61 #include <dev/stg/tmc18c30reg.h>
   62 #include <dev/stg/tmc18c30var.h>
   63 #include <dev/stg/tmc18c30.h>
   64 
   65 static struct _pcsid
   66 {
   67         u_int32_t       type;
   68         const char      *desc;
   69 } pci_ids[] = {
   70         { 0x00001036,   "Adaptec AHA-2920/A,Future Domain TMC-18XX/3260"        },
   71         { 0x00000000,   NULL                                                    }
   72 };
   73 
   74 static int
   75 stg_pci_probe(device_t dev)
   76 {
   77         u_int32_t type = pci_get_devid(dev);
   78         struct _pcsid *stg = pci_ids;
   79 
   80         while (stg->type && stg->type != type)
   81                 ++stg;
   82         if (stg->desc) {
   83                 device_set_desc(dev, stg->desc);
   84                 return (BUS_PROBE_DEFAULT);
   85         }
   86         return (ENXIO);
   87 }
   88 
   89 static int
   90 stg_pci_attach(device_t dev)
   91 {
   92         struct stg_softc        *sc = device_get_softc(dev);
   93         int                     error;
   94 
   95         sc->port_rid = PCIR_BAR(0);
   96         sc->irq_rid = 0;
   97         error = stg_alloc_resource(dev);
   98         if (error) {
   99                 return(error);
  100         }
  101 
  102         /* XXXX remove INTR_ENTROPY below for MFC */
  103         error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_CAM | INTR_ENTROPY,
  104                                NULL, stg_intr, (void *)sc, &sc->stg_intrhand);
  105         if (error) {
  106                 stg_release_resource(dev);
  107                 return(error);
  108         }
  109 
  110         if (stg_attach(dev) == 0) {
  111                 stg_release_resource(dev);
  112                 return(ENXIO);
  113         }
  114 
  115         return(0);
  116 }
  117 
  118 static device_method_t stg_pci_methods[] = {
  119         /* Device interface */
  120         DEVMETHOD(device_probe,         stg_pci_probe),
  121         DEVMETHOD(device_attach,        stg_pci_attach),
  122         DEVMETHOD(device_detach,        stg_detach),
  123 
  124         { 0, 0 }
  125 };
  126 
  127 static driver_t stg_pci_driver = {
  128         "stg",
  129         stg_pci_methods,
  130         sizeof(struct stg_softc),
  131 };
  132 
  133 DRIVER_MODULE(stg, pci, stg_pci_driver, stg_devclass, 0, 0);
  134 MODULE_DEPEND(stg, scsi_low, 1, 1, 1);
  135 MODULE_DEPEND(stg, pci, 1, 1, 1);

Cache object: c8742ba53223b805118ee12eadf3a119


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.