This source file includes following definitions.
- le_lebuffer_wrcsr
- le_lebuffer_rdcsr
- lematch_lebuffer
- leattach_lebuffer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 #include "bpfilter.h"
42
43 #include <sys/cdefs.h>
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 #include <sys/malloc.h>
51
52 #include <net/if.h>
53 #include <net/if_media.h>
54
55 #ifdef INET
56 #include <netinet/in.h>
57 #include <netinet/if_ether.h>
58 #endif
59
60 #include <machine/bus.h>
61 #include <machine/intr.h>
62 #include <machine/autoconf.h>
63
64 #include <dev/sbus/sbusvar.h>
65 #include <dev/sbus/lebuffervar.h>
66
67 #include <dev/ic/am7990reg.h>
68 #include <dev/ic/am7990var.h>
69
70
71
72
73 #define LEREG1_RDP 0
74 #define LEREG1_RAP 2
75
76 struct le_softc {
77 struct am7990_softc sc_am7990;
78 bus_space_tag_t sc_bustag;
79 bus_dma_tag_t sc_dmatag;
80 bus_space_handle_t sc_reg;
81 };
82
83
84 int lematch_lebuffer(struct device *, void *, void *);
85 void leattach_lebuffer(struct device *, struct device *, void *);
86
87 struct cfattach le_lebuffer_ca = {
88 sizeof(struct le_softc), lematch_lebuffer, leattach_lebuffer
89 };
90
91 extern struct cfdriver le_cd;
92
93 struct cfdriver lebuffer_cd = {
94 NULL, "lebuffer", DV_DULL
95 };
96
97 void le_lebuffer_wrcsr(struct am7990_softc *, u_int16_t, u_int16_t);
98 u_int16_t le_lebuffer_rdcsr(struct am7990_softc *, u_int16_t);
99
100 void
101 le_lebuffer_wrcsr(struct am7990_softc *sc, u_int16_t port, u_int16_t val)
102 {
103 struct le_softc *lesc = (struct le_softc *)sc;
104
105 bus_space_write_2(lesc->sc_bustag, lesc->sc_reg, LEREG1_RAP, port);
106 bus_space_barrier(lesc->sc_bustag, lesc->sc_reg, LEREG1_RAP, 2,
107 BUS_SPACE_BARRIER_WRITE);
108 bus_space_write_2(lesc->sc_bustag, lesc->sc_reg, LEREG1_RDP, val);
109 bus_space_barrier(lesc->sc_bustag, lesc->sc_reg, LEREG1_RDP, 2,
110 BUS_SPACE_BARRIER_WRITE);
111
112 #if defined(SUN4M)
113
114
115
116
117
118 if (CPU_ISSUN4M) {
119 volatile u_int16_t discard;
120 discard = bus_space_read_2(lesc->sc_bustag, lesc->sc_reg,
121 LEREG1_RDP);
122 }
123 #endif
124 }
125
126 u_int16_t
127 le_lebuffer_rdcsr(struct am7990_softc *sc, u_int16_t port)
128 {
129 struct le_softc *lesc = (struct le_softc *)sc;
130
131 bus_space_write_2(lesc->sc_bustag, lesc->sc_reg, LEREG1_RAP, port);
132 bus_space_barrier(lesc->sc_bustag, lesc->sc_reg, LEREG1_RAP, 2,
133 BUS_SPACE_BARRIER_WRITE);
134 return (bus_space_read_2(lesc->sc_bustag, lesc->sc_reg, LEREG1_RDP));
135 }
136
137 int
138 lematch_lebuffer(struct device *parent, void *vcf, void *aux)
139 {
140 struct sbus_attach_args *sa = aux;
141 struct cfdata *cf = vcf;
142
143 return (strcmp(cf->cf_driver->cd_name, sa->sa_name) == 0);
144 }
145
146
147 void
148 leattach_lebuffer(struct device *parent, struct device *self, void *aux)
149 {
150 struct sbus_attach_args *sa = aux;
151 struct le_softc *lesc = (struct le_softc *)self;
152 struct am7990_softc *sc = &lesc->sc_am7990;
153 struct lebuf_softc *lebuf = (struct lebuf_softc *)parent;
154
155 extern void myetheraddr(u_char *);
156
157 lesc->sc_bustag = sa->sa_bustag;
158 lesc->sc_dmatag = sa->sa_dmatag;
159
160 if (sbus_bus_map(sa->sa_bustag,
161 sa->sa_slot, sa->sa_offset, sa->sa_size,
162 0, 0, &lesc->sc_reg)) {
163 printf(": cannot map registers\n");
164 return;
165 }
166
167 sc->sc_mem = lebuf->sc_buffer;
168 sc->sc_memsize = lebuf->sc_bufsiz;
169 sc->sc_addr = 0;
170 lebuf->attached = 1;
171
172
173 sc->sc_conf3 = getpropint(sa->sa_node, "busmaster-regval",
174 LE_C3_BSWP | LE_C3_ACON | LE_C3_BCON);
175
176 myetheraddr(sc->sc_arpcom.ac_enaddr);
177
178 sc->sc_copytodesc = am7990_copytobuf_contig;
179 sc->sc_copyfromdesc = am7990_copyfrombuf_contig;
180 sc->sc_copytobuf = am7990_copytobuf_contig;
181 sc->sc_copyfrombuf = am7990_copyfrombuf_contig;
182 sc->sc_zerobuf = am7990_zerobuf_contig;
183
184 sc->sc_rdcsr = le_lebuffer_rdcsr;
185 sc->sc_wrcsr = le_lebuffer_wrcsr;
186
187 am7990_config(&lesc->sc_am7990);
188
189
190 if (sa->sa_nintr != 0)
191 (void)bus_intr_establish(lesc->sc_bustag, sa->sa_pri,
192 IPL_NET, 0, am7990_intr, sc, self->dv_xname);
193 }