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: releng/11.2/sys/dev/stg/tmc18c30_pci.c 331722 2018-03-29 02:50:57Z eadler $");
   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 
   60 #include <dev/stg/tmc18c30reg.h>
   61 #include <dev/stg/tmc18c30var.h>
   62 #include <dev/stg/tmc18c30.h>
   63 
   64 static struct _pcsid
   65 {
   66         u_int32_t       type;
   67         const char      *desc;
   68 } pci_ids[] = {
   69         { 0x00001036,   "Adaptec AHA-2920/A,Future Domain TMC-18XX/3260"        },
   70         { 0x00000000,   NULL                                                    }
   71 };
   72 
   73 static int
   74 stg_pci_probe(device_t dev)
   75 {
   76         u_int32_t type = pci_get_devid(dev);
   77         struct _pcsid *stg = pci_ids;
   78 
   79         while (stg->type && stg->type != type)
   80                 ++stg;
   81         if (stg->desc) {
   82                 device_set_desc(dev, stg->desc);
   83                 return (BUS_PROBE_DEFAULT);
   84         }
   85         return (ENXIO);
   86 }
   87 
   88 static int
   89 stg_pci_attach(device_t dev)
   90 {
   91         struct stg_softc        *sc = device_get_softc(dev);
   92         int                     error;
   93 
   94         sc->port_rid = PCIR_BAR(0);
   95         sc->irq_rid = 0;
   96         error = stg_alloc_resource(dev);
   97         if (error) {
   98                 return(error);
   99         }
  100 
  101         /* XXXX remove INTR_ENTROPY below for MFC */
  102         error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_CAM | INTR_ENTROPY |
  103             INTR_MPSAFE, NULL, stg_intr, sc, &sc->stg_intrhand);
  104         if (error) {
  105                 stg_release_resource(dev);
  106                 return(error);
  107         }
  108 
  109         if (stg_attach(dev) == 0) {
  110                 stg_release_resource(dev);
  111                 return(ENXIO);
  112         }
  113 
  114         return(0);
  115 }
  116 
  117 static device_method_t stg_pci_methods[] = {
  118         /* Device interface */
  119         DEVMETHOD(device_probe,         stg_pci_probe),
  120         DEVMETHOD(device_attach,        stg_pci_attach),
  121         DEVMETHOD(device_detach,        stg_detach),
  122 
  123         { 0, 0 }
  124 };
  125 
  126 static driver_t stg_pci_driver = {
  127         "stg",
  128         stg_pci_methods,
  129         sizeof(struct stg_softc),
  130 };
  131 
  132 DRIVER_MODULE(stg, pci, stg_pci_driver, stg_devclass, 0, 0);
  133 MODULE_DEPEND(stg, scsi_low, 1, 1, 1);
  134 MODULE_DEPEND(stg, pci, 1, 1, 1);

Cache object: 739a4b2d7f1549eb25bf1eebb5e48d7b


[ 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.