if_ei.c revision 1.3.2.2 1 1.3.2.2 nathanw /* $NetBSD: if_ei.c,v 1.3.2.2 2002/01/08 00:31:31 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 * All rights reserved.
6 1.3.2.2 nathanw *
7 1.3.2.2 nathanw * Redistribution and use in source and binary forms, with or without
8 1.3.2.2 nathanw * modification, are permitted provided that the following conditions
9 1.3.2.2 nathanw * are met:
10 1.3.2.2 nathanw * 1. Redistributions of source code must retain the above copyright
11 1.3.2.2 nathanw * notice, this list of conditions and the following disclaimer.
12 1.3.2.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
13 1.3.2.2 nathanw * notice, this list of conditions and the following disclaimer in the
14 1.3.2.2 nathanw * documentation and/or other materials provided with the distribution.
15 1.3.2.2 nathanw * 3. The name of the author may not be used to endorse or promote products
16 1.3.2.2 nathanw * derived from this software without specific prior written permission.
17 1.3.2.2 nathanw *
18 1.3.2.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 1.3.2.2 nathanw * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 1.3.2.2 nathanw * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 1.3.2.2 nathanw * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 1.3.2.2 nathanw * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 1.3.2.2 nathanw * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 1.3.2.2 nathanw * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 1.3.2.2 nathanw * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 1.3.2.2 nathanw * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 1.3.2.2 nathanw * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 1.3.2.2 nathanw */
29 1.3.2.2 nathanw /*
30 1.3.2.2 nathanw * if_ei.c -- driver for Acorn AKA25 Ether1 card
31 1.3.2.2 nathanw */
32 1.3.2.2 nathanw /*
33 1.3.2.2 nathanw * This is not directly based on the arm32 ie driver, as that doesn't
34 1.3.2.2 nathanw * use the MI 82586 driver, and generally looks a mess (not to mention
35 1.3.2.2 nathanw * having dodgy copyright status). Let's try again.
36 1.3.2.2 nathanw */
37 1.3.2.2 nathanw
38 1.3.2.2 nathanw #include <sys/cdefs.h>
39 1.3.2.2 nathanw __KERNEL_RCSID(0, "$NetBSD: if_ei.c,v 1.3.2.2 2002/01/08 00:31:31 nathanw Exp $");
40 1.3.2.2 nathanw
41 1.3.2.2 nathanw #include <sys/param.h>
42 1.3.2.2 nathanw
43 1.3.2.2 nathanw #include <sys/device.h>
44 1.3.2.2 nathanw #include <sys/malloc.h>
45 1.3.2.2 nathanw #include <sys/reboot.h> /* For bootverbose */
46 1.3.2.2 nathanw #include <sys/socket.h>
47 1.3.2.2 nathanw #include <sys/syslog.h>
48 1.3.2.2 nathanw #include <sys/systm.h>
49 1.3.2.2 nathanw #include <net/if.h>
50 1.3.2.2 nathanw #include <net/if_ether.h>
51 1.3.2.2 nathanw #include <net/if_media.h>
52 1.3.2.2 nathanw #include <machine/bus.h>
53 1.3.2.2 nathanw #include <dev/ic/i82586reg.h>
54 1.3.2.2 nathanw #include <dev/ic/i82586var.h>
55 1.3.2.2 nathanw #include <dev/podulebus/podulebus.h>
56 1.3.2.2 nathanw #include <dev/podulebus/podules.h>
57 1.3.2.2 nathanw #include <dev/podulebus/if_eireg.h>
58 1.3.2.2 nathanw
59 1.3.2.2 nathanw /* Callbacks from the MI 82586 driver */
60 1.3.2.2 nathanw static void ei_hwreset(struct ie_softc *, int);
61 1.3.2.2 nathanw /* static void ei_hwinit(struct ie_softc *); */
62 1.3.2.2 nathanw static void ei_attn(struct ie_softc *, int);
63 1.3.2.2 nathanw static int ei_intrhook(struct ie_softc *, int);
64 1.3.2.2 nathanw
65 1.3.2.2 nathanw static void ei_copyin(struct ie_softc *, void *, int, size_t);
66 1.3.2.2 nathanw static void ei_copyout(struct ie_softc *, const void *, int, size_t);
67 1.3.2.2 nathanw static u_int16_t ei_read16(struct ie_softc *, int);
68 1.3.2.2 nathanw static void ei_write16(struct ie_softc *, int, u_int16_t);
69 1.3.2.2 nathanw static void ei_write24(struct ie_softc *, int, int);
70 1.3.2.2 nathanw
71 1.3.2.2 nathanw /* autoconfiguration glue */
72 1.3.2.2 nathanw static int ei_match(struct device *, struct cfdata *, void *);
73 1.3.2.2 nathanw static void ei_attach(struct device *, struct device *, void *);
74 1.3.2.2 nathanw
75 1.3.2.2 nathanw struct ei_softc {
76 1.3.2.2 nathanw struct ie_softc sc_ie;
77 1.3.2.2 nathanw bus_space_tag_t sc_ctl_t;
78 1.3.2.2 nathanw bus_space_handle_t sc_ctl_h;
79 1.3.2.2 nathanw bus_space_tag_t sc_mem_t;
80 1.3.2.2 nathanw bus_space_handle_t sc_mem_h;
81 1.3.2.2 nathanw bus_space_tag_t sc_rom_t;
82 1.3.2.2 nathanw bus_space_handle_t sc_rom_h;
83 1.3.2.2 nathanw u_int8_t sc_idrom[EI_ROMSIZE];
84 1.3.2.2 nathanw void *sc_ih;
85 1.3.2.2 nathanw struct evcnt sc_intrcnt;
86 1.3.2.2 nathanw };
87 1.3.2.2 nathanw
88 1.3.2.2 nathanw struct cfattach ei_ca = {
89 1.3.2.2 nathanw sizeof(struct ei_softc), ei_match, ei_attach
90 1.3.2.2 nathanw };
91 1.3.2.2 nathanw
92 1.3.2.2 nathanw static inline void
93 1.3.2.2 nathanw ei_setpage(struct ei_softc *sc, int page)
94 1.3.2.2 nathanw {
95 1.3.2.2 nathanw
96 1.3.2.2 nathanw bus_space_write_1(sc->sc_ctl_t, sc->sc_ctl_h, EI_PAGE, page);
97 1.3.2.2 nathanw }
98 1.3.2.2 nathanw
99 1.3.2.2 nathanw static inline void
100 1.3.2.2 nathanw ei_cli(struct ei_softc *sc)
101 1.3.2.2 nathanw {
102 1.3.2.2 nathanw
103 1.3.2.2 nathanw bus_space_write_1(sc->sc_ctl_t, sc->sc_ctl_h, EI_CONTROL, EI_CTL_CLI);
104 1.3.2.2 nathanw }
105 1.3.2.2 nathanw
106 1.3.2.2 nathanw static int
107 1.3.2.2 nathanw ei_match(struct device *parent, struct cfdata *cf, void *aux)
108 1.3.2.2 nathanw {
109 1.3.2.2 nathanw struct podulebus_attach_args *pa = aux;
110 1.3.2.2 nathanw
111 1.3.2.2 nathanw return IS_PODULE(pa, MANUFACTURER_ACORN, PODULE_ACORN_ETHER1);
112 1.3.2.2 nathanw }
113 1.3.2.2 nathanw
114 1.3.2.2 nathanw static void
115 1.3.2.2 nathanw ei_attach(struct device *parent, struct device *self, void *aux)
116 1.3.2.2 nathanw {
117 1.3.2.2 nathanw struct podulebus_attach_args *pa = aux;
118 1.3.2.2 nathanw struct ei_softc *sc = (struct ei_softc *)self;
119 1.3.2.2 nathanw int i;
120 1.3.2.2 nathanw char descr[16];
121 1.3.2.2 nathanw
122 1.3.2.2 nathanw /* Set up bus spaces */
123 1.3.2.2 nathanw sc->sc_ctl_t = sc->sc_mem_t = pa->pa_fast_t;
124 1.3.2.2 nathanw bus_space_map(pa->pa_fast_t, pa->pa_fast_base, EI_MEMOFF, 0,
125 1.3.2.2 nathanw &sc->sc_ctl_h);
126 1.3.2.2 nathanw bus_space_map(pa->pa_fast_t, pa->pa_fast_base + EI_MEMOFF,
127 1.3.2.2 nathanw EI_PAGESIZE * 2, 0, &sc->sc_mem_h);
128 1.3.2.2 nathanw sc->sc_rom_t = pa->pa_sync_t;
129 1.3.2.2 nathanw bus_space_map(pa->pa_sync_t, pa->pa_sync_base, EI_ROMSIZE, 0,
130 1.3.2.2 nathanw &sc->sc_rom_h);
131 1.3.2.2 nathanw
132 1.3.2.2 nathanw /* Set up callbacks */
133 1.3.2.2 nathanw sc->sc_ie.hwinit = NULL;
134 1.3.2.2 nathanw sc->sc_ie.intrhook = ei_intrhook;
135 1.3.2.2 nathanw sc->sc_ie.hwreset = ei_hwreset;
136 1.3.2.2 nathanw sc->sc_ie.chan_attn = ei_attn;
137 1.3.2.2 nathanw
138 1.3.2.2 nathanw sc->sc_ie.memcopyin = ei_copyin;
139 1.3.2.2 nathanw sc->sc_ie.memcopyout = ei_copyout;
140 1.3.2.2 nathanw
141 1.3.2.2 nathanw sc->sc_ie.ie_bus_barrier = NULL;
142 1.3.2.2 nathanw sc->sc_ie.ie_bus_read16 = ei_read16;
143 1.3.2.2 nathanw sc->sc_ie.ie_bus_write16 = ei_write16;
144 1.3.2.2 nathanw sc->sc_ie.ie_bus_write24 = ei_write24;
145 1.3.2.2 nathanw
146 1.3.2.2 nathanw sc->sc_ie.do_xmitnopchain = 0; /* Does it listen? */
147 1.3.2.2 nathanw
148 1.3.2.2 nathanw sc->sc_ie.sc_mediachange = NULL;
149 1.3.2.2 nathanw sc->sc_ie.sc_mediastatus = NULL;
150 1.3.2.2 nathanw
151 1.3.2.2 nathanw sc->sc_ie.bt = sc->sc_mem_t; /* XXX hope it doesn't use them */
152 1.3.2.2 nathanw sc->sc_ie.bh = sc->sc_mem_h;
153 1.3.2.2 nathanw
154 1.3.2.2 nathanw printf(":");
155 1.3.2.2 nathanw
156 1.3.2.2 nathanw /* All Ether1s are 64k (I believe) */
157 1.3.2.2 nathanw sc->sc_ie.sc_msize = EI_MEMSIZE;
158 1.3.2.2 nathanw
159 1.3.2.2 nathanw /* set up pointers to important on-card control structures */
160 1.3.2.2 nathanw sc->sc_ie.iscp = 0;
161 1.3.2.2 nathanw sc->sc_ie.scb = IE_ISCP_SZ;
162 1.3.2.2 nathanw sc->sc_ie.scp = sc->sc_ie.sc_msize + IE_SCP_ADDR - (1 << 24);
163 1.3.2.2 nathanw
164 1.3.2.2 nathanw sc->sc_ie.buf_area = sc->sc_ie.scb + IE_SCB_SZ;
165 1.3.2.2 nathanw sc->sc_ie.buf_area_sz =
166 1.3.2.2 nathanw sc->sc_ie.sc_msize - IE_ISCP_SZ - IE_SCB_SZ - IE_SCP_SZ;
167 1.3.2.2 nathanw
168 1.3.2.2 nathanw /* Wipe the whole of the card's memory */
169 1.3.2.2 nathanw for (i = 0; i < EI_NPAGES; i++) {
170 1.3.2.2 nathanw ei_setpage(sc, i);
171 1.3.2.2 nathanw bus_space_set_region_2(sc->sc_mem_t, sc->sc_mem_h,
172 1.3.2.2 nathanw 0, 0,EI_PAGESIZE / 2);
173 1.3.2.2 nathanw }
174 1.3.2.2 nathanw
175 1.3.2.2 nathanw /* set up pointers to key structures */
176 1.3.2.2 nathanw ei_write24(&sc->sc_ie, IE_SCP_ISCP((u_long)sc->sc_ie.scp),
177 1.3.2.2 nathanw (u_long) sc->sc_ie.iscp);
178 1.3.2.2 nathanw ei_write16(&sc->sc_ie, IE_ISCP_SCB((u_long)sc->sc_ie.iscp),
179 1.3.2.2 nathanw (u_long) sc->sc_ie.scb);
180 1.3.2.2 nathanw ei_write24(&sc->sc_ie, IE_ISCP_BASE((u_long)sc->sc_ie.iscp),
181 1.3.2.2 nathanw (u_long) sc->sc_ie.iscp);
182 1.3.2.2 nathanw
183 1.3.2.2 nathanw /* check if chip answers */
184 1.3.2.2 nathanw if (i82586_proberam(&sc->sc_ie) == 0) {
185 1.3.2.2 nathanw printf(" memory probe failed\n");
186 1.3.2.2 nathanw return;
187 1.3.2.2 nathanw }
188 1.3.2.2 nathanw
189 1.3.2.2 nathanw /* Read ROM */
190 1.3.2.2 nathanw bus_space_read_region_1(sc->sc_rom_t, sc->sc_rom_h, 0,
191 1.3.2.2 nathanw sc->sc_idrom, EI_ROMSIZE);
192 1.3.2.2 nathanw
193 1.3.2.2 nathanw snprintf(descr, 15, "AKA25 iss. %d", sc->sc_idrom[EI_ROM_HWREV]);
194 1.3.2.2 nathanw i82586_attach(&sc->sc_ie, descr, sc->sc_idrom + EI_ROM_EADDR,
195 1.3.2.2 nathanw NULL, 0, 0);
196 1.3.2.2 nathanw
197 1.3.2.2 nathanw evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, NULL,
198 1.3.2.2 nathanw self->dv_xname, "intr");
199 1.3.2.2 nathanw sc->sc_ih = podulebus_irq_establish(pa->pa_ih, IPL_NET, i82586_intr,
200 1.3.2.2 nathanw self, &sc->sc_intrcnt);
201 1.3.2.2 nathanw ei_cli(sc);
202 1.3.2.2 nathanw }
203 1.3.2.2 nathanw
204 1.3.2.2 nathanw static void
205 1.3.2.2 nathanw ei_hwreset(struct ie_softc *sc_ie, int why)
206 1.3.2.2 nathanw {
207 1.3.2.2 nathanw struct ei_softc *sc = (struct ei_softc *)sc_ie;
208 1.3.2.2 nathanw
209 1.3.2.2 nathanw bus_space_write_1(sc->sc_ctl_t, sc->sc_ctl_h, EI_CONTROL, EI_CTL_RST);
210 1.3.2.2 nathanw DELAY(1000);
211 1.3.2.2 nathanw bus_space_write_1(sc->sc_ctl_t, sc->sc_ctl_h, EI_CONTROL, 0);
212 1.3.2.2 nathanw DELAY(1000);
213 1.3.2.2 nathanw ei_cli(sc);
214 1.3.2.2 nathanw }
215 1.3.2.2 nathanw
216 1.3.2.2 nathanw static int
217 1.3.2.2 nathanw ei_intrhook(struct ie_softc *sc_ie, int why)
218 1.3.2.2 nathanw {
219 1.3.2.2 nathanw struct ei_softc *sc = (struct ei_softc *)sc_ie;
220 1.3.2.2 nathanw
221 1.3.2.2 nathanw switch (why) {
222 1.3.2.2 nathanw case INTR_EXIT:
223 1.3.2.2 nathanw case INTR_ACK:
224 1.3.2.2 nathanw ei_cli(sc);
225 1.3.2.2 nathanw break;
226 1.3.2.2 nathanw }
227 1.3.2.2 nathanw return 0;
228 1.3.2.2 nathanw }
229 1.3.2.2 nathanw
230 1.3.2.2 nathanw static void
231 1.3.2.2 nathanw ei_attn(struct ie_softc *sc_ie, int why)
232 1.3.2.2 nathanw {
233 1.3.2.2 nathanw struct ei_softc *sc = (void *)sc_ie;
234 1.3.2.2 nathanw
235 1.3.2.2 nathanw bus_space_write_1(sc->sc_ctl_t, sc->sc_ctl_h, EI_CONTROL, EI_CTL_CA);
236 1.3.2.2 nathanw }
237 1.3.2.2 nathanw
238 1.3.2.2 nathanw /*
239 1.3.2.2 nathanw * Various access functions to allow the MI 82586 driver to get at the
240 1.3.2.2 nathanw * board's memory. All memory accesses must go through these, as
241 1.3.2.2 nathanw * nothing else knows how to manipulate the page register. Note that
242 1.3.2.2 nathanw * all addresses and lengths passed in are in bytes of actual data.
243 1.3.2.2 nathanw * The bus_space functions deal in words, though, so we have to
244 1.3.2.2 nathanw * convert on the way through.
245 1.3.2.2 nathanw */
246 1.3.2.2 nathanw
247 1.3.2.2 nathanw static void
248 1.3.2.2 nathanw ei_copyin(struct ie_softc *sc_ie, void *dest, int src, size_t size)
249 1.3.2.2 nathanw {
250 1.3.2.2 nathanw struct ei_softc *sc = (struct ei_softc *)sc_ie;
251 1.3.2.2 nathanw int cnt, s, extra_byte;
252 1.3.2.2 nathanw u_int16_t *wptr;
253 1.3.2.2 nathanw
254 1.3.2.2 nathanw #ifdef DIAGNOSTIC
255 1.3.2.2 nathanw if (src % 2 != 0 || !ALIGNED_POINTER(dest, u_int16_t))
256 1.3.2.2 nathanw panic("%s: unaligned copyin", sc_ie->sc_dev.dv_xname);
257 1.3.2.2 nathanw #endif
258 1.3.2.2 nathanw wptr = dest;
259 1.3.2.2 nathanw extra_byte = size % 2;
260 1.3.2.2 nathanw size -= extra_byte;
261 1.3.2.2 nathanw while (size > 0) {
262 1.3.2.2 nathanw cnt = EI_PAGESIZE - src % EI_PAGESIZE;
263 1.3.2.2 nathanw if (cnt > size)
264 1.3.2.2 nathanw cnt = size;
265 1.3.2.2 nathanw s = splnet();
266 1.3.2.2 nathanw ei_setpage(sc, ei_atop(src));
267 1.3.2.2 nathanw /* bus ops are in words */
268 1.3.2.2 nathanw bus_space_read_region_2(sc->sc_mem_t, sc->sc_mem_h,
269 1.3.2.2 nathanw ei_atopo(src) / 2, wptr, cnt / 2);
270 1.3.2.2 nathanw splx(s);
271 1.3.2.2 nathanw src += cnt;
272 1.3.2.2 nathanw wptr += cnt / 2;
273 1.3.2.2 nathanw size -= cnt;
274 1.3.2.2 nathanw }
275 1.3.2.2 nathanw if (extra_byte) {
276 1.3.2.2 nathanw /* Do we need to be this careful? */
277 1.3.2.2 nathanw s = splnet();
278 1.3.2.2 nathanw ei_setpage(sc, ei_atop(src));
279 1.3.2.2 nathanw *(u_int8_t *)wptr =
280 1.3.2.2 nathanw bus_space_read_2(sc->sc_mem_t, sc->sc_mem_h,
281 1.3.2.2 nathanw ei_atopo(src) / 2) & 0xff;
282 1.3.2.2 nathanw splx(s);
283 1.3.2.2 nathanw }
284 1.3.2.2 nathanw }
285 1.3.2.2 nathanw
286 1.3.2.2 nathanw static void
287 1.3.2.2 nathanw ei_copyout(struct ie_softc *sc_ie, const void *src, int dest, size_t size)
288 1.3.2.2 nathanw {
289 1.3.2.2 nathanw struct ei_softc *sc = (struct ei_softc *)sc_ie;
290 1.3.2.2 nathanw int cnt, s;
291 1.3.2.2 nathanw const u_int16_t *wptr;
292 1.3.2.2 nathanw u_int16_t *bounce = NULL;
293 1.3.2.2 nathanw
294 1.3.2.2 nathanw #ifdef DIAGNOSTIC
295 1.3.2.2 nathanw if (dest % 2 != 0)
296 1.3.2.2 nathanw panic("%s: unaligned copyout", sc_ie->sc_dev.dv_xname);
297 1.3.2.2 nathanw #endif
298 1.3.2.2 nathanw if (!ALIGNED_POINTER(src, u_int16_t)) {
299 1.3.2.2 nathanw MALLOC(bounce, u_int16_t *, size, M_DEVBUF, M_NOWAIT);
300 1.3.2.2 nathanw if (bounce == NULL)
301 1.3.2.2 nathanw panic("%s: no memory to align copyout",
302 1.3.2.2 nathanw sc_ie->sc_dev.dv_xname);
303 1.3.2.2 nathanw memcpy(bounce, src, size);
304 1.3.2.2 nathanw src = bounce;
305 1.3.2.2 nathanw }
306 1.3.2.2 nathanw wptr = src;
307 1.3.2.2 nathanw if (size % 2 != 0)
308 1.3.2.2 nathanw size++; /* This is safe, since the buffer is 16bit aligned */
309 1.3.2.2 nathanw while (size > 0) {
310 1.3.2.2 nathanw cnt = EI_PAGESIZE - dest % EI_PAGESIZE;
311 1.3.2.2 nathanw if (cnt > size)
312 1.3.2.2 nathanw cnt = size;
313 1.3.2.2 nathanw s = splnet();
314 1.3.2.2 nathanw ei_setpage(sc, ei_atop(dest));
315 1.3.2.2 nathanw /* bus ops are in words */
316 1.3.2.2 nathanw bus_space_write_region_2(sc->sc_mem_t, sc->sc_mem_h,
317 1.3.2.2 nathanw ei_atopo(dest) / 2, wptr, cnt / 2);
318 1.3.2.2 nathanw splx(s);
319 1.3.2.2 nathanw wptr += cnt / 2;
320 1.3.2.2 nathanw dest += cnt;
321 1.3.2.2 nathanw size -= cnt;
322 1.3.2.2 nathanw }
323 1.3.2.2 nathanw if (bounce != NULL)
324 1.3.2.2 nathanw FREE(bounce, M_DEVBUF);
325 1.3.2.2 nathanw }
326 1.3.2.2 nathanw
327 1.3.2.2 nathanw static u_int16_t
328 1.3.2.2 nathanw ei_read16(struct ie_softc *sc_ie, int addr)
329 1.3.2.2 nathanw {
330 1.3.2.2 nathanw struct ei_softc *sc = (struct ei_softc *)sc_ie;
331 1.3.2.2 nathanw int result, s;
332 1.3.2.2 nathanw
333 1.3.2.2 nathanw #ifdef DIAGNOSTIC
334 1.3.2.2 nathanw if (addr % 2 != 0)
335 1.3.2.2 nathanw panic("%s: unaligned read16", sc_ie->sc_dev.dv_xname);
336 1.3.2.2 nathanw #endif
337 1.3.2.2 nathanw s = splnet();
338 1.3.2.2 nathanw ei_setpage(sc, ei_atop(addr));
339 1.3.2.2 nathanw result = bus_space_read_2(sc->sc_mem_t, sc->sc_mem_h,
340 1.3.2.2 nathanw ei_atopo(addr) / 2);
341 1.3.2.2 nathanw splx(s);
342 1.3.2.2 nathanw return result;
343 1.3.2.2 nathanw }
344 1.3.2.2 nathanw
345 1.3.2.2 nathanw static void
346 1.3.2.2 nathanw ei_write16(struct ie_softc *sc_ie, int addr, u_int16_t value)
347 1.3.2.2 nathanw {
348 1.3.2.2 nathanw struct ei_softc *sc = (struct ei_softc *)sc_ie;
349 1.3.2.2 nathanw int s;
350 1.3.2.2 nathanw
351 1.3.2.2 nathanw #ifdef DIAGNOSTIC
352 1.3.2.2 nathanw if (addr % 2 != 0)
353 1.3.2.2 nathanw panic("%s: unaligned write16", sc_ie->sc_dev.dv_xname);
354 1.3.2.2 nathanw #endif
355 1.3.2.2 nathanw s = splnet();
356 1.3.2.2 nathanw ei_setpage(sc, ei_atop(addr));
357 1.3.2.2 nathanw bus_space_write_2(sc->sc_mem_t, sc->sc_mem_h, ei_atopo(addr) / 2,
358 1.3.2.2 nathanw value);
359 1.3.2.2 nathanw splx(s);
360 1.3.2.2 nathanw }
361 1.3.2.2 nathanw
362 1.3.2.2 nathanw static void
363 1.3.2.2 nathanw ei_write24(struct ie_softc *sc_ie, int addr, int value)
364 1.3.2.2 nathanw {
365 1.3.2.2 nathanw int s;
366 1.3.2.2 nathanw
367 1.3.2.2 nathanw #ifdef DIAGNOSTIC
368 1.3.2.2 nathanw if (addr % 2 != 0)
369 1.3.2.2 nathanw panic("%s: unaligned write24", sc_ie->sc_dev.dv_xname);
370 1.3.2.2 nathanw #endif
371 1.3.2.2 nathanw s = splnet();
372 1.3.2.2 nathanw ei_write16(sc_ie, addr, value & 0xffff);
373 1.3.2.2 nathanw ei_write16(sc_ie, addr + 2, (value >> 16) & 0xff);
374 1.3.2.2 nathanw splx(s);
375 1.3.2.2 nathanw }
376 1.3.2.2 nathanw
377