if_le.c revision 1.3 1 1.3 mycroft /* $NetBSD: if_le.c,v 1.3 1996/02/03 06:38:27 mycroft Exp $ */
2 1.1 chuck
3 1.1 chuck /*-
4 1.2 mycroft * Copyright (c) 1995 Charles M. Hannum. All rights reserved.
5 1.2 mycroft * Copyright (c) 1992, 1993
6 1.1 chuck * The Regents of the University of California. All rights reserved.
7 1.1 chuck *
8 1.2 mycroft * This code is derived from software contributed to Berkeley by
9 1.2 mycroft * Ralph Campbell and Rick Macklem.
10 1.2 mycroft *
11 1.1 chuck * Redistribution and use in source and binary forms, with or without
12 1.1 chuck * modification, are permitted provided that the following conditions
13 1.1 chuck * are met:
14 1.1 chuck * 1. Redistributions of source code must retain the above copyright
15 1.1 chuck * notice, this list of conditions and the following disclaimer.
16 1.1 chuck * 2. Redistributions in binary form must reproduce the above copyright
17 1.1 chuck * notice, this list of conditions and the following disclaimer in the
18 1.1 chuck * documentation and/or other materials provided with the distribution.
19 1.1 chuck * 3. All advertising materials mentioning features or use of this software
20 1.1 chuck * must display the following acknowledgement:
21 1.1 chuck * This product includes software developed by the University of
22 1.1 chuck * California, Berkeley and its contributors.
23 1.1 chuck * 4. Neither the name of the University nor the names of its contributors
24 1.1 chuck * may be used to endorse or promote products derived from this software
25 1.1 chuck * without specific prior written permission.
26 1.1 chuck *
27 1.1 chuck * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 1.1 chuck * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 1.1 chuck * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 1.1 chuck * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 1.1 chuck * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 1.1 chuck * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 1.1 chuck * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 1.1 chuck * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 1.1 chuck * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 1.1 chuck * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 1.1 chuck * SUCH DAMAGE.
38 1.1 chuck *
39 1.2 mycroft * @(#)if_le.c 8.2 (Berkeley) 11/16/93
40 1.1 chuck */
41 1.1 chuck
42 1.1 chuck #include "bpfilter.h"
43 1.1 chuck
44 1.1 chuck #include <sys/param.h>
45 1.1 chuck #include <sys/systm.h>
46 1.1 chuck #include <sys/mbuf.h>
47 1.2 mycroft #include <sys/syslog.h>
48 1.1 chuck #include <sys/socket.h>
49 1.2 mycroft #include <sys/device.h>
50 1.1 chuck
51 1.1 chuck #include <net/if.h>
52 1.1 chuck
53 1.1 chuck #ifdef INET
54 1.1 chuck #include <netinet/in.h>
55 1.1 chuck #include <netinet/if_ether.h>
56 1.1 chuck #endif
57 1.1 chuck
58 1.2 mycroft #include <vm/vm.h>
59 1.1 chuck
60 1.1 chuck #include <machine/cpu.h>
61 1.1 chuck #include <machine/pmap.h>
62 1.1 chuck
63 1.1 chuck #include <mvme68k/dev/iio.h>
64 1.2 mycroft #include <mvme68k/dev/pccreg.h>
65 1.1 chuck #include <mvme68k/dev/if_lereg.h>
66 1.2 mycroft #include <mvme68k/dev/if_levar.h>
67 1.2 mycroft #include <dev/ic/am7990reg.h>
68 1.2 mycroft #define LE_NEED_BUF_CONTIG
69 1.2 mycroft #include <dev/ic/am7990var.h>
70 1.2 mycroft
71 1.2 mycroft #define LE_SOFTC(unit) lecd.cd_devs[unit]
72 1.2 mycroft #define LE_DELAY(x) DELAY(x)
73 1.2 mycroft
74 1.2 mycroft int lematch __P((struct device *, void *, void *));
75 1.2 mycroft void leattach __P((struct device *, struct device *, void *));
76 1.2 mycroft int leintr __P((void *));
77 1.1 chuck
78 1.2 mycroft struct cfdriver lecd = {
79 1.2 mycroft NULL, "le", lematch, leattach, DV_IFNET, sizeof(struct le_softc)
80 1.1 chuck };
81 1.1 chuck
82 1.1 chuck void *ledatabuf; /* XXXCDC hack from pmap bootstrap */
83 1.1 chuck
84 1.2 mycroft integrate void
85 1.2 mycroft lewrcsr(sc, port, val)
86 1.2 mycroft struct le_softc *sc;
87 1.2 mycroft u_int16_t port, val;
88 1.1 chuck {
89 1.1 chuck register struct lereg1 *ler1 = sc->sc_r1;
90 1.1 chuck
91 1.2 mycroft ler1->ler1_rap = port;
92 1.2 mycroft ler1->ler1_rdp = val;
93 1.1 chuck }
94 1.1 chuck
95 1.2 mycroft integrate u_int16_t
96 1.2 mycroft lerdcsr(sc, port)
97 1.2 mycroft struct le_softc *sc;
98 1.2 mycroft u_int16_t port;
99 1.1 chuck {
100 1.1 chuck register struct lereg1 *ler1 = sc->sc_r1;
101 1.2 mycroft u_int16_t val;
102 1.1 chuck
103 1.2 mycroft ler1->ler1_rap = port;
104 1.2 mycroft val = ler1->ler1_rdp;
105 1.2 mycroft return (val);
106 1.1 chuck }
107 1.1 chuck
108 1.1 chuck int
109 1.2 mycroft lematch(parent, match, aux)
110 1.2 mycroft struct device *parent;
111 1.2 mycroft void *match, *aux;
112 1.1 chuck {
113 1.2 mycroft struct cfdata *cf = match;
114 1.1 chuck
115 1.2 mycroft return !badbaddr((caddr_t) IIO_CFLOC_ADDR(cf));
116 1.1 chuck }
117 1.1 chuck
118 1.1 chuck void
119 1.2 mycroft leattach(parent, self, aux)
120 1.2 mycroft struct device *parent, *self;
121 1.2 mycroft void *aux;
122 1.2 mycroft {
123 1.2 mycroft struct le_softc *sc = (void *)self;
124 1.2 mycroft struct cfdata *cf = self->dv_cfdata;
125 1.2 mycroft int pri = IIO_CFLOC_LEVEL(cf);
126 1.1 chuck
127 1.2 mycroft /* XXX the following declarations should be elsewhere */
128 1.2 mycroft extern void myetheraddr __P((u_char *));
129 1.1 chuck
130 1.2 mycroft iio_print(cf);
131 1.1 chuck
132 1.2 mycroft sc->sc_r1 = (struct lereg1 *)IIO_CFLOC_ADDR(cf);
133 1.2 mycroft sc->sc_mem = ledatabuf; /* XXX */
134 1.2 mycroft sc->sc_conf3 = LE_C3_BSWP;
135 1.2 mycroft sc->sc_addr = (u_long)sc->sc_mem;
136 1.2 mycroft sc->sc_memsize = 4 * NBPG; /* XXX */
137 1.2 mycroft
138 1.2 mycroft myetheraddr(sc->sc_arpcom.ac_enaddr);
139 1.2 mycroft
140 1.2 mycroft sc->sc_copytodesc = copytobuf_contig;
141 1.2 mycroft sc->sc_copyfromdesc = copyfrombuf_contig;
142 1.2 mycroft sc->sc_copytobuf = copytobuf_contig;
143 1.2 mycroft sc->sc_copyfrombuf = copyfrombuf_contig;
144 1.2 mycroft sc->sc_zerobuf = zerobuf_contig;
145 1.1 chuck
146 1.2 mycroft sc->sc_arpcom.ac_if.if_name = lecd.cd_name;
147 1.2 mycroft leconfig(sc);
148 1.1 chuck
149 1.2 mycroft pccintr_establish(PCCV_LE, leintr, pri, sc);
150 1.2 mycroft sys_pcc->le_int = pri | PCC_IENABLE;
151 1.1 chuck }
152 1.3 mycroft
153 1.3 mycroft #include <dev/ic/am7990.c>
154