if_we_isa.c revision 1.4 1 1.4 lukem /* $NetBSD: if_we_isa.c,v 1.4 2001/11/13 08:01:21 lukem Exp $ */
2 1.1 jdolecek
3 1.1 jdolecek /*-
4 1.1 jdolecek * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 1.1 jdolecek * All rights reserved.
6 1.1 jdolecek *
7 1.1 jdolecek * This code is derived from software contributed to The NetBSD Foundation
8 1.1 jdolecek * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 1.1 jdolecek * NASA Ames Research Center.
10 1.1 jdolecek *
11 1.1 jdolecek * Redistribution and use in source and binary forms, with or without
12 1.1 jdolecek * modification, are permitted provided that the following conditions
13 1.1 jdolecek * are met:
14 1.1 jdolecek * 1. Redistributions of source code must retain the above copyright
15 1.1 jdolecek * notice, this list of conditions and the following disclaimer.
16 1.1 jdolecek * 2. Redistributions in binary form must reproduce the above copyright
17 1.1 jdolecek * notice, this list of conditions and the following disclaimer in the
18 1.1 jdolecek * documentation and/or other materials provided with the distribution.
19 1.1 jdolecek * 3. All advertising materials mentioning features or use of this software
20 1.1 jdolecek * must display the following acknowledgement:
21 1.1 jdolecek * This product includes software developed by the NetBSD
22 1.1 jdolecek * Foundation, Inc. and its contributors.
23 1.1 jdolecek * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.1 jdolecek * contributors may be used to endorse or promote products derived
25 1.1 jdolecek * from this software without specific prior written permission.
26 1.1 jdolecek *
27 1.1 jdolecek * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.1 jdolecek * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.1 jdolecek * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.1 jdolecek * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.1 jdolecek * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.1 jdolecek * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.1 jdolecek * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.1 jdolecek * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.1 jdolecek * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.1 jdolecek * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.1 jdolecek * POSSIBILITY OF SUCH DAMAGE.
38 1.1 jdolecek */
39 1.1 jdolecek
40 1.1 jdolecek /*
41 1.1 jdolecek * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
42 1.1 jdolecek * adapters.
43 1.1 jdolecek *
44 1.1 jdolecek * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
45 1.1 jdolecek *
46 1.1 jdolecek * Copyright (C) 1993, David Greenman. This software may be used, modified,
47 1.1 jdolecek * copied, distributed, and sold, in both source and binary form provided that
48 1.1 jdolecek * the above copyright and these terms are retained. Under no circumstances is
49 1.1 jdolecek * the author responsible for the proper functioning of this software, nor does
50 1.1 jdolecek * the author assume any responsibility for damages incurred with its use.
51 1.1 jdolecek */
52 1.1 jdolecek
53 1.1 jdolecek /*
54 1.1 jdolecek * Device driver for the Western Digital/SMC 8003 and 8013 series,
55 1.1 jdolecek * and the SMC Elite Ultra (8216).
56 1.1 jdolecek */
57 1.4 lukem
58 1.4 lukem #include <sys/cdefs.h>
59 1.4 lukem __KERNEL_RCSID(0, "$NetBSD: if_we_isa.c,v 1.4 2001/11/13 08:01:21 lukem Exp $");
60 1.1 jdolecek
61 1.1 jdolecek #include <sys/param.h>
62 1.1 jdolecek #include <sys/systm.h>
63 1.1 jdolecek #include <sys/device.h>
64 1.1 jdolecek #include <sys/socket.h>
65 1.1 jdolecek #include <sys/mbuf.h>
66 1.1 jdolecek #include <sys/syslog.h>
67 1.1 jdolecek
68 1.1 jdolecek #include <net/if.h>
69 1.1 jdolecek #include <net/if_dl.h>
70 1.1 jdolecek #include <net/if_types.h>
71 1.1 jdolecek #include <net/if_media.h>
72 1.1 jdolecek
73 1.1 jdolecek #include <net/if_ether.h>
74 1.1 jdolecek
75 1.1 jdolecek #include <machine/bus.h>
76 1.1 jdolecek #include <machine/bswap.h>
77 1.1 jdolecek #include <machine/intr.h>
78 1.1 jdolecek
79 1.1 jdolecek #include <dev/isa/isareg.h>
80 1.1 jdolecek #include <dev/isa/isavar.h>
81 1.1 jdolecek
82 1.1 jdolecek #include <dev/ic/dp8390reg.h>
83 1.1 jdolecek #include <dev/ic/dp8390var.h>
84 1.1 jdolecek #include <dev/ic/wereg.h>
85 1.1 jdolecek #include <dev/ic/wevar.h>
86 1.1 jdolecek
87 1.1 jdolecek #ifndef __BUS_SPACE_HAS_STREAM_METHODS
88 1.1 jdolecek #define bus_space_read_region_stream_2 bus_space_read_region_2
89 1.1 jdolecek #define bus_space_write_stream_2 bus_space_write_2
90 1.1 jdolecek #define bus_space_write_region_stream_2 bus_space_write_region_2
91 1.1 jdolecek #endif
92 1.1 jdolecek
93 1.1 jdolecek int we_isa_probe __P((struct device *, struct cfdata *, void *));
94 1.1 jdolecek void we_isa_attach __P((struct device *, struct device *, void *));
95 1.1 jdolecek
96 1.1 jdolecek struct cfattach we_isa_ca = {
97 1.1 jdolecek sizeof(struct we_softc), we_isa_probe, we_isa_attach
98 1.1 jdolecek };
99 1.1 jdolecek
100 1.1 jdolecek extern struct cfdriver we_cd;
101 1.1 jdolecek
102 1.1 jdolecek static const char *we_params __P((bus_space_tag_t, bus_space_handle_t,
103 1.1 jdolecek u_int8_t *, bus_size_t *, int *, int *));
104 1.1 jdolecek
105 1.1 jdolecek static const int we_584_irq[] = {
106 1.1 jdolecek 9, 3, 5, 7, 10, 11, 15, 4,
107 1.1 jdolecek };
108 1.1 jdolecek #define NWE_584_IRQ (sizeof(we_584_irq) / sizeof(we_584_irq[0]))
109 1.1 jdolecek
110 1.1 jdolecek static const int we_790_irq[] = {
111 1.1 jdolecek IRQUNK, 9, 3, 5, 7, 10, 11, 15,
112 1.1 jdolecek };
113 1.1 jdolecek #define NWE_790_IRQ (sizeof(we_790_irq) / sizeof(we_790_irq[0]))
114 1.1 jdolecek
115 1.1 jdolecek /*
116 1.1 jdolecek * Delay needed when switching 16-bit access to shared memory.
117 1.1 jdolecek */
118 1.1 jdolecek #define WE_DELAY(wsc) delay(3)
119 1.1 jdolecek
120 1.1 jdolecek /*
121 1.1 jdolecek * Enable card RAM, and 16-bit access.
122 1.1 jdolecek */
123 1.1 jdolecek #define WE_MEM_ENABLE(wsc) \
124 1.1 jdolecek do { \
125 1.1 jdolecek if ((wsc)->sc_16bitp) \
126 1.1 jdolecek bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \
127 1.1 jdolecek WE_LAAR, (wsc)->sc_laar_proto | WE_LAAR_M16EN); \
128 1.1 jdolecek bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \
129 1.1 jdolecek WE_MSR, wsc->sc_msr_proto | WE_MSR_MENB); \
130 1.1 jdolecek WE_DELAY((wsc)); \
131 1.1 jdolecek } while (0)
132 1.1 jdolecek
133 1.1 jdolecek /*
134 1.1 jdolecek * Disable card RAM, and 16-bit access.
135 1.1 jdolecek */
136 1.1 jdolecek #define WE_MEM_DISABLE(wsc) \
137 1.1 jdolecek do { \
138 1.1 jdolecek bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \
139 1.1 jdolecek WE_MSR, (wsc)->sc_msr_proto); \
140 1.1 jdolecek if ((wsc)->sc_16bitp) \
141 1.1 jdolecek bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \
142 1.1 jdolecek WE_LAAR, (wsc)->sc_laar_proto); \
143 1.1 jdolecek WE_DELAY((wsc)); \
144 1.1 jdolecek } while (0)
145 1.1 jdolecek
146 1.1 jdolecek int
147 1.1 jdolecek we_isa_probe(parent, cf, aux)
148 1.1 jdolecek struct device *parent;
149 1.1 jdolecek struct cfdata *cf;
150 1.1 jdolecek void *aux;
151 1.1 jdolecek {
152 1.1 jdolecek struct isa_attach_args *ia = aux;
153 1.1 jdolecek bus_space_tag_t asict, memt;
154 1.1 jdolecek bus_space_handle_t asich, memh;
155 1.1 jdolecek bus_size_t memsize;
156 1.1 jdolecek int asich_valid, memh_valid;
157 1.1 jdolecek int i, is790, rv = 0;
158 1.1 jdolecek u_int8_t x, type;
159 1.1 jdolecek
160 1.1 jdolecek asict = ia->ia_iot;
161 1.1 jdolecek memt = ia->ia_memt;
162 1.1 jdolecek
163 1.1 jdolecek asich_valid = memh_valid = 0;
164 1.1 jdolecek
165 1.1 jdolecek /* Disallow wildcarded i/o addresses. */
166 1.1 jdolecek if (ia->ia_iobase == ISACF_PORT_DEFAULT)
167 1.1 jdolecek return (0);
168 1.1 jdolecek
169 1.1 jdolecek /* Disallow wildcarded mem address. */
170 1.1 jdolecek if (ia->ia_maddr == ISACF_IOMEM_DEFAULT)
171 1.1 jdolecek return (0);
172 1.1 jdolecek
173 1.1 jdolecek /* Attempt to map the device. */
174 1.1 jdolecek if (bus_space_map(asict, ia->ia_iobase, WE_NPORTS, 0, &asich))
175 1.1 jdolecek goto out;
176 1.1 jdolecek asich_valid = 1;
177 1.1 jdolecek
178 1.1 jdolecek #ifdef TOSH_ETHER
179 1.1 jdolecek bus_space_write_1(asict, asich, WE_MSR, WE_MSR_POW);
180 1.1 jdolecek #endif
181 1.1 jdolecek
182 1.1 jdolecek /*
183 1.1 jdolecek * Attempt to do a checksum over the station address PROM.
184 1.1 jdolecek * If it fails, it's probably not a WD/SMC board. There is
185 1.1 jdolecek * a problem with this, though. Some clone WD8003E boards
186 1.1 jdolecek * (e.g. Danpex) won't pass the checksum. In this case,
187 1.1 jdolecek * the checksum byte always seems to be 0.
188 1.1 jdolecek */
189 1.1 jdolecek for (x = 0, i = 0; i < 8; i++)
190 1.1 jdolecek x += bus_space_read_1(asict, asich, WE_PROM + i);
191 1.1 jdolecek
192 1.1 jdolecek if (x != WE_ROM_CHECKSUM_TOTAL) {
193 1.1 jdolecek /* Make sure it's an 8003E clone... */
194 1.1 jdolecek if (bus_space_read_1(asict, asich, WE_CARD_ID) !=
195 1.1 jdolecek WE_TYPE_WD8003E)
196 1.1 jdolecek goto out;
197 1.1 jdolecek
198 1.1 jdolecek /* Check the checksum byte. */
199 1.1 jdolecek if (bus_space_read_1(asict, asich, WE_PROM + 7) != 0)
200 1.1 jdolecek goto out;
201 1.1 jdolecek }
202 1.1 jdolecek
203 1.1 jdolecek /*
204 1.1 jdolecek * Reset the card to force it into a known state.
205 1.1 jdolecek */
206 1.1 jdolecek #ifdef TOSH_ETHER
207 1.1 jdolecek bus_space_write_1(asict, asich, WE_MSR, WE_MSR_RST | WE_MSR_POW);
208 1.1 jdolecek #else
209 1.1 jdolecek bus_space_write_1(asict, asich, WE_MSR, WE_MSR_RST);
210 1.1 jdolecek #endif
211 1.1 jdolecek delay(100);
212 1.1 jdolecek
213 1.1 jdolecek bus_space_write_1(asict, asich, WE_MSR,
214 1.1 jdolecek bus_space_read_1(asict, asich, WE_MSR) & ~WE_MSR_RST);
215 1.1 jdolecek
216 1.1 jdolecek /* Wait in case the card is reading it's EEPROM. */
217 1.1 jdolecek delay(5000);
218 1.1 jdolecek
219 1.1 jdolecek /*
220 1.1 jdolecek * Get parameters.
221 1.1 jdolecek */
222 1.1 jdolecek if (we_params(asict, asich, &type, &memsize, NULL, &is790) == NULL)
223 1.1 jdolecek goto out;
224 1.1 jdolecek
225 1.1 jdolecek /* Allow user to override probed value. */
226 1.1 jdolecek if (ia->ia_msize)
227 1.1 jdolecek memsize = ia->ia_msize;
228 1.1 jdolecek
229 1.1 jdolecek /* Attempt to map the memory space. */
230 1.1 jdolecek if (bus_space_map(memt, ia->ia_maddr, memsize, 0, &memh))
231 1.1 jdolecek goto out;
232 1.1 jdolecek memh_valid = 1;
233 1.1 jdolecek
234 1.1 jdolecek /*
235 1.1 jdolecek * If possible, get the assigned interrupt number from the card
236 1.1 jdolecek * and use it.
237 1.1 jdolecek */
238 1.1 jdolecek if (is790) {
239 1.1 jdolecek u_int8_t hwr;
240 1.1 jdolecek
241 1.1 jdolecek /* Assemble together the encoded interrupt number. */
242 1.1 jdolecek hwr = bus_space_read_1(asict, asich, WE790_HWR);
243 1.1 jdolecek bus_space_write_1(asict, asich, WE790_HWR,
244 1.1 jdolecek hwr | WE790_HWR_SWH);
245 1.1 jdolecek
246 1.1 jdolecek x = bus_space_read_1(asict, asich, WE790_GCR);
247 1.1 jdolecek i = ((x & WE790_GCR_IR2) >> 4) |
248 1.1 jdolecek ((x & (WE790_GCR_IR1|WE790_GCR_IR0)) >> 2);
249 1.1 jdolecek bus_space_write_1(asict, asich, WE790_HWR,
250 1.1 jdolecek hwr & ~WE790_HWR_SWH);
251 1.1 jdolecek
252 1.1 jdolecek if (ia->ia_irq != IRQUNK && ia->ia_irq != we_790_irq[i])
253 1.1 jdolecek printf("%s%d: overriding IRQ %d to %d\n",
254 1.1 jdolecek we_cd.cd_name, cf->cf_unit, ia->ia_irq,
255 1.1 jdolecek we_790_irq[i]);
256 1.1 jdolecek ia->ia_irq = we_790_irq[i];
257 1.1 jdolecek } else if (type & WE_SOFTCONFIG) {
258 1.1 jdolecek /* Assemble together the encoded interrupt number. */
259 1.1 jdolecek i = (bus_space_read_1(asict, asich, WE_ICR) & WE_ICR_IR2) |
260 1.1 jdolecek ((bus_space_read_1(asict, asich, WE_IRR) &
261 1.1 jdolecek (WE_IRR_IR0 | WE_IRR_IR1)) >> 5);
262 1.1 jdolecek
263 1.1 jdolecek if (ia->ia_irq != IRQUNK && ia->ia_irq != we_584_irq[i])
264 1.1 jdolecek printf("%s%d: overriding IRQ %d to %d\n",
265 1.1 jdolecek we_cd.cd_name, cf->cf_unit, ia->ia_irq,
266 1.1 jdolecek we_584_irq[i]);
267 1.1 jdolecek ia->ia_irq = we_584_irq[i];
268 1.1 jdolecek }
269 1.1 jdolecek
270 1.1 jdolecek /* So, we say we've found it! */
271 1.1 jdolecek ia->ia_iosize = WE_NPORTS;
272 1.1 jdolecek ia->ia_msize = memsize;
273 1.1 jdolecek rv = 1;
274 1.1 jdolecek
275 1.1 jdolecek out:
276 1.1 jdolecek if (asich_valid)
277 1.1 jdolecek bus_space_unmap(asict, asich, WE_NPORTS);
278 1.1 jdolecek if (memh_valid)
279 1.1 jdolecek bus_space_unmap(memt, memh, memsize);
280 1.1 jdolecek return (rv);
281 1.1 jdolecek }
282 1.1 jdolecek
283 1.1 jdolecek void
284 1.1 jdolecek we_isa_attach(parent, self, aux)
285 1.1 jdolecek struct device *parent, *self;
286 1.1 jdolecek void *aux;
287 1.1 jdolecek {
288 1.1 jdolecek struct we_softc *wsc = (struct we_softc *)self;
289 1.1 jdolecek struct dp8390_softc *sc = &wsc->sc_dp8390;
290 1.1 jdolecek struct isa_attach_args *ia = aux;
291 1.1 jdolecek bus_space_tag_t nict, asict, memt;
292 1.1 jdolecek bus_space_handle_t nich, asich, memh;
293 1.1 jdolecek const char *typestr;
294 1.1 jdolecek
295 1.1 jdolecek printf("\n");
296 1.1 jdolecek
297 1.1 jdolecek nict = asict = ia->ia_iot;
298 1.1 jdolecek memt = ia->ia_memt;
299 1.1 jdolecek
300 1.1 jdolecek /* Map the device. */
301 1.1 jdolecek if (bus_space_map(asict, ia->ia_iobase, WE_NPORTS, 0, &asich)) {
302 1.1 jdolecek printf("%s: can't map nic i/o space\n",
303 1.1 jdolecek sc->sc_dev.dv_xname);
304 1.1 jdolecek return;
305 1.1 jdolecek }
306 1.1 jdolecek
307 1.1 jdolecek if (bus_space_subregion(asict, asich, WE_NIC_OFFSET, WE_NIC_NPORTS,
308 1.1 jdolecek &nich)) {
309 1.1 jdolecek printf("%s: can't subregion i/o space\n",
310 1.1 jdolecek sc->sc_dev.dv_xname);
311 1.1 jdolecek return;
312 1.1 jdolecek }
313 1.1 jdolecek
314 1.1 jdolecek typestr = we_params(asict, asich, &wsc->sc_type, NULL,
315 1.1 jdolecek &wsc->sc_16bitp, &sc->is790);
316 1.1 jdolecek if (typestr == NULL) {
317 1.1 jdolecek printf("%s: where did the card go?\n", sc->sc_dev.dv_xname);
318 1.1 jdolecek return;
319 1.1 jdolecek }
320 1.1 jdolecek
321 1.1 jdolecek /*
322 1.1 jdolecek * Map memory space. Note we use the size that might have
323 1.1 jdolecek * been overridden by the user.
324 1.1 jdolecek */
325 1.1 jdolecek if (bus_space_map(memt, ia->ia_maddr, ia->ia_msize, 0, &memh)) {
326 1.1 jdolecek printf("%s: can't map shared memory\n",
327 1.1 jdolecek sc->sc_dev.dv_xname);
328 1.1 jdolecek return;
329 1.1 jdolecek }
330 1.1 jdolecek
331 1.1 jdolecek wsc->sc_asict = asict;
332 1.1 jdolecek wsc->sc_asich = asich;
333 1.1 jdolecek
334 1.1 jdolecek sc->sc_regt = nict;
335 1.1 jdolecek sc->sc_regh = nich;
336 1.1 jdolecek
337 1.1 jdolecek sc->sc_buft = memt;
338 1.1 jdolecek sc->sc_bufh = memh;
339 1.1 jdolecek
340 1.1 jdolecek wsc->sc_maddr = ia->ia_maddr;
341 1.1 jdolecek sc->mem_size = ia->ia_msize;
342 1.1 jdolecek
343 1.1 jdolecek /* Interface is always enabled. */
344 1.1 jdolecek sc->sc_enabled = 1;
345 1.1 jdolecek
346 1.1 jdolecek if (we_config(self, wsc, typestr))
347 1.1 jdolecek return;
348 1.1 jdolecek
349 1.1 jdolecek /*
350 1.1 jdolecek * Enable the configured interrupt.
351 1.1 jdolecek */
352 1.1 jdolecek if (sc->is790)
353 1.1 jdolecek bus_space_write_1(asict, asich, WE790_ICR,
354 1.1 jdolecek bus_space_read_1(asict, asich, WE790_ICR) |
355 1.1 jdolecek WE790_ICR_EIL);
356 1.1 jdolecek else if (wsc->sc_type & WE_SOFTCONFIG)
357 1.1 jdolecek bus_space_write_1(asict, asich, WE_IRR,
358 1.1 jdolecek bus_space_read_1(asict, asich, WE_IRR) | WE_IRR_IEN);
359 1.1 jdolecek else if (ia->ia_irq == IRQUNK) {
360 1.1 jdolecek printf("%s: can't wildcard IRQ on a %s\n",
361 1.1 jdolecek sc->sc_dev.dv_xname, typestr);
362 1.1 jdolecek return;
363 1.1 jdolecek }
364 1.1 jdolecek
365 1.1 jdolecek /* Establish interrupt handler. */
366 1.1 jdolecek wsc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
367 1.1 jdolecek IPL_NET, dp8390_intr, sc);
368 1.1 jdolecek if (wsc->sc_ih == NULL)
369 1.1 jdolecek printf("%s: can't establish interrupt\n", sc->sc_dev.dv_xname);
370 1.1 jdolecek }
371 1.1 jdolecek
372 1.1 jdolecek static const char *
373 1.1 jdolecek we_params(asict, asich, typep, memsizep, is16bitp, is790p)
374 1.1 jdolecek bus_space_tag_t asict;
375 1.1 jdolecek bus_space_handle_t asich;
376 1.1 jdolecek u_int8_t *typep;
377 1.1 jdolecek bus_size_t *memsizep;
378 1.1 jdolecek int *is16bitp, *is790p;
379 1.1 jdolecek {
380 1.1 jdolecek const char *typestr;
381 1.1 jdolecek bus_size_t memsize;
382 1.1 jdolecek int is16bit, is790;
383 1.1 jdolecek u_int8_t type;
384 1.1 jdolecek
385 1.1 jdolecek memsize = 8192;
386 1.1 jdolecek is16bit = is790 = 0;
387 1.1 jdolecek
388 1.1 jdolecek type = bus_space_read_1(asict, asich, WE_CARD_ID);
389 1.1 jdolecek switch (type) {
390 1.1 jdolecek case WE_TYPE_WD8003S:
391 1.1 jdolecek typestr = "WD8003S";
392 1.1 jdolecek break;
393 1.1 jdolecek case WE_TYPE_WD8003E:
394 1.1 jdolecek typestr = "WD8003E";
395 1.1 jdolecek break;
396 1.1 jdolecek case WE_TYPE_WD8003EB:
397 1.1 jdolecek typestr = "WD8003EB";
398 1.1 jdolecek break;
399 1.1 jdolecek case WE_TYPE_WD8003W:
400 1.1 jdolecek typestr = "WD8003W";
401 1.1 jdolecek break;
402 1.1 jdolecek case WE_TYPE_WD8013EBT:
403 1.1 jdolecek typestr = "WD8013EBT";
404 1.1 jdolecek memsize = 16384;
405 1.1 jdolecek is16bit = 1;
406 1.1 jdolecek break;
407 1.1 jdolecek case WE_TYPE_WD8013W:
408 1.1 jdolecek typestr = "WD8013W";
409 1.1 jdolecek memsize = 16384;
410 1.1 jdolecek is16bit = 1;
411 1.1 jdolecek break;
412 1.1 jdolecek case WE_TYPE_WD8013EP: /* also WD8003EP */
413 1.1 jdolecek if (bus_space_read_1(asict, asich, WE_ICR) & WE_ICR_16BIT) {
414 1.1 jdolecek is16bit = 1;
415 1.1 jdolecek memsize = 16384;
416 1.1 jdolecek typestr = "WD8013EP";
417 1.1 jdolecek } else
418 1.1 jdolecek typestr = "WD8003EP";
419 1.1 jdolecek break;
420 1.1 jdolecek case WE_TYPE_WD8013WC:
421 1.1 jdolecek typestr = "WD8013WC";
422 1.1 jdolecek memsize = 16384;
423 1.1 jdolecek is16bit = 1;
424 1.1 jdolecek break;
425 1.1 jdolecek case WE_TYPE_WD8013EBP:
426 1.1 jdolecek typestr = "WD8013EBP";
427 1.1 jdolecek memsize = 16384;
428 1.1 jdolecek is16bit = 1;
429 1.1 jdolecek break;
430 1.1 jdolecek case WE_TYPE_WD8013EPC:
431 1.1 jdolecek typestr = "WD8013EPC";
432 1.1 jdolecek memsize = 16384;
433 1.1 jdolecek is16bit = 1;
434 1.1 jdolecek break;
435 1.1 jdolecek case WE_TYPE_SMC8216C:
436 1.1 jdolecek case WE_TYPE_SMC8216T:
437 1.1 jdolecek {
438 1.1 jdolecek u_int8_t hwr;
439 1.1 jdolecek
440 1.1 jdolecek typestr = (type == WE_TYPE_SMC8216C) ?
441 1.1 jdolecek "SMC8216/SMC8216C" : "SMC8216T";
442 1.1 jdolecek
443 1.1 jdolecek hwr = bus_space_read_1(asict, asich, WE790_HWR);
444 1.1 jdolecek bus_space_write_1(asict, asich, WE790_HWR,
445 1.1 jdolecek hwr | WE790_HWR_SWH);
446 1.1 jdolecek switch (bus_space_read_1(asict, asich, WE790_RAR) &
447 1.1 jdolecek WE790_RAR_SZ64) {
448 1.1 jdolecek case WE790_RAR_SZ64:
449 1.1 jdolecek memsize = 65536;
450 1.1 jdolecek break;
451 1.1 jdolecek case WE790_RAR_SZ32:
452 1.1 jdolecek memsize = 32768;
453 1.1 jdolecek break;
454 1.1 jdolecek case WE790_RAR_SZ16:
455 1.1 jdolecek memsize = 16384;
456 1.1 jdolecek break;
457 1.1 jdolecek case WE790_RAR_SZ8:
458 1.1 jdolecek /* 8216 has 16K shared mem -- 8416 has 8K */
459 1.1 jdolecek typestr = (type == WE_TYPE_SMC8216C) ?
460 1.1 jdolecek "SMC8416C/SMC8416BT" : "SMC8416T";
461 1.1 jdolecek memsize = 8192;
462 1.1 jdolecek break;
463 1.1 jdolecek }
464 1.1 jdolecek bus_space_write_1(asict, asich, WE790_HWR, hwr);
465 1.1 jdolecek
466 1.1 jdolecek is16bit = 1;
467 1.1 jdolecek is790 = 1;
468 1.1 jdolecek break;
469 1.1 jdolecek }
470 1.1 jdolecek #ifdef TOSH_ETHER
471 1.1 jdolecek case WE_TYPE_TOSHIBA1:
472 1.1 jdolecek typestr = "Toshiba1";
473 1.1 jdolecek memsize = 32768;
474 1.1 jdolecek is16bit = 1;
475 1.1 jdolecek break;
476 1.1 jdolecek case WE_TYPE_TOSHIBA4:
477 1.1 jdolecek typestr = "Toshiba4";
478 1.1 jdolecek memsize = 32768;
479 1.1 jdolecek is16bit = 1;
480 1.1 jdolecek break;
481 1.1 jdolecek #endif
482 1.1 jdolecek default:
483 1.1 jdolecek /* Not one we recognize. */
484 1.1 jdolecek return (NULL);
485 1.1 jdolecek }
486 1.1 jdolecek
487 1.1 jdolecek /*
488 1.1 jdolecek * Make some adjustments to initial values depending on what is
489 1.1 jdolecek * found in the ICR.
490 1.1 jdolecek */
491 1.1 jdolecek if (is16bit && (type != WE_TYPE_WD8013EBT) &&
492 1.1 jdolecek #ifdef TOSH_ETHER
493 1.1 jdolecek (type != WE_TYPE_TOSHIBA1 && type != WE_TYPE_TOSHIBA4) &&
494 1.1 jdolecek #endif
495 1.1 jdolecek (bus_space_read_1(asict, asich, WE_ICR) & WE_ICR_16BIT) == 0) {
496 1.1 jdolecek is16bit = 0;
497 1.1 jdolecek memsize = 8192;
498 1.1 jdolecek }
499 1.1 jdolecek
500 1.1 jdolecek #ifdef WE_DEBUG
501 1.1 jdolecek {
502 1.1 jdolecek int i;
503 1.1 jdolecek
504 1.1 jdolecek printf("we_params: type = 0x%x, typestr = %s, is16bit = %d, "
505 1.1 jdolecek "memsize = %d\n", type, typestr, is16bit, memsize);
506 1.1 jdolecek for (i = 0; i < 8; i++)
507 1.1 jdolecek printf(" %d -> 0x%x\n", i,
508 1.1 jdolecek bus_space_read_1(asict, asich, i));
509 1.1 jdolecek }
510 1.1 jdolecek #endif
511 1.1 jdolecek
512 1.1 jdolecek if (typep != NULL)
513 1.1 jdolecek *typep = type;
514 1.1 jdolecek if (memsizep != NULL)
515 1.1 jdolecek *memsizep = memsize;
516 1.1 jdolecek if (is16bitp != NULL)
517 1.1 jdolecek *is16bitp = is16bit;
518 1.1 jdolecek if (is790p != NULL)
519 1.1 jdolecek *is790p = is790;
520 1.1 jdolecek return (typestr);
521 1.1 jdolecek }
522