Deleted Added
full compact
if_an_pci.c (175446) if_an_pci.c (198995)
1/*-
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/dev/an/if_an_pci.c 175446 2008-01-18 16:34:18Z ambrisko $");
34__FBSDID("$FreeBSD: head/sys/dev/an/if_an_pci.c 198995 2009-11-06 18:28:13Z jhb $");
35
36/*
37 * This is a PCI shim for the Aironet PC4500/4800 wireless network
38 * driver. Aironet makes PCMCIA, ISA and PCI versions of these devices,
39 * which all have basically the same interface. The ISA and PCI cards
40 * are actually bridge adapters with PCMCIA cards inserted into them,
41 * however they appear as normal PCI or ISA devices to the host.
42 *

--- 55 unchanged lines hidden (view full) ---

98#define AIRONET_DEVICEID_4800 0x4800
99#define AIRONET_DEVICEID_4xxx 0x0001
100#define AIRONET_DEVICEID_MPI350 0xA504
101#define AN_PCI_PLX_LOIO 0x14 /* PLX chip iobase */
102#define AN_PCI_LOIO 0x18 /* Aironet iobase */
103
104static struct an_type an_devs[] = {
105 { AIRONET_VENDORID, AIRONET_DEVICEID_35x, "Cisco Aironet 350 Series" },
35
36/*
37 * This is a PCI shim for the Aironet PC4500/4800 wireless network
38 * driver. Aironet makes PCMCIA, ISA and PCI versions of these devices,
39 * which all have basically the same interface. The ISA and PCI cards
40 * are actually bridge adapters with PCMCIA cards inserted into them,
41 * however they appear as normal PCI or ISA devices to the host.
42 *

--- 55 unchanged lines hidden (view full) ---

98#define AIRONET_DEVICEID_4800 0x4800
99#define AIRONET_DEVICEID_4xxx 0x0001
100#define AIRONET_DEVICEID_MPI350 0xA504
101#define AN_PCI_PLX_LOIO 0x14 /* PLX chip iobase */
102#define AN_PCI_LOIO 0x18 /* Aironet iobase */
103
104static struct an_type an_devs[] = {
105 { AIRONET_VENDORID, AIRONET_DEVICEID_35x, "Cisco Aironet 350 Series" },
106 { AIRONET_VENDORID, AIRONET_DEVICEID_MPI350, "Cisco Aironet MPI350" },
106 { AIRONET_VENDORID, AIRONET_DEVICEID_4500, "Aironet PCI4500" },
107 { AIRONET_VENDORID, AIRONET_DEVICEID_4800, "Aironet PCI4800" },
108 { AIRONET_VENDORID, AIRONET_DEVICEID_4xxx, "Aironet PCI4500/PCI4800" },
109 { 0, 0, NULL }
110};
111
112static int an_probe_pci (device_t);
113static int an_attach_pci (device_t);

--- 14 unchanged lines hidden (view full) ---

128 pci_get_device(dev) == t->an_did) {
129 device_set_desc(dev, t->an_name);
130 an_pci_probe(dev);
131 return(BUS_PROBE_DEFAULT);
132 }
133 t++;
134 }
135
107 { AIRONET_VENDORID, AIRONET_DEVICEID_4500, "Aironet PCI4500" },
108 { AIRONET_VENDORID, AIRONET_DEVICEID_4800, "Aironet PCI4800" },
109 { AIRONET_VENDORID, AIRONET_DEVICEID_4xxx, "Aironet PCI4500/PCI4800" },
110 { 0, 0, NULL }
111};
112
113static int an_probe_pci (device_t);
114static int an_attach_pci (device_t);

--- 14 unchanged lines hidden (view full) ---

