2 * SPDX-License-Identifier: BSD-4-Clause
4 * Copyright (c) 2013 Justin Hibbits
6 * Copyright (c) 1997, 1998, 1999
7 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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.
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.
38 * Lucent WaveLAN/IEEE 802.11 MacIO attachment for FreeBSD.
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
46 #include <sys/cdefs.h>
47 __FBSDID("$FreeBSD$");
49 #include <sys/param.h>
50 #include <sys/kernel.h>
51 #include <sys/socket.h>
52 #include <sys/systm.h>
54 #include <sys/module.h>
57 #include <machine/bus.h>
58 #include <machine/resource.h>
61 #include <dev/ofw/ofw_bus.h>
62 #include <dev/ofw/openfirm.h>
63 #include <machine/ofw_machdep.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>
72 #include <net80211/ieee80211_var.h>
73 #include <net80211/ieee80211_radiotap.h>
75 #include <dev/wi/if_wavelan_ieee.h>
76 #include <dev/wi/if_wireg.h>
77 #include <dev/wi/if_wivar.h>
79 #include <powerpc/powermac/maciovar.h>
81 static int wi_macio_probe(device_t);
82 static int wi_macio_attach(device_t);
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),
94 static driver_t wi_macio_driver = {
97 sizeof(struct wi_softc)
100 DRIVER_MODULE(wi, macio, wi_macio_driver, wi_devclass, 0, 0);
101 MODULE_DEPEND(wi, wlan, 1, 1, 1);
104 wi_macio_probe(device_t dev)
106 const char *name, *compat;
108 /* Make sure we're a network driver */
109 name = ofw_bus_get_name(dev);
113 if (strcmp(name, "radio") != 0) {
116 compat = ofw_bus_get_compat(dev);
117 if (strcmp(compat, "wireless") != 0) {
121 device_set_desc(dev, "Apple Airport");
126 wi_macio_attach(device_t dev)
131 sc = device_get_softc(dev);
135 error = wi_alloc(dev, 0);
137 macio_enable_wireless(device_get_parent(dev), 1);
138 /* Make sure interrupts are disabled. */
139 CSR_WRITE_2(sc, WI_INT_EN, 0);
140 CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
142 error = wi_attach(dev);