Deleted Added
full compact
mps_pci.c (253460) mps_pci.c (254263)
1/*-
2 * Copyright (c) 2009 Yahoo! Inc.
3 * 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

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

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009 Yahoo! Inc.
3 * 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

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

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/mps/mps_pci.c 253460 2013-07-19 00:12:41Z scottl $");
28__FBSDID("$FreeBSD: head/sys/dev/mps/mps_pci.c 254263 2013-08-12 23:30:01Z scottl $");
29
30/* PCI/PCI-X/PCIe bus interface for the LSI MPT2 controllers */
31
32/* TODO Move headers to mpsvar */
33#include <sys/types.h>
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/kernel.h>

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

178 return (ENXIO);
179}
180
181static int
182mps_pci_attach(device_t dev)
183{
184 struct mps_softc *sc;
185 struct mps_ident *m;
29
30/* PCI/PCI-X/PCIe bus interface for the LSI MPT2 controllers */
31
32/* TODO Move headers to mpsvar */
33#include <sys/types.h>
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/kernel.h>

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

178 return (ENXIO);
179}
180
181static int
182mps_pci_attach(device_t dev)
183{
184 struct mps_softc *sc;
185 struct mps_ident *m;
186 uint16_t command;
187 int error;
188
189 sc = device_get_softc(dev);
190 bzero(sc, sizeof(*sc));
191 sc->mps_dev = dev;
192 m = mps_find_ident(dev);
193 sc->mps_flags = m->flags;
194
195 /* Twiddle basic PCI config bits for a sanity check */
186 int error;
187
188 sc = device_get_softc(dev);
189 bzero(sc, sizeof(*sc));
190 sc->mps_dev = dev;
191 m = mps_find_ident(dev);
192 sc->mps_flags = m->flags;
193
194 /* Twiddle basic PCI config bits for a sanity check */
196 command = pci_read_config(dev, PCIR_COMMAND, 2);
197 command |= PCIM_CMD_BUSMASTEREN;
198 pci_write_config(dev, PCIR_COMMAND, command, 2);
199 command = pci_read_config(dev, PCIR_COMMAND, 2);
200 if ((command & PCIM_CMD_BUSMASTEREN) == 0) {
201 mps_printf(sc, "Cannot enable PCI busmaster\n");
202 return (ENXIO);
203 }
204 if ((command & PCIM_CMD_MEMEN) == 0) {
205 mps_printf(sc, "PCI memory window not available\n");
206 return (ENXIO);
207 }
195 pci_enable_busmaster(dev);
208
209 /* Allocate the System Interface Register Set */
210 sc->mps_regs_rid = PCIR_BAR(1);
211 if ((sc->mps_regs_resource = bus_alloc_resource_any(dev,
212 SYS_RES_MEMORY, &sc->mps_regs_rid, RF_ACTIVE)) == NULL) {
213 mps_printf(sc, "Cannot allocate PCI registers\n");
214 return (ENXIO);
215 }

--- 178 unchanged lines hidden ---
196
197 /* Allocate the System Interface Register Set */
198 sc->mps_regs_rid = PCIR_BAR(1);
199 if ((sc->mps_regs_resource = bus_alloc_resource_any(dev,
200 SYS_RES_MEMORY, &sc->mps_regs_rid, RF_ACTIVE)) == NULL) {
201 mps_printf(sc, "Cannot allocate PCI registers\n");
202 return (ENXIO);
203 }

--- 178 unchanged lines hidden ---