Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / sbus / if_en.c
blobb1eeb8603d24c120be2f719196ff5b81cba691cd
1 /* $NetBSD: if_en.c,v 1.26 2009/09/17 16:28:12 tsutsui Exp $ */
3 /*
5 * Copyright (c) 1996 Charles D. Cranor and Washington University.
6 * All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Charles D. Cranor and
19 * Washington University.
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 * i f _ e n _ s b u s . c
39 * author: Chuck Cranor <chuck@ccrc.wustl.edu>
40 * started: spring, 1996.
42 * SBUS glue for the eni155s card.
45 #include <sys/cdefs.h>
46 __KERNEL_RCSID(0, "$NetBSD: if_en.c,v 1.26 2009/09/17 16:28:12 tsutsui Exp $");
48 #include <sys/param.h>
49 #include <sys/systm.h>
50 #include <sys/device.h>
51 #include <sys/mbuf.h>
52 #include <sys/socket.h>
53 #include <sys/socketvar.h>
55 #include <net/if.h>
57 #include <sys/bus.h>
58 #include <sys/intr.h>
59 #include <sys/cpu.h>
61 #include <dev/sbus/sbusvar.h>
63 #include <dev/ic/midwayreg.h>
64 #include <dev/ic/midwayvar.h>
68 * local structures
70 struct en_sbus_softc {
71 /* bus independent stuff */
72 struct en_softc sc_en; /* includes "device" structure */
74 /* sbus glue */
79 * prototypes
81 static int en_sbus_match(device_t, cfdata_t, void *);
82 static void en_sbus_attach(device_t, device_t, void *);
85 * SBus autoconfig attachments
88 CFATTACH_DECL(en_sbus, sizeof(struct en_sbus_softc),
89 en_sbus_match, en_sbus_attach, NULL, NULL);
91 /***********************************************************************/
94 * autoconfig stuff
97 static int
98 en_sbus_match(device_t parent, cfdata_t cf, void *aux)
100 struct sbus_attach_args *sa = aux;
102 if (strcmp("ENI-155s", sa->sa_name) == 0) {
103 if (CPU_ISSUN4M) {
104 #ifdef DEBUG
105 printf("%s: sun4m DMA not supported yet\n",
106 sa->sa_name);
107 #endif
108 return (0);
110 return (1);
111 } else {
112 return (0);
117 static void
118 en_sbus_attach(device_t parent, device_t self, void *aux)
120 struct sbus_attach_args *sa = aux;
121 struct en_sbus_softc *ssc = device_private(self);
122 struct en_softc *sc = &ssc->sc_en;
124 printf("\n");
126 if (sbus_bus_map(sa->sa_bustag,
127 sa->sa_slot,
128 sa->sa_offset,
129 4*1024*1024,
130 0, &sc->en_base) != 0) {
131 aprint_error_dev(self, "cannot map registers\n");
132 return;
135 /* Establish interrupt handler */
136 if (sa->sa_nintr != 0)
137 (void)bus_intr_establish(sa->sa_bustag, sa->sa_pri,
138 IPL_NET, en_intr, sc);
140 sc->ipl = sa->sa_pri; /* appropriate? */
143 * done SBUS specific stuff
145 en_attach(sc);