if_tlp_pci.c revision 1.11 1 /* $NetBSD: if_tlp_pci.c,v 1.11 1999/09/17 21:55:01 thorpej Exp $ */
2
3 /*-
4 * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40 /*
41 * PCI bus front-end for the Digital Semiconductor ``Tulip'' (21x4x)
42 * Ethernet controller family driver.
43 */
44
45 #include "opt_inet.h"
46 #include "opt_ns.h"
47 #include "bpfilter.h"
48
49 #include <sys/param.h>
50 #include <sys/systm.h>
51 #include <sys/mbuf.h>
52 #include <sys/malloc.h>
53 #include <sys/kernel.h>
54 #include <sys/socket.h>
55 #include <sys/ioctl.h>
56 #include <sys/errno.h>
57 #include <sys/device.h>
58
59 #include <net/if.h>
60 #include <net/if_dl.h>
61 #include <net/if_media.h>
62 #include <net/if_ether.h>
63
64 #if NBPFILTER > 0
65 #include <net/bpf.h>
66 #endif
67
68 #ifdef INET
69 #include <netinet/in.h>
70 #include <netinet/if_inarp.h>
71 #endif
72
73 #ifdef NS
74 #include <netns/ns.h>
75 #include <netns/ns_if.h>
76 #endif
77
78 #include <machine/bus.h>
79 #include <machine/intr.h>
80
81 #include <dev/mii/miivar.h>
82
83 #include <dev/ic/tulipreg.h>
84 #include <dev/ic/tulipvar.h>
85
86 #include <dev/pci/pcivar.h>
87 #include <dev/pci/pcireg.h>
88 #include <dev/pci/pcidevs.h>
89
90 /*
91 * PCI configuration space registers used by the Tulip.
92 */
93 #define TULIP_PCI_IOBA 0x10 /* i/o mapped base */
94 #define TULIP_PCI_MMBA 0x14 /* memory mapped base */
95
96 struct tulip_pci_softc {
97 struct tulip_softc sc_tulip; /* real Tulip softc */
98
99 /* PCI-specific goo. */
100 void *sc_ih; /* interrupt handle */
101
102 pci_chipset_tag_t sc_pc; /* our PCI chipset */
103 pcitag_t sc_pcitag; /* our PCI tag */
104
105 int sc_flags; /* flags; see below */
106
107 LIST_HEAD(, tulip_pci_softc) sc_intrslaves;
108 LIST_ENTRY(tulip_pci_softc) sc_intrq;
109
110 /* Our {ROM,interrupt} master. */
111 struct tulip_pci_softc *sc_master;
112 };
113
114 /* sc_flags */
115 #define TULIP_PCI_SHAREDINTR 0x01 /* interrupt is shared */
116 #define TULIP_PCI_SLAVEINTR 0x02 /* interrupt is slave */
117 #define TULIP_PCI_SHAREDROM 0x04 /* ROM is shared */
118 #define TULIP_PCI_SLAVEROM 0x08 /* slave of shared ROM */
119
120 int tlp_pci_match __P((struct device *, struct cfdata *, void *));
121 void tlp_pci_attach __P((struct device *, struct device *, void *));
122
123 struct cfattach tlp_pci_ca = {
124 sizeof(struct tulip_pci_softc), tlp_pci_match, tlp_pci_attach,
125 };
126
127 const struct tulip_pci_product {
128 u_int32_t tpp_vendor; /* PCI vendor ID */
129 u_int32_t tpp_product; /* PCI product ID */
130 tulip_chip_t tpp_chip; /* base Tulip chip type */
131 } tlp_pci_products[] = {
132 #ifdef TLP_MATCH_21040
133 { PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21040,
134 TULIP_CHIP_21040 },
135 #endif
136 #ifdef TLP_MATCH_21041
137 { PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21041,
138 TULIP_CHIP_21041 },
139 #endif
140 #ifdef TLP_MATCH_21140
141 { PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21140,
142 TULIP_CHIP_21140 },
143 #endif
144 #ifdef TLP_MATCH_21142
145 { PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21142,
146 TULIP_CHIP_21142 },
147 #endif
148
149 { PCI_VENDOR_LITEON, PCI_PRODUCT_LITEON_82C168,
150 TULIP_CHIP_82C168 },
151
152 #if 0
153 /*
154 * Note: This is like a MX98715A with Wake-On-LAN and a
155 * 128-bit multicast hash table.
156 */
157 { PCI_VENDOR_LITEON, PCI_PRODUCT_LITEON_82C115,
158 TULIP_CHIP_82C115 },
159 #endif
160
161 #if 0
162 { PCI_VENDOR_MACRONIX, PCI_PRODUCT_MACRONIX_MX98713,
163 TULIP_CHIP_MX98713 },
164 { PCI_VENDOR_MACRONIX, PCI_PRODUCT_MACRONIX_MX987x5,
165 TULIP_CHIP_MX98715 },
166
167 { PCI_VENDOR_COMPEX, PCI_PRODUCT_COMPEX_RL100TX,
168 TULIP_CHIP_MX98713 },
169 #endif
170
171 { PCI_VENDOR_WINBOND, PCI_PRODUCT_WINBOND_W89C840F,
172 TULIP_CHIP_WB89C840F },
173 { PCI_VENDOR_COMPEX, PCI_PRODUCT_COMPEX_RL100ATX,
174 TULIP_CHIP_WB89C840F },
175
176 #if 0
177 { PCI_VENDOR_DAVICOM, PCI_PRODUCT_DAVICOM_DM9102,
178 TULIP_CHIP_DM9102 },
179
180 { PCI_VENDOR_ADMTEK, PCI_PRODUCT_ADMTEK_AL981,
181 TULIP_CHIP_AL981 },
182
183 { PCI_VENDOR_ASIX, PCI_PRODUCT_ASIX_AX88140A,
184 TULIP_CHIP_AX88140 },
185 #endif
186
187 { 0, 0,
188 TULIP_CHIP_INVALID },
189 };
190
191 struct tlp_pci_quirks {
192 void (*tpq_func) __P((struct tulip_pci_softc *,
193 const u_int8_t *));
194 u_int8_t tpq_oui[3];
195 };
196
197 void tlp_pci_znyx_21040_quirks __P((struct tulip_pci_softc *,
198 const u_int8_t *));
199 void tlp_pci_smc_21040_quirks __P((struct tulip_pci_softc *,
200 const u_int8_t *));
201 void tlp_pci_cogent_21040_quirks __P((struct tulip_pci_softc *,
202 const u_int8_t *));
203 void tlp_pci_accton_21040_quirks __P((struct tulip_pci_softc *,
204 const u_int8_t *));
205
206 const struct tlp_pci_quirks tlp_pci_21040_quirks[] = {
207 { tlp_pci_znyx_21040_quirks, { 0x00, 0xc0, 0x95 } },
208 { tlp_pci_smc_21040_quirks, { 0x00, 0x00, 0xc0 } },
209 { tlp_pci_cogent_21040_quirks, { 0x00, 0x00, 0x92 } },
210 { tlp_pci_accton_21040_quirks, { 0x00, 0x00, 0xe8 } },
211 { NULL, { 0, 0, 0 } }
212 };
213
214 const char *tlp_pci_chip_names[] = TULIP_CHIP_NAMES;
215
216 int tlp_pci_shared_intr __P((void *));
217
218 const struct tulip_pci_product *tlp_pci_lookup
219 __P((const struct pci_attach_args *));
220 void tlp_pci_get_quirks __P((struct tulip_pci_softc *, const u_int8_t *,
221 const struct tlp_pci_quirks *));
222 void tlp_pci_check_slaved __P((struct tulip_pci_softc *, int, int));
223
224 const struct tulip_pci_product *
225 tlp_pci_lookup(pa)
226 const struct pci_attach_args *pa;
227 {
228 const struct tulip_pci_product *tpp;
229
230 for (tpp = tlp_pci_products;
231 tlp_pci_chip_names[tpp->tpp_chip] != NULL;
232 tpp++) {
233 if (PCI_VENDOR(pa->pa_id) == tpp->tpp_vendor &&
234 PCI_PRODUCT(pa->pa_id) == tpp->tpp_product)
235 return (tpp);
236 }
237 return (NULL);
238 }
239
240 void
241 tlp_pci_get_quirks(psc, enaddr, tpq)
242 struct tulip_pci_softc *psc;
243 const u_int8_t *enaddr;
244 const struct tlp_pci_quirks *tpq;
245 {
246
247 for (; tpq->tpq_func != NULL; tpq++) {
248 if (tpq->tpq_oui[0] == enaddr[0] &&
249 tpq->tpq_oui[1] == enaddr[1] &&
250 tpq->tpq_oui[2] == enaddr[2]) {
251 (*tpq->tpq_func)(psc, enaddr);
252 return;
253 }
254 }
255 }
256
257 void
258 tlp_pci_check_slaved(psc, shared, slaved)
259 struct tulip_pci_softc *psc;
260 int shared, slaved;
261 {
262 extern struct cfdriver tlp_cd;
263 struct tulip_pci_softc *cur, *best = NULL;
264 struct tulip_softc *sc = &psc->sc_tulip;
265 int i;
266
267 /*
268 * First of all, find the lowest pcidev numbered device on our
269 * bus marked as shared. That should be our master.
270 */
271 for (i = 0; i < tlp_cd.cd_ndevs; i++) {
272 if ((cur = tlp_cd.cd_devs[i]) == NULL)
273 continue;
274 if (cur->sc_tulip.sc_dev.dv_parent != sc->sc_dev.dv_parent)
275 continue;
276 if ((cur->sc_flags & shared) == 0)
277 continue;
278 if (cur == psc)
279 continue;
280 if (best == NULL ||
281 best->sc_tulip.sc_devno > cur->sc_tulip.sc_devno)
282 best = cur;
283 }
284
285 if (best != NULL) {
286 psc->sc_master = best;
287 psc->sc_flags |= (shared | slaved);
288 }
289 }
290
291 int
292 tlp_pci_match(parent, match, aux)
293 struct device *parent;
294 struct cfdata *match;
295 void *aux;
296 {
297 struct pci_attach_args *pa = aux;
298
299 if (tlp_pci_lookup(pa) != NULL)
300 return (10); /* beat if_de.c */
301
302 return (0);
303 }
304
305 void
306 tlp_pci_attach(parent, self, aux)
307 struct device *parent, *self;
308 void *aux;
309 {
310 struct tulip_pci_softc *psc = (void *) self;
311 struct tulip_softc *sc = &psc->sc_tulip;
312 struct pci_attach_args *pa = aux;
313 pci_chipset_tag_t pc = pa->pa_pc;
314 pci_intr_handle_t ih;
315 const char *intrstr = NULL;
316 bus_space_tag_t iot, memt;
317 bus_space_handle_t ioh, memh;
318 int ioh_valid, memh_valid, i, j;
319 const struct tulip_pci_product *tpp;
320 u_int8_t enaddr[ETHER_ADDR_LEN];
321 u_int32_t val;
322
323 sc->sc_devno = pa->pa_device;
324 psc->sc_pc = pa->pa_pc;
325 psc->sc_pcitag = pa->pa_tag;
326
327 LIST_INIT(&psc->sc_intrslaves);
328
329 /*
330 * Map the device.
331 */
332 ioh_valid = (pci_mapreg_map(pa, TULIP_PCI_IOBA,
333 PCI_MAPREG_TYPE_IO, 0,
334 &iot, &ioh, NULL, NULL) == 0);
335 memh_valid = (pci_mapreg_map(pa, TULIP_PCI_MMBA,
336 PCI_MAPREG_TYPE_MEM|PCI_MAPREG_MEM_TYPE_32BIT, 0,
337 &memt, &memh, NULL, NULL) == 0);
338
339 if (memh_valid) {
340 sc->sc_st = memt;
341 sc->sc_sh = memh;
342 } else if (ioh_valid) {
343 sc->sc_st = iot;
344 sc->sc_sh = ioh;
345 } else {
346 printf(": unable to map device registers\n");
347 return;
348 }
349
350 tpp = tlp_pci_lookup(pa);
351 if (tpp == NULL) {
352 printf("\n");
353 panic("tlp_pci_attach: impossible");
354 }
355 sc->sc_chip = tpp->tpp_chip;
356
357 /*
358 * By default, Tulip registers are 8 bytes long (4 bytes
359 * followed by a 4 byte pad).
360 */
361 sc->sc_regshift = 3;
362
363 /*
364 * Get revision info, and set some chip-specific variables.
365 */
366 sc->sc_rev = PCI_REVISION(pa->pa_class);
367 switch (sc->sc_chip) {
368 case TULIP_CHIP_21140:
369 if (sc->sc_rev >= 0x20)
370 sc->sc_chip = TULIP_CHIP_21140A;
371 break;
372
373 case TULIP_CHIP_21142:
374 if (sc->sc_rev >= 0x20)
375 sc->sc_chip = TULIP_CHIP_21143;
376 break;
377
378 case TULIP_CHIP_82C168:
379 if (sc->sc_rev >= 0x20)
380 sc->sc_chip = TULIP_CHIP_82C169;
381 break;
382
383 case TULIP_CHIP_MX98713:
384 if (sc->sc_rev >= 0x10)
385 sc->sc_chip = TULIP_CHIP_MX98713A;
386 break;
387
388 case TULIP_CHIP_MX98715:
389 if (sc->sc_rev >= 0x30)
390 sc->sc_chip = TULIP_CHIP_MX98725;
391 break;
392
393 case TULIP_CHIP_WB89C840F:
394 sc->sc_regshift = 2;
395 break;
396
397 case TULIP_CHIP_AX88140:
398 if (sc->sc_rev >= 0x10)
399 sc->sc_chip = TULIP_CHIP_AX88141;
400 break;
401
402 default:
403 /* Nothing. */
404 }
405
406 printf(": %s Ethernet, pass %d.%d\n",
407 tlp_pci_chip_names[sc->sc_chip],
408 (sc->sc_rev >> 4) & 0xf, sc->sc_rev & 0xf);
409
410 switch (sc->sc_chip) {
411 case TULIP_CHIP_21040:
412 if (sc->sc_rev < 0x20) {
413 printf("%s: 21040 must be at least pass 2.0\n",
414 sc->sc_dev.dv_xname);
415 return;
416 }
417 break;
418
419 case TULIP_CHIP_21140:
420 if (sc->sc_rev < 0x11) {
421 printf("%s: 21140 must be at least pass 1.1\n",
422 sc->sc_dev.dv_xname);
423 return;
424 }
425 break;
426
427 default:
428 /* Nothing. */
429 }
430
431 sc->sc_dmat = pa->pa_dmat;
432
433 /*
434 * Make sure bus mastering is enabled.
435 */
436 pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
437 pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG) |
438 PCI_COMMAND_MASTER_ENABLE);
439
440 /*
441 * Get the cacheline size.
442 */
443 sc->sc_cacheline = PCI_CACHELINE(pci_conf_read(pc, pa->pa_tag,
444 PCI_BHLC_REG));
445
446 /*
447 * Read the contents of the Ethernet Address ROM/SROM.
448 */
449 memset(sc->sc_srom, 0, sizeof(sc->sc_srom));
450 switch (sc->sc_chip) {
451 case TULIP_CHIP_21040:
452 TULIP_WRITE(sc, CSR_MIIROM, MIIROM_SROMCS);
453 for (i = 0; i < sizeof(sc->sc_srom); i++) {
454 for (j = 0; j < 10000; j++) {
455 val = TULIP_READ(sc, CSR_MIIROM);
456 if ((val & MIIROM_DN) == 0)
457 break;
458 }
459 sc->sc_srom[i] = val & MIIROM_DATA;
460 }
461 break;
462
463 case TULIP_CHIP_82C168:
464 case TULIP_CHIP_82C169:
465 {
466 u_int16_t *rombuf = (u_int16_t *)sc->sc_srom;
467
468 /*
469 * The Lite-On PNIC stores the Ethernet address in
470 * the first 3 words of the EEPROM. EEPROM access
471 * is not like the other Tulip chips.
472 */
473 for (i = 0; i < 3; i++) {
474 TULIP_WRITE(sc, CSR_PNIC_SROMCTL,
475 PNIC_SROMCTL_READ | i);
476 for (j = 0; j < 500; j++) {
477 delay(2);
478 val = TULIP_READ(sc, CSR_MIIROM);
479 if ((val & PNIC_MIIROM_BUSY) == 0)
480 break;
481 }
482 if (val & PNIC_MIIROM_BUSY) {
483 printf("%s: EEPROM timed out\n",
484 sc->sc_dev.dv_xname);
485 return;
486 }
487 rombuf[i] = bswap16(val & PNIC_MIIROM_DATA);
488 }
489 break;
490 }
491
492 default:
493 tlp_read_srom(sc, 0, sizeof(sc->sc_srom) >> 2,
494 (u_int16_t *)sc->sc_srom);
495 }
496
497 /*
498 * Deal with chip/board quirks. This includes setting up
499 * the mediasw, and extracting the Ethernet address from
500 * the rombuf.
501 */
502 switch (sc->sc_chip) {
503 case TULIP_CHIP_21040:
504 /* Check for a slaved ROM on a multi-port board. */
505 tlp_pci_check_slaved(psc, TULIP_PCI_SHAREDROM,
506 TULIP_PCI_SLAVEROM);
507 if (psc->sc_flags & TULIP_PCI_SLAVEROM)
508 memcpy(sc->sc_srom, psc->sc_master->sc_tulip.sc_srom,
509 sizeof(sc->sc_srom));
510
511 /*
512 * Parse the Ethernet Address ROM.
513 */
514 if (tlp_parse_old_srom(sc, enaddr) == 0) {
515 printf("%s: unable to decode Ethernet Address ROM\n",
516 sc->sc_dev.dv_xname);
517 return;
518 }
519
520 /*
521 * If we have a slaved ROM, adjust the Ethernet address.
522 */
523 if (psc->sc_flags & TULIP_PCI_SLAVEROM)
524 enaddr[5] +=
525 sc->sc_devno - psc->sc_master->sc_tulip.sc_devno;
526
527 /*
528 * All 21040 boards start out with the same
529 * media switch.
530 */
531 sc->sc_mediasw = &tlp_21040_mediasw;
532
533 /*
534 * Deal with any quirks this board might have.
535 */
536 tlp_pci_get_quirks(psc, enaddr, tlp_pci_21040_quirks);
537 break;
538
539 case TULIP_CHIP_82C168:
540 case TULIP_CHIP_82C169:
541 /*
542 * Lite-On PNIC's Ethernet address is the first 6
543 * bytes of its EEPROM.
544 */
545 memcpy(enaddr, sc->sc_srom, ETHER_ADDR_LEN);
546
547 /*
548 * Lite-On PNICs always use the same mediasw; we
549 * select MII vs. internal NWAY automatically.
550 */
551 sc->sc_mediasw = &tlp_pnic_mediasw;
552 break;
553
554 case TULIP_CHIP_WB89C840F:
555 /*
556 * Winbond 89C840F's Ethernet address is the first
557 * 6 bytes of its EEPROM.
558 */
559 memcpy(enaddr, sc->sc_srom, ETHER_ADDR_LEN);
560
561 /*
562 * Winbond 89C840F has an MII attached to the SIO.
563 */
564 sc->sc_mediasw = &tlp_sio_mii_mediasw;
565 break;
566
567 default:
568 printf("%s: sorry, unable to handle your board\n",
569 sc->sc_dev.dv_xname);
570 return;
571 }
572
573 /*
574 * Handle shared interrupts.
575 */
576 if (psc->sc_flags & TULIP_PCI_SHAREDINTR) {
577 if (psc->sc_master)
578 psc->sc_flags |= TULIP_PCI_SLAVEINTR;
579 else {
580 tlp_pci_check_slaved(psc, TULIP_PCI_SHAREDINTR,
581 TULIP_PCI_SLAVEINTR);
582 if (psc->sc_master == NULL)
583 psc->sc_master = psc;
584 }
585 LIST_INSERT_HEAD(&psc->sc_master->sc_intrslaves,
586 psc, sc_intrq);
587 }
588
589 if (psc->sc_flags & TULIP_PCI_SLAVEINTR) {
590 printf("%s: sharing interrupt with %s\n",
591 sc->sc_dev.dv_xname,
592 psc->sc_master->sc_tulip.sc_dev.dv_xname);
593 } else {
594 /*
595 * Map and establish our interrupt.
596 */
597 if (pci_intr_map(pc, pa->pa_intrtag, pa->pa_intrpin,
598 pa->pa_intrline, &ih)) {
599 printf("%s: unable to map interrupt\n",
600 sc->sc_dev.dv_xname);
601 return;
602 }
603 intrstr = pci_intr_string(pc, ih);
604 psc->sc_ih = pci_intr_establish(pc, ih, IPL_NET,
605 (psc->sc_flags & TULIP_PCI_SHAREDINTR) ?
606 tlp_pci_shared_intr : tlp_intr, sc);
607 if (psc->sc_ih == NULL) {
608 printf("%s: unable to establish interrupt",
609 sc->sc_dev.dv_xname);
610 if (intrstr != NULL)
611 printf(" at %s", intrstr);
612 printf("\n");
613 return;
614 }
615 printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname,
616 intrstr);
617 }
618
619 /*
620 * Finish off the attach.
621 */
622 tlp_attach(sc, enaddr);
623 }
624
625 int
626 tlp_pci_shared_intr(arg)
627 void *arg;
628 {
629 struct tulip_pci_softc *master = arg, *slave;
630 int rv = 0;
631
632 for (slave = LIST_FIRST(&master->sc_intrslaves);
633 slave != NULL;
634 slave = LIST_NEXT(slave, sc_intrq))
635 rv |= tlp_intr(&slave->sc_tulip);
636
637 return (rv);
638 }
639
640 void
641 tlp_pci_znyx_21040_quirks(psc, enaddr)
642 struct tulip_pci_softc *psc;
643 const u_int8_t *enaddr;
644 {
645 struct tulip_softc *sc = &psc->sc_tulip;
646 u_int16_t id = 0;
647
648 /*
649 * If we have a slaved ROM, just copy the bits from the master.
650 * This is in case we fail the ROM ID check (older boards) and
651 * need to fall back on Ethernet address model checking; that
652 * will fail for slave chips.
653 */
654 if (psc->sc_flags & TULIP_PCI_SLAVEROM) {
655 strcpy(sc->sc_name, psc->sc_master->sc_tulip.sc_name);
656 sc->sc_mediasw = psc->sc_master->sc_tulip.sc_mediasw;
657 psc->sc_flags |=
658 psc->sc_master->sc_flags & TULIP_PCI_SHAREDINTR;
659 return;
660 }
661
662 if (sc->sc_srom[32] == 0x4a && sc->sc_srom[33] == 0x52) {
663 id = sc->sc_srom[37] | (sc->sc_srom[36] << 8);
664 switch (id) {
665 zx312:
666 case 0x0602: /* ZX312 */
667 strcpy(sc->sc_name, "ZNYX ZX312");
668 return;
669
670 case 0x0622: /* ZX312T */
671 strcpy(sc->sc_name, "ZNYX ZX312T");
672 sc->sc_mediasw = &tlp_21040_tp_mediasw;
673 return;
674
675 zx314_inta:
676 case 0x0701: /* ZX314 INTA */
677 psc->sc_flags |= TULIP_PCI_SHAREDINTR;
678 /* FALLTHROUGH */
679 case 0x0711: /* ZX314 */
680 strcpy(sc->sc_name, "ZNYX ZX314");
681 psc->sc_flags |= TULIP_PCI_SHAREDROM;
682 sc->sc_mediasw = &tlp_21040_tp_mediasw;
683 return;
684
685 zx315_inta:
686 case 0x0801: /* ZX315 INTA */
687 psc->sc_flags |= TULIP_PCI_SHAREDINTR;
688 /* FALLTHROUGH */
689 case 0x0811: /* ZX315 */
690 strcpy(sc->sc_name, "ZNYX ZX315");
691 psc->sc_flags |= TULIP_PCI_SHAREDROM;
692 return;
693
694 default:
695 id = 0;
696 }
697 }
698
699 /*
700 * Deal with boards that have broken ROMs.
701 */
702 if (id == 0) {
703 if ((enaddr[3] & ~3) == 0xf0 && (enaddr[5] & 3) == 0x00)
704 goto zx314_inta;
705 if ((enaddr[3] & ~3) == 0xf4 && (enaddr[5] & 1) == 0x00)
706 goto zx315_inta;
707 if ((enaddr[3] & ~3) == 0xec)
708 goto zx312;
709 }
710
711 strcpy(sc->sc_name, "ZNYX ZX31x");
712 }
713
714 void
715 tlp_pci_smc_21040_quirks(psc, enaddr)
716 struct tulip_pci_softc *psc;
717 const u_int8_t *enaddr;
718 {
719 struct tulip_softc *sc = &psc->sc_tulip;
720 u_int16_t id1, id2, ei;
721 int auibnc = 0, utp = 0;
722 char *cp;
723
724 id1 = sc->sc_srom[0x60] | (sc->sc_srom[0x61] << 8);
725 id2 = sc->sc_srom[0x62] | (sc->sc_srom[0x63] << 8);
726 ei = sc->sc_srom[0x66] | (sc->sc_srom[0x67] << 8);
727
728 strcpy(sc->sc_name, "SMC 8432");
729 cp = &sc->sc_name[8];
730
731 if ((id1 & 1) == 0) {
732 *cp++ = 'B';
733 auibnc = 1;
734 }
735 if ((id1 & 0xff) > 0x32) {
736 *cp++ = 'T';
737 utp = 1;
738 }
739 if ((id1 & 0x4000) == 0) {
740 *cp++ = 'A';
741 auibnc = 1;
742 }
743 if (id2 == 0x15) {
744 sc->sc_name[7] = '4';
745 *cp++ = '-';
746 *cp++ = 'C';
747 *cp++ = 'H';
748 *cp++ = ei ? '2' : '1';
749 }
750 *cp = '\0';
751
752 if (utp != 0 && auibnc == 0)
753 sc->sc_mediasw = &tlp_21040_tp_mediasw;
754 else if (utp == 0 && auibnc != 0)
755 sc->sc_mediasw = &tlp_21040_auibnc_mediasw;
756 }
757
758 void
759 tlp_pci_cogent_21040_quirks(psc, enaddr)
760 struct tulip_pci_softc *psc;
761 const u_int8_t *enaddr;
762 {
763
764 strcpy(psc->sc_tulip.sc_name, "Cogent multi-port");
765 psc->sc_flags |= TULIP_PCI_SHAREDINTR|TULIP_PCI_SHAREDROM;
766 }
767
768 void
769 tlp_pci_accton_21040_quirks(psc, enaddr)
770 struct tulip_pci_softc *psc;
771 const u_int8_t *enaddr;
772 {
773
774 strcpy(psc->sc_tulip.sc_name, "ACCTON EN1203");
775 }
776