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