129 pci_get_device(dev) == t->an_did) {
130 device_set_desc(dev, t->an_name);
131 an_pci_probe(dev);
132 return(BUS_PROBE_DEFAULT);
133 }
134 t++;
135 }
136
136 if (pci_get_vendor(dev) == AIRONET_VENDORID &&
137 pci_get_device(dev) == AIRONET_DEVICEID_MPI350) {
138 device_set_desc(dev, "Cisco Aironet MPI350");
139 an_pci_probe(dev);
140 return(BUS_PROBE_DEFAULT);
141 }
142
143 return(ENXIO);
144}
145
146static int
147an_attach_pci(dev)
148 device_t dev;
149{
150 u_int32_t command;
151 struct an_softc *sc;
137 return(ENXIO);
138}
139
140static int
141an_attach_pci(dev)
142 device_t dev;
143{
144 u_int32_t command;
145 struct an_softc *sc;
152 int unit, flags, error = 0;
146 int flags, error = 0;
153
154 sc = device_get_softc(dev);
147
148 sc = device_get_softc(dev);
155 unit = device_get_unit(dev);
156 flags = device_get_flags(dev);
157
158 if (pci_get_vendor(dev) == AIRONET_VENDORID &&
159 pci_get_device(dev) == AIRONET_DEVICEID_MPI350) {
160 sc->mpi350 = 1;
161 sc->port_rid = PCIR_BAR(0);
162 } else {
163 /*
164 * Map control/status registers.
165 */
166 command = pci_read_config(dev, PCIR_COMMAND, 4);
167 command |= PCIM_CMD_PORTEN;
168 pci_write_config(dev, PCIR_COMMAND, command, 4);
169 command = pci_read_config(dev, PCIR_COMMAND, 4);
170
171 if (!(command & PCIM_CMD_PORTEN)) {
149 flags = device_get_flags(dev);
150
151 if (pci_get_vendor(dev) == AIRONET_VENDORID &&
152 pci_get_device(dev) == AIRONET_DEVICEID_MPI350) {
153 sc->mpi350 = 1;
154 sc->port_rid = PCIR_BAR(0);
155 } else {
156 /*
157 * Map control/status registers.
158 */
159 command = pci_read_config(dev, PCIR_COMMAND, 4);
160 command |= PCIM_CMD_PORTEN;
161 pci_write_config(dev, PCIR_COMMAND, command, 4);
162 command = pci_read_config(dev, PCIR_COMMAND, 4);
163
164 if (!(command & PCIM_CMD_PORTEN)) {
172 printf("an%d: failed to enable I/O ports!\n", unit);
165 device_printf(dev, "failed to enable I/O ports!\n");
173 error = ENXIO;
174 goto fail;
175 }
176 sc->port_rid = AN_PCI_LOIO;
177 }
178 error = an_alloc_port(dev, sc->port_rid, 1);
179
180 if (error) {
166 error = ENXIO;
167 goto fail;
168 }
169 sc->port_rid = AN_PCI_LOIO;
170 }
171 error = an_alloc_port(dev, sc->port_rid, 1);
172
173 if (error) {
181 printf("an%d: couldn't map ports\n", unit);
174 device_printf(dev, "couldn't map ports\n");
182 goto fail;
183 }
184
185 sc->an_btag = rman_get_bustag(sc->port_res);
186 sc->an_bhandle = rman_get_bushandle(sc->port_res);
187
188 /* Allocate memory for MPI350 */
189 if (sc->mpi350) {
190 /* Allocate memory */
191 sc->mem_rid = PCIR_BAR(1);
192 error = an_alloc_memory(dev, sc->mem_rid, 1);
193 if (error) {
175 goto fail;
176 }
177
178 sc->an_btag = rman_get_bustag(sc->port_res);
179 sc->an_bhandle = rman_get_bushandle(sc->port_res);
180
181 /* Allocate memory for MPI350 */
182 if (sc->mpi350) {
183 /* Allocate memory */
184 sc->mem_rid = PCIR_BAR(1);
185 error = an_alloc_memory(dev, sc->mem_rid, 1);
186 if (error) {
194 printf("an%d: couldn't map memory\n", unit);
187 device_printf(dev, "couldn't map memory\n");
195 goto fail;
196 }
197 sc->an_mem_btag = rman_get_bustag(sc->mem_res);
198 sc->an_mem_bhandle = rman_get_bushandle(sc->mem_res);
199
200 /* Allocate aux. memory */
201 sc->mem_aux_rid = PCIR_BAR(2);
202 error = an_alloc_aux_memory(dev, sc->mem_aux_rid,
203 AN_AUX_MEM_SIZE);
204 if (error) {
188 goto fail;
189 }
190 sc->an_mem_btag = rman_get_bustag(sc->mem_res);
191 sc->an_mem_bhandle = rman_get_bushandle(sc->mem_res);
192
193 /* Allocate aux. memory */
194 sc->mem_aux_rid = PCIR_BAR(2);
195 error = an_alloc_aux_memory(dev, sc->mem_aux_rid,
196 AN_AUX_MEM_SIZE);
197 if (error) {
205 printf("an%d: couldn't map aux memory\n", unit);
198 device_printf(dev, "couldn't map aux memory\n");
206 goto fail;
207 }
208 sc->an_mem_aux_btag = rman_get_bustag(sc->mem_aux_res);
209 sc->an_mem_aux_bhandle = rman_get_bushandle(sc->mem_aux_res);
210
211 /* Allocate DMA region */
212 error = bus_dma_tag_create(NULL, /* parent */
213 1, 0, /* alignment, bounds */
214 BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
215 BUS_SPACE_MAXADDR, /* highaddr */
216 NULL, NULL, /* filter, filterarg */
217 0x3ffff, /* maxsize XXX */
218 1, /* nsegments */
219 0xffff, /* maxsegsize XXX */
220 BUS_DMA_ALLOCNOW, /* flags */
221 NULL, /* lockfunc */
222 NULL, /* lockarg */
223 &sc->an_dtag);
224 if (error) {
199 goto fail;
200 }
201 sc->an_mem_aux_btag = rman_get_bustag(sc->mem_aux_res);
202 sc->an_mem_aux_bhandle = rman_get_bushandle(sc->mem_aux_res);
203
204 /* Allocate DMA region */
205 error = bus_dma_tag_create(NULL, /* parent */
206 1, 0, /* alignment, bounds */
207 BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
208 BUS_SPACE_MAXADDR, /* highaddr */
209 NULL, NULL, /* filter, filterarg */
210 0x3ffff, /* maxsize XXX */
211 1, /* nsegments */
212 0xffff, /* maxsegsize XXX */
213 BUS_DMA_ALLOCNOW, /* flags */
214 NULL, /* lockfunc */
215 NULL, /* lockarg */
216 &sc->an_dtag);
217 if (error) {
225 printf("an%d: couldn't get DMA region\n", unit);
218 device_printf(dev, "couldn't get DMA region\n");
226 goto fail;
227 }
228 }
229
230 /* Allocate interrupt */
231 error = an_alloc_irq(dev, 0, RF_SHAREABLE);
232 if (error) {
219 goto fail;
220 }
221 }
222
223 /* Allocate interrupt */
224 error = an_alloc_irq(dev, 0, RF_SHAREABLE);
225 if (error) {
226 device_printf(dev, "couldn't get interrupt\n");
233 goto fail;
234 }
235
236 sc->an_dev = dev;
227 goto fail;
228 }
229
230 sc->an_dev = dev;
237 error = an_attach(sc, device_get_unit(dev), flags);
231 error = an_attach(sc, flags);
238 if (error) {
232 if (error) {
233 device_printf(dev, "couldn't attach\n");
239 goto fail;
240 }
241
242 /*
243 * Must setup the interrupt after the an_attach to prevent racing.
244 */
245 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
246 NULL, an_intr, sc, &sc->irq_handle);
234 goto fail;
235 }
236
237 /*
238 * Must setup the interrupt after the an_attach to prevent racing.
239 */
240 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
241 NULL, an_intr, sc, &sc->irq_handle);
242 if (error)
243 device_printf(dev, "couldn't setup interrupt\n");
247
248fail:
249 if (error)
250 an_release_resources(dev);
251 return(error);
252}
253
254static int

--- 37 unchanged lines hidden ---
244
245fail:
246 if (error)
247 an_release_resources(dev);
248 return(error);
249}
250
251static int

--- 37 unchanged lines hidden ---