2 * Copyright (c) 2003 Bob Bishop
6 * Noriaki Mitsunaga, Mitsuru Iwasaki and Takanori Watanabe.
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.
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
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.
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.
40 #include <sys/cdefs.h>
41 __FBSDID("$FreeBSD$");
43 #include <sys/param.h>
44 #include <sys/systm.h>
45 #include <sys/kernel.h>
46 #include <sys/module.h>
48 #include <sys/malloc.h>
49 #include <sys/errno.h>
51 #include <machine/bus.h>
52 #include <machine/resource.h>
55 #include <dev/pci/pcireg.h>
56 #include <dev/pci/pcivar.h>
58 #include <cam/scsi/scsi_low.h>
59 #include <cam/scsi/scsi_low_pisa.h>
61 #include <dev/stg/tmc18c30reg.h>
62 #include <dev/stg/tmc18c30var.h>
63 #include <dev/stg/tmc18c30.h>
70 { 0x00001036, "Adaptec AHA-2920/A,Future Domain TMC-18XX/3260" },
75 stg_pci_probe(device_t dev)
77 u_int32_t type = pci_get_devid(dev);
78 struct _pcsid *stg = pci_ids;
80 while (stg->type && stg->type != type)
83 device_set_desc(dev, stg->desc);
84 return (BUS_PROBE_DEFAULT);
90 stg_pci_attach(device_t dev)
92 struct stg_softc *sc = device_get_softc(dev);
95 sc->port_rid = PCIR_BAR(0);
97 error = stg_alloc_resource(dev);
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);
106 stg_release_resource(dev);
110 if (stg_attach(dev) == 0) {
111 stg_release_resource(dev);
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),
127 static driver_t stg_pci_driver = {
130 sizeof(struct stg_softc),
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);