1 /*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 2013 Justin Hibbits
5 * All rights reserved.
6 * Copyright (c) 1997, 1998, 1999
7 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by Bill Paul.
20 * 4. Neither the name of the author nor the names of any co-contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34 * THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 /*
38 * Lucent WaveLAN/IEEE 802.11 MacIO attachment for FreeBSD.
39 *
40 * Based on the PCMCIA driver
41 * Written by Bill Paul <wpaul@ctr.columbia.edu>
42 * Electrical Engineering Department
43 * Columbia University, New York City
44 */
45
46 #include <sys/cdefs.h>
47 __FBSDID("$FreeBSD$");
48
49 #include <sys/param.h>
50 #include <sys/kernel.h>
51 #include <sys/socket.h>
52 #include <sys/systm.h>
53 #include <sys/mbuf.h>
54 #include <sys/module.h>
55 #include <sys/bus.h>
56
57 #include <machine/bus.h>
58 #include <machine/resource.h>
59 #include <sys/rman.h>
60
61 #include <dev/ofw/ofw_bus.h>
62 #include <dev/ofw/openfirm.h>
63 #include <machine/ofw_machdep.h>
64
65 #include <net/if.h>
66 #include <net/if_arp.h>
67 #include <net/ethernet.h>
68 #include <net/if_dl.h>
69 #include <net/if_media.h>
70 #include <net/if_types.h>
71
72 #include <net80211/ieee80211_var.h>
73 #include <net80211/ieee80211_radiotap.h>
74
75 #include <dev/wi/if_wavelan_ieee.h>
76 #include <dev/wi/if_wireg.h>
77 #include <dev/wi/if_wivar.h>
78
79 #include <powerpc/powermac/maciovar.h>
80
81 static int wi_macio_probe(device_t);
82 static int wi_macio_attach(device_t);
83
84 static device_method_t wi_macio_methods[] = {
85 /* Device interface */
86 DEVMETHOD(device_probe, wi_macio_probe),
87 DEVMETHOD(device_attach, wi_macio_attach),
88 DEVMETHOD(device_detach, wi_detach),
89 DEVMETHOD(device_shutdown, wi_shutdown),
90 { 0, 0 }
91 };
92
93 static driver_t wi_macio_driver = {
94 "wi",
95 wi_macio_methods,
96 sizeof(struct wi_softc)
97 };
98
99 DRIVER_MODULE(wi, macio, wi_macio_driver, wi_devclass, 0, 0);
100 MODULE_DEPEND(wi, wlan, 1, 1, 1);
101
102 static int
103 wi_macio_probe(device_t dev)
104 {
105 const char *name, *compat;
106
107 /* Make sure we're a network driver */
108 name = ofw_bus_get_name(dev);
109 if (name == NULL)
110 return (ENXIO);
111
112 if (strcmp(name, "radio") != 0) {
113 return ENXIO;
114 }
115 compat = ofw_bus_get_compat(dev);
116 if (strcmp(compat, "wireless") != 0) {
117 return ENXIO;
118 }
119
120 device_set_desc(dev, "Apple Airport");
121 return 0;
122 }
123
124 static int
125 wi_macio_attach(device_t dev)
126 {
127 struct wi_softc *sc;
128 int error;
129
130 sc = device_get_softc(dev);
131 sc->wi_gone = 0;
132 sc->wi_bus_type = 0;
133
134 error = wi_alloc(dev, 0);
135 if (error == 0) {
136 macio_enable_wireless(device_get_parent(dev), 1);
137 /* Make sure interrupts are disabled. */
138 CSR_WRITE_2(sc, WI_INT_EN, 0);
139 CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
140
141 error = wi_attach(dev);
142 if (error != 0)
143 wi_free(dev);
144 else
145 gone_in_dev(dev, 13, "pccard removed, wi doesn't support modern crypto");
146 }
147 return error;
148 }
Cache object: 503e03f710c0b890cd343a15235c5abe
|