if_ai.c revision 1.34 1 1.34 msaitoh /* $NetBSD: if_ai.c,v 1.34 2019/04/09 05:24:07 msaitoh Exp $ */
2 1.1 pk
3 1.1 pk /*-
4 1.1 pk * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 1.1 pk * All rights reserved.
6 1.1 pk *
7 1.1 pk * This code is derived from software contributed to The NetBSD Foundation
8 1.1 pk * by Rafal K. Boni.
9 1.1 pk *
10 1.1 pk * Redistribution and use in source and binary forms, with or without
11 1.1 pk * modification, are permitted provided that the following conditions
12 1.1 pk * are met:
13 1.1 pk * 1. Redistributions of source code must retain the above copyright
14 1.1 pk * notice, this list of conditions and the following disclaimer.
15 1.1 pk * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 pk * notice, this list of conditions and the following disclaimer in the
17 1.1 pk * documentation and/or other materials provided with the distribution.
18 1.1 pk *
19 1.1 pk * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 pk * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 pk * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 pk * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 pk * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 pk * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 pk * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 pk * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 pk * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 pk * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 pk * POSSIBILITY OF SUCH DAMAGE.
30 1.1 pk */
31 1.12 lukem
32 1.12 lukem #include <sys/cdefs.h>
33 1.34 msaitoh __KERNEL_RCSID(0, "$NetBSD: if_ai.c,v 1.34 2019/04/09 05:24:07 msaitoh Exp $");
34 1.1 pk
35 1.1 pk #include <sys/param.h>
36 1.1 pk #include <sys/systm.h>
37 1.1 pk #include <sys/mbuf.h>
38 1.1 pk #include <sys/errno.h>
39 1.1 pk #include <sys/device.h>
40 1.1 pk #include <sys/protosw.h>
41 1.1 pk #include <sys/socket.h>
42 1.1 pk
43 1.1 pk #include <net/if.h>
44 1.1 pk #include <net/if_dl.h>
45 1.1 pk #include <net/if_types.h>
46 1.1 pk #include <net/if_media.h>
47 1.1 pk #include <net/if_ether.h>
48 1.1 pk
49 1.26 ad #include <sys/cpu.h>
50 1.26 ad #include <sys/bus.h>
51 1.26 ad #include <sys/intr.h>
52 1.1 pk
53 1.1 pk #include <dev/isa/isareg.h>
54 1.1 pk #include <dev/isa/isavar.h>
55 1.1 pk
56 1.1 pk #include <dev/ic/i82586reg.h>
57 1.1 pk #include <dev/ic/i82586var.h>
58 1.1 pk #include <dev/isa/if_aireg.h>
59 1.1 pk
60 1.1 pk #ifdef AI_DEBUG
61 1.1 pk #define DPRINTF(x) printf x
62 1.1 pk #else
63 1.2 pk #define DPRINTF(x)
64 1.1 pk #endif
65 1.1 pk
66 1.1 pk struct ai_softc {
67 1.1 pk struct ie_softc sc_ie;
68 1.1 pk
69 1.1 pk bus_space_tag_t sc_regt; /* space tag for registers */
70 1.1 pk bus_space_handle_t sc_regh; /* space handle for registers */
71 1.1 pk
72 1.34 msaitoh uint8_t card_rev;
73 1.34 msaitoh uint8_t card_type;
74 1.1 pk
75 1.2 pk void *sc_ih; /* interrupt handle */
76 1.1 pk };
77 1.1 pk
78 1.34 msaitoh static const char *ai_names[] = {
79 1.1 pk "StarLAN 10",
80 1.1 pk "EN100",
81 1.1 pk "StarLAN Fiber",
82 1.1 pk };
83 1.1 pk
84 1.1 pk /* Functions required by the i82586 MI driver */
85 1.20 perry static void ai_reset(struct ie_softc *, int);
86 1.20 perry static void ai_atten(struct ie_softc *, int);
87 1.1 pk
88 1.20 perry static void ai_copyin(struct ie_softc *, void *, int, size_t);
89 1.20 perry static void ai_copyout(struct ie_softc *, const void *, int, size_t);
90 1.2 pk
91 1.34 msaitoh static uint16_t ai_read_16(struct ie_softc *, int);
92 1.34 msaitoh static void ai_write_16(struct ie_softc *, int, uint16_t);
93 1.20 perry static void ai_write_24(struct ie_softc *, int, int);
94 1.2 pk
95 1.1 pk /* Local support functions */
96 1.20 perry static int check_ie_present(struct ie_softc*, bus_space_tag_t,
97 1.20 perry bus_space_handle_t, bus_size_t);
98 1.20 perry static int ai_find_mem_size(struct ai_softc*, bus_space_tag_t,
99 1.20 perry bus_size_t);
100 1.1 pk
101 1.34 msaitoh static int ai_match(device_t, cfdata_t, void *);
102 1.34 msaitoh static void ai_attach(device_t, device_t, void *);
103 1.1 pk
104 1.1 pk /*
105 1.1 pk * AT&T StarLan support routines
106 1.1 pk */
107 1.1 pk static void
108 1.29 dsl ai_reset(struct ie_softc *sc, int why)
109 1.1 pk {
110 1.34 msaitoh struct ai_softc *asc = (struct ai_softc *)sc;
111 1.1 pk
112 1.2 pk switch (why) {
113 1.2 pk case CHIP_PROBE:
114 1.34 msaitoh /* Reset to chip to see if it responds */
115 1.2 pk bus_space_write_1(asc->sc_regt, asc->sc_regh, AI_RESET, 0);
116 1.2 pk DELAY(100);
117 1.2 pk break;
118 1.2 pk
119 1.2 pk case CARD_RESET:
120 1.2 pk /*
121 1.34 msaitoh * This takes around 10sec, and we can get
122 1.2 pk * by quite well w/out it...
123 1.2 pk */
124 1.2 pk break;
125 1.2 pk }
126 1.1 pk }
127 1.1 pk
128 1.1 pk static void
129 1.25 christos ai_atten(struct ie_softc *sc, int why)
130 1.1 pk {
131 1.34 msaitoh struct ai_softc *asc = (struct ai_softc *)sc;
132 1.34 msaitoh
133 1.34 msaitoh bus_space_write_1(asc->sc_regt, asc->sc_regh, AI_ATTN, 0);
134 1.1 pk }
135 1.1 pk
136 1.1 pk static void
137 1.34 msaitoh ai_copyin(struct ie_softc *sc, void *dst, int offset, size_t size)
138 1.1 pk {
139 1.2 pk int dribble;
140 1.34 msaitoh uint8_t *bptr = dst;
141 1.1 pk
142 1.2 pk bus_space_barrier(sc->bt, sc->bh, offset, size,
143 1.34 msaitoh BUS_SPACE_BARRIER_READ);
144 1.1 pk
145 1.2 pk if (offset % 2) {
146 1.2 pk *bptr = bus_space_read_1(sc->bt, sc->bh, offset);
147 1.2 pk offset++; bptr++; size--;
148 1.2 pk }
149 1.2 pk
150 1.2 pk dribble = size % 2;
151 1.34 msaitoh bus_space_read_region_2(sc->bt, sc->bh, offset, (uint16_t *)bptr,
152 1.34 msaitoh size >> 1);
153 1.2 pk
154 1.2 pk if (dribble) {
155 1.2 pk bptr += size - 1;
156 1.2 pk offset += size - 1;
157 1.2 pk *bptr = bus_space_read_1(sc->bt, sc->bh, offset);
158 1.2 pk }
159 1.1 pk }
160 1.1 pk
161 1.1 pk static void
162 1.34 msaitoh ai_copyout(struct ie_softc *sc, const void *src, int offset, size_t size)
163 1.1 pk {
164 1.2 pk int dribble;
165 1.2 pk int osize = size;
166 1.2 pk int ooffset = offset;
167 1.34 msaitoh const uint8_t *bptr = src;
168 1.2 pk
169 1.2 pk if (offset % 2) {
170 1.2 pk bus_space_write_1(sc->bt, sc->bh, offset, *bptr);
171 1.2 pk offset++; bptr++; size--;
172 1.2 pk }
173 1.2 pk
174 1.2 pk dribble = size % 2;
175 1.22 christos bus_space_write_region_2(sc->bt, sc->bh, offset,
176 1.34 msaitoh (const uint16_t *)bptr, size >> 1);
177 1.2 pk if (dribble) {
178 1.2 pk bptr += size - 1;
179 1.2 pk offset += size - 1;
180 1.2 pk bus_space_write_1(sc->bt, sc->bh, offset, *bptr);
181 1.2 pk }
182 1.1 pk
183 1.2 pk bus_space_barrier(sc->bt, sc->bh, ooffset, osize,
184 1.34 msaitoh BUS_SPACE_BARRIER_WRITE);
185 1.1 pk }
186 1.1 pk
187 1.34 msaitoh static uint16_t
188 1.34 msaitoh ai_read_16(struct ie_softc *sc, int offset)
189 1.1 pk {
190 1.34 msaitoh
191 1.1 pk bus_space_barrier(sc->bt, sc->bh, offset, 2, BUS_SPACE_BARRIER_READ);
192 1.1 pk return bus_space_read_2(sc->bt, sc->bh, offset);
193 1.1 pk }
194 1.1 pk
195 1.1 pk static void
196 1.34 msaitoh ai_write_16(struct ie_softc *sc, int offset, uint16_t value)
197 1.1 pk {
198 1.34 msaitoh
199 1.1 pk bus_space_write_2(sc->bt, sc->bh, offset, value);
200 1.1 pk bus_space_barrier(sc->bt, sc->bh, offset, 2, BUS_SPACE_BARRIER_WRITE);
201 1.1 pk }
202 1.1 pk
203 1.1 pk static void
204 1.34 msaitoh ai_write_24(struct ie_softc *sc, int offset, int addr)
205 1.1 pk {
206 1.34 msaitoh
207 1.1 pk bus_space_write_4(sc->bt, sc->bh, offset, addr +
208 1.34 msaitoh (u_long)sc->sc_maddr - (u_long)sc->sc_iobase);
209 1.1 pk bus_space_barrier(sc->bt, sc->bh, offset, 4, BUS_SPACE_BARRIER_WRITE);
210 1.1 pk }
211 1.1 pk
212 1.1 pk int
213 1.32 cegger ai_match(device_t parent, cfdata_t cf, void *aux)
214 1.1 pk {
215 1.2 pk int rv = 0;
216 1.34 msaitoh uint8_t val, type;
217 1.2 pk bus_size_t memsize;
218 1.3 pk bus_space_tag_t iot;
219 1.2 pk bus_space_handle_t ioh;
220 1.2 pk struct isa_attach_args * const ia = aux;
221 1.3 pk struct ai_softc asc;
222 1.2 pk
223 1.14 thorpej if (ia->ia_nio < 1)
224 1.34 msaitoh return 0;
225 1.14 thorpej if (ia->ia_niomem < 1)
226 1.34 msaitoh return 0;
227 1.14 thorpej if (ia->ia_nirq < 1)
228 1.34 msaitoh return 0;
229 1.14 thorpej
230 1.14 thorpej if (ISA_DIRECT_CONFIG(ia))
231 1.34 msaitoh return 0;
232 1.2 pk
233 1.2 pk /* Punt if wildcarded port, IRQ or memory address */
234 1.19 drochner if (ia->ia_io[0].ir_addr == ISA_UNKNOWN_PORT ||
235 1.19 drochner ia->ia_iomem[0].ir_addr == ISA_UNKNOWN_IOMEM ||
236 1.19 drochner ia->ia_irq[0].ir_irq == ISA_UNKNOWN_IRQ) {
237 1.2 pk DPRINTF((
238 1.2 pk "ai_match: wildcarded IRQ, IOAddr, or memAddr, skipping\n"));
239 1.34 msaitoh return 0;
240 1.2 pk }
241 1.2 pk
242 1.3 pk iot = ia->ia_iot;
243 1.3 pk
244 1.2 pk /*
245 1.2 pk * This probe is horribly bad, but I have no info on this card other
246 1.2 pk * than the former driver, and it was just as bad!
247 1.2 pk */
248 1.14 thorpej if (bus_space_map(iot, ia->ia_io[0].ir_addr,
249 1.2 pk AI_IOSIZE, 0, &ioh) != 0) {
250 1.2 pk
251 1.2 pk DPRINTF(("ai_match: cannot map %d IO ports @ 0x%x\n",
252 1.2 pk AI_IOSIZE, ia->ia_iobase));
253 1.34 msaitoh return 0;
254 1.2 pk }
255 1.2 pk
256 1.3 pk val = bus_space_read_1(iot, ioh, AI_REVISION);
257 1.2 pk
258 1.2 pk type = SL_BOARD(val);
259 1.5 pk if (type != SL10_BOARD && type != EN100_BOARD &&
260 1.2 pk type != SLFIBER_BOARD) {
261 1.2 pk DPRINTF(("ai_match: unknown board code 0x%02x @ 0x%x\n",
262 1.2 pk type, ia->ia_iobase));
263 1.2 pk goto out;
264 1.2 pk }
265 1.1 pk
266 1.3 pk /*
267 1.3 pk * Fill in just about enough of our local `ai_softc' for
268 1.3 pk * ai_find_mem_size() to do its job.
269 1.3 pk */
270 1.11 thorpej memset(&asc, 0, sizeof asc);
271 1.3 pk asc.sc_regt = iot;
272 1.3 pk asc.sc_regh = ioh;
273 1.1 pk
274 1.14 thorpej if ((memsize = ai_find_mem_size(&asc, ia->ia_memt,
275 1.14 thorpej ia->ia_iomem[0].ir_addr)) == 0) {
276 1.2 pk DPRINTF(("ai_match: cannot size memory of board @ 0x%x\n",
277 1.14 thorpej ia->ia_io[0].ir_addr));
278 1.3 pk goto out;
279 1.2 pk }
280 1.1 pk
281 1.14 thorpej if (ia->ia_iomem[0].ir_size != 0 &&
282 1.14 thorpej ia->ia_iomem[0].ir_size != memsize) {
283 1.2 pk DPRINTF((
284 1.2 pk "ai_match: memsize of board @ 0x%x doesn't match config\n",
285 1.2 pk ia->ia_iobase));
286 1.2 pk goto out;
287 1.2 pk }
288 1.2 pk
289 1.2 pk rv = 1;
290 1.14 thorpej
291 1.14 thorpej ia->ia_nio = 1;
292 1.14 thorpej ia->ia_io[0].ir_size = AI_IOSIZE;
293 1.14 thorpej
294 1.14 thorpej ia->ia_niomem = 1;
295 1.14 thorpej ia->ia_iomem[0].ir_size = memsize;
296 1.14 thorpej
297 1.14 thorpej ia->ia_nirq = 1;
298 1.14 thorpej
299 1.14 thorpej ia->ia_ndrq = 0;
300 1.14 thorpej
301 1.2 pk DPRINTF(("ai_match: found board @ 0x%x\n", ia->ia_iobase));
302 1.1 pk
303 1.1 pk out:
304 1.3 pk bus_space_unmap(iot, ioh, AI_IOSIZE);
305 1.2 pk return rv;
306 1.1 pk }
307 1.1 pk
308 1.1 pk void
309 1.32 cegger ai_attach(device_t parent, device_t self, void *aux)
310 1.1 pk {
311 1.33 tsutsui struct ai_softc *asc = device_private(self);
312 1.2 pk struct ie_softc *sc = &asc->sc_ie;
313 1.2 pk struct isa_attach_args *ia = aux;
314 1.34 msaitoh uint8_t val = 0;
315 1.2 pk bus_space_handle_t ioh, memh;
316 1.34 msaitoh uint8_t ethaddr[ETHER_ADDR_LEN];
317 1.5 pk char name[80];
318 1.2 pk
319 1.33 tsutsui sc->sc_dev = self;
320 1.33 tsutsui
321 1.14 thorpej if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr,
322 1.14 thorpej ia->ia_io[0].ir_size, 0, &ioh) != 0) {
323 1.2 pk DPRINTF(("\n%s: can't map i/o space 0x%x-0x%x\n",
324 1.33 tsutsui device_xname(self),
325 1.14 thorpej ia->ia_io[0].ir_addr, ia->ia_io[0].ir_addr +
326 1.14 thorpej ia->ia_io[0].ir_size - 1));
327 1.2 pk return;
328 1.2 pk }
329 1.2 pk
330 1.14 thorpej if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr,
331 1.14 thorpej ia->ia_iomem[0].ir_size, 0, &memh) != 0) {
332 1.2 pk DPRINTF(("\n%s: can't map iomem space 0x%x-0x%x\n",
333 1.33 tsutsui device_xname(self),
334 1.14 thorpej ia->ia_iomem[0].ir_addr, ia->ia_iomem[0].ir_addr +
335 1.14 thorpej ia->ia_iomem[0].ir_size - 1));
336 1.14 thorpej bus_space_unmap(ia->ia_iot, ioh, ia->ia_io[0].ir_size);
337 1.2 pk return;
338 1.2 pk }
339 1.2 pk
340 1.2 pk asc->sc_regt = ia->ia_iot;
341 1.2 pk asc->sc_regh = ioh;
342 1.2 pk
343 1.2 pk sc->hwinit = NULL;
344 1.2 pk sc->intrhook = NULL;
345 1.2 pk sc->hwreset = ai_reset;
346 1.2 pk sc->chan_attn = ai_atten;
347 1.9 bjh21
348 1.9 bjh21 sc->ie_bus_barrier = NULL;
349 1.2 pk
350 1.2 pk sc->memcopyin = ai_copyin;
351 1.2 pk sc->memcopyout = ai_copyout;
352 1.2 pk sc->ie_bus_read16 = ai_read_16;
353 1.2 pk sc->ie_bus_write16 = ai_write_16;
354 1.2 pk sc->ie_bus_write24 = ai_write_24;
355 1.2 pk
356 1.2 pk sc->do_xmitnopchain = 0;
357 1.2 pk
358 1.2 pk sc->sc_mediachange = NULL;
359 1.2 pk sc->sc_mediastatus = NULL;
360 1.2 pk
361 1.2 pk sc->bt = ia->ia_memt;
362 1.2 pk sc->bh = memh;
363 1.2 pk
364 1.2 pk /* Map i/o space. */
365 1.14 thorpej sc->sc_msize = ia->ia_iomem[0].ir_size;
366 1.7 augustss sc->sc_maddr = (void *)memh;
367 1.7 augustss sc->sc_iobase = (char *)sc->sc_maddr + sc->sc_msize - (1 << 24);
368 1.2 pk
369 1.34 msaitoh /* Set up pointers to important on-card control structures */
370 1.2 pk sc->iscp = 0;
371 1.2 pk sc->scb = IE_ISCP_SZ;
372 1.2 pk sc->scp = sc->sc_msize + IE_SCP_ADDR - (1 << 24);
373 1.2 pk
374 1.2 pk sc->buf_area = sc->scb + IE_SCB_SZ;
375 1.2 pk sc->buf_area_sz = sc->sc_msize - IE_ISCP_SZ - IE_SCB_SZ - IE_SCP_SZ;
376 1.2 pk
377 1.34 msaitoh /* Zero card memory */
378 1.2 pk bus_space_set_region_1(sc->bt, sc->bh, 0, 0, sc->sc_msize);
379 1.2 pk
380 1.34 msaitoh /* Set card to 16-bit bus mode */
381 1.21 perry bus_space_write_1(sc->bt, sc->bh, IE_SCP_BUS_USE((u_long)sc->scp),
382 1.34 msaitoh IE_SYSBUS_16BIT);
383 1.2 pk
384 1.34 msaitoh /* Set up pointers to key structures */
385 1.34 msaitoh ai_write_24(sc, IE_SCP_ISCP((u_long)sc->scp), (u_long)sc->iscp);
386 1.34 msaitoh ai_write_16(sc, IE_ISCP_SCB((u_long)sc->iscp), (u_long)sc->scb);
387 1.34 msaitoh ai_write_24(sc, IE_ISCP_BASE((u_long)sc->iscp), (u_long)sc->iscp);
388 1.2 pk
389 1.34 msaitoh /* Flush setup of pointers, check if chip answers */
390 1.2 pk bus_space_barrier(sc->bt, sc->bh, 0, sc->sc_msize,
391 1.34 msaitoh BUS_SPACE_BARRIER_WRITE);
392 1.2 pk if (!i82586_proberam(sc)) {
393 1.2 pk DPRINTF(("\n%s: can't talk to i82586!\n",
394 1.33 tsutsui device_xname(self)));
395 1.14 thorpej bus_space_unmap(ia->ia_iot, ioh, ia->ia_io[0].ir_size);
396 1.14 thorpej bus_space_unmap(ia->ia_memt, memh, ia->ia_iomem[0].ir_size);
397 1.2 pk return;
398 1.2 pk }
399 1.2 pk
400 1.2 pk val = bus_space_read_1(asc->sc_regt, asc->sc_regh, AI_REVISION);
401 1.2 pk asc->card_rev = SL_REV(val);
402 1.2 pk asc->card_type = SL_BOARD(val) - 1;
403 1.18 itojun snprintf(name, sizeof(name), "%s, rev. %d",
404 1.18 itojun ai_names[asc->card_type], asc->card_rev);
405 1.2 pk
406 1.5 pk i82586_attach(sc, name, ethaddr, NULL, 0, 0);
407 1.2 pk
408 1.14 thorpej asc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
409 1.14 thorpej IST_EDGE, IPL_NET, i82586_intr, sc);
410 1.2 pk if (asc->sc_ih == NULL) {
411 1.2 pk DPRINTF(("\n%s: can't establish interrupt\n",
412 1.33 tsutsui device_xname(self)));
413 1.2 pk }
414 1.1 pk }
415 1.1 pk
416 1.1 pk /*
417 1.1 pk * Divine the memory size of this board.
418 1.1 pk * Better hope there's nothing important hiding just below the card...
419 1.1 pk */
420 1.1 pk static int
421 1.29 dsl ai_find_mem_size(struct ai_softc* asc, bus_space_tag_t memt, bus_size_t maddr)
422 1.1 pk {
423 1.1 pk int size;
424 1.1 pk bus_space_handle_t memh;
425 1.34 msaitoh struct ie_softc *sc = &asc->sc_ie;
426 1.1 pk
427 1.1 pk for (size = 65536; size >= 16384; size -= 16384) {
428 1.2 pk if (bus_space_map(memt, maddr, size, 0, &memh) == 0) {
429 1.2 pk size = check_ie_present(sc, memt, maddr, size);
430 1.2 pk bus_space_unmap(memt, memh, size);
431 1.2 pk
432 1.2 pk if (size != 0)
433 1.2 pk return size;
434 1.2 pk }
435 1.1 pk }
436 1.1 pk
437 1.34 msaitoh return 0;
438 1.1 pk }
439 1.1 pk
440 1.1 pk /*
441 1.1 pk * Check to see if there's an 82586 out there.
442 1.1 pk */
443 1.1 pk static int
444 1.34 msaitoh check_ie_present(struct ie_softc* sc, bus_space_tag_t memt,
445 1.34 msaitoh bus_space_handle_t memh, bus_size_t size)
446 1.1 pk {
447 1.34 msaitoh
448 1.2 pk sc->hwreset = ai_reset;
449 1.2 pk sc->chan_attn = ai_atten;
450 1.2 pk sc->ie_bus_read16 = ai_read_16;
451 1.2 pk sc->ie_bus_write16 = ai_write_16;
452 1.2 pk
453 1.2 pk sc->bt = memt;
454 1.2 pk sc->bh = memh;
455 1.7 augustss sc->sc_iobase = (char *)memh + size - (1 << 24);
456 1.2 pk
457 1.2 pk sc->scp = size + IE_SCP_ADDR - (1 << 24);
458 1.34 msaitoh bus_space_set_region_1(memt, memh, (u_long)sc->scp, 0, IE_SCP_SZ);
459 1.2 pk
460 1.2 pk sc->iscp = 0;
461 1.34 msaitoh bus_space_set_region_1(memt, memh, (u_long)sc->iscp, 0, IE_ISCP_SZ);
462 1.2 pk
463 1.2 pk sc->scb = IE_ISCP_SZ;
464 1.2 pk bus_space_set_region_1(memt, memh, sc->scb, 0, IE_SCB_SZ);
465 1.2 pk
466 1.34 msaitoh /* Set card to 16-bit bus mode */
467 1.13 fredette bus_space_write_1(sc->bt, sc->bh, IE_SCP_BUS_USE((u_long)sc->scp),
468 1.34 msaitoh IE_SYSBUS_16BIT);
469 1.2 pk
470 1.34 msaitoh /* Set up pointers to key structures */
471 1.34 msaitoh ai_write_24(sc, IE_SCP_ISCP((u_long)sc->scp), (u_long)sc->iscp);
472 1.34 msaitoh ai_write_16(sc, IE_ISCP_SCB((u_long)sc->iscp), (u_long)sc->scb);
473 1.34 msaitoh ai_write_24(sc, IE_ISCP_BASE((u_long)sc->iscp), (u_long)sc->iscp);
474 1.2 pk
475 1.34 msaitoh /* Flush setup of pointers, check if chip answers */
476 1.2 pk bus_space_barrier(sc->bt, sc->bh, 0, sc->sc_msize,
477 1.34 msaitoh BUS_SPACE_BARRIER_WRITE);
478 1.2 pk
479 1.2 pk if (!i82586_proberam(sc))
480 1.34 msaitoh return 0;
481 1.1 pk
482 1.34 msaitoh return size;
483 1.1 pk }
484 1.1 pk
485 1.33 tsutsui CFATTACH_DECL_NEW(ai, sizeof(struct ai_softc),
486 1.17 thorpej ai_match, ai_attach, NULL, NULL);
487