Line data Source code
1 : /* $OpenBSD: if_an_pci.c,v 1.19 2015/11/24 17:11:39 mpi Exp $ */
2 :
3 : /*
4 : * Copyright (c) 1997, 1998, 1999
5 : * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
6 : *
7 : * Redistribution and use in source and binary forms, with or without
8 : * modification, are permitted provided that the following conditions
9 : * are met:
10 : * 1. Redistributions of source code must retain the above copyright
11 : * notice, this list of conditions and the following disclaimer.
12 : * 2. Redistributions in binary form must reproduce the above copyright
13 : * notice, this list of conditions and the following disclaimer in the
14 : * documentation and/or other materials provided with the distribution.
15 : * 3. All advertising materials mentioning features or use of this software
16 : * must display the following acknowledgement:
17 : * This product includes software developed by Bill Paul.
18 : * 4. Neither the name of the author nor the names of any co-contributors
19 : * may be used to endorse or promote products derived from this software
20 : * without specific prior written permission.
21 : *
22 : * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
23 : * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 : * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 : * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
26 : * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 : * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 : * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 : * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 : * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 : * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 : * THE POSSIBILITY OF SUCH DAMAGE.
33 : *
34 : * $FreeBSD: src/sys/dev/an/if_an_pci.c,v 1.1 2000/01/14 20:40:56 wpaul Exp $
35 : */
36 :
37 : /*
38 : * This is a PCI shim for the Aironet PC4500/4800 wireless network
39 : * driver. Aironet makes PCMCIA, ISA and PCI versions of these devices,
40 : * which all have basically the same interface. The ISA and PCI cards
41 : * are actually bridge adapters with PCMCIA cards inserted into them,
42 : * however they appear as normal PCI or ISA devices to the host.
43 : *
44 : * All we do here is handle the PCI match and attach and set up an
45 : * interrupt handler entry point. The PCI version of the card uses
46 : * a PLX 9050 PCI to "dumb bus" bridge chip, which provides us with
47 : * multiple PCI address space mappings. The primary mapping at PCI
48 : * register 0x14 is for the PLX chip itself, *NOT* the Aironet card.
49 : * The I/O address of the Aironet is actually at register 0x18, which
50 : * is the local bus mapping register for bus space 0. There are also
51 : * registers for additional register spaces at registers 0x1C and
52 : * 0x20, but these are unused in the Aironet devices. To find out
53 : * more, you need a datasheet for the 9050 from PLX, but you have
54 : * to go through their sales office to get it. Bleh.
55 : */
56 :
57 : #include <sys/param.h>
58 : #include <sys/systm.h>
59 : #include <sys/device.h>
60 : #include <sys/timeout.h>
61 : #include <sys/socket.h>
62 : #include <sys/tree.h>
63 :
64 : #include <net/if.h>
65 : #include <net/if_media.h>
66 :
67 : #include <netinet/in.h>
68 : #include <netinet/if_ether.h>
69 :
70 : #include <net80211/ieee80211_radiotap.h>
71 : #include <net80211/ieee80211_var.h>
72 :
73 : #include <machine/bus.h>
74 : #include <machine/intr.h>
75 :
76 : #include <dev/pci/pcireg.h>
77 : #include <dev/pci/pcivar.h>
78 : #include <dev/pci/pcidevs.h>
79 :
80 : #include <dev/ic/anreg.h>
81 : #include <dev/ic/anvar.h>
82 :
83 : #define AN_PCI_PLX_LOIO 0x14 /* PLX chip iobase */
84 : #define AN_PCI_LOIO 0x18 /* Aironet iobase */
85 :
86 : int an_pci_match(struct device *, void *, void *);
87 : void an_pci_attach(struct device *, struct device *, void *);
88 :
89 : struct cfattach an_pci_ca = {
90 : sizeof (struct an_softc), an_pci_match, an_pci_attach
91 : };
92 :
93 : const struct pci_matchid an_pci_devices[] = {
94 : { PCI_VENDOR_AIRONET, PCI_PRODUCT_AIRONET_PCI352 },
95 : { PCI_VENDOR_AIRONET, PCI_PRODUCT_AIRONET_PC4500 },
96 : { PCI_VENDOR_AIRONET, PCI_PRODUCT_AIRONET_PC4800 },
97 : { PCI_VENDOR_AIRONET, PCI_PRODUCT_AIRONET_PC4800_1 },
98 : };
99 :
100 : int
101 0 : an_pci_match(struct device *parent, void *match, void *aux)
102 : {
103 0 : return (pci_matchbyid((struct pci_attach_args *)aux, an_pci_devices,
104 : nitems(an_pci_devices)));
105 : }
106 :
107 : void
108 0 : an_pci_attach(struct device *parent, struct device *self, void *aux)
109 : {
110 0 : struct an_softc *sc = (struct an_softc *)self;
111 0 : struct pci_attach_args *pa = aux;
112 0 : pci_intr_handle_t ih;
113 0 : bus_space_handle_t ioh;
114 0 : bus_space_tag_t iot = pa->pa_iot;
115 0 : pci_chipset_tag_t pc = pa->pa_pc;
116 : const char *intrstr;
117 :
118 : /* Map the I/O ports. */
119 0 : if (pci_mapreg_map(pa, AN_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0,
120 0 : &iot, &ioh, NULL, NULL, 0) != 0) {
121 0 : printf(": can't map i/o space\n");
122 0 : return;
123 : }
124 0 : sc->sc_iot = iot;
125 0 : sc->sc_ioh = ioh;
126 :
127 : /* Map and establish the interrupt. */
128 0 : if (pci_intr_map(pa, &ih)) {
129 0 : printf("\n%s: couldn't map interrupt\n", sc->sc_dev.dv_xname);
130 0 : return;
131 : }
132 0 : intrstr = pci_intr_string(pc, ih);
133 0 : sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, an_intr, sc,
134 0 : sc->sc_dev.dv_xname);
135 0 : if (sc->sc_ih == NULL) {
136 0 : printf("\n%s: couldn't establish interrupt",
137 : sc->sc_dev.dv_xname);
138 0 : if (intrstr != NULL)
139 0 : printf(" at %s", intrstr);
140 0 : printf("\n");
141 0 : return;
142 : }
143 0 : printf(": %s", intrstr);
144 :
145 0 : sc->sc_enabled = 1;
146 :
147 0 : an_attach(sc);
148 0 : }
|