1/*- 2 * Copyright (c) 2000 Matthew R. Green 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 --- 15 unchanged lines hidden (view full) --- 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * from: NetBSD: if_hme_pci.c,v 1.14 2004/03/17 08:58:23 martin Exp 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: head/sys/dev/hme/if_hme_pci.c 137982 2004-11-22 06:46:30Z yongari $"); |
33 34/* 35 * PCI front-end device driver for the HME ethernet device. 36 */ 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/bus.h> --- 139 unchanged lines hidden (view full) --- 180 * Some Sun HMEs do have their intpin register bogusly set to 0, 181 * although it should be 1. correct that. 182 */ 183 if (pci_get_intpin(dev) == 0) 184 pci_set_intpin(dev, 1); 185 186 sc->sc_pci = 1; 187 sc->sc_dev = dev; |
188 mtx_init(&sc->sc_lock, device_get_nameunit(dev), MTX_NETWORK_LOCK, 189 MTX_DEF); |
190 191 /* 192 * Map five register banks: 193 * 194 * bank 0: HME SEB registers: +0x0000 195 * bank 1: HME ETX registers: +0x2000 196 * bank 2: HME ERX registers: +0x4000 197 * bank 3: HME MAC registers: +0x6000 198 * bank 4: HME MIF registers: +0x7000 199 * 200 */ 201 hsc->hsc_srid = PCI_HME_BASEADDR; 202 hsc->hsc_sres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, 203 &hsc->hsc_srid, RF_ACTIVE); 204 if (hsc->hsc_sres == NULL) { 205 device_printf(dev, "could not map device registers\n"); |
206 error = ENXIO; 207 goto fail_mtx; |
208 } 209 hsc->hsc_irid = 0; 210 hsc->hsc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, 211 &hsc->hsc_irid, RF_SHAREABLE | RF_ACTIVE); 212 if (hsc->hsc_ires == NULL) { 213 device_printf(dev, "could not allocate interrupt\n"); 214 error = ENXIO; 215 goto fail_sres; --- 129 unchanged lines hidden (view full) --- 345 /* 346 * call the main configure 347 */ 348 if ((error = hme_config(sc)) != 0) { 349 device_printf(dev, "could not be configured\n"); 350 goto fail_ires; 351 } 352 |
353 if ((error = bus_setup_intr(dev, hsc->hsc_ires, INTR_TYPE_NET | 354 INTR_MPSAFE, hme_intr, sc, &hsc->hsc_ih)) != 0) { |
355 device_printf(dev, "couldn't establish interrupt\n"); 356 hme_detach(sc); 357 goto fail_ires; 358 } 359 return (0); 360 361fail_ires: 362 bus_release_resource(dev, SYS_RES_IRQ, hsc->hsc_irid, hsc->hsc_ires); 363fail_sres: 364 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_srid, hsc->hsc_sres); |
365fail_mtx: 366 mtx_destroy(&sc->sc_lock); |
367 return (error); 368} 369 370static int 371hme_pci_detach(device_t dev) 372{ 373 struct hme_pci_softc *hsc = device_get_softc(dev); 374 struct hme_softc *sc = &hsc->hsc_hme; 375 |
376 bus_teardown_intr(dev, hsc->hsc_ires, hsc->hsc_ih); |
377 hme_detach(sc); |
378 bus_release_resource(dev, SYS_RES_IRQ, hsc->hsc_irid, hsc->hsc_ires); 379 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_srid, hsc->hsc_sres); 380 return (0); 381} 382 383static int 384hme_pci_suspend(device_t dev) 385{ --- 16 unchanged lines hidden --- |