aic_isapnp.c revision 1.5 1 1.5 mycroft /* $NetBSD: aic_isapnp.c,v 1.5 1999/03/22 10:00:10 mycroft Exp $ */
2 1.1 enami
3 1.1 enami /*-
4 1.1 enami * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 1.1 enami * All rights reserved.
6 1.1 enami *
7 1.1 enami * This code is derived from software contributed to The NetBSD Foundation
8 1.1 enami * by Enami Tsugutomo <enami (at) but-b.or.jp>
9 1.1 enami *
10 1.1 enami * Redistribution and use in source and binary forms, with or without
11 1.1 enami * modification, are permitted provided that the following conditions
12 1.1 enami * are met:
13 1.1 enami * 1. Redistributions of source code must retain the above copyright
14 1.1 enami * notice, this list of conditions and the following disclaimer.
15 1.1 enami * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 enami * notice, this list of conditions and the following disclaimer in the
17 1.1 enami * documentation and/or other materials provided with the distribution.
18 1.1 enami * 3. All advertising materials mentioning features or use of this software
19 1.1 enami * must display the following acknowledgement:
20 1.1 enami * This product includes software developed by the NetBSD
21 1.1 enami * Foundation, Inc. and its contributors.
22 1.1 enami * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 enami * contributors may be used to endorse or promote products derived
24 1.1 enami * from this software without specific prior written permission.
25 1.1 enami *
26 1.1 enami * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 enami * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 enami * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 enami * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 enami * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 enami * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 enami * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 enami * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 enami * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 enami * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 enami * POSSIBILITY OF SUCH DAMAGE.
37 1.1 enami */
38 1.1 enami
39 1.1 enami #include <sys/param.h>
40 1.1 enami #include <sys/systm.h>
41 1.1 enami #include <sys/device.h>
42 1.1 enami
43 1.1 enami #include <machine/bus.h>
44 1.1 enami
45 1.1 enami #include <dev/isa/isavar.h>
46 1.1 enami
47 1.1 enami #include <dev/isapnp/isapnpreg.h>
48 1.1 enami #include <dev/isapnp/isapnpvar.h>
49 1.3 christos #include <dev/isapnp/isapnpdevs.h>
50 1.1 enami
51 1.1 enami #include <dev/scsipi/scsipi_all.h>
52 1.1 enami #include <dev/scsipi/scsipiconf.h>
53 1.1 enami #include <dev/scsipi/scsi_all.h>
54 1.1 enami
55 1.1 enami #include <dev/ic/aic6360var.h>
56 1.1 enami
57 1.1 enami struct aic_isapnp_softc {
58 1.1 enami struct aic_softc sc_aic; /* real "com" softc */
59 1.1 enami
60 1.1 enami /* ISAPnP-specific goo. */
61 1.1 enami void *sc_ih; /* interrupt handler */
62 1.1 enami };
63 1.1 enami
64 1.1 enami int aic_isapnp_match __P((struct device *, struct cfdata *, void *));
65 1.1 enami void aic_isapnp_attach __P((struct device *, struct device *, void *));
66 1.1 enami
67 1.1 enami struct cfattach aic_isapnp_ca = {
68 1.1 enami sizeof(struct aic_isapnp_softc), aic_isapnp_match, aic_isapnp_attach
69 1.1 enami };
70 1.1 enami
71 1.1 enami int
72 1.1 enami aic_isapnp_match(parent, match, aux)
73 1.1 enami struct device *parent;
74 1.1 enami struct cfdata *match;
75 1.1 enami void *aux;
76 1.1 enami {
77 1.5 mycroft int pri, variant;
78 1.4 mycroft
79 1.5 mycroft pri = isapnp_devmatch(aux, &isapnp_aic_devinfo, &variant);
80 1.5 mycroft if (pri && variant > 0)
81 1.5 mycroft pri = 0;
82 1.5 mycroft return (pri);
83 1.1 enami }
84 1.1 enami
85 1.1 enami void
86 1.1 enami aic_isapnp_attach(parent, self, aux)
87 1.1 enami struct device *parent, *self;
88 1.1 enami void *aux;
89 1.1 enami {
90 1.1 enami struct aic_isapnp_softc *isc = (void *)self;
91 1.1 enami struct aic_softc *sc = &isc->sc_aic;
92 1.1 enami struct isapnp_attach_args *ipa = aux;
93 1.1 enami
94 1.1 enami printf("\n");
95 1.1 enami
96 1.1 enami if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
97 1.1 enami printf("%s: error in region allocation\n",
98 1.1 enami sc->sc_dev.dv_xname);
99 1.1 enami return;
100 1.1 enami }
101 1.1 enami
102 1.1 enami sc->sc_iot = ipa->ipa_iot;
103 1.1 enami sc->sc_ioh = ipa->ipa_io[0].h;
104 1.1 enami
105 1.1 enami if (!aic_find(sc->sc_iot, sc->sc_ioh)) {
106 1.1 enami printf("%s: couldn't find device\n", sc->sc_dev.dv_xname);
107 1.1 enami return;
108 1.1 enami }
109 1.1 enami
110 1.1 enami aicattach(sc);
111 1.1 enami
112 1.1 enami /* Establish the interrupt handler. */
113 1.1 enami isc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
114 1.1 enami ipa->ipa_irq[0].type, IPL_BIO, aicintr, sc);
115 1.1 enami if (isc->sc_ih == NULL)
116 1.1 enami printf("%s: couldn't establish interrupt\n",
117 1.1 enami sc->sc_dev.dv_xname);
118 1.1 enami }
119