1/*- 2 * Copyright (c) 1999 The NetBSD Foundation, Inc. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to The NetBSD Foundation 6 * by Paul Kranenburg. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 23 unchanged lines hidden (view full) --- 32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 * POSSIBILITY OF SUCH DAMAGE. 35 * 36 * from: NetBSD: if_hme_sbus.c,v 1.19 2004/03/17 17:04:58 pk Exp 37 */ 38 39#include <sys/cdefs.h> |
40__FBSDID("$FreeBSD: head/sys/dev/hme/if_hme_sbus.c 137982 2004-11-22 06:46:30Z yongari $"); |
41 42/* 43 * SBus front-end device driver for the HME ethernet device. 44 */ 45 46#include <sys/param.h> 47#include <sys/systm.h> 48#include <sys/bus.h> --- 98 unchanged lines hidden (view full) --- 147hme_sbus_attach(device_t dev) 148{ 149 struct hme_sbus_softc *hsc = device_get_softc(dev); 150 struct hme_softc *sc = &hsc->hsc_hme; 151 u_int32_t burst; 152 u_long start, count; 153 int error = 0; 154 |
155 mtx_init(&sc->sc_lock, device_get_nameunit(dev), MTX_NETWORK_LOCK, 156 MTX_DEF); |
157 /* 158 * Map five register banks: 159 * 160 * bank 0: HME SEB registers 161 * bank 1: HME ETX registers 162 * bank 2: HME ERX registers 163 * bank 3: HME MAC registers 164 * bank 4: HME MIF registers 165 * 166 */ 167 hsc->hsc_seb_rid = 0; 168 hsc->hsc_seb_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, 169 &hsc->hsc_seb_rid, RF_ACTIVE); 170 if (hsc->hsc_seb_res == NULL) { 171 device_printf(dev, "cannot map SEB registers\n"); |
172 error = ENXIO; 173 goto fail_mtx_res; |
174 } 175 sc->sc_sebt = rman_get_bustag(hsc->hsc_seb_res); 176 sc->sc_sebh = rman_get_bushandle(hsc->hsc_seb_res); 177 178 hsc->hsc_etx_rid = 1; 179 hsc->hsc_etx_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, 180 &hsc->hsc_etx_rid, RF_ACTIVE); 181 if (hsc->hsc_etx_res == NULL) { --- 81 unchanged lines hidden (view full) --- 263 sc->sc_pci = 0; /* XXX: should all be done in bus_dma. */ 264 sc->sc_dev = dev; 265 266 if ((error = hme_config(sc)) != 0) { 267 device_printf(dev, "could not be configured\n"); 268 goto fail_ires; 269 } 270 |
271 if ((error = bus_setup_intr(dev, hsc->hsc_ires, INTR_TYPE_NET | 272 INTR_MPSAFE, hme_intr, sc, &hsc->hsc_ih)) != 0) { |
273 device_printf(dev, "couldn't establish interrupt\n"); 274 hme_detach(sc); 275 goto fail_ires; 276 } 277 return (0); 278 279fail_ires: 280 bus_release_resource(dev, SYS_RES_IRQ, hsc->hsc_irid, hsc->hsc_ires); --- 9 unchanged lines hidden (view full) --- 290 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_erx_rid, 291 hsc->hsc_erx_res); 292fail_etx_res: 293 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_etx_rid, 294 hsc->hsc_etx_res); 295fail_seb_res: 296 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_seb_rid, 297 hsc->hsc_seb_res); |
298fail_mtx_res: 299 mtx_destroy(&sc->sc_lock); |
300 return (error); 301} 302 303static int 304hme_sbus_detach(device_t dev) 305{ 306 struct hme_sbus_softc *hsc = device_get_softc(dev); 307 struct hme_softc *sc = &hsc->hsc_hme; 308 |
309 bus_teardown_intr(dev, hsc->hsc_ires, hsc->hsc_ih); |
310 hme_detach(sc); |
311 if (hsc->hsc_mif_res != NULL) { 312 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mif_rid, 313 hsc->hsc_mif_res); 314 } 315 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mac_rid, 316 hsc->hsc_mac_res); 317 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_erx_rid, 318 hsc->hsc_erx_res); 319 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_etx_rid, 320 hsc->hsc_etx_res); 321 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_seb_rid, 322 hsc->hsc_seb_res); |
323 mtx_destroy(&sc->sc_lock); |
324 return (0); 325} 326 327static int 328hme_sbus_suspend(device_t dev) 329{ 330 struct hme_sbus_softc *hsc = device_get_softc(dev); 331 struct hme_softc *sc = &hsc->hsc_hme; --- 14 unchanged lines hidden --- |