Deleted Added
full compact
if_hme_pci.c (133731) if_hme_pci.c (137982)
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>
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 $");
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;
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);
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");
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");
204 return (ENXIO);
206 error = ENXIO;
207 goto fail_mtx;
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
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
350 if ((error = bus_setup_intr(dev, hsc->hsc_ires, INTR_TYPE_NET, hme_intr,
351 sc, &hsc->hsc_ih)) != 0) {
353 if ((error = bus_setup_intr(dev, hsc->hsc_ires, INTR_TYPE_NET |
354 INTR_MPSAFE, hme_intr, 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);
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);
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
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
371 hme_detach(sc);
372
373 bus_teardown_intr(dev, hsc->hsc_ires, hsc->hsc_ih);
376 bus_teardown_intr(dev, hsc->hsc_ires, hsc->hsc_ih);
377 hme_detach(sc);
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 ---
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 ---