if_eb.c revision 1.1.2.2 1 1.1.2.2 bjh21 /* $NetBSD: if_eb.c,v 1.1.2.2 2001/03/25 01:09:37 bjh21 Exp $ */
2 1.1.2.2 bjh21
3 1.1.2.2 bjh21 /*
4 1.1.2.2 bjh21 * Copyright (c) 2000, 2001 Ben Harris
5 1.1.2.2 bjh21 * Copyright (c) 1995 Mark Brinicombe
6 1.1.2.2 bjh21 * All rights reserved.
7 1.1.2.2 bjh21 *
8 1.1.2.2 bjh21 * Redistribution and use in source and binary forms, with or without
9 1.1.2.2 bjh21 * modification, are permitted provided that the following conditions
10 1.1.2.2 bjh21 * are met:
11 1.1.2.2 bjh21 * 1. Redistributions of source code must retain the above copyright
12 1.1.2.2 bjh21 * notice, this list of conditions and the following disclaimer.
13 1.1.2.2 bjh21 * 2. Redistributions in binary form must reproduce the above copyright
14 1.1.2.2 bjh21 * notice, this list of conditions and the following disclaimer in the
15 1.1.2.2 bjh21 * documentation and/or other materials provided with the distribution.
16 1.1.2.2 bjh21 * 3. All advertising materials mentioning features or use of this software
17 1.1.2.2 bjh21 * must display the following acknowledgement:
18 1.1.2.2 bjh21 * This product includes software developed by Mark Brinicombe.
19 1.1.2.2 bjh21 * 4. The name of the company nor the name of the author may be used to
20 1.1.2.2 bjh21 * endorse or promote products derived from this software without specific
21 1.1.2.2 bjh21 * prior written permission.
22 1.1.2.2 bjh21 *
23 1.1.2.2 bjh21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
24 1.1.2.2 bjh21 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 1.1.2.2 bjh21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.1.2.2 bjh21 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 1.1.2.2 bjh21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 1.1.2.2 bjh21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 1.1.2.2 bjh21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1.2.2 bjh21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1.2.2 bjh21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1.2.2 bjh21 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1.2.2 bjh21 * SUCH DAMAGE.
34 1.1.2.2 bjh21 */
35 1.1.2.2 bjh21 /*
36 1.1.2.2 bjh21 * if_eb.c - EtherB device driver
37 1.1.2.2 bjh21 */
38 1.1.2.2 bjh21
39 1.1.2.2 bjh21 #include <sys/param.h>
40 1.1.2.2 bjh21
41 1.1.2.2 bjh21 __RCSID("$NetBSD: if_eb.c,v 1.1.2.2 2001/03/25 01:09:37 bjh21 Exp $");
42 1.1.2.2 bjh21
43 1.1.2.2 bjh21 #include <sys/device.h>
44 1.1.2.2 bjh21 #include <sys/socket.h>
45 1.1.2.2 bjh21 #include <sys/systm.h>
46 1.1.2.2 bjh21
47 1.1.2.2 bjh21 #include <machine/bus.h>
48 1.1.2.2 bjh21 #include <machine/intr.h>
49 1.1.2.2 bjh21
50 1.1.2.2 bjh21 #include <net/if.h>
51 1.1.2.2 bjh21 #include <net/if_ether.h>
52 1.1.2.2 bjh21
53 1.1.2.2 bjh21 #include <dev/podulebus/podulebus.h>
54 1.1.2.2 bjh21 #include <dev/podulebus/podules.h>
55 1.1.2.2 bjh21
56 1.1.2.2 bjh21 #include <dev/podulebus/if_ebreg.h>
57 1.1.2.2 bjh21 #include <dev/ic/seeq8005var.h>
58 1.1.2.2 bjh21
59 1.1.2.2 bjh21 /*
60 1.1.2.2 bjh21 * per-line info and status
61 1.1.2.2 bjh21 */
62 1.1.2.2 bjh21
63 1.1.2.2 bjh21 struct eb_softc {
64 1.1.2.2 bjh21 struct seeq8005_softc sc_8005;
65 1.1.2.2 bjh21 void *sc_ih;
66 1.1.2.2 bjh21 struct evcnt sc_intrcnt;
67 1.1.2.2 bjh21 };
68 1.1.2.2 bjh21
69 1.1.2.2 bjh21 /*
70 1.1.2.2 bjh21 * prototypes
71 1.1.2.2 bjh21 */
72 1.1.2.2 bjh21
73 1.1.2.2 bjh21 int ebprobe(struct device *, struct cfdata *, void *);
74 1.1.2.2 bjh21 void ebattach(struct device *, struct device *, void *);
75 1.1.2.2 bjh21
76 1.1.2.2 bjh21 /* driver structure for autoconf */
77 1.1.2.2 bjh21
78 1.1.2.2 bjh21 struct cfattach eb_ca = {
79 1.1.2.2 bjh21 sizeof(struct eb_softc), ebprobe, ebattach
80 1.1.2.2 bjh21 };
81 1.1.2.2 bjh21
82 1.1.2.2 bjh21 /*
83 1.1.2.2 bjh21 * Probe routine.
84 1.1.2.2 bjh21 */
85 1.1.2.2 bjh21
86 1.1.2.2 bjh21 /*
87 1.1.2.2 bjh21 * Probe for the ether3 podule.
88 1.1.2.2 bjh21 */
89 1.1.2.2 bjh21
90 1.1.2.2 bjh21 int
91 1.1.2.2 bjh21 ebprobe(struct device *parent, struct cfdata *cf, void *aux)
92 1.1.2.2 bjh21 {
93 1.1.2.2 bjh21 struct podulebus_attach_args *pa = aux;
94 1.1.2.2 bjh21
95 1.1.2.2 bjh21 if (matchpodule(pa, MANUFACTURER_ANT, PODULE_ANT_ETHERB, -1) == 0)
96 1.1.2.2 bjh21 return 0;
97 1.1.2.2 bjh21
98 1.1.2.2 bjh21 return 1;
99 1.1.2.2 bjh21 }
100 1.1.2.2 bjh21
101 1.1.2.2 bjh21
102 1.1.2.2 bjh21 /*
103 1.1.2.2 bjh21 * Attach podule.
104 1.1.2.2 bjh21 */
105 1.1.2.2 bjh21
106 1.1.2.2 bjh21 void
107 1.1.2.2 bjh21 ebattach(struct device *parent, struct device *self, void *aux)
108 1.1.2.2 bjh21 {
109 1.1.2.2 bjh21 struct eb_softc *sc = (void *)self;
110 1.1.2.2 bjh21 struct podulebus_attach_args *pa = aux;
111 1.1.2.2 bjh21 u_int8_t myaddr[ETHER_ADDR_LEN];
112 1.1.2.2 bjh21
113 1.1.2.2 bjh21 /* dprintf(("Attaching %s...\n", sc->sc_dev.dv_xname));*/
114 1.1.2.2 bjh21
115 1.1.2.2 bjh21 /* Set the address of the controller for easy access */
116 1.1.2.2 bjh21 podulebus_shift_tag(pa->pa_mod_t, EB_8004_SHIFT, &sc->sc_8005.sc_iot);
117 1.1.2.2 bjh21 bus_space_map(sc->sc_8005.sc_iot, pa->pa_mod_base + EB_8004_BASE,
118 1.1.2.2 bjh21 /* XXX */ 0, 0, &sc->sc_8005.sc_ioh);
119 1.1.2.2 bjh21
120 1.1.2.2 bjh21 /*
121 1.1.2.2 bjh21 * Build the address from the machine id.
122 1.1.2.2 bjh21 */
123 1.1.2.2 bjh21 netslot_ea(myaddr);
124 1.1.2.2 bjh21
125 1.1.2.2 bjh21 printf(":");
126 1.1.2.2 bjh21 seeq8005_attach(&sc->sc_8005, myaddr, NULL, 0, 0);
127 1.1.2.2 bjh21
128 1.1.2.2 bjh21 /* Claim a podule interrupt */
129 1.1.2.2 bjh21
130 1.1.2.2 bjh21 evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, NULL,
131 1.1.2.2 bjh21 self->dv_xname, "intr");
132 1.1.2.2 bjh21 sc->sc_ih = podulebus_irq_establish(pa->pa_ih, IPL_NET, seeq8005intr,
133 1.1.2.2 bjh21 sc, &sc->sc_intrcnt);
134 1.1.2.2 bjh21 }
135 1.1.2.2 bjh21
136 1.1.2.2 bjh21 /* End of if_eb.c */
137