Deleted Added
full compact
if_en_pci.c (150306) if_en_pci.c (150712)
1/* $NetBSD: if_en_pci.c,v 1.1 1996/06/22 02:00:31 chuck Exp $ */
2/*-
3 * Copyright (c) 1996 Charles D. Cranor and Washington University.
4 * All rights reserved.
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:

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

27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
34#include <sys/cdefs.h>
1/* $NetBSD: if_en_pci.c,v 1.1 1996/06/22 02:00:31 chuck Exp $ */
2/*-
3 * Copyright (c) 1996 Charles D. Cranor and Washington University.
4 * All rights reserved.
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:

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

27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/dev/en/if_en_pci.c 150306 2005-09-19 03:10:21Z imp $");
35__FBSDID("$FreeBSD: head/sys/dev/en/if_en_pci.c 150712 2005-09-29 14:56:30Z jhb $");
36
37/*
38 * i f _ e n _ p c i . c
39 *
40 * author: Chuck Cranor <chuck@ccrc.wustl.edu>
41 * started: spring, 1996.
42 *
43 * FreeBSD PCI glue for the eni155p card.
44 * thanks to Matt Thomas for figuring out FreeBSD vs NetBSD vs etc.. diffs.
45 */
46
47#include <sys/cdefs.h>
36
37/*
38 * i f _ e n _ p c i . c
39 *
40 * author: Chuck Cranor <chuck@ccrc.wustl.edu>
41 * started: spring, 1996.
42 *
43 * FreeBSD PCI glue for the eni155p card.
44 * thanks to Matt Thomas for figuring out FreeBSD vs NetBSD vs etc.. diffs.
45 */
46
47#include <sys/cdefs.h>
48__FBSDID("$FreeBSD: head/sys/dev/en/if_en_pci.c 150306 2005-09-19 03:10:21Z imp $");
48__FBSDID("$FreeBSD: head/sys/dev/en/if_en_pci.c 150712 2005-09-29 14:56:30Z jhb $");
49
50#include <sys/param.h>
51#include <sys/kernel.h>
52#include <sys/module.h>
53#include <sys/systm.h>
54#include <sys/socket.h>
55#include <sys/sysctl.h>
56#include <sys/condvar.h>

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

93
94static void eni_get_macaddr(device_t, struct en_pci_softc *);
95static void adp_get_macaddr(struct en_pci_softc *);
96
97/*
98 * address of config base memory address register in PCI config space
99 * (this is card specific)
100 */
49
50#include <sys/param.h>
51#include <sys/kernel.h>
52#include <sys/module.h>
53#include <sys/systm.h>
54#include <sys/socket.h>
55#include <sys/sysctl.h>
56#include <sys/condvar.h>

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

93
94static void eni_get_macaddr(device_t, struct en_pci_softc *);
95static void adp_get_macaddr(struct en_pci_softc *);
96
97/*
98 * address of config base memory address register in PCI config space
99 * (this is card specific)
100 */
101#define PCI_CBMA 0x10
101#define PCI_CBMA PCIR_BAR(0)
102
103/*
104 * tonga (pci bridge). ENI cards only!
105 */
106#define EN_TONGA 0x60 /* PCI config addr of tonga reg */
107
108#define TONGA_SWAP_DMA 0x80 /* endian swap control */
109#define TONGA_SWAP_BYTE 0x40

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

188 return (ENXIO);
189}
190
191static int
192en_pci_attach(device_t dev)
193{
194 struct en_softc *sc;
195 struct en_pci_softc *scp;
102
103/*
104 * tonga (pci bridge). ENI cards only!
105 */
106#define EN_TONGA 0x60 /* PCI config addr of tonga reg */
107
108#define TONGA_SWAP_DMA 0x80 /* endian swap control */
109#define TONGA_SWAP_BYTE 0x40

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

188 return (ENXIO);
189}
190
191static int
192en_pci_attach(device_t dev)
193{
194 struct en_softc *sc;
195 struct en_pci_softc *scp;
196 u_long val;
197 int rid, error = 0;
198
199 sc = device_get_softc(dev);
200 scp = (struct en_pci_softc *)sc;
201 sc->ifp = if_alloc(IFT_ATM);
202 if (sc->ifp == NULL) {
203 device_printf(dev, "can not if_alloc()\n");
204 error = ENOSPC;
205 goto fail;
206 }
207
208 if_initname(sc->ifp, device_get_name(dev),
209 device_get_unit(dev));
210
211 /*
212 * Enable bus mastering.
213 */
196 int rid, error = 0;
197
198 sc = device_get_softc(dev);
199 scp = (struct en_pci_softc *)sc;
200 sc->ifp = if_alloc(IFT_ATM);
201 if (sc->ifp == NULL) {
202 device_printf(dev, "can not if_alloc()\n");
203 error = ENOSPC;
204 goto fail;
205 }
206
207 if_initname(sc->ifp, device_get_name(dev),
208 device_get_unit(dev));
209
210 /*
211 * Enable bus mastering.
212 */
214 val = pci_read_config(dev, PCIR_COMMAND, 2);
215 val |= (PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
216 pci_write_config(dev, PCIR_COMMAND, val, 2);
213 pci_enable_busmaster(dev);
217
218 /*
219 * Map control/status registers.
220 */
221 rid = PCI_CBMA;
222 scp->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
223 RF_ACTIVE);
224 if (scp->res == NULL) {

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

279 /*
280 * Do the interrupt SETUP last just before returning
281 */
282 error = bus_setup_intr(dev, scp->irq, INTR_TYPE_NET,
283 en_intr, sc, &scp->ih);
284 if (error) {
285 en_reset(sc);
286 atm_ifdetach(sc->ifp);
214
215 /*
216 * Map control/status registers.
217 */
218 rid = PCI_CBMA;
219 scp->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
220 RF_ACTIVE);
221 if (scp->res == NULL) {

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

276 /*
277 * Do the interrupt SETUP last just before returning
278 */
279 error = bus_setup_intr(dev, scp->irq, INTR_TYPE_NET,
280 en_intr, sc, &scp->ih);
281 if (error) {
282 en_reset(sc);
283 atm_ifdetach(sc->ifp);
287 if_free(sc->ifp);
288 device_printf(dev, "could not setup irq\n");
289 bus_release_resource(dev, SYS_RES_IRQ, 0, scp->irq);
290 bus_release_resource(dev, SYS_RES_MEMORY, PCI_CBMA, scp->res);
291 en_destroy(sc);
292 if_free(sc->ifp);
293 goto fail;
294 }
295

--- 207 unchanged lines hidden ---
284 device_printf(dev, "could not setup irq\n");
285 bus_release_resource(dev, SYS_RES_IRQ, 0, scp->irq);
286 bus_release_resource(dev, SYS_RES_MEMORY, PCI_CBMA, scp->res);
287 en_destroy(sc);
288 if_free(sc->ifp);
289 goto fail;
290 }
291

--- 207 unchanged lines hidden ---