1 /* $NetBSD: iha_pci.c,v 1.15 2008/04/12 08:21:19 tsutsui Exp $ */
4 * Copyright (c) 2001 Izumi Tsutsui. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Device driver for the INI-9XXXU/UW or INIC-940/950 PCI SCSI Controller.
30 * Written for 386bsd and FreeBSD by
31 * Winston Hung <winstonh@initio.com>
33 * Copyright (c) 1997-1999 Initio Corp.
34 * Copyright (c) 2000 Ken Westerback
35 * All rights reserved.
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer,
42 * without modification, immediately at the beginning of the file.
43 * 2. The name of the author may not be used to endorse or promote products
44 * derived from this software without specific prior written permission.
46 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
47 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
48 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
49 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
50 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
51 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
52 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
54 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
55 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
56 * THE POSSIBILITY OF SUCH DAMAGE.
60 * Ported to NetBSD by Izumi Tsutsui <tsutsui@NetBSD.org> from OpenBSD:
61 * $OpenBSD: iha_pci.c,v 1.2 2001/03/29 23:53:38 krw Exp $
64 #include <sys/cdefs.h>
65 __KERNEL_RCSID(0, "$NetBSD: iha_pci.c,v 1.15 2008/04/12 08:21:19 tsutsui Exp $");
67 #include <sys/param.h>
68 #include <sys/systm.h>
69 #include <sys/device.h>
71 #include <uvm/uvm_extern.h>
73 #include <dev/pci/pcidevs.h>
74 #include <dev/pci/pcivar.h>
76 #include <dev/scsipi/scsipi_all.h>
77 #include <dev/scsipi/scsi_all.h>
78 #include <dev/scsipi/scsiconf.h>
80 #include <dev/ic/ihavar.h>
82 static int iha_pci_match(device_t
, cfdata_t
, void *);
83 static void iha_pci_attach(device_t
, device_t
, void *);
85 CFATTACH_DECL_NEW(iha_pci
, sizeof(struct iha_softc
),
86 iha_pci_match
, iha_pci_attach
, NULL
, NULL
);
89 iha_pci_match(device_t parent
, cfdata_t cf
, void *aux
)
91 struct pci_attach_args
*pa
= aux
;
93 if (PCI_VENDOR(pa
->pa_id
) != PCI_VENDOR_INITIO
)
96 switch (PCI_PRODUCT(pa
->pa_id
)) {
97 case PCI_PRODUCT_INITIO_I940
:
98 case PCI_PRODUCT_INITIO_I950
:
106 iha_pci_attach(device_t parent
, device_t self
, void *aux
)
108 struct iha_softc
*sc
= device_private(self
);
109 struct pci_attach_args
*pa
= aux
;
111 bus_space_handle_t ioh
;
112 pci_intr_handle_t ih
;
120 pci_devinfo(pa
->pa_id
, pa
->pa_class
, 0, devinfo
, sizeof(devinfo
));
121 aprint_normal(": %s (rev. 0x%02x)\n",
122 devinfo
, PCI_REVISION(pa
->pa_class
));
124 command
= pci_conf_read(pa
->pa_pc
,pa
->pa_tag
,PCI_COMMAND_STATUS_REG
);
125 command
|= PCI_COMMAND_MASTER_ENABLE
| PCI_COMMAND_PARITY_ENABLE
;
127 pci_conf_write(pa
->pa_pc
, pa
->pa_tag
, PCI_COMMAND_STATUS_REG
, command
);
130 * XXX - Tried memory mapping (using code from adw and ahc)
131 * rather that IO mapping, but it didn't work at all..
133 ioh_valid
= pci_mapreg_map(pa
, PCI_MAPREG_START
, PCI_MAPREG_TYPE_IO
, 0,
134 &iot
, &ioh
, NULL
, NULL
);
136 if (ioh_valid
!= 0) {
137 aprint_error_dev(self
, "unable to map registers\n");
143 sc
->sc_dmat
= pa
->pa_dmat
;
145 if (pci_intr_map(pa
, &ih
)) {
146 aprint_error_dev(self
, "couldn't map interrupt\n");
149 intrstr
= pci_intr_string(pa
->pa_pc
, ih
);
151 sc
->sc_ih
= pci_intr_establish(pa
->pa_pc
, ih
, IPL_BIO
, iha_intr
, sc
);
153 if (sc
->sc_ih
== NULL
) {
154 aprint_error_dev(self
, "couldn't establish interrupt");
156 aprint_error(" at %s", intrstr
);
160 aprint_normal_dev(self
, "interrupting at %s\n", intrstr
);