Deleted Added
full compact
if_mwl_pci.c (212410) if_mwl_pci.c (254263)
1/*-
2 * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
3 * Copyright (c) 2007-2009 Marvell Semiconductor, Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
26 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGES.
29 */
30
31#include <sys/cdefs.h>
32#ifdef __FreeBSD__
1/*-
2 * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
3 * Copyright (c) 2007-2009 Marvell Semiconductor, Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
26 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGES.
29 */
30
31#include <sys/cdefs.h>
32#ifdef __FreeBSD__
33__FBSDID("$FreeBSD: head/sys/dev/mwl/if_mwl_pci.c 212410 2010-09-10 08:11:48Z bschmidt $");
33__FBSDID("$FreeBSD: head/sys/dev/mwl/if_mwl_pci.c 254263 2013-08-12 23:30:01Z scottl $");
34#endif
35
36/*
37 * PCI front-end for the Marvell Wireless LAN controller driver.
38 */
39
40#include <sys/param.h>
41#include <sys/systm.h>

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

115 ident = mwl_pci_lookup(pci_get_vendor(dev), pci_get_device(dev));
116 if (ident != NULL) {
117 device_set_desc(dev, ident->name);
118 return BUS_PROBE_DEFAULT;
119 }
120 return ENXIO;
121}
122
34#endif
35
36/*
37 * PCI front-end for the Marvell Wireless LAN controller driver.
38 */
39
40#include <sys/param.h>
41#include <sys/systm.h>

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

115 ident = mwl_pci_lookup(pci_get_vendor(dev), pci_get_device(dev));
116 if (ident != NULL) {
117 device_set_desc(dev, ident->name);
118 return BUS_PROBE_DEFAULT;
119 }
120 return ENXIO;
121}
122
123static u_int32_t
124mwl_pci_setup(device_t dev)
125{
126 u_int32_t cmd;
127
128 /*
129 * Enable memory mapping and bus mastering.
130 */
131 cmd = pci_read_config(dev, PCIR_COMMAND, 4);
132 cmd |= PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN;
133 pci_write_config(dev, PCIR_COMMAND, cmd, 4);
134 cmd = pci_read_config(dev, PCIR_COMMAND, 4);
135 if ((cmd & PCIM_CMD_MEMEN) == 0) {
136 device_printf(dev, "failed to enable memory mapping\n");
137 return 0;
138 }
139 if ((cmd & PCIM_CMD_BUSMASTEREN) == 0) {
140 device_printf(dev, "failed to enable bus mastering\n");
141 return 0;
142 }
143 return 1;
144}
145
146static int
147mwl_pci_attach(device_t dev)
148{
149 struct mwl_pci_softc *psc = device_get_softc(dev);
150 struct mwl_softc *sc = &psc->sc_sc;
151 int rid, error = ENXIO;
152
153 sc->sc_dev = dev;
154
123static int
124mwl_pci_attach(device_t dev)
125{
126 struct mwl_pci_softc *psc = device_get_softc(dev);
127 struct mwl_softc *sc = &psc->sc_sc;
128 int rid, error = ENXIO;
129
130 sc->sc_dev = dev;
131
155 /*
156 * Enable memory mapping and bus mastering.
157 */
158 if (!mwl_pci_setup(dev))
159 return 0;
132 pci_enable_busmaster(dev);
133
160 /*
161 * Setup memory-mapping of PCI registers.
162 */
163 rid = BS_BAR0;
164 psc->sc_sr0 = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
165 RF_ACTIVE);
166 if (psc->sc_sr0 == NULL) {
167 device_printf(dev, "cannot map BAR0 register space\n");

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

280 return (0);
281}
282
283static int
284mwl_pci_resume(device_t dev)
285{
286 struct mwl_pci_softc *psc = device_get_softc(dev);
287
134 /*
135 * Setup memory-mapping of PCI registers.
136 */
137 rid = BS_BAR0;
138 psc->sc_sr0 = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
139 RF_ACTIVE);
140 if (psc->sc_sr0 == NULL) {
141 device_printf(dev, "cannot map BAR0 register space\n");

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

254 return (0);
255}
256
257static int
258mwl_pci_resume(device_t dev)
259{
260 struct mwl_pci_softc *psc = device_get_softc(dev);
261
288 if (!mwl_pci_setup(dev))
289 return ENXIO;
262 pci_enable_busmaster(dev);
290
291 mwl_resume(&psc->sc_sc);
292
293 return (0);
294}
295
296static device_method_t mwl_pci_methods[] = {
297 /* Device interface */

--- 19 unchanged lines hidden ---
263
264 mwl_resume(&psc->sc_sc);
265
266 return (0);
267}
268
269static device_method_t mwl_pci_methods[] = {
270 /* Device interface */

--- 19 unchanged lines hidden ---