3 * Copyright (c) 1996 Stefan Esser <se@freebsd.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice immediately at the beginning of the file, without modification,
11 * this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Absolutely no warranty of function or purpose is made by the author
17 * 4. Modifications may be freely made to this file if the above conditions
20 * $FreeBSD: src/sys/dev/ed/if_ed_pci.c,v 1.34 2003/10/31 18:31:58 brooks Exp $
21 * $DragonFly: src/sys/dev/netif/ed/if_ed_pci.c,v 1.11 2005/12/31 14:07:59 sephe Exp $
24 #include <sys/param.h>
25 #include <sys/systm.h>
26 #include <sys/socket.h>
27 #include <sys/kernel.h>
29 #include <sys/module.h>
32 #include <machine/bus.h>
34 #include <machine/resource.h>
37 #include <net/if_arp.h>
38 #include <net/if_mib.h>
40 #include <bus/pci/pcireg.h>
41 #include <bus/pci/pcivar.h>
45 static int ed_pci_detach(device_t dev);
53 { 0x802910ec, "NE2000 PCI Ethernet (RealTek 8029)" },
54 { 0x50004a14, "NE2000 PCI Ethernet (NetVin 5000)" },
55 { 0x09401050, "NE2000 PCI Ethernet (ProLAN)" },
56 { 0x140111f6, "NE2000 PCI Ethernet (Compex)" },
57 { 0x30008e2e, "NE2000 PCI Ethernet (KTI)" },
58 { 0x19808c4a, "NE2000 PCI Ethernet (Winbond W89C940)" },
59 { 0x0e3410bd, "NE2000 PCI Ethernet (Surecom NE-34)" },
60 { 0x09261106, "NE2000 PCI Ethernet (VIA VT86C926)" },
64 static int ed_pci_probe (device_t);
65 static int ed_pci_attach (device_t);
68 ed_pci_probe (device_t dev)
70 u_int32_t type = pci_get_devid(dev);
71 struct _pcsid *ep =pci_ids;
73 while (ep->type && ep->type != type)
76 device_set_desc(dev, ep->desc);
84 ed_pci_attach(device_t dev)
86 struct ed_softc *sc = device_get_softc(dev);
90 error = ed_probe_Novell(dev, PCIR_MAPS, flags);
94 error = ed_alloc_irq(dev, 0, RF_SHAREABLE);
96 ed_release_resources(dev);
100 error = ed_attach(dev);
102 error = bus_setup_intr(dev, sc->irq_res, INTR_NETSAFE,
103 edintr, sc, &sc->irq_handle,
104 sc->arpcom.ac_if.if_serializer);
108 ed_release_resources(dev);
114 ed_pci_detach(device_t dev)
116 struct ed_softc *sc = device_get_softc(dev);
117 struct ifnet *ifp = &sc->arpcom.ac_if;
119 lwkt_serialize_enter(ifp->if_serializer);
122 device_printf(dev, "already unloaded\n");
123 lwkt_serialize_exit(ifp->if_serializer);
127 ifp->if_flags &= ~IFF_RUNNING;
129 bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
131 lwkt_serialize_exit(ifp->if_serializer);
134 ed_release_resources(dev);
138 static device_method_t ed_pci_methods[] = {
139 /* Device interface */
140 DEVMETHOD(device_probe, ed_pci_probe),
141 DEVMETHOD(device_attach, ed_pci_attach),
142 DEVMETHOD(device_attach, ed_pci_detach),
147 static driver_t ed_pci_driver = {
150 sizeof(struct ed_softc),
153 static devclass_t ed_devclass;
155 DRIVER_MODULE(ed, pci, ed_pci_driver, ed_devclass, 0, 0);
156 MODULE_DEPEND(ed, pci, 1, 1, 1);