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