sundance.c revision a734c64bff58bda2fa48c2795453e092167b0ff7
* v1.1 01-01-2003 timlegge Initial implementation * v1.7 04-10-2003 timlegge Transfers Linux Kernel (30 sec) * v1.8 04-13-2003 timlegge Fix multiple transmission bug * v1.9 08-19-2003 timlegge Support Multicast * v1.10 01-17-2004 timlegge Initial driver output cleanup * v1.11 03-21-2004 timlegge Remove unused variables * v1.12 03-21-2004 timlegge Remove excess MII defines * v1.13 03-24-2004 timlegge Update to Linux 2.4.25 driver ****************************************************************************/ * Oracle GPL Disclaimer: For the avoidance of doubt, except that if any license choice * other than GPL or LGPL is available it will apply instead, Oracle elects to use only * the General Public License version 2 (GPLv2) at this time for any software where * a choice of GPL license versions is made available with the language indicating * that GPLv2 or any later version may be used, or where a choice of which version * of the GPL is applied is otherwise unspecified. /* to get some global routines like printf */ /* to get the interface to the body of the program */ /* to get the PCI support functions, if this is a PCI NIC */ /* Condensed operations for readability. */ /* Maximum number of multicast addresses to filter (vs. rx-all-multicast). The sundance uses a 64 element hash table based on the Ethernet CRC. */ // static int multicast_filter_limit = 32; /* Set the copy breakpoint for the copy-only-tiny-frames scheme. Setting to > 1518 effectively disables this feature. This chip can receive into any byte alignment buffers, so word-oriented archs do not need a copy-align of the IP header. */ /* Allow forcing the media type */ /* media[] specifies the media type the NIC operates at. autosense Autosensing active media. 10mbps_hd 10Mbps half duplex. 10mbps_fd 10Mbps full duplex. 100mbps_hd 100Mbps half duplex. 100mbps_fd 100Mbps full duplex. static char media[] =
"autosense";
/* Operational parameters that are set at compile time. */ /* As Etherboot uses a Polling driver we can keep the number of rings to the minimum number required. In general that is 1 transmit and 4 receive receive rings. However some cards require that there be a minimum of 2 rings */ #
define TX_QUEUE_LEN 10 /* Limit ring entries actually used. *//* Operational parameters that usually are not changed. */ /* Time in jiffies before concluding the transmitter is hung. */ /* Offsets to the device registers. Unlike software-only systems, device drivers interact with complex hardware. It's not useful to define symbolic names for every register bit in the device. The name can only partially document the semantics and make the driver longer and more difficult to read. In general, only the important configuration values or bits changed multiple times should be defined symbolically. /* Aliased and bogus values! */ /* Bits in the interrupt status/mask registers. */ /* Bits in the RxMode register. */ /* The Rx and Tx buffer descriptors. Using only 32 bit fields simplifies software endian correction. This structure must be aligned, and should avoid spanning cache lines. /********************************************** * Descriptor Ring and Buffer defination ***********************************************/ /* Define the TX Descriptor */ /* Define the RX Descriptor */ /* Create a static buffer of size PKT_BUF_SZ for each RX and TX descriptor. All descriptors point to a part of this buffer */ /* FIXME: Move BASE to the private structure */ /* Frequently used values */ /* MII tranceiver section */ /* Station Address location within the EEPROM */ DBG (
"%s: Setting %s-duplex based on MII #%d " /************************************************************************** * init_ring - setup the tx and rx descriptors *************************************************************************/ /* Initialize all the Rx descriptors */ /* Mark the last entry as wrapping the ring */ /* We only use one transmit buffer, but two * descriptors so transmit engines have somewhere * to point should they feel the need */ /* This descriptor is never used */ /* Mark the last entry as wrapping the ring, * though this should never happen */ /************************************************************************** * ***********************************************************************/ /* The Tx List Pointer is written as packets are queued */ /* Initialize other registers. */ /* __set_mac_addr(dev); */ if (
sdc->
mtu >
2047)
/* this will never happen with default options */ /* Set the chip to poll every N*30nsec */ /* Fix DFE-580TX packet drop issue */ /* Construct a perfect filter frame with the mac address as first match * and broadcast for all others */ for (i = 0; i <
192; i++)
DBG (
"%s: Done sundance_reset, status: Rx %hX Tx %hX " "MAC Control %hX, %hX %hX\n",
/************************************************************************** ***************************************************************************/ /************************************************************************** ***************************************************************************/ /* return true if there's an ethernet packet ready to read */ /* nic->packet should contain data on return */ /* nic->packetlen should contain length of data */ /* There is a packet ready */ DBG (
"Polling frame_status error\n" );
/* Do we really care about this */ /* FIXME: What should happen Will this ever occur */ printf(
"Poll Error: pkt_len < rx_copybreak");
/************************************************************************** TRANSMIT - Transmit a frame ***************************************************************************/ unsigned int t,
/* Type */ unsigned int s,
/* size */ /* Setup the transmit descriptor */ /* Point to transmit descriptor */ /* Trigger an immediate send */ /************************************************************************** DISABLE - Turn off ethernet interface ***************************************************************************/ /* put the card in its initial state */ /* This function serves 3 purposes. * This disables DMA and interrupts so we don't receive * unexpected packets or interrupts from the card after * etherboot has finished. * This frees resources so etherboot may use * this driver on another interface * This allows etherboot to reinitialize the interface * if something is something goes wrong. /* Stop the Chipchips Tx and Rx Status */ /************************************************************************** PROBE - Look for an adapter, this routine's visible to the outside ***************************************************************************/ /* BASE is used throughout to address the card */ /* Get the MAC Address by reading the EEPROM */ for (i = 0; i <
3; i++) {
/* Update the nic structure with the MAC Address */ /* Set the card as PCI Bus Master */ // sdc->mii_if.dev = pci; // sdc->mii_if.phy_id_mask = 0x1f; // sdc->mii_if.reg_num_mask = 0x1f; /* point to private storage */ /* Print out some hardware info */ DBG (
"%s: %s at ioaddr %hX, ",
sdc->
phys[0] =
1;
/* Default Setting */ printf(
"%s: No MII transceiver found!\n",
/* Parse override configuration */ /* Default 100Mbps Full */ /* The Linux driver uses flow control and resets the link here. This means the mii section from above would need to be re done I believe. Since it serves no real purpose leave it out. */ printf(
"Override speed=%d, %s duplex\n",
/* Reset the chip to erase previous misconfiguration */ * wait for reset to complete * this is heavily inspired by the linux sundance driver * according to the linux driver it can take up to 1ms for the reset DBG(
"sundance: NIC reset did not complete.\n");
/* point to NIC specific routines */ /* Read the EEPROM and MII Management Data I/O (MDIO) interfaces. */ int boguscnt =
10000;
/* Typical 1900 ticks */ /* MII transceiver control section. Read and write the MII registers using software-generated serial MDIO protocol. See the MII specifications or DP83840A data sheet The maximum data clock rate is 2.5 Mhz. The timing is decoupled from the processor clock by flushing the write from the CPU write buffer with a following read, and using PCI /* Generate the preamble required for initial synchronization and a few older transceivers. */ /* Establish sync by sending at least 32 logic ones. */ /* Shift the read command bits out. */ for (i =
15; i >= 0; i--) {
/* Read the two transition, 16 data, and wire-idle bits. */ for (i =
19; i > 0; i--) {
return (
retval >>
1) &
0xffff;
/* Shift the command bits out. */ for (i =
31; i >= 0; i--) {
/* Clear out extra bits. */ for (i =
2; i > 0; i--) {
PCI_ROM(
0x13f0,
0x0201,
"sundance",
"ST201 Sundance 'Alta' based Adaptor", 0),
PCI_ROM(
0x1186,
0x1002,
"dfe530txs",
"D-Link DFE530TXS (Sundance ST201 Alta)", 0),
PCI_ROM(
0x13f0,
0x0200,
"ip100a",
"IC+ IP100A", 0),