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