Home | History | Annotate | Download | only in net
      1 /* -*- Mode:C; c-basic-offset:4; -*- */
      2 
      3 /*
      4   Tulip and clone Etherboot Driver
      5 
      6   By Marty Connor (mdc (at) etherboot.org)
      7   Copyright (C) 2001 Entity Cyber, Inc.
      8 
      9   This software may be used and distributed according to the terms
     10   of the GNU Public License, incorporated herein by reference.
     11 
     12   As of April 2001 this driver should support most tulip cards that
     13   the Linux tulip driver supports because Donald Becker's Linux media
     14   detection code is now included.
     15 
     16   Based on Ken Yap's Tulip Etherboot Driver and Donald Becker's
     17   Linux Tulip Driver. Supports N-Way speed auto-configuration on
     18   MX98715, MX98715A and MX98725. Support inexpensive PCI 10/100 cards
     19   based on the Macronix MX987x5 chip, such as the SOHOware Fast
     20   model SFA110A, and the LinkSYS model LNE100TX. The NetGear
     21   model FA310X, based on the LC82C168 chip is supported.
     22   The TRENDnet TE100-PCIA NIC which uses a genuine Intel 21143-PD
     23   chipset is supported. Also, Davicom DM9102's.
     24 
     25   Documentation and source code used:
     26   Source for Etherboot driver at
     27   http://etherboot.sourceforge.net/
     28   MX98715A Data Sheet and MX98715A Application Note
     29   on http://www.macronix.com/  (PDF format files)
     30   Source for Linux tulip driver at
     31   http://cesdis.gsfc.nasa.gov/linux/drivers/tulip.html
     32 
     33   Adapted by Ken Yap from
     34   FreeBSD netboot DEC 21143 driver
     35   Author: David Sharp
     36   date: Nov/98
     37 
     38   Some code fragments were taken from verious places, Ken Yap's
     39   etherboot, FreeBSD's if_de.c, and various Linux related files.
     40   DEC's manuals for the 21143 and SROM format were very helpful.
     41   The Linux de driver development page has a number of links to
     42   useful related information.  Have a look at:
     43   ftp://cesdis.gsfc.nasa.gov/pub/linux/drivers/tulip-devel.html
     44 */
     45 
     46 FILE_LICENCE ( GPL_ANY );
     47 
     48 /*********************************************************************/
     49 /* Revision History                                                  */
     50 /*********************************************************************/
     51 
     52 /*
     53   08 Feb 2005  Ramesh Chander chhabaramesh at yahoo.co.in added table entries
     54                for SGThomson STE10/100A
     55   07 Sep 2003  timlegge	Multicast Support Added
     56   11 Apr 2001  mdc     [patch to etherboot 4.7.24]
     57      Major rewrite to include Linux tulip driver media detection
     58      code.  This driver should support a lot more cards now.
     59   16 Jul 2000  mdc     0.75b11
     60      Added support for ADMtek 0985 Centaur-P, a "Comet" tulip clone
     61      which is used on the LinkSYS LNE100TX v4.x cards.  We already
     62      support LNE100TX v2.0 cards, which use a different controller.
     63   04 Jul 2000   jam     ?
     64      Added test of status after receiving a packet from the card.
     65      Also uncommented the tulip_disable routine.  Stray packets
     66      seemed to be causing problems.
     67   27 Apr 2000   njl     ?
     68   29 Feb 2000   mdc     0.75b7
     69      Increased reset delay to 3 seconds because Macronix cards seem to
     70      need more reset time before card comes back to a usable state.
     71   26 Feb 2000   mdc     0.75b6
     72      Added a 1 second delay after initializing the transmitter because
     73      some cards seem to need the time or they drop the first packet
     74      transmitted.
     75   23 Feb 2000   mdc     0.75b5
     76      removed udelay code and used currticks() for more reliable delay
     77      code in reset pause and sanity timeouts.  Added function prototypes
     78      and TX debugging code.
     79   21 Feb 2000   mdc     patch to Etherboot 4.4.3
     80      Incorporated patches from Bob Edwards and Paul Mackerras of
     81      Linuxcare's OZLabs to deal with inefficiencies in tulip_transmit
     82      and udelay.  We now wait for packet transmission to complete
     83      (or sanity timeout).
     84   04 Feb 2000   Robert.Edwards (at) anu.edu.au patch to Etherboot 4.4.2
     85      patch to tulip.c that implements the automatic selection of the MII
     86      interface on cards using the Intel/DEC 21143 reference design, in
     87      particular, the TRENDnet TE100-PCIA NIC which uses a genuine Intel
     88      21143-PD chipset.
     89   11 Jan 2000   mdc     0.75b4
     90      Added support for NetGear FA310TX card based on the LC82C168
     91      chip.  This should also support Lite-On LC82C168 boards.
     92      Added simple MII support. Re-arranged code to better modularize
     93      initializations.
     94   04 Dec 1999   mdc     0.75b3
     95      Added preliminary support for LNE100TX PCI cards.  Should work for
     96      PNIC2 cards. No MII support, but single interface (RJ45) tulip
     97      cards seem to not care.
     98   03 Dec 1999   mdc     0.75b2
     99      Renamed from mx987x5 to tulip, merged in original tulip init code
    100      from tulip.c to support other tulip compatible cards.
    101   02 Dec 1999   mdc     0.75b1
    102      Released Beta MX987x5 Driver for code review and testing to netboot
    103      and thinguin mailing lists.
    104 */
    105 
    106 
    107 /*********************************************************************/
    109 /* Declarations                                                      */
    110 /*********************************************************************/
    111 
    112 #include "etherboot.h"
    113 #include "nic.h"
    114 
    115 #include <gpxe/ethernet.h>
    116 #include <gpxe/pci.h>
    117 
    118 /* User settable parameters */
    119 
    120 #undef	TULIP_DEBUG
    121 #undef	TULIP_DEBUG_WHERE
    122 #ifdef	TULIP_DEBUG
    123 static int tulip_debug = 2;             /* 1 normal messages, 0 quiet .. 7 verbose. */
    124 #endif
    125 
    126 #define TX_TIME_OUT       2*TICKS_PER_SEC
    127 
    128 /* helpful macros if on a big_endian machine for changing byte order.
    129    not strictly needed on Intel */
    130 #define get_unaligned(ptr) (*(ptr))
    131 #define put_unaligned(val, ptr) ((void)( *(ptr) = (val) ))
    132 #define get_u16(ptr) (*(u16 *)(ptr))
    133 #define virt_to_le32desc(addr)  virt_to_bus(addr)
    134 
    135 #define TULIP_IOTYPE  PCI_USES_MASTER | PCI_USES_IO | PCI_ADDR0
    136 #define TULIP_SIZE 0x80
    137 
    138 /* This is a mysterious value that can be written to CSR11 in the 21040 (only)
    139    to support a pre-NWay full-duplex signaling mechanism using short frames.
    140    No one knows what it should be, but if left at its default value some
    141    10base2(!) packets trigger a full-duplex-request interrupt. */
    142 #define FULL_DUPLEX_MAGIC       0x6969
    143 
    144 static const int csr0 = 0x01A00000 | 0x8000;
    145 
    146 /*  The possible media types that can be set in options[] are: */
    147 #define MEDIA_MASK 31
    148 static const char * const medianame[32] = {
    149     "10baseT", "10base2", "AUI", "100baseTx",
    150     "10baseT-FDX", "100baseTx-FDX", "100baseT4", "100baseFx",
    151     "100baseFx-FDX", "MII 10baseT", "MII 10baseT-FDX", "MII",
    152     "10baseT(forced)", "MII 100baseTx", "MII 100baseTx-FDX", "MII 100baseT4",
    153     "MII 100baseFx-HDX", "MII 100baseFx-FDX", "Home-PNA 1Mbps", "Invalid-19",
    154 };
    155 
    156 /* This much match tulip_tbl[]!  Note 21142 == 21143. */
    157 enum tulip_chips {
    158     DC21040=0, DC21041=1, DC21140=2, DC21142=3, DC21143=3,
    159     LC82C168, MX98713, MX98715, MX98725, AX88141, AX88140, PNIC2, COMET,
    160     COMPEX9881, I21145, XIRCOM, SGThomson,	/*Ramesh Chander*/
    161 };
    162 
    163 enum pci_id_flags_bits {
    164     /* Set PCI command register bits before calling probe1(). */
    165     PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4,
    166     /* Read and map the single following PCI BAR. */
    167     PCI_ADDR0=0<<4, PCI_ADDR1=1<<4, PCI_ADDR2=2<<4, PCI_ADDR3=3<<4,
    168     PCI_ADDR_64BITS=0x100, PCI_NO_ACPI_WAKE=0x200, PCI_NO_MIN_LATENCY=0x400,
    169     PCI_UNUSED_IRQ=0x800,
    170 };
    171 
    172 struct pci_id_info {
    173     char *name;
    174     struct match_info {
    175         u32 pci, pci_mask, subsystem, subsystem_mask;
    176         u32 revision, revision_mask;                            /* Only 8 bits. */
    177     } id;
    178     enum pci_id_flags_bits pci_flags;
    179     int io_size;                                /* Needed for I/O region check or ioremap(). */
    180     int drv_flags;                              /* Driver use, intended as capability flags. */
    181 };
    182 
    183 static const struct pci_id_info pci_id_tbl[] = {
    184     { "Digital DC21040 Tulip", { 0x00021011, 0xffffffff, 0, 0, 0, 0 },
    185       TULIP_IOTYPE, 0x80, DC21040 },
    186     { "Digital DC21041 Tulip", { 0x00141011, 0xffffffff, 0, 0, 0, 0 },
    187       TULIP_IOTYPE, 0x80, DC21041 },
    188     { "Digital DS21140A Tulip", { 0x00091011, 0xffffffff, 0,0, 0x20,0xf0 },
    189       TULIP_IOTYPE, 0x80, DC21140 },
    190     { "Digital DS21140 Tulip", { 0x00091011, 0xffffffff, 0, 0, 0, 0 },
    191       TULIP_IOTYPE, 0x80, DC21140 },
    192     { "Digital DS21143 Tulip", { 0x00191011, 0xffffffff, 0,0, 65,0xff },
    193       TULIP_IOTYPE, TULIP_SIZE, DC21142 },
    194     { "Digital DS21142 Tulip", { 0x00191011, 0xffffffff, 0, 0, 0, 0 },
    195       TULIP_IOTYPE, TULIP_SIZE, DC21142 },
    196     { "Kingston KNE110tx (PNIC)", { 0x000211AD, 0xffffffff, 0xf0022646, 0xffffffff, 0, 0 },
    197       TULIP_IOTYPE, 256, LC82C168 },
    198     { "Lite-On 82c168 PNIC", { 0x000211AD, 0xffffffff, 0, 0, 0, 0 },
    199       TULIP_IOTYPE, 256, LC82C168 },
    200     { "Macronix 98713 PMAC", { 0x051210d9, 0xffffffff, 0, 0, 0, 0 },
    201       TULIP_IOTYPE, 256, MX98713 },
    202     { "Macronix 98715 PMAC", { 0x053110d9, 0xffffffff, 0, 0, 0, 0 },
    203       TULIP_IOTYPE, 256, MX98715 },
    204     { "Macronix 98725 PMAC", { 0x053110d9, 0xffffffff, 0, 0, 0, 0 },
    205       TULIP_IOTYPE, 256, MX98725 },
    206     { "ASIX AX88141", { 0x1400125B, 0xffffffff, 0,0, 0x10, 0xf0 },
    207       TULIP_IOTYPE, 128, AX88141 },
    208     { "ASIX AX88140", { 0x1400125B, 0xffffffff, 0, 0, 0, 0 },
    209       TULIP_IOTYPE, 128, AX88140 },
    210     { "Lite-On LC82C115 PNIC-II", { 0xc11511AD, 0xffffffff, 0, 0, 0, 0 },
    211       TULIP_IOTYPE, 256, PNIC2 },
    212     { "ADMtek AN981 Comet", { 0x09811317, 0xffffffff, 0, 0, 0, 0 },
    213       TULIP_IOTYPE, 256, COMET },
    214     { "ADMTek AN983 Comet", { 0x12161113, 0xffffffff, 0, 0, 0, 0 },
    215       TULIP_IOTYPE, 256, COMET },
    216     { "ADMTek Comet AN983b", { 0x95111317, 0xffffffff, 0, 0, 0, 0 },
    217       TULIP_IOTYPE, 256, COMET },
    218     { "ADMtek Centaur-P", { 0x09851317, 0xffffffff, 0, 0, 0, 0 },
    219       TULIP_IOTYPE, 256, COMET },
    220     { "ADMtek Centaur-C", { 0x19851317, 0xffffffff, 0, 0, 0, 0 },
    221       TULIP_IOTYPE, 256, COMET },
    222     { "Compex RL100-TX", { 0x988111F6, 0xffffffff, 0, 0, 0, 0 },
    223       TULIP_IOTYPE, 128, COMPEX9881 },
    224     { "Intel 21145 Tulip", { 0x00398086, 0xffffffff, 0, 0, 0, 0 },
    225       TULIP_IOTYPE, 128, I21145 },
    226     { "Xircom Tulip clone", { 0x0003115d, 0xffffffff, 0, 0, 0, 0 },
    227       TULIP_IOTYPE, 128, XIRCOM },
    228     { "Davicom DM9102", { 0x91021282, 0xffffffff, 0, 0, 0, 0 },
    229       TULIP_IOTYPE, 0x80, DC21140 },
    230     { "Davicom DM9100", { 0x91001282, 0xffffffff, 0, 0, 0, 0 },
    231       TULIP_IOTYPE, 0x80, DC21140 },
    232     { "Macronix mxic-98715 (EN1217)", { 0x12171113, 0xffffffff, 0, 0, 0, 0 },
    233       TULIP_IOTYPE, 256, MX98715 },
    234     { "3Com 3cSOHO100B-TX (ADMtek Centuar)", { 0x930010b7, 0xffffffff, 0, 0, 0, 0 },
    235       TULIP_IOTYPE, TULIP_SIZE, COMET },
    236     { "SG Thomson STE10/100A", { 0x2774104a, 0xffffffff, 0, 0, 0, 0 },
    237       TULIP_IOTYPE, 256, COMET },	/*Ramesh Chander*/
    238     { 0, { 0, 0, 0, 0, 0, 0 }, 0, 0, 0 },
    239 };
    240 
    241 enum tbl_flag {
    242     HAS_MII=1, HAS_MEDIA_TABLE=2, CSR12_IN_SROM=4, ALWAYS_CHECK_MII=8,
    243     HAS_PWRDWN=0x10, MC_HASH_ONLY=0x20, /* Hash-only multicast filter. */
    244     HAS_PNICNWAY=0x80, HAS_NWAY=0x40,   /* Uses internal NWay xcvr. */
    245     HAS_INTR_MITIGATION=0x100, IS_ASIX=0x200, HAS_8023X=0x400,
    246 };
    247 
    248 /* Note: this table must match  enum tulip_chips  above. */
    249 static struct tulip_chip_table {
    250     char *chip_name;
    251     int flags;
    252 } tulip_tbl[] = {
    253     { "Digital DC21040 Tulip", 0},
    254     { "Digital DC21041 Tulip", HAS_MEDIA_TABLE | HAS_NWAY },
    255     { "Digital DS21140 Tulip", HAS_MII | HAS_MEDIA_TABLE | CSR12_IN_SROM },
    256     { "Digital DS21143 Tulip", HAS_MII | HAS_MEDIA_TABLE | ALWAYS_CHECK_MII
    257       | HAS_PWRDWN | HAS_NWAY   | HAS_INTR_MITIGATION },
    258     { "Lite-On 82c168 PNIC", HAS_MII | HAS_PNICNWAY },
    259     { "Macronix 98713 PMAC", HAS_MII | HAS_MEDIA_TABLE | CSR12_IN_SROM },
    260     { "Macronix 98715 PMAC", HAS_MEDIA_TABLE },
    261     { "Macronix 98725 PMAC", HAS_MEDIA_TABLE },
    262     { "ASIX AX88140", HAS_MII | HAS_MEDIA_TABLE | CSR12_IN_SROM
    263       | MC_HASH_ONLY | IS_ASIX },
    264     { "ASIX AX88141", HAS_MII | HAS_MEDIA_TABLE | CSR12_IN_SROM | MC_HASH_ONLY
    265       | IS_ASIX },
    266     { "Lite-On PNIC-II", HAS_MII | HAS_NWAY | HAS_8023X },
    267     { "ADMtek Comet", HAS_MII | MC_HASH_ONLY },
    268     { "Compex 9881 PMAC",       HAS_MII | HAS_MEDIA_TABLE | CSR12_IN_SROM },
    269     { "Intel DS21145 Tulip", HAS_MII | HAS_MEDIA_TABLE | ALWAYS_CHECK_MII
    270       | HAS_PWRDWN | HAS_NWAY },
    271     { "Xircom tulip work-alike", HAS_MII | HAS_MEDIA_TABLE | ALWAYS_CHECK_MII
    272       | HAS_PWRDWN | HAS_NWAY },
    273     { "SGThomson STE10/100A", HAS_MII | MC_HASH_ONLY },	/*Ramesh Chander*/
    274     { 0, 0 },
    275 };
    276 
    277 /* A full-duplex map for media types. */
    278 enum MediaIs {
    279     MediaIsFD = 1, MediaAlwaysFD=2, MediaIsMII=4, MediaIsFx=8,
    280     MediaIs100=16};
    281 
    282 static const char media_cap[32] =
    283 {0,0,0,16,  3,19,16,24,  27,4,7,5, 0,20,23,20, 20,31,0,0, };
    284 static u8 t21040_csr13[] = {2,0x0C,8,4,  4,0,0,0, 0,0,0,0, 4,0,0,0};
    285 
    286 /* 21041 transceiver register settings: 10-T, 10-2, AUI, 10-T, 10T-FD */
    287 static u16 t21041_csr13[] = { 0xEF01, 0xEF09, 0xEF09, 0xEF01, 0xEF09, };
    288 static u16 t21041_csr14[] = { 0xFFFF, 0xF7FD, 0xF7FD, 0x7F3F, 0x7F3D, };
    289 static u16 t21041_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
    290 
    291 /* not used
    292 static u16 t21142_csr13[] = { 0x0001, 0x0009, 0x0009, 0x0000, 0x0001, };
    293 */
    294 static u16 t21142_csr14[] = { 0xFFFF, 0x0705, 0x0705, 0x0000, 0x7F3D, };
    295 /* not used
    296 static u16 t21142_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
    297 */
    298 
    299 /* Offsets to the Command and Status Registers, "CSRs".  All accesses
    300    must be longword instructions and quadword aligned. */
    301 enum tulip_offsets {
    302     CSR0=0,     CSR1=0x08,  CSR2=0x10,  CSR3=0x18,  CSR4=0x20,  CSR5=0x28,
    303     CSR6=0x30,  CSR7=0x38,  CSR8=0x40,  CSR9=0x48, CSR10=0x50, CSR11=0x58,
    304     CSR12=0x60, CSR13=0x68, CSR14=0x70, CSR15=0x78, CSR16=0x80, CSR20=0xA0
    305 };
    306 
    307 /* The bits in the CSR5 status registers, mostly interrupt sources. */
    308 enum status_bits {
    309     TimerInt=0x800, TPLnkFail=0x1000, TPLnkPass=0x10,
    310     NormalIntr=0x10000, AbnormalIntr=0x8000,
    311     RxJabber=0x200, RxDied=0x100, RxNoBuf=0x80, RxIntr=0x40,
    312     TxFIFOUnderflow=0x20, TxJabber=0x08, TxNoBuf=0x04, TxDied=0x02, TxIntr=0x01,
    313 };
    314 
    315 /* The configuration bits in CSR6. */
    316 enum csr6_mode_bits {
    317 	TxOn=0x2000, RxOn=0x0002, FullDuplex=0x0200,
    318 	AcceptBroadcast=0x0100, AcceptAllMulticast=0x0080,
    319 	AcceptAllPhys=0x0040, AcceptRunt=0x0008,
    320 };
    321 
    322 
    323 enum desc_status_bits {
    324     DescOwnded=0x80000000, RxDescFatalErr=0x8000, RxWholePkt=0x0300,
    325 };
    326 
    327 struct medialeaf {
    328     u8 type;
    329     u8 media;
    330     unsigned char *leafdata;
    331 };
    332 
    333 struct mediatable {
    334     u16 defaultmedia;
    335     u8 leafcount, csr12dir;                             /* General purpose pin directions. */
    336     unsigned has_mii:1, has_nonmii:1, has_reset:6;
    337     u32 csr15dir, csr15val;                             /* 21143 NWay setting. */
    338     struct medialeaf mleaf[0];
    339 };
    340 
    341 struct mediainfo {
    342     struct mediainfo *next;
    343     int info_type;
    344     int index;
    345     unsigned char *info;
    346 };
    347 
    348 /* EEPROM Address width definitions */
    349 #define EEPROM_ADDRLEN 6
    350 #define EEPROM_SIZE    128              /* 2 << EEPROM_ADDRLEN */
    351 
    352 /* The EEPROM commands include the alway-set leading bit. */
    353 #define EE_WRITE_CMD    (5 << addr_len)
    354 #define EE_READ_CMD     (6 << addr_len)
    355 #define EE_ERASE_CMD    (7 << addr_len)
    356 
    357 /* EEPROM_Ctrl bits. */
    358 #define EE_SHIFT_CLK    0x02    /* EEPROM shift clock. */
    359 #define EE_CS           0x01    /* EEPROM chip select. */
    360 #define EE_DATA_WRITE   0x04    /* EEPROM chip data in. */
    361 #define EE_WRITE_0      0x01
    362 #define EE_WRITE_1      0x05
    363 #define EE_DATA_READ    0x08    /* EEPROM chip data out. */
    364 #define EE_ENB          (0x4800 | EE_CS)
    365 
    366 /* Delay between EEPROM clock transitions.  Even at 33Mhz current PCI
    367    implementations don't overrun the EEPROM clock.  We add a bus
    368    turn-around to insure that this remains true.  */
    369 #define eeprom_delay()  inl(ee_addr)
    370 
    371 /* Size of transmit and receive buffers */
    372 #define BUFLEN 1536
    373 
    374 /* Ring-wrap flag in length field, use for last ring entry.
    375    0x01000000 means chain on buffer2 address,
    376    0x02000000 means use the ring start address in CSR2/3.
    377    Note: Some work-alike chips do not function correctly in chained mode.
    378    The ASIX chip works only in chained mode.
    379    Thus we indicate ring mode, but always write the 'next' field for
    380    chained mode as well. */
    381 #define DESC_RING_WRAP 0x02000000
    382 
    383 /* transmit and receive descriptor format */
    384 struct tulip_rx_desc {
    385     volatile u32 status;
    386     u32 length;
    387     u32 buffer1, buffer2;
    388 };
    389 
    390 struct tulip_tx_desc {
    391     volatile u32 status;
    392     u32 length;
    393     u32 buffer1, buffer2;
    394 };
    395 
    396 /*********************************************************************/
    397 /* Global Storage                                                    */
    398 /*********************************************************************/
    399 
    400 static u32 ioaddr;
    401 
    402 struct tulip_private {
    403     int cur_rx;
    404     int chip_id;                        /* index into tulip_tbl[]  */
    405     int pci_id_idx;                     /* index into pci_id_tbl[] */
    406     int revision;
    407     int flags;
    408     unsigned short vendor_id;           /* PCI card vendor code */
    409     unsigned short dev_id;              /* PCI card device code */
    410     unsigned char ehdr[ETH_HLEN];       /* buffer for ethernet header */
    411     const char *nic_name;
    412     unsigned int csr0, csr6;            /* Current CSR0, CSR6 settings. */
    413     unsigned int if_port;
    414     unsigned int full_duplex;         /* Full-duplex operation requested. */
    415     unsigned int full_duplex_lock;
    416     unsigned int medialock;           /* Do not sense media type. */
    417     unsigned int mediasense;          /* Media sensing in progress. */
    418     unsigned int nway, nwayset;     /* 21143 internal NWay. */
    419     unsigned int default_port;
    420     unsigned char eeprom[EEPROM_SIZE];  /* Serial EEPROM contents. */
    421     u8 media_table_storage[(sizeof(struct mediatable) + 32*sizeof(struct medialeaf))];
    422     u16 sym_advertise, mii_advertise;   /* NWay to-advertise. */
    423     struct mediatable *mtable;
    424     u16 lpar;                           /* 21143 Link partner ability. */
    425     u16 advertising[4];                 /* MII advertise, from SROM table. */
    426     signed char phys[4], mii_cnt;       /* MII device addresses. */
    427     int cur_index;                      /* Current media index. */
    428     int saved_if_port;
    429 };
    430 
    431 /* Note: transmit and receive buffers must be longword aligned and
    432    longword divisable */
    433 
    434 #define TX_RING_SIZE	2
    435 #define RX_RING_SIZE	4
    436 struct {
    437     struct tulip_tx_desc tx_ring[TX_RING_SIZE];
    438     unsigned char txb[BUFLEN];
    439     struct tulip_rx_desc rx_ring[RX_RING_SIZE];
    440     unsigned char rxb[RX_RING_SIZE * BUFLEN];
    441     struct tulip_private tpx;
    442 } tulip_bss __shared __attribute__ ((aligned(4)));
    443 #define tx_ring tulip_bss.tx_ring
    444 #define txb tulip_bss.txb
    445 #define rx_ring tulip_bss.rx_ring
    446 #define rxb tulip_bss.rxb
    447 
    448 static struct tulip_private *tp;
    449 
    450 /* Known cards that have old-style EEPROMs.
    451    Writing this table is described at
    452    http://cesdis.gsfc.nasa.gov/linux/drivers/tulip-drivers/tulip-media.html */
    453 static struct fixups {
    454     char *name;
    455     unsigned char addr0, addr1, addr2;
    456     u16 newtable[32];                           /* Max length below. */
    457 } eeprom_fixups[] = {
    458     {"Asante", 0, 0, 0x94, {0x1e00, 0x0000, 0x0800, 0x0100, 0x018c,
    459                             0x0000, 0x0000, 0xe078, 0x0001, 0x0050, 0x0018 }},
    460     {"SMC9332DST", 0, 0, 0xC0, { 0x1e00, 0x0000, 0x0800, 0x041f,
    461                                  0x0000, 0x009E, /* 10baseT */
    462                                  0x0004, 0x009E, /* 10baseT-FD */
    463                                  0x0903, 0x006D, /* 100baseTx */
    464                                  0x0905, 0x006D, /* 100baseTx-FD */ }},
    465     {"Cogent EM100", 0, 0, 0x92, { 0x1e00, 0x0000, 0x0800, 0x063f,
    466                                    0x0107, 0x8021, /* 100baseFx */
    467                                    0x0108, 0x8021, /* 100baseFx-FD */
    468                                    0x0100, 0x009E, /* 10baseT */
    469                                    0x0104, 0x009E, /* 10baseT-FD */
    470                                    0x0103, 0x006D, /* 100baseTx */
    471                                    0x0105, 0x006D, /* 100baseTx-FD */ }},
    472     {"Maxtech NX-110", 0, 0, 0xE8, { 0x1e00, 0x0000, 0x0800, 0x0513,
    473                                      0x1001, 0x009E, /* 10base2, CSR12 0x10*/
    474                                      0x0000, 0x009E, /* 10baseT */
    475                                      0x0004, 0x009E, /* 10baseT-FD */
    476                                      0x0303, 0x006D, /* 100baseTx, CSR12 0x03 */
    477                                      0x0305, 0x006D, /* 100baseTx-FD CSR12 0x03 */}},
    478     {"Accton EN1207", 0, 0, 0xE8, { 0x1e00, 0x0000, 0x0800, 0x051F,
    479                                     0x1B01, 0x0000, /* 10base2,   CSR12 0x1B */
    480                                     0x0B00, 0x009E, /* 10baseT,   CSR12 0x0B */
    481                                     0x0B04, 0x009E, /* 10baseT-FD,CSR12 0x0B */
    482                                     0x1B03, 0x006D, /* 100baseTx, CSR12 0x1B */
    483                                     0x1B05, 0x006D, /* 100baseTx-FD CSR12 0x1B */
    484     }},
    485     {0, 0, 0, 0, {}}};
    486 
    487 static const char * block_name[] = {"21140 non-MII", "21140 MII PHY",
    488                                     "21142 Serial PHY", "21142 MII PHY", "21143 SYM PHY", "21143 reset method"};
    489 
    490 
    491 /*********************************************************************/
    493 /* Function Prototypes                                               */
    494 /*********************************************************************/
    495 static int mdio_read(struct nic *nic, int phy_id, int location);
    496 static void mdio_write(struct nic *nic, int phy_id, int location, int value);
    497 static int read_eeprom(unsigned long ioaddr, int location, int addr_len);
    498 static void parse_eeprom(struct nic *nic);
    499 static int tulip_probe(struct nic *nic,struct pci_device *pci);
    500 static void tulip_init_ring(struct nic *nic);
    501 static void tulip_reset(struct nic *nic);
    502 static void tulip_transmit(struct nic *nic, const char *d, unsigned int t,
    503                            unsigned int s, const char *p);
    504 static int tulip_poll(struct nic *nic, int retrieve);
    505 static void tulip_disable(struct nic *nic);
    506 static void nway_start(struct nic *nic);
    507 static void pnic_do_nway(struct nic *nic);
    508 static void select_media(struct nic *nic, int startup);
    509 static void init_media(struct nic *nic);
    510 static void start_link(struct nic *nic);
    511 static int tulip_check_duplex(struct nic *nic);
    512 
    513 static void tulip_wait(unsigned int nticks);
    514 
    515 #ifdef TULIP_DEBUG_WHERE
    516 static void whereami(const char *str);
    517 #endif
    518 
    519 #ifdef TULIP_DEBUG
    520 static void tulip_more(void);
    521 #endif
    522 
    523 
    524 /*********************************************************************/
    526 /* Utility Routines                                                  */
    527 /*********************************************************************/
    528 
    529 #ifdef TULIP_DEBUG_WHERE
    530 static void whereami (const char *str, struct pci_device *pci)
    531 {
    532     printf("%s: %s\n", tp->nic_name, str);
    533     /* sleep(2); */
    534 }
    535 #endif
    536 
    537 #ifdef  TULIP_DEBUG
    538 static void tulip_more(void)
    539 {
    540     printf("\n\n-- more --");
    541     while (!iskey())
    542         /* wait */;
    543     getchar();
    544     printf("\n\n");
    545 }
    546 #endif /* TULIP_DEBUG */
    547 
    548 static void tulip_wait(unsigned int nticks)
    549 {
    550     unsigned int to = currticks() + nticks;
    551     while (currticks() < to)
    552         /* wait */ ;
    553 }
    554 
    555 
    556 /*********************************************************************/
    558 /* Media Descriptor Code                                             */
    559 /*********************************************************************/
    560 
    561 /* MII transceiver control section.
    562    Read and write the MII registers using software-generated serial
    563    MDIO protocol.  See the MII specifications or DP83840A data sheet
    564    for details. */
    565 
    566 /* The maximum data clock rate is 2.5 Mhz.  The minimum timing is usually
    567    met by back-to-back PCI I/O cycles, but we insert a delay to avoid
    568    "overclocking" issues or future 66Mhz PCI. */
    569 #define mdio_delay() inl(mdio_addr)
    570 
    571 /* Read and write the MII registers using software-generated serial
    572    MDIO protocol.  It is just different enough from the EEPROM protocol
    573    to not share code.  The maxium data clock rate is 2.5 Mhz. */
    574 #define MDIO_SHIFT_CLK  0x10000
    575 #define MDIO_DATA_WRITE0 0x00000
    576 #define MDIO_DATA_WRITE1 0x20000
    577 #define MDIO_ENB                0x00000         /* Ignore the 0x02000 databook setting. */
    578 #define MDIO_ENB_IN             0x40000
    579 #define MDIO_DATA_READ  0x80000
    580 
    581 /* MII transceiver control section.
    582    Read and write the MII registers using software-generated serial
    583    MDIO protocol.  See the MII specifications or DP83840A data sheet
    584    for details. */
    585 
    586 int mdio_read(struct nic *nic __unused, int phy_id, int location)
    587 {
    588     int i;
    589     int read_cmd = (0xf6 << 10) | (phy_id << 5) | location;
    590     int retval = 0;
    591     long mdio_addr = ioaddr + CSR9;
    592 
    593 #ifdef TULIP_DEBUG_WHERE
    594     whereami("mdio_read\n");
    595 #endif
    596 
    597     if (tp->chip_id == LC82C168) {
    598 	int i = 1000;
    599 	outl(0x60020000 + (phy_id<<23) + (location<<18), ioaddr + 0xA0);
    600 	inl(ioaddr + 0xA0);
    601 	inl(ioaddr + 0xA0);
    602 	while (--i > 0)
    603 	    if ( ! ((retval = inl(ioaddr + 0xA0)) & 0x80000000))
    604 		return retval & 0xffff;
    605 	return 0xffff;
    606     }
    607 
    608     if (tp->chip_id == COMET) {
    609 	if (phy_id == 1) {
    610 	    if (location < 7)
    611 		return inl(ioaddr + 0xB4 + (location<<2));
    612 	    else if (location == 17)
    613 		return inl(ioaddr + 0xD0);
    614 	    else if (location >= 29 && location <= 31)
    615 		return inl(ioaddr + 0xD4 + ((location-29)<<2));
    616 	}
    617 	return 0xffff;
    618     }
    619 
    620     /* Establish sync by sending at least 32 logic ones. */
    621     for (i = 32; i >= 0; i--) {
    622 	outl(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr);
    623 	mdio_delay();
    624 	outl(MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr);
    625 	mdio_delay();
    626     }
    627     /* Shift the read command bits out. */
    628     for (i = 15; i >= 0; i--) {
    629 	int dataval = (read_cmd & (1 << i)) ? MDIO_DATA_WRITE1 : 0;
    630 
    631 	outl(MDIO_ENB | dataval, mdio_addr);
    632 	mdio_delay();
    633 	outl(MDIO_ENB | dataval | MDIO_SHIFT_CLK, mdio_addr);
    634 	mdio_delay();
    635     }
    636     /* Read the two transition, 16 data, and wire-idle bits. */
    637     for (i = 19; i > 0; i--) {
    638 	outl(MDIO_ENB_IN, mdio_addr);
    639 	mdio_delay();
    640 	retval = (retval << 1) | ((inl(mdio_addr) & MDIO_DATA_READ) ? 1 : 0);
    641 	outl(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
    642 	mdio_delay();
    643     }
    644     return (retval>>1) & 0xffff;
    645 }
    646 
    647 void mdio_write(struct nic *nic __unused, int phy_id, int location, int value)
    648 {
    649     int i;
    650     int cmd = (0x5002 << 16) | (phy_id << 23) | (location<<18) | value;
    651     long mdio_addr = ioaddr + CSR9;
    652 
    653 #ifdef TULIP_DEBUG_WHERE
    654     whereami("mdio_write\n");
    655 #endif
    656 
    657     if (tp->chip_id == LC82C168) {
    658 	int i = 1000;
    659 	outl(cmd, ioaddr + 0xA0);
    660 	do
    661 	    if ( ! (inl(ioaddr + 0xA0) & 0x80000000))
    662 		break;
    663 	while (--i > 0);
    664 	return;
    665     }
    666 
    667     if (tp->chip_id == COMET) {
    668 	if (phy_id != 1)
    669 	    return;
    670 	if (location < 7)
    671 	    outl(value, ioaddr + 0xB4 + (location<<2));
    672 	else if (location == 17)
    673 	    outl(value, ioaddr + 0xD0);
    674 	else if (location >= 29 && location <= 31)
    675 	    outl(value, ioaddr + 0xD4 + ((location-29)<<2));
    676 	return;
    677     }
    678 
    679     /* Establish sync by sending 32 logic ones. */
    680     for (i = 32; i >= 0; i--) {
    681 	outl(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr);
    682 	mdio_delay();
    683 	outl(MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr);
    684 	mdio_delay();
    685     }
    686     /* Shift the command bits out. */
    687     for (i = 31; i >= 0; i--) {
    688 	int dataval = (cmd & (1 << i)) ? MDIO_DATA_WRITE1 : 0;
    689 	outl(MDIO_ENB | dataval, mdio_addr);
    690 	mdio_delay();
    691 	outl(MDIO_ENB | dataval | MDIO_SHIFT_CLK, mdio_addr);
    692 	mdio_delay();
    693     }
    694     /* Clear out extra bits. */
    695     for (i = 2; i > 0; i--) {
    696 	outl(MDIO_ENB_IN, mdio_addr);
    697 	mdio_delay();
    698 	outl(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
    699 	mdio_delay();
    700     }
    701 }
    702 
    703 
    704 /*********************************************************************/
    706 /* EEPROM Reading Code                                               */
    707 /*********************************************************************/
    708 /* EEPROM routines adapted from the Linux Tulip Code */
    709 /* Reading a serial EEPROM is a "bit" grungy, but we work our way
    710    through:->.
    711 */
    712 static int read_eeprom(unsigned long ioaddr, int location, int addr_len)
    713 {
    714     int i;
    715     unsigned short retval = 0;
    716     long ee_addr = ioaddr + CSR9;
    717     int read_cmd = location | EE_READ_CMD;
    718 
    719 #ifdef TULIP_DEBUG_WHERE
    720     whereami("read_eeprom\n");
    721 #endif
    722 
    723     outl(EE_ENB & ~EE_CS, ee_addr);
    724     outl(EE_ENB, ee_addr);
    725 
    726     /* Shift the read command bits out. */
    727     for (i = 4 + addr_len; i >= 0; i--) {
    728         short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
    729         outl(EE_ENB | dataval, ee_addr);
    730         eeprom_delay();
    731         outl(EE_ENB | dataval | EE_SHIFT_CLK, ee_addr);
    732         eeprom_delay();
    733     }
    734     outl(EE_ENB, ee_addr);
    735 
    736     for (i = 16; i > 0; i--) {
    737         outl(EE_ENB | EE_SHIFT_CLK, ee_addr);
    738         eeprom_delay();
    739         retval = (retval << 1) | ((inl(ee_addr) & EE_DATA_READ) ? 1 : 0);
    740         outl(EE_ENB, ee_addr);
    741         eeprom_delay();
    742     }
    743 
    744     /* Terminate the EEPROM access. */
    745     outl(EE_ENB & ~EE_CS, ee_addr);
    746     return retval;
    747 }
    748 
    749 
    750 /*********************************************************************/
    752 /* EEPROM Parsing Code                                               */
    753 /*********************************************************************/
    754 static void parse_eeprom(struct nic *nic)
    755 {
    756     unsigned char *p, *ee_data = tp->eeprom;
    757     int new_advertise = 0;
    758     int i;
    759 
    760 #ifdef TULIP_DEBUG_WHERE
    761     whereami("parse_eeprom\n");
    762 #endif
    763 
    764     tp->mtable = 0;
    765     /* Detect an old-style (SA only) EEPROM layout:
    766        memcmp(ee_data, ee_data+16, 8). */
    767     for (i = 0; i < 8; i ++)
    768         if (ee_data[i] != ee_data[16+i])
    769             break;
    770     if (i >= 8) {
    771         /* Do a fix-up based on the vendor half of the station address. */
    772         for (i = 0; eeprom_fixups[i].name; i++) {
    773             if (nic->node_addr[0] == eeprom_fixups[i].addr0
    774                 &&  nic->node_addr[1] == eeprom_fixups[i].addr1
    775                 &&  nic->node_addr[2] == eeprom_fixups[i].addr2) {
    776                 if (nic->node_addr[2] == 0xE8  &&  ee_data[0x1a] == 0x55)
    777                     i++;                /* An Accton EN1207, not an outlaw Maxtech. */
    778                 memcpy(ee_data + 26, eeprom_fixups[i].newtable,
    779                        sizeof(eeprom_fixups[i].newtable));
    780 #ifdef TULIP_DEBUG
    781                 printf("%s: Old format EEPROM on '%s' board.\n%s: Using substitute media control info.\n",
    782                        tp->nic_name, eeprom_fixups[i].name, tp->nic_name);
    783 #endif
    784                 break;
    785             }
    786         }
    787         if (eeprom_fixups[i].name == NULL) { /* No fixup found. */
    788 #ifdef TULIP_DEBUG
    789             printf("%s: Old style EEPROM with no media selection information.\n",
    790                    tp->nic_name);
    791 #endif
    792             return;
    793         }
    794     }
    795 
    796     if (ee_data[19] > 1) {
    797 #ifdef TULIP_DEBUG
    798         printf("%s:  Multiport cards (%d ports) may not work correctly.\n",
    799                tp->nic_name, ee_data[19]);
    800 #endif
    801     }
    802 
    803     p = (void *)ee_data + ee_data[27];
    804 
    805     if (ee_data[27] == 0) {             /* No valid media table. */
    806 #ifdef TULIP_DEBUG
    807         if (tulip_debug > 1) {
    808             printf("%s:  No Valid Media Table. ee_data[27] = %hhX\n",
    809                    tp->nic_name, ee_data[27]);
    810         }
    811 #endif
    812     } else if (tp->chip_id == DC21041) {
    813         int media = get_u16(p);
    814         int count = p[2];
    815         p += 3;
    816 
    817         printf("%s: 21041 Media table, default media %hX (%s).\n",
    818                tp->nic_name, media,
    819                media & 0x0800 ? "Autosense" : medianame[media & 15]);
    820         for (i = 0; i < count; i++) {
    821             unsigned char media_block = *p++;
    822             int media_code = media_block & MEDIA_MASK;
    823             if (media_block & 0x40)
    824                 p += 6;
    825             switch(media_code) {
    826             case 0: new_advertise |= 0x0020; break;
    827             case 4: new_advertise |= 0x0040; break;
    828             }
    829             printf("%s:  21041 media #%d, %s.\n",
    830                    tp->nic_name, media_code, medianame[media_code]);
    831         }
    832     } else {
    833         unsigned char csr12dir = 0;
    834         int count;
    835         struct mediatable *mtable;
    836         u16 media = get_u16(p);
    837 
    838         p += 2;
    839         if (tp->flags & CSR12_IN_SROM)
    840             csr12dir = *p++;
    841         count = *p++;
    842 
    843         tp->mtable = mtable = (struct mediatable *)&tp->media_table_storage[0];
    844 
    845         mtable->defaultmedia = media;
    846         mtable->leafcount = count;
    847         mtable->csr12dir = csr12dir;
    848         mtable->has_nonmii = mtable->has_mii = mtable->has_reset = 0;
    849         mtable->csr15dir = mtable->csr15val = 0;
    850 
    851         printf("%s:  EEPROM default media type %s.\n", tp->nic_name,
    852                media & 0x0800 ? "Autosense" : medianame[media & MEDIA_MASK]);
    853 
    854         for (i = 0; i < count; i++) {
    855             struct medialeaf *leaf = &mtable->mleaf[i];
    856 
    857             if ((p[0] & 0x80) == 0) { /* 21140 Compact block. */
    858                 leaf->type = 0;
    859                 leaf->media = p[0] & 0x3f;
    860                 leaf->leafdata = p;
    861                 if ((p[2] & 0x61) == 0x01)      /* Bogus, but Znyx boards do it. */
    862                     mtable->has_mii = 1;
    863                 p += 4;
    864             } else {
    865                 switch(leaf->type = p[1]) {
    866                 case 5:
    867                     mtable->has_reset = i;
    868                     leaf->media = p[2] & 0x0f;
    869                     break;
    870                 case 1: case 3:
    871                     mtable->has_mii = 1;
    872                     leaf->media = 11;
    873                     break;
    874                 case 2:
    875                     if ((p[2] & 0x3f) == 0) {
    876                         u32 base15 = (p[2] & 0x40) ? get_u16(p + 7) : 0x0008;
    877                         u16 *p1 = (u16 *)(p + (p[2] & 0x40 ? 9 : 3));
    878                         mtable->csr15dir = (get_unaligned(p1 + 0)<<16) + base15;
    879                         mtable->csr15val = (get_unaligned(p1 + 1)<<16) + base15;
    880                     }
    881                     /* Fall through. */
    882                 case 0: case 4:
    883                     mtable->has_nonmii = 1;
    884                     leaf->media = p[2] & MEDIA_MASK;
    885                     switch (leaf->media) {
    886                     case 0: new_advertise |= 0x0020; break;
    887                     case 4: new_advertise |= 0x0040; break;
    888                     case 3: new_advertise |= 0x0080; break;
    889                     case 5: new_advertise |= 0x0100; break;
    890                     case 6: new_advertise |= 0x0200; break;
    891                     }
    892                     break;
    893                 default:
    894                     leaf->media = 19;
    895                 }
    896                 leaf->leafdata = p + 2;
    897                 p += (p[0] & 0x3f) + 1;
    898             }
    899 #ifdef TULIP_DEBUG
    900             if (tulip_debug > 1  &&  leaf->media == 11) {
    901                 unsigned char *bp = leaf->leafdata;
    902                 printf("%s:  MII interface PHY %d, setup/reset sequences %d/%d long, capabilities %hhX %hhX.\n",
    903                        tp->nic_name, bp[0], bp[1], bp[2 + bp[1]*2],
    904                        bp[5 + bp[2 + bp[1]*2]*2], bp[4 + bp[2 + bp[1]*2]*2]);
    905             }
    906 #endif
    907             printf("%s:  Index #%d - Media %s (#%d) described "
    908                    "by a %s (%d) block.\n",
    909                    tp->nic_name, i, medianame[leaf->media], leaf->media,
    910                    leaf->type < 6 ? block_name[leaf->type] : "UNKNOWN",
    911                    leaf->type);
    912         }
    913         if (new_advertise)
    914             tp->sym_advertise = new_advertise;
    915     }
    916 }
    917 
    918 
    919 /*********************************************************************/
    921 /* tulip_init_ring - setup the tx and rx descriptors                */
    922 /*********************************************************************/
    923 static void tulip_init_ring(struct nic *nic __unused)
    924 {
    925     int i;
    926 
    927 #ifdef TULIP_DEBUG_WHERE
    928     whereami("tulip_init_ring\n");
    929 #endif
    930 
    931     tp->cur_rx = 0;
    932 
    933     for (i = 0; i < RX_RING_SIZE; i++) {
    934 	rx_ring[i].status  = cpu_to_le32(0x80000000);
    935 	rx_ring[i].length  = cpu_to_le32(BUFLEN);
    936 	rx_ring[i].buffer1 = virt_to_le32desc(&rxb[i * BUFLEN]);
    937 	rx_ring[i].buffer2 = virt_to_le32desc(&rx_ring[i+1]);
    938     }
    939     /* Mark the last entry as wrapping the ring. */
    940     rx_ring[i-1].length    = cpu_to_le32(DESC_RING_WRAP | BUFLEN);
    941     rx_ring[i-1].buffer2   = virt_to_le32desc(&rx_ring[0]);
    942 
    943     /* We only use 1 transmit buffer, but we use 2 descriptors so
    944        transmit engines have somewhere to point to if they feel the need */
    945 
    946     tx_ring[0].status  = 0x00000000;
    947     tx_ring[0].buffer1 = virt_to_le32desc(&txb[0]);
    948     tx_ring[0].buffer2 = virt_to_le32desc(&tx_ring[1]);
    949 
    950     /* this descriptor should never get used, since it will never be owned
    951        by the machine (status will always == 0) */
    952     tx_ring[1].status  = 0x00000000;
    953     tx_ring[1].buffer1 = virt_to_le32desc(&txb[0]);
    954     tx_ring[1].buffer2 = virt_to_le32desc(&tx_ring[0]);
    955 
    956     /* Mark the last entry as wrapping the ring, though this should never happen */
    957     tx_ring[1].length  = cpu_to_le32(DESC_RING_WRAP | BUFLEN);
    958 }
    959 
    960 
    962 static void set_rx_mode(struct nic *nic __unused) {
    963 	int csr6 = inl(ioaddr + CSR6) & ~0x00D5;
    964 
    965 	tp->csr6 &= ~0x00D5;
    966 
    967 	/* !IFF_PROMISC */
    968 	tp->csr6 |= AcceptAllMulticast;
    969 	csr6 |= AcceptAllMulticast;
    970 
    971 	outl(csr6, ioaddr + CSR6);
    972 
    973 
    974 
    975 }
    976 
    977 /*********************************************************************/
    978 /* eth_reset - Reset adapter                                         */
    979 /*********************************************************************/
    980 static void tulip_reset(struct nic *nic)
    981 {
    982     int i;
    983     unsigned long to;
    984 
    985 #ifdef TULIP_DEBUG_WHERE
    986     whereami("tulip_reset\n");
    987 #endif
    988 
    989     /* Stop Tx and RX */
    990     outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);
    991 
    992     /* On some chip revs we must set the MII/SYM port before the reset!? */
    993     if (tp->mii_cnt  ||  (tp->mtable  &&  tp->mtable->has_mii)) {
    994 	outl(0x814C0000, ioaddr + CSR6);
    995     }
    996 
    997     /* Reset the chip, holding bit 0 set at least 50 PCI cycles. */
    998     outl(0x00000001, ioaddr + CSR0);
    999     tulip_wait(1);
   1000 
   1001     /* turn off reset and set cache align=16lword, burst=unlimit */
   1002     outl(tp->csr0, ioaddr + CSR0);
   1003 
   1004     /*  Wait the specified 50 PCI cycles after a reset */
   1005     tulip_wait(1);
   1006 
   1007     /* set up transmit and receive descriptors */
   1008     tulip_init_ring(nic);
   1009 
   1010     if (tp->chip_id == PNIC2) {
   1011         u32 addr_high = (nic->node_addr[1]<<8) + (nic->node_addr[0]<<0);
   1012         /* This address setting does not appear to impact chip operation?? */
   1013         outl((nic->node_addr[5]<<8) + nic->node_addr[4] +
   1014              (nic->node_addr[3]<<24) + (nic->node_addr[2]<<16),
   1015              ioaddr + 0xB0);
   1016         outl(addr_high + (addr_high<<16), ioaddr + 0xB8);
   1017     }
   1018 
   1019     /* MC_HASH_ONLY boards don't support setup packets */
   1020     if (tp->flags & MC_HASH_ONLY) {
   1021         u32 addr_low = cpu_to_le32(get_unaligned((u32 *)nic->node_addr));
   1022         u32 addr_high = cpu_to_le32(get_unaligned((u16 *)(nic->node_addr+4)));
   1023 
   1024 	/* clear multicast hash filters and setup MAC address filters */
   1025 	if (tp->flags & IS_ASIX) {
   1026             outl(0, ioaddr + CSR13);
   1027             outl(addr_low,  ioaddr + CSR14);
   1028             outl(1, ioaddr + CSR13);
   1029             outl(addr_high, ioaddr + CSR14);
   1030 	    outl(2, ioaddr + CSR13);
   1031 	    outl(0, ioaddr + CSR14);
   1032 	    outl(3, ioaddr + CSR13);
   1033 	    outl(0, ioaddr + CSR14);
   1034 	} else if (tp->chip_id == COMET) {
   1035             outl(addr_low,  ioaddr + 0xA4);
   1036             outl(addr_high, ioaddr + 0xA8);
   1037             outl(0, ioaddr + 0xAC);
   1038             outl(0, ioaddr + 0xB0);
   1039 	}
   1040     } else {
   1041 	/* for other boards we send a setup packet to initialize
   1042 	   the filters */
   1043 	u32 tx_flags = 0x08000000 | 192;
   1044 
   1045 	/* construct perfect filter frame with mac address as first match
   1046 	   and broadcast address for all others */
   1047 	for (i=0; i<192; i++)
   1048 	    txb[i] = 0xFF;
   1049 	txb[0] = nic->node_addr[0];
   1050 	txb[1] = nic->node_addr[1];
   1051 	txb[4] = nic->node_addr[2];
   1052 	txb[5] = nic->node_addr[3];
   1053 	txb[8] = nic->node_addr[4];
   1054 	txb[9] = nic->node_addr[5];
   1055 
   1056 	tx_ring[0].length  = cpu_to_le32(tx_flags);
   1057 	tx_ring[0].buffer1 = virt_to_le32desc(&txb[0]);
   1058 	tx_ring[0].status  = cpu_to_le32(0x80000000);
   1059     }
   1060 
   1061     /* Point to rx and tx descriptors */
   1062     outl(virt_to_le32desc(&rx_ring[0]), ioaddr + CSR3);
   1063     outl(virt_to_le32desc(&tx_ring[0]), ioaddr + CSR4);
   1064 
   1065     init_media(nic);
   1066 
   1067     /* set the chip's operating mode (but don't turn on xmit and recv yet) */
   1068     outl((tp->csr6 & ~0x00002002), ioaddr + CSR6);
   1069 
   1070     /* send setup packet for cards that support it */
   1071     if (!(tp->flags & MC_HASH_ONLY)) {
   1072 	/* enable transmit  wait for completion */
   1073 	outl(tp->csr6 | 0x00002000, ioaddr + CSR6);
   1074 	/* immediate transmit demand */
   1075 	outl(0, ioaddr + CSR1);
   1076 
   1077 	to = currticks() + TX_TIME_OUT;
   1078 	while ((tx_ring[0].status & 0x80000000) && (currticks() < to))
   1079 	    /* wait */ ;
   1080 
   1081 	if (currticks() >= to) {
   1082 	    printf ("%s: TX Setup Timeout.\n", tp->nic_name);
   1083 	}
   1084     }
   1085 
   1086     if (tp->chip_id == LC82C168)
   1087 	tulip_check_duplex(nic);
   1088 
   1089     set_rx_mode(nic);
   1090 
   1091     /* enable transmit and receive */
   1092     outl(tp->csr6 | 0x00002002, ioaddr + CSR6);
   1093 }
   1094 
   1095 
   1096 /*********************************************************************/
   1098 /* eth_transmit - Transmit a frame                                   */
   1099 /*********************************************************************/
   1100 static void tulip_transmit(struct nic *nic, const char *d, unsigned int t,
   1101                            unsigned int s, const char *p)
   1102 {
   1103     u16 nstype;
   1104     u32 to;
   1105     u32 csr6 = inl(ioaddr + CSR6);
   1106 
   1107 #ifdef TULIP_DEBUG_WHERE
   1108     whereami("tulip_transmit\n");
   1109 #endif
   1110 
   1111     /* Disable Tx */
   1112     outl(csr6 & ~0x00002000, ioaddr + CSR6);
   1113 
   1114     memcpy(txb, d, ETH_ALEN);
   1115     memcpy(txb + ETH_ALEN, nic->node_addr, ETH_ALEN);
   1116     nstype = htons((u16) t);
   1117     memcpy(txb + 2 * ETH_ALEN, (u8 *)&nstype, 2);
   1118     memcpy(txb + ETH_HLEN, p, s);
   1119 
   1120     s += ETH_HLEN;
   1121     s &= 0x0FFF;
   1122 
   1123     /* pad to minimum packet size */
   1124     while (s < ETH_ZLEN)
   1125         txb[s++] = '\0';
   1126 
   1127 #ifdef TULIP_DEBUG
   1128     if (tulip_debug > 1)
   1129 	printf("%s: sending %d bytes ethtype %hX\n", tp->nic_name, s, t);
   1130 #endif
   1131 
   1132     /* setup the transmit descriptor */
   1133     /* 0x60000000 = no interrupt on completion */
   1134     tx_ring[0].length = cpu_to_le32(0x60000000 | s);
   1135     tx_ring[0].status = cpu_to_le32(0x80000000);
   1136 
   1137     /* Point to transmit descriptor */
   1138     outl(virt_to_le32desc(&tx_ring[0]), ioaddr + CSR4);
   1139 
   1140     /* Enable Tx */
   1141     outl(csr6 | 0x00002000, ioaddr + CSR6);
   1142     /* immediate transmit demand */
   1143     outl(0, ioaddr + CSR1);
   1144 
   1145     to = currticks() + TX_TIME_OUT;
   1146     while ((tx_ring[0].status & 0x80000000) && (currticks() < to))
   1147         /* wait */ ;
   1148 
   1149     if (currticks() >= to) {
   1150         printf ("TX Timeout!\n");
   1151     }
   1152 
   1153     /* Disable Tx */
   1154     outl(csr6 & ~0x00002000, ioaddr + CSR6);
   1155 }
   1156 
   1157 /*********************************************************************/
   1159 /* eth_poll - Wait for a frame                                       */
   1160 /*********************************************************************/
   1161 static int tulip_poll(struct nic *nic, int retrieve)
   1162 {
   1163 
   1164 #ifdef TULIP_DEBUG_WHERE
   1165     whereami("tulip_poll\n");
   1166 #endif
   1167 
   1168     /* no packet waiting. packet still owned by NIC */
   1169     if (rx_ring[tp->cur_rx].status & 0x80000000)
   1170         return 0;
   1171 
   1172     if ( ! retrieve ) return 1;
   1173 
   1174 #ifdef TULIP_DEBUG_WHERE
   1175     whereami("tulip_poll got one\n");
   1176 #endif
   1177 
   1178     nic->packetlen = (rx_ring[tp->cur_rx].status & 0x3FFF0000) >> 16;
   1179 
   1180     /* if we get a corrupted packet. throw it away and move on */
   1181     if (rx_ring[tp->cur_rx].status & 0x00008000) {
   1182 	/* return the descriptor and buffer to receive ring */
   1183         rx_ring[tp->cur_rx].status = 0x80000000;
   1184 	tp->cur_rx = (++tp->cur_rx) % RX_RING_SIZE;
   1185         return 0;
   1186     }
   1187 
   1188     /* copy packet to working buffer */
   1189     memcpy(nic->packet, rxb + tp->cur_rx * BUFLEN, nic->packetlen);
   1190 
   1191     /* return the descriptor and buffer to receive ring */
   1192     rx_ring[tp->cur_rx].status = 0x80000000;
   1193     tp->cur_rx = (++tp->cur_rx) % RX_RING_SIZE;
   1194 
   1195     return 1;
   1196 }
   1197 
   1198 /*********************************************************************/
   1200 /* eth_disable - Disable the interface                               */
   1201 /*********************************************************************/
   1202 static void tulip_disable ( struct nic *nic ) {
   1203 
   1204 #ifdef TULIP_DEBUG_WHERE
   1205     whereami("tulip_disable\n");
   1206 #endif
   1207 
   1208     tulip_reset(nic);
   1209 
   1210     /* disable interrupts */
   1211     outl(0x00000000, ioaddr + CSR7);
   1212 
   1213     /* Stop the chip's Tx and Rx processes. */
   1214     outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);
   1215 
   1216     /* Clear the missed-packet counter. */
   1217     inl(ioaddr + CSR8);
   1218 }
   1219 
   1220 /*********************************************************************/
   1222 /*IRQ - Enable, Disable, or Force interrupts                         */
   1223 /*********************************************************************/
   1224 static void tulip_irq(struct nic *nic __unused, irq_action_t action __unused)
   1225 {
   1226   switch ( action ) {
   1227   case DISABLE :
   1228     break;
   1229   case ENABLE :
   1230     break;
   1231   case FORCE :
   1232     break;
   1233   }
   1234 }
   1235 
   1236 static struct nic_operations tulip_operations = {
   1238 	.connect	= dummy_connect,
   1239 	.poll		= tulip_poll,
   1240 	.transmit	= tulip_transmit,
   1241 	.irq		= tulip_irq,
   1242 
   1243 };
   1244 
   1245 /*********************************************************************/
   1247 /* eth_probe - Look for an adapter                                   */
   1248 /*********************************************************************/
   1249 static int tulip_probe ( struct nic *nic, struct pci_device *pci ) {
   1250 
   1251     u32 i;
   1252     u8  chip_rev;
   1253     u8 ee_data[EEPROM_SIZE];
   1254     unsigned short sum;
   1255     int chip_idx;
   1256     static unsigned char last_phys_addr[ETH_ALEN] = {0x00, 'L', 'i', 'n', 'u', 'x'};
   1257 
   1258     if (pci->ioaddr == 0)
   1259         return 0;
   1260 
   1261     ioaddr         = pci->ioaddr;
   1262     nic->ioaddr    = pci->ioaddr & ~3;
   1263     nic->irqno     = 0;
   1264 
   1265     /* point to private storage */
   1266     tp = &tulip_bss.tpx;
   1267 
   1268     tp->vendor_id  = pci->vendor;
   1269     tp->dev_id     = pci->device;
   1270     tp->nic_name   = pci->driver_name;
   1271 
   1272     tp->if_port = 0;
   1273     tp->default_port = 0;
   1274 
   1275     adjust_pci_device(pci);
   1276 
   1277     /* disable interrupts */
   1278     outl(0x00000000, ioaddr + CSR7);
   1279 
   1280     /* Stop the chip's Tx and Rx processes. */
   1281     outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);
   1282 
   1283     /* Clear the missed-packet counter. */
   1284     inl(ioaddr + CSR8);
   1285 
   1286     printf("\n");                /* so we start on a fresh line */
   1287 #ifdef TULIP_DEBUG_WHERE
   1288     whereami("tulip_probe\n");
   1289 #endif
   1290 
   1291 #ifdef TULIP_DEBUG
   1292     if (tulip_debug > 1)
   1293 	printf ("%s: Looking for Tulip Chip: Vendor=%hX  Device=%hX\n", tp->nic_name,
   1294 		tp->vendor, tp->dev_id);
   1295 #endif
   1296 
   1297     /* Figure out which chip we're dealing with */
   1298     i = 0;
   1299     chip_idx = -1;
   1300 
   1301     while (pci_id_tbl[i].name) {
   1302         if ( (((u32) tp->dev_id << 16) | tp->vendor_id) ==
   1303              (pci_id_tbl[i].id.pci & pci_id_tbl[i].id.pci_mask) ) {
   1304             chip_idx = pci_id_tbl[i].drv_flags;
   1305             break;
   1306         }
   1307         i++;
   1308     }
   1309 
   1310     if (chip_idx == -1) {
   1311         printf ("%s: Unknown Tulip Chip: Vendor=%hX  Device=%hX\n", tp->nic_name,
   1312                 tp->vendor_id, tp->dev_id);
   1313         return 0;
   1314     }
   1315 
   1316     tp->pci_id_idx = i;
   1317     tp->flags = tulip_tbl[chip_idx].flags;
   1318 
   1319 #ifdef TULIP_DEBUG
   1320     if (tulip_debug > 1) {
   1321 	printf ("%s: tp->pci_id_idx == %d,  name == %s\n", tp->nic_name,
   1322 		tp->pci_id_idx, pci_id_tbl[tp->pci_id_idx].name);
   1323 	printf ("%s: chip_idx == %d, name == %s\n", tp->nic_name, chip_idx,
   1324 		tulip_tbl[chip_idx].chip_name);
   1325     }
   1326 #endif
   1327 
   1328     /* Bring the 21041/21143 out of sleep mode.
   1329        Caution: Snooze mode does not work with some boards! */
   1330     if (tp->flags & HAS_PWRDWN)
   1331         pci_write_config_dword(pci, 0x40, 0x00000000);
   1332 
   1333     if (inl(ioaddr + CSR5) == 0xFFFFFFFF) {
   1334         printf("%s: The Tulip chip at %X is not functioning.\n",
   1335                tp->nic_name, (unsigned int) ioaddr);
   1336         return 0;
   1337     }
   1338 
   1339     pci_read_config_byte(pci, PCI_REVISION, &chip_rev);
   1340 
   1341     printf("%s: [chip: %s] rev %d at %hX\n", tp->nic_name,
   1342            tulip_tbl[chip_idx].chip_name, chip_rev, (unsigned int) ioaddr);
   1343     printf("%s: Vendor=%hX  Device=%hX", tp->nic_name, tp->vendor_id, tp->dev_id);
   1344 
   1345     if (chip_idx == DC21041  &&  inl(ioaddr + CSR9) & 0x8000) {
   1346         printf(" 21040 compatible mode.");
   1347         chip_idx = DC21040;
   1348     }
   1349 
   1350     printf("\n");
   1351 
   1352     /* The SROM/EEPROM interface varies dramatically. */
   1353     sum = 0;
   1354     if (chip_idx == DC21040) {
   1355         outl(0, ioaddr + CSR9);         /* Reset the pointer with a dummy write. */
   1356         for (i = 0; i < ETH_ALEN; i++) {
   1357             int value, boguscnt = 100000;
   1358             do
   1359                 value = inl(ioaddr + CSR9);
   1360             while (value < 0  && --boguscnt > 0);
   1361             nic->node_addr[i] = value;
   1362             sum += value & 0xff;
   1363         }
   1364     } else if (chip_idx == LC82C168) {
   1365         for (i = 0; i < 3; i++) {
   1366             int value, boguscnt = 100000;
   1367             outl(0x600 | i, ioaddr + 0x98);
   1368             do
   1369                 value = inl(ioaddr + CSR9);
   1370             while (value < 0  && --boguscnt > 0);
   1371             put_unaligned(le16_to_cpu(value), ((u16*)nic->node_addr) + i);
   1372             sum += value & 0xffff;
   1373         }
   1374     } else if (chip_idx == COMET) {
   1375         /* No need to read the EEPROM. */
   1376         put_unaligned(inl(ioaddr + 0xA4), (u32 *)nic->node_addr);
   1377         put_unaligned(inl(ioaddr + 0xA8), (u16 *)(nic->node_addr + 4));
   1378         for (i = 0; i < ETH_ALEN; i ++)
   1379             sum += nic->node_addr[i];
   1380     } else {
   1381         /* A serial EEPROM interface, we read now and sort it out later. */
   1382         int sa_offset = 0;
   1383         int ee_addr_size = read_eeprom(ioaddr, 0xff, 8) & 0x40000 ? 8 : 6;
   1384 
   1385         for (i = 0; i < sizeof(ee_data)/2; i++)
   1386             ((u16 *)ee_data)[i] =
   1387                 le16_to_cpu(read_eeprom(ioaddr, i, ee_addr_size));
   1388 
   1389         /* DEC now has a specification (see Notes) but early board makers
   1390            just put the address in the first EEPROM locations. */
   1391         /* This does  memcmp(eedata, eedata+16, 8) */
   1392         for (i = 0; i < 8; i ++)
   1393             if (ee_data[i] != ee_data[16+i])
   1394                 sa_offset = 20;
   1395         if (ee_data[0] == 0xff  &&  ee_data[1] == 0xff &&  ee_data[2] == 0) {
   1396             sa_offset = 2;              /* Grrr, damn Matrox boards. */
   1397         }
   1398         for (i = 0; i < ETH_ALEN; i ++) {
   1399             nic->node_addr[i] = ee_data[i + sa_offset];
   1400             sum += ee_data[i + sa_offset];
   1401         }
   1402     }
   1403     /* Lite-On boards have the address byte-swapped. */
   1404     if ((nic->node_addr[0] == 0xA0  ||  nic->node_addr[0] == 0xC0)
   1405         &&  nic->node_addr[1] == 0x00)
   1406         for (i = 0; i < ETH_ALEN; i+=2) {
   1407             char tmp = nic->node_addr[i];
   1408             nic->node_addr[i] = nic->node_addr[i+1];
   1409             nic->node_addr[i+1] = tmp;
   1410         }
   1411 
   1412     if (sum == 0  || sum == ETH_ALEN*0xff) {
   1413         printf("%s: EEPROM not present!\n", tp->nic_name);
   1414         for (i = 0; i < ETH_ALEN-1; i++)
   1415             nic->node_addr[i] = last_phys_addr[i];
   1416         nic->node_addr[i] = last_phys_addr[i] + 1;
   1417     }
   1418 
   1419     for (i = 0; i < ETH_ALEN; i++)
   1420         last_phys_addr[i] = nic->node_addr[i];
   1421 
   1422     DBG ( "%s: %s at ioaddr %hX\n", tp->nic_name, eth_ntoa ( nic->node_addr ),
   1423 	  (unsigned int) ioaddr );
   1424 
   1425     tp->chip_id = chip_idx;
   1426     tp->revision = chip_rev;
   1427     tp->csr0 = csr0;
   1428 
   1429     /* BugFixes: The 21143-TD hangs with PCI Write-and-Invalidate cycles.
   1430        And the ASIX must have a burst limit or horrible things happen. */
   1431     if (chip_idx == DC21143  &&  chip_rev == 65)
   1432         tp->csr0 &= ~0x01000000;
   1433     else if (tp->flags & IS_ASIX)
   1434         tp->csr0 |= 0x2000;
   1435 
   1436     if (media_cap[tp->default_port] & MediaIsMII) {
   1437         static const u16 media2advert[] = { 0x20, 0x40, 0x03e0, 0x60,
   1438 					    0x80, 0x100, 0x200 };
   1439         tp->mii_advertise = media2advert[tp->default_port - 9];
   1440         tp->mii_advertise |= (tp->flags & HAS_8023X); /* Matching bits! */
   1441     }
   1442 
   1443     /* This is logically part of the probe routine, but too complex
   1444        to write inline. */
   1445     if (tp->flags & HAS_MEDIA_TABLE) {
   1446         memcpy(tp->eeprom, ee_data, sizeof(tp->eeprom));
   1447         parse_eeprom(nic);
   1448     }
   1449 
   1450     start_link(nic);
   1451 
   1452     /* reset the device and make ready for tx and rx of packets */
   1453     tulip_reset(nic);
   1454     nic->nic_op	= &tulip_operations;
   1455 
   1456     /* give the board a chance to reset before returning */
   1457     tulip_wait(4*TICKS_PER_SEC);
   1458 
   1459     return 1;
   1460 }
   1461 
   1462 static void start_link(struct nic *nic)
   1463 {
   1464     int i;
   1465 
   1466 #ifdef TULIP_DEBUG_WHERE
   1467     whereami("start_link\n");
   1468 #endif
   1469 
   1470     if ((tp->flags & ALWAYS_CHECK_MII) ||
   1471         (tp->mtable  &&  tp->mtable->has_mii) ||
   1472         ( ! tp->mtable  &&  (tp->flags & HAS_MII))) {
   1473         unsigned int phy, phy_idx;
   1474         if (tp->mtable  &&  tp->mtable->has_mii) {
   1475             for (i = 0; i < tp->mtable->leafcount; i++)
   1476                 if (tp->mtable->mleaf[i].media == 11) {
   1477                     tp->cur_index = i;
   1478                     tp->saved_if_port = tp->if_port;
   1479                     select_media(nic, 2);
   1480                     tp->if_port = tp->saved_if_port;
   1481                     break;
   1482                 }
   1483         }
   1484 
   1485         /* Find the connected MII xcvrs. */
   1486         for (phy = 0, phy_idx = 0; phy < 32 && phy_idx < sizeof(tp->phys);
   1487              phy++) {
   1488             int mii_status = mdio_read(nic, phy, 1);
   1489             if ((mii_status & 0x8301) == 0x8001 ||
   1490                 ((mii_status & 0x8000) == 0  && (mii_status & 0x7800) != 0)) {
   1491                 int mii_reg0 = mdio_read(nic, phy, 0);
   1492                 int mii_advert = mdio_read(nic, phy, 4);
   1493                 int to_advert;
   1494 
   1495                 if (tp->mii_advertise)
   1496                     to_advert = tp->mii_advertise;
   1497                 else if (tp->advertising[phy_idx])
   1498                     to_advert = tp->advertising[phy_idx];
   1499                 else                    /* Leave unchanged. */
   1500                     tp->mii_advertise = to_advert = mii_advert;
   1501 
   1502                 tp->phys[phy_idx++] = phy;
   1503                 printf("%s:  MII transceiver %d config %hX status %hX advertising %hX.\n",
   1504                        tp->nic_name, phy, mii_reg0, mii_status, mii_advert);
   1505                                 /* Fixup for DLink with miswired PHY. */
   1506                 if (mii_advert != to_advert) {
   1507                     printf("%s:  Advertising %hX on PHY %d previously advertising %hX.\n",
   1508                            tp->nic_name, to_advert, phy, mii_advert);
   1509                     mdio_write(nic, phy, 4, to_advert);
   1510                 }
   1511                                 /* Enable autonegotiation: some boards default to off. */
   1512                 mdio_write(nic, phy, 0, mii_reg0 |
   1513                            (tp->full_duplex ? 0x1100 : 0x1000) |
   1514                            (media_cap[tp->default_port]&MediaIs100 ? 0x2000:0));
   1515             }
   1516         }
   1517         tp->mii_cnt = phy_idx;
   1518         if (tp->mtable  &&  tp->mtable->has_mii  &&  phy_idx == 0) {
   1519             printf("%s: ***WARNING***: No MII transceiver found!\n",
   1520                    tp->nic_name);
   1521             tp->phys[0] = 1;
   1522         }
   1523     }
   1524 
   1525     /* Reset the xcvr interface and turn on heartbeat. */
   1526     switch (tp->chip_id) {
   1527     case DC21040:
   1528         outl(0x00000000, ioaddr + CSR13);
   1529         outl(0x00000004, ioaddr + CSR13);
   1530         break;
   1531     case DC21041:
   1532         /* This is nway_start(). */
   1533         if (tp->sym_advertise == 0)
   1534             tp->sym_advertise = 0x0061;
   1535         outl(0x00000000, ioaddr + CSR13);
   1536         outl(0xFFFFFFFF, ioaddr + CSR14);
   1537         outl(0x00000008, ioaddr + CSR15); /* Listen on AUI also. */
   1538         outl(inl(ioaddr + CSR6) | 0x0200, ioaddr + CSR6);
   1539         outl(0x0000EF01, ioaddr + CSR13);
   1540         break;
   1541     case DC21140: default:
   1542         if (tp->mtable)
   1543             outl(tp->mtable->csr12dir | 0x100, ioaddr + CSR12);
   1544         break;
   1545     case DC21142:
   1546     case PNIC2:
   1547         if (tp->mii_cnt  ||  media_cap[tp->if_port] & MediaIsMII) {
   1548             outl(0x82020000, ioaddr + CSR6);
   1549             outl(0x0000, ioaddr + CSR13);
   1550             outl(0x0000, ioaddr + CSR14);
   1551             outl(0x820E0000, ioaddr + CSR6);
   1552         } else
   1553             nway_start(nic);
   1554         break;
   1555     case LC82C168:
   1556         if ( ! tp->mii_cnt) {
   1557             tp->nway = 1;
   1558             tp->nwayset = 0;
   1559             outl(0x00420000, ioaddr + CSR6);
   1560             outl(0x30, ioaddr + CSR12);
   1561             outl(0x0001F078, ioaddr + 0xB8);
   1562             outl(0x0201F078, ioaddr + 0xB8); /* Turn on autonegotiation. */
   1563         }
   1564         break;
   1565     case MX98713: case COMPEX9881:
   1566         outl(0x00000000, ioaddr + CSR6);
   1567         outl(0x000711C0, ioaddr + CSR14); /* Turn on NWay. */
   1568         outl(0x00000001, ioaddr + CSR13);
   1569         break;
   1570     case MX98715: case MX98725:
   1571         outl(0x01a80000, ioaddr + CSR6);
   1572         outl(0xFFFFFFFF, ioaddr + CSR14);
   1573         outl(0x00001000, ioaddr + CSR12);
   1574         break;
   1575     case COMET:
   1576         /* No initialization necessary. */
   1577         break;
   1578     }
   1579 }
   1580 
   1581 static void nway_start(struct nic *nic __unused)
   1582 {
   1583     int csr14 = ((tp->sym_advertise & 0x0780) << 9)  |
   1584         ((tp->sym_advertise&0x0020)<<1) | 0xffbf;
   1585 
   1586 #ifdef TULIP_DEBUG_WHERE
   1587     whereami("nway_start\n");
   1588 #endif
   1589 
   1590     tp->if_port = 0;
   1591     tp->nway = tp->mediasense = 1;
   1592     tp->nwayset = tp->lpar = 0;
   1593     if (tp->chip_id == PNIC2) {
   1594         tp->csr6 = 0x01000000 | (tp->sym_advertise & 0x0040 ? 0x0200 : 0);
   1595         return;
   1596     }
   1597 #ifdef TULIP_DEBUG
   1598     if (tulip_debug > 1)
   1599         printf("%s: Restarting internal NWay autonegotiation, %X.\n",
   1600                tp->nic_name, csr14);
   1601 #endif
   1602     outl(0x0001, ioaddr + CSR13);
   1603     outl(csr14, ioaddr + CSR14);
   1604     tp->csr6 = 0x82420000 | (tp->sym_advertise & 0x0040 ? 0x0200 : 0);
   1605     outl(tp->csr6, ioaddr + CSR6);
   1606     if (tp->mtable  &&  tp->mtable->csr15dir) {
   1607         outl(tp->mtable->csr15dir, ioaddr + CSR15);
   1608         outl(tp->mtable->csr15val, ioaddr + CSR15);
   1609     } else if (tp->chip_id != PNIC2)
   1610         outw(0x0008, ioaddr + CSR15);
   1611     if (tp->chip_id == DC21041)                 /* Trigger NWAY. */
   1612         outl(0xEF01, ioaddr + CSR12);
   1613     else
   1614         outl(0x1301, ioaddr + CSR12);
   1615 }
   1616 
   1617 static void init_media(struct nic *nic)
   1618 {
   1619     int i;
   1620 
   1621 #ifdef TULIP_DEBUG_WHERE
   1622     whereami("init_media\n");
   1623 #endif
   1624 
   1625     tp->saved_if_port = tp->if_port;
   1626     if (tp->if_port == 0)
   1627         tp->if_port = tp->default_port;
   1628 
   1629     /* Allow selecting a default media. */
   1630     i = 0;
   1631     if (tp->mtable == NULL)
   1632         goto media_picked;
   1633     if (tp->if_port) {
   1634         int looking_for = media_cap[tp->if_port] & MediaIsMII ? 11 :
   1635             (tp->if_port == 12 ? 0 : tp->if_port);
   1636         for (i = 0; i < tp->mtable->leafcount; i++)
   1637             if (tp->mtable->mleaf[i].media == looking_for) {
   1638                 printf("%s: Using user-specified media %s.\n",
   1639                        tp->nic_name, medianame[tp->if_port]);
   1640                 goto media_picked;
   1641             }
   1642     }
   1643     if ((tp->mtable->defaultmedia & 0x0800) == 0) {
   1644         int looking_for = tp->mtable->defaultmedia & 15;
   1645         for (i = 0; i < tp->mtable->leafcount; i++)
   1646             if (tp->mtable->mleaf[i].media == looking_for) {
   1647                 printf("%s: Using EEPROM-set media %s.\n",
   1648                        tp->nic_name, medianame[looking_for]);
   1649                 goto media_picked;
   1650             }
   1651     }
   1652     /* Start sensing first non-full-duplex media. */
   1653     for (i = tp->mtable->leafcount - 1;
   1654          (media_cap[tp->mtable->mleaf[i].media] & MediaAlwaysFD) && i > 0; i--)
   1655         ;
   1656  media_picked:
   1657 
   1658     tp->csr6 = 0;
   1659     tp->cur_index = i;
   1660     tp->nwayset = 0;
   1661 
   1662     if (tp->if_port) {
   1663         if (tp->chip_id == DC21143  &&  media_cap[tp->if_port] & MediaIsMII) {
   1664             /* We must reset the media CSRs when we force-select MII mode. */
   1665             outl(0x0000, ioaddr + CSR13);
   1666             outl(0x0000, ioaddr + CSR14);
   1667             outl(0x0008, ioaddr + CSR15);
   1668         }
   1669         select_media(nic, 1);
   1670         return;
   1671     }
   1672     switch(tp->chip_id) {
   1673     case DC21041:
   1674         /* tp->nway = 1;*/
   1675         nway_start(nic);
   1676         break;
   1677     case DC21142:
   1678         if (tp->mii_cnt) {
   1679             select_media(nic, 1);
   1680 #ifdef TULIP_DEBUG
   1681             if (tulip_debug > 1)
   1682                 printf("%s: Using MII transceiver %d, status %hX.\n",
   1683                        tp->nic_name, tp->phys[0], mdio_read(nic, tp->phys[0], 1));
   1684 #endif
   1685             outl(0x82020000, ioaddr + CSR6);
   1686             tp->csr6 = 0x820E0000;
   1687             tp->if_port = 11;
   1688             outl(0x0000, ioaddr + CSR13);
   1689             outl(0x0000, ioaddr + CSR14);
   1690         } else
   1691             nway_start(nic);
   1692         break;
   1693     case PNIC2:
   1694         nway_start(nic);
   1695         break;
   1696     case LC82C168:
   1697         if (tp->mii_cnt) {
   1698             tp->if_port = 11;
   1699             tp->csr6 = 0x814C0000 | (tp->full_duplex ? 0x0200 : 0);
   1700             outl(0x0001, ioaddr + CSR15);
   1701         } else if (inl(ioaddr + CSR5) & TPLnkPass)
   1702             pnic_do_nway(nic);
   1703         else {
   1704             /* Start with 10mbps to do autonegotiation. */
   1705             outl(0x32, ioaddr + CSR12);
   1706             tp->csr6 = 0x00420000;
   1707             outl(0x0001B078, ioaddr + 0xB8);
   1708             outl(0x0201B078, ioaddr + 0xB8);
   1709         }
   1710         break;
   1711     case MX98713: case COMPEX9881:
   1712         tp->if_port = 0;
   1713         tp->csr6 = 0x01880000 | (tp->full_duplex ? 0x0200 : 0);
   1714         outl(0x0f370000 | inw(ioaddr + 0x80), ioaddr + 0x80);
   1715         break;
   1716     case MX98715: case MX98725:
   1717         /* Provided by BOLO, Macronix - 12/10/1998. */
   1718         tp->if_port = 0;
   1719         tp->csr6 = 0x01a80200;
   1720         outl(0x0f370000 | inw(ioaddr + 0x80), ioaddr + 0x80);
   1721         outl(0x11000 | inw(ioaddr + 0xa0), ioaddr + 0xa0);
   1722         break;
   1723     case COMET:
   1724         /* Enable automatic Tx underrun recovery */
   1725         outl(inl(ioaddr + 0x88) | 1, ioaddr + 0x88);
   1726         tp->if_port = 0;
   1727 	tp->csr6 = 0x00040000;
   1728         break;
   1729     case AX88140: case AX88141:
   1730         tp->csr6 = tp->mii_cnt ? 0x00040100 : 0x00000100;
   1731         break;
   1732     default:
   1733         select_media(nic, 1);
   1734     }
   1735 }
   1736 
   1737 static void pnic_do_nway(struct nic *nic __unused)
   1738 {
   1739     u32 phy_reg = inl(ioaddr + 0xB8);
   1740     u32 new_csr6 = tp->csr6 & ~0x40C40200;
   1741 
   1742 #ifdef TULIP_DEBUG_WHERE
   1743     whereami("pnic_do_nway\n");
   1744 #endif
   1745 
   1746     if (phy_reg & 0x78000000) { /* Ignore baseT4 */
   1747         if (phy_reg & 0x20000000)               tp->if_port = 5;
   1748         else if (phy_reg & 0x40000000)  tp->if_port = 3;
   1749         else if (phy_reg & 0x10000000)  tp->if_port = 4;
   1750         else if (phy_reg & 0x08000000)  tp->if_port = 0;
   1751         tp->nwayset = 1;
   1752         new_csr6 = (tp->if_port & 1) ? 0x01860000 : 0x00420000;
   1753         outl(0x32 | (tp->if_port & 1), ioaddr + CSR12);
   1754         if (tp->if_port & 1)
   1755             outl(0x1F868, ioaddr + 0xB8);
   1756         if (phy_reg & 0x30000000) {
   1757             tp->full_duplex = 1;
   1758             new_csr6 |= 0x00000200;
   1759         }
   1760 #ifdef TULIP_DEBUG
   1761         if (tulip_debug > 1)
   1762             printf("%s: PNIC autonegotiated status %X, %s.\n",
   1763                    tp->nic_name, phy_reg, medianame[tp->if_port]);
   1764 #endif
   1765         if (tp->csr6 != new_csr6) {
   1766             tp->csr6 = new_csr6;
   1767             outl(tp->csr6 | 0x0002, ioaddr + CSR6);     /* Restart Tx */
   1768             outl(tp->csr6 | 0x2002, ioaddr + CSR6);
   1769         }
   1770     }
   1771 }
   1772 
   1773 /* Set up the transceiver control registers for the selected media type. */
   1774 static void select_media(struct nic *nic, int startup)
   1775 {
   1776     struct mediatable *mtable = tp->mtable;
   1777     u32 new_csr6;
   1778     int i;
   1779 
   1780 #ifdef TULIP_DEBUG_WHERE
   1781     whereami("select_media\n");
   1782 #endif
   1783 
   1784     if (mtable) {
   1785         struct medialeaf *mleaf = &mtable->mleaf[tp->cur_index];
   1786         unsigned char *p = mleaf->leafdata;
   1787         switch (mleaf->type) {
   1788         case 0:                                 /* 21140 non-MII xcvr. */
   1789 #ifdef TULIP_DEBUG
   1790             if (tulip_debug > 1)
   1791                 printf("%s: Using a 21140 non-MII transceiver"
   1792                        " with control setting %hhX.\n",
   1793                        tp->nic_name, p[1]);
   1794 #endif
   1795             tp->if_port = p[0];
   1796             if (startup)
   1797                 outl(mtable->csr12dir | 0x100, ioaddr + CSR12);
   1798             outl(p[1], ioaddr + CSR12);
   1799             new_csr6 = 0x02000000 | ((p[2] & 0x71) << 18);
   1800             break;
   1801         case 2: case 4: {
   1802             u16 setup[5];
   1803             u32 csr13val, csr14val, csr15dir, csr15val;
   1804             for (i = 0; i < 5; i++)
   1805                 setup[i] = get_u16(&p[i*2 + 1]);
   1806 
   1807             tp->if_port = p[0] & 15;
   1808             if (media_cap[tp->if_port] & MediaAlwaysFD)
   1809                 tp->full_duplex = 1;
   1810 
   1811             if (startup && mtable->has_reset) {
   1812                 struct medialeaf *rleaf = &mtable->mleaf[mtable->has_reset];
   1813                 unsigned char *rst = rleaf->leafdata;
   1814 #ifdef TULIP_DEBUG
   1815                 if (tulip_debug > 1)
   1816                     printf("%s: Resetting the transceiver.\n",
   1817                            tp->nic_name);
   1818 #endif
   1819                 for (i = 0; i < rst[0]; i++)
   1820                     outl(get_u16(rst + 1 + (i<<1)) << 16, ioaddr + CSR15);
   1821             }
   1822 #ifdef TULIP_DEBUG
   1823             if (tulip_debug > 1)
   1824                 printf("%s: 21143 non-MII %s transceiver control "
   1825                        "%hX/%hX.\n",
   1826                        tp->nic_name, medianame[tp->if_port], setup[0], setup[1]);
   1827 #endif
   1828             if (p[0] & 0x40) {  /* SIA (CSR13-15) setup values are provided. */
   1829                 csr13val = setup[0];
   1830                 csr14val = setup[1];
   1831                 csr15dir = (setup[3]<<16) | setup[2];
   1832                 csr15val = (setup[4]<<16) | setup[2];
   1833                 outl(0, ioaddr + CSR13);
   1834                 outl(csr14val, ioaddr + CSR14);
   1835                 outl(csr15dir, ioaddr + CSR15); /* Direction */
   1836                 outl(csr15val, ioaddr + CSR15); /* Data */
   1837                 outl(csr13val, ioaddr + CSR13);
   1838             } else {
   1839                 csr13val = 1;
   1840                 csr14val = 0x0003FF7F;
   1841                 csr15dir = (setup[0]<<16) | 0x0008;
   1842                 csr15val = (setup[1]<<16) | 0x0008;
   1843                 if (tp->if_port <= 4)
   1844                     csr14val = t21142_csr14[tp->if_port];
   1845                 if (startup) {
   1846                     outl(0, ioaddr + CSR13);
   1847                     outl(csr14val, ioaddr + CSR14);
   1848                 }
   1849                 outl(csr15dir, ioaddr + CSR15); /* Direction */
   1850                 outl(csr15val, ioaddr + CSR15); /* Data */
   1851                 if (startup) outl(csr13val, ioaddr + CSR13);
   1852             }
   1853 #ifdef TULIP_DEBUG
   1854             if (tulip_debug > 1)
   1855                 printf("%s:  Setting CSR15 to %X/%X.\n",
   1856                        tp->nic_name, csr15dir, csr15val);
   1857 #endif
   1858             if (mleaf->type == 4)
   1859                 new_csr6 = 0x82020000 | ((setup[2] & 0x71) << 18);
   1860             else
   1861                 new_csr6 = 0x82420000;
   1862             break;
   1863         }
   1864         case 1: case 3: {
   1865             int phy_num = p[0];
   1866             int init_length = p[1];
   1867             u16 *misc_info;
   1868 
   1869             tp->if_port = 11;
   1870             new_csr6 = 0x020E0000;
   1871             if (mleaf->type == 3) {     /* 21142 */
   1872                 u16 *init_sequence = (u16*)(p+2);
   1873                 u16 *reset_sequence = &((u16*)(p+3))[init_length];
   1874                 int reset_length = p[2 + init_length*2];
   1875                 misc_info = reset_sequence + reset_length;
   1876                 if (startup)
   1877                     for (i = 0; i < reset_length; i++)
   1878                         outl(get_u16(&reset_sequence[i]) << 16, ioaddr + CSR15);
   1879                 for (i = 0; i < init_length; i++)
   1880                     outl(get_u16(&init_sequence[i]) << 16, ioaddr + CSR15);
   1881             } else {
   1882                 u8 *init_sequence = p + 2;
   1883                 u8 *reset_sequence = p + 3 + init_length;
   1884                 int reset_length = p[2 + init_length];
   1885                 misc_info = (u16*)(reset_sequence + reset_length);
   1886                 if (startup) {
   1887                     outl(mtable->csr12dir | 0x100, ioaddr + CSR12);
   1888                     for (i = 0; i < reset_length; i++)
   1889                         outl(reset_sequence[i], ioaddr + CSR12);
   1890                 }
   1891                 for (i = 0; i < init_length; i++)
   1892                     outl(init_sequence[i], ioaddr + CSR12);
   1893             }
   1894             tp->advertising[phy_num] = get_u16(&misc_info[1]) | 1;
   1895             if (startup < 2) {
   1896                 if (tp->mii_advertise == 0)
   1897                     tp->mii_advertise = tp->advertising[phy_num];
   1898 #ifdef TULIP_DEBUG
   1899                 if (tulip_debug > 1)
   1900                     printf("%s:  Advertising %hX on MII %d.\n",
   1901                            tp->nic_name, tp->mii_advertise, tp->phys[phy_num]);
   1902 #endif
   1903                 mdio_write(nic, tp->phys[phy_num], 4, tp->mii_advertise);
   1904             }
   1905             break;
   1906         }
   1907         default:
   1908             printf("%s:  Invalid media table selection %d.\n",
   1909                    tp->nic_name, mleaf->type);
   1910             new_csr6 = 0x020E0000;
   1911         }
   1912 #ifdef TULIP_DEBUG
   1913         if (tulip_debug > 1)
   1914             printf("%s: Using media type %s, CSR12 is %hhX.\n",
   1915                    tp->nic_name, medianame[tp->if_port],
   1916                    inl(ioaddr + CSR12) & 0xff);
   1917 #endif
   1918     } else if (tp->chip_id == DC21041) {
   1919         int port = tp->if_port <= 4 ? tp->if_port : 0;
   1920 #ifdef TULIP_DEBUG
   1921         if (tulip_debug > 1)
   1922             printf("%s: 21041 using media %s, CSR12 is %hX.\n",
   1923                    tp->nic_name, medianame[port == 3 ? 12: port],
   1924                    inl(ioaddr + CSR12));
   1925 #endif
   1926         outl(0x00000000, ioaddr + CSR13); /* Reset the serial interface */
   1927         outl(t21041_csr14[port], ioaddr + CSR14);
   1928         outl(t21041_csr15[port], ioaddr + CSR15);
   1929         outl(t21041_csr13[port], ioaddr + CSR13);
   1930         new_csr6 = 0x80020000;
   1931     } else if (tp->chip_id == LC82C168) {
   1932         if (startup && ! tp->medialock)
   1933             tp->if_port = tp->mii_cnt ? 11 : 0;
   1934 #ifdef TULIP_DEBUG
   1935         if (tulip_debug > 1)
   1936 	    printf("%s: PNIC PHY status is %hX, media %s.\n",
   1937                    tp->nic_name, inl(ioaddr + 0xB8), medianame[tp->if_port]);
   1938 #endif
   1939         if (tp->mii_cnt) {
   1940             new_csr6 = 0x810C0000;
   1941             outl(0x0001, ioaddr + CSR15);
   1942             outl(0x0201B07A, ioaddr + 0xB8);
   1943         } else if (startup) {
   1944             /* Start with 10mbps to do autonegotiation. */
   1945             outl(0x32, ioaddr + CSR12);
   1946             new_csr6 = 0x00420000;
   1947             outl(0x0001B078, ioaddr + 0xB8);
   1948             outl(0x0201B078, ioaddr + 0xB8);
   1949         } else if (tp->if_port == 3  ||  tp->if_port == 5) {
   1950             outl(0x33, ioaddr + CSR12);
   1951             new_csr6 = 0x01860000;
   1952             /* Trigger autonegotiation. */
   1953             outl(startup ? 0x0201F868 : 0x0001F868, ioaddr + 0xB8);
   1954         } else {
   1955             outl(0x32, ioaddr + CSR12);
   1956             new_csr6 = 0x00420000;
   1957             outl(0x1F078, ioaddr + 0xB8);
   1958         }
   1959     } else if (tp->chip_id == DC21040) {                                        /* 21040 */
   1960         /* Turn on the xcvr interface. */
   1961 #ifdef TULIP_DEBUG
   1962         int csr12 = inl(ioaddr + CSR12);
   1963         if (tulip_debug > 1)
   1964             printf("%s: 21040 media type is %s, CSR12 is %hhX.\n",
   1965                    tp->nic_name, medianame[tp->if_port], csr12);
   1966 #endif
   1967         if (media_cap[tp->if_port] & MediaAlwaysFD)
   1968             tp->full_duplex = 1;
   1969         new_csr6 = 0x20000;
   1970         /* Set the full duplux match frame. */
   1971         outl(FULL_DUPLEX_MAGIC, ioaddr + CSR11);
   1972         outl(0x00000000, ioaddr + CSR13); /* Reset the serial interface */
   1973         if (t21040_csr13[tp->if_port] & 8) {
   1974             outl(0x0705, ioaddr + CSR14);
   1975             outl(0x0006, ioaddr + CSR15);
   1976         } else {
   1977             outl(0xffff, ioaddr + CSR14);
   1978             outl(0x0000, ioaddr + CSR15);
   1979         }
   1980         outl(0x8f01 | t21040_csr13[tp->if_port], ioaddr + CSR13);
   1981     } else {                                    /* Unknown chip type with no media table. */
   1982         if (tp->default_port == 0)
   1983             tp->if_port = tp->mii_cnt ? 11 : 3;
   1984         if (media_cap[tp->if_port] & MediaIsMII) {
   1985             new_csr6 = 0x020E0000;
   1986         } else if (media_cap[tp->if_port] & MediaIsFx) {
   1987             new_csr6 = 0x028600000;
   1988         } else
   1989             new_csr6 = 0x038600000;
   1990 #ifdef TULIP_DEBUG
   1991         if (tulip_debug > 1)
   1992             printf("%s: No media description table, assuming "
   1993                    "%s transceiver, CSR12 %hhX.\n",
   1994                    tp->nic_name, medianame[tp->if_port],
   1995                    inl(ioaddr + CSR12));
   1996 #endif
   1997     }
   1998 
   1999     tp->csr6 = new_csr6 | (tp->csr6 & 0xfdff) | (tp->full_duplex ? 0x0200 : 0);
   2000     return;
   2001 }
   2002 
   2003 /*
   2004   Check the MII negotiated duplex and change the CSR6 setting if
   2005   required.
   2006   Return 0 if everything is OK.
   2007   Return < 0 if the transceiver is missing or has no link beat.
   2008 */
   2009 static int tulip_check_duplex(struct nic *nic)
   2010 {
   2011         unsigned int bmsr, lpa, negotiated, new_csr6;
   2012 
   2013         bmsr = mdio_read(nic, tp->phys[0], 1);
   2014         lpa = mdio_read(nic, tp->phys[0], 5);
   2015 
   2016 #ifdef TULIP_DEBUG
   2017         if (tulip_debug > 1)
   2018                 printf("%s: MII status %#x, Link partner report "
   2019                            "%#x.\n", tp->nic_name, bmsr, lpa);
   2020 #endif
   2021 
   2022         if (bmsr == 0xffff)
   2023                 return -2;
   2024         if ((bmsr & 4) == 0) {
   2025                 int new_bmsr = mdio_read(nic, tp->phys[0], 1);
   2026                 if ((new_bmsr & 4) == 0) {
   2027 #ifdef TULIP_DEBUG
   2028                         if (tulip_debug  > 1)
   2029                                 printf("%s: No link beat on the MII interface,"
   2030                                            " status %#x.\n", tp->nic_name,
   2031                                            new_bmsr);
   2032 #endif
   2033                         return -1;
   2034                 }
   2035         }
   2036         tp->full_duplex = lpa & 0x140;
   2037 
   2038         new_csr6 = tp->csr6;
   2039         negotiated = lpa & tp->advertising[0];
   2040 
   2041         if(negotiated & 0x380) new_csr6 &= ~0x400000;
   2042         else                   new_csr6 |= 0x400000;
   2043         if (tp->full_duplex)   new_csr6 |= 0x200;
   2044         else                   new_csr6 &= ~0x200;
   2045 
   2046         if (new_csr6 != tp->csr6) {
   2047                 tp->csr6 = new_csr6;
   2048 
   2049 #ifdef TULIP_DEBUG
   2050                 if (tulip_debug > 0)
   2051                         printf("%s: Setting %s-duplex based on MII"
   2052                                    "#%d link partner capability of %#x.\n",
   2053                                    tp->nic_name,
   2054                                    tp->full_duplex ? "full" : "half",
   2055                                    tp->phys[0], lpa);
   2056 #endif
   2057                 return 1;
   2058         }
   2059 
   2060         return 0;
   2061 }
   2062 
   2063 static struct pci_device_id tulip_nics[] = {
   2064 PCI_ROM(0x1011, 0x0002, "dc21040",     "Digital Tulip", 0),
   2065 PCI_ROM(0x1011, 0x0009, "ds21140",     "Digital Tulip Fast", 0),
   2066 PCI_ROM(0x1011, 0x0014, "dc21041",     "Digital Tulip+", 0),
   2067 PCI_ROM(0x1011, 0x0019, "ds21142",     "Digital Tulip 21142", 0),
   2068 PCI_ROM(0x10b7, 0x9300, "3csoho100b-tx","3ComSOHO100B-TX", 0),
   2069 PCI_ROM(0x10b9, 0x5261, "ali1563",     "ALi 1563 integrated ethernet", 0),
   2070 PCI_ROM(0x10d9, 0x0512, "mx98713",     "Macronix MX987x3", 0),
   2071 PCI_ROM(0x10d9, 0x0531, "mx98715",     "Macronix MX987x5", 0),
   2072 PCI_ROM(0x1113, 0x1217, "mxic-98715",  "Macronix MX987x5", 0),
   2073 PCI_ROM(0x11ad, 0xc115, "lc82c115",    "LinkSys LNE100TX", 0),
   2074 PCI_ROM(0x11ad, 0x0002, "82c168",      "Netgear FA310TX", 0),
   2075 PCI_ROM(0x1282, 0x9100, "dm9100",      "Davicom 9100", 0),
   2076 PCI_ROM(0x1282, 0x9102, "dm9102",      "Davicom 9102", 0),
   2077 PCI_ROM(0x1282, 0x9009, "dm9009",      "Davicom 9009", 0),
   2078 PCI_ROM(0x1282, 0x9132, "dm9132",      "Davicom 9132", 0),
   2079 PCI_ROM(0x1317, 0x0985, "centaur-p",   "ADMtek Centaur-P", 0),
   2080 PCI_ROM(0x1317, 0x0981, "an981",       "ADMtek AN981 Comet", 0),		/* ADMTek Centaur-P (stmicro) */
   2081 PCI_ROM(0x1113, 0x1216, "an983",       "ADMTek AN983 Comet", 0),
   2082 PCI_ROM(0x1317, 0x9511, "an983b",      "ADMTek Comet 983b", 0),
   2083 PCI_ROM(0x1317, 0x1985, "centaur-c",   "ADMTek Centaur-C", 0),
   2084 PCI_ROM(0x8086, 0x0039, "intel21145",  "Intel Tulip", 0),
   2085 PCI_ROM(0x125b, 0x1400, "ax88140",     "ASIX AX88140", 0),
   2086 PCI_ROM(0x11f6, 0x9881, "rl100tx",     "Compex RL100-TX", 0),
   2087 PCI_ROM(0x115d, 0x0003, "xircomtulip", "Xircom Tulip", 0),
   2088 PCI_ROM(0x104a, 0x0981, "tulip-0981",  "Tulip 0x104a 0x0981", 0),
   2089 PCI_ROM(0x104a, 0x2774, "SGThomson-STE10100A", "Tulip 0x104a 0x2774", 0),	/*Modified by Ramesh Chander*/
   2090 PCI_ROM(0x1113, 0x9511, "tulip-9511",  "Tulip 0x1113 0x9511", 0),
   2091 PCI_ROM(0x1186, 0x1561, "tulip-1561",  "Tulip 0x1186 0x1561", 0),
   2092 PCI_ROM(0x1259, 0xa120, "tulip-a120",  "Tulip 0x1259 0xa120", 0),
   2093 PCI_ROM(0x13d1, 0xab02, "tulip-ab02",  "Tulip 0x13d1 0xab02", 0),
   2094 PCI_ROM(0x13d1, 0xab03, "tulip-ab03",  "Tulip 0x13d1 0xab03", 0),
   2095 PCI_ROM(0x13d1, 0xab08, "tulip-ab08",  "Tulip 0x13d1 0xab08", 0),
   2096 PCI_ROM(0x14f1, 0x1803, "lanfinity",   "Conexant LANfinity", 0),
   2097 PCI_ROM(0x1626, 0x8410, "tulip-8410",  "Tulip 0x1626 0x8410", 0),
   2098 PCI_ROM(0x1737, 0xab08, "tulip-1737-ab08","Tulip 0x1737 0xab08", 0),
   2099 PCI_ROM(0x1737, 0xab09, "tulip-ab09",  "Tulip 0x1737 0xab09", 0),
   2100 };
   2101 
   2102 PCI_DRIVER ( tulip_driver, tulip_nics, PCI_NO_CLASS );
   2103 
   2104 DRIVER ( "Tulip", nic_driver, pci_driver, tulip_driver,
   2105 	 tulip_probe, tulip_disable );
   2106 
   2107 /*
   2108  * Local variables:
   2109  *  c-basic-offset: 8
   2110  *  c-indent-level: 8
   2111  *  tab-width: 8
   2112  * End:
   2113  */
   2114