1 /* $NetBSD: if_ea.c,v 1.15 2009/05/12 13:18:40 cegger Exp $ */
4 * Copyright (c) 2000, 2001 Ben Harris
5 * Copyright (c) 1995 Mark Brinicombe
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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 Mark Brinicombe.
19 * 4. The name of the company nor the name of the author may be used to
20 * endorse or promote products derived from this software without specific
21 * prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * if_ea.c - Ether3 device driver
39 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: if_ea.c,v 1.15 2009/05/12 13:18:40 cegger Exp $");
42 #include <sys/param.h>
44 #include <sys/device.h>
45 #include <sys/socket.h>
46 #include <sys/systm.h>
52 #include <net/if_ether.h>
54 #include <dev/podulebus/podulebus.h>
55 #include <dev/podulebus/podules.h>
57 #include <dev/podulebus/if_eareg.h>
58 #include <dev/ic/seeq8005var.h>
61 * per-line info and status
65 struct seeq8005_softc sc_8005
;
67 struct evcnt sc_intrcnt
;
74 int eaprobe(device_t
, cfdata_t
, void *);
75 void eaattach(device_t
, device_t
, void *);
77 /* driver structure for autoconf */
79 CFATTACH_DECL(ea
, sizeof(struct ea_softc
),
80 eaprobe
, eaattach
, NULL
, NULL
);
87 * Probe for the ether3 podule.
91 eaprobe(device_t parent
, cfdata_t cf
, void *aux
)
93 struct podulebus_attach_args
*pa
= aux
;
95 return pa
->pa_product
== PODULE_ETHER3
;
104 eaattach(device_t parent
, device_t self
, void *aux
)
106 struct ea_softc
*sc
= device_private(self
);
107 struct podulebus_attach_args
*pa
= aux
;
108 u_int8_t myaddr
[ETHER_ADDR_LEN
];
112 /* dprintf(("Attaching %s...\n", device_xname(&sc->sc_dev)));*/
114 /* Set the address of the controller for easy access */
115 podulebus_shift_tag(pa
->pa_mod_t
, EA_8005_SHIFT
, &sc
->sc_8005
.sc_iot
);
116 bus_space_map(sc
->sc_8005
.sc_iot
, pa
->pa_mod_base
, /* XXX */ 0, 0,
117 &sc
->sc_8005
.sc_ioh
);
119 /* Get the Ethernet address from the device description string. */
120 if (pa
->pa_descr
== NULL
) {
121 printf(": No description for Ethernet address\n");
124 ptr
= strchr(pa
->pa_descr
, '(');
126 printf(": Ethernet address not found in description\n");
130 for (i
= 0; i
< ETHER_ADDR_LEN
; i
++) {
131 myaddr
[i
] = strtoul(ptr
, &ptr
, 16);
132 if (*ptr
++ != (i
== ETHER_ADDR_LEN
- 1 ? ')' : ':')) {
133 printf(": Bad Ethernet address found in "
140 seeq8005_attach(&sc
->sc_8005
, myaddr
, NULL
, 0, 0);
142 /* Claim a podule interrupt */
144 evcnt_attach_dynamic(&sc
->sc_intrcnt
, EVCNT_TYPE_INTR
, NULL
,
145 device_xname(self
), "intr");
146 sc
->sc_ih
= podulebus_irq_establish(pa
->pa_ih
, IPL_NET
, seeq8005intr
,
147 sc
, &sc
->sc_intrcnt
);