/* -*- Mode:C; c-basic-offset:4; -*- */
/*
Tulip and clone Etherboot Driver
By Marty Connor (mdc@thinguin.org)
Copyright (C) 2001 Entity Cyber, Inc.
This software may be used and distributed according to the terms
of the GNU Public License, incorporated herein by reference.
As of April 2001 this driver should support most tulip cards that
the Linux tulip driver supports because Donald Becker's Linux media
detection code is now included.
Based on Ken Yap's Tulip Etherboot Driver and Donald Becker's
Linux Tulip Driver. Supports N-Way speed auto-configuration on
MX98715, MX98715A and MX98725. Support inexpensive PCI 10/100 cards
based on the Macronix MX987x5 chip, such as the SOHOware Fast
model SFA110A, and the LinkSYS model LNE100TX. The NetGear
model FA310X, based on the LC82C168 chip is supported.
The TRENDnet TE100-PCIA NIC which uses a genuine Intel 21143-PD
chipset is supported. Also, Davicom DM9102's.
Documentation and source code used:
Source for Etherboot driver at
MX98715A Data Sheet and MX98715A Application Note
on http://www.macronix.com/ (PDF format files)
Source for Linux tulip driver at
Adapted by Ken Yap from
FreeBSD netboot DEC 21143 driver
Author: David Sharp
date: Nov/98
Some code fragments were taken from verious places, Ken Yap's
etherboot, FreeBSD's if_de.c, and various Linux related files.
DEC's manuals for the 21143 and SROM format were very helpful.
The Linux de driver development page has a number of links to
useful related information. Have a look at:
*/
/*********************************************************************/
/* Revision History */
/*********************************************************************/
/*
07 Sep 2003 timlegge Multicast Support Added
11 Apr 2001 mdc [patch to etherboot 4.7.24]
Major rewrite to include Linux tulip driver media detection
code. This driver should support a lot more cards now.
16 Jul 2000 mdc 0.75b11
Added support for ADMtek 0985 Centaur-P, a "Comet" tulip clone
which is used on the LinkSYS LNE100TX v4.x cards. We already
support LNE100TX v2.0 cards, which use a different controller.
04 Jul 2000 jam ?
Added test of status after receiving a packet from the card.
Also uncommented the tulip_disable routine. Stray packets
seemed to be causing problems.
27 Apr 2000 njl ?
29 Feb 2000 mdc 0.75b7
Increased reset delay to 3 seconds because Macronix cards seem to
need more reset time before card comes back to a usable state.
26 Feb 2000 mdc 0.75b6
Added a 1 second delay after initializing the transmitter because
some cards seem to need the time or they drop the first packet
transmitted.
23 Feb 2000 mdc 0.75b5
removed udelay code and used currticks() for more reliable delay
code in reset pause and sanity timeouts. Added function prototypes
and TX debugging code.
21 Feb 2000 mdc patch to Etherboot 4.4.3
Incorporated patches from Bob Edwards and Paul Mackerras of
Linuxcare's OZLabs to deal with inefficiencies in tulip_transmit
and udelay. We now wait for packet transmission to complete
(or sanity timeout).
04 Feb 2000 Robert.Edwards@anu.edu.au patch to Etherboot 4.4.2
patch to tulip.c that implements the automatic selection of the MII
particular, the TRENDnet TE100-PCIA NIC which uses a genuine Intel
21143-PD chipset.
11 Jan 2000 mdc 0.75b4
Added support for NetGear FA310TX card based on the LC82C168
chip. This should also support Lite-On LC82C168 boards.
Added simple MII support. Re-arranged code to better modularize
initializations.
04 Dec 1999 mdc 0.75b3
Added preliminary support for LNE100TX PCI cards. Should work for
PNIC2 cards. No MII support, but single interface (RJ45) tulip
cards seem to not care.
03 Dec 1999 mdc 0.75b2
Renamed from mx987x5 to tulip, merged in original tulip init code
from tulip.c to support other tulip compatible cards.
02 Dec 1999 mdc 0.75b1
Released Beta MX987x5 Driver for code review and testing to netboot
and thinguin mailing lists.
*/
/*********************************************************************/
/* Declarations */
/*********************************************************************/
#include "etherboot.h"
#include "nic.h"
#include "pci.h"
/* User settable parameters */
#ifdef TULIP_DEBUG
#endif
/* helpful macros if on a big_endian machine for changing byte order.
not strictly needed on Intel */
/* This is a mysterious value that can be written to CSR11 in the 21040 (only)
to support a pre-NWay full-duplex signaling mechanism using short frames.
No one knows what it should be, but if left at its default value some
10base2(!) packets trigger a full-duplex-request interrupt. */
/* The possible media types that can be set in options[] are: */
"10baseT", "10base2", "AUI", "100baseTx",
"10baseT-FDX", "100baseTx-FDX", "100baseT4", "100baseFx",
"100baseFx-FDX", "MII 10baseT", "MII 10baseT-FDX", "MII",
"10baseT(forced)", "MII 100baseTx", "MII 100baseTx-FDX", "MII 100baseT4",
"MII 100baseFx-HDX", "MII 100baseFx-FDX", "Home-PNA 1Mbps", "Invalid-19",
};
/* This much match tulip_tbl[]! Note 21142 == 21143. */
enum tulip_chips {
};
enum pci_id_flags_bits {
/* Set PCI command register bits before calling probe1(). */
/* Read and map the single following PCI BAR. */
};
struct pci_id_info {
char *name;
struct match_info {
} id;
};
{ "Digital DC21040 Tulip", { 0x00021011, 0xffffffff, 0, 0, 0, 0 },
{ "Digital DC21041 Tulip", { 0x00141011, 0xffffffff, 0, 0, 0, 0 },
{ "Digital DS21140A Tulip", { 0x00091011, 0xffffffff, 0,0, 0x20,0xf0 },
{ "Digital DS21140 Tulip", { 0x00091011, 0xffffffff, 0, 0, 0, 0 },
{ "Digital DS21143 Tulip", { 0x00191011, 0xffffffff, 0,0, 65,0xff },
{ "Digital DS21142 Tulip", { 0x00191011, 0xffffffff, 0, 0, 0, 0 },
{ "Kingston KNE110tx (PNIC)", { 0x000211AD, 0xffffffff, 0xf0022646, 0xffffffff, 0, 0 },
{ "Lite-On 82c168 PNIC", { 0x000211AD, 0xffffffff, 0, 0, 0, 0 },
{ "Macronix 98713 PMAC", { 0x051210d9, 0xffffffff, 0, 0, 0, 0 },
{ "Macronix 98715 PMAC", { 0x053110d9, 0xffffffff, 0, 0, 0, 0 },
{ "Macronix 98725 PMAC", { 0x053110d9, 0xffffffff, 0, 0, 0, 0 },
{ "ASIX AX88141", { 0x1400125B, 0xffffffff, 0,0, 0x10, 0xf0 },
{ "ASIX AX88140", { 0x1400125B, 0xffffffff, 0, 0, 0, 0 },
{ "Lite-On LC82C115 PNIC-II", { 0xc11511AD, 0xffffffff, 0, 0, 0, 0 },
{ "ADMtek AN981 Comet", { 0x09811317, 0xffffffff, 0, 0, 0, 0 },
{ "ADMTek AN983 Comet", { 0x12161113, 0xffffffff, 0, 0, 0, 0 },
{ "ADMtek Centaur-P", { 0x09851317, 0xffffffff, 0, 0, 0, 0 },
{ "ADMtek Centaur-C", { 0x19851317, 0xffffffff, 0, 0, 0, 0 },
{ "Compex RL100-TX", { 0x988111F6, 0xffffffff, 0, 0, 0, 0 },
{ "Intel 21145 Tulip", { 0x00398086, 0xffffffff, 0, 0, 0, 0 },
{ "Xircom Tulip clone", { 0x0003115d, 0xffffffff, 0, 0, 0, 0 },
{ "Davicom DM9102", { 0x91021282, 0xffffffff, 0, 0, 0, 0 },
{ "Davicom DM9100", { 0x91001282, 0xffffffff, 0, 0, 0, 0 },
{ "Macronix mxic-98715 (EN1217)", { 0x12171113, 0xffffffff, 0, 0, 0, 0 },
{ 0, { 0, 0, 0, 0, 0, 0 }, 0, 0, 0 },
};
enum tbl_flag {
};
/* Note: this table must match enum tulip_chips above. */
static struct tulip_chip_table {
char *chip_name;
int flags;
} tulip_tbl[] = {
{ "Digital DC21040 Tulip", 0},
{ "Macronix 98715 PMAC", HAS_MEDIA_TABLE },
{ "Macronix 98725 PMAC", HAS_MEDIA_TABLE },
| MC_HASH_ONLY | IS_ASIX },
| IS_ASIX },
{ "ADMtek Comet", MC_HASH_ONLY },
| HAS_PWRDWN | HAS_NWAY },
| HAS_PWRDWN | HAS_NWAY },
{ 0, 0 },
};
/* A full-duplex map for media types. */
enum MediaIs {
{0,0,0,16, 3,19,16,24, 27,4,7,5, 0,20,23,20, 20,31,0,0, };
/* 21041 transceiver register settings: 10-T, 10-2, AUI, 10-T, 10T-FD */
/* not used
static u16 t21142_csr13[] = { 0x0001, 0x0009, 0x0009, 0x0000, 0x0001, };
*/
/* not used
static u16 t21142_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
*/
/* Offsets to the Command and Status Registers, "CSRs". All accesses
must be longword instructions and quadword aligned. */
enum tulip_offsets {
};
/* The bits in the CSR5 status registers, mostly interrupt sources. */
enum status_bits {
};
/* The configuration bits in CSR6. */
enum csr6_mode_bits {
};
enum desc_status_bits {
};
struct medialeaf {
unsigned char *leafdata;
};
struct mediatable {
};
struct mediainfo {
int info_type;
int index;
unsigned char *info;
};
/* EEPROM Address width definitions */
/* The EEPROM commands include the alway-set leading bit. */
/* EEPROM_Ctrl bits. */
/* Delay between EEPROM clock transitions. Even at 33Mhz current PCI
implementations don't overrun the EEPROM clock. We add a bus
turn-around to insure that this remains true. */
/* Size of transmit and receive buffers */
/* Ring-wrap flag in length field, use for last ring entry.
0x01000000 means chain on buffer2 address,
0x02000000 means use the ring start address in CSR2/3.
Note: Some work-alike chips do not function correctly in chained mode.
The ASIX chip works only in chained mode.
Thus we indicate ring mode, but always write the 'next' field for
chained mode as well. */
/* transmit and receive descriptor format */
struct tulip_rx_desc {
};
struct tulip_tx_desc {
};
/*********************************************************************/
/* Global Storage */
/*********************************************************************/
/* Note: transmit and receive buffers must be longword aligned and
longword divisable */
static struct tulip_private {
int cur_rx;
int revision;
int flags;
const char *nic_name;
unsigned int if_port;
unsigned int full_duplex_lock;
unsigned int default_port;
int saved_if_port;
} tpx;
/* Known cards that have old-style EEPROMs.
Writing this table is described at
static struct fixups {
char *name;
} eeprom_fixups[] = {
{"Asante", 0, 0, 0x94, {0x1e00, 0x0000, 0x0800, 0x0100, 0x018c,
0x0000, 0x0000, 0xe078, 0x0001, 0x0050, 0x0018 }},
{"SMC9332DST", 0, 0, 0xC0, { 0x1e00, 0x0000, 0x0800, 0x041f,
0x0000, 0x009E, /* 10baseT */
0x0004, 0x009E, /* 10baseT-FD */
0x0903, 0x006D, /* 100baseTx */
0x0905, 0x006D, /* 100baseTx-FD */ }},
{"Cogent EM100", 0, 0, 0x92, { 0x1e00, 0x0000, 0x0800, 0x063f,
0x0107, 0x8021, /* 100baseFx */
0x0108, 0x8021, /* 100baseFx-FD */
0x0100, 0x009E, /* 10baseT */
0x0104, 0x009E, /* 10baseT-FD */
0x0103, 0x006D, /* 100baseTx */
0x0105, 0x006D, /* 100baseTx-FD */ }},
{"Maxtech NX-110", 0, 0, 0xE8, { 0x1e00, 0x0000, 0x0800, 0x0513,
0x1001, 0x009E, /* 10base2, CSR12 0x10*/
0x0000, 0x009E, /* 10baseT */
0x0004, 0x009E, /* 10baseT-FD */
0x0303, 0x006D, /* 100baseTx, CSR12 0x03 */
0x0305, 0x006D, /* 100baseTx-FD CSR12 0x03 */}},
{"Accton EN1207", 0, 0, 0xE8, { 0x1e00, 0x0000, 0x0800, 0x051F,
0x1B01, 0x0000, /* 10base2, CSR12 0x1B */
0x0B00, 0x009E, /* 10baseT, CSR12 0x0B */
0x0B04, 0x009E, /* 10baseT-FD,CSR12 0x0B */
0x1B03, 0x006D, /* 100baseTx, CSR12 0x1B */
0x1B05, 0x006D, /* 100baseTx-FD CSR12 0x1B */
}},
{0, 0, 0, 0, {}}};
"21142 Serial PHY", "21142 MII PHY", "21143 SYM PHY", "21143 reset method"};
/*********************************************************************/
/* Function Prototypes */
/*********************************************************************/
unsigned int s, const char *p);
static void tulip_wait(unsigned int nticks);
#ifdef TULIP_DEBUG_WHERE
#endif
#ifdef TULIP_DEBUG
static void tulip_more(void);
#endif
/*********************************************************************/
/* Utility Routines */
/*********************************************************************/
#ifdef TULIP_DEBUG_WHERE
{
/* sleep(2); */
}
#endif
#ifdef TULIP_DEBUG
static void tulip_more(void)
{
printf("\n\n-- more --");
while (!iskey())
/* wait */;
getchar();
printf("\n\n");
}
#endif /* TULIP_DEBUG */
{
/* wait */ ;
}
/*********************************************************************/
/* Media Descriptor Code */
/*********************************************************************/
/* MII transceiver control section.
Read and write the MII registers using software-generated serial
MDIO protocol. See the MII specifications or DP83840A data sheet
for details. */
/* The maximum data clock rate is 2.5 Mhz. The minimum timing is usually
met by back-to-back PCI I/O cycles, but we insert a delay to avoid
"overclocking" issues or future 66Mhz PCI. */
/* Read and write the MII registers using software-generated serial
MDIO protocol. It is just different enough from the EEPROM protocol
to not share code. The maxium data clock rate is 2.5 Mhz. */
/* MII transceiver control section.
Read and write the MII registers using software-generated serial
MDIO protocol. See the MII specifications or DP83840A data sheet
for details. */
{
int i;
int retval = 0;
#ifdef TULIP_DEBUG_WHERE
whereami("mdio_read\n");
#endif
int i = 1000;
while (--i > 0)
return retval & 0xffff;
return 0xffff;
}
if (phy_id == 1) {
if (location < 7)
else if (location == 17)
}
return 0xffff;
}
/* Establish sync by sending at least 32 logic ones. */
for (i = 32; i >= 0; i--) {
mdio_delay();
mdio_delay();
}
/* Shift the read command bits out. */
for (i = 15; i >= 0; i--) {
mdio_delay();
mdio_delay();
}
/* Read the two transition, 16 data, and wire-idle bits. */
for (i = 19; i > 0; i--) {
mdio_delay();
mdio_delay();
}
}
{
int i;
#ifdef TULIP_DEBUG_WHERE
whereami("mdio_write\n");
#endif
int i = 1000;
do
break;
while (--i > 0);
return;
}
if (phy_id != 1)
return;
if (location < 7)
else if (location == 17)
return;
}
/* Establish sync by sending 32 logic ones. */
for (i = 32; i >= 0; i--) {
mdio_delay();
mdio_delay();
}
/* Shift the command bits out. */
for (i = 31; i >= 0; i--) {
mdio_delay();
mdio_delay();
}
/* Clear out extra bits. */
for (i = 2; i > 0; i--) {
mdio_delay();
mdio_delay();
}
}
/*********************************************************************/
/* EEPROM Reading Code */
/*********************************************************************/
/* EEPROM routines adapted from the Linux Tulip Code */
/* Reading a serial EEPROM is a "bit" grungy, but we work our way
through:->.
*/
{
int i;
unsigned short retval = 0;
#ifdef TULIP_DEBUG_WHERE
whereami("read_eeprom\n");
#endif
/* Shift the read command bits out. */
for (i = 4 + addr_len; i >= 0; i--) {
eeprom_delay();
eeprom_delay();
}
for (i = 16; i > 0; i--) {
eeprom_delay();
eeprom_delay();
}
/* Terminate the EEPROM access. */
return retval;
}
/*********************************************************************/
/* EEPROM Parsing Code */
/*********************************************************************/
{
int new_advertise = 0;
int i;
#ifdef TULIP_DEBUG_WHERE
whereami("parse_eeprom\n");
#endif
/* Detect an old-style (SA only) EEPROM layout:
memcmp(ee_data, ee_data+16, 8). */
for (i = 0; i < 8; i ++)
break;
if (i >= 8) {
/* Do a fix-up based on the vendor half of the station address. */
for (i = 0; eeprom_fixups[i].name; i++) {
i++; /* An Accton EN1207, not an outlaw Maxtech. */
sizeof(eeprom_fixups[i].newtable));
#ifdef TULIP_DEBUG
printf("%s: Old format EEPROM on '%s' board.\n%s: Using substitute media control info.\n",
#endif
break;
}
}
#ifdef TULIP_DEBUG
printf("%s: Old style EEPROM with no media selection information.\n",
#endif
return;
}
}
#ifdef TULIP_DEBUG
printf("%s: Multiport cards (%d ports) may not work correctly.\n",
#endif
}
#ifdef TULIP_DEBUG
if (tulip_debug > 1) {
printf("%s: No Valid Media Table. ee_data[27] = %hhX\n",
}
#endif
p += 3;
printf("%s: 21041 Media table, default media %hX (%s).\n",
for (i = 0; i < count; i++) {
unsigned char media_block = *p++;
if (media_block & 0x40)
p += 6;
switch(media_code) {
case 0: new_advertise |= 0x0020; break;
}
printf("%s: 21041 media #%d, %s.\n",
}
} else {
unsigned char csr12dir = 0;
int count;
p += 2;
csr12dir = *p++;
count = *p++;
for (i = 0; i < count; i++) {
if ((p[0] & 0x80) == 0) { /* 21140 Compact block. */
if ((p[2] & 0x61) == 0x01) /* Bogus, but Znyx boards do it. */
p += 4;
} else {
case 5:
break;
case 1: case 3:
break;
case 2:
if ((p[2] & 0x3f) == 0) {
}
/* Fall through. */
case 0: case 4:
case 0: new_advertise |= 0x0020; break;
}
break;
default:
}
p += (p[0] & 0x3f) + 1;
}
#ifdef TULIP_DEBUG
}
#endif
printf("%s: Index #%d - Media %s (#%d) described "
"by a %s (%d) block.\n",
}
if (new_advertise)
}
}
/*********************************************************************/
/* tulip_init_ring - setup the tx and rx descriptors */
/*********************************************************************/
{
int i;
#ifdef TULIP_DEBUG_WHERE
whereami("tulip_init_ring\n");
#endif
for (i = 0; i < RX_RING_SIZE; i++) {
}
/* Mark the last entry as wrapping the ring. */
/* We only use 1 transmit buffer, but we use 2 descriptors so
transmit engines have somewhere to point to if they feel the need */
/* this descriptor should never get used, since it will never be owned
by the machine (status will always == 0) */
/* Mark the last entry as wrapping the ring, though this should never happen */
}
/* !IFF_PROMISC */
}
/*********************************************************************/
/* eth_reset - Reset adapter */
/*********************************************************************/
{
int i;
unsigned long to;
#ifdef TULIP_DEBUG_WHERE
whereami("tulip_reset\n");
#endif
/* Stop Tx and RX */
}
/* Reset the chip, holding bit 0 set at least 50 PCI cycles. */
tulip_wait(1);
/* turn off reset and set cache align=16lword, burst=unlimit */
/* Wait the specified 50 PCI cycles after a reset */
tulip_wait(1);
/* set up transmit and receive descriptors */
/* This address setting does not appear to impact chip operation?? */
ioaddr + 0xB0);
}
/* MC_HASH_ONLY boards don't support setup packets */
/* clear multicast hash filters and setup MAC address filters */
}
} else {
/* for other boards we send a setup packet to initialize
the filters */
/* construct perfect filter frame with mac address as first match
and broadcast address for all others */
for (i=0; i<192; i++)
txb[i] = 0xFF;
}
/* Point to rx and tx descriptors */
/* set the chip's operating mode (but don't turn on xmit and recv yet) */
/* send setup packet for cards that support it */
/* enable transmit wait for completion */
/* immediate transmit demand */
/* wait */ ;
}
}
/* enable transmit and receive */
}
/*********************************************************************/
/* eth_transmit - Transmit a frame */
/*********************************************************************/
unsigned int s, const char *p)
{
#ifdef TULIP_DEBUG_WHERE
whereami("tulip_transmit\n");
#endif
/* Disable Tx */
s += ETH_HLEN;
s &= 0x0FFF;
/* pad to minimum packet size */
while (s < ETH_ZLEN)
txb[s++] = '\0';
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
#endif
/* setup the transmit descriptor */
/* 0x60000000 = no interrupt on completion */
/* Point to transmit descriptor */
/* Enable Tx */
/* immediate transmit demand */
/* wait */ ;
printf ("TX Timeout!\n");
}
/* Disable Tx */
}
/*********************************************************************/
/* eth_poll - Wait for a frame */
/*********************************************************************/
{
#ifdef TULIP_DEBUG_WHERE
whereami("tulip_poll\n");
#endif
/* no packet waiting. packet still owned by NIC */
return 0;
if ( ! retrieve ) return 1;
#ifdef TULIP_DEBUG_WHERE
whereami("tulip_poll got one\n");
#endif
/* if we get a corrupted packet. throw it away and move on */
/* return the descriptor and buffer to receive ring */
return 0;
}
/* copy packet to working buffer */
/* return the descriptor and buffer to receive ring */
return 1;
}
/*********************************************************************/
/* eth_disable - Disable the interface */
/*********************************************************************/
{
#ifdef TULIP_DEBUG_WHERE
whereami("tulip_disable\n");
#endif
/* merge reset and disable */
/* disable interrupts */
/* Stop the chip's Tx and Rx processes. */
/* Clear the missed-packet counter. */
}
/*********************************************************************/
/*IRQ - Enable, Disable, or Force interrupts */
/*********************************************************************/
{
switch ( action ) {
case DISABLE :
break;
case ENABLE :
break;
case FORCE :
break;
}
}
/*********************************************************************/
/* eth_probe - Look for an adapter */
/*********************************************************************/
{
u32 i;
unsigned short sum;
int chip_idx;
return 0;
/* point to private storage */
tp->default_port = 0;
/* disable interrupts */
/* Stop the chip's Tx and Rx processes. */
/* Clear the missed-packet counter. */
#ifdef TULIP_DEBUG_WHERE
whereami("tulip_probe\n");
#endif
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
#endif
/* Figure out which chip we're dealing with */
i = 0;
chip_idx = -1;
while (pci_id_tbl[i].name) {
break;
}
i++;
}
if (chip_idx == -1) {
return 0;
}
tp->pci_id_idx = i;
#ifdef TULIP_DEBUG
if (tulip_debug > 1) {
}
#endif
/* Bring the 21041/21143 out of sleep mode.
Caution: Snooze mode does not work with some boards! */
printf("%s: The Tulip chip at %X is not functioning.\n",
return 0;
}
printf(" 21040 compatible mode.");
}
printf("\n");
sum = 0;
for (i = 0; i < ETH_ALEN; i++) {
do
}
for (i = 0; i < 3; i++) {
do
}
/* No need to read the EEPROM. */
for (i = 0; i < ETH_ALEN; i ++)
} else {
/* A serial EEPROM interface, we read now and sort it out later. */
int sa_offset = 0;
for (i = 0; i < sizeof(ee_data)/2; i++)
/* DEC now has a specification (see Notes) but early board makers
just put the address in the first EEPROM locations. */
/* This does memcmp(eedata, eedata+16, 8) */
for (i = 0; i < 8; i ++)
sa_offset = 20;
}
for (i = 0; i < ETH_ALEN; i ++) {
}
}
/* Lite-On boards have the address byte-swapped. */
for (i = 0; i < ETH_ALEN; i+=2) {
}
for (i = 0; i < ETH_ALEN-1; i++)
}
for (i = 0; i < ETH_ALEN; i++)
/* BugFixes: The 21143-TD hangs with PCI Write-and-Invalidate cycles.
And the ASIX must have a burst limit or horrible things happen. */
}
/* This is logically part of the probe routine, but too complex
to write inline. */
}
/* reset the device and make ready for tx and rx of packets */
/* give the board a chance to reset before returning */
return 1;
}
{
int i;
#ifdef TULIP_DEBUG_WHERE
whereami("start_link\n");
#endif
break;
}
}
/* Find the connected MII xcvrs. */
phy++) {
int to_advert;
if (tp->mii_advertise)
else /* Leave unchanged. */
printf("%s: MII transceiver %d config %hX status %hX advertising %hX.\n",
/* Fixup for DLink with miswired PHY. */
if (mii_advert != to_advert) {
printf("%s: Advertising %hX on PHY %d previously advertising %hX.\n",
}
/* Enable autonegotiation: some boards default to off. */
}
}
printf("%s: ***WARNING***: No MII transceiver found!\n",
}
}
/* Reset the xcvr interface and turn on heartbeat. */
case DC21040:
break;
case DC21041:
/* This is nway_start(). */
if (tp->sym_advertise == 0)
break;
case DC21140: default:
break;
case DC21142:
case PNIC2:
} else
break;
case LC82C168:
}
break;
case MX98713: case COMPEX9881:
break;
break;
case COMET:
/* No initialization necessary. */
break;
}
}
{
#ifdef TULIP_DEBUG_WHERE
whereami("nway_start\n");
#endif
return;
}
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
printf("%s: Restarting internal NWay autonegotiation, %X.\n",
#endif
else
}
{
int i;
#ifdef TULIP_DEBUG_WHERE
whereami("init_media\n");
#endif
/* Allow selecting a default media. */
i = 0;
goto media_picked;
printf("%s: Using user-specified media %s.\n",
goto media_picked;
}
}
printf("%s: Using EEPROM-set media %s.\n",
goto media_picked;
}
}
/* Start sensing first non-full-duplex media. */
;
/* We must reset the media CSRs when we force-select MII mode. */
}
return;
}
case DC21041:
/* tp->nway = 1;*/
break;
case DC21142:
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
printf("%s: Using MII transceiver %d, status %hX.\n",
#endif
} else
break;
case PNIC2:
break;
case LC82C168:
else {
/* Start with 10mbps to do autonegotiation. */
}
break;
case MX98713: case COMPEX9881:
break;
/* Provided by BOLO, Macronix - 12/10/1998. */
break;
case COMET:
break;
break;
default:
}
}
{
#ifdef TULIP_DEBUG_WHERE
whereami("pnic_do_nway\n");
#endif
if (phy_reg & 0x30000000) {
new_csr6 |= 0x00000200;
}
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
printf("%s: PNIC autonegotiated status %X, %s.\n",
#endif
}
}
}
/* Set up the transceiver control registers for the selected media type. */
{
int i;
#ifdef TULIP_DEBUG_WHERE
whereami("select_media\n");
#endif
if (mtable) {
case 0: /* 21140 non-MII xcvr. */
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
printf("%s: Using a 21140 non-MII transceiver"
" with control setting %hhX.\n",
#endif
if (startup)
break;
case 2: case 4: {
for (i = 0; i < 5; i++)
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
printf("%s: Resetting the transceiver.\n",
#endif
for (i = 0; i < rst[0]; i++)
}
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
printf("%s: 21143 non-MII %s transceiver control "
"%hX/%hX.\n",
#endif
if (p[0] & 0x40) { /* SIA (CSR13-15) setup values are provided. */
} else {
csr13val = 1;
csr14val = 0x0003FF7F;
if (startup) {
}
}
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
printf("%s: Setting CSR15 to %X/%X.\n",
#endif
else
new_csr6 = 0x82420000;
break;
}
case 1: case 3: {
int phy_num = p[0];
new_csr6 = 0x020E0000;
if (startup)
for (i = 0; i < reset_length; i++)
for (i = 0; i < init_length; i++)
} else {
if (startup) {
for (i = 0; i < reset_length; i++)
}
for (i = 0; i < init_length; i++)
}
if (startup < 2) {
if (tp->mii_advertise == 0)
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
printf("%s: Advertising %hX on MII %d.\n",
#endif
}
break;
}
default:
printf("%s: Invalid media table selection %d.\n",
new_csr6 = 0x020E0000;
}
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
printf("%s: Using media type %s, CSR12 is %hhX.\n",
#endif
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
printf("%s: 21041 using media %s, CSR12 is %hX.\n",
#endif
new_csr6 = 0x80020000;
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
printf("%s: PNIC PHY status is %hX, media %s.\n",
#endif
new_csr6 = 0x810C0000;
} else if (startup) {
/* Start with 10mbps to do autonegotiation. */
new_csr6 = 0x00420000;
new_csr6 = 0x01860000;
/* Trigger autonegotiation. */
} else {
new_csr6 = 0x00420000;
}
/* Turn on the xcvr interface. */
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
printf("%s: 21040 media type is %s, CSR12 is %hhX.\n",
#endif
new_csr6 = 0x20000;
/* Set the full duplux match frame. */
} else {
}
} else { /* Unknown chip type with no media table. */
if (tp->default_port == 0)
new_csr6 = 0x020E0000;
new_csr6 = 0x028600000;
} else
new_csr6 = 0x038600000;
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
printf("%s: No media description table, assuming "
"%s transceiver, CSR12 %hhX.\n",
#endif
}
return;
}
/*
Check the MII negotiated duplex and change the CSR6 setting if
required.
Return 0 if everything is OK.
Return < 0 if the transceiver is missing or has no link beat.
*/
{
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
printf("%s: MII status %#x, Link partner report "
#endif
if (bmsr == 0xffff)
return -2;
if ((bmsr & 4) == 0) {
if ((new_bmsr & 4) == 0) {
#ifdef TULIP_DEBUG
if (tulip_debug > 1)
printf("%s: No link beat on the MII interface,"
new_bmsr);
#endif
return -1;
}
}
else new_csr6 |= 0x400000;
else new_csr6 &= ~0x200;
#ifdef TULIP_DEBUG
if (tulip_debug > 0)
printf("%s: Setting %s-duplex based on MII"
"#%d link partner capability of %#x.\n",
#endif
return 1;
}
return 0;
}
};
.type = NIC_DRIVER,
.name = "Tulip",
.probe = tulip_probe,
.ids = tulip_nics,
.class = 0,
};