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