1 /* $NetBSD: if_tlp_pci.c,v 1.114 2009/05/06 09:25:16 cegger Exp $ */
4 * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc.
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; and Charles M. Hannum.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
34 * PCI bus front-end for the Digital Semiconductor ``Tulip'' (21x4x)
35 * Ethernet controller family driver.
38 #include <sys/cdefs.h>
39 __KERNEL_RCSID(0, "$NetBSD: if_tlp_pci.c,v 1.114 2009/05/06 09:25:16 cegger Exp $");
41 #include <sys/param.h>
42 #include <sys/systm.h>
44 #include <sys/malloc.h>
45 #include <sys/kernel.h>
46 #include <sys/socket.h>
47 #include <sys/ioctl.h>
48 #include <sys/errno.h>
49 #include <sys/device.h>
51 #include <machine/endian.h>
54 #include <net/if_dl.h>
55 #include <net/if_media.h>
56 #include <net/if_ether.h>
61 #include <machine/promlib.h>
64 #include <dev/mii/miivar.h>
65 #include <dev/mii/mii_bitbang.h>
67 #include <dev/ic/tulipreg.h>
68 #include <dev/ic/tulipvar.h>
70 #include <dev/pci/pcivar.h>
71 #include <dev/pci/pcireg.h>
72 #include <dev/pci/pcidevs.h>
75 * PCI configuration space registers used by the Tulip.
77 #define TULIP_PCI_IOBA 0x10 /* i/o mapped base */
78 #define TULIP_PCI_MMBA 0x14 /* memory mapped base */
79 #define TULIP_PCI_CFDA 0x40 /* configuration driver area */
81 #define CFDA_SLEEP 0x80000000 /* sleep mode */
82 #define CFDA_SNOOZE 0x40000000 /* snooze mode */
84 struct tulip_pci_softc
{
85 struct tulip_softc sc_tulip
; /* real Tulip softc */
87 /* PCI-specific goo. */
88 void *sc_ih
; /* interrupt handle */
89 bus_size_t sc_mapsize
;
91 pci_chipset_tag_t sc_pc
; /* our PCI chipset */
92 pcitag_t sc_pcitag
; /* our PCI tag */
94 int sc_flags
; /* flags; see below */
96 LIST_HEAD(, tulip_pci_softc
) sc_intrslaves
;
97 LIST_ENTRY(tulip_pci_softc
) sc_intrq
;
99 /* Our {ROM,interrupt} master. */
100 struct tulip_pci_softc
*sc_master
;
104 #define TULIP_PCI_SHAREDINTR 0x01 /* interrupt is shared */
105 #define TULIP_PCI_SLAVEINTR 0x02 /* interrupt is slave */
106 #define TULIP_PCI_SHAREDROM 0x04 /* ROM is shared */
107 #define TULIP_PCI_SLAVEROM 0x08 /* slave of shared ROM */
109 static int tlp_pci_match(device_t
, cfdata_t
, void *);
110 static void tlp_pci_attach(device_t
, device_t
, void *);
111 static int tlp_pci_detach(device_t
, int);
113 CFATTACH_DECL3_NEW(tlp_pci
, sizeof(struct tulip_pci_softc
),
114 tlp_pci_match
, tlp_pci_attach
, tlp_pci_detach
, NULL
, NULL
, NULL
,
115 DVF_DETACH_SHUTDOWN
);
117 static const struct tulip_pci_product
{
118 uint32_t tpp_vendor
; /* PCI vendor ID */
119 uint32_t tpp_product
; /* PCI product ID */
120 tulip_chip_t tpp_chip
; /* base Tulip chip type */
121 } tlp_pci_products
[] = {
122 { PCI_VENDOR_DEC
, PCI_PRODUCT_DEC_21040
,
124 { PCI_VENDOR_DEC
, PCI_PRODUCT_DEC_21041
,
126 { PCI_VENDOR_DEC
, PCI_PRODUCT_DEC_21140
,
128 { PCI_VENDOR_DEC
, PCI_PRODUCT_DEC_21142
,
131 { PCI_VENDOR_LITEON
, PCI_PRODUCT_LITEON_82C168
,
135 * Note: This is like a MX98725 with Wake-On-LAN and a
136 * 128-bit multicast hash table.
138 { PCI_VENDOR_LITEON
, PCI_PRODUCT_LITEON_82C115
,
141 { PCI_VENDOR_MACRONIX
, PCI_PRODUCT_MACRONIX_MX98713
,
142 TULIP_CHIP_MX98713
},
143 { PCI_VENDOR_MACRONIX
, PCI_PRODUCT_MACRONIX_MX987x5
,
144 TULIP_CHIP_MX98715
},
146 { PCI_VENDOR_COMPEX
, PCI_PRODUCT_COMPEX_RL100TX
,
147 TULIP_CHIP_MX98713
},
149 { PCI_VENDOR_WINBOND
, PCI_PRODUCT_WINBOND_W89C840F
,
150 TULIP_CHIP_WB89C840F
},
151 { PCI_VENDOR_COMPEX
, PCI_PRODUCT_COMPEX_RL100ATX
,
152 TULIP_CHIP_WB89C840F
},
154 { PCI_VENDOR_DAVICOM
, PCI_PRODUCT_DAVICOM_DM9102
,
157 { PCI_VENDOR_ADMTEK
, PCI_PRODUCT_ADMTEK_AL981
,
160 { PCI_VENDOR_ADMTEK
, PCI_PRODUCT_ADMTEK_AN983
,
162 { PCI_VENDOR_ADMTEK
, PCI_PRODUCT_ADMTEK_ADM9511
,
164 { PCI_VENDOR_ADMTEK
, PCI_PRODUCT_ADMTEK_ADM9513
,
166 { PCI_VENDOR_ACCTON
, PCI_PRODUCT_ACCTON_EN2242
,
169 { PCI_VENDOR_3COM
, PCI_PRODUCT_3COM_3C910SOHOB
,
172 { PCI_VENDOR_ASIX
, PCI_PRODUCT_ASIX_AX88140A
,
173 TULIP_CHIP_AX88140
},
175 { PCI_VENDOR_CONEXANT
, PCI_PRODUCT_CONEXANT_LANFINITY
,
179 TULIP_CHIP_INVALID
},
182 struct tlp_pci_quirks
{
183 void (*tpq_func
)(struct tulip_pci_softc
*,
188 static void tlp_pci_dec_quirks(struct tulip_pci_softc
*,
191 static void tlp_pci_znyx_21040_quirks(struct tulip_pci_softc
*,
193 static void tlp_pci_smc_21040_quirks(struct tulip_pci_softc
*,
195 static void tlp_pci_cogent_21040_quirks(struct tulip_pci_softc
*,
197 static void tlp_pci_accton_21040_quirks(struct tulip_pci_softc
*,
200 static void tlp_pci_cobalt_21142_quirks(struct tulip_pci_softc
*,
202 static void tlp_pci_algor_21142_quirks(struct tulip_pci_softc
*,
204 static void tlp_pci_netwinder_21142_quirks(struct tulip_pci_softc
*,
206 static void tlp_pci_phobos_21142_quirks(struct tulip_pci_softc
*,
208 static void tlp_pci_znyx_21142_quirks(struct tulip_pci_softc
*,
211 static void tlp_pci_adaptec_quirks(struct tulip_pci_softc
*,
214 static const struct tlp_pci_quirks tlp_pci_21040_quirks
[] = {
215 { tlp_pci_znyx_21040_quirks
, { 0x00, 0xc0, 0x95 } },
216 { tlp_pci_smc_21040_quirks
, { 0x00, 0x00, 0xc0 } },
217 { tlp_pci_cogent_21040_quirks
, { 0x00, 0x00, 0x92 } },
218 { tlp_pci_accton_21040_quirks
, { 0x00, 0x00, 0xe8 } },
219 { NULL
, { 0, 0, 0 } }
222 static const struct tlp_pci_quirks tlp_pci_21041_quirks
[] = {
223 { tlp_pci_dec_quirks
, { 0x08, 0x00, 0x2b } },
224 { tlp_pci_dec_quirks
, { 0x00, 0x00, 0xf8 } },
225 { NULL
, { 0, 0, 0 } }
228 static void tlp_pci_asante_21140_quirks(struct tulip_pci_softc
*,
230 static void tlp_pci_e100_quirks(struct tulip_pci_softc
*,
232 static void tlp_pci_phobos_21140_quirks(struct tulip_pci_softc
*,
234 static void tlp_pci_smc_21140_quirks(struct tulip_pci_softc
*,
236 static void tlp_pci_vpc_21140_quirks(struct tulip_pci_softc
*,
239 static const struct tlp_pci_quirks tlp_pci_21140_quirks
[] = {
240 { tlp_pci_dec_quirks
, { 0x08, 0x00, 0x2b } },
241 { tlp_pci_dec_quirks
, { 0x00, 0x00, 0xf8 } },
242 { tlp_pci_e100_quirks
, { 0x00, 0xa0, 0x59 } },
243 { tlp_pci_asante_21140_quirks
, { 0x00, 0x00, 0x94 } },
244 { tlp_pci_adaptec_quirks
, { 0x00, 0x00, 0x92 } },
245 { tlp_pci_adaptec_quirks
, { 0x00, 0x00, 0xd1 } },
246 { tlp_pci_phobos_21140_quirks
, { 0x00, 0x60, 0xf5 } },
247 { tlp_pci_smc_21140_quirks
, { 0x00, 0x00, 0xc0 } },
248 { tlp_pci_vpc_21140_quirks
, { 0x00, 0x03, 0xff } },
249 { NULL
, { 0, 0, 0 } }
252 static const struct tlp_pci_quirks tlp_pci_21142_quirks
[] = {
253 { tlp_pci_dec_quirks
, { 0x08, 0x00, 0x2b } },
254 { tlp_pci_dec_quirks
, { 0x00, 0x00, 0xf8 } },
255 { tlp_pci_cobalt_21142_quirks
, { 0x00, 0x10, 0xe0 } },
256 { tlp_pci_algor_21142_quirks
, { 0x00, 0x40, 0xbc } },
257 { tlp_pci_adaptec_quirks
, { 0x00, 0x00, 0xd1 } },
258 { tlp_pci_netwinder_21142_quirks
,{ 0x00, 0x10, 0x57 } },
259 { tlp_pci_phobos_21142_quirks
, { 0x00, 0x60, 0xf5 } },
260 { tlp_pci_znyx_21142_quirks
, { 0x00, 0xc0, 0x95 } },
261 { NULL
, { 0, 0, 0 } }
264 static int tlp_pci_shared_intr(void *);
266 static const struct tulip_pci_product
*
267 tlp_pci_lookup(const struct pci_attach_args
*pa
)
269 const struct tulip_pci_product
*tpp
;
271 /* Don't match lmc cards */
272 if (PCI_VENDOR(pci_conf_read(pa
->pa_pc
, pa
->pa_tag
,
273 PCI_SUBSYS_ID_REG
)) == PCI_VENDOR_LMC
)
276 for (tpp
= tlp_pci_products
;
277 tlp_chip_names
[tpp
->tpp_chip
] != NULL
;
279 if (PCI_VENDOR(pa
->pa_id
) == tpp
->tpp_vendor
&&
280 PCI_PRODUCT(pa
->pa_id
) == tpp
->tpp_product
)
287 tlp_pci_get_quirks(struct tulip_pci_softc
*psc
, const uint8_t *enaddr
,
288 const struct tlp_pci_quirks
*tpq
)
291 for (; tpq
->tpq_func
!= NULL
; tpq
++) {
292 if (tpq
->tpq_oui
[0] == enaddr
[0] &&
293 tpq
->tpq_oui
[1] == enaddr
[1] &&
294 tpq
->tpq_oui
[2] == enaddr
[2]) {
295 (*tpq
->tpq_func
)(psc
, enaddr
);
302 tlp_pci_check_slaved(struct tulip_pci_softc
*psc
, int shared
, int slaved
)
304 extern struct cfdriver tlp_cd
;
305 struct tulip_pci_softc
*cur
, *best
= NULL
;
306 struct tulip_softc
*sc
= &psc
->sc_tulip
;
310 * First of all, find the lowest pcidev numbered device on our
311 * bus marked as shared. That should be our master.
313 for (i
= 0; i
< tlp_cd
.cd_ndevs
; i
++) {
314 if ((cur
= device_lookup_private(&tlp_cd
, i
)) == NULL
)
316 if (device_parent(cur
->sc_tulip
.sc_dev
) !=
317 device_parent(sc
->sc_dev
))
319 if ((cur
->sc_flags
& shared
) == 0)
324 best
->sc_tulip
.sc_devno
> cur
->sc_tulip
.sc_devno
)
329 psc
->sc_master
= best
;
330 psc
->sc_flags
|= (shared
| slaved
);
335 tlp_pci_match(device_t parent
, cfdata_t match
, void *aux
)
337 struct pci_attach_args
*pa
= aux
;
339 if (tlp_pci_lookup(pa
) != NULL
)
340 return 10; /* beat if_de.c */
346 tlp_pci_attach(device_t parent
, device_t self
, void *aux
)
348 struct tulip_pci_softc
*psc
= device_private(self
);
349 struct tulip_softc
*sc
= &psc
->sc_tulip
;
350 struct pci_attach_args
*pa
= aux
;
351 pci_chipset_tag_t pc
= pa
->pa_pc
;
352 pci_intr_handle_t ih
;
353 const char *intrstr
= NULL
;
354 bus_space_tag_t iot
, memt
;
355 bus_space_handle_t ioh
, memh
;
356 int ioh_valid
, memh_valid
, i
, j
;
357 const struct tulip_pci_product
*tpp
;
359 uint8_t enaddr
[ETHER_ADDR_LEN
];
363 bus_size_t iosize
= 0, memsize
= 0;
366 sc
->sc_devno
= pa
->pa_device
;
367 psc
->sc_pc
= pa
->pa_pc
;
368 psc
->sc_pcitag
= pa
->pa_tag
;
370 LIST_INIT(&psc
->sc_intrslaves
);
372 tpp
= tlp_pci_lookup(pa
);
375 panic("tlp_pci_attach: impossible");
377 sc
->sc_chip
= tpp
->tpp_chip
;
380 * By default, Tulip registers are 8 bytes long (4 bytes
381 * followed by a 4 byte pad).
386 * No power management hooks.
387 * XXX Maybe we should add some!
389 sc
->sc_flags
|= TULIPF_ENABLED
;
392 * Get revision info, and set some chip-specific variables.
394 sc
->sc_rev
= PCI_REVISION(pa
->pa_class
);
395 switch (sc
->sc_chip
) {
396 case TULIP_CHIP_21140
:
397 if (sc
->sc_rev
>= 0x20)
398 sc
->sc_chip
= TULIP_CHIP_21140A
;
401 case TULIP_CHIP_21142
:
402 if (sc
->sc_rev
>= 0x20)
403 sc
->sc_chip
= TULIP_CHIP_21143
;
406 case TULIP_CHIP_82C168
:
407 if (sc
->sc_rev
>= 0x20)
408 sc
->sc_chip
= TULIP_CHIP_82C169
;
411 case TULIP_CHIP_MX98713
:
412 if (sc
->sc_rev
>= 0x10)
413 sc
->sc_chip
= TULIP_CHIP_MX98713A
;
416 case TULIP_CHIP_MX98715
:
417 if (sc
->sc_rev
>= 0x20)
418 sc
->sc_chip
= TULIP_CHIP_MX98715A
;
419 if (sc
->sc_rev
>= 0x25)
420 sc
->sc_chip
= TULIP_CHIP_MX98715AEC_X
;
421 if (sc
->sc_rev
>= 0x30)
422 sc
->sc_chip
= TULIP_CHIP_MX98725
;
425 case TULIP_CHIP_WB89C840F
:
429 case TULIP_CHIP_AN985
:
431 * The AN983 and AN985 are very similar, and are
432 * differentiated by a "signature" register that
433 * is like, but not identical, to a PCI ID register.
435 reg
= pci_conf_read(pc
, pa
->pa_tag
, 0x80);
438 sc
->sc_chip
= TULIP_CHIP_AN985
;
442 sc
->sc_chip
= TULIP_CHIP_AN983
;
446 /* Unknown -- use default. */
451 case TULIP_CHIP_AX88140
:
452 if (sc
->sc_rev
>= 0x10)
453 sc
->sc_chip
= TULIP_CHIP_AX88141
;
456 case TULIP_CHIP_DM9102
:
457 if (sc
->sc_rev
>= 0x30)
458 sc
->sc_chip
= TULIP_CHIP_DM9102A
;
466 aprint_normal(": %s Ethernet, pass %d.%d\n",
467 tlp_chip_names
[sc
->sc_chip
],
468 (sc
->sc_rev
>> 4) & 0xf, sc
->sc_rev
& 0xf);
470 switch (sc
->sc_chip
) {
471 case TULIP_CHIP_21040
:
472 if (sc
->sc_rev
< 0x20) {
473 aprint_normal_dev(self
,
474 "21040 must be at least pass 2.0\n");
479 case TULIP_CHIP_21140
:
480 if (sc
->sc_rev
< 0x11) {
481 aprint_normal_dev(self
,
482 "21140 must be at least pass 1.1\n");
493 * Check to see if the device is in power-save mode, and
494 * being it out if necessary.
496 switch (sc
->sc_chip
) {
497 case TULIP_CHIP_21140
:
498 case TULIP_CHIP_21140A
:
499 case TULIP_CHIP_21142
:
500 case TULIP_CHIP_21143
:
501 case TULIP_CHIP_MX98713A
:
502 case TULIP_CHIP_MX98715
:
503 case TULIP_CHIP_MX98715A
:
504 case TULIP_CHIP_MX98715AEC_X
:
505 case TULIP_CHIP_MX98725
:
506 case TULIP_CHIP_DM9102
:
507 case TULIP_CHIP_DM9102A
:
508 case TULIP_CHIP_AX88140
:
509 case TULIP_CHIP_AX88141
:
510 case TULIP_CHIP_RS7112
:
512 * Clear the "sleep mode" bit in the CFDA register.
514 reg
= pci_conf_read(pc
, pa
->pa_tag
, TULIP_PCI_CFDA
);
515 if (reg
& (CFDA_SLEEP
|CFDA_SNOOZE
))
516 pci_conf_write(pc
, pa
->pa_tag
, TULIP_PCI_CFDA
,
517 reg
& ~(CFDA_SLEEP
|CFDA_SNOOZE
));
526 if ((error
= pci_activate(pa
->pa_pc
, pa
->pa_tag
, self
,
527 NULL
)) && error
!= EOPNOTSUPP
) {
528 aprint_error_dev(self
, "cannot activate %d\n",
537 ioh_valid
= (pci_mapreg_map(pa
, TULIP_PCI_IOBA
,
538 PCI_MAPREG_TYPE_IO
, 0,
539 &iot
, &ioh
, NULL
, &iosize
) == 0);
540 memh_valid
= (pci_mapreg_map(pa
, TULIP_PCI_MMBA
,
541 PCI_MAPREG_TYPE_MEM
|PCI_MAPREG_MEM_TYPE_32BIT
, 0,
542 &memt
, &memh
, NULL
, &memsize
) == 0);
546 psc
->sc_mapsize
= memsize
;
548 bus_space_unmap(iot
, ioh
, iosize
);
551 } else if (ioh_valid
) {
554 psc
->sc_mapsize
= iosize
;
556 bus_space_unmap(memt
, memh
, memsize
);
560 aprint_error_dev(self
, "unable to map device registers\n");
564 sc
->sc_dmat
= pa
->pa_dmat
;
567 * Make sure bus mastering is enabled.
569 pci_conf_write(pc
, pa
->pa_tag
, PCI_COMMAND_STATUS_REG
,
570 pci_conf_read(pc
, pa
->pa_tag
, PCI_COMMAND_STATUS_REG
) |
571 PCI_COMMAND_MASTER_ENABLE
);
574 * Get the cacheline size.
576 sc
->sc_cacheline
= PCI_CACHELINE(pci_conf_read(pc
, pa
->pa_tag
,
580 * Get PCI data moving command info.
582 if (pa
->pa_flags
& PCI_FLAGS_MRL_OKAY
)
583 sc
->sc_flags
|= TULIPF_MRL
;
584 if (pa
->pa_flags
& PCI_FLAGS_MRM_OKAY
)
585 sc
->sc_flags
|= TULIPF_MRM
;
586 if (pa
->pa_flags
& PCI_FLAGS_MWI_OKAY
)
587 sc
->sc_flags
|= TULIPF_MWI
;
590 * Read the contents of the Ethernet Address ROM/SROM.
592 switch (sc
->sc_chip
) {
593 case TULIP_CHIP_21040
:
594 sc
->sc_srom_addrbits
= 6;
595 sc
->sc_srom
= malloc(TULIP_ROM_SIZE(6), M_DEVBUF
, M_NOWAIT
);
596 TULIP_WRITE(sc
, CSR_MIIROM
, MIIROM_SROMCS
);
597 for (i
= 0; i
< TULIP_ROM_SIZE(6); i
++) {
598 for (j
= 0; j
< 10000; j
++) {
599 val
= TULIP_READ(sc
, CSR_MIIROM
);
600 if ((val
& MIIROM_DN
) == 0)
603 sc
->sc_srom
[i
] = val
& MIIROM_DATA
;
607 case TULIP_CHIP_82C168
:
608 case TULIP_CHIP_82C169
:
610 sc
->sc_srom_addrbits
= 2;
611 sc
->sc_srom
= malloc(TULIP_ROM_SIZE(2), M_DEVBUF
, M_NOWAIT
);
614 * The Lite-On PNIC stores the Ethernet address in
615 * the first 3 words of the EEPROM. EEPROM access
616 * is not like the other Tulip chips.
618 for (i
= 0; i
< 6; i
+= 2) {
619 TULIP_WRITE(sc
, CSR_PNIC_SROMCTL
,
620 PNIC_SROMCTL_READ
| (i
>> 1));
621 for (j
= 0; j
< 500; j
++) {
623 val
= TULIP_READ(sc
, CSR_MIIROM
);
624 if ((val
& PNIC_MIIROM_BUSY
) == 0)
627 if (val
& PNIC_MIIROM_BUSY
) {
628 aprint_error_dev(self
, "EEPROM timed out\n");
631 val
&= PNIC_MIIROM_DATA
;
632 sc
->sc_srom
[i
] = val
>> 8;
633 sc
->sc_srom
[i
+ 1] = val
& 0xff;
640 * XXX This isn't quite the right way to do this; we should
641 * XXX be attempting to fetch the mac-addr property in the
642 * XXX bus-agnostic part of the driver independently. But
643 * XXX that requires a larger change in the SROM handling
644 * XXX logic, and for now we can at least remove a machine-
645 * XXX dependent wart from the PCI front-end.
647 ea
= prop_dictionary_get(device_properties(self
),
650 extern int tlp_srom_debug
;
651 KASSERT(prop_object_type(ea
) == PROP_TYPE_DATA
);
652 KASSERT(prop_data_size(ea
) == ETHER_ADDR_LEN
);
654 memcpy(enaddr
, prop_data_data_nocopy(ea
),
657 sc
->sc_srom_addrbits
= 6;
658 sc
->sc_srom
= malloc(TULIP_ROM_SIZE(6), M_DEVBUF
,
660 memcpy(sc
->sc_srom
, enaddr
, sizeof(enaddr
));
661 if (tlp_srom_debug
) {
662 aprint_normal("SROM CONTENTS:");
663 for (i
= 0; i
< TULIP_ROM_SIZE(6); i
++) {
665 aprint_normal("\n\t");
666 aprint_normal("0x%02x ", sc
->sc_srom
[i
]);
673 /* Check for a slaved ROM on a multi-port board. */
674 tlp_pci_check_slaved(psc
, TULIP_PCI_SHAREDROM
,
676 if (psc
->sc_flags
& TULIP_PCI_SLAVEROM
) {
677 sc
->sc_srom_addrbits
=
678 psc
->sc_master
->sc_tulip
.sc_srom_addrbits
;
679 sc
->sc_srom
= psc
->sc_master
->sc_tulip
.sc_srom
;
681 sc
->sc_devno
- psc
->sc_master
->sc_tulip
.sc_devno
;
683 else if (tlp_read_srom(sc
) == 0)
689 * Deal with chip/board quirks. This includes setting up
690 * the mediasw, and extracting the Ethernet address from
693 switch (sc
->sc_chip
) {
694 case TULIP_CHIP_21040
:
696 * Parse the Ethernet Address ROM.
698 if (tlp_parse_old_srom(sc
, enaddr
) == 0)
703 * All 21040 boards start out with the same
706 sc
->sc_mediasw
= &tlp_21040_mediasw
;
709 * Deal with any quirks this board might have.
711 tlp_pci_get_quirks(psc
, enaddr
, tlp_pci_21040_quirks
);
714 case TULIP_CHIP_21041
:
715 /* Check for new format SROM. */
716 if (tlp_isv_srom_enaddr(sc
, enaddr
) == 0) {
718 * Not an ISV SROM; try the old DEC Ethernet Address
721 if (tlp_parse_old_srom(sc
, enaddr
) == 0)
726 * All 21041 boards use the same media switch; they all
727 * work basically the same! Yippee!
729 sc
->sc_mediasw
= &tlp_21041_mediasw
;
732 * Deal with any quirks this board might have.
734 tlp_pci_get_quirks(psc
, enaddr
, tlp_pci_21041_quirks
);
737 case TULIP_CHIP_21140
:
738 case TULIP_CHIP_21140A
:
739 /* Check for new format SROM. */
740 if (tlp_isv_srom_enaddr(sc
, enaddr
) == 0) {
742 * Not an ISV SROM; try the old DEC Ethernet Address
745 if (tlp_parse_old_srom(sc
, enaddr
) == 0)
749 * We start out with the 2114x ISV media switch.
750 * When we search for quirks, we may change to
751 * a different switch.
753 sc
->sc_mediasw
= &tlp_2114x_isv_mediasw
;
757 * Deal with any quirks this board might have.
759 tlp_pci_get_quirks(psc
, enaddr
, tlp_pci_21140_quirks
);
762 * Bail out now if we can't deal with this board.
764 if (sc
->sc_mediasw
== NULL
)
768 case TULIP_CHIP_21142
:
769 case TULIP_CHIP_21143
:
770 /* Check for new format SROM. */
771 if (tlp_isv_srom_enaddr(sc
, enaddr
) == 0) {
773 * Not an ISV SROM; try the old DEC Ethernet Address
776 if (tlp_parse_old_srom(sc
, enaddr
) == 0) {
778 * One last try: just copy the address
779 * from offset 20 and try to look
782 memcpy(enaddr
, &sc
->sc_srom
[20],
787 * We start out with the 2114x ISV media switch.
788 * When we search for quirks, we may change to
789 * a different switch.
791 sc
->sc_mediasw
= &tlp_2114x_isv_mediasw
;
795 * Deal with any quirks this board might have.
797 tlp_pci_get_quirks(psc
, enaddr
, tlp_pci_21142_quirks
);
800 * Bail out now if we can't deal with this board.
802 if (sc
->sc_mediasw
== NULL
)
806 case TULIP_CHIP_82C168
:
807 case TULIP_CHIP_82C169
:
809 * Lite-On PNIC's Ethernet address is the first 6
810 * bytes of its EEPROM.
812 memcpy(enaddr
, sc
->sc_srom
, ETHER_ADDR_LEN
);
815 * Lite-On PNICs always use the same mediasw; we
816 * select MII vs. internal NWAY automatically.
818 sc
->sc_mediasw
= &tlp_pnic_mediasw
;
821 case TULIP_CHIP_MX98713
:
823 * The Macronix MX98713 has an MII and GPIO, but no
824 * internal Nway block. This chip is basically a
825 * perfect 21140A clone, with the exception of the
826 * a magic register frobbing in order to make the
827 * interface function.
829 if (tlp_isv_srom_enaddr(sc
, enaddr
)) {
830 sc
->sc_mediasw
= &tlp_2114x_isv_mediasw
;
835 case TULIP_CHIP_82C115
:
837 * Yippee! The Lite-On 82C115 is a clone of
838 * the MX98725 (the data sheet even says `MXIC'
839 * on it)! Imagine that, a clone of a clone.
841 * The differences are really minimal:
843 * - Wake-On-LAN support
844 * - 128-bit multicast hash table, rather than
845 * the standard 512-bit hash table
849 case TULIP_CHIP_MX98713A
:
850 case TULIP_CHIP_MX98715A
:
851 case TULIP_CHIP_MX98715AEC_X
:
852 case TULIP_CHIP_MX98725
:
854 * The MX98713A has an MII as well as an internal Nway block,
855 * but no GPIO. The MX98715 and MX98725 have an internal
858 * The internal Nway block, unlike the Lite-On PNIC's, does
859 * just that - performs Nway. Once autonegotiation completes,
860 * we must program the GPR media information into the chip.
862 * The byte offset of the Ethernet address is stored at
865 memcpy(enaddr
, &sc
->sc_srom
[sc
->sc_srom
[0x70]], ETHER_ADDR_LEN
);
866 sc
->sc_mediasw
= &tlp_pmac_mediasw
;
869 case TULIP_CHIP_WB89C840F
:
871 * Winbond 89C840F's Ethernet address is the first
872 * 6 bytes of its EEPROM.
874 memcpy(enaddr
, sc
->sc_srom
, ETHER_ADDR_LEN
);
877 * Winbond 89C840F has an MII attached to the SIO.
879 sc
->sc_mediasw
= &tlp_sio_mii_mediasw
;
882 case TULIP_CHIP_AL981
:
884 * The ADMtek AL981's Ethernet address is located
885 * at offset 8 of its EEPROM.
887 memcpy(enaddr
, &sc
->sc_srom
[8], ETHER_ADDR_LEN
);
890 * ADMtek AL981 has a built-in PHY accessed through
893 sc
->sc_mediasw
= &tlp_al981_mediasw
;
896 case TULIP_CHIP_AN983
:
897 case TULIP_CHIP_AN985
:
899 * The ADMtek AN985's Ethernet address is located
900 * at offset 8 of its EEPROM.
902 memcpy(enaddr
, &sc
->sc_srom
[8], ETHER_ADDR_LEN
);
905 * The ADMtek AN985 can be configured in Single-Chip
906 * mode or MAC-only mode. Single-Chip uses the built-in
907 * PHY, MAC-only has an external PHY (usually HomePNA).
908 * The selection is based on an EEPROM setting, and both
909 * PHYs are accessed via MII attached to SIO.
911 * The AN985 "ghosts" the internal PHY onto all
912 * MII addresses, so we have to use a media init
913 * routine that limits the search.
914 * XXX How does this work with MAC-only mode?
916 sc
->sc_mediasw
= &tlp_an985_mediasw
;
919 case TULIP_CHIP_DM9102
:
920 case TULIP_CHIP_DM9102A
:
922 * Some boards with the Davicom chip have an ISV
923 * SROM (mostly DM9102A boards -- trying to describe
924 * the HomePNA PHY, probably) although the data in
925 * them is generally wrong. Check for ISV format
926 * and grab the Ethernet address that way, and if
927 * that fails, fall back on grabbing it from an
928 * observed offset of 20 (which is where it would
929 * be in an ISV SROM anyhow, tho ISV can cope with
930 * multi-port boards).
932 if (!tlp_isv_srom_enaddr(sc
, enaddr
)) {
934 if ((sc
->sc_srom
[20] == 0 &&
935 sc
->sc_srom
[21] == 0 &&
936 sc
->sc_srom
[22] == 0) ||
937 (sc
->sc_srom
[20] == 0xff &&
938 sc
->sc_srom
[21] == 0xff &&
939 sc
->sc_srom
[22] == 0xff)) {
940 prom_getether(PCITAG_NODE(pa
->pa_tag
), enaddr
);
943 memcpy(enaddr
, &sc
->sc_srom
[20], ETHER_ADDR_LEN
);
947 * Davicom chips all have an internal MII interface
948 * and a built-in PHY. DM9102A also has a an external
949 * MII interface, usually with a HomePNA PHY attached
952 sc
->sc_mediasw
= &tlp_dm9102_mediasw
;
955 case TULIP_CHIP_AX88140
:
956 case TULIP_CHIP_AX88141
:
958 * ASIX AX88140/AX88141 Ethernet Address is located at offset
961 memcpy(enaddr
, &sc
->sc_srom
[20], ETHER_ADDR_LEN
);
964 * ASIX AX88140A/AX88141 chip can have a built-in PHY or
965 * an external MII interface.
967 sc
->sc_mediasw
= &tlp_asix_mediasw
;
970 case TULIP_CHIP_RS7112
:
972 * RS7112 Ethernet Address is located of offset 0x19a
975 memcpy(enaddr
, &sc
->sc_srom
[0x19a], ETHER_ADDR_LEN
);
977 /* RS7112 chip has a PHY at MII address 1 */
978 sc
->sc_mediasw
= &tlp_rs7112_mediasw
;
983 aprint_error_dev(self
, "sorry, unable to handle your board\n");
988 * Handle shared interrupts.
990 if (psc
->sc_flags
& TULIP_PCI_SHAREDINTR
) {
992 psc
->sc_flags
|= TULIP_PCI_SLAVEINTR
;
994 tlp_pci_check_slaved(psc
, TULIP_PCI_SHAREDINTR
,
995 TULIP_PCI_SLAVEINTR
);
996 if (psc
->sc_master
== NULL
)
997 psc
->sc_master
= psc
;
999 LIST_INSERT_HEAD(&psc
->sc_master
->sc_intrslaves
,
1003 if (psc
->sc_flags
& TULIP_PCI_SLAVEINTR
) {
1004 aprint_normal_dev(self
, "sharing interrupt with %s\n",
1005 device_xname(psc
->sc_master
->sc_tulip
.sc_dev
));
1008 * Map and establish our interrupt.
1010 if (pci_intr_map(pa
, &ih
)) {
1011 aprint_error_dev(self
, "unable to map interrupt\n");
1014 intrstr
= pci_intr_string(pc
, ih
);
1015 psc
->sc_ih
= pci_intr_establish(pc
, ih
, IPL_NET
,
1016 (psc
->sc_flags
& TULIP_PCI_SHAREDINTR
) ?
1017 tlp_pci_shared_intr
: tlp_intr
, sc
);
1018 if (psc
->sc_ih
== NULL
) {
1019 aprint_error_dev(self
, "unable to establish interrupt");
1020 if (intrstr
!= NULL
)
1021 aprint_error(" at %s", intrstr
);
1025 aprint_normal_dev(self
, "interrupting at %s\n",
1030 * Finish off the attach.
1032 error
= tlp_attach(sc
, enaddr
);
1038 if (psc
->sc_ih
!= NULL
) {
1039 pci_intr_disestablish(psc
->sc_pc
, psc
->sc_ih
);
1044 bus_space_unmap(iot
, ioh
, iosize
);
1046 bus_space_unmap(memt
, memh
, memsize
);
1047 psc
->sc_mapsize
= 0;
1052 tlp_pci_detach(device_t self
, int flags
)
1054 struct tulip_pci_softc
*psc
= device_private(self
);
1055 struct tulip_softc
*sc
= &psc
->sc_tulip
;
1058 rv
= tlp_detach(sc
);
1062 if (psc
->sc_ih
!= NULL
) {
1063 pci_intr_disestablish(psc
->sc_pc
, psc
->sc_ih
);
1067 if (psc
->sc_mapsize
) {
1068 bus_space_unmap(sc
->sc_st
, sc
->sc_sh
, psc
->sc_mapsize
);
1069 psc
->sc_mapsize
= 0;
1076 tlp_pci_shared_intr(void *arg
)
1078 struct tulip_pci_softc
*master
= arg
, *slave
;
1081 for (slave
= LIST_FIRST(&master
->sc_intrslaves
);
1083 slave
= LIST_NEXT(slave
, sc_intrq
))
1084 rv
|= tlp_intr(&slave
->sc_tulip
);
1090 tlp_pci_dec_quirks(struct tulip_pci_softc
*psc
, const uint8_t *enaddr
)
1092 struct tulip_softc
*sc
= &psc
->sc_tulip
;
1095 * This isn't really a quirk-gathering device, really. We
1096 * just want to get the spiffy DEC board name from the SROM.
1098 strcpy(sc
->sc_name
, "DEC ");
1100 if (memcmp(&sc
->sc_srom
[29], "DE500", 5) == 0 ||
1101 memcmp(&sc
->sc_srom
[29], "DE450", 5) == 0)
1102 memcpy(&sc
->sc_name
[4], &sc
->sc_srom
[29], 8);
1104 sc
->sc_name
[3] = '\0';
1108 tlp_pci_znyx_21040_quirks(struct tulip_pci_softc
*psc
, const uint8_t *enaddr
)
1110 struct tulip_softc
*sc
= &psc
->sc_tulip
;
1114 * If we have a slaved ROM, just copy the bits from the master.
1115 * This is in case we fail the ROM ID check (older boards) and
1116 * need to fall back on Ethernet address model checking; that
1117 * will fail for slave chips.
1119 if (psc
->sc_flags
& TULIP_PCI_SLAVEROM
) {
1120 strcpy(sc
->sc_name
, psc
->sc_master
->sc_tulip
.sc_name
);
1121 sc
->sc_mediasw
= psc
->sc_master
->sc_tulip
.sc_mediasw
;
1123 psc
->sc_master
->sc_flags
& TULIP_PCI_SHAREDINTR
;
1127 if (sc
->sc_srom
[32] == 0x4a && sc
->sc_srom
[33] == 0x52) {
1128 id
= sc
->sc_srom
[37] | (sc
->sc_srom
[36] << 8);
1131 case 0x0602: /* ZX312 */
1132 strcpy(sc
->sc_name
, "ZNYX ZX312");
1135 case 0x0622: /* ZX312T */
1136 strcpy(sc
->sc_name
, "ZNYX ZX312T");
1137 sc
->sc_mediasw
= &tlp_21040_tp_mediasw
;
1141 case 0x0701: /* ZX314 INTA */
1142 psc
->sc_flags
|= TULIP_PCI_SHAREDINTR
;
1144 case 0x0711: /* ZX314 */
1145 strcpy(sc
->sc_name
, "ZNYX ZX314");
1146 psc
->sc_flags
|= TULIP_PCI_SHAREDROM
;
1147 sc
->sc_mediasw
= &tlp_21040_tp_mediasw
;
1151 case 0x0801: /* ZX315 INTA */
1152 psc
->sc_flags
|= TULIP_PCI_SHAREDINTR
;
1154 case 0x0811: /* ZX315 */
1155 strcpy(sc
->sc_name
, "ZNYX ZX315");
1156 psc
->sc_flags
|= TULIP_PCI_SHAREDROM
;
1166 * Deal with boards that have broken ROMs.
1169 if ((enaddr
[3] & ~3) == 0xf0 && (enaddr
[5] & 3) == 0x00)
1171 if ((enaddr
[3] & ~3) == 0xf4 && (enaddr
[5] & 1) == 0x00)
1173 if ((enaddr
[3] & ~3) == 0xec)
1177 strcpy(sc
->sc_name
, "ZNYX ZX31x");
1180 static void tlp_pci_znyx_21142_qs6611_reset(struct tulip_softc
*);
1183 tlp_pci_znyx_21142_quirks(struct tulip_pci_softc
*psc
, const uint8_t *enaddr
)
1185 struct tulip_softc
*sc
= &psc
->sc_tulip
;
1188 subid
= pci_conf_read(psc
->sc_pc
, psc
->sc_pcitag
, PCI_SUBSYS_ID_REG
);
1190 if (PCI_VENDOR(subid
) != PCI_VENDOR_ZNYX
)
1193 switch (PCI_PRODUCT(subid
) & 0xff) {
1195 * ZNYX 21143 boards with QS6611 PHY
1197 case 0x12: /* ZX345Q */
1198 case 0x13: /* ZX346Q */
1199 case 0x14: /* ZX348Q */
1200 case 0x18: /* ZX414 */
1201 case 0x19: /* ZX412 */
1202 case 0x1a: /* ZX444 */
1203 case 0x1b: /* ZX442 */
1204 case 0x23: /* ZX212 */
1205 case 0x24: /* ZX214 */
1206 case 0x29: /* ZX374 */
1207 case 0x2d: /* ZX372 */
1208 case 0x2b: /* ZX244 */
1209 case 0x2c: /* ZX424 */
1210 case 0x2e: /* ZX422 */
1211 aprint_normal_dev(sc
->sc_dev
, "QS6611 PHY\n");
1212 sc
->sc_reset
= tlp_pci_znyx_21142_qs6611_reset
;
1218 tlp_pci_znyx_21142_qs6611_reset(struct tulip_softc
*sc
)
1224 TULIP_WRITE(sc
, CSR_SIAGEN
,
1225 SIAGEN_CWE
| SIAGEN_LGS1
| SIAGEN_ABM
| (0xf << 16));
1227 TULIP_WRITE(sc
, CSR_SIAGEN
, (0x4 << 16));
1232 tlp_pci_smc_21040_quirks(struct tulip_pci_softc
*psc
, const uint8_t *enaddr
)
1234 struct tulip_softc
*sc
= &psc
->sc_tulip
;
1235 uint16_t id1
, id2
, ei
;
1236 int auibnc
= 0, utp
= 0;
1239 id1
= sc
->sc_srom
[0x60] | (sc
->sc_srom
[0x61] << 8);
1240 id2
= sc
->sc_srom
[0x62] | (sc
->sc_srom
[0x63] << 8);
1241 ei
= sc
->sc_srom
[0x66] | (sc
->sc_srom
[0x67] << 8);
1243 strcpy(sc
->sc_name
, "SMC 8432");
1244 cp
= &sc
->sc_name
[8];
1246 if ((id1
& 1) == 0) {
1250 if ((id1
& 0xff) > 0x32) {
1254 if ((id1
& 0x4000) == 0) {
1259 sc
->sc_name
[7] = '4';
1263 *cp
++ = ei
? '2' : '1';
1267 if (utp
!= 0 && auibnc
== 0)
1268 sc
->sc_mediasw
= &tlp_21040_tp_mediasw
;
1269 else if (utp
== 0 && auibnc
!= 0)
1270 sc
->sc_mediasw
= &tlp_21040_auibnc_mediasw
;
1274 tlp_pci_cogent_21040_quirks(struct tulip_pci_softc
*psc
, const uint8_t *enaddr
)
1277 strcpy(psc
->sc_tulip
.sc_name
, "Cogent multi-port");
1278 psc
->sc_flags
|= TULIP_PCI_SHAREDINTR
|TULIP_PCI_SHAREDROM
;
1282 tlp_pci_accton_21040_quirks(struct tulip_pci_softc
*psc
, const uint8_t *enaddr
)
1285 strcpy(psc
->sc_tulip
.sc_name
, "ACCTON EN1203");
1288 static void tlp_pci_asante_21140_reset(struct tulip_softc
*);
1291 tlp_pci_asante_21140_quirks(struct tulip_pci_softc
*psc
, const uint8_t *enaddr
)
1293 struct tulip_softc
*sc
= &psc
->sc_tulip
;
1296 * Some Asante boards don't use the ISV SROM format. For
1297 * those that don't, we initialize the GPIO direction bits,
1298 * and provide our own reset hook, which resets the MII.
1300 * All of these boards use SIO-attached-MII media.
1302 if (sc
->sc_mediasw
== &tlp_2114x_isv_mediasw
)
1305 strcpy(sc
->sc_name
, "Asante");
1307 sc
->sc_gp_dir
= 0xbf;
1308 sc
->sc_reset
= tlp_pci_asante_21140_reset
;
1309 sc
->sc_mediasw
= &tlp_sio_mii_mediasw
;
1313 tlp_pci_e100_quirks(struct tulip_pci_softc
*psc
, const uint8_t *enaddr
)
1315 struct tulip_softc
*sc
= &psc
->sc_tulip
;
1317 if (sc
->sc_mediasw
== &tlp_2114x_isv_mediasw
)
1320 strcpy(sc
->sc_name
, "UMAX E100");
1322 sc
->sc_gp_dir
= 0xbf;
1323 sc
->sc_reset
= tlp_pci_asante_21140_reset
;
1324 sc
->sc_mediasw
= &tlp_sio_mii_mediasw
;
1328 tlp_pci_asante_21140_reset(struct tulip_softc
*sc
)
1331 TULIP_WRITE(sc
, CSR_GPP
, GPP_GPC
| sc
->sc_gp_dir
);
1332 TULIP_WRITE(sc
, CSR_GPP
, 0x8);
1334 TULIP_WRITE(sc
, CSR_GPP
, 0);
1337 static void tlp_pci_phobos_21140_reset(struct tulip_softc
*);
1340 tlp_pci_phobos_21140_quirks(struct tulip_pci_softc
*psc
, const uint8_t *enaddr
)
1342 struct tulip_softc
*sc
= &psc
->sc_tulip
;
1345 * Phobo boards just use MII-on_SIO.
1347 sc
->sc_mediasw
= &tlp_sio_mii_mediasw
;
1348 sc
->sc_reset
= tlp_pci_phobos_21140_reset
;
1351 * These boards appear solely on sgimips machines behind a special
1352 * GIO<->PCI ASIC and require the DBO and BLE bits to be set in CSR0.
1354 sc
->sc_flags
|= (TULIPF_BLE
| TULIPF_DBO
);
1358 tlp_pci_phobos_21140_reset(struct tulip_softc
*sc
)
1361 TULIP_WRITE(sc
, CSR_GPP
, 0x1fd);
1363 TULIP_WRITE(sc
, CSR_GPP
, 0xfd);
1365 TULIP_WRITE(sc
, CSR_GPP
, 0);
1369 * SMC 9332DST media switch.
1371 static void tlp_smc9332dst_tmsw_init(struct tulip_softc
*);
1373 static const struct tulip_mediasw tlp_smc9332dst_mediasw
= {
1374 tlp_smc9332dst_tmsw_init
,
1380 tlp_pci_smc_21140_quirks(struct tulip_pci_softc
*psc
, const uint8_t *enaddr
)
1382 struct tulip_softc
*sc
= &psc
->sc_tulip
;
1384 if (sc
->sc_mediasw
!= NULL
) {
1387 strcpy(psc
->sc_tulip
.sc_name
, "SMC 9332DST");
1388 sc
->sc_mediasw
= &tlp_smc9332dst_mediasw
;
1392 tlp_smc9332dst_tmsw_init(struct tulip_softc
*sc
)
1394 struct tulip_21x4x_media
*tm
;
1395 const char *sep
= "";
1399 sc
->sc_gp_dir
= GPP_SMC9332DST_PINS
;
1400 sc
->sc_opmode
= OPMODE_MBO
| OPMODE_PS
;
1401 TULIP_WRITE(sc
, CSR_OPMODE
, sc
->sc_opmode
);
1403 ifmedia_init(&sc
->sc_mii
.mii_media
, 0, tlp_mediachange
,
1405 aprint_normal_dev(sc
->sc_dev
, "");
1408 tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO); \
1409 tm->tm_opmode = (c); \
1410 tm->tm_gpdata = GPP_SMC9332DST_INIT; \
1411 ifmedia_add(&sc->sc_mii.mii_media, (m), 0, tm)
1412 #define PRINT(str) aprint_normal("%s%s", sep, str); sep = ", "
1414 ADD(IFM_MAKEWORD(IFM_ETHER
, IFM_10_T
, 0, 0), OPMODE_TTM
);
1417 ADD(IFM_MAKEWORD(IFM_ETHER
, IFM_10_T
, IFM_FDX
, 0),
1418 OPMODE_TTM
| OPMODE_FD
);
1419 PRINT("10baseT-FDX");
1421 ADD(IFM_MAKEWORD(IFM_ETHER
, IFM_100_TX
, 0, 0),
1422 OPMODE_PS
| OPMODE_PCS
| OPMODE_SCR
);
1425 ADD(IFM_MAKEWORD(IFM_ETHER
, IFM_100_TX
, IFM_FDX
, 0),
1426 OPMODE_PS
| OPMODE_PCS
| OPMODE_SCR
| OPMODE_FD
);
1427 PRINT("100baseTX-FDX");
1432 aprint_normal("\n");
1435 TULIP_WRITE(sc
, CSR_OPMODE
, sc
->sc_opmode
| OPMODE_PCS
| OPMODE_SCR
);
1436 TULIP_WRITE(sc
, CSR_GPP
, GPP_GPC
| sc
->sc_gp_dir
);
1438 TULIP_WRITE(sc
, CSR_GPP
, GPP_SMC9332DST_INIT
);
1441 for (i
= 1000; i
> 0; i
--) {
1442 reg
= TULIP_READ(sc
, CSR_GPP
);
1443 if ((~reg
& (GPP_SMC9332DST_OK10
|
1444 GPP_SMC9332DST_OK100
)) == 0) {
1448 } else if ((reg
& GPP_SMC9332DST_OK10
) == 0) {
1456 ifmedia_set(&sc
->sc_mii
.mii_media
, IFM_ETHER
|IFM_100_TX
);
1458 ifmedia_set(&sc
->sc_mii
.mii_media
, IFM_ETHER
|IFM_10_T
);
1463 tlp_pci_vpc_21140_quirks(struct tulip_pci_softc
*psc
, const uint8_t *enaddr
)
1465 struct tulip_softc
*sc
= &psc
->sc_tulip
;
1466 char *p1
= (char *) &sc
->sc_srom
[32];
1467 char *p2
= &sc
->sc_name
[0];
1470 if ((unsigned char) *p1
& 0x80)
1477 static void tlp_pci_cobalt_21142_reset(struct tulip_softc
*);
1480 tlp_pci_cobalt_21142_quirks(struct tulip_pci_softc
*psc
, const uint8_t *enaddr
)
1482 struct tulip_softc
*sc
= &psc
->sc_tulip
;
1485 * Cobalt Networks interfaces are just MII-on-SIO.
1487 sc
->sc_reset
= tlp_pci_cobalt_21142_reset
;
1488 sc
->sc_mediasw
= &tlp_sio_mii_mediasw
;
1491 * The Cobalt systems tend to fall back to store-and-forward
1492 * pretty quickly, so we select that from the beginning to
1493 * avoid initial timeouts.
1495 sc
->sc_txthresh
= TXTH_SF
;
1499 tlp_pci_cobalt_21142_reset(struct tulip_softc
*sc
)
1505 TULIP_WRITE(sc
, CSR_SIAGEN
, SIAGEN_CWE
| (1 << 16));
1507 TULIP_WRITE(sc
, CSR_SIAGEN
, SIAGEN_CWE
);
1512 tlp_pci_algor_21142_quirks(struct tulip_pci_softc
*psc
, const uint8_t *enaddr
)
1514 struct tulip_softc
*sc
= &psc
->sc_tulip
;
1517 * Algorithmics boards just have MII-on-SIO.
1519 * XXX They also have AUI on the serial interface.
1520 * XXX Deal with this.
1522 sc
->sc_mediasw
= &tlp_sio_mii_mediasw
;
1526 * Cogent EM1x0 (aka. Adaptec ANA-6910) media switch.
1528 static void tlp_cogent_em1x0_tmsw_init(struct tulip_softc
*);
1530 static const struct tulip_mediasw tlp_cogent_em1x0_mediasw
= {
1531 tlp_cogent_em1x0_tmsw_init
,
1537 tlp_pci_adaptec_quirks(struct tulip_pci_softc
*psc
, const uint8_t *enaddr
)
1539 struct tulip_softc
*sc
= &psc
->sc_tulip
;
1540 uint8_t *srom
= sc
->sc_srom
, id0
;
1543 if (sc
->sc_mediasw
== NULL
) {
1547 strcpy(psc
->sc_tulip
.sc_name
, "Cogent EM100TX");
1548 sc
->sc_mediasw
= &tlp_cogent_em1x0_mediasw
;
1552 strcpy(psc
->sc_tulip
.sc_name
, "Cogent EM100FX");
1553 sc
->sc_mediasw
= &tlp_cogent_em1x0_mediasw
;
1558 strcpy(psc
->sc_tulip
.sc_name
, "Cogent EM110TX");
1559 sc
->sc_mediasw
= &tlp_cogent_em1x0_mediasw
;
1564 printf("%s: unknown Cogent board ID 0x%02x\n",
1565 device_xname(sc
->sc_dev
), id0
);
1570 id1
= TULIP_ROM_GETW(srom
, 0);
1571 id2
= TULIP_ROM_GETW(srom
, 2);
1572 if (id1
!= 0x1109) {
1578 strcpy(psc
->sc_tulip
.sc_name
, "Adaptec ANA-6911");
1582 strcpy(psc
->sc_tulip
.sc_name
, "Adaptec ANA-6944A");
1583 psc
->sc_flags
|= TULIP_PCI_SHAREDINTR
|TULIP_PCI_SHAREDROM
;
1587 strcpy(psc
->sc_tulip
.sc_name
, "Adaptec ANA-6911A");
1591 strcpy(psc
->sc_tulip
.sc_name
, "Adaptec ANA-6922");
1592 psc
->sc_flags
|= TULIP_PCI_SHAREDINTR
|TULIP_PCI_SHAREDROM
;
1597 printf("%s: unknown Adaptec/Cogent board ID 0x%04x/0x%04x\n",
1598 device_xname(sc
->sc_dev
), id1
, id2
);
1603 tlp_cogent_em1x0_tmsw_init(struct tulip_softc
*sc
)
1605 struct tulip_21x4x_media
*tm
;
1606 const char *sep
= "";
1608 sc
->sc_gp_dir
= GPP_COGENT_EM1x0_PINS
;
1609 sc
->sc_opmode
= OPMODE_MBO
| OPMODE_PS
;
1610 TULIP_WRITE(sc
, CSR_OPMODE
, sc
->sc_opmode
);
1612 ifmedia_init(&sc
->sc_mii
.mii_media
, 0, tlp_mediachange
,
1614 aprint_normal_dev(sc
->sc_dev
, "");
1617 tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO); \
1618 tm->tm_opmode = (c); \
1619 tm->tm_gpdata = GPP_COGENT_EM1x0_INIT; \
1620 ifmedia_add(&sc->sc_mii.mii_media, (m), 0, tm)
1621 #define PRINT(str) aprint_normal("%s%s", sep, str); sep = ", "
1623 if (sc
->sc_srom
[32] == 0x15) {
1624 ADD(IFM_MAKEWORD(IFM_ETHER
, IFM_100_FX
, 0, 0),
1625 OPMODE_PS
| OPMODE_PCS
);
1628 ADD(IFM_MAKEWORD(IFM_ETHER
, IFM_100_FX
, IFM_FDX
, 0),
1629 OPMODE_PS
| OPMODE_PCS
| OPMODE_FD
);
1630 PRINT("100baseFX-FDX");
1631 aprint_normal("\n");
1633 ifmedia_set(&sc
->sc_mii
.mii_media
, IFM_ETHER
|IFM_100_FX
);
1635 ADD(IFM_MAKEWORD(IFM_ETHER
, IFM_100_TX
, 0, 0),
1636 OPMODE_PS
| OPMODE_PCS
| OPMODE_SCR
);
1639 ADD(IFM_MAKEWORD(IFM_ETHER
, IFM_100_FX
, IFM_FDX
, 0),
1640 OPMODE_PS
| OPMODE_PCS
| OPMODE_SCR
| OPMODE_FD
);
1641 PRINT("100baseTX-FDX");
1642 aprint_normal("\n");
1644 ifmedia_set(&sc
->sc_mii
.mii_media
, IFM_ETHER
|IFM_100_TX
);
1651 static void tlp_pci_netwinder_21142_reset(struct tulip_softc
*);
1654 tlp_pci_netwinder_21142_quirks(struct tulip_pci_softc
*psc
,
1655 const uint8_t *enaddr
)
1657 struct tulip_softc
*sc
= &psc
->sc_tulip
;
1660 * Netwinders just use MII-on_SIO.
1662 sc
->sc_mediasw
= &tlp_sio_mii_mediasw
;
1663 sc
->sc_reset
= tlp_pci_netwinder_21142_reset
;
1667 tlp_pci_netwinder_21142_reset(struct tulip_softc
*sc
)
1673 TULIP_WRITE(sc
, CSR_SIAGEN
, 0x0821 << 16);
1675 TULIP_WRITE(sc
, CSR_SIAGEN
, 0x0000 << 16);
1677 TULIP_WRITE(sc
, CSR_SIAGEN
, 0x0001 << 16);
1681 static void tlp_pci_phobos_21142_reset(struct tulip_softc
*);
1684 tlp_pci_phobos_21142_quirks(struct tulip_pci_softc
*psc
, const uint8_t *enaddr
)
1686 struct tulip_softc
*sc
= &psc
->sc_tulip
;
1689 * Phobo boards just use MII-on_SIO.
1691 sc
->sc_mediasw
= &tlp_sio_mii_mediasw
;
1692 sc
->sc_reset
= tlp_pci_phobos_21142_reset
;
1695 * These boards appear solely on sgimips machines behind a special
1696 * GIO<->PCI ASIC and require the DBO and BLE bits to be set in CSR0.
1698 sc
->sc_flags
|= (TULIPF_BLE
| TULIPF_DBO
);
1702 tlp_pci_phobos_21142_reset(struct tulip_softc
*sc
)
1707 TULIP_WRITE(sc
, CSR_SIAGEN
, (0x880f << 16));
1709 TULIP_WRITE(sc
, CSR_SIAGEN
, (0x800f << 16));