Deleted Added
full compact
amr_pci.c (239939) amr_pci.c (254263)
1/*-
2 * Copyright (c) 1999,2000 Michael Smith
3 * Copyright (c) 2000 BSDi
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:

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

50 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54 * SUCH DAMAGE.
55 */
56
57#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1999,2000 Michael Smith
3 * Copyright (c) 2000 BSDi
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:

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

50 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54 * SUCH DAMAGE.
55 */
56
57#include <sys/cdefs.h>
58__FBSDID("$FreeBSD: head/sys/dev/amr/amr_pci.c 239939 2012-08-31 09:42:46Z scottl $");
58__FBSDID("$FreeBSD: head/sys/dev/amr/amr_pci.c 254263 2013-08-12 23:30:01Z scottl $");
59
60#include <sys/param.h>
61#include <sys/systm.h>
62#include <sys/kernel.h>
63#include <sys/module.h>
64#include <sys/sysctl.h>
65
66#include <sys/bio.h>

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

179}
180
181static int
182amr_pci_attach(device_t dev)
183{
184 struct amr_softc *sc;
185 struct amr_ident *id;
186 int rid, rtype, error;
59
60#include <sys/param.h>
61#include <sys/systm.h>
62#include <sys/kernel.h>
63#include <sys/module.h>
64#include <sys/sysctl.h>
65
66#include <sys/bio.h>

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

179}
180
181static int
182amr_pci_attach(device_t dev)
183{
184 struct amr_softc *sc;
185 struct amr_ident *id;
186 int rid, rtype, error;
187 u_int32_t command;
188
189 debug_called(1);
190
191 /*
192 * Initialise softc.
193 */
194 sc = device_get_softc(dev);
195 bzero(sc, sizeof(*sc));
196 sc->amr_dev = dev;
197
198 /* assume failure is 'not configured' */
199 error = ENXIO;
200
201 /*
202 * Determine board type.
203 */
204 if ((id = amr_find_ident(dev)) == NULL)
205 return (ENXIO);
206
187
188 debug_called(1);
189
190 /*
191 * Initialise softc.
192 */
193 sc = device_get_softc(dev);
194 bzero(sc, sizeof(*sc));
195 sc->amr_dev = dev;
196
197 /* assume failure is 'not configured' */
198 error = ENXIO;
199
200 /*
201 * Determine board type.
202 */
203 if ((id = amr_find_ident(dev)) == NULL)
204 return (ENXIO);
205
207 command = pci_read_config(dev, PCIR_COMMAND, 1);
208 if (id->flags & AMR_ID_QUARTZ) {
206 if (id->flags & AMR_ID_QUARTZ) {
209 /*
210 * Make sure we are going to be able to talk to this board.
211 */
212 if ((command & PCIM_CMD_MEMEN) == 0) {
213 device_printf(dev, "memory window not available\n");
214 return (ENXIO);
215 }
216 sc->amr_type |= AMR_TYPE_QUARTZ;
207 sc->amr_type |= AMR_TYPE_QUARTZ;
217 } else {
218 /*
219 * Make sure we are going to be able to talk to this board.
220 */
221 if ((command & PCIM_CMD_PORTEN) == 0) {
222 device_printf(dev, "I/O window not available\n");
223 return (ENXIO);
224 }
225 }
226
227 if ((amr_force_sg32 == 0) && (id->flags & AMR_ID_DO_SG64) &&
228 (sizeof(vm_paddr_t) > 4)) {
229 device_printf(dev, "Using 64-bit DMA\n");
230 sc->amr_type |= AMR_TYPE_SG64;
231 }
232
233 /* force the busmaster enable bit on */
208 }
209
210 if ((amr_force_sg32 == 0) && (id->flags & AMR_ID_DO_SG64) &&
211 (sizeof(vm_paddr_t) > 4)) {
212 device_printf(dev, "Using 64-bit DMA\n");
213 sc->amr_type |= AMR_TYPE_SG64;
214 }
215
216 /* force the busmaster enable bit on */
234 if (!(command & PCIM_CMD_BUSMASTEREN)) {
235 device_printf(dev, "busmaster bit not set, enabling\n");
236 command |= PCIM_CMD_BUSMASTEREN;
237 pci_write_config(dev, PCIR_COMMAND, command, 2);
238 }
217 pci_enable_busmaster(dev);
239
240 /*
241 * Allocate the PCI register window.
242 */
243 rid = PCIR_BAR(0);
244 rtype = AMR_IS_QUARTZ(sc) ? SYS_RES_MEMORY : SYS_RES_IOPORT;
245 sc->amr_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE);
246 if (sc->amr_reg == NULL) {

--- 471 unchanged lines hidden ---
218
219 /*
220 * Allocate the PCI register window.
221 */
222 rid = PCIR_BAR(0);
223 rtype = AMR_IS_QUARTZ(sc) ? SYS_RES_MEMORY : SYS_RES_IOPORT;
224 sc->amr_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE);
225 if (sc->amr_reg == NULL) {

--- 471 unchanged lines hidden ---