1 /* $NetBSD: aic_isapnp.c,v 1.20 2009/09/22 12:56:06 tsutsui Exp $ */
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Enami Tsugutomo <enami@but-b.or.jp>
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: aic_isapnp.c,v 1.20 2009/09/22 12:56:06 tsutsui Exp $");
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/device.h>
41 #include <dev/isa/isavar.h>
43 #include <dev/isapnp/isapnpreg.h>
44 #include <dev/isapnp/isapnpvar.h>
45 #include <dev/isapnp/isapnpdevs.h>
47 #include <dev/scsipi/scsipi_all.h>
48 #include <dev/scsipi/scsipiconf.h>
49 #include <dev/scsipi/scsi_all.h>
51 #include <dev/ic/aic6360var.h>
53 struct aic_isapnp_softc
{
54 struct aic_softc sc_aic
; /* real "com" softc */
56 /* ISAPnP-specific goo. */
57 void *sc_ih
; /* interrupt handler */
60 static int aic_isapnp_match(device_t
, cfdata_t
, void *);
61 static void aic_isapnp_attach(device_t
, device_t
, void *);
63 CFATTACH_DECL_NEW(aic_isapnp
, sizeof(struct aic_isapnp_softc
),
64 aic_isapnp_match
, aic_isapnp_attach
, NULL
, NULL
);
67 aic_isapnp_match(device_t parent
, cfdata_t match
, void *aux
)
71 pri
= isapnp_devmatch(aux
, &isapnp_aic_devinfo
, &variant
);
72 if (pri
&& variant
> 0)
78 aic_isapnp_attach(device_t parent
, device_t self
, void *aux
)
80 struct aic_isapnp_softc
*isc
= device_private(self
);
81 struct aic_softc
*sc
= &isc
->sc_aic
;
82 struct isapnp_attach_args
*ipa
= aux
;
88 if (isapnp_config(ipa
->ipa_iot
, ipa
->ipa_memt
, ipa
)) {
89 aprint_error_dev(self
, "error in region allocation\n");
93 sc
->sc_iot
= ipa
->ipa_iot
;
94 sc
->sc_ioh
= ipa
->ipa_io
[0].h
;
96 if (!aic_find(sc
->sc_iot
, sc
->sc_ioh
)) {
97 aprint_error_dev(self
, "couldn't find device\n");
103 /* Establish the interrupt handler. */
104 isc
->sc_ih
= isa_intr_establish(ipa
->ipa_ic
, ipa
->ipa_irq
[0].num
,
105 ipa
->ipa_irq
[0].type
, IPL_BIO
, aicintr
, sc
);
106 if (isc
->sc_ih
== NULL
)
107 aprint_error_dev(self
, "couldn't establish interrupt\n");