Deleted Added
full compact
if_gem_pci.c (147256) if_gem_pci.c (148369)
1/*-
2 * Copyright (C) 2001 Eduardo Horvath.
3 * All rights reserved.
4 *
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:

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

24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * from: NetBSD: if_gem_pci.c,v 1.7 2001/10/18 15:09:15 thorpej Exp
28 *
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (C) 2001 Eduardo Horvath.
3 * All rights reserved.
4 *
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:

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

24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * from: NetBSD: if_gem_pci.c,v 1.7 2001/10/18 15:09:15 thorpej Exp
28 *
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sys/dev/gem/if_gem_pci.c 147256 2005-06-10 16:49:24Z brooks $");
32__FBSDID("$FreeBSD: head/sys/dev/gem/if_gem_pci.c 148369 2005-07-24 18:45:15Z marius $");
33
34/*
35 * PCI bindings for Sun GEM ethernet controllers.
36 */
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/bus.h>
41#include <sys/malloc.h>
42#include <sys/kernel.h>
33
34/*
35 * PCI bindings for Sun GEM ethernet controllers.
36 */
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/bus.h>
41#include <sys/malloc.h>
42#include <sys/kernel.h>
43#include <sys/lock.h>
43#include <sys/module.h>
44#include <sys/module.h>
45#include <sys/mutex.h>
44#include <sys/resource.h>
45#include <sys/socket.h>
46
47#include <machine/endian.h>
48
49#include <net/ethernet.h>
50#include <net/if.h>
51#include <net/if_arp.h>

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

170 * although it should be 1. correct that.
171 */
172 if (pci_get_intpin(dev) == 0)
173 pci_set_intpin(dev, 1);
174
175 sc->sc_dev = dev;
176 sc->sc_pci = 1; /* XXX */
177
46#include <sys/resource.h>
47#include <sys/socket.h>
48
49#include <machine/endian.h>
50
51#include <net/ethernet.h>
52#include <net/if.h>
53#include <net/if_arp.h>

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

172 * although it should be 1. correct that.
173 */
174 if (pci_get_intpin(dev) == 0)
175 pci_set_intpin(dev, 1);
176
177 sc->sc_dev = dev;
178 sc->sc_pci = 1; /* XXX */
179
180 GEM_LOCK_INIT(sc, device_get_nameunit(dev));
181
178 gsc->gsc_srid = PCI_GEM_BASEADDR;
179 gsc->gsc_sres = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
180 &gsc->gsc_srid, RF_ACTIVE);
181 if (gsc->gsc_sres == NULL) {
182 device_printf(dev, "failed to allocate bus space resource\n");
182 gsc->gsc_srid = PCI_GEM_BASEADDR;
183 gsc->gsc_sres = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
184 &gsc->gsc_srid, RF_ACTIVE);
185 if (gsc->gsc_sres == NULL) {
186 device_printf(dev, "failed to allocate bus space resource\n");
183 return (ENXIO);
187 goto fail_mtx;
184 }
185
186 gsc->gsc_irid = 0;
187 gsc->gsc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ,
188 &gsc->gsc_irid, RF_SHAREABLE | RF_ACTIVE);
189 if (gsc->gsc_ires == NULL) {
190 device_printf(dev, "failed to allocate interrupt resource\n");
191 goto fail_sres;

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

200 /*
201 * call the main configure
202 */
203 if (gem_attach(sc) != 0) {
204 device_printf(dev, "could not be configured\n");
205 goto fail_ires;
206 }
207
188 }
189
190 gsc->gsc_irid = 0;
191 gsc->gsc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ,
192 &gsc->gsc_irid, RF_SHAREABLE | RF_ACTIVE);
193 if (gsc->gsc_ires == NULL) {
194 device_printf(dev, "failed to allocate interrupt resource\n");
195 goto fail_sres;

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

204 /*
205 * call the main configure
206 */
207 if (gem_attach(sc) != 0) {
208 device_printf(dev, "could not be configured\n");
209 goto fail_ires;
210 }
211
208 if (bus_setup_intr(dev, gsc->gsc_ires, INTR_TYPE_NET, gem_intr, sc,
209 &gsc->gsc_ih) != 0) {
212 if (bus_setup_intr(dev, gsc->gsc_ires, INTR_TYPE_NET | INTR_MPSAFE,
213 gem_intr, sc, &gsc->gsc_ih) != 0) {
210 device_printf(dev, "failed to set up interrupt\n");
211 gem_detach(sc);
212 goto fail_ires;
213 }
214 return (0);
215
216fail_ires:
217 bus_release_resource(dev, SYS_RES_IRQ, gsc->gsc_irid, gsc->gsc_ires);
218fail_sres:
219 bus_release_resource(dev, SYS_RES_MEMORY, gsc->gsc_srid, gsc->gsc_sres);
214 device_printf(dev, "failed to set up interrupt\n");
215 gem_detach(sc);
216 goto fail_ires;
217 }
218 return (0);
219
220fail_ires:
221 bus_release_resource(dev, SYS_RES_IRQ, gsc->gsc_irid, gsc->gsc_ires);
222fail_sres:
223 bus_release_resource(dev, SYS_RES_MEMORY, gsc->gsc_srid, gsc->gsc_sres);
224fail_mtx:
225 GEM_LOCK_DESTROY(sc);
220 return (ENXIO);
221}
222
223static int
224gem_pci_detach(dev)
225 device_t dev;
226{
227 struct gem_pci_softc *gsc = device_get_softc(dev);
228 struct gem_softc *sc = &gsc->gsc_gem;
229
226 return (ENXIO);
227}
228
229static int
230gem_pci_detach(dev)
231 device_t dev;
232{
233 struct gem_pci_softc *gsc = device_get_softc(dev);
234 struct gem_softc *sc = &gsc->gsc_gem;
235
230 gem_detach(sc);
231
232 bus_teardown_intr(dev, gsc->gsc_ires, gsc->gsc_ih);
236 bus_teardown_intr(dev, gsc->gsc_ires, gsc->gsc_ih);
237 gem_detach(sc);
233 bus_release_resource(dev, SYS_RES_IRQ, gsc->gsc_irid, gsc->gsc_ires);
234 bus_release_resource(dev, SYS_RES_MEMORY, gsc->gsc_srid, gsc->gsc_sres);
238 bus_release_resource(dev, SYS_RES_IRQ, gsc->gsc_irid, gsc->gsc_ires);
239 bus_release_resource(dev, SYS_RES_MEMORY, gsc->gsc_srid, gsc->gsc_sres);
240 GEM_LOCK_DESTROY(sc);
235 return (0);
236}
237
238static int
239gem_pci_suspend(dev)
240 device_t dev;
241{
242 struct gem_pci_softc *gsc = device_get_softc(dev);

--- 16 unchanged lines hidden ---
241 return (0);
242}
243
244static int
245gem_pci_suspend(dev)
246 device_t dev;
247{
248 struct gem_pci_softc *gsc = device_get_softc(dev);

--- 16 unchanged lines hidden ---