Deleted Added
sdiff udiff text old ( 133731 ) new ( 137982 )
full compact
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 133731 2004-08-14 22:38:20Z marius $");
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
189 /*
190 * Map five register banks:
191 *
192 * bank 0: HME SEB registers: +0x0000
193 * bank 1: HME ETX registers: +0x2000
194 * bank 2: HME ERX registers: +0x4000
195 * bank 3: HME MAC registers: +0x6000
196 * bank 4: HME MIF registers: +0x7000
197 *
198 */
199 hsc->hsc_srid = PCI_HME_BASEADDR;
200 hsc->hsc_sres = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
201 &hsc->hsc_srid, RF_ACTIVE);
202 if (hsc->hsc_sres == NULL) {
203 device_printf(dev, "could not map device registers\n");
204 return (ENXIO);
205 }
206 hsc->hsc_irid = 0;
207 hsc->hsc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ,
208 &hsc->hsc_irid, RF_SHAREABLE | RF_ACTIVE);
209 if (hsc->hsc_ires == NULL) {
210 device_printf(dev, "could not allocate interrupt\n");
211 error = ENXIO;
212 goto fail_sres;

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

342 /*
343 * call the main configure
344 */
345 if ((error = hme_config(sc)) != 0) {
346 device_printf(dev, "could not be configured\n");
347 goto fail_ires;
348 }
349
350 if ((error = bus_setup_intr(dev, hsc->hsc_ires, INTR_TYPE_NET, hme_intr,
351 sc, &hsc->hsc_ih)) != 0) {
352 device_printf(dev, "couldn't establish interrupt\n");
353 hme_detach(sc);
354 goto fail_ires;
355 }
356 return (0);
357
358fail_ires:
359 bus_release_resource(dev, SYS_RES_IRQ, hsc->hsc_irid, hsc->hsc_ires);
360fail_sres:
361 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_srid, hsc->hsc_sres);
362 return (error);
363}
364
365static int
366hme_pci_detach(device_t dev)
367{
368 struct hme_pci_softc *hsc = device_get_softc(dev);
369 struct hme_softc *sc = &hsc->hsc_hme;
370
371 hme_detach(sc);
372
373 bus_teardown_intr(dev, hsc->hsc_ires, hsc->hsc_ih);
374 bus_release_resource(dev, SYS_RES_IRQ, hsc->hsc_irid, hsc->hsc_ires);
375 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_srid, hsc->hsc_sres);
376 return (0);
377}
378
379static int
380hme_pci_suspend(device_t dev)
381{

--- 16 unchanged lines hidden ---