if_an_isapnp.c revision 1.15.8.1 1 /* $NetBSD: if_an_isapnp.c,v 1.15.8.1 2007/10/23 20:08:24 ad Exp $ */
2
3 /*-
4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
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.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * ISAPnP bus front-end for the Aironet ISA4500/ISA4800 Wireless LAN Adapter.
41 * Unlike WaveLAN, this adapter is attached as an ISA device using an address
42 * decoder hack.
43 */
44
45 #include <sys/cdefs.h>
46 __KERNEL_RCSID(0, "$NetBSD: if_an_isapnp.c,v 1.15.8.1 2007/10/23 20:08:24 ad Exp $");
47
48 #include <sys/param.h>
49 #include <sys/systm.h>
50 #include <sys/mbuf.h>
51 #include <sys/malloc.h>
52 #include <sys/kernel.h>
53 #include <sys/socket.h>
54 #include <sys/ioctl.h>
55 #include <sys/errno.h>
56 #include <sys/device.h>
57 #include <sys/callout.h>
58
59 #include <net/if.h>
60 #include <net/if_dl.h>
61 #include <net/if_media.h>
62 #include <net/if_ether.h>
63
64 #include <net80211/ieee80211_netbsd.h>
65 #include <net80211/ieee80211_var.h>
66
67 #include <sys/bus.h>
68 #include <sys/intr.h>
69
70 #include <dev/ic/anreg.h>
71 #include <dev/ic/anvar.h>
72
73 #include <dev/isa/isavar.h>
74
75 #include <dev/isapnp/isapnpreg.h>
76 #include <dev/isapnp/isapnpvar.h>
77 #include <dev/isapnp/isapnpdevs.h>
78
79 int an_isapnp_match(struct device *, struct cfdata *, void *);
80 void an_isapnp_attach(struct device *, struct device *, void *);
81
82 struct an_isapnp_softc {
83 struct an_softc sc_an; /* real "an" softc */
84
85 /* ISA-specific goo. */
86 void *sc_ih; /* interrupt cookie */
87 };
88
89 CFATTACH_DECL(an_isapnp, sizeof(struct an_isapnp_softc),
90 an_isapnp_match, an_isapnp_attach, NULL, NULL);
91
92 int
93 an_isapnp_match(struct device *parent, struct cfdata *match,
94 void *aux)
95 {
96 int pri, variant;
97
98 pri = isapnp_devmatch(aux, &isapnp_an_devinfo, &variant);
99 if (pri && variant > 0)
100 pri = 0;
101 return (pri);
102 }
103
104 void
105 an_isapnp_attach(struct device *parent, struct device *self, void *aux)
106 {
107 struct an_isapnp_softc *isc = device_private(self);
108 struct an_softc *sc = &isc->sc_an;
109 struct isapnp_attach_args *ipa = aux;
110
111 printf("\n");
112
113 if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
114 printf("%s: can't configure isapnp resources\n",
115 sc->sc_dev.dv_xname);
116 return;
117 }
118
119 sc->sc_iot = ipa->ipa_iot;
120 sc->sc_ioh = ipa->ipa_io[0].h;
121
122 printf("%s: %s %s\n", sc->sc_dev.dv_xname, ipa->ipa_devident,
123 ipa->ipa_devclass);
124
125 /* This interface is always enabled. */
126 sc->sc_enabled = 1;
127
128 /* Establish the interrupt handler. */
129 isc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
130 ipa->ipa_irq[0].type, IPL_NET, an_intr, sc);
131 if (isc->sc_ih == NULL) {
132 printf("%s: couldn't establish interrupt handler\n",
133 sc->sc_dev.dv_xname);
134 return;
135 }
136
137 if (an_attach(sc) != 0) {
138 printf("%s: failed to attach controller\n",
139 sc->sc_dev.dv_xname);
140 isa_intr_disestablish(ipa->ipa_ic, isc->sc_ih);
141 isc->sc_ih = NULL;
142 }
143 }
